Skip to content

Commit

Permalink
v1.8.6 (#503)
Browse files Browse the repository at this point in the history
NOTE: CommonResources is now marked as an incompatible mod.

## Minor features
- Added `solarSystemVolume` and `creditsVolume` to the `Volumes` module.
Lets you change star system without setting up a black hole, and allows
going straight to the fast, final, or kazoo credits scenes.

## Improvements
- Ghost matter from detail props and from HazardVolumes now should be
deactivated when going underwater.
- Improved support for Discord Rich Presence
- Water, sand, and lava will appear on title screen planets

## Bug fixes
- Fixed funnels not working when the planet had no primary
  • Loading branch information
JohnCorby committed Jan 23, 2023
2 parents 84aebf8 + c382e90 commit bb2dcb4
Show file tree
Hide file tree
Showing 18 changed files with 380 additions and 36 deletions.
10 changes: 7 additions & 3 deletions NewHorizons/Builder/Body/FunnelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.Components.Orbital;

namespace NewHorizons.Builder.Body
{
Expand Down Expand Up @@ -34,7 +35,7 @@ internal static void InitPrefabs()
if (_lavaMaterial == null) _lavaMaterial = new Material(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().sharedMaterial).DontDestroyOnLoad();
}

public static void Make(GameObject planetGO, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rigidbody, FunnelModule module)
{
InitPrefabs();

Expand All @@ -55,7 +56,7 @@ public static void Make(GameObject planetGO, ConstantForceDetector detector, OWR
var detectorGO = new GameObject("Detector_Funnel");
detectorGO.transform.parent = funnelGO.transform;
var funnelDetector = detectorGO.AddComponent<ConstantForceDetector>();
funnelDetector._inheritDetector = detector;
funnelDetector._inheritDetector = planetGO.GetComponentInChildren<ConstantForceDetector>();
funnelDetector._detectableFields = new ForceVolume[0];

detectorGO.AddComponent<ForceApplier>();
Expand Down Expand Up @@ -165,7 +166,10 @@ public static void Make(GameObject planetGO, ConstantForceDetector detector, OWR
break;
}

var sector = planetGO.GetComponent<AstroObject>().GetPrimaryBody().GetRootSector();
// We take the sector of the binary focal point if it exists for this funnel (like with the twins)
var primaryBody = planetGO.GetComponent<AstroObject>().GetPrimaryBody();
if (primaryBody?.GetComponent<BinaryFocalPoint>() != null) sector = primaryBody.GetRootSector();

proxyGO.GetComponent<SectorProxy>().SetSector(sector);
geoGO.GetComponent<SectorCullGroup>().SetSector(sector);
volumesGO.GetComponent<SectorCollisionGroup>().SetSector(sector);
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/Builder/Body/SingularityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam
if (hasDestructionVolume) destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>();
else if (targetStarSystem != null)
{
var wormholeVolume = destructionVolumeGO.AddComponent<ChangeStarSystemVolume>();
var wormholeVolume = destructionVolumeGO.AddComponent<BlackHoleWarpVolume>();
wormholeVolume.TargetSolarSystem = targetStarSystem;
}
}
Expand Down
4 changes: 3 additions & 1 deletion NewHorizons/Builder/Body/WaterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal static void InitPrefabs()
if (_oceanAmbientLight == null) _oceanAmbientLight = SearchUtilities.Find("Ocean_GD").GetComponent<OceanLODController>()._ambientLight.gameObject.InstantiateInactive().Rename("OceanAmbientLight").DontDestroyOnLoad();
}

public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module)
public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module)
{
InitPrefabs();

Expand Down Expand Up @@ -148,6 +148,8 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, Wate

waterGO.transform.position = planetGO.transform.position;
waterGO.SetActive(true);

return fluidVolume;
}
}
}
8 changes: 8 additions & 0 deletions NewHorizons/Builder/Props/DetailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ private static void FixComponent(Component component, GameObject planetGO)
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
}

if (component is DarkMatterSubmergeController submergeController)
{
var water = planetGO.GetComponentsInChildren<RadialFluidVolume>().FirstOrDefault(x => x._fluidType == FluidVolume.Type.WATER);
// dont use SetDetectableFluid here because Awake hasn't been called yet
if (submergeController._fluidDetector)
submergeController._fluidDetector._onlyDetectableFluid = water;
}

// Fix anglerfish speed on orbiting planets
if (component is AnglerfishController angler)
{
Expand Down
18 changes: 18 additions & 0 deletions NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using UnityEngine;

namespace NewHorizons.Builder.Volumes
{
internal static class ChangeStarSystemVolumeBuilder
{
public static WarpVolume Make(GameObject planetGO, Sector sector, VolumesModule.ChangeStarSystemVolumeInfo info)
{
var volume = VolumeBuilder.Make<WarpVolume>(planetGO, sector, info);

volume.TargetSolarSystem = info.targetStarSystem;

return volume;
}
}
}
18 changes: 18 additions & 0 deletions NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using UnityEngine;

namespace NewHorizons.Builder.Volumes
{
internal static class CreditsVolumeBuilder
{
public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, VolumesModule.LoadCreditsVolumeInfo info)
{
var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info);

volume.creditsType = info.creditsType;

return volume;
}
}
}
18 changes: 18 additions & 0 deletions NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody
var visorFrostEffectVolume = go.AddComponent<VisorFrostEffectVolume>();
visorFrostEffectVolume._frostRate = 0.5f;
visorFrostEffectVolume._maxFrost = 0.91f;

var water = planetGO.GetComponentsInChildren<RadialFluidVolume>().FirstOrDefault(x => x._fluidType == FluidVolume.Type.WATER);
if (water != null)
{
var submerge = go.AddComponent<DarkMatterSubmergeController>();
submerge._activeWhenSubmerged = false;
submerge._effectVolumes = new EffectVolume[] { hazardVolume, visorFrostEffectVolume };
// THERE ARE NO RENDERERS??? RUH ROH!!!

var detectorGO = new GameObject("ConstantFluidDetector");
detectorGO.transform.parent = go.transform;
detectorGO.transform.localPosition = Vector3.zero;
detectorGO.layer = LayerMask.NameToLayer("BasicDetector");
var detector = detectorGO.AddComponent<ConstantFluidDetector>();
detector.SetDetectableFluid(water);

submerge._fluidDetector = detector;
}
}
else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.ELECTRICITY)
{
Expand Down
14 changes: 14 additions & 0 deletions NewHorizons/Builder/Volumes/VolumesBuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Pl
VolumeBuilder.Make<LightlessLightSourceVolume>(go, sector, lightSourceVolume);
}
}
if (config.Volumes.solarSystemVolume != null)
{
foreach (var solarSystemVolume in config.Volumes.solarSystemVolume)
{
ChangeStarSystemVolumeBuilder.Make(go, sector, solarSystemVolume);
}
}
if (config.Volumes.creditsVolume != null)
{
foreach (var creditsVolume in config.Volumes.creditsVolume)
{
CreditsVolumeBuilder.Make(go, sector, creditsVolume);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace NewHorizons.Components.Volumes
namespace NewHorizons.Components.Volumes
{
public class ChangeStarSystemVolume : BlackHoleDestructionVolume
public class BlackHoleWarpVolume : BlackHoleDestructionVolume
{
public string TargetSolarSystem { get; set; }

Expand Down
35 changes: 35 additions & 0 deletions NewHorizons/Components/Volumes/LoadCreditsVolume.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NewHorizons.External.Modules;
using UnityEngine;

namespace NewHorizons.Components.Volumes
{
internal class LoadCreditsVolume : BaseVolume
{
public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast;

public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
switch(creditsType)
{
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast:
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final:
LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo:
TimelineObliterationController.s_hasRealityEnded = true;
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
}
}
}

public override void OnTriggerVolumeExit(GameObject hitObj)
{

}
}
}
31 changes: 31 additions & 0 deletions NewHorizons/Components/Volumes/WarpVolume.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NewHorizons.External.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace NewHorizons.Components.Volumes
{
internal class WarpVolume : BaseVolume
{
public string TargetSolarSystem;

public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
if (Main.Instance.CurrentStarSystem != TargetSolarSystem) // Otherwise it really breaks idk why
{
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
}
}
}

public override void OnTriggerVolumeExit(GameObject hitObj)
{

}
}
}
37 changes: 37 additions & 0 deletions NewHorizons/External/Modules/VolumesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ public class VolumesModule
/// </summary>
public PriorityVolumeInfo[] zeroGravityVolumes;

/// <summary>
/// Entering this volume will load a new solar system.
/// </summary>
public ChangeStarSystemVolumeInfo[] solarSystemVolume;

/// <summary>
/// Enter this volume to be sent to the end credits scene
/// </summary>
public LoadCreditsVolumeInfo[] creditsVolume;

[JsonObject]
public class VolumeInfo
{
Expand Down Expand Up @@ -136,6 +146,33 @@ public class VolumeInfo
public string rename;
}

[JsonObject]
public class ChangeStarSystemVolumeInfo : VolumeInfo
{
/// <summary>
/// The star system that entering this volume will send you to.
/// </summary>
[DefaultValue("SolarSystem")]
public string targetStarSystem;
}

[JsonObject]
public class LoadCreditsVolumeInfo : VolumeInfo
{
[JsonConverter(typeof(StringEnumConverter))]
public enum CreditsType
{
[EnumMember(Value = @"fast")] Fast = 0,

[EnumMember(Value = @"final")] Final = 1,

[EnumMember(Value = @"kazoo")] Kazoo = 2
}

[DefaultValue("fast")]
public CreditsType creditsType = CreditsType.Fast;
}

[JsonObject]
public class PriorityVolumeInfo : VolumeInfo
{
Expand Down
4 changes: 2 additions & 2 deletions NewHorizons/Handlers/PlanetCreationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public static GameObject GenerateStandardBody(NewHorizonsBody body, bool default
});
}

RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector);
RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector, body.Config.Star != null, body.Config.Atmosphere != null);

Logger.LogVerbose($"Finished creating [{body.Config.name}]");

Expand Down Expand Up @@ -638,7 +638,7 @@ private static GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go

if (body.Config.Funnel != null)
{
FunnelBuilder.Make(go, go.GetComponentInChildren<ConstantForceDetector>(), rb, body.Config.Funnel);
FunnelBuilder.Make(go, sector, rb, body.Config.Funnel);
}

// Has to go last probably
Expand Down
Loading

0 comments on commit bb2dcb4

Please sign in to comment.