From 3bbf27674ce5a4b0edac69473787b65e5db76657 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 27 Jun 2022 17:39:29 -0400 Subject: [PATCH] Fix null orbit line bug --- NewHorizons/Handlers/PlanetCreationHandler.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index b0b6a019..8ca8f61d 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -534,7 +534,10 @@ namespace NewHorizons.Handlers // Since we destroyed the AO we have to replace links to it in other places newAO.gameObject.GetComponentInChildren()._referenceFrame._attachedAstroObject = newAO; - GameObject.Destroy(go.GetComponentInChildren().gameObject); + // QM and stuff don't have orbit lines + var orbitLine = go.GetComponentInChildren()?.gameObject; + if (orbitLine != null) GameObject.Destroy(orbitLine); + var isMoon = newAO.GetAstroObjectType() == AstroObject.Type.Moon || newAO.GetAstroObjectType() == AstroObject.Type.Satellite; if (body.Config.Orbit.showOrbitLine) OrbitlineBuilder.Make(go, newAO, isMoon, body.Config); @@ -563,7 +566,7 @@ namespace NewHorizons.Handlers { if (childAO is NHAstroObject && ExistingAOConfigs.ContainsKey(childAO)) { - // If it's already and NH object we repeat the whole process else it doesn't work idk + // If it's already an NH object we repeat the whole process else it doesn't work idk NextPassBodies.Add(ExistingAOConfigs[childAO]); } else