new-horizons/NewHorizons/Components/TimeLoopController.cs
2022-05-12 19:49:02 -04:00

37 lines
972 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components
{
public class TimeLoopController : MonoBehaviour
{
private float _supernovaTime;
private bool _supernovaHappened;
public void Start()
{
GlobalMessenger.AddListener("TriggerSupernova", OnTriggerSupernova);
}
public void Update()
{
// Stock gives like 33 seconds after the sun collapses
// Gonna assume it takes like 7 seconds to collapse after the supernova trigger
if(_supernovaHappened && Time.time > _supernovaTime + 40f)
{
Locator.GetDeathManager().KillPlayer(DeathType.TimeLoop);
}
}
public void OnTriggerSupernova()
{
_supernovaHappened = true;
_supernovaTime = Time.time;
}
}
}