Fix trifid's star light stuff

This commit is contained in:
Noah Pilarski 2022-09-17 11:11:24 -04:00
parent 01ee3e9ad8
commit cf5e7b42e7
4 changed files with 10 additions and 8 deletions

View File

@ -49,7 +49,7 @@ namespace NewHorizons.Builder.Body
if (_giantMaterial == null) _giantMaterial = new Material(SearchUtilities.Find("Sun_Body").GetComponent<SunController>()._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)

View File

@ -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

View File

@ -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<Light>());
if (light != null) SunLightEffectsController.RemoveStarLight(light);
if (_stellarRemnant != null)
{

View File

@ -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<Light>());
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)