Fix generating body multiple times

This commit is contained in:
Nick 2022-05-07 16:15:21 -04:00
parent 18dbbc57b1
commit 10c203fb8f

View File

@ -166,6 +166,9 @@ namespace NewHorizons.Handlers
var sector = go.GetComponentInChildren<Sector>();
var rb = go.GetAttachedOWRigidbody();
// Did we already generate the rest of the body
var justUpdateOrbit = go.GetComponent<NHAstroObject>() != null && ExistingAOConfigs.ContainsKey(go.GetComponent<NHAstroObject>());
// 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)