using System.Collections;
namespace X10D.Unity;
///
/// Represents a yield instruction which waits for a given amount of time, as provided by a .
///
public struct WaitForTimeSpan : IEnumerator
{
private readonly TimeSpan _duration;
private readonly DateTime _start;
private DateTime _current;
///
/// Initializes a new instance of the struct.
///
/// The duration of the pause.
public WaitForTimeSpan(TimeSpan duration)
{
_duration = duration;
_start = DateTime.Now;
_current = _start;
}
///
public object Current
{
get => _current;
}
///
public bool MoveNext()
{
_current += TimeSpan.FromSeconds(UnityEngine.Time.deltaTime);
return _current < _start + _duration;
}
///
public void Reset()
{
}
}