mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
refactor(GFramework.Core): 简化GameArchitecture类的继承实现
移除了GameArchitecture类中不必要的泛型参数,并删除了示例代码中的PlayerModel 类定义,因为AbstractModel基类已经自动实现了架构引用功能,简化了组件注册 的代码示例。
This commit is contained in:
parent
023ba44f57
commit
396723bd68
@ -151,27 +151,16 @@ public class SaveManager : ContextAwareBase
|
||||
### 1. 组件注册规则
|
||||
|
||||
```csharp
|
||||
public class GameArchitecture : Architecture<GameArchitecture>
|
||||
public class GameArchitecture : Architecture
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
// ✅ 正确:Model/System/Utility 自动获得架构引用
|
||||
// Model/System/Utility 自动获得架构引用
|
||||
this.RegisterModel<PlayerModel>(new PlayerModel());
|
||||
this.RegisterSystem<CombatSystem>(new CombatSystem());
|
||||
this.RegisterUtility<StorageUtility>(new StorageUtility());
|
||||
}
|
||||
}
|
||||
|
||||
// Model 继承 AbstractModel,AbstractModel 实现了 IBelongToArchitecture
|
||||
public class PlayerModel : AbstractModel
|
||||
{
|
||||
// 无需手动实现 GetArchitecture,基类已实现
|
||||
protected override void OnInit()
|
||||
{
|
||||
// 可以直接使用架构能力
|
||||
this.SendEvent(new PlayerModelInitializedEvent());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Command/Query 自动注入规则
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user