mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 21:34:28 +08:00
feat(core): 添加架构初始化完成事件
- 在架构初始化完成后发送 ArchitectureInitializedEvent 事件 - 新增 ArchitectureEvents 类用于定义架构相关事件 - 修改 AbstractResourceFactorySystem 在架构初始化完成后执行资源预加载 - 移除 AbstractArchitecture 中的多余空行
This commit is contained in:
parent
4157ef1384
commit
a444581ec7
@ -10,7 +10,6 @@ namespace GFramework.Core.Godot.architecture;
|
|||||||
public abstract class AbstractArchitecture<T> : Architecture<T> where T : Architecture<T>, new()
|
public abstract class AbstractArchitecture<T> : Architecture<T> where T : Architecture<T>, new()
|
||||||
{
|
{
|
||||||
private const string ArchitectureName = "__GFrameworkArchitectureAnchor";
|
private const string ArchitectureName = "__GFrameworkArchitectureAnchor";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化架构,按顺序注册模型、系统和工具
|
/// 初始化架构,按顺序注册模型、系统和工具
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using GFramework.Core.extensions;
|
using GFramework.Core.events;
|
||||||
|
using GFramework.Core.extensions;
|
||||||
using GFramework.Core.system;
|
using GFramework.Core.system;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
@ -25,9 +26,14 @@ public abstract class AbstractResourceFactorySystem : AbstractSystem, IResourceF
|
|||||||
_registry = new ResourceFactory.Registry();
|
_registry = new ResourceFactory.Registry();
|
||||||
_resourceLoadSystem = this.GetSystem<IResourceLoadSystem>();
|
_resourceLoadSystem = this.GetSystem<IResourceLoadSystem>();
|
||||||
_assetCatalogSystem = this.GetSystem<IAssetCatalogSystem>();
|
_assetCatalogSystem = this.GetSystem<IAssetCatalogSystem>();
|
||||||
|
// 注册资源
|
||||||
RegisterResources();
|
RegisterResources();
|
||||||
// 执行预加载
|
// 监听架构初始化事件
|
||||||
|
this.RegisterEvent<ArchitectureEvents.ArchitectureInitializedEvent>(_ =>
|
||||||
|
{
|
||||||
|
// 预加载所有资源
|
||||||
_registry.PreloadAll();
|
_registry.PreloadAll();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -46,7 +46,8 @@ public abstract class Architecture<T> : IArchitecture where T : Architecture<T>,
|
|||||||
foreach (var system in arch._mSystems) system.Init();
|
foreach (var system in arch._mSystems) system.Init();
|
||||||
|
|
||||||
arch._mSystems.Clear();
|
arch._mSystems.Clear();
|
||||||
|
// 发送架构初始化完成事件
|
||||||
|
arch.SendEvent(new ArchitectureEvents.ArchitectureInitializedEvent());
|
||||||
arch._mInited = true;
|
arch._mInited = true;
|
||||||
return arch;
|
return arch;
|
||||||
}, LazyThreadSafetyMode.ExecutionAndPublication);
|
}, LazyThreadSafetyMode.ExecutionAndPublication);
|
||||||
|
|||||||
11
GFramework.Core/events/ArchitectureEvents.cs
Normal file
11
GFramework.Core/events/ArchitectureEvents.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
namespace GFramework.Core.events;
|
||||||
|
|
||||||
|
public static class ArchitectureEvents
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 架构初始化完成事件
|
||||||
|
/// 在所有 Model / System Init 执行完毕后派发
|
||||||
|
/// </summary>
|
||||||
|
public readonly struct ArchitectureInitializedEvent { }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user