GeWuYou f143cf5c1b feat(coroutine): 实现协程系统核心功能
- 添加协程上下文、句柄、调度器和作用域管理类
- 实现协程等待指令包括 WaitForSeconds、WaitUntil 和 WaitWhile
- 创建协程系统和全局协程作用域管理器
- 定义协程相关抽象接口 ICoroutineScheduler、ICoroutineScope 等
- 升级 Meziantou.Analyzer 依赖版本至 2.0.283
- 升级 Meziantou.Polyfill 依赖版本至 1.0.100
2026-01-20 23:05:15 +08:00

24 lines
837 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Game.Abstractions.coroutine;
namespace GFramework.Game.coroutine;
/// <summary>
/// 等待条件为假的等待指令当指定的谓词条件变为false时完成等待
/// </summary>
/// <param name="predicate">用于判断是否继续等待的条件函数返回true表示继续等待返回false表示等待结束</param>
public class WaitWhile(Func<bool> predicate) : IYieldInstruction
{
/// <summary>
/// 获取等待指令是否已完成
/// </summary>
public bool IsDone { get; private set; }
/// <summary>
/// 更新等待状态,检查谓词条件是否满足结束等待的要求
/// </summary>
/// <param name="deltaTime">自上次更新以来的时间间隔</param>
public void Update(float deltaTime)
{
if (!IsDone) IsDone = !predicate();
}
}