From db3785f2f43af3a1f97a652e581aa9741281f8ba Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 16 Jul 2023 16:37:56 -0400 Subject: [PATCH] Revert "Remove stock planets immediately since we use SearchUtility anyway" This reverts commit be9df727565364f85e9a6b5d53d06c2e45651d17. --- NewHorizons/Handlers/PlanetCreationHandler.cs | 4 ++-- NewHorizons/Handlers/PlanetDestructionHandler.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 0379a982..98d55efa 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -32,8 +32,6 @@ namespace NewHorizons.Handlers public static void Init(List bodies) { - if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveStockPlanets(); - Main.FurthestOrbit = 30000; _existingBodyDict = new(); @@ -137,6 +135,8 @@ namespace NewHorizons.Handlers SingularityBuilder.PairAllSingularities(); // Events.FireOnNextUpdate(PlanetDestroyer.RemoveAllProxies); + + if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveStockPlanets(); } public static bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 304881a7..4a752848 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -54,12 +54,19 @@ namespace NewHorizons.Handlers public static void RemoveSolarSystem() { + // Stop the sun from killing the player + var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN"); + sunVolumes.SetActive(false); + foreach (var name in _solarSystemBodies) { var ao = AstroObjectLocator.GetAstroObject(name); - if (ao != null) RemoveBody(ao, false); + if (ao != null) Delay.FireInNUpdates(() => RemoveBody(ao, false), 2); else NHLogger.LogError($"Couldn't find [{name}]"); } + + // Bring the sun back because why not + Delay.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 3); } public static void RemoveEyeOfTheUniverse()