From cf5e7b42e73f4bd86a619a7d348a853d44085c56 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 17 Sep 2022 11:11:24 -0400 Subject: [PATCH] Fix trifid's star light stuff --- NewHorizons/Builder/Body/StarBuilder.cs | 7 +++++-- NewHorizons/Builder/Body/StellarRemnantBuilder.cs | 2 +- .../Components/SizeControllers/StarEvolutionController.cs | 3 ++- NewHorizons/Handlers/PlanetCreationHandler.cs | 6 ++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 761d2397..d32dba2f 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -49,7 +49,7 @@ namespace NewHorizons.Builder.Body if (_giantMaterial == null) _giantMaterial = new Material(SearchUtilities.Find("Sun_Body").GetComponent()._endSurfaceMaterial).DontDestroyOnLoad(); } - public static (GameObject, StarController, StarEvolutionController) Make(GameObject planetGO, Sector sector, StarModule starModule, IModBehaviour mod, bool isStellarRemnant) + public static (GameObject, StarController, StarEvolutionController, Light) Make(GameObject planetGO, Sector sector, StarModule starModule, IModBehaviour mod, bool isStellarRemnant) { InitPrefabs(); @@ -158,6 +158,8 @@ namespace NewHorizons.Builder.Body light.intensity *= starModule.solarLuminosity; light.range = starModule.lightRadius; + sunLight.name = "StarLight"; + Color lightColour = light.color; if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor(); @@ -190,6 +192,7 @@ namespace NewHorizons.Builder.Body starEvolutionController.atmosphere = sunAtmosphere; starEvolutionController.controller = starController; + starEvolutionController.light = light; starEvolutionController.supernovaColour = starModule.supernovaTint; starFluidVolume.SetStarEvolutionController(starEvolutionController); @@ -212,7 +215,7 @@ namespace NewHorizons.Builder.Body starGO.SetActive(true); - return (starGO, starController, starEvolutionController); + return (starGO, starController, starEvolutionController, light); } public static (GameObject, Renderer, Renderer) MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod, bool isStellarRemnant) diff --git a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs index 6e06c5dc..5b6a68cd 100644 --- a/NewHorizons/Builder/Body/StellarRemnantBuilder.cs +++ b/NewHorizons/Builder/Body/StellarRemnantBuilder.cs @@ -108,7 +108,7 @@ namespace NewHorizons.Builder.Body // Instead of showing the typical star surface we use a tinted singularity GameObject neutronStar; if (proxy != null) neutronStar = StarBuilder.MakeStarProxy(planetGO, proxy, neutronStarModule, mod, true).Item1; - else (neutronStar, _, _) = StarBuilder.Make(planetGO, sector, neutronStarModule, mod, true); + else (neutronStar, _, _, _) = StarBuilder.Make(planetGO, sector, neutronStarModule, mod, true); neutronStar.FindChild("Surface").SetActive(false); // Modify solar flares diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 77289286..753eb85c 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -26,6 +26,7 @@ namespace NewHorizons.Components.SizeControllers public MColor supernovaColour; public Texture normalRamp; public Texture collapseRamp; + public Light light; private Color _startColour; private Color _endColour; @@ -303,7 +304,7 @@ namespace NewHorizons.Components.SizeControllers private void DisableStar(bool start = false) { if (controller != null) SunLightEffectsController.RemoveStar(controller); - if (!isProxy) SunLightEffectsController.RemoveStarLight(gameObject.FindChild("SunLight").GetComponent()); + if (light != null) SunLightEffectsController.RemoveStarLight(light); if (_stellarRemnant != null) { diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 65771442..783c80e6 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -514,12 +514,10 @@ namespace NewHorizons.Handlers if (body.Config.Star != null) { - var (star, starController, starEvolutionController) = StarBuilder.Make(go, sector, body.Config.Star, body.Mod, body.Config.isStellarRemnant); + var (star, starController, starEvolutionController, starLight) = StarBuilder.Make(go, sector, body.Config.Star, body.Mod, body.Config.isStellarRemnant); if (starController != null) SunLightEffectsController.AddStar(starController); - - var starLight = star.FindChild("SunLight"); - if (starLight != null) SunLightEffectsController.AddStarLight(starLight.GetComponent()); + if (starLight != null) SunLightEffectsController.AddStarLight(starLight); // If it has an evolution controller that means it will die -> we make a remnant (unless its a remnant) if (starEvolutionController != null && !body.Config.isStellarRemnant)