mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Let stars explode sans remnant, fix proxy exploding on its own. Fixes #718
This commit is contained in:
parent
b61c25ff35
commit
44dbed9e97
@ -200,7 +200,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
|
||||
var secondsElapsed = TimeLoop.GetSecondsElapsed();
|
||||
var lifespanInSeconds = lifespan * 60;
|
||||
if (willExplode && secondsElapsed >= lifespanInSeconds)
|
||||
if (!isProxy && willExplode && secondsElapsed >= lifespanInSeconds)
|
||||
{
|
||||
var timeAfter = secondsElapsed - lifespanInSeconds;
|
||||
if (timeAfter <= collapseTime)
|
||||
@ -271,7 +271,8 @@ namespace NewHorizons.Components.SizeControllers
|
||||
_surface._materials[0].Lerp(_collapseStartSurfaceMaterial, _collapseEndSurfaceMaterial, t);
|
||||
|
||||
// After the collapse is done we go supernova
|
||||
if (_collapseTimer > collapseTime) StartSupernova();
|
||||
// Main star will call this on the proxy
|
||||
if (!isProxy && _collapseTimer > collapseTime) StartSupernova();
|
||||
}
|
||||
|
||||
private void UpdateSupernova()
|
||||
@ -364,10 +365,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
_surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial);
|
||||
if (oneShotSource != null && !PlayerState.IsSleepingAtCampfire() && !PlayerState.InDreamWorld()) oneShotSource.PlayOneShot(AudioType.Sun_Collapse);
|
||||
|
||||
if (_proxy != null)
|
||||
{
|
||||
_proxy.StartCollapse();
|
||||
}
|
||||
_proxy?.StartCollapse();
|
||||
}
|
||||
|
||||
public void StopCollapse()
|
||||
@ -380,7 +378,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
_isCollapsing = false;
|
||||
_surface._materials[0].CopyPropertiesFromMaterial(_endSurfaceMaterial);
|
||||
|
||||
if (_proxy != null) _proxy.StopCollapse();
|
||||
_proxy?.StopCollapse();
|
||||
}
|
||||
|
||||
public void StartSupernova()
|
||||
@ -394,19 +392,24 @@ namespace NewHorizons.Components.SizeControllers
|
||||
supernova.Activate();
|
||||
_isSupernova = true;
|
||||
_supernovaStartTime = Time.time;
|
||||
if (atmosphere != null) atmosphere.SetActive(false);
|
||||
if (destructionVolume != null) destructionVolume._deathType = DeathType.Supernova;
|
||||
if (planetDestructionVolume != null) planetDestructionVolume._deathType = DeathType.Supernova;
|
||||
if (oneShotSource != null && !PlayerState.IsSleepingAtCampfire() && !PlayerState.InDreamWorld()) oneShotSource.PlayOneShot(AudioType.Sun_Explosion);
|
||||
atmosphere?.SetActive(false);
|
||||
|
||||
if (_proxy != null)
|
||||
if (destructionVolume != null)
|
||||
{
|
||||
_proxy.StartSupernova();
|
||||
|
||||
// When the supernova starts some effects start on, we have to refresh their states
|
||||
var nhproxy = _proxy.GetComponentInParent<NHProxy>();
|
||||
nhproxy.ToggleRendering(!nhproxy._outOfRange);
|
||||
destructionVolume._deathType = DeathType.Supernova;
|
||||
}
|
||||
|
||||
if (planetDestructionVolume != null)
|
||||
{
|
||||
planetDestructionVolume._deathType = DeathType.Supernova;
|
||||
}
|
||||
|
||||
if (oneShotSource != null && !PlayerState.IsSleepingAtCampfire() && !PlayerState.InDreamWorld())
|
||||
{
|
||||
oneShotSource.PlayOneShot(AudioType.Sun_Explosion);
|
||||
}
|
||||
|
||||
_proxy?.StartSupernova();
|
||||
}
|
||||
|
||||
public void StopSupernova()
|
||||
@ -416,26 +419,33 @@ namespace NewHorizons.Components.SizeControllers
|
||||
NHLogger.LogVerbose($"{gameObject.transform.root.name} stopped supernova");
|
||||
|
||||
SupernovaStop.Invoke();
|
||||
if (supernova != null) supernova.Deactivate();
|
||||
supernova?.Deactivate();
|
||||
_isSupernova = false;
|
||||
if (atmosphere != null) atmosphere.SetActive(true);
|
||||
atmosphere?.SetActive(true);
|
||||
|
||||
if (destructionVolume != null)
|
||||
{
|
||||
destructionVolume._deathType = DeathType.Energy;
|
||||
destructionVolume.transform.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
if (planetDestructionVolume != null)
|
||||
{
|
||||
planetDestructionVolume._deathType = DeathType.Energy;
|
||||
planetDestructionVolume.transform.localScale = Vector3.one;
|
||||
}
|
||||
if (heatVolume != null) heatVolume.transform.localScale = Vector3.one;
|
||||
|
||||
if (heatVolume != null)
|
||||
{
|
||||
heatVolume.transform.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
gameObject.SetActive(true);
|
||||
transform.localScale = Vector3.one;
|
||||
_surface._materials[0] = _surfaceMaterial;
|
||||
_surface.transform.localScale = Vector3.one;
|
||||
|
||||
if (_proxy != null) _proxy.StopSupernova();
|
||||
_proxy?.StopSupernova();
|
||||
}
|
||||
|
||||
public bool IsCollapsing() => _isCollapsing;
|
||||
@ -472,7 +482,11 @@ namespace NewHorizons.Components.SizeControllers
|
||||
{
|
||||
base.FixedUpdate();
|
||||
UpdateMainSequence();
|
||||
if (willExplode && (TimeLoop.GetMinutesElapsed() / lifespan) >= 1) StartCollapse();
|
||||
// Proxy will have its collapse triggered by the main star component
|
||||
if (!isProxy && willExplode && (TimeLoop.GetMinutesElapsed() / lifespan) >= 1)
|
||||
{
|
||||
StartCollapse();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -35,12 +35,19 @@ namespace NewHorizons.Components.Stars
|
||||
public void Activate()
|
||||
{
|
||||
enabled = true;
|
||||
|
||||
var proxy = IsProxy() ? this.GetComponentInParent<NHProxy>() : null;
|
||||
|
||||
if (proxy == null || proxy._renderingEnabled)
|
||||
{
|
||||
shockwave.enabled = _renderingEnabled;
|
||||
for (int i = 0; i < explosionParticles.Length; i++)
|
||||
{
|
||||
explosionParticles[i].Play();
|
||||
_cachedParticleRenderers[i].enabled = _renderingEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
_time = 0.0f;
|
||||
_currentSupernovaScale = supernovaScale.Evaluate(0.0f);
|
||||
_localSupernovaMat = new Material(supernovaMaterial);
|
||||
|
||||
@ -18,6 +18,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using NewHorizons.Streaming;
|
||||
using Newtonsoft.Json;
|
||||
using NewHorizons.External.Modules.VariableSize;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
@ -604,10 +605,6 @@ namespace NewHorizons.Handlers
|
||||
remnantGO.SetActive(false);
|
||||
starEvolutionController.SetStellarRemnant(remnantGO);
|
||||
}
|
||||
else
|
||||
{
|
||||
starEvolutionController.willExplode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user