Turn off reference frame and map marker for dead stars

This commit is contained in:
Noah Pilarski 2022-08-08 23:28:22 -04:00
parent a5b14591f3
commit cbc8275587
2 changed files with 23 additions and 0 deletions

View File

@ -137,6 +137,7 @@ namespace NewHorizons.Builder.Body
if (starModule.curve != null) controller.SetScaleCurve(starModule.curve);
controller.size = starModule.size;
controller.atmosphere = sunAtmosphere;
controller.controller = starController;
controller.supernova = supernova;
controller.StartColour = starModule.tint;
controller.EndColour = starModule.endTint;

View File

@ -14,6 +14,7 @@ namespace NewHorizons.Components.SizeControllers
public class StarEvolutionController : SizeController
{
public GameObject atmosphere;
public StarController controller;
public SupernovaEffectController supernova;
public bool WillExplode { get; set; }
public MColor StartColour { get; set; }
@ -29,6 +30,8 @@ namespace NewHorizons.Components.SizeControllers
private HeatHazardVolume _heatVolume;
private DestructionVolume _destructionVolume;
private SolarFlareEmitter _flareEmitter;
private MapMarker _mapMarker;
private OWRigidbody _rigidbody;
private bool _isCollapsing;
private float _collapseStartSize;
@ -64,6 +67,9 @@ namespace NewHorizons.Components.SizeControllers
private void Start()
{
_rigidbody = this.GetAttachedOWRigidbody();
if (_rigidbody != null) _mapMarker = _rigidbody.GetComponent<MapMarker>();
var sun = GameObject.FindObjectOfType<SunController>();
_collapseStartSurfaceMaterial = new Material(sun._collapseStartSurfaceMaterial);
_collapseEndSurfaceMaterial = new Material(sun._collapseEndSurfaceMaterial);
@ -207,6 +213,22 @@ namespace NewHorizons.Components.SizeControllers
if (Time.time > _supernovaStartTime + 45f)
{
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)
{
_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);
}