2024-10-17 17:23:05 +03:00

33 lines
779 B
C#

using UnityEngine;
namespace StinkySteak.SimulationTimer
{
public struct SimulationTimer
{
public static SimulationTimer None => default;
private float _targetTime;
public float TargetTime => _targetTime;
public static SimulationTimer CreateFromSeconds(float duration)
{
return new SimulationTimer()
{
_targetTime = duration + Time.time
};
}
public bool IsRunning => _targetTime > 0;
public bool IsExpired()
=> Time.time >= _targetTime && IsRunning;
public bool IsExpiredOrNotRunning()
=> Time.time >= _targetTime;
public float RemainingSeconds
=> Mathf.Max(_targetTime - Time.time, 0);
}
}