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

29 lines
765 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>
/// 延迟等待指令实现IYieldInstruction接口用于协程中的时间延迟
/// </summary>
/// <param name="seconds">需要延迟的秒数</param>
public sealed class Delay(double seconds) : IYieldInstruction
{
/// <summary>
/// 剩余等待时间
/// </summary>
private double _remaining = Math.Max(0, seconds);
/// <summary>
/// 更新延迟计时器
/// </summary>
/// <param name="deltaTime">时间增量</param>
public void Update(double deltaTime)
{
_remaining -= deltaTime;
}
/// <summary>
/// 获取延迟是否完成
/// </summary>
public bool IsDone => _remaining <= 0;
}