From 177552a7307f996b4670aa327d701f64fa4147c9 Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Sat, 7 Feb 2026 08:57:48 +0800
Subject: [PATCH] =?UTF-8?q?docs(coroutine):=20=E6=9B=B4=E6=96=B0=E5=8D=8F?=
=?UTF-8?q?=E7=A8=8B=E6=89=A9=E5=B1=95=E6=96=B9=E6=B3=95=E5=92=8C=E5=AE=9A?=
=?UTF-8?q?=E6=97=B6=E5=99=A8=E7=B1=BB=E7=9A=84=E6=96=87=E6=A1=A3=E6=B3=A8?=
=?UTF-8?q?=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 为 CoroutineExtensions 类添加了总体功能描述
- 完善了 RunCoroutine 方法的参数和返回值文档注释
- 补充了 CancelWith 方法族的参数说明和返回值描述
- 优化了 AllNodesAlive 私有方法的文档注释格式
- 将 Timing 类中的重复错误消息提取为静态只读字段
- 统一了调度器属性的异常消息为常量引用
- [release ci]
---
.../coroutine/CoroutineExtensions.cs | 36 +++++++++++++------
GFramework.Godot/coroutine/Timing.cs | 9 ++---
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/GFramework.Godot/coroutine/CoroutineExtensions.cs b/GFramework.Godot/coroutine/CoroutineExtensions.cs
index 7ea08d4..1a0c112 100644
--- a/GFramework.Godot/coroutine/CoroutineExtensions.cs
+++ b/GFramework.Godot/coroutine/CoroutineExtensions.cs
@@ -4,11 +4,18 @@ using Godot;
namespace GFramework.Godot.coroutine;
+///
+/// 提供协程相关的扩展方法,用于简化协程的启动和管理。
+///
public static class CoroutineExtensions
{
///
- /// 启动协程的扩展方法
+ /// 启动协程的扩展方法。
///
+ /// 要启动的协程枚举器。
+ /// 协程运行的时间段,默认为 Process。
+ /// 协程的标签,可用于标识或分组协程。
+ /// 返回协程的句柄,可用于后续操作(如停止协程)。
public static CoroutineHandle RunCoroutine(
this IEnumerator coroutine,
Segment segment = Segment.Process,
@@ -18,8 +25,11 @@ public static class CoroutineExtensions
}
///
- /// 让协程在指定节点被销毁时自动取消
+ /// 让协程在指定节点被销毁时自动取消。
///
+ /// 要执行的协程枚举器。
+ /// 用于检查是否存活的节点。
+ /// 包装后的协程枚举器。
public static IEnumerator CancelWith(
this IEnumerator coroutine,
Node node)
@@ -29,8 +39,12 @@ public static class CoroutineExtensions
}
///
- /// 让协程在任一节点被销毁时自动取消
+ /// 让协程在任一节点被销毁时自动取消。
///
+ /// 要执行的协程枚举器。
+ /// 第一个用于检查是否存活的节点。
+ /// 第二个用于检查是否存活的节点。
+ /// 包装后的协程枚举器。
public static IEnumerator CancelWith(
this IEnumerator coroutine,
Node node1,
@@ -43,11 +57,11 @@ public static class CoroutineExtensions
}
///
- /// 让协程在多个节点都被销毁时自动取消
+ /// 让协程在多个节点都被销毁时自动取消。
///
- /// 要执行的协程枚举器
- /// 用于检查是否存活的节点数组
- /// 包装后的协程枚举器
+ /// 要执行的协程枚举器。
+ /// 用于检查是否存活的节点数组。
+ /// 包装后的协程枚举器。
public static IEnumerator CancelWith(
this IEnumerator coroutine,
params Node[] nodes)
@@ -58,12 +72,12 @@ public static class CoroutineExtensions
}
///
- /// 检查所有节点是否都处于存活状态
+ /// 检查所有节点是否都处于存活状态。
///
- /// 要检查的节点数组
- /// 如果所有节点都存活则返回true,否则返回false
+ /// 要检查的节点数组。
+ /// 如果所有节点都存活则返回 true,否则返回 false。
private static bool AllNodesAlive(Node[] nodes)
{
return nodes.All(Timing.IsNodeAlive);
}
-}
\ No newline at end of file
+}
diff --git a/GFramework.Godot/coroutine/Timing.cs b/GFramework.Godot/coroutine/Timing.cs
index 29fdf6c..4d6fbd8 100644
--- a/GFramework.Godot/coroutine/Timing.cs
+++ b/GFramework.Godot/coroutine/Timing.cs
@@ -28,34 +28,35 @@ public partial class Timing : Node
private GodotTimeSource? _processTimeSource;
private CoroutineScheduler? _processIgnorePauseScheduler;
private GodotTimeSource? _processIgnorePauseTimeSource;
+ private const string NotInitializedMessage = "Timing not yet initialized (_Ready not executed)";
///
/// 获取Process调度器,如果未初始化则抛出异常
///
private CoroutineScheduler ProcessScheduler =>
_processScheduler ?? throw new InvalidOperationException(
- "Timing not yet initialized (_Ready not executed)");
+ NotInitializedMessage);
///
/// 获取忽略暂停的Process调度器,如果未初始化则抛出异常
///
private CoroutineScheduler ProcessIgnorePauseScheduler =>
_processIgnorePauseScheduler ?? throw new InvalidOperationException(
- "Timing not yet initialized (_Ready not executed)");
+ NotInitializedMessage);
///
/// 获取Physics调度器,如果未初始化则抛出异常
///
private CoroutineScheduler PhysicsScheduler =>
_physicsScheduler ?? throw new InvalidOperationException(
- "Timing not yet initialized (_Ready not executed)");
+ NotInitializedMessage);
///
/// 获取Deferred调度器,如果未初始化则抛出异常
///
private CoroutineScheduler DeferredScheduler =>
_deferredScheduler ?? throw new InvalidOperationException(
- "Timing not yet initialized (_Ready not executed)");
+ NotInitializedMessage);
#region 单例