Fix everything

This commit is contained in:
Nick 2022-08-25 21:02:16 -04:00
parent b637a50439
commit 8185a8871d
6 changed files with 142 additions and 152 deletions

View File

@ -7,6 +7,8 @@ using NewHorizons.External.Modules.VariableSize;
using Logger = NewHorizons.Utility.Logger;
using OWML.ModHelper;
using OWML.Common;
using UnityEngine.InputSystem.XR;
using System.Linq;
namespace NewHorizons.Builder.Body
{
@ -23,11 +25,7 @@ namespace NewHorizons.Builder.Body
public static (GameObject, StarController, StarEvolutionController) Make(GameObject planetGO, Sector sector, StarModule starModule, IModBehaviour mod, bool isStellarRemnant)
{
var starGO = MakeStarGraphics(planetGO, sector, starModule, mod);
starGO.SetActive(false);
var ramp = starGO.GetComponentInChildren<TessellatedSphereRenderer>().sharedMaterial.GetTexture(ColorRamp);
var (starGO, starEvolutionController, supernova) = SharedStarGeneration(planetGO, sector, mod, starModule, isStellarRemnant);
var sunAudio = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform);
sunAudio.transform.localPosition = Vector3.zero;
@ -112,6 +110,7 @@ namespace NewHorizons.Builder.Body
planetDestructionVolume.AddComponent<OWTriggerVolume>();
planetDestructionVolume.AddComponent<StarDestructionVolume>()._deathType = DeathType.Energy;
// Star light
var sunLight = new GameObject("StarLight");
sunLight.transform.parent = starGO.transform;
sunLight.transform.localPosition = Vector3.zero;
@ -138,6 +137,7 @@ namespace NewHorizons.Builder.Body
proxyShadowLight.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>());
proxyShadowLight._light = light;
// Star controller (works on atmospheric shaders)
StarController starController = null;
if (starModule.solarLuminosity != 0 && starModule.hasStarController)
{
@ -152,49 +152,19 @@ namespace NewHorizons.Builder.Body
starController.IsStellarRemnant = isStellarRemnant;
}
// TODO: A lot of this is shared with the proxy generation, we should merge that
// Could go into the star graphics method
var starEvolutionController = starGO.AddComponent<StarEvolutionController>();
if (starModule.curve != null) starEvolutionController.SetScaleCurve(starModule.curve);
starEvolutionController.size = starModule.size;
starEvolutionController.atmosphere = sunAtmosphere;
starEvolutionController.controller = starController;
starEvolutionController.startColour = starModule.tint;
starEvolutionController.endColour = starModule.endTint;
starEvolutionController.supernovaColour = starModule.supernovaTint;
starEvolutionController.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
starFluidVolume.SetStarEvolutionController(starEvolutionController);
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
{
starEvolutionController.collapseRamp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
}
surfaceAudio.SetStarEvolutionController(starEvolutionController);
if (!isStellarRemnant)
{
var supernova = MakeSupernova(starGO, starModule);
starEvolutionController.supernovaSize = starModule.supernovaSize;
var duration = starModule.supernovaSize / starModule.supernovaSpeed;
starEvolutionController.supernovaTime = duration;
starEvolutionController.supernovaScaleEnd = duration;
starEvolutionController.supernovaScaleStart = duration * 0.9f;
starEvolutionController.deathType = starModule.stellarDeathType;
starEvolutionController.supernova = supernova;
starEvolutionController.willExplode = starModule.stellarDeathType != StellarDeathType.None;
starEvolutionController.lifespan = starModule.lifespan;
starEvolutionController.heatVolume = heatVolume.GetComponent<HeatHazardVolume>();
starEvolutionController.destructionVolume = deathVolume.GetComponent<DestructionVolume>();
starEvolutionController.planetDestructionVolume = planetDestructionVolume.GetComponent<StarDestructionVolume>();
starEvolutionController.starFluidVolume = starFluidVolume;
starEvolutionController.oneShotSource = sunAudio.transform.Find("OneShotAudio_Sun")?.GetComponent<OWAudioSource>();
}
else
{
starEvolutionController.willExplode = false;
}
starEvolutionController.heatVolume = heatVolume.GetComponent<HeatHazardVolume>();
starEvolutionController.destructionVolume = deathVolume.GetComponent<DestructionVolume>();
starEvolutionController.planetDestructionVolume = planetDestructionVolume.GetComponent<StarDestructionVolume>();
starEvolutionController.starFluidVolume = starFluidVolume;
starEvolutionController.oneShotSource = sunAudio.transform.Find("OneShotAudio_Sun")?.GetComponent<OWAudioSource>();
var shockLayerRuleset = sector.gameObject.AddComponent<ShockLayerRuleset>();
shockLayerRuleset._type = ShockLayerRuleset.ShockType.Radial;
@ -211,58 +181,70 @@ namespace NewHorizons.Builder.Body
public static GameObject MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod, bool isStellarRemnant)
{
var starGO = MakeStarGraphics(proxyGO, null, starModule, mod);
var ramp = starGO.GetComponentInChildren<TessellatedSphereRenderer>().sharedMaterial.GetTexture(ColorRamp);
var (starGO, controller, supernova) = SharedStarGeneration(proxyGO, null, mod, starModule, isStellarRemnant);
var controller = starGO.AddComponent<StarEvolutionController>();
if (starModule.curve != null) controller.SetScaleCurve(starModule.curve);
controller.size = starModule.size;
controller.startColour = starModule.tint;
controller.endColour = starModule.endTint;
controller.isProxy = true;
controller.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
{
controller.collapseRamp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
}
controller.enabled = true;
starGO.SetActive(true);
// Planet can have multiple stars on them, so find the one that is also a remnant / not a remnant
// This will bug out if we make quantum stars. Will have to figure that out eventually.
var mainController = planet.GetComponentsInChildren<StarEvolutionController>(true).Where(x => x.isRemnant == isStellarRemnant).FirstOrDefault();
mainController.SetProxy(controller);
// Remnants can't go supernova
if (!isStellarRemnant)
if (supernova != null)
{
var supernova = MakeSupernova(starGO, starModule, true);
supernova.SetIsProxy(true);
starGO.SetActive(false);
controller.isProxy = true;
controller.supernovaSize = starModule.supernovaSize;
var duration = starModule.supernovaSize / starModule.supernovaSpeed;
controller.supernovaTime = duration;
controller.supernovaScaleEnd = duration;
controller.supernovaScaleStart = duration * 0.9f;
controller.deathType = starModule.stellarDeathType;
controller.supernova = supernova;
controller.supernovaColour = starModule.supernovaTint;
controller.willExplode = starModule.stellarDeathType != StellarDeathType.None;
controller.lifespan = starModule.lifespan;
var main = planet.GetComponentInChildren<StarEvolutionController>(true);
main.SetProxy(controller);
supernova._main = main.supernova;
}
else
{
controller.willExplode = false;
supernova.mainStellerDeathController = mainController.supernova;
}
return starGO;
}
private static (GameObject, StarEvolutionController, StellarDeathController) SharedStarGeneration(GameObject planetGO, Sector sector, IModBehaviour mod, StarModule starModule, bool isStellarRemnant)
{
var starGO = MakeStarGraphics(planetGO, sector, starModule, mod);
starGO.SetActive(false);
var ramp = starGO.GetComponentInChildren<TessellatedSphereRenderer>(true).sharedMaterial.GetTexture(ColorRamp);
var starEvolutionController = starGO.AddComponent<StarEvolutionController>();
starEvolutionController.isRemnant = isStellarRemnant;
if (starModule.curve != null) starEvolutionController.SetScaleCurve(starModule.curve);
starEvolutionController.size = starModule.size;
starEvolutionController.startColour = starModule.tint;
starEvolutionController.endColour = starModule.endTint;
starEvolutionController.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
{
starEvolutionController.collapseRamp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
}
StellarDeathController supernova = null;
var willExplode = !isStellarRemnant && starModule.stellarDeathType != StellarDeathType.None;
if (willExplode)
{
supernova = MakeSupernova(starGO, starModule);
starEvolutionController.supernovaSize = starModule.supernovaSize;
var duration = starModule.supernovaSize / starModule.supernovaSpeed;
starEvolutionController.supernovaTime = duration;
starEvolutionController.supernovaScaleEnd = duration;
starEvolutionController.supernovaScaleStart = duration * 0.9f;
starEvolutionController.deathType = starModule.stellarDeathType;
starEvolutionController.supernova = supernova;
starEvolutionController.supernovaColour = starModule.supernovaTint;
starEvolutionController.lifespan = starModule.lifespan;
}
starEvolutionController.willExplode = willExplode;
starEvolutionController.enabled = true;
starGO.SetActive(true);
return (starGO, starEvolutionController, supernova);
}
public static GameObject MakeStarGraphics(GameObject rootObject, Sector sector, StarModule starModule, IModBehaviour mod)
{
if (_colorOverTime == null) _colorOverTime = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/StarColorOverTime.png");
@ -346,26 +328,26 @@ namespace NewHorizons.Builder.Body
var supernova = supernovaGO.GetComponent<SupernovaEffectController>();
var stellarDeath = supernovaGO.AddComponent<StellarDeathController>();
stellarDeath.enabled = false;
stellarDeath._surface = starGO.GetComponentInChildren<TessellatedSphereRenderer>();
stellarDeath.surface = starGO.GetComponentInChildren<TessellatedSphereRenderer>(true);
var duration = starModule.supernovaSize / starModule.supernovaSpeed;
stellarDeath._supernovaScale = new AnimationCurve(new Keyframe(0, 200, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration, starModule.supernovaSize, 1758.508f, 1758.508f, 1f / 3f, 1f / 3f));
stellarDeath._supernovaAlpha = new AnimationCurve(new Keyframe(duration * 0.1f, 1, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration * 0.3f, 1.0002f, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration, 0, -0.0578f, 1 / 3f, -0.0578f, 1 / 3f));
stellarDeath._explosionParticles = supernova._explosionParticles;
stellarDeath._shockwave = supernova._shockwave;
stellarDeath._shockwaveLength = supernova._shockwaveLength;
stellarDeath._shockwaveAlpha = supernova._shockwaveAlpha;
stellarDeath._shockwaveScale = supernova._shockwaveScale;
stellarDeath._supernovaMaterial = supernova._supernovaMaterial;
stellarDeath.supernovaScale = new AnimationCurve(new Keyframe(0, 200, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration, starModule.supernovaSize, 1758.508f, 1758.508f, 1f / 3f, 1f / 3f));
stellarDeath.supernovaAlpha = new AnimationCurve(new Keyframe(duration * 0.1f, 1, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration * 0.3f, 1.0002f, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(duration, 0, -0.0578f, 1 / 3f, -0.0578f, 1 / 3f));
stellarDeath.explosionParticles = supernova._explosionParticles;
stellarDeath.shockwave = supernova._shockwave;
stellarDeath.shockwaveLength = supernova._shockwaveLength;
stellarDeath.shockwaveAlpha = supernova._shockwaveAlpha;
stellarDeath.shockwaveScale = supernova._shockwaveScale;
stellarDeath.supernovaMaterial = supernova._supernovaMaterial;
GameObject.Destroy(supernova);
if (starModule.supernovaTint != null)
{
var colour = starModule.supernovaTint.ToColor();
var supernovaMaterial = new Material(stellarDeath._supernovaMaterial);
var supernovaMaterial = new Material(stellarDeath.supernovaMaterial);
var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_SUN_Supernova_d.png"), Color.white, colour);
supernovaMaterial.SetTexture(ColorRamp, ramp);
stellarDeath._supernovaMaterial = supernovaMaterial;
stellarDeath.supernovaMaterial = supernovaMaterial;
// Motes
var moteMaterial = supernovaGO.GetComponentInChildren<ParticleSystemRenderer>().material;
@ -393,10 +375,10 @@ namespace NewHorizons.Builder.Body
audioSource.spatialBlend = 1;
audioSource.volume = 0.5f;
audioSource.velocityUpdateMode = AudioVelocityUpdateMode.Fixed;
stellarDeath._audioSource = supernovaWallAudio.AddComponent<OWAudioSource>();
stellarDeath._audioSource._audioSource = audioSource;
stellarDeath._audioSource._audioLibraryClip = AudioType.Sun_SupernovaWall_LP;
stellarDeath._audioSource.SetTrack(OWAudioMixer.TrackName.EndTimes_SFX);
stellarDeath.audioSource = supernovaWallAudio.AddComponent<OWAudioSource>();
stellarDeath.audioSource._audioSource = audioSource;
stellarDeath.audioSource._audioLibraryClip = AudioType.Sun_SupernovaWall_LP;
stellarDeath.audioSource.SetTrack(OWAudioMixer.TrackName.EndTimes_SFX);
}
supernovaGO.SetActive(true);

View File

@ -17,6 +17,7 @@ namespace NewHorizons.Components.SizeControllers
public class StarEvolutionController : SizeController
{
public bool isProxy;
public bool isRemnant;
public GameObject atmosphere;
public StarController controller;
@ -86,8 +87,12 @@ namespace NewHorizons.Components.SizeControllers
private Color _currentColour;
private TessellatedSphereRenderer _surface;
private void Start()
{
_surface = GetComponentInChildren<TessellatedSphereRenderer>(true);
_rigidbody = this.GetAttachedOWRigidbody();
var sun = GameObject.FindObjectOfType<SunController>();
@ -163,7 +168,7 @@ namespace NewHorizons.Components.SizeControllers
}
_flareEmitter = GetComponentInChildren<SolarFlareEmitter>();
_surfaceMaterial = supernova._surface._materials[0];
_surfaceMaterial = _surface._materials[0];
if (!isProxy) SupernovaEffectHandler.RegisterStar(this);
@ -189,7 +194,7 @@ namespace NewHorizons.Components.SizeControllers
public void SetProxy(StarEvolutionController proxy)
{
_proxy = proxy;
_proxy.supernova.SetIsProxy(true);
_proxy.supernova?.SetIsProxy(true);
}
private void UpdateMainSequence()
@ -204,21 +209,21 @@ namespace NewHorizons.Components.SizeControllers
if (t < 1f)
{
_currentColour = Color.Lerp(_startColour, _endColour, t);
supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t);
supernova._surface._materials[0].SetFloat(ColorTime, t);
_surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, t);
_surface._materials[0].SetFloat(ColorTime, t);
}
else
{
_currentColour = _endColour;
supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, 1);
supernova._surface._materials[0].SetFloat(ColorTime, 1);
_surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, 1);
_surface._materials[0].SetFloat(ColorTime, 1);
}
}
else
{
_currentColour = _startColour;
supernova._surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, 0);
supernova._surface._materials[0].SetFloat(ColorTime, 0);
_surface._materials[0].Lerp(_startSurfaceMaterial, _endSurfaceMaterial, 0);
_surface._materials[0].SetFloat(ColorTime, 0);
}
if (_flareEmitter != null) _flareEmitter._tint = _currentColour;
@ -234,7 +239,7 @@ namespace NewHorizons.Components.SizeControllers
_currentColour = Color.Lerp(_endColour, Color.white, t);
supernova._surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t);
_surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t);
// After the collapse is done we go supernova
if (_collapseTimer > collapseTime) StartSupernova();
@ -324,7 +329,7 @@ namespace NewHorizons.Components.SizeControllers
_isCollapsing = true;
_collapseStartSize = CurrentScale;
_collapseTimer = 0f;
supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial);
_surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial);
if (oneShotSource != null && !PlayerState.IsSleepingAtCampfire() && !PlayerState.InDreamWorld()) oneShotSource.PlayOneShot(AudioType.Sun_Collapse);
if (_proxy != null) _proxy.StartCollapse();
@ -338,7 +343,7 @@ namespace NewHorizons.Components.SizeControllers
CollapseStop.Invoke();
_isCollapsing = false;
supernova._surface._materials[0].CopyPropertiesFromMaterial(_endSurfaceMaterial);
_surface._materials[0].CopyPropertiesFromMaterial(_endSurfaceMaterial);
if (_proxy != null) _proxy.StopCollapse();
}
@ -384,8 +389,8 @@ namespace NewHorizons.Components.SizeControllers
if (heatVolume != null) heatVolume.transform.localScale = Vector3.one;
gameObject.SetActive(true);
transform.localScale = Vector3.one;
supernova._surface._materials[0] = _surfaceMaterial;
supernova._surface.transform.localScale = Vector3.one;
_surface._materials[0] = _surfaceMaterial;
_surface.transform.localScale = Vector3.one;
if (_proxy != null) _proxy.StopSupernova();
}

View File

@ -7,19 +7,20 @@ namespace NewHorizons.Components
{
public class StellarDeathController : MonoBehaviour
{
public ParticleSystem[] _explosionParticles;
public MeshRenderer _shockwave;
public float _shockwaveLength = 5f;
public AnimationCurve _shockwaveScale = AnimationCurve.Linear(0.0f, 0.0f, 1f, 100000f);
public AnimationCurve _shockwaveAlpha = AnimationCurve.Linear(0.0f, 1f, 1f, 0.0f);
public ParticleSystem[] explosionParticles;
public MeshRenderer shockwave;
public float shockwaveLength = 5f;
public AnimationCurve shockwaveScale = AnimationCurve.Linear(0.0f, 0.0f, 1f, 100000f);
public AnimationCurve shockwaveAlpha = AnimationCurve.Linear(0.0f, 1f, 1f, 0.0f);
public TessellatedSphereRenderer _surface;
public Material _supernovaMaterial;
public AnimationCurve _supernovaScale = new AnimationCurve(new Keyframe(0, 200, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(45, 50000, 1758.508f, 1758.508f, 1f / 3f, 1f / 3f));
public AnimationCurve _supernovaAlpha = new AnimationCurve(new Keyframe(5, 1, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(15, 1.0002f, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(50, 0, -0.0578f, 1 / 3f, -0.0578f, 1 / 3f));
public TessellatedSphereRenderer surface;
public Material supernovaMaterial;
public AnimationCurve supernovaScale = new AnimationCurve(new Keyframe(0, 200, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(45, 50000, 1758.508f, 1758.508f, 1f / 3f, 1f / 3f));
public AnimationCurve supernovaAlpha = new AnimationCurve(new Keyframe(5, 1, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(15, 1.0002f, 0, 0, 1f / 3f, 1f / 3f), new Keyframe(50, 0, -0.0578f, 1 / 3f, -0.0578f, 1 / 3f));
public OWAudioSource audioSource;
public StellarDeathController mainStellerDeathController;
public OWAudioSource _audioSource;
public StellarDeathController _main;
private float _time;
private float _currentSupernovaScale;
private Material _localSupernovaMat;
@ -28,58 +29,59 @@ namespace NewHorizons.Components
public void Awake()
{
_cachedParticleRenderers = new ParticleSystemRenderer[_explosionParticles.Length];
for (int index = 0; index < _explosionParticles.Length; ++index)
_cachedParticleRenderers[index] = _explosionParticles[index].GetComponent<ParticleSystemRenderer>();
_cachedParticleRenderers = new ParticleSystemRenderer[explosionParticles.Length];
for (int index = 0; index < explosionParticles.Length; ++index)
_cachedParticleRenderers[index] = explosionParticles[index].GetComponent<ParticleSystemRenderer>();
}
public void Activate()
{
enabled = true;
_shockwave.enabled = true;
foreach (var particle in _explosionParticles) particle.Play();
shockwave.enabled = true;
foreach (var particle in explosionParticles) particle.Play();
_time = 0.0f;
_currentSupernovaScale = _supernovaScale.Evaluate(0.0f);
_localSupernovaMat = new Material(_supernovaMaterial);
_surface.sharedMaterial = _localSupernovaMat;
_currentSupernovaScale = supernovaScale.Evaluate(0.0f);
_localSupernovaMat = new Material(supernovaMaterial);
surface.sharedMaterial = _localSupernovaMat;
if (_audioSource == null) return;
if (audioSource == null) return;
_audioSource.AssignAudioLibraryClip(AudioType.Sun_SupernovaWall_LP);
_audioSource.SetLocalVolume(0);
_audioSource.Play();
audioSource.AssignAudioLibraryClip(AudioType.Sun_SupernovaWall_LP);
audioSource.SetLocalVolume(0);
audioSource.Play();
}
public void Deactivate()
{
enabled = false;
_shockwave.enabled = false;
shockwave.enabled = false;
if (_audioSource == null) return;
if (audioSource == null) return;
_audioSource.SetLocalVolume(0);
_audioSource.Stop();
audioSource.SetLocalVolume(0);
audioSource.Stop();
}
public void FixedUpdate()
{
if (_main != null) _time = _main._time;
if (mainStellerDeathController != null) _time = mainStellerDeathController._time;
else _time += Time.deltaTime;
float shockwaveTime = Mathf.Clamp01(_time / _shockwaveLength);
_shockwave.transform.localScale = Vector3.one * _shockwaveScale.Evaluate(shockwaveTime);
_shockwave.material.color = Color.Lerp(Color.black, _shockwave.sharedMaterial.color, _shockwaveAlpha.Evaluate(shockwaveTime));
_currentSupernovaScale = _supernovaScale.Evaluate(_time);
_surface.transform.localScale = Vector3.one * _currentSupernovaScale;
_localSupernovaMat.color = Color.Lerp(Color.black, _supernovaMaterial.color, _supernovaAlpha.Evaluate(_time));
float shockwaveTime = Mathf.Clamp01(_time / shockwaveLength);
shockwave.transform.localScale = Vector3.one * shockwaveScale.Evaluate(shockwaveTime);
shockwave.material.color = Color.Lerp(Color.black, shockwave.sharedMaterial.color, shockwaveAlpha.Evaluate(shockwaveTime));
_currentSupernovaScale = supernovaScale.Evaluate(_time);
surface.transform.localScale = Vector3.one * _currentSupernovaScale;
_localSupernovaMat.color = Color.Lerp(Color.black, supernovaMaterial.color, supernovaAlpha.Evaluate(_time));
float distanceToPlayer = PlayerState.InDreamWorld() ? 20000f : (Vector3.Distance(transform.position, Locator.GetPlayerCamera().transform.position) - GetSupernovaRadius());
if (_isProxy) return;
if (_audioSource != null)
if (audioSource != null)
{
float dt = Mathf.InverseLerp(12000f, 0.0f, distanceToPlayer);
_audioSource.SetLocalVolume(Mathf.Lerp(0.0f, 1f, dt * dt) * Mathf.InverseLerp(0.0f, 5f, _time));
audioSource.SetLocalVolume(Mathf.Lerp(0.0f, 1f, dt * dt) * Mathf.InverseLerp(0.0f, 5f, _time));
}
RumbleManager.UpdateSupernova(distanceToPlayer);
@ -99,7 +101,7 @@ namespace NewHorizons.Components
public void SetRenderingEnabled(bool renderingEnabled)
{
if (!enabled) return;
_shockwave.enabled = renderingEnabled;
shockwave.enabled = renderingEnabled;
SetParticlesVisibility(renderingEnabled);
}
}

View File

@ -508,12 +508,12 @@ namespace NewHorizons.Handlers
if (body.Config.Star != null)
{
var (star, starController, starEvolutionController) = StarBuilder.Make(go, sector, body.Config.Star, body.Mod, false);
var (star, starController, starEvolutionController) = StarBuilder.Make(go, sector, body.Config.Star, body.Mod, body.Config.isStellarRemnant);
if (starController != null) StarLightController.AddStar(starController);
// If it has an evolution controller that means it will die -> we make a remnant
if (starEvolutionController != null)
// 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)
{
GameObject remnantGO;

View File

@ -108,11 +108,12 @@ namespace NewHorizons.Handlers
public static SunController GetSunController() => _sunController;
public static bool InPointInsideAnySupernova(Vector3 position)
public static bool IsPointInsideAnySupernova(Vector3 position)
{
foreach (var starEvolutionController in _starEvolutionControllers)
{
if (!IsStarActive(starEvolutionController)) continue;
if (starEvolutionController.supernova == null) continue;
var distanceSqr = (position - starEvolutionController.transform.position).sqrMagnitude;
var size = starEvolutionController.GetSupernovaRadius();

View File

@ -47,7 +47,7 @@ namespace NewHorizons.Patches
}
else
{
__result = SupernovaEffectHandler.InPointInsideAnySupernova(__instance._realObjectTransform.position);
__result = SupernovaEffectHandler.IsPointInsideAnySupernova(__instance._realObjectTransform.position);
return false;
}
}