From 93a9d2c40f7634f3bcd2db6b2a883bf280a72c97 Mon Sep 17 00:00:00 2001 From: "Nick J. Connors" Date: Thu, 24 Feb 2022 21:00:29 -0500 Subject: [PATCH] Make stars not do shader stuff if luminosity is 0 --- NewHorizons/Builder/Body/StarBuilder.cs | 20 +++++++++++-------- NewHorizons/Components/StarLightController.cs | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index d1633545..5177a8d9 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -152,14 +152,18 @@ namespace NewHorizons.Builder.Body starGO.transform.localPosition = Vector3.zero; starGO.transform.localScale = starModule.Size * Vector3.one; - var starController = body.AddComponent(); - starController.Light = light; - starController.AmbientLight = ambientLight; - starController.FaceActiveCamera = faceActiveCamera; - starController.CSMTextureCacher = csmTextureCacher; - starController.ProxyShadowLight = proxyShadowLight; - starController.Intensity = starModule.SolarLuminosity; - starController.SunColor = lightColour; + StarController starController = null; + if (starModule.SolarLuminosity != 0) + { + starController = body.AddComponent(); + starController.Light = light; + starController.AmbientLight = ambientLight; + starController.FaceActiveCamera = faceActiveCamera; + starController.CSMTextureCacher = csmTextureCacher; + starController.ProxyShadowLight = proxyShadowLight; + starController.Intensity = starModule.SolarLuminosity; + starController.SunColor = lightColour; + } if (starModule.Curve != null) { diff --git a/NewHorizons/Components/StarLightController.cs b/NewHorizons/Components/StarLightController.cs index 6cb27308..c6943337 100644 --- a/NewHorizons/Components/StarLightController.cs +++ b/NewHorizons/Components/StarLightController.cs @@ -28,6 +28,8 @@ namespace NewHorizons.Utility public void AddStar(StarController star) { + if (star == null) return; + Logger.Log($"Adding new star to list: {star.gameObject.name}"); _stars.Add(star); }