From f990f8d2c175934e7dbf9affd2ce490e32d1dcc6 Mon Sep 17 00:00:00 2001 From: GwWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Sun, 21 Dec 2025 12:28:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(architecture):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E5=88=9D=E5=A7=8B=E5=8C=96=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将原有的 RegisterModels、RegisterSystems 和 RegisterUtilities 方法合并为统一的 InstallModules 抽象方法,由子类实现具体的模块注册逻辑。同时调整初始化顺序,确保 架构能正确绑定到 Godot 生命周期中并管理资源清理。 --- .../architecture/AbstractArchitecture.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/GFramework.Godot/architecture/AbstractArchitecture.cs b/GFramework.Godot/architecture/AbstractArchitecture.cs index 9c26d27..e30cd4e 100644 --- a/GFramework.Godot/architecture/AbstractArchitecture.cs +++ b/GFramework.Godot/architecture/AbstractArchitecture.cs @@ -10,17 +10,21 @@ namespace GFramework.Godot.architecture; public abstract class AbstractArchitecture : Architecture where T : Architecture, new() { private const string ArchitectureName = "__GFramework__Architecture__Anchor"; + /// /// 初始化架构,按顺序注册模型、系统和工具 /// protected override void Init() { - RegisterModels(); - RegisterSystems(); - RegisterUtilities(); AttachToGodotLifecycle(); + InstallModules(); } + /// + /// 安装模块抽象方法,由子类实现具体的模块注册逻辑 + /// + protected abstract void InstallModules(); + /// /// 将架构绑定到Godot生命周期中,确保在场景树销毁时能够正确清理资源 /// 通过创建一个锚节点来监听场景树的销毁事件 @@ -43,20 +47,5 @@ public abstract class AbstractArchitecture : Architecture where T : Archit tree.Root.CallDeferred(Node.MethodName.AddChild, anchor); } - - /// - /// 注册工具抽象方法,由子类实现具体的工具注册逻辑 - /// - protected abstract void RegisterUtilities(); - - /// - /// 注册系统抽象方法,由子类实现具体系统注册逻辑 - /// - protected abstract void RegisterSystems(); - - /// - /// 注册模型抽象方法,由子类实现具体模型注册逻辑 - /// - protected abstract void RegisterModels(); }