From a447b803076c70f546f3479b64786dd4dd88ff19 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 25 Aug 2022 23:34:41 -0400 Subject: [PATCH] If smaller than 1000 don't explode by default --- NewHorizons/Builder/Body/StellarRemnantBuilder.cs | 13 +++++++++---- NewHorizons/Handlers/PlanetCreationHandler.cs | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs index 30d5d111..331befc1 100644 --- a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs +++ b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs @@ -11,8 +11,15 @@ namespace NewHorizons.Builder.Body { public static class StellarRemnantBuilder { + public const float whiteDwarfSize = 1000; + public const float neutronStarSize = 2000; + public const float blackholeSize = 4000; + public static GameObject Make(GameObject go, OWRigidbody rb, float soi, IModBehaviour mod, NewHorizonsBody star) { + var remnantType = star.Config.Star.stellarRemnantType; + if (remnantType == StellarRemnantType.Default && star.Config.Star.size < whiteDwarfSize) return null; + try { Logger.Log($"Creating stellar remnant for [{star.Config.name}]"); @@ -22,8 +29,6 @@ namespace NewHorizons.Builder.Body sector.gameObject.SetActive(false); - var remnantType = star.Config.Star.stellarRemnantType; - if (remnantType == StellarRemnantType.Default) remnantType = GetDefault(star.Config.Star.size); switch (remnantType) @@ -60,8 +65,8 @@ namespace NewHorizons.Builder.Body private static StellarRemnantType GetDefault(float progenitorSize) { - if (progenitorSize >= 4000) return StellarRemnantType.BlackHole; - else if (2000 < progenitorSize && progenitorSize < 4000) return StellarRemnantType.NeutronStar; + if (progenitorSize >= blackholeSize) return StellarRemnantType.BlackHole; + else if (neutronStarSize < progenitorSize && progenitorSize < blackholeSize) return StellarRemnantType.NeutronStar; else return StellarRemnantType.WhiteDwarf; } diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 15542454..73df7daa 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -511,8 +511,15 @@ namespace NewHorizons.Handlers remnantGO = StellarRemnantBuilder.Make(go, rb, sphereOfInfluence, body.Mod, body); } - remnantGO.SetActive(false); - starEvolutionController.SetStellarRemnant(remnantGO); + if (remnantGO != null) + { + remnantGO.SetActive(false); + starEvolutionController.SetStellarRemnant(remnantGO); + } + else + { + starEvolutionController.willExplode = false; + } } }