mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
refactor(architecture): 重构架构初始化流程
将原有的 RegisterModels、RegisterSystems 和 RegisterUtilities 方法合并为统一的 InstallModules 抽象方法,由子类实现具体的模块注册逻辑。同时调整初始化顺序,确保 架构能正确绑定到 Godot 生命周期中并管理资源清理。
This commit is contained in:
parent
383d934e02
commit
f990f8d2c1
@ -10,17 +10,21 @@ namespace GFramework.Godot.architecture;
|
||||
public abstract class AbstractArchitecture<T> : Architecture<T> where T : Architecture<T>, new()
|
||||
{
|
||||
private const string ArchitectureName = "__GFramework__Architecture__Anchor";
|
||||
|
||||
/// <summary>
|
||||
/// 初始化架构,按顺序注册模型、系统和工具
|
||||
/// </summary>
|
||||
protected override void Init()
|
||||
{
|
||||
RegisterModels();
|
||||
RegisterSystems();
|
||||
RegisterUtilities();
|
||||
AttachToGodotLifecycle();
|
||||
InstallModules();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安装模块抽象方法,由子类实现具体的模块注册逻辑
|
||||
/// </summary>
|
||||
protected abstract void InstallModules();
|
||||
|
||||
/// <summary>
|
||||
/// 将架构绑定到Godot生命周期中,确保在场景树销毁时能够正确清理资源
|
||||
/// 通过创建一个锚节点来监听场景树的销毁事件
|
||||
@ -43,20 +47,5 @@ public abstract class AbstractArchitecture<T> : Architecture<T> where T : Archit
|
||||
|
||||
tree.Root.CallDeferred(Node.MethodName.AddChild, anchor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册工具抽象方法,由子类实现具体的工具注册逻辑
|
||||
/// </summary>
|
||||
protected abstract void RegisterUtilities();
|
||||
|
||||
/// <summary>
|
||||
/// 注册系统抽象方法,由子类实现具体系统注册逻辑
|
||||
/// </summary>
|
||||
protected abstract void RegisterSystems();
|
||||
|
||||
/// <summary>
|
||||
/// 注册模型抽象方法,由子类实现具体模型注册逻辑
|
||||
/// </summary>
|
||||
protected abstract void RegisterModels();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user