From 52d20238d6cab6e979ddf76362fd3b3e1a741399 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 23:46:22 -0400 Subject: [PATCH 01/14] Fix default system override logging error on load --- NewHorizons/Main.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index d839410a..e056b4c3 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -907,7 +907,8 @@ namespace NewHorizons } else { - if (!string.IsNullOrEmpty(_defaultSystemOverride)) + // Ignore first load because it doesn't even know what systems we have + if (!_firstLoad && !string.IsNullOrEmpty(_defaultSystemOverride)) { NHLogger.LogError($"The given default system override {_defaultSystemOverride} is invalid - no system exists with that name"); } From 41121fdc2655daab635470f8099b4e5f25560a3e Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 23:47:12 -0400 Subject: [PATCH 02/14] Fix spawning inside cloaks fixes #671 --- NewHorizons/Handlers/PlayerSpawnHandler.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index 8a9eb6f8..d81a3cd6 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -10,11 +10,11 @@ namespace NewHorizons.Handlers { public static void SetUpPlayerSpawn() { - var spawnPoint = Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint; - if (spawnPoint != null) + if (UsingCustomSpawn()) { - SearchUtilities.Find("Player_Body").GetComponent().SetBodyToMatch(spawnPoint.GetAttachedOWRigidbody()); - GetPlayerSpawner().SetInitialSpawnPoint(spawnPoint); + var spawn = GetDefaultSpawn(); + SearchUtilities.Find("Player_Body").GetComponent().SetBodyToMatch(spawn.GetAttachedOWRigidbody()); + GetPlayerSpawner().SetInitialSpawnPoint(spawn); } else { @@ -44,6 +44,13 @@ namespace NewHorizons.Handlers // Arbitrary number, depending on the machine some people die, some people fall through the floor, its very inconsistent Delay.StartCoroutine(SpawnCoroutine(30)); } + + var cloak = GetDefaultSpawn()?.GetAttachedOWRigidbody()?.GetComponentInChildren(); + if (cloak != null) + { + // Ensures it has invoked everything and actually placed the player in the cloaking field + cloak._firstUpdate = true; + } } public static void SpawnShip() From b3327f7ae6719d4aa83b69687f3d997b31d61c1e Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 00:14:45 -0400 Subject: [PATCH 03/14] Fix star size in SunLightParamUpdater --- .../StarEvolutionController.cs | 2 ++ .../Stars/SunLightEffectsController.cs | 27 ++++++++++++------- .../SunPatches/SunLightParamUpdaterPatches.cs | 15 +++++++++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index f67bc42f..ecb273b1 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -454,6 +454,8 @@ namespace NewHorizons.Components.SizeControllers public float GetSupernovaRadius() => supernova.GetSupernovaRadius(); + public float GetSurfaceRadius() => transform.localScale.x; + public float GetMaxSupernovaRadius() => supernovaSize; protected new void FixedUpdate() diff --git a/NewHorizons/Components/Stars/SunLightEffectsController.cs b/NewHorizons/Components/Stars/SunLightEffectsController.cs index 6d26808e..14af0ee9 100644 --- a/NewHorizons/Components/Stars/SunLightEffectsController.cs +++ b/NewHorizons/Components/Stars/SunLightEffectsController.cs @@ -1,4 +1,5 @@ using NewHorizons.Builder.Atmosphere; +using NewHorizons.Components.SizeControllers; using NewHorizons.Utility.OWML; using System.Collections.Generic; using UnityEngine; @@ -17,7 +18,11 @@ namespace NewHorizons.Components.Stars private readonly List _stars = new(); private readonly List _lights = new(); - private StarController _activeStar; + // SunController or StarEvolutionController + public StarEvolutionController ActiveStarEvolutionController { get; private set; } + public SunController ActiveSunController { get; private set; } + + private StarController _activeStarController; private SunLightController _sunLightController; private SunLightParamUpdater _sunLightParamUpdater; @@ -54,7 +59,7 @@ namespace NewHorizons.Components.Stars NHLogger.LogVerbose($"Removing star from list: {star?.gameObject?.name}"); if (Instance._stars.Contains(star)) { - if (Instance._activeStar != null && Instance._activeStar.Equals(star)) + if (Instance._activeStarController != null && Instance._activeStarController.Equals(star)) { Instance._stars.Remove(star); if (Instance._stars.Count > 0) Instance.ChangeActiveStar(Instance._stars[0]); @@ -121,11 +126,11 @@ namespace NewHorizons.Components.Stars if (_stars.Count > 0) { - if (_activeStar == null || !_activeStar.gameObject.activeInHierarchy) + if (_activeStarController == null || !_activeStarController.gameObject.activeInHierarchy) { - if (_stars.Contains(_activeStar)) + if (_stars.Contains(_activeStarController)) { - _stars.Remove(_activeStar); + _stars.Remove(_activeStarController); } if (_stars.Count > 0) @@ -145,8 +150,8 @@ namespace NewHorizons.Components.Stars // Update atmo shaders foreach (var (planet, material) in AtmosphereBuilder.Skys) { - var sqrDist = (planet.transform.position - _activeStar.transform.position).sqrMagnitude; - var intensity = Mathf.Min(_activeStar.Intensity / (sqrDist / hearthSunDistanceSqr), 1f); + var sqrDist = (planet.transform.position - _activeStarController.transform.position).sqrMagnitude; + var intensity = Mathf.Min(_activeStarController.Intensity / (sqrDist / hearthSunDistanceSqr), 1f); material.SetFloat(SunIntensity, intensity); } @@ -156,7 +161,7 @@ namespace NewHorizons.Components.Stars if (star == null) continue; if (!(star.gameObject.activeSelf && star.gameObject.activeInHierarchy)) continue; - if (star.Intensity * (star.transform.position - origin).sqrMagnitude < _activeStar.Intensity * (_activeStar.transform.position - origin).sqrMagnitude) + if (star.Intensity * (star.transform.position - origin).sqrMagnitude < _activeStarController.Intensity * (_activeStarController.transform.position - origin).sqrMagnitude) { ChangeActiveStar(star); break; @@ -170,11 +175,13 @@ namespace NewHorizons.Components.Stars { if (_sunLightController == null || _sunLightParamUpdater == null) return; - if (_activeStar != null) _activeStar.Disable(); + _activeStarController?.Disable(); NHLogger.LogVerbose($"Switching active star: {star.gameObject.name}"); - _activeStar = star; + _activeStarController = star; + ActiveStarEvolutionController = star.GetComponentInChildren(); + ActiveSunController = star.GetComponent(); star.Enable(); diff --git a/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs b/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs index 45d68e3e..8062a9c2 100644 --- a/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs +++ b/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Stars; using UnityEngine; namespace NewHorizons.Patches.SunPatches { @@ -13,10 +14,20 @@ namespace NewHorizons.Patches.SunPatches { Vector3 position = __instance.transform.position; float w = 2000f; - if (__instance._sunController != null) + + var sunController = SunLightEffectsController.Instance.ActiveSunController; + var starEvolutionController = SunLightEffectsController.Instance.ActiveStarEvolutionController; + + if (sunController != null) { - w = __instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius(); + w = sunController.HasSupernovaStarted() ? sunController.GetSupernovaRadius() : sunController.GetSurfaceRadius(); } + // This is an addition in this patch, to work with our stars + else if (starEvolutionController != null) + { + w = starEvolutionController.HasSupernovaStarted() ? starEvolutionController.GetSupernovaRadius() : starEvolutionController.GetSurfaceRadius(); + } + float range = __instance.sunLight.range; Color color = __instance._sunLightController != null ? __instance._sunLightController.sunColor : __instance.sunLight.color; float w2 = __instance._sunLightController != null ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity; From dd08fd70b93b00f938a522d5400e7695f6af6841 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 00:55:03 -0400 Subject: [PATCH 04/14] Delete all non NH proxies probably --- NewHorizons/Handlers/PlanetDestructionHandler.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index e8377893..272dc68e 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; +using NewHorizons.Components; namespace NewHorizons.Handlers { @@ -66,17 +67,20 @@ namespace NewHorizons.Handlers } } - foreach (var proxyBody in GameObject.FindObjectsOfType()) - { - toDisable.Add(proxyBody.gameObject); - } - Delay.FireInNUpdates(() => { foreach (var gameObject in toDisable) { gameObject.SetActive(false); } + // Kill all non nh proxies + foreach (var proxy in GameObject.FindObjectsOfType()) + { + if (proxy is not NHProxy) + { + proxy.gameObject.SetActive(false); + } + } GameObject.FindObjectOfType().gameObject.SetActive(false); // force call update here to make it switch to an active star. idk why we didnt have to do this before From 95af39497c61db51793fe374414191842e70fde5 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 01:51:37 -0400 Subject: [PATCH 05/14] Apparently this doesn't even get called but I DONT CARE --- .../ShipLogEntryLocationPatches.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogEntryLocationPatches.cs diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogEntryLocationPatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogEntryLocationPatches.cs new file mode 100644 index 00000000..956f22c5 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogEntryLocationPatches.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using NewHorizons.Handlers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogEntryLocation))] + public static class ShipLogEntryLocationPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogEntryLocation.OnValidate))] + public static bool ShipLogEntryLocation_OnValidate(ShipLogEntryLocation __instance) + { + // This part is unchanged + if (!__instance._entryID.Equals(string.Empty) && !__instance.gameObject.name.Equals(__instance._entryID)) + { + __instance.gameObject.name = __instance._entryID; + } + + // Base method checks if its on the Ringworld to see if it can be cloaked, we wanna check for a cloak field controller instead + var cloak = __instance.GetComponentInChildren(); + __instance._isWithinCloakField = cloak != null; + return false; + } + } +} From 13c2b8badc3106d61285d46af81c0be650df53db Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 01:54:40 -0400 Subject: [PATCH 06/14] Fix water inside of cloaking fields --- NewHorizons/Builder/Body/WaterBuilder.cs | 12 +++++- .../Volumes/WaterCloakFixerVolume.cs | 42 +++++++++++++++++++ NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 3039d6dd..c525099e 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -5,6 +5,9 @@ using NewHorizons.External.Modules.VariableSize; using Tessellation; using NewHorizons.Utility.OWML; using NewHorizons.Utility.OuterWilds; +using NewHorizons.External.Configs; +using NewHorizons.Components.Volumes; +using System.Linq; namespace NewHorizons.Builder.Body { @@ -41,10 +44,12 @@ namespace NewHorizons.Builder.Body if (_oceanAmbientLight == null) _oceanAmbientLight = SearchUtilities.Find("Ocean_GD").GetComponent()._ambientLight.gameObject.InstantiateInactive().Rename("OceanAmbientLight").DontDestroyOnLoad(); } - public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module) + public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigidbody rb, PlanetConfig config) { InitPrefabs(); + var module = config.Water; + var waterSize = module.size; GameObject waterGO = new GameObject("Water"); @@ -154,6 +159,11 @@ namespace NewHorizons.Builder.Body fogGO.GetComponent().material.SetFloat("_Radius2", 0); } + if (config.Cloak != null) + { + fluidVolume.gameObject.AddComponent().material = TSR.sharedMaterials.First(x => x.name == "Ocean_GD_Surface_mat"); + } + // TODO: fix ruleset making the sand bubble pop up waterGO.transform.position = planetGO.transform.position; diff --git a/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs new file mode 100644 index 00000000..06cbb8c9 --- /dev/null +++ b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace NewHorizons.Components.Volumes +{ + internal class WaterCloakFixerVolume : MonoBehaviour + { + public Material material; + private OWTriggerVolume _volume; + + public void Start() + { + _volume = GetComponent().GetOWTriggerVolume(); + + _volume.OnEntry += WaterCloakFixerVolume_OnEntry; + _volume.OnExit += WaterCloakFixerVolume_OnExit; + + material.renderQueue = 3000; + } + + public void OnDestroy() + { + _volume.OnEntry -= WaterCloakFixerVolume_OnEntry; + _volume.OnExit -= WaterCloakFixerVolume_OnExit; + } + + private void WaterCloakFixerVolume_OnEntry(GameObject hitObj) + { + if (hitObj.CompareTag("PlayerDetector")) + { + material.renderQueue = 2990; + } + } + + private void WaterCloakFixerVolume_OnExit(GameObject hitObj) + { + if (hitObj.CompareTag("PlayerDetector")) + { + material.renderQueue = 3000; + } + } + } +} diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index d15c97a9..85e8dd3c 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -627,7 +627,7 @@ namespace NewHorizons.Handlers if (body.Config.Water != null) { - WaterBuilder.Make(go, sector, rb, body.Config.Water); + WaterBuilder.Make(go, sector, rb, body.Config); } if (body.Config.Sand != null) From e8d7307bb3ad690e5ab4faee928a9f8b97062109 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 12:05:18 -0400 Subject: [PATCH 07/14] Fix sun proxy breaking --- .../Stars/SunLightEffectsController.cs | 3 ++- .../Patches/ProxyPatches/SunProxyPatches.cs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 NewHorizons/Patches/ProxyPatches/SunProxyPatches.cs diff --git a/NewHorizons/Components/Stars/SunLightEffectsController.cs b/NewHorizons/Components/Stars/SunLightEffectsController.cs index 14af0ee9..fe6c3741 100644 --- a/NewHorizons/Components/Stars/SunLightEffectsController.cs +++ b/NewHorizons/Components/Stars/SunLightEffectsController.cs @@ -201,7 +201,8 @@ namespace NewHorizons.Components.Stars transform.localPosition = Vector3.zero; // Some effects use Locator.GetSunTransform so hopefully its fine to change it - Locator._sunTransform = transform; + // Use the root transform of the star because that's the default behaviour, breaks SunProxy is not (potentially others) + Locator._sunTransform = star.transform; // TODO?: maybe also turn off star controller stuff (mainly proxy light) since idk if that can handle more than 1 being on } diff --git a/NewHorizons/Patches/ProxyPatches/SunProxyPatches.cs b/NewHorizons/Patches/ProxyPatches/SunProxyPatches.cs new file mode 100644 index 00000000..48590d22 --- /dev/null +++ b/NewHorizons/Patches/ProxyPatches/SunProxyPatches.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using NewHorizons.Utility; + +namespace NewHorizons.Patches.ProxyPatches +{ + [HarmonyPatch(typeof(SunProxy))] + public static class SunProxyPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(SunProxy.Start))] + public static void SunProxy_Start(SunProxy __instance) + { + // We mess with the Locator.GetSunTransform() value to switch it to other relevant stars since it's used for some other effects + // However if it's set to a different star when the SunProxy starts it breaks, so we double check it here + __instance._sunTransform = SearchUtilities.Find("Sun_Body").transform; + __instance._realSunController = __instance._sunTransform.GetComponent(); + } + } +} From c9ee5ec1ac38a7ad9b5b9c4c7329ec526bf8cace Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 12:32:40 -0400 Subject: [PATCH 08/14] Size the inner warp fog sphere --- NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index bbad4250..990b7c18 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -257,7 +257,9 @@ namespace NewHorizons.Builder.Props // Seed fog works differently, so it doesn't need to be fixed // (it's also located on a different child path, so the below FindChild calls wouldn't work) + // Default size is 70 var fog = brambleNode.FindChild("Effects/InnerWarpFogSphere"); + fog.transform.localScale = Vector3.one * config.scale * 70f; var fogMaterial = fog.GetComponent().material; fogMaterial.SetFloat("_Radius", fogMaterial.GetFloat("_Radius") * config.scale); fogMaterial.SetFloat("_Density", fogMaterial.GetFloat("_Density") / config.scale); From 89480333c88c4fe12ea8e783ef172f4efd00afde Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 23 Aug 2023 12:37:57 -0400 Subject: [PATCH 09/14] Allow changing orbit line distance shown at #225 --- .../Builder/Orbital/OrbitlineBuilder.cs | 14 +++++++----- NewHorizons/External/Modules/OrbitModule.cs | 22 ++++++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index a2ffbab0..ae3aff08 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -61,15 +61,17 @@ namespace NewHorizons.Builder.Orbital var fade = isMoon; - /* - if (config.Base.IsSatellite) + if (config.Orbit.orbitLineFadeStartDistance >= 0) { - if (config.Orbit.Tint != null) color = new Color(0.4082f, 0.516f, 0.4469f, 1f); fade = true; - orbitLine._fadeEndDist = 5000; - orbitLine._fadeStartDist = 3000; + orbitLine._fadeStartDist = config.Orbit.orbitLineFadeStartDistance; + } + + if (config.Orbit.orbitLineFadeEndDistance >= 0) + { + fade = true; + orbitLine._fadeEndDist = config.Orbit.orbitLineFadeEndDistance; } - */ orbitLine._color = color; lineRenderer.endColor = new Color(color.r, color.g, color.b, 0f); diff --git a/NewHorizons/External/Modules/OrbitModule.cs b/NewHorizons/External/Modules/OrbitModule.cs index e3a6a566..bb1325e4 100644 --- a/NewHorizons/External/Modules/OrbitModule.cs +++ b/NewHorizons/External/Modules/OrbitModule.cs @@ -45,6 +45,12 @@ namespace NewHorizons.External.Modules /// public bool isTidallyLocked; + /// + /// Is the body meant to stay in one place without moving? If staticPosition is not set, the initial position + /// will be determined using its orbital parameters. + /// + public bool isStatic; + /// /// If it is tidally locked, this direction will face towards the primary. Ex: Interloper uses `0, -1, 0`. Most planets /// will want something like `-1, 0, 0`. @@ -62,12 +68,6 @@ namespace NewHorizons.External.Modules /// public bool dottedOrbitLine; - /// - /// Is the body meant to stay in one place without moving? If staticPosition is not set, the initial position - /// will be determined using its orbital parameters. - /// - public bool isStatic; - /// /// Colour of the orbit-line in the map view. /// @@ -78,6 +78,16 @@ namespace NewHorizons.External.Modules /// public bool trackingOrbitLine; + /// + /// If the camera is farther than this distance the orbit line will fade out. Leave empty to not have it fade out. + /// + public float orbitLineFadeEndDistance = -1f; + + /// + /// If the camera is closer than this distance the orbit line will fade out. Leave empty to not have it fade out. + /// + public float orbitLineFadeStartDistance = -1f; + /// /// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius. /// From f1292cbfe9540ffe436a5de08d231480c0cce0e1 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 23 Aug 2023 16:40:02 +0000 Subject: [PATCH 10/14] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index ddab910d..c34f9431 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1056,6 +1056,10 @@ "type": "boolean", "description": "Should the body always have one side facing its primary?" }, + "isStatic": { + "type": "boolean", + "description": "Is the body meant to stay in one place without moving? If staticPosition is not set, the initial position\nwill be determined using its orbital parameters." + }, "alignmentAxis": { "description": "If it is tidally locked, this direction will face towards the primary. Ex: Interloper uses `0, -1, 0`. Most planets\nwill want something like `-1, 0, 0`.", "$ref": "#/definitions/MVector3" @@ -1069,10 +1073,6 @@ "type": "boolean", "description": "Should the orbit line be dotted?" }, - "isStatic": { - "type": "boolean", - "description": "Is the body meant to stay in one place without moving? If staticPosition is not set, the initial position\nwill be determined using its orbital parameters." - }, "tint": { "description": "Colour of the orbit-line in the map view.", "$ref": "#/definitions/MColor" @@ -1081,6 +1081,16 @@ "type": "boolean", "description": "Should we just draw a line behind its orbit instead of the entire circle/ellipse?" }, + "orbitLineFadeEndDistance": { + "type": "number", + "description": "If the camera is farther than this distance the orbit line will fade out. Leave empty to not have it fade out.", + "format": "float" + }, + "orbitLineFadeStartDistance": { + "type": "number", + "description": "If the camera is closer than this distance the orbit line will fade out. Leave empty to not have it fade out.", + "format": "float" + }, "semiMajorAxis": { "type": "number", "description": "The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.", From b0eac14fe3403fc5bbec25f81e94e5bee4436d99 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Aug 2023 12:20:10 -0400 Subject: [PATCH 11/14] Fix issues in Intervention (null vessel blackhole, missing null check in detail orb fix) --- NewHorizons/Builder/Props/DetailBuilder.cs | 2 +- .../WarpPatches/VesselWarpControllerPatches.cs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index eeef8d1b..6d4e634e 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -374,7 +374,7 @@ namespace NewHorizons.Builder.Props else if (component is NomaiInterfaceOrb orb) { // detect planet gravity - var gravityVolume = planetGO.GetAttachedOWRigidbody().GetAttachedGravityVolume(); + var gravityVolume = planetGO.GetAttachedOWRigidbody()?.GetAttachedGravityVolume(); orb.GetComponent()._detectableFields = gravityVolume ? new ForceVolume[] { gravityVolume } : new ForceVolume[] { }; } diff --git a/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs index 4676edd4..8089ac89 100644 --- a/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs +++ b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs @@ -29,12 +29,22 @@ namespace NewHorizons.Patches.WarpPatches [HarmonyPatch(nameof(VesselWarpController.CheckSystemActivation))] public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance) { - if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") + // Base method only manages the state of the source warp platform blackhole if the EyeStateManager isn't null + // However we place the vessel into other systems, so we want to handle the state in those locations as well + // For some reason the blackhole can also just be null in which case we ignore all this. Happens in Intervention 1.0.3 + if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" && __instance._sourceWarpPlatform._blackHole != null) { - if (!__instance._sourceWarpPlatform.IsBlackHoleOpen() && __instance._hasPower && __instance._warpPlatformPowerSlot.IsActivated() && __instance._targetWarpPlatform != null) - __instance._sourceWarpPlatform.OpenBlackHole(__instance._targetWarpPlatform, true); - else if (__instance._sourceWarpPlatform.IsBlackHoleOpen() && (!__instance._hasPower || !__instance._warpPlatformPowerSlot.IsActivated())) + var isBlackHoleOpen = __instance._sourceWarpPlatform.IsBlackHoleOpen(); + var shouldBlackHoleBeOpen = __instance._hasPower && __instance._warpPlatformPowerSlot.IsActivated() && __instance._targetWarpPlatform != null; + + if (isBlackHoleOpen && !shouldBlackHoleBeOpen) + { __instance._sourceWarpPlatform.CloseBlackHole(); + } + else if (!isBlackHoleOpen && shouldBlackHoleBeOpen) + { + __instance._sourceWarpPlatform.OpenBlackHole(__instance._targetWarpPlatform, true); + } } } From 0c727fe7ea2cc49da531625eac9c712718f6c2bd Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Aug 2023 12:20:38 -0400 Subject: [PATCH 12/14] Update manifest.json --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 762b1c52..38deebd8 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.14.6", + "version": "1.14.7", "owmlVersion": "2.9.3", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From 6f68750117aec27f07d7eba067979a6cc5ed7a8b Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Aug 2023 12:27:05 -0400 Subject: [PATCH 13/14] Try catch detail fixes --- NewHorizons/Builder/Props/DetailBuilder.cs | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index eeef8d1b..45df3793 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -116,25 +116,33 @@ namespace NewHorizons.Builder.Props foreach (var component in prop.GetComponentsInChildren(true)) { - // Components can come through as null here (yes, really), - // Usually if a script was added to a prefab in an asset bundle but isn't present in the loaded mod DLLs - if (component == null) + // Rather than having the entire prop not exist when a detail fails let's just try-catch and log an error + try { - invalidComponentFound = true; - continue; - } - if (component.gameObject == prop && component is OWItem) isItem = true; + // Components can come through as null here (yes, really), + // Usually if a script was added to a prefab in an asset bundle but isn't present in the loaded mod DLLs + if (component == null) + { + invalidComponentFound = true; + continue; + } + if (component.gameObject == prop && component is OWItem) isItem = true; - if (sector == null) - { - if (FixUnsectoredComponent(component)) continue; - } - else - { - FixSectoredComponent(component, sector, existingSectors, detail.keepLoaded); - } + if (sector == null) + { + if (FixUnsectoredComponent(component)) continue; + } + else + { + FixSectoredComponent(component, sector, existingSectors, detail.keepLoaded); + } - FixComponent(component, go, detail.ignoreSun); + FixComponent(component, go, detail.ignoreSun); + } + catch(Exception e) + { + NHLogger.LogError($"Failed to correct component {component?.GetType()?.Name} on {go?.name} - {e}"); + } } if (detail.path != null) @@ -155,7 +163,7 @@ namespace NewHorizons.Builder.Props } } - // Items shouldn't use these else they get weird + // Items should always be kept loaded else they will vanish in your hand as you leave the sector if (isItem) detail.keepLoaded = true; prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); From 3e23e433f792a2b8349e0037e56f0574b876e27b Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Aug 2023 12:35:32 -0400 Subject: [PATCH 14/14] Fix up comments --- .../Stars/SunLightEffectsController.cs | 2 +- .../Volumes/WaterCloakFixerVolume.cs | 18 +++++++++++++++--- NewHorizons/Handlers/PlayerSpawnHandler.cs | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Components/Stars/SunLightEffectsController.cs b/NewHorizons/Components/Stars/SunLightEffectsController.cs index fe6c3741..b4c42d03 100644 --- a/NewHorizons/Components/Stars/SunLightEffectsController.cs +++ b/NewHorizons/Components/Stars/SunLightEffectsController.cs @@ -201,7 +201,7 @@ namespace NewHorizons.Components.Stars transform.localPosition = Vector3.zero; // Some effects use Locator.GetSunTransform so hopefully its fine to change it - // Use the root transform of the star because that's the default behaviour, breaks SunProxy is not (potentially others) + // Use the root transform of the star because that's the default behaviour, breaks SunProxy if not (potentially others) Locator._sunTransform = star.transform; // TODO?: maybe also turn off star controller stuff (mainly proxy light) since idk if that can handle more than 1 being on diff --git a/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs index 06cbb8c9..d74aaa89 100644 --- a/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs +++ b/NewHorizons/Components/Volumes/WaterCloakFixerVolume.cs @@ -2,11 +2,23 @@ using UnityEngine; namespace NewHorizons.Components.Volumes { + /// + /// A cloak can interfere with the rendering of water + /// Water has a lower render queue and is transparent, so you can see the background black cloak over top of the water + /// We fix this by setting the water's render queue to that of the cloak + /// However, this means that when you are inside the water you will see through the cloak since it's not rendered on top + /// To fix that, we set the render queue back to normal when the player enters the water + /// Currently this doesnt nothing to fix probe camera pictures. If you are outside of the water, the probe will see the stars and through the cloak + /// Oh well + /// internal class WaterCloakFixerVolume : MonoBehaviour { public Material material; private OWTriggerVolume _volume; + public const int WATER_RENDER_QUEUE = 2990; + public const int CLOAK_RENDER_QUEUE = 3000; + public void Start() { _volume = GetComponent().GetOWTriggerVolume(); @@ -14,7 +26,7 @@ namespace NewHorizons.Components.Volumes _volume.OnEntry += WaterCloakFixerVolume_OnEntry; _volume.OnExit += WaterCloakFixerVolume_OnExit; - material.renderQueue = 3000; + material.renderQueue = CLOAK_RENDER_QUEUE; } public void OnDestroy() @@ -27,7 +39,7 @@ namespace NewHorizons.Components.Volumes { if (hitObj.CompareTag("PlayerDetector")) { - material.renderQueue = 2990; + material.renderQueue = WATER_RENDER_QUEUE; } } @@ -35,7 +47,7 @@ namespace NewHorizons.Components.Volumes { if (hitObj.CompareTag("PlayerDetector")) { - material.renderQueue = 3000; + material.renderQueue = CLOAK_RENDER_QUEUE; } } } diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index d81a3cd6..083eff3b 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -48,7 +48,7 @@ namespace NewHorizons.Handlers var cloak = GetDefaultSpawn()?.GetAttachedOWRigidbody()?.GetComponentInChildren(); if (cloak != null) { - // Ensures it has invoked everything and actually placed the player in the cloaking field + // Ensures it has invoked everything and actually placed the player in the cloaking field #671 cloak._firstUpdate = true; } }