GeWuYou ddbf7af572 feat(coroutine): 添加完整的协程系统实现
- 实现了协程调度器和句柄管理机制
- 添加了多种等待指令包括延时、帧数、条件等待等
- 创建了协程辅助方法和扩展功能
- 集成了Godot引擎的时间源和生命周期管理
- 实现了协程的暂停、恢复、终止等控制功能
- 添加了协程标签管理和按标签批量操作功能
- 提供了与Godot节点生命周期绑定的取消机制
2026-01-21 20:34:10 +08:00

26 lines
902 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.Core.Abstractions.coroutine;
namespace GFramework.Core.coroutine;
/// <summary>
/// 表示一个等待条件为假时才完成的协程指令
/// </summary>
/// <param name="predicate">用于判断是否继续等待的条件函数当返回true时继续等待返回false时完成</param>
public sealed class WaitWhile(Func<bool> predicate) : IYieldInstruction
{
private readonly Func<bool> _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate));
/// <summary>
/// 更新协程状态(此实现中为空方法)
/// </summary>
/// <param name="deltaTime">时间增量</param>
public void Update(double deltaTime)
{
}
/// <summary>
/// 获取协程指令是否已完成
/// 当谓词函数返回false时表示条件不再满足指令完成
/// </summary>
public bool IsDone => !_predicate();
}