From 565a0575b8d56916230302a365f8a3a181073fc1 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 21:04:00 -0400 Subject: [PATCH 01/10] Cache details used on the eye --- NewHorizons/Handlers/EyeDetailCacher.cs | 39 +++++++++++++++++++++++++ NewHorizons/Main.cs | 2 ++ NewHorizons/Utility/SearchUtilities.cs | 8 +++++ 3 files changed, 49 insertions(+) create mode 100644 NewHorizons/Handlers/EyeDetailCacher.cs diff --git a/NewHorizons/Handlers/EyeDetailCacher.cs b/NewHorizons/Handlers/EyeDetailCacher.cs new file mode 100644 index 000000000..6e9faef60 --- /dev/null +++ b/NewHorizons/Handlers/EyeDetailCacher.cs @@ -0,0 +1,39 @@ +using NewHorizons.Utility; +using NewHorizons.Utility.OWML; +using System.Linq; + +namespace NewHorizons.Handlers; + +public static class EyeDetailCacher +{ + public static void Init() + { + foreach (var body in Main.BodyDict["EyeOfTheUniverse"]) + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {body.Config.name}"); + if (body.Config?.Props?.details == null) continue; + + foreach (var detail in body.Config.Props.details) + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {detail.path}"); + + + if (string.IsNullOrEmpty(detail.path)) continue; + + var planet = detail.path.Contains('/') ? detail.path.Split('/').First() : string.Empty; + + // TODO: what other root paths can we ignore + if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body") + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {detail.path}"); + var obj = SearchUtilities.Find(detail.path); + if (obj != null) + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Added solar system asset to dont destroy on load cache for eye: {detail.path}"); + SearchUtilities.AddToDontDestroyOnLoadCache(detail.path, obj); + } + } + } + } + } +} diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 3b38bd350..ec0325ea6 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -341,6 +341,8 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { try { + EyeDetailCacher.Init(); + AtmosphereBuilder.InitPrefabs(); BrambleDimensionBuilder.InitPrefabs(); BrambleNodeBuilder.InitPrefabs(); diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 9ed77826b..4bd0ca445 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -9,9 +9,15 @@ namespace NewHorizons.Utility { public static class SearchUtilities { + private static readonly Dictionary DontDestroyOnLoadCachedGameObjects = new Dictionary(); private static readonly Dictionary CachedGameObjects = new Dictionary(); private static readonly Dictionary CachedRootGameObjects = new Dictionary(); + public static void AddToDontDestroyOnLoadCache(string path, GameObject go) + { + DontDestroyOnLoadCachedGameObjects[path] = go.InstantiateInactive().DontDestroyOnLoad(); + } + public static void ClearCache() { NHLogger.LogVerbose("Clearing search cache"); @@ -96,6 +102,8 @@ public static string GetPath(this Transform current) /// public static GameObject Find(string path, bool warn = true) { + if (DontDestroyOnLoadCachedGameObjects.TryGetValue(path, out var gameObject)) return gameObject; + if (CachedGameObjects.TryGetValue(path, out var go)) return go; // 1: normal find From 3530057a50ab94b1212a4d9b43077019a3bcb8c4 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 21:16:18 -0400 Subject: [PATCH 02/10] Fix an ernesto nre in the eye --- NewHorizons/Builder/Props/DetailBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index cdbcd8f46..3d14ad07a 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -446,7 +446,7 @@ public void Start() angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended; angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended; } - angler.enabled = true; + angler.enabled = false; angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking); Destroy(this); From f4bc2f1aa77010921b521daf7f4a17450f9ec397 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 15 Jun 2024 02:40:52 -0400 Subject: [PATCH 03/10] Add vessel to eye children --- NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs b/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs index c20aa7b6f..9e3a8a01d 100644 --- a/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs +++ b/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs @@ -164,6 +164,9 @@ public static GameObject[] GetChildren(AstroObject primary) .Select(x => x.gameObject) .Where(x => x.name == "SS_Debris_Body")); break; + case AstroObject.Name.Eye: + otherChildren.Add(SearchUtilities.Find("Vessel_Body")); + break; // Just in case GetChildren runs before sun station's name is changed case AstroObject.Name.CustomString: if (primary._customName.Equals("Sun Station")) From 67ef92772563a1a36116087d5238988a6db527f1 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 22:30:40 -0400 Subject: [PATCH 04/10] Don't cache guys continuously forever, make reload configs work at eye --- NewHorizons/Handlers/EyeDetailCacher.cs | 9 ++++++++- NewHorizons/Main.cs | 3 ++- NewHorizons/Utility/DebugTools/DebugReload.cs | 16 ++++++++++++++-- NewHorizons/Utility/SearchUtilities.cs | 9 +++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Handlers/EyeDetailCacher.cs b/NewHorizons/Handlers/EyeDetailCacher.cs index 6e9faef60..289e5cba2 100644 --- a/NewHorizons/Handlers/EyeDetailCacher.cs +++ b/NewHorizons/Handlers/EyeDetailCacher.cs @@ -6,8 +6,16 @@ namespace NewHorizons.Handlers; public static class EyeDetailCacher { + public static bool IsInitialized; + public static void Init() { + if (IsInitialized) return; + + SearchUtilities.ClearDontDestroyOnLoadCache(); + + IsInitialized = true; + foreach (var body in Main.BodyDict["EyeOfTheUniverse"]) { NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {body.Config.name}"); @@ -17,7 +25,6 @@ public static void Init() { NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {detail.path}"); - if (string.IsNullOrEmpty(detail.path)) continue; var planet = detail.path.Contains('/') ? detail.path.Split('/').First() : string.Empty; diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index ec0325ea6..4df680c9e 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -969,7 +969,8 @@ public void ChangeCurrentStarSystem(string newStarSystem, bool warp = false, boo } else { - PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye + if (!IsWarpingBackToEye) + PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye if (SystemDict[CurrentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed(); else SecondsElapsedInLoop = -1; diff --git a/NewHorizons/Utility/DebugTools/DebugReload.cs b/NewHorizons/Utility/DebugTools/DebugReload.cs index 09e283d24..bfadfa05d 100644 --- a/NewHorizons/Utility/DebugTools/DebugReload.cs +++ b/NewHorizons/Utility/DebugTools/DebugReload.cs @@ -43,10 +43,22 @@ private static void ReloadConfigs() NHLogger.LogWarning("Error While Reloading"); } + Main.Instance.ForceClearCaches = true; + + SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent().OnSkipToNextTimeLoop(); - Main.Instance.ForceClearCaches = true; - Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel); + if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") + { + PlayerData._currentGameSave.warpedToTheEye = true; + Main.Instance.IsWarpingBackToEye = true; + EyeDetailCacher.IsInitialized = false; + Main.Instance.ChangeCurrentStarSystem("SolarSystem"); + } + else + { + Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel); + } Main.SecondsElapsedInLoop = -1f; } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 4bd0ca445..36e656e69 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -18,6 +18,15 @@ public static void AddToDontDestroyOnLoadCache(string path, GameObject go) DontDestroyOnLoadCachedGameObjects[path] = go.InstantiateInactive().DontDestroyOnLoad(); } + public static void ClearDontDestroyOnLoadCache() + { + foreach (var go in DontDestroyOnLoadCachedGameObjects.Values) + { + GameObject.Destroy(go); + } + DontDestroyOnLoadCachedGameObjects.Clear(); + } + public static void ClearCache() { NHLogger.LogVerbose("Clearing search cache"); From 804665b3a9010cf5d46ae713780927608ad98c98 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 22:33:20 -0400 Subject: [PATCH 05/10] Ignore asset bundle guys, remove unneeded comment, comment angler stuff --- NewHorizons/Builder/Props/DetailBuilder.cs | 3 ++- NewHorizons/Handlers/EyeDetailCacher.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 3d14ad07a..5700ced2e 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -438,7 +438,7 @@ public void Start() NHLogger.LogVerbose("Fixing anglerfish animation"); - // Remove any event reference to its angler + // Remove any event reference to its angler so that they dont change its state if (angler._anglerfishController) { angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState; @@ -446,6 +446,7 @@ public void Start() angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended; angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended; } + // Disable the angler anim controller because we don't want Update or LateUpdate to run, just need it to set the initial Animator state angler.enabled = false; angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking); diff --git a/NewHorizons/Handlers/EyeDetailCacher.cs b/NewHorizons/Handlers/EyeDetailCacher.cs index 289e5cba2..422e74d3a 100644 --- a/NewHorizons/Handlers/EyeDetailCacher.cs +++ b/NewHorizons/Handlers/EyeDetailCacher.cs @@ -25,11 +25,11 @@ public static void Init() { NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {detail.path}"); + if (!string.IsNullOrEmpty(detail.assetBundle)) continue; if (string.IsNullOrEmpty(detail.path)) continue; var planet = detail.path.Contains('/') ? detail.path.Split('/').First() : string.Empty; - // TODO: what other root paths can we ignore if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body") { NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {detail.path}"); From aaa21aa3bacc4ccc5558217af5ffe42d939c44e3 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 22:48:13 -0400 Subject: [PATCH 06/10] Make scatter work too and dont set warpedToEye since its unneeded --- NewHorizons/Handlers/EyeDetailCacher.cs | 49 +++++++++++++------ NewHorizons/Utility/DebugTools/DebugReload.cs | 1 - 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/NewHorizons/Handlers/EyeDetailCacher.cs b/NewHorizons/Handlers/EyeDetailCacher.cs index 422e74d3a..62dfb4609 100644 --- a/NewHorizons/Handlers/EyeDetailCacher.cs +++ b/NewHorizons/Handlers/EyeDetailCacher.cs @@ -19,28 +19,45 @@ public static void Init() foreach (var body in Main.BodyDict["EyeOfTheUniverse"]) { NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {body.Config.name}"); - if (body.Config?.Props?.details == null) continue; - - foreach (var detail in body.Config.Props.details) + if (body.Config?.Props?.details != null) { - NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {detail.path}"); - - if (!string.IsNullOrEmpty(detail.assetBundle)) continue; - if (string.IsNullOrEmpty(detail.path)) continue; + foreach (var detail in body.Config.Props.details) + { + if (!string.IsNullOrEmpty(detail.assetBundle)) continue; - var planet = detail.path.Contains('/') ? detail.path.Split('/').First() : string.Empty; + AddPathToCache(detail.path); + } + } - if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body") + if (body.Config?.Props?.scatter != null) + { + foreach (var scatter in body.Config.Props.scatter) { - NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {detail.path}"); - var obj = SearchUtilities.Find(detail.path); - if (obj != null) - { - NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Added solar system asset to dont destroy on load cache for eye: {detail.path}"); - SearchUtilities.AddToDontDestroyOnLoadCache(detail.path, obj); - } + if (!string.IsNullOrEmpty(scatter.assetBundle)) continue; + + AddPathToCache(scatter.path); } } } } + + private static void AddPathToCache(string path) + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {path}"); + + if (string.IsNullOrEmpty(path)) return; + + var planet = path.Contains('/') ? path.Split('/').First() : string.Empty; + + if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body") + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {path}"); + var obj = SearchUtilities.Find(path); + if (obj != null) + { + NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Added solar system asset to dont destroy on load cache for eye: {path}"); + SearchUtilities.AddToDontDestroyOnLoadCache(path, obj); + } + } + } } diff --git a/NewHorizons/Utility/DebugTools/DebugReload.cs b/NewHorizons/Utility/DebugTools/DebugReload.cs index bfadfa05d..97a40178f 100644 --- a/NewHorizons/Utility/DebugTools/DebugReload.cs +++ b/NewHorizons/Utility/DebugTools/DebugReload.cs @@ -50,7 +50,6 @@ private static void ReloadConfigs() if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") { - PlayerData._currentGameSave.warpedToTheEye = true; Main.Instance.IsWarpingBackToEye = true; EyeDetailCacher.IsInitialized = false; Main.Instance.ChangeCurrentStarSystem("SolarSystem"); From 61f5f5e64f7f9a84e2e9ffac0811f7d9612afd03 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 19 Jun 2024 14:52:44 -0700 Subject: [PATCH 07/10] possibly fix lantern petals --- NewHorizons/Builder/Props/DetailBuilder.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 5700ced2e..b06f62ef4 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -159,6 +159,12 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, G DialogueBuilder.HandleUnityCreatedDialogue(dialogue); } + // copied details need their lanterns fixed + if (!isFromAssetBundle && component is DreamLanternController lantern) + { + lantern.gameObject.AddComponent(); + } + FixComponent(component, go, detail.ignoreSun); } catch(Exception e) @@ -501,5 +507,32 @@ public void Start() Destroy(this); } } + + /// + /// need component here to run after DreamLanternController.Awake + /// + [RequireComponent(typeof(DreamLanternController))] + private class DreamLanternControllerFixer : MonoBehaviour + { + private void Start() + { + // based on https://github.com/Bwc9876/OW-Amogus/blob/master/Amogus/LanternCreator.cs + // needed to fix petals looking backwards, among other things + + var lantern = GetComponent(); + // SearchUtilities caches so its fine + var sourceLantern = SearchUtilities + .Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_ArtifactHouse_Zone1/Interactibles_ArtifactHouse_Zone1/Prefab_IP_DreamLanternItem_2 (1)") + .GetComponent(); + + // this is set in Awake, we wanna override it + lantern._origLensFlareBrightness = sourceLantern._lensFlare.brightness; + lantern._focuserPetalsBaseEulerAngles = sourceLantern._focuserPetalsBaseEulerAngles; + lantern._concealerRootsBaseScale = sourceLantern._concealerRootsBaseScale; + lantern._concealerCoversStartPos = sourceLantern._concealerCoversStartPos; + + Destroy(this); + } + } } } From e2fbd48289d833cb11c452b1e7d2ad803b3aeb55 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 19 Jun 2024 15:03:06 -0700 Subject: [PATCH 08/10] gotta update visuals --- NewHorizons/Builder/Props/DetailBuilder.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index b06f62ef4..1def5cd9e 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -528,8 +528,11 @@ private void Start() // this is set in Awake, we wanna override it lantern._origLensFlareBrightness = sourceLantern._lensFlare.brightness; lantern._focuserPetalsBaseEulerAngles = sourceLantern._focuserPetalsBaseEulerAngles; + lantern._dirtyFlag_focus = true; lantern._concealerRootsBaseScale = sourceLantern._concealerRootsBaseScale; lantern._concealerCoversStartPos = sourceLantern._concealerCoversStartPos; + lantern._dirtyFlag_concealment = true; + lantern.UpdateVisuals(); Destroy(this); } From a32ba6fbd1c4729557402618b219d5316e03c6e4 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 20 Jun 2024 00:05:07 -0400 Subject: [PATCH 09/10] Manually copy the lantern values in so that it works at the eye --- NewHorizons/Builder/Props/DetailBuilder.cs | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 1def5cd9e..89d0887b1 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -520,17 +520,35 @@ private void Start() // needed to fix petals looking backwards, among other things var lantern = GetComponent(); - // SearchUtilities caches so its fine - var sourceLantern = SearchUtilities - .Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_ArtifactHouse_Zone1/Interactibles_ArtifactHouse_Zone1/Prefab_IP_DreamLanternItem_2 (1)") - .GetComponent(); // this is set in Awake, we wanna override it - lantern._origLensFlareBrightness = sourceLantern._lensFlare.brightness; - lantern._focuserPetalsBaseEulerAngles = sourceLantern._focuserPetalsBaseEulerAngles; + + // Manually copied these values from a artifact lantern so that we don't have to find it (works in Eye) + lantern._origLensFlareBrightness = 0f; + lantern._focuserPetalsBaseEulerAngles = new Vector3[] + { + new Vector3(0.7f, 270.0f, 357.5f), + new Vector3(288.7f, 270.1f, 357.4f), + new Vector3(323.3f, 90.0f, 177.5f), + new Vector3(35.3f, 90.0f, 177.5f), + new Vector3(72.7f, 270.1f, 357.5f) + }; lantern._dirtyFlag_focus = true; - lantern._concealerRootsBaseScale = sourceLantern._concealerRootsBaseScale; - lantern._concealerCoversStartPos = sourceLantern._concealerCoversStartPos; + lantern._concealerRootsBaseScale = new Vector3[] + { + Vector3.one, + Vector3.one, + Vector3.one + }; + lantern._concealerCoversStartPos = new Vector3[] + { + new Vector3(0.0f, 0.0f, 0.0f), + new Vector3(0.0f, -0.1f, 0.0f), + new Vector3(0.0f, -0.2f, 0.0f), + new Vector3(0.0f, 0.2f, 0.0f), + new Vector3(0.0f, 0.1f, 0.0f), + new Vector3(0.0f, 0.0f, 0.0f) + }; lantern._dirtyFlag_concealment = true; lantern.UpdateVisuals(); From 9e00c229c7161cfad5d468671941150349d6b777 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 21 Jun 2024 02:24:00 -0400 Subject: [PATCH 10/10] Bump Version --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 710599427..1d5f963ea 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.22.1", + "version": "1.22.2", "owmlVersion": "2.12.1", "dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "PacificEngine.OW_CommonResources" ],