mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将Init方法统一重命名为Initialize方法以提高一致性 - 修改Architecture类中的组件注册逻辑,优化去重判断 - 更新ECS系统基础类以使用新的初始化接口 - 重构EcsWorld类使用属性自动实现而非私有字段 - 移除过时的EcsUsageExample示例文件 - 更新相关测试类以匹配新的初始化方法命名 - 改进代码注释和文档字符串格式
102 lines
3.9 KiB
C#
102 lines
3.9 KiB
C#
using GFramework.Core.Abstractions.lifecycle;
|
||
using GFramework.Core.Abstractions.model;
|
||
using GFramework.Core.Abstractions.system;
|
||
using GFramework.Core.Abstractions.utility;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
|
||
namespace GFramework.Core.Abstractions.architecture;
|
||
|
||
/// <summary>
|
||
/// 架构接口,专注于生命周期管理,包括系统、模型、工具的注册和获取
|
||
/// 业务操作通过 ArchitectureRuntime 提供
|
||
/// </summary>
|
||
public interface IArchitecture : IAsyncInitializable, IAsyncDestroyable, IInitializable, IDestroyable
|
||
{
|
||
/// <summary>
|
||
/// 获取架构上下文
|
||
/// </summary>
|
||
IArchitectureContext Context { get; }
|
||
|
||
/// <summary>
|
||
/// 获取或设置用于配置服务集合的委托
|
||
/// </summary>
|
||
/// <value>
|
||
/// 一个可为空的委托,用于配置IServiceCollection实例
|
||
/// </value>
|
||
Action<IServiceCollection>? Configurator { get; }
|
||
|
||
/// <summary>
|
||
/// 注册系统实例到架构中
|
||
/// </summary>
|
||
/// <typeparam name="T">系统类型,必须实现ISystem接口</typeparam>
|
||
/// <param name="system">要注册的系统实例</param>
|
||
/// <returns>注册的系统实例</returns>
|
||
T RegisterSystem<T>(T system) where T : ISystem;
|
||
|
||
/// <summary>
|
||
/// 注册系统实例到架构中
|
||
/// </summary>
|
||
/// <typeparam name="T">系统类型,必须实现ISystem接口</typeparam>
|
||
/// <param name="onCreated">系统实例创建后的回调函数,可为null</param>
|
||
void RegisterSystem<T>(Action<T>? onCreated = null) where T : class, ISystem;
|
||
|
||
/// <summary>
|
||
/// 注册模型实例到架构中
|
||
/// </summary>
|
||
/// <typeparam name="T">模型类型,必须实现IModel接口</typeparam>
|
||
/// <param name="model">要注册的模型实例</param>
|
||
/// <returns>注册的模型实例</returns>
|
||
T RegisterModel<T>(T model) where T : IModel;
|
||
|
||
/// <summary>
|
||
/// 注册模型实例到架构中
|
||
/// </summary>
|
||
/// <typeparam name="T">模型类型,必须实现IModel接口</typeparam>
|
||
/// <param name="onCreated">模型实例创建后的回调函数,可为null</param>
|
||
void RegisterModel<T>(Action<T>? onCreated = null) where T : class, IModel;
|
||
|
||
/// <summary>
|
||
/// 注册工具实例到架构中
|
||
/// </summary>
|
||
/// <typeparam name="T">工具类型,必须实现IUtility接口</typeparam>
|
||
/// <param name="utility">要注册的工具实例</param>
|
||
/// <returns>注册的工具实例</returns>
|
||
T RegisterUtility<T>(T utility) where T : IUtility;
|
||
|
||
|
||
/// <summary>
|
||
/// 注册工具类型并可选地指定创建回调
|
||
/// 当工具实例被创建时会调用指定的回调函数
|
||
/// </summary>
|
||
/// <typeparam name="T">工具类型,必须是引用类型且实现IUtility接口</typeparam>
|
||
/// <param name="onCreated">工具实例创建后的回调函数,可为null</param>
|
||
void RegisterUtility<T>(Action<T>? onCreated = null) where T : class, IUtility;
|
||
|
||
/// <summary>
|
||
/// 注册中介行为管道
|
||
/// 用于配置Mediator框架的行为拦截和处理逻辑
|
||
/// </summary>
|
||
/// <typeparam name="TBehavior">行为类型,必须是引用类型</typeparam>
|
||
void RegisterMediatorBehavior<TBehavior>()
|
||
where TBehavior : class;
|
||
|
||
/// <summary>
|
||
/// 安装架构模块
|
||
/// </summary>
|
||
/// <param name="module">要安装的模块</param>
|
||
/// <returns>安装的模块实例</returns>
|
||
IArchitectureModule InstallModule(IArchitectureModule module);
|
||
|
||
/// <summary>
|
||
/// 注册生命周期钩子
|
||
/// </summary>
|
||
/// <param name="hook">生命周期钩子实例</param>
|
||
/// <returns>注册的钩子实例</returns>
|
||
IArchitectureLifecycle RegisterLifecycleHook(IArchitectureLifecycle hook);
|
||
|
||
/// <summary>
|
||
/// 等待直到架构准备就绪的异步操作
|
||
/// </summary>
|
||
/// <returns>表示异步等待操作的任务</returns>
|
||
Task WaitUntilReadyAsync();
|
||
} |