using System.Collections;
namespace X10D.Unity;
///
/// Represents a yield instruction which waits for a specified amount of seconds.
///
/// This struct exists as an allocation-free alternative to .
public struct WaitForSecondsNoAlloc : IEnumerator
{
private readonly float _duration;
private float _delta;
///
/// Initializes a new instance of the struct.
///
/// The duration of the pause, in seconds.
public WaitForSecondsNoAlloc(float duration)
{
_duration = duration;
_delta = 0f;
}
///
public object Current
{
get => _delta;
}
///
public bool MoveNext()
{
_delta += UnityEngine.Time.deltaTime;
return _delta < _duration;
}
///
public void Reset()
{
}
}