using GFramework.Game.Abstractions.coroutine;
namespace GFramework.Game.coroutine;
///
/// 表示一个等待指定秒数的时间延迟指令
///
/// 需要等待的秒数
public class WaitForSeconds(float seconds) : IYieldInstruction
{
private float _elapsed;
///
/// 获取当前等待是否已完成
///
public bool IsDone { get; private set; }
///
/// 更新时间进度
///
/// 自上次更新以来经过的时间(秒)
public void Update(float deltaTime)
{
if (IsDone) return;
_elapsed += deltaTime;
if (_elapsed >= seconds) IsDone = true;
}
///
/// 重置等待状态到初始状态
///
public void Reset()
{
_elapsed = 0;
IsDone = false;
}
}