Obsolete and tweak supernova effects

This commit is contained in:
TerrificTrifid 2023-02-23 23:17:55 -06:00
parent d6eb69b551
commit 5b9809f041
4 changed files with 37 additions and 13 deletions

View File

@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body
if (_shockLayerMaterial == null) _shockLayerMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Shocklayer_GD").GetComponent<MeshRenderer>().sharedMaterial).Rename("ShockLayer_mat").DontDestroyOnLoad(); if (_shockLayerMaterial == null) _shockLayerMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Shocklayer_GD").GetComponent<MeshRenderer>().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(); InitPrefabs();
@ -41,7 +41,8 @@ namespace NewHorizons.Builder.Body
if (currentController._ambientLight == null && ambientLight != null) if (currentController._ambientLight == null && ambientLight != null)
{ {
currentController._ambientLight = ambientLight; 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; if (currentController._atmosphere == null && atmosphere != null) currentController._atmosphere = atmosphere;
@ -57,8 +58,9 @@ namespace NewHorizons.Builder.Body
var supernovaController = new GameObject("SupernovaController"); var supernovaController = new GameObject("SupernovaController");
supernovaController.transform.SetParent(sector?.transform ?? planetGO.transform, false); supernovaController.transform.SetParent(sector?.transform ?? planetGO.transform, false);
var supernovaEffectController = supernovaController.AddComponent<NHSupernovaPlanetEffectController>(); var supernovaEffectController = supernovaController.AddComponent<NHSupernovaPlanetEffectController>();
supernovaEffectController._ambientLight = ambientLight; currentController._ambientLight = ambientLight;
supernovaEffectController._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 (config.Atmosphere != null && config.Atmosphere.atmosphereSunIntensity != 0) supernovaEffectController._atmosphereOrigSunIntensity = config.Atmosphere.atmosphereSunIntensity; if (config.Atmosphere != null && config.Atmosphere.atmosphereSunIntensity != 0) supernovaEffectController._atmosphereOrigSunIntensity = config.Atmosphere.atmosphereSunIntensity;
supernovaEffectController._atmosphere = atmosphere; supernovaEffectController._atmosphere = atmosphere;
supernovaEffectController._atmosphereRenderer = atmosphereRenderer; supernovaEffectController._atmosphereRenderer = atmosphereRenderer;
@ -180,8 +182,8 @@ namespace NewHorizons.Builder.Body
if (vanillaController._shockLayer != null) vanillaController._shockLayer.gameObject.SetActive(true); if (vanillaController._shockLayer != null) vanillaController._shockLayer.gameObject.SetActive(true);
var supernovaEffectController = vanillaController.gameObject.GetAddComponent<NHSupernovaPlanetEffectController>(); var supernovaEffectController = vanillaController.gameObject.GetAddComponent<NHSupernovaPlanetEffectController>();
supernovaEffectController._atmosphere = vanillaController._atmosphere; supernovaEffectController._atmosphere = vanillaController._atmosphere;
supernovaEffectController._ambientLight = vanillaController._ambientLight; supernovaEffectController._ambientLight = new Light[] { vanillaController._ambientLight };
supernovaEffectController._ambientLightOrigIntensity = vanillaController._ambientLightOrigIntensity; supernovaEffectController._ambientLightOrigIntensity = new float[] { vanillaController._ambientLightOrigIntensity };
supernovaEffectController._atmosphere = vanillaController._atmosphere; supernovaEffectController._atmosphere = vanillaController._atmosphere;
supernovaEffectController._fog = vanillaController._fog; supernovaEffectController._fog = vanillaController._fog;
supernovaEffectController._fogOrigTint = vanillaController._fogOrigTint; supernovaEffectController._fogOrigTint = vanillaController._fogOrigTint;

View File

@ -10,8 +10,8 @@ namespace NewHorizons.Components
{ {
public class NHSupernovaPlanetEffectController : MonoBehaviour public class NHSupernovaPlanetEffectController : MonoBehaviour
{ {
public Light _ambientLight; public Light[] _ambientLight;
public float _ambientLightOrigIntensity; public float[] _ambientLightOrigIntensity;
public LODGroup _atmosphere; public LODGroup _atmosphere;
public Renderer _atmosphereRenderer; public Renderer _atmosphereRenderer;
public float _atmosphereOrigSunIntensity = 1; public float _atmosphereOrigSunIntensity = 1;
@ -131,7 +131,13 @@ namespace NewHorizons.Components
{ {
float collapseProgress = StarEvolutionController.GetCollapseProgress(); 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) if (_atmosphere != null)
{ {
@ -181,7 +187,13 @@ namespace NewHorizons.Components
{ {
float collapseProgress = SunController.GetCollapseProgress(); 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) if (_atmosphere != null)
{ {
@ -212,7 +224,13 @@ namespace NewHorizons.Components
{ {
if (_shockLayer != null) _shockLayer.enabled = false; 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; if (_fog != null) _fog.fogTint = _fogOrigTint;

View File

@ -291,7 +291,11 @@ namespace NewHorizons.External.Configs
radius = Base.cloakRadius 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) if (Atmosphere != null)
{ {

View File

@ -497,7 +497,7 @@ namespace NewHorizons.Handlers
{ {
var sphereOfInfluence = GetSphereOfInfluence(body); var sphereOfInfluence = GetSphereOfInfluence(body);
Light ambientLight = null; Light[] ambientLight = null;
if (body.Config.Base.ambientLight != 0) if (body.Config.Base.ambientLight != 0)
{ {
ambientLight = AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.ambientLight); ambientLight = AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.ambientLight);