mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
feat(signal): 为SignalBuilder添加连接标志参数支持
- 为To方法添加GodotObject.ConnectFlags参数,默认为null - 为ToAndCall方法添加GodotObject.ConnectFlags参数,默认为null - 重构连接逻辑使用合并后的标志值 - 更新XML文档注释包含新参数说明
This commit is contained in:
parent
98f343d78e
commit
f88f90f394
@ -26,14 +26,16 @@ public sealed class SignalBuilder(GodotObject target, StringName signal)
|
||||
/// 连接信号到指定的可调用对象
|
||||
/// </summary>
|
||||
/// <param name="callable">要连接的可调用对象</param>
|
||||
/// <param name="flags">连接标志</param>
|
||||
/// <returns>当前构建器实例</returns>
|
||||
public SignalBuilder To(Callable callable)
|
||||
public SignalBuilder To(Callable callable, GodotObject.ConnectFlags? flags = null)
|
||||
{
|
||||
var finalFlags = flags ?? _flags;
|
||||
// 根据是否设置了标志来决定连接方式
|
||||
if (_flags is null)
|
||||
if (finalFlags is null)
|
||||
target.Connect(signal, callable);
|
||||
else
|
||||
target.Connect(signal, callable, (uint)_flags);
|
||||
target.Connect(signal, callable, (uint)finalFlags);
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -42,11 +44,12 @@ public sealed class SignalBuilder(GodotObject target, StringName signal)
|
||||
/// 连接信号到指定的可调用对象并立即调用
|
||||
/// </summary>
|
||||
/// <param name="callable">要连接的可调用对象</param>
|
||||
/// <param name="flags">连接标志</param>
|
||||
/// <param name="args">调用参数</param>
|
||||
/// <returns>当前构建器实例</returns>
|
||||
public SignalBuilder ToAndCall(Callable callable, params Variant[] args)
|
||||
public SignalBuilder ToAndCall(Callable callable, GodotObject.ConnectFlags? flags = null, params Variant[] args)
|
||||
{
|
||||
To(callable);
|
||||
To(callable, flags);
|
||||
callable.Call(args);
|
||||
return this;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user