GFramework/GFramework.Godot/architecture/ArchitectureAnchorNode.cs
GwWuYou d1cd0cfb05 feat(architecture): 引入架构阶段管理机制
新增 `ArchitecturePhase` 枚举及生命周期接口,支持在不同阶段执行相应逻辑。
实现基于阶段的状态转换控制与校验,增强架构初始化流程的可控性与扩展性。
添加模块安装接口 `IArchitectureModule` 及相关感知接口,便于插件化集成。
完善系统与模型注册限制,禁止在就绪后注册组件,提升运行时稳定性。
移除旧版补丁注册机制,统一通过生命周期钩子进行扩展。
2025-12-21 11:39:35 +08:00

35 lines
915 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 Godot;
namespace GFramework.Godot.architecture;
/// <summary>
/// 架构锚点节点类用于在Godot场景树中作为架构组件的根节点
/// 该类提供了退出时的回调绑定功能,可以在节点从场景树中移除时执行清理操作
/// </summary>
public partial class ArchitectureAnchorNode : Node
{
private Action? _onExit;
/// <summary>
/// 绑定节点退出时的回调动作
/// </summary>
/// <param name="onExit">当节点从场景树退出时要执行的动作</param>
public void Bind(Action onExit)
{
_onExit = onExit;
}
/// <summary>
/// 当节点从场景树中移除时调用此方法
/// 执行绑定的退出回调并清理引用
/// </summary>
public override void _ExitTree()
{
// 执行退出回调
_onExit?.Invoke();
// 清理引用
_onExit = null;
}
}