1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 06:25:42 +00:00
X10D/X10D.Unity/src/WaitForFrames.cs

41 lines
852 B
C#
Raw Normal View History

using System.Collections;
namespace X10D.Unity;
/// <summary>
/// Represents a yield instruction that waits for a specific number of frames.
/// </summary>
public struct WaitForFrames : IEnumerator
{
private readonly int _frameCount;
private int _frameIndex;
/// <summary>
/// Initializes a new instance of the <see cref="WaitForFrames" /> struct.
/// </summary>
/// <param name="frameCount">The frame count.</param>
public WaitForFrames(int frameCount)
{
_frameCount = frameCount;
_frameIndex = 0;
}
/// <inheritdoc />
public object Current
{
get => _frameCount;
}
/// <inheritdoc />
public bool MoveNext()
{
return ++_frameIndex <= _frameCount;
}
/// <inheritdoc />
public void Reset()
{
_frameIndex = 0;
}
}