mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 19:24:29 +08:00
refactor(signal): 优化 SignalBuilder 的 To 方法实现
- 将方法功能描述从"将信号连接到指定的处理方法"更新为"连接信号到指定的可调用对象" - 为 To 方法添加返回值类型 SignalBuilder 以支持链式调用 - 简化连接逻辑,移除不必要的 if-else 分支 - 添加 End 方法用于返回目标节点 - 更新参数说明文档
This commit is contained in:
parent
cb17d9ecdd
commit
cacd82d7b7
@ -23,18 +23,24 @@ public sealed class SignalBuilder(Node target, StringName signal)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将信号连接到指定的处理方法
|
||||
/// 连接信号到指定的可调用对象
|
||||
/// </summary>
|
||||
/// <param name="callable">信号触发时要调用的处理方法</param>
|
||||
public void To(Callable callable)
|
||||
/// <param name="callable">要连接的可调用对象</param>
|
||||
/// <returns>当前构建器实例</returns>
|
||||
public SignalBuilder To(Callable callable)
|
||||
{
|
||||
// 根据是否设置了标志来决定使用哪种连接方法
|
||||
// 根据是否设置了标志来决定连接方式
|
||||
if (_flags is null)
|
||||
{
|
||||
target.Connect(signal, callable);
|
||||
return;
|
||||
}
|
||||
else
|
||||
target.Connect(signal, callable, (uint)_flags);
|
||||
|
||||
target.Connect(signal, callable, (uint)_flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显式结束,返回 Node
|
||||
/// </summary>
|
||||
/// <returns>目标节点</returns>
|
||||
public Node End() => target;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user