From e1040110bb2aa14c8ab7347dc46cd0e2165331fd Mon Sep 17 00:00:00 2001 From: ALEXTANGXIAO <574809918@qq.com> Date: Wed, 13 Dec 2023 23:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E6=8B=93=E5=B1=95GameEvent,?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9F=BA=E4=BA=8EInterface=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E8=B0=83=E7=94=A8=E6=8A=9B=E5=87=BA=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=87=AA=E5=8A=A8=E5=8C=96=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=A3=B0=E6=98=8E=E7=9A=84Interface=E6=9D=A5=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=AE=9E=E7=8E=B0=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 升级拓展GameEvent,支持基于Interface的方法调用抛出事件,以及自动化根据声明的Interface来生成实现代码。 --- .../HotFix/GameLogic/Common/CodeTypes.meta | 3 + .../GameLogic/Common/CodeTypes/Attribute.meta | 3 + .../CodeTypes/Attribute/BaseAttribute.cs | 9 + .../CodeTypes/Attribute/BaseAttribute.cs.meta | 3 + .../GameLogic/Common/CodeTypes/CodeTypes.cs | 75 +++++++ .../Common/CodeTypes/CodeTypes.cs.meta | 3 + .../Common/CodeTypes/UnOrderMultiMapSet.cs | 80 +++++++ .../CodeTypes/UnOrderMultiMapSet.cs.meta | 3 + .../GameScripts/HotFix/GameLogic/Event.meta | 3 + .../GameLogic/Event/EventInterfaceHelper.cs | 20 ++ .../Event/EventInterfaceHelper.cs.meta | 3 + .../Event/EventInterfaceImpAttribute.cs | 16 ++ .../Event/EventInterfaceImpAttribute.cs.meta | 3 + .../HotFix/GameLogic/Event/Gen.meta | 3 + .../GameLogic/Event/Gen/GroupLogic.meta | 8 + .../Gen/GroupLogic/IActorLogicEvent_Gen.cs | 70 ++++++ .../GroupLogic/IActorLogicEvent_Gen.cs.meta | 11 + .../HotFix/GameLogic/Event/Gen/GroupUI.meta | 8 + .../Event/Gen/GroupUI/ILoginUI_Gen.cs | 40 ++++ .../Event/Gen/GroupUI/ILoginUI_Gen.cs.meta | 11 + .../HotFix/GameLogic/Event/Interface.meta | 3 + .../Event/Interface/LogicEventInterface.meta | 3 + .../LogicEventInterface/IActorLogicEvent.cs | 38 ++++ .../IActorLogicEvent.cs.meta | 3 + .../Event/Interface/UIEventInterface.meta | 3 + .../Interface/UIEventInterface/ILoginUI.cs | 17 ++ .../UIEventInterface/ILoginUI.cs.meta | 3 + .../Event/RegisterEventInterface_Logic.cs | 41 ++++ .../RegisterEventInterface_Logic.cs.meta | 3 + .../Event/RegisterEventInterface_UI.cs | 41 ++++ .../Event/RegisterEventInterface_UI.cs.meta | 3 + .../GameLogic/GameApp_RegisterSystem.cs | 3 + .../Assets/TEngine/Editor/EventInterface.meta | 8 + .../EventInterface/EventInterfaceGenerate.cs | 199 ++++++++++++++++++ .../EventInterfaceGenerate.cs.meta | 11 + .../TEngine/Editor/TEngine.Editor.asmdef | 4 +- .../Core/GameEvent/EventInterfaceAttribute.cs | 5 +- .../Runtime/Core/GameEvent/EventMgr.cs | 15 ++ .../Runtime/Core/GameEvent/GameEvent.cs | 1 + 39 files changed, 776 insertions(+), 3 deletions(-) create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs.meta create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs create mode 100644 UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs.meta create mode 100644 UnityProject/Assets/TEngine/Editor/EventInterface.meta create mode 100644 UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs create mode 100644 UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes.meta new file mode 100644 index 00000000..740b9d87 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 40a878a415f34e7a855fc4916bbb8e6b +timeCreated: 1702479104 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute.meta new file mode 100644 index 00000000..21d15a96 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1dcaa491f139438dbd963d8bbf0dba85 +timeCreated: 1702385397 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs new file mode 100644 index 00000000..7697a10f --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace GameLogic +{ + [AttributeUsage(AttributeTargets.Class)] + public class BaseAttribute: Attribute + { + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs.meta new file mode 100644 index 00000000..93772d85 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/Attribute/BaseAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 819c4eaddddd4646a100da2e3f19c3c7 +timeCreated: 1702385397 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs new file mode 100644 index 00000000..519fccdd --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace GameLogic +{ + public class CodeTypes + { + private static CodeTypes _instance; + public static CodeTypes Instance => _instance ??= new CodeTypes(); + + private readonly Dictionary _allTypes = new(); + private readonly UnOrderMultiMapSet _types = new(); + + public void Init(Assembly[] assemblies) + { + Dictionary addTypes = GetAssemblyTypes(assemblies); + foreach ((string fullName, Type type) in addTypes) + { + _allTypes[fullName] = type; + + if (type.IsAbstract) + { + continue; + } + + // 记录所有的有BaseAttribute标记的的类型 + object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true); + + foreach (object o in objects) + { + _types.Add(o.GetType(), type); + } + } + } + + public HashSet GetTypes(Type systemAttributeType) + { + if (!_types.ContainsKey(systemAttributeType)) + { + return new HashSet(); + } + + return _types[systemAttributeType]; + } + + public Dictionary GetTypes() + { + return _allTypes; + } + + public Type GetType(string typeName) + { + return _allTypes[typeName]; + } + + public static Dictionary GetAssemblyTypes(params Assembly[] args) + { + Dictionary types = new Dictionary(); + + foreach (Assembly ass in args) + { + foreach (Type type in ass.GetTypes()) + { + if (type.FullName != null) + { + types[type.FullName] = type; + } + } + } + + return types; + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs.meta new file mode 100644 index 00000000..14cb5f80 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/CodeTypes.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01fdfc4515314c579523ac3716005210 +timeCreated: 1702385429 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs new file mode 100644 index 00000000..f115d426 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs @@ -0,0 +1,80 @@ +using System.Collections.Generic; + +namespace GameLogic +{ + public class UnOrderMultiMapSet: Dictionary> + { + public new HashSet this[TKey t] + { + get + { + HashSet set; + if (!TryGetValue(t, out set)) + { + set = new HashSet(); + } + return set; + } + } + + public Dictionary> GetDictionary() + { + return this; + } + + public void Add(TKey t, TValue k) + { + HashSet set; + TryGetValue(t, out set); + if (set == null) + { + set = new HashSet(); + base[t] = set; + } + set.Add(k); + } + + public bool Remove(TKey t, TValue k) + { + HashSet set; + TryGetValue(t, out set); + if (set == null) + { + return false; + } + if (!set.Remove(k)) + { + return false; + } + if (set.Count == 0) + { + Remove(t); + } + return true; + } + + public bool Contains(TKey t, TValue k) + { + HashSet set; + TryGetValue(t, out set); + if (set == null) + { + return false; + } + return set.Contains(k); + } + + public new int Count + { + get + { + int count = 0; + foreach (KeyValuePair> kv in this) + { + count += kv.Value.Count; + } + return count; + } + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs.meta new file mode 100644 index 00000000..253636f8 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Common/CodeTypes/UnOrderMultiMapSet.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b798f0c1317c4caf9ace168f07b51d4f +timeCreated: 1702385485 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event.meta new file mode 100644 index 00000000..5d11bedd --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d1f693ff76ae490fbe194855d94e8266 +timeCreated: 1702479172 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs new file mode 100644 index 00000000..fa3a000c --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs @@ -0,0 +1,20 @@ +using System; +using TEngine; + +namespace GameLogic +{ + /// + /// 事件接口帮助类。 + /// + internal class EventInterfaceHelper + { + /// + /// 初始化。 + /// + public static void Init() + { + RegisterEventInterface_Logic.Register(GameEvent.EventMgr); + RegisterEventInterface_UI.Register(GameEvent.EventMgr); + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs.meta new file mode 100644 index 00000000..9dc0781d --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9afaf331ee7249adb5cc0953dfd3413c +timeCreated: 1702379658 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs new file mode 100644 index 00000000..9686fe43 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs @@ -0,0 +1,16 @@ +using TEngine; + +namespace GameLogic +{ + [System.AttributeUsage(System.AttributeTargets.Class)] + internal class EventInterfaceImpAttribute : BaseAttribute + { + private EEventGroup _eGroup; + public EEventGroup EventGroup => _eGroup; + + public EventInterfaceImpAttribute(EEventGroup group) + { + _eGroup = group; + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs.meta new file mode 100644 index 00000000..6c996cdf --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/EventInterfaceImpAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8bbf40942b0e4470bb8d8a82577f713c +timeCreated: 1702479403 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen.meta new file mode 100644 index 00000000..eac153e2 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: de49bf2e9f0a4fac85851a582e2fb4ed +timeCreated: 1702379835 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic.meta new file mode 100644 index 00000000..dc1024d1 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bff68b49afffbe54b9d5ff4e4cad4f23 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs new file mode 100644 index 00000000..b43bba22 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by autoBindTool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using UnityEngine; +using UnityEngine.UI; +using TEngine; + +namespace GameLogic +{ + public partial class IActorLogicEvent_Event + { + public static readonly int OnMainPlayerDataChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerDataChange"); + public static readonly int OnMainPlayerLevelChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerLevelChange"); + public static readonly int OnMainPlayerGoldChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerGoldChange"); + public static readonly int OnMainPlayerDiamondChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerDiamondChange"); + public static readonly int OnMainPlayerBindDiamondChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerBindDiamondChange"); + public static readonly int OnMainPlayerCurrencyChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerCurrencyChange"); + public static readonly int OnMainPlayerExpChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerExpChange"); + } + + [EventInterfaceImp(EEventGroup.GroupLogic)] + public partial class IActorLogicEvent_Gen : IActorLogicEvent + { + private EventDispatcher _dispatcher; + public IActorLogicEvent_Gen(EventDispatcher dispatcher) + { + _dispatcher = dispatcher; + } + + public void OnMainPlayerDataChange() + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerDataChange); + } + + public void OnMainPlayerLevelChange() + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerLevelChange); + } + + public void OnMainPlayerGoldChange(System.UInt32 oldVal,System.UInt32 newVal) + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerGoldChange,oldVal,newVal); + } + + public void OnMainPlayerDiamondChange(System.UInt32 oldVal,System.UInt32 newVal) + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerDiamondChange,oldVal,newVal); + } + + public void OnMainPlayerBindDiamondChange(System.UInt32 oldVal,System.UInt32 newVal) + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerBindDiamondChange,oldVal,newVal); + } + + public void OnMainPlayerCurrencyChange(GameLogic.CurrencyType type,System.UInt32 oldVal,System.UInt32 newVal) + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerCurrencyChange,type,oldVal,newVal); + } + + public void OnMainPlayerExpChange(System.UInt64 oldVal,System.UInt64 newVal) + { + _dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerExpChange,oldVal,newVal); + } + + } +} diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs.meta new file mode 100644 index 00000000..6e4a09f5 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupLogic/IActorLogicEvent_Gen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 12d7d4edd7d06bc4286ea4af153380c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI.meta new file mode 100644 index 00000000..21ceb480 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 615ca01c7a524654c91935631f39f570 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs new file mode 100644 index 00000000..4edaf392 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by autoBindTool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using UnityEngine; +using UnityEngine.UI; +using TEngine; + +namespace GameLogic +{ + public partial class ILoginUI_Event + { + public static readonly int OnRoleLogin = RuntimeId.ToRuntimeId("ILoginUI_Event.OnRoleLogin"); + public static readonly int OnRoleLoginOut = RuntimeId.ToRuntimeId("ILoginUI_Event.OnRoleLoginOut"); + } + + [EventInterfaceImp(EEventGroup.GroupUI)] + public partial class ILoginUI_Gen : ILoginUI + { + private EventDispatcher _dispatcher; + public ILoginUI_Gen(EventDispatcher dispatcher) + { + _dispatcher = dispatcher; + } + + public void OnRoleLogin(System.Boolean isReconnect) + { + _dispatcher.Send(ILoginUI_Event.OnRoleLogin,isReconnect); + } + + public void OnRoleLoginOut() + { + _dispatcher.Send(ILoginUI_Event.OnRoleLoginOut); + } + + } +} diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs.meta new file mode 100644 index 00000000..d00bf3c9 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Gen/GroupUI/ILoginUI_Gen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bde7ed0ea10cf29448370b39ecd69a97 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface.meta new file mode 100644 index 00000000..ea8a46e0 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7cf3381dedbf4daeb53e710a5c544204 +timeCreated: 1702433587 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface.meta new file mode 100644 index 00000000..0bc78a33 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 610229edeca4417685ffd07f18b2b9f1 +timeCreated: 1702379817 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs new file mode 100644 index 00000000..f9421e47 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs @@ -0,0 +1,38 @@ +using System; +using TEngine; + +namespace GameLogic +{ + /// + /// 示例货币枚举。 + /// + public enum CurrencyType + { + None, + Gold, + Diamond, + } + + /// + /// 示意逻辑层事件。 + /// 优化抛出事件,通过接口约束事件参数。 + /// example: GameEvent.Get().OnMainPlayerCurrencyChange(CurrencyType.Gold,oldVal,newVal); + /// + [EventInterface(EEventGroup.GroupLogic)] + interface IActorLogicEvent + { + void OnMainPlayerDataChange(); + + void OnMainPlayerLevelChange(); + + void OnMainPlayerGoldChange(uint oldVal, uint newVal); + + void OnMainPlayerDiamondChange(uint oldVal, uint newVal); + + void OnMainPlayerBindDiamondChange(uint oldVal, uint newVal); + + void OnMainPlayerCurrencyChange(CurrencyType type, uint oldVal, uint newVal); + + void OnMainPlayerExpChange(ulong oldVal, ulong newVal); + } +} diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs.meta new file mode 100644 index 00000000..09710a94 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/LogicEventInterface/IActorLogicEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8d4558cb74e8462a86f0ee3461f6b7c9 +timeCreated: 1702383645 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface.meta new file mode 100644 index 00000000..bd25d14b --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 90e13cc92c5d42f28b4f5fab599f472a +timeCreated: 1702379805 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs new file mode 100644 index 00000000..fd957913 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs @@ -0,0 +1,17 @@ +using TEngine; + +namespace GameLogic +{ + /// + /// 示意UI层事件。 + /// 优化抛出事件,通过接口约束事件参数。 + /// example: GameEvent.Get().OnRoleLogin(isReconnect); + /// + [EventInterface(EEventGroup.GroupUI)] + public interface ILoginUI + { + public void OnRoleLogin(bool isReconnect); + + public void OnRoleLoginOut(); + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs.meta new file mode 100644 index 00000000..12d53ab7 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/Interface/UIEventInterface/ILoginUI.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 33b45e62bd3447498acfe874017b9a35 +timeCreated: 1702433755 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs new file mode 100644 index 00000000..45a26dc1 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using TEngine; + +namespace GameLogic +{ + /// + /// 逻辑层事件接口。 + /// + internal class RegisterEventInterface_Logic + { + /// + /// 注册逻辑层事件接口。 + /// + /// 事件管理器。 + public static void Register(EventMgr mgr) + { + HashSet types = CodeTypes.Instance.GetTypes(typeof(EventInterfaceImpAttribute)); + + foreach (Type type in types) + { + object[] attrs = type.GetCustomAttributes(typeof(EventInterfaceImpAttribute), false); + if (attrs.Length == 0) + { + continue; + } + + EventInterfaceImpAttribute httpHandlerAttribute = (EventInterfaceImpAttribute)attrs[0]; + + if (httpHandlerAttribute.EventGroup != EEventGroup.GroupLogic) + { + continue; + } + + object obj = Activator.CreateInstance(type, mgr.Dispatcher); + + mgr.RegWrapInterface(obj.GetType().GetInterfaces()[0]?.FullName, obj); + } + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs.meta new file mode 100644 index 00000000..7b2cc26e --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_Logic.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8bdf6c139b44758aa16db2e1837f5d9 +timeCreated: 1702379518 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs new file mode 100644 index 00000000..3327a153 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using TEngine; + +namespace GameLogic +{ + /// + /// UI层事件接口。 + /// + internal class RegisterEventInterface_UI + { + /// + /// 注册UI层事件接口。 + /// + /// 事件管理器。 + public static void Register(EventMgr mgr) + { + HashSet types = CodeTypes.Instance.GetTypes(typeof(EventInterfaceImpAttribute)); + + foreach (Type type in types) + { + object[] attrs = type.GetCustomAttributes(typeof(EventInterfaceImpAttribute), false); + if (attrs.Length == 0) + { + continue; + } + + EventInterfaceImpAttribute httpHandlerAttribute = (EventInterfaceImpAttribute)attrs[0]; + + if (httpHandlerAttribute.EventGroup != EEventGroup.GroupUI) + { + continue; + } + + object obj = Activator.CreateInstance(type, mgr.Dispatcher); + + mgr.RegWrapInterface(obj.GetType().GetInterfaces()[0]?.FullName, obj); + } + } + } +} \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs.meta b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs.meta new file mode 100644 index 00000000..a3ff2b91 --- /dev/null +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/Event/RegisterEventInterface_UI.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f53b67f2cfbe4912bffee9593cd60970 +timeCreated: 1702379505 \ No newline at end of file diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs index 9d4c5477..9c973f17 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using GameLogic; using TEngine; using UnityEngine; @@ -8,6 +9,8 @@ public partial class GameApp private void Init() { + CodeTypes.Instance.Init(_hotfixAssembly.ToArray()); + EventInterfaceHelper.Init(); _listLogicMgr = new List(); RegisterAllSystem(); InitSystemSetting(); diff --git a/UnityProject/Assets/TEngine/Editor/EventInterface.meta b/UnityProject/Assets/TEngine/Editor/EventInterface.meta new file mode 100644 index 00000000..22841d96 --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/EventInterface.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 86094b7c7ca31ab4da174cc7eae14a3c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs b/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs new file mode 100644 index 00000000..936ef566 --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs @@ -0,0 +1,199 @@ +#region Class Documentation +/************************************************************************************************************ +Class Name: EventInterfaceGenerate.cs +Type: Editor, Generator, Util, Static +Definition: + 用法,在目录"Assets/GameScripts/HotFix/GameLogic/Event/Interface/"下分组照示例声明Interface 模块待抛出事件的接口。编译后自动生成接口实现抛出的脚本。 +Example: + + 旧版抛出事件方式: GameEvent.Send(RuntimeId.ToRuntimeId("OnMainPlayerCurrencyChange"),CurrencyType.Gold,oldVal,newVal); + + 新版抛出事件方式 : GameEvent.Get().OnMainPlayerCurrencyChange(CurrencyType.Gold,oldVal,newVal); + +************************************************************************************************************/ +#endregion + +using System; +using System.Collections; +using System.IO; +using System.Linq; +using System.Reflection; +using TEngine; +using Unity.EditorCoroutines.Editor; +using UnityEditor; +using UnityEngine; + +[InitializeOnLoad] +public static class EventInterfaceGenerate +{ + public static string NameSpace = @"GameLogic"; + + + public const string EventInterfacePath = "Assets/GameScripts/HotFix/GameLogic/Event/Interface/"; + + static EventInterfaceGenerate() + { + Generate(); + } + + [MenuItem("TEngine/Generate EventInterface", false, 300)] + public static void Generate() + { + if (EventInterfaceGenerateTag.HadGenerate) + { + return; + } + + EventInterfaceGenerateTag.HadGenerate = true; + + // 加载程序集 + Assembly assembly = typeof(GameApp).Assembly; + + // 获取程序集中的所有类型 + Type[] types = assembly.GetTypes(); + + // 遍历每个类型 + foreach (Type type in types) + { + // 检查类型是否是接口 + if (!type.IsInterface) + { + continue; + } + + var attribute = type.GetCustomAttributes(typeof(EventInterfaceAttribute), false).FirstOrDefault(); + + if (attribute != null) + { + EventInterfaceAttribute eventInterfaceAttribute = attribute as EventInterfaceAttribute; + + GenAutoBindCode(type, eventInterfaceAttribute); + } + } + + AssetDatabase.Refresh(); + Debug.Log("Generate EventInterface Complete"); + // EditorUtility.DisplayDialog("提示", "代码生成完毕", "OK"); + + EditorCoroutineUtility.StartCoroutine(EventInterfaceGenerateTag.Reset(), null); + } + + /// + /// 生成自动绑定代码 + /// + private static void GenAutoBindCode(Type interfaceType, EventInterfaceAttribute eventInterfaceAttribute) + { + string interfaceName = interfaceType.Name; + string className = $"{interfaceName}_Gen"; + string codePath = $"{Application.dataPath}/GameScripts/HotFix/GameLogic/Event/Gen/{eventInterfaceAttribute.EventGroup}"; + + if (!Directory.Exists(codePath)) + { + Directory.CreateDirectory(codePath); + } + + using (StreamWriter sw = new StreamWriter($"{codePath}/{className}.cs")) + { + sw.WriteLine( + $"//------------------------------------------------------------------------------\n//\t\n//\t\tThis code was generated by autoBindTool.\n//\t\tChanges to this file may cause incorrect behavior and will be lost if\n//\t\tthe code is regenerated.\n//\t\n//------------------------------------------------------------------------------"); + sw.WriteLine("using UnityEngine;"); + sw.WriteLine("using UnityEngine.UI;"); + sw.WriteLine("using TEngine;"); + sw.WriteLine(""); + + if (!string.IsNullOrEmpty(NameSpace)) + { + //命名空间 + sw.WriteLine("namespace " + NameSpace); + sw.WriteLine("{"); + } + + #region EventId生成 + + sw.WriteLine($"\tpublic partial class {interfaceName}_Event"); + sw.WriteLine("\t{"); + + // 获取接口中的所有方法 + MethodInfo[] methods = interfaceType.GetMethods(); + + //组件字段 + foreach (MethodInfo method in methods) + { + sw.WriteLine($"\t\tpublic static readonly int {method.Name} = RuntimeId.ToRuntimeId(\"{interfaceName}_Event.{method.Name}\");"); + } + + sw.WriteLine("\t}"); + sw.WriteLine(""); + + #endregion + + + //类名 + sw.WriteLine($"\t[EventInterfaceImp(EEventGroup.{eventInterfaceAttribute.EventGroup})]"); + sw.WriteLine($"\tpublic partial class {className} : {interfaceName}"); + sw.WriteLine("\t{"); + + sw.WriteLine("\t\tprivate EventDispatcher _dispatcher;"); + sw.WriteLine($"\t\tpublic {className}(EventDispatcher dispatcher)"); + sw.WriteLine("\t\t{"); + sw.WriteLine($"\t\t\t_dispatcher = dispatcher;"); + sw.WriteLine("\t\t}"); + sw.WriteLine(""); + + //组件字段 + foreach (MethodInfo methodInfo in methods) + { + ParameterInfo[] parameterInfos = methodInfo.GetParameters(); //得到指定方法的参数列表 + if (parameterInfos.Length <= 0) + { + sw.WriteLine( + $" public void {methodInfo.Name}()\n {{\n _dispatcher.Send({interfaceName}_Event.{methodInfo.Name});\n }}"); + } + else + { + string paramStr = ""; + string paramStr2 = ""; + for (int i = 0; i < parameterInfos.Length; i++) + { + var parameterInfo = parameterInfos[i]; + Type type = parameterInfo.ParameterType; + string paramName = parameterInfo.Name; + if (i == parameterInfos.Length - 1) + { + paramStr += $"{type.FullName} {paramName}"; + paramStr2 += $"{paramName}"; + } + else + { + paramStr += $"{type.FullName} {paramName},"; + paramStr2 += $"{paramName},"; + } + } + + sw.WriteLine( + $" public void {methodInfo.Name}({paramStr})\n {{\n _dispatcher.Send({interfaceName}_Event.{methodInfo.Name},{paramStr2});\n }}"); + } + + sw.WriteLine(""); + } + + sw.WriteLine("\t}"); + + if (!string.IsNullOrEmpty(NameSpace)) + { + sw.WriteLine("}"); + } + } + } +} + +public static class EventInterfaceGenerateTag +{ + public static bool HadGenerate = false; + + public static IEnumerator Reset() + { + yield return new WaitForSeconds(10f); + HadGenerate = false; + } +} \ No newline at end of file diff --git a/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta b/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta new file mode 100644 index 00000000..2d2f0d43 --- /dev/null +++ b/UnityProject/Assets/TEngine/Editor/EventInterface/EventInterfaceGenerate.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3e3af172e88343e4cb49c9e870518ede +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/TEngine/Editor/TEngine.Editor.asmdef b/UnityProject/Assets/TEngine/Editor/TEngine.Editor.asmdef index c23a1086..f661cd06 100644 --- a/UnityProject/Assets/TEngine/Editor/TEngine.Editor.asmdef +++ b/UnityProject/Assets/TEngine/Editor/TEngine.Editor.asmdef @@ -5,7 +5,9 @@ "GUID:24c092aee38482f4e80715eaa8148782", "GUID:e34a5702dd353724aa315fb8011f08c3", "GUID:4d1926c9df5b052469a1c63448b7609a", - "GUID:2373f786d14518f44b0f475db77ba4de" + "GUID:2373f786d14518f44b0f475db77ba4de", + "GUID:6e76b07590314a543b982daed6af2509", + "GUID:478a2357cc57436488a56e564b08d223" ], "includePlatforms": [ "Editor" diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventInterfaceAttribute.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventInterfaceAttribute.cs index a2f331d0..e9f411b3 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventInterfaceAttribute.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventInterfaceAttribute.cs @@ -19,10 +19,11 @@ namespace TEngine } [System.AttributeUsage(System.AttributeTargets.Interface)] - public class EventInterface : Attribute + public class EventInterfaceAttribute : Attribute { private EEventGroup _eGroup; - public EventInterface(EEventGroup group) + public EEventGroup EventGroup => _eGroup; + public EventInterfaceAttribute(EEventGroup group) { _eGroup = group; } diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventMgr.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventMgr.cs index 8cb704c2..feb2d265 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventMgr.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/EventMgr.cs @@ -50,6 +50,21 @@ namespace TEngine _eventEntryMap.Add(typeName, entry); } } + + /// + /// 注册wrap的函数。 + /// + /// 类型名称。 + /// 调用接口名。 + public void RegWrapInterface(string typeName,object callerWrap) + { + var entry = new EventEntryData(); + entry.InterfaceWrap = callerWrap; + if (typeName != null) + { + _eventEntryMap.Add(typeName, entry); + } + } /// /// 分发注册器。 diff --git a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs index c866890f..bc7e52e3 100644 --- a/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs +++ b/UnityProject/Assets/TEngine/Runtime/Core/GameEvent/GameEvent.cs @@ -12,6 +12,7 @@ namespace TEngine /// private static readonly EventMgr _eventMgr = new EventMgr(); + public static EventMgr EventMgr => _eventMgr; #region 细分的注册接口 ///