mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 添加协程上下文、句柄、调度器和作用域管理类 - 实现协程等待指令包括 WaitForSeconds、WaitUntil 和 WaitWhile - 创建协程系统和全局协程作用域管理器 - 定义协程相关抽象接口 ICoroutineScheduler、ICoroutineScope 等 - 升级 Meziantou.Analyzer 依赖版本至 2.0.283 - 升级 Meziantou.Polyfill 依赖版本至 1.0.100
24 lines
729 B
C#
24 lines
729 B
C#
using GFramework.Game.Abstractions.coroutine;
|
|
|
|
namespace GFramework.Game.coroutine;
|
|
|
|
/// <summary>
|
|
/// 表示一个等待指定秒数的时间延迟指令
|
|
/// </summary>
|
|
/// <param name="seconds">需要等待的秒数</param>
|
|
public class WaitForSeconds(float seconds) : IYieldInstruction
|
|
{
|
|
private float _elapsed;
|
|
public bool IsDone { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 更新时间进度,当累计时间达到指定秒数时标记完成
|
|
/// </summary>
|
|
/// <param name="deltaTime">自上次更新以来经过的时间(秒)</param>
|
|
public void Update(float deltaTime)
|
|
{
|
|
if (IsDone) return;
|
|
_elapsed += deltaTime;
|
|
if (_elapsed >= seconds) IsDone = true;
|
|
}
|
|
} |