From fe8d0888704cdaacd9c98e496557fb3a3f8691f9 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Aug 2023 13:39:38 -0400 Subject: [PATCH] Giants deep killing method --- .../Handlers/PlanetDestructionHandler.cs | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 866e48b4..79a92b2e 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -45,6 +45,7 @@ namespace NewHorizons.Handlers // Since we didn't call RemoveBody on the all planets there are some we have to call here StrangerRemoved(); TimberHearthRemoved(); + GiantsDeepRemoved(); SunRemoved(); } @@ -114,6 +115,17 @@ namespace NewHorizons.Handlers GameObject.Destroy(obj.gameObject); } } + + private static void GiantsDeepRemoved() + { + foreach (var jelly in UnityEngine.Object.FindObjectsOfType()) + { + if (jelly.GetSector().GetRootSector().GetName() == Sector.Name.GiantsDeep) + { + DisableGameObject(jelly.gameObject); + } + } + } #endregion public static void DisableAstroObject(AstroObject ao, List toDisable = null) @@ -157,13 +169,7 @@ namespace NewHorizons.Handlers break; case AstroObject.Name.GiantsDeep: - foreach (var jelly in UnityEngine.Object.FindObjectsOfType()) - { - if (jelly.GetSector().GetRootSector().GetName() == Sector.Name.GiantsDeep) - { - DisableGameObject(jelly.gameObject); - } - } + GiantsDeepRemoved(); break; case AstroObject.Name.TimberHearth: TimberHearthRemoved(); @@ -189,8 +195,14 @@ namespace NewHorizons.Handlers // Some children might be astro objects and as such can have children of their own var childAO = child.GetComponent(); - if (childAO != null) DisableAstroObject(childAO, toDisable); - else DisableGameObject(child); + if (childAO != null) + { + DisableAstroObject(childAO, toDisable); + } + else + { + DisableGameObject(child); + } } // Always delete moons