From 10c203fb8f51c1538fe7abc40f3b7f06bc38e617 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 7 May 2022 16:15:21 -0400 Subject: [PATCH] Fix generating body multiple times --- NewHorizons/Handlers/PlanetCreationHandler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 11d670cb..a3c7556c 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -166,6 +166,9 @@ namespace NewHorizons.Handlers var sector = go.GetComponentInChildren(); var rb = go.GetAttachedOWRigidbody(); + // Did we already generate the rest of the body + var justUpdateOrbit = go.GetComponent() != null && ExistingAOConfigs.ContainsKey(go.GetComponent()); + // Since orbits are always there just check if they set a semi major axis if (body.Config.Orbit != null && body.Config.Orbit.SemiMajorAxis != 0f) { @@ -177,6 +180,8 @@ namespace NewHorizons.Handlers } } + if (justUpdateOrbit) return go; + if (body.Config.ChildrenToDestroy != null && body.Config.ChildrenToDestroy.Length > 0) { foreach (var child in body.Config.ChildrenToDestroy)