diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDelegateData.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDelegateData.cs index 4b6925f0..f503c483 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDelegateData.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDelegateData.cs @@ -231,5 +231,35 @@ namespace TEngine CheckModify(); } + + /// + /// 回调调用。 + /// + /// 事件参数1。 + /// 事件参数2。 + /// 事件参数3。 + /// 事件参数4。 + /// 事件参数5。 + /// 事件参数6。 + /// 事件参数1类型。 + /// 事件参数2类型。 + /// 事件参数3类型。 + /// 事件参数4类型。 + /// 事件参数5类型。 + /// 事件参数6类型。 + public void Callback(TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6) + { + _isExecute = true; + for (var i = 0; i < _listExist.Count; i++) + { + var d = _listExist[i]; + if (d is Action action) + { + action(arg1, arg2, arg3, arg4, arg5, arg6); + } + } + + CheckModify(); + } } } \ No newline at end of file diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDispatcher.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDispatcher.cs index 7f319e5b..4ba105e3 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDispatcher.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventDispatcher.cs @@ -151,6 +151,29 @@ namespace TEngine } } + /// + /// 发送事件。 + /// + /// 事件类型。 + /// 事件参数1。 + /// 事件参数2。 + /// 事件参数3。 + /// 事件参数4。 + /// 事件参数5。 + /// 事件参数6。 + /// 事件参数1类型。 + /// 事件参数2类型。 + /// 事件参数3类型。 + /// 事件参数4类型。 + /// 事件参数5类型。 + /// 事件参数6类型。 + public void Send(int eventType, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6) + { + if (_eventTable.TryGetValue(eventType, out var d)) + { + d.Callback(arg1, arg2, arg3, arg4, arg5, arg6); + } + } #endregion } } \ No newline at end of file diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs index 5039c8fc..c866890f 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs @@ -94,6 +94,23 @@ namespace TEngine { return _eventMgr.Dispatcher.AddEventListener(eventType, handler); } + + /// + /// 增加事件监听。 + /// + /// 事件类型。 + /// 事件处理回调。 + /// 事件参数1类型。 + /// 事件参数2类型。 + /// 事件参数3类型。 + /// 事件参数4类型。 + /// 事件参数5类型。 + /// 事件参数6类型。 + /// + public static bool AddEventListener(int eventType, Action handler) + { + return _eventMgr.Dispatcher.AddEventListener(eventType, handler); + } /// /// 移除事件监听。 @@ -534,6 +551,27 @@ namespace TEngine { _eventMgr.Dispatcher.Send(RuntimeId.ToRuntimeId(eventType), arg1, arg2, arg3, arg4, arg5); } + + /// + /// + /// + /// 事件类型。 + /// 事件参数1。 + /// 事件参数2。 + /// 事件参数3。 + /// 事件参数4。 + /// 事件参数5。 + /// 事件参数6。 + /// 事件参数1类型。 + /// 事件参数2类型。 + /// 事件参数3类型。 + /// 事件参数4类型。 + /// 事件参数5类型。 + /// 事件参数6类型。 + public static void Send(int eventType, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6) + { + _eventMgr.Dispatcher.Send(eventType, arg1, arg2, arg3, arg4, arg5, arg6); + } /// ///