From aaa21aa3bacc4ccc5558217af5ffe42d939c44e3 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 18 Jun 2024 22:48:13 -0400 Subject: [PATCH] Make scatter work too and dont set warpedToEye since its unneeded --- NewHorizons/Handlers/EyeDetailCacher.cs | 53 ++++++++++++------- NewHorizons/Utility/DebugTools/DebugReload.cs | 1 - 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/NewHorizons/Handlers/EyeDetailCacher.cs b/NewHorizons/Handlers/EyeDetailCacher.cs index 422e74d3..62dfb460 100644 --- a/NewHorizons/Handlers/EyeDetailCacher.cs +++ b/NewHorizons/Handlers/EyeDetailCacher.cs @@ -19,28 +19,45 @@ public static class EyeDetailCacher 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; - - var planet = detail.path.Contains('/') ? detail.path.Split('/').First() : string.Empty; - - if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body") + foreach (var detail in body.Config.Props.details) { - 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(detail.assetBundle)) continue; + + AddPathToCache(detail.path); + } + } + + if (body.Config?.Props?.scatter != null) + { + foreach (var scatter in body.Config.Props.scatter) + { + 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 bfadfa05..97a40178 100644 --- a/NewHorizons/Utility/DebugTools/DebugReload.cs +++ b/NewHorizons/Utility/DebugTools/DebugReload.cs @@ -50,7 +50,6 @@ namespace NewHorizons.Utility.DebugTools if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") { - PlayerData._currentGameSave.warpedToTheEye = true; Main.Instance.IsWarpingBackToEye = true; EyeDetailCacher.IsInitialized = false; Main.Instance.ChangeCurrentStarSystem("SolarSystem");