From abfe068cc8ba9bf992a2997f8f22571bd6eec916 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 21 May 2022 23:30:36 -0400 Subject: [PATCH] Waah wah im Idiot and i dont like get component --- .../Components/Orbital/BinaryFocalPoint.cs | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Components/Orbital/BinaryFocalPoint.cs b/NewHorizons/Components/Orbital/BinaryFocalPoint.cs index f1ce6d84..6738a690 100644 --- a/NewHorizons/Components/Orbital/BinaryFocalPoint.cs +++ b/NewHorizons/Components/Orbital/BinaryFocalPoint.cs @@ -19,24 +19,37 @@ namespace NewHorizons.Components.Orbital void Update() { - if (Primary == null || Secondary == null) return; - - // Secondary and primary must have been engulfed by a star - if (!Primary.isActiveAndEnabled && !Secondary.isActiveAndEnabled) + if (Primary == null || Secondary == null) { - ReferenceFrameTracker component = Locator.GetPlayerBody().GetComponent(); - if (component.GetReferenceFrame(true) != null && component.GetReferenceFrame(true).GetOWRigidBody() == gameObject) - { - component.UntargetReferenceFrame(); - } - MapMarker component2 = gameObject.GetComponent(); - if (component2 != null) - { - component2.DisableMarker(); - } + CleanUp(); gameObject.SetActive(false); - FakeMassBody.SetActive(false); } + else + { + // Secondary and primary must have been engulfed by a star + if (!Primary.isActiveAndEnabled && !Secondary.isActiveAndEnabled) + { + CleanUp(); + gameObject.SetActive(false); + } + } + } + + private void CleanUp() + { + ReferenceFrameTracker component = Locator.GetPlayerBody()?.GetComponent(); + if (component?.GetReferenceFrame(true)?.GetOWRigidBody() == gameObject) + { + component.UntargetReferenceFrame(); + } + + MapMarker component2 = gameObject.GetComponent(); + if (component2 != null) + { + component2.DisableMarker(); + } + + FakeMassBody.SetActive(false); } } }