diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 96582265..6bf22816 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -277,27 +277,6 @@ namespace NewHorizons.Handlers UpdateBodyOrbit(body, go); } - if (body.Config.removeChildren != null) - { - var goPath = go.transform.GetPath(); - var transforms = go.GetComponentsInChildren(true); - foreach (var childPath in body.Config.removeChildren) - { - // Multiple children can have the same path so we delete all that match - var path = $"{goPath}/{childPath}"; - - var flag = true; - foreach (var childObj in transforms.Where(x => x.GetPath() == path)) - { - flag = false; - // idk why we wait here but we do - Delay.FireInNUpdates(() => childObj.gameObject.SetActive(false), 2); - } - - if (flag) Logger.LogWarning($"Couldn't find \"{childPath}\"."); - } - } - // Do stuff that's shared between generating new planets and updating old ones go = SharedGenerateBody(body, go, sector, rb); @@ -589,6 +568,9 @@ namespace NewHorizons.Handlers SupernovaEffectBuilder.Make(go, sector, body.Config, procGen, ambientLight, fog, atmosphere, null, fog?._fogImpostor); } + // We allow removing children afterwards so you can also take bits off of the modules you used + if (body.Config.removeChildren != null) RemoveChildren(go, body); + return go; } @@ -735,5 +717,26 @@ namespace NewHorizons.Handlers Main.FurthestOrbit = go.transform.position.magnitude + 30000f; } } + + private static void RemoveChildren(GameObject go, NewHorizonsBody body) + { + var goPath = go.transform.GetPath(); + var transforms = go.GetComponentsInChildren(true); + foreach (var childPath in body.Config.removeChildren) + { + // Multiple children can have the same path so we delete all that match + var path = $"{goPath}/{childPath}"; + + var flag = true; + foreach (var childObj in transforms.Where(x => x.GetPath() == path)) + { + flag = false; + // idk why we wait here but we do + Delay.FireInNUpdates(() => childObj.gameObject.SetActive(false), 2); + } + + if (flag) Logger.LogWarning($"Couldn't find \"{childPath}\"."); + } + } } }