diff --git a/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs b/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs index 204a4402..934b33d5 100644 --- a/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs +++ b/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs @@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body if (_shockLayerMaterial == null) _shockLayerMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Shocklayer_GD").GetComponent().sharedMaterial).Rename("ShockLayer_mat").DontDestroyOnLoad(); } - public static NHSupernovaPlanetEffectController Make(GameObject planetGO, Sector sector, PlanetConfig config, IModBehaviour mod, GameObject procGen, Light ambientLight, PlanetaryFogController fog, LODGroup atmosphere, Renderer atmosphereRenderer, Renderer fogImpostor) + public static NHSupernovaPlanetEffectController Make(GameObject planetGO, Sector sector, PlanetConfig config, IModBehaviour mod, GameObject procGen, Light[] ambientLight, PlanetaryFogController fog, LODGroup atmosphere, Renderer atmosphereRenderer, Renderer fogImpostor) { InitPrefabs(); @@ -41,7 +41,8 @@ namespace NewHorizons.Builder.Body if (currentController._ambientLight == null && ambientLight != null) { currentController._ambientLight = ambientLight; - currentController._ambientLightOrigIntensity = config.Base.ambientLight; + currentController._ambientLightOrigIntensity = new float[ambientLight.Length]; + for (int i = 0; i < ambientLight.Length; i++) currentController._ambientLightOrigIntensity[i] = ambientLight[i].intensity; } if (currentController._atmosphere == null && atmosphere != null) currentController._atmosphere = atmosphere; @@ -57,8 +58,9 @@ namespace NewHorizons.Builder.Body var supernovaController = new GameObject("SupernovaController"); supernovaController.transform.SetParent(sector?.transform ?? planetGO.transform, false); var supernovaEffectController = supernovaController.AddComponent(); - supernovaEffectController._ambientLight = ambientLight; - supernovaEffectController._ambientLightOrigIntensity = config.Base.ambientLight; + currentController._ambientLight = ambientLight; + currentController._ambientLightOrigIntensity = new float[ambientLight.Length]; + for (int i = 0; i < ambientLight.Length; i++) currentController._ambientLightOrigIntensity[i] = ambientLight[i].intensity; if (config.Atmosphere != null && config.Atmosphere.atmosphereSunIntensity != 0) supernovaEffectController._atmosphereOrigSunIntensity = config.Atmosphere.atmosphereSunIntensity; supernovaEffectController._atmosphere = atmosphere; supernovaEffectController._atmosphereRenderer = atmosphereRenderer; @@ -180,8 +182,8 @@ namespace NewHorizons.Builder.Body if (vanillaController._shockLayer != null) vanillaController._shockLayer.gameObject.SetActive(true); var supernovaEffectController = vanillaController.gameObject.GetAddComponent(); supernovaEffectController._atmosphere = vanillaController._atmosphere; - supernovaEffectController._ambientLight = vanillaController._ambientLight; - supernovaEffectController._ambientLightOrigIntensity = vanillaController._ambientLightOrigIntensity; + supernovaEffectController._ambientLight = new Light[] { vanillaController._ambientLight }; + supernovaEffectController._ambientLightOrigIntensity = new float[] { vanillaController._ambientLightOrigIntensity }; supernovaEffectController._atmosphere = vanillaController._atmosphere; supernovaEffectController._fog = vanillaController._fog; supernovaEffectController._fogOrigTint = vanillaController._fogOrigTint; diff --git a/NewHorizons/Components/NHSupernovaPlanetEffectController.cs b/NewHorizons/Components/NHSupernovaPlanetEffectController.cs index 15f8017e..bdf60aa0 100644 --- a/NewHorizons/Components/NHSupernovaPlanetEffectController.cs +++ b/NewHorizons/Components/NHSupernovaPlanetEffectController.cs @@ -10,8 +10,8 @@ namespace NewHorizons.Components { public class NHSupernovaPlanetEffectController : MonoBehaviour { - public Light _ambientLight; - public float _ambientLightOrigIntensity; + public Light[] _ambientLight; + public float[] _ambientLightOrigIntensity; public LODGroup _atmosphere; public Renderer _atmosphereRenderer; public float _atmosphereOrigSunIntensity = 1; @@ -131,7 +131,13 @@ namespace NewHorizons.Components { float collapseProgress = StarEvolutionController.GetCollapseProgress(); - if (_ambientLight != null) _ambientLight.intensity = _ambientLightOrigIntensity * (1f - collapseProgress); + if (_ambientLight != null) + { + for (int i = 0; i < _ambientLight.Length; i++) + { + _ambientLight[i].intensity = _ambientLightOrigIntensity[i] * (1f - collapseProgress); + } + } if (_atmosphere != null) { @@ -181,7 +187,13 @@ namespace NewHorizons.Components { float collapseProgress = SunController.GetCollapseProgress(); - if (_ambientLight != null) _ambientLight.intensity = _ambientLightOrigIntensity * (1f - collapseProgress); + if (_ambientLight != null) + { + for (int i = 0; i < _ambientLight.Length; i++) + { + _ambientLight[i].intensity = _ambientLightOrigIntensity[i] * (1f - collapseProgress); + } + } if (_atmosphere != null) { @@ -212,7 +224,13 @@ namespace NewHorizons.Components { if (_shockLayer != null) _shockLayer.enabled = false; - if (_ambientLight != null) _ambientLight.intensity = _ambientLightOrigIntensity; + if (_ambientLight != null) + { + for (int i = 0; i < _ambientLight.Length; i++) + { + _ambientLight[i].intensity = _ambientLightOrigIntensity[i]; + } + } if (_fog != null) _fog.fogTint = _fogOrigTint; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 875922df..20ca31da 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -291,7 +291,11 @@ namespace NewHorizons.External.Configs radius = Base.cloakRadius }; - if (Base.hasAmbientLight) Base.ambientLight = 0.5f; + if (Base.hasAmbientLight || Base.ambientLight != 0) + { + if (AmbientLights == null) AmbientLights = new AmbientLightModule[0]; + AmbientLights = AmbientLights.Append(new AmbientLightModule { intensity = Base.ambientLight != 0 ? Base.ambientLight : 0.5f }).ToArray(); + } if (Atmosphere != null) { diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index ee7cbba5..196061dc 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -497,7 +497,7 @@ namespace NewHorizons.Handlers { var sphereOfInfluence = GetSphereOfInfluence(body); - Light ambientLight = null; + Light[] ambientLight = null; if (body.Config.Base.ambientLight != 0) { ambientLight = AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.ambientLight);