mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
7e020b2537
@ -144,6 +144,8 @@ namespace NewHorizons.Builder.Body
|
||||
controller.WillExplode = starModule.goSupernova;
|
||||
controller.lifespan = starModule.lifespan;
|
||||
controller.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
|
||||
controller._destructionVolume = deathVolume.GetComponent<DestructionVolume>();
|
||||
controller._planetDestructionVolume = planetDestructionVolume.GetComponent<DestructionVolume>();
|
||||
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
|
||||
{
|
||||
controller.collapseRamp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
|
||||
@ -185,6 +187,7 @@ namespace NewHorizons.Builder.Body
|
||||
var controller = starGO.AddComponent<StarEvolutionController>();
|
||||
if (starModule.curve != null) controller.SetScaleCurve(starModule.curve);
|
||||
controller.size = starModule.size;
|
||||
controller.supernovaSize = starModule.supernovaSize;
|
||||
controller.supernova = supernova;
|
||||
controller.StartColour = starModule.tint;
|
||||
controller.EndColour = starModule.endTint;
|
||||
@ -198,7 +201,7 @@ namespace NewHorizons.Builder.Body
|
||||
controller.enabled = true;
|
||||
starGO.SetActive(true);
|
||||
|
||||
planet.GetComponentInChildren<StarEvolutionController>().SetProxy(controller);
|
||||
planet.GetComponentInChildren<StarEvolutionController>(true).SetProxy(controller);
|
||||
|
||||
return proxyGO;
|
||||
}
|
||||
@ -284,6 +287,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
var supernova = supernovaGO.GetComponent<SupernovaEffectController>();
|
||||
supernova._surface = starGO.GetComponentInChildren<TessellatedSphereRenderer>();
|
||||
supernova._supernovaScale = AnimationCurve.Linear(5, 0, 15, starModule.supernovaSize);
|
||||
supernova._supernovaVolume = null;
|
||||
|
||||
if (starModule.supernovaTint != null)
|
||||
|
||||
@ -28,7 +28,8 @@ namespace NewHorizons.Components.SizeControllers
|
||||
private PlanetaryFogController _fog;
|
||||
private MeshRenderer[] _atmosphereRenderers;
|
||||
private HeatHazardVolume _heatVolume;
|
||||
private DestructionVolume _destructionVolume;
|
||||
public DestructionVolume _destructionVolume;
|
||||
public DestructionVolume _planetDestructionVolume;
|
||||
private SolarFlareEmitter _flareEmitter;
|
||||
private MapMarker _mapMarker;
|
||||
private OWRigidbody _rigidbody;
|
||||
@ -39,6 +40,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
|
||||
public float collapseTime = 10f; // seconds
|
||||
public float lifespan = 22f; // minutes
|
||||
public float supernovaSize = 50000f;
|
||||
|
||||
private bool _isSupernova;
|
||||
private float _supernovaStartTime;
|
||||
@ -119,7 +121,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
}
|
||||
|
||||
_heatVolume = GetComponentInChildren<HeatHazardVolume>();
|
||||
_destructionVolume = GetComponentInChildren<DestructionVolume>();
|
||||
if (_destructionVolume != null) _destructionVolume = GetComponentInChildren<DestructionVolume>();
|
||||
|
||||
if (atmosphere != null)
|
||||
{
|
||||
@ -142,6 +144,19 @@ namespace NewHorizons.Components.SizeControllers
|
||||
|
||||
_flareEmitter = GetComponentInChildren<SolarFlareEmitter>();
|
||||
_surfaceMaterial = supernova._surface._materials[0];
|
||||
|
||||
var secondsElapsed = TimeLoop.GetSecondsElapsed();
|
||||
var lifespanInSeconds = lifespan * 60;
|
||||
if (secondsElapsed >= lifespanInSeconds)
|
||||
{
|
||||
var timeAfter = secondsElapsed - lifespanInSeconds;
|
||||
if (timeAfter <= collapseTime)
|
||||
Delay.RunWhen(() => Main.IsSystemReady, StartCollapse);
|
||||
else if (timeAfter <= collapseTime + 45)
|
||||
Delay.RunWhen(() => Main.IsSystemReady, StartSupernova);
|
||||
else
|
||||
Delay.RunWhen(() => Main.IsSystemReady, () => Delay.FireOnNextUpdate(() => DisableStar(true)));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
@ -209,28 +224,53 @@ namespace NewHorizons.Components.SizeControllers
|
||||
|
||||
// Make the destruction volume scale slightly smaller so you really have to be in the supernova to die
|
||||
if (_destructionVolume != null) _destructionVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius() * 0.9f;
|
||||
if (_planetDestructionVolume != null) _planetDestructionVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius() * 0.9f;
|
||||
if (_heatVolume != null) _heatVolume.transform.localScale = Vector3.one * supernova.GetSupernovaRadius();
|
||||
|
||||
if (Time.time > _supernovaStartTime + 45f)
|
||||
{
|
||||
if (_rigidbody != null)
|
||||
DisableStar();
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableStar(bool start = false)
|
||||
{
|
||||
if (_rigidbody != null)
|
||||
{
|
||||
ReferenceFrameTracker referenceFrameTracker = Locator.GetPlayerBody().GetComponent<ReferenceFrameTracker>();
|
||||
if (referenceFrameTracker.GetReferenceFrame() != null && referenceFrameTracker.GetReferenceFrame().GetOWRigidBody() == _rigidbody) referenceFrameTracker.UntargetReferenceFrame();
|
||||
_rigidbody._isTargetable = false;
|
||||
if (_rigidbody._attachedRFVolume != null)
|
||||
{
|
||||
ReferenceFrameTracker referenceFrameTracker = Locator.GetPlayerBody().GetComponent<ReferenceFrameTracker>();
|
||||
if (referenceFrameTracker.GetReferenceFrame() != null && referenceFrameTracker.GetReferenceFrame().GetOWRigidBody() == _rigidbody) referenceFrameTracker.UntargetReferenceFrame();
|
||||
_rigidbody._isTargetable = false;
|
||||
if (_rigidbody._attachedRFVolume != null)
|
||||
_rigidbody._attachedRFVolume._minColliderRadius = 0;
|
||||
_rigidbody._attachedRFVolume._maxColliderRadius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_mapMarker != null) _mapMarker.DisableMarker();
|
||||
|
||||
if (controller != null) StarLightController.RemoveStar(controller);
|
||||
|
||||
// Just turn off the star entirely
|
||||
base.gameObject.SetActive(false);
|
||||
|
||||
if (start && _planetDestructionVolume != null)
|
||||
{
|
||||
foreach (var collider in Physics.OverlapSphere(_planetDestructionVolume.transform.position, _planetDestructionVolume.GetComponent<SphereCollider>().radius * supernovaSize * 0.9f))
|
||||
{
|
||||
if (collider.attachedRigidbody != null)
|
||||
{
|
||||
_rigidbody._attachedRFVolume._minColliderRadius = 0;
|
||||
_rigidbody._attachedRFVolume._maxColliderRadius = 0;
|
||||
var body = collider.attachedRigidbody.GetComponent<OWRigidbody>();
|
||||
if (body != null && body != _rigidbody)
|
||||
{
|
||||
// Vanish anything that is not a player-related object
|
||||
if (!(collider.attachedRigidbody.CompareTag("Player") || collider.attachedRigidbody.CompareTag("Ship") || collider.attachedRigidbody.CompareTag("ShipCockpit") || collider.attachedRigidbody.CompareTag("Probe")))
|
||||
{
|
||||
_planetDestructionVolume.Vanish(body, new RelativeLocationData(body, _rigidbody, _planetDestructionVolume.transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_mapMarker != null) _mapMarker.DisableMarker();
|
||||
|
||||
if (controller != null) StarLightController.RemoveStar(controller);
|
||||
|
||||
// Just turn off the star entirely
|
||||
base.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +312,7 @@ namespace NewHorizons.Components.SizeControllers
|
||||
_supernovaStartTime = Time.time;
|
||||
if (atmosphere != null) atmosphere.SetActive(false);
|
||||
if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova;
|
||||
if (_planetDestructionVolume != null) _planetDestructionVolume._deathType = DeathType.Supernova;
|
||||
|
||||
if (_proxy != null) _proxy.StartSupernova();
|
||||
}
|
||||
@ -290,6 +331,11 @@ namespace NewHorizons.Components.SizeControllers
|
||||
_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;
|
||||
gameObject.SetActive(true);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
@ -52,6 +52,13 @@ namespace NewHorizons.External.Modules.VariableSize
|
||||
[DefaultValue(1f)] [Range(0f, double.MaxValue)]
|
||||
public float solarLuminosity = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Radius of the supernova.
|
||||
/// </summary>
|
||||
[DefaultValue(50000f)]
|
||||
[Range(0f, double.MaxValue)]
|
||||
public float supernovaSize = 50000f;
|
||||
|
||||
/// <summary>
|
||||
/// The tint of the supernova this star creates when it dies.
|
||||
/// </summary>
|
||||
|
||||
@ -381,6 +381,14 @@ namespace NewHorizons
|
||||
remoteViewer._visualSector = northPoleSurface;
|
||||
}
|
||||
|
||||
//Stop starfield from disappearing when there is no lights
|
||||
var playerBody = SearchUtilities.Find("Player_Body");
|
||||
var playerLight = playerBody.AddComponent<Light>();
|
||||
playerLight.innerSpotAngle = 0;
|
||||
playerLight.spotAngle = 179;
|
||||
playerLight.range = 0.5f;
|
||||
playerLight.intensity = 0.001f;
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Log($"Star system finished loading [{Instance.CurrentStarSystem}]");
|
||||
|
||||
@ -2333,6 +2333,13 @@
|
||||
"default": 1.0,
|
||||
"minimum": 0.0
|
||||
},
|
||||
"supernovaSize": {
|
||||
"type": "number",
|
||||
"description": "Radius of the supernova.",
|
||||
"format": "float",
|
||||
"default": 50000.0,
|
||||
"minimum": 0.0
|
||||
},
|
||||
"supernovaTint": {
|
||||
"description": "The tint of the supernova this star creates when it dies.",
|
||||
"$ref": "#/definitions/MColor"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user