mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将所有小写的命名空间导入更正为首字母大写格式 - 统一 GFramework 框架的命名空间引用规范 - 修复 core、ecs、godot 等模块的命名空间导入错误 - 标准化文档示例代码中的 using 语句格式 - 确保所有文档中的命名空间引用保持一致性 - 更新 global using 语句以匹配正确的命名空间格式
52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
namespace GFramework.Core.Abstractions.Events;
|
|
|
|
/// <summary>
|
|
/// 事件总线接口,提供事件的发送、注册和注销功能
|
|
/// </summary>
|
|
public interface IEventBus
|
|
{
|
|
/// <summary>
|
|
/// 发送事件,自动创建事件实例
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型,必须具有无参构造函数</typeparam>
|
|
void Send<T>() where T : new();
|
|
|
|
/// <summary>
|
|
/// 发送指定的事件实例
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="e">事件实例</param>
|
|
void Send<T>(T e);
|
|
|
|
/// <summary>
|
|
/// 发送指定的事件实例,并指定传播模式
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="e">事件实例</param>
|
|
/// <param name="propagation">事件传播模式</param>
|
|
void Send<T>(T e, EventPropagation propagation);
|
|
|
|
/// <summary>
|
|
/// 注册事件监听器
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="onEvent">事件处理回调函数</param>
|
|
/// <returns>反注册接口,用于注销事件监听</returns>
|
|
IUnRegister Register<T>(Action<T> onEvent);
|
|
|
|
/// <summary>
|
|
/// 注册事件监听器,并指定优先级
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="onEvent">事件处理回调函数</param>
|
|
/// <param name="priority">优先级,数值越大优先级越高</param>
|
|
/// <returns>反注册接口,用于注销事件监听</returns>
|
|
IUnRegister Register<T>(Action<T> onEvent, int priority);
|
|
|
|
/// <summary>
|
|
/// 注销事件监听器
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="onEvent">要注销的事件处理回调函数</param>
|
|
void UnRegister<T>(Action<T> onEvent);
|
|
} |