diff --git a/Server/App/Program.cs b/Server/App/Program.cs index fed21db019270e7f0fbc336142832797aa1abae9..3bac2b2aa57e73d137cba0bcb7582b07206d514d 100644 --- a/Server/App/Program.cs +++ b/Server/App/Program.cs @@ -36,7 +36,7 @@ namespace ET Log.Info($"server start........................ {Game.Scene.Id}"); // 先加这里,后面删掉 - Game.EventSystem.Run(EventIdType.AfterScenesAdd); + Game.EventSystem.Publish(new EventType.AppStart()); while (true) { diff --git a/Server/Hotfix/Module/Scene/AfterScenesAdd_CreateScene.cs b/Server/Hotfix/Module/Scene/AppStart_InitGame.cs similarity index 88% rename from Server/Hotfix/Module/Scene/AfterScenesAdd_CreateScene.cs rename to Server/Hotfix/Module/Scene/AppStart_InitGame.cs index b3ff0ffcaf2d76a7852ac557eee186b734c66c35..41205ad81a21ed1cfbaa1ba7ba4e300a55e53f60 100644 --- a/Server/Hotfix/Module/Scene/AfterScenesAdd_CreateScene.cs +++ b/Server/Hotfix/Module/Scene/AppStart_InitGame.cs @@ -2,10 +2,15 @@ namespace ET { - [Event(EventIdType.AfterScenesAdd)] - public class AfterScenesAdd_CreateScene: AEvent + [Event] + public class AppStart_Init: AEvent { - public override void Run() + public override void Run(EventType.AppStart args) + { + RunAsync().Coroutine(); + } + + public async ETVoid RunAsync() { Game.Scene.AddComponent(); @@ -30,11 +35,6 @@ namespace ET Game.Scene.AddComponent(processConfig.InnerAddress); - RunInner().Coroutine(); - } - - public async ETVoid RunInner() - { var processScenes = StartSceneConfigCategory.Instance.GetByProcess(IdGenerater.Process); foreach (StartSceneConfig startConfig in processScenes) { diff --git a/Server/Model/Base/Event/EventIdType.cs b/Server/Model/Base/Event/EventIdType.cs deleted file mode 100644 index 6292d758ba8c170ce1726099b36b19954ceea16c..0000000000000000000000000000000000000000 --- a/Server/Model/Base/Event/EventIdType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ET -{ - public static class EventIdType - { - public const string NumbericChange = "NumbericChange"; - public const string AfterScenesAdd = "AfterScenesAdd"; - } -} \ No newline at end of file diff --git a/Server/Model/EventType.cs b/Server/Model/EventType.cs new file mode 100644 index 0000000000000000000000000000000000000000..7298cf1f9e4af66bd7e54160efb34efadb3cddd7 --- /dev/null +++ b/Server/Model/EventType.cs @@ -0,0 +1,9 @@ +namespace ET +{ + namespace EventType + { + public struct AppStart + { + } + } +} \ No newline at end of file diff --git a/Server/Model/Other/Options.cs b/Server/Model/Other/Options.cs index f99ce4c4fb88f84d772a17dda95a3b6c5dc54218..3f7821d53fcf72f796d2a73bc6d36beb91568154 100644 --- a/Server/Model/Other/Options.cs +++ b/Server/Model/Other/Options.cs @@ -4,7 +4,7 @@ namespace ET { public class Options: Entity { - [Option("process", Required = false, Default = 1)] + [Option("Process", Required = false, Default = 1)] public int Process { get; set; } } } \ No newline at end of file diff --git a/Server/Model/Server.Model.csproj b/Server/Model/Server.Model.csproj index 0b853e7eea0f6f7de01ed6eb2d4a1d9a0a379a66..914c08440e496d983ae8579a4474e927c2cd8c67 100644 --- a/Server/Model/Server.Model.csproj +++ b/Server/Model/Server.Model.csproj @@ -77,9 +77,6 @@ Base\Object\EntityFactory.cs - - Base\Object\EventProxy.cs - Base\Object\EventSystem.cs diff --git a/Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs b/Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs index b5dba009ab4ab80a68784d5af925805835ba4a9b..0e10c9ae70a07b2fab8299ea6000f262f86e438e 100644 --- a/Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs +++ b/Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs @@ -1,12 +1,12 @@ namespace ET { // 分发数值监听 - [Event(EventIdType.NumbericChange)] - public class NumericChangeEvent_NotifyWatcher: AEvent + [Event] + public class NumericChangeEvent_NotifyWatcher: AEvent { - public override void Run(long id, NumericType numericType, int value) + public override void Run(EventType.NumbericChange args) { - Game.Scene.GetComponent().Run(numericType, id, value); + Game.Scene.GetComponent().Run(args.NumericType, args.Parent.Id, args.New); } } } diff --git a/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs index eb009b0c2ecb6f89fa26b92ae9c89b612e8266fc..924c8cbab84f98f039767edf94a6622c6a496ae8 100644 --- a/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs +++ b/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs @@ -2,12 +2,12 @@ namespace ET { - [Event(EventIdType.LoadingBegin)] - public class LoadingBeginEvent_CreateLoadingUI : AEvent + [Event()] + public class LoadingBeginEvent_CreateLoadingUI : AEvent { - public override void Run(Entity domain) + public override void Run(EventType.LoadingBegin args) { - UI ui = UILoadingFactory.Create(domain); + UI ui = UILoadingFactory.Create(args.Scene); Game.Scene.GetComponent().Add(ui); } } diff --git a/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs index b0249d7da1519bb403ea55981de8f625d3bd5ce1..e77a67e884835b55cea32d643b87ed79bedc9e99 100644 --- a/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs +++ b/Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs @@ -1,9 +1,9 @@ namespace ET { - [Event(EventIdType.LoadingFinish)] - public class LoadingFinishEvent_RemoveLoadingUI : AEvent + [Event] + public class LoadingFinishEvent_RemoveLoadingUI : AEvent { - public override void Run() + public override void Run(EventType.LoadingFinish args) { Game.Scene.GetComponent().Remove(UIType.UILoading); } diff --git a/Unity/Assets/HotfixView/Demo/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs index 6e4b4ee5c14743f07af9374e0cef9346976319e5..e71ab1bf75ac219866a4edc32ead35f0307973f4 100644 --- a/Unity/Assets/HotfixView/Demo/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs +++ b/Unity/Assets/HotfixView/Demo/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs @@ -1,11 +1,9 @@ - - -namespace ET +namespace ET { - [Event(EventIdType.EnterMapFinish)] - public class EnterMapFinish_RemoveLobbyUI: AEvent + [Event] + public class EnterMapFinish_RemoveLobbyUI: AEvent { - public override void Run() + public override void Run(EventType.EnterMapFinish args) { Game.Scene.GetComponent().Remove(UIType.UILobby); Game.Scene.GetComponent().UnloadBundle(UIType.UILobby.StringToAB()); diff --git a/Unity/Assets/HotfixView/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs index 0bb3718799a26d4396958c26d9b30469b979baea..35038fafd721dd9b8f5c8f0ab96bb3b2e711f36f 100644 --- a/Unity/Assets/HotfixView/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs +++ b/Unity/Assets/HotfixView/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs @@ -2,10 +2,10 @@ namespace ET { - [Event(EventIdType.LoginFinish)] - public class LoginFinish_CreateLobbyUI: AEvent + [Event] + public class LoginFinish_CreateLobbyUI: AEvent { - public override void Run() + public override void Run(EventType.LoginFinish args) { UI ui = UILobbyFactory.Create(); Game.Scene.GetComponent().Add(ui); diff --git a/Unity/Assets/HotfixView/Demo/UI/UILogin/InitSceneStart_CreateLoginUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILogin/InitSceneStart_CreateLoginUI.cs deleted file mode 100644 index d04ea79e7fcb394f77fcf6a2e4c66704f07c5c53..0000000000000000000000000000000000000000 --- a/Unity/Assets/HotfixView/Demo/UI/UILogin/InitSceneStart_CreateLoginUI.cs +++ /dev/null @@ -1,14 +0,0 @@ - - -namespace ET -{ - [Event(EventIdType.InitSceneStart)] - public class InitSceneStart_CreateLoginUI: AEvent - { - public override void Run() - { - UI ui = UILoginFactory.Create(); - Game.Scene.GetComponent().Add(ui); - } - } -} diff --git a/Unity/Assets/HotfixView/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs b/Unity/Assets/HotfixView/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs index 5b3162433c99b64671dad8e78ad85f41195e1beb..ecc720f6283ae97683e32df4744d1e6689f72a08 100644 --- a/Unity/Assets/HotfixView/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs +++ b/Unity/Assets/HotfixView/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs @@ -2,10 +2,10 @@ namespace ET { - [Event(EventIdType.LoginFinish)] - public class LoginFinish_RemoveLoginUI: AEvent + [Event] + public class LoginFinish_RemoveLoginUI: AEvent { - public override void Run() + public override void Run(EventType.LoginFinish args) { Game.Scene.GetComponent().Remove(UIType.UILogin); Game.Scene.GetComponent().UnloadBundle(UIType.UILogin.StringToAB()); diff --git a/Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs b/Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs index 44e4f0bab2a235a114003079c1567bd2912c0911..19341334b79e3e0bc973a32f76f718e3b447b8fd 100644 --- a/Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs +++ b/Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs @@ -2,10 +2,10 @@ namespace ET { - [Event(EventIdType.AfterUnitCreate)] - public class AfterUnitCreate_CreateUnitView: AEvent + [Event] + public class AfterUnitCreate_CreateUnitView: AEvent { - public override void Run(Unit unit) + public override void Run(EventType.AfterUnitCreate args) { // Unit View层 ResourcesComponent resourcesComponent = Game.Scene.GetComponent(); @@ -14,7 +14,7 @@ namespace ET GameObject go = UnityEngine.Object.Instantiate(prefab); - unit.AddComponent(); + args.Unit.AddComponent(); } } } \ No newline at end of file diff --git a/Unity/Assets/Model/Base/Event/EventAttribute.cs b/Unity/Assets/Model/Base/Event/EventAttribute.cs index 260167ed0b80ea1b1f66e79b8ff3c9f001dede78..ed6e7bc9c0c8ee24b6be4e5320e25b8e7b54503c 100644 --- a/Unity/Assets/Model/Base/Event/EventAttribute.cs +++ b/Unity/Assets/Model/Base/Event/EventAttribute.cs @@ -5,11 +5,5 @@ namespace ET [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class EventAttribute: BaseAttribute { - public string Type { get; } - - public EventAttribute(string type) - { - this.Type = type; - } } } \ No newline at end of file diff --git a/Unity/Assets/Model/Base/Event/EventIdType.cs b/Unity/Assets/Model/Base/Event/EventIdType.cs deleted file mode 100644 index 057980f4484a01679badf28dd2cbfbb44b662f81..0000000000000000000000000000000000000000 --- a/Unity/Assets/Model/Base/Event/EventIdType.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace ET -{ - public static class EventIdType - { - public const string RecvHotfixMessage = "RecvHotfixMessage"; - public const string BehaviorTreeRunTreeEvent = "BehaviorTreeRunTreeEvent"; - public const string BehaviorTreeOpenEditor = "BehaviorTreeOpenEditor"; - public const string BehaviorTreeClickNode = "BehaviorTreeClickNode"; - public const string BehaviorTreeAfterChangeNodeType = "BehaviorTreeAfterChangeNodeType"; - public const string BehaviorTreeCreateNode = "BehaviorTreeCreateNode"; - public const string BehaviorTreePropertyDesignerNewCreateClick = "BehaviorTreePropertyDesignerNewCreateClick"; - public const string BehaviorTreeMouseInNode = "BehaviorTreeMouseInNode"; - public const string BehaviorTreeConnectState = "BehaviorTreeConnectState"; - public const string BehaviorTreeReplaceClick = "BehaviorTreeReplaceClick"; - public const string BehaviorTreeRightDesignerDrag = "BehaviorTreeRightDesignerDrag"; - public const string SessionRecvMessage = "SessionRecvMessage"; - public const string NumbericChange = "NumbericChange"; - public const string MessageDeserializeFinish = "MessageDeserializeFinish"; - public const string SceneChange = "SceneChange"; - public const string FrameUpdate = "FrameUpdate"; - public const string LoadingBegin = "LoadingBegin"; - public const string LoadingFinish = "LoadingFinish"; - public const string TestHotfixSubscribMonoEvent = "TestHotfixSubscribMonoEvent"; - public const string MaxModelEvent = "MaxModelEvent"; - public const string InitSceneStart = "InitSceneStart"; - public const string LoginFinish = "LoginFinish"; - public const string EnterMapFinish = "EnterMapFinish"; - public const string AfterUnitCreate = "AfterUnitCreate"; - } -} \ No newline at end of file diff --git a/Unity/Assets/Model/Base/Event/IEvent.cs b/Unity/Assets/Model/Base/Event/IEvent.cs index 169f36795a00e3deff899eb6f66a0c1086553ca3..978e59332c23dd5c66caeb1bfc1ca8ece5c8d73f 100644 --- a/Unity/Assets/Model/Base/Event/IEvent.cs +++ b/Unity/Assets/Model/Base/Event/IEvent.cs @@ -2,111 +2,8 @@ namespace ET { - public interface IEvent + public abstract class AEvent where A: struct { - void Handle(); - void Handle(object a); - void Handle(object a, object b); - void Handle(object a, object b, object c); - } - - public abstract class AEvent : IEvent - { - public void Handle() - { - this.Run(); - } - - public void Handle(object a) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b, object c) - { - throw new NotImplementedException(); - } - - public abstract void Run(); - } - - public abstract class AEvent: IEvent - { - public void Handle() - { - throw new NotImplementedException(); - } - - public void Handle(object a) - { - this.Run((A)a); - } - - public void Handle(object a, object b) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b, object c) - { - throw new NotImplementedException(); - } - public abstract void Run(A a); } - - public abstract class AEvent: IEvent - { - public void Handle() - { - throw new NotImplementedException(); - } - - public void Handle(object a) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b) - { - this.Run((A)a, (B)b); - } - - public void Handle(object a, object b, object c) - { - throw new NotImplementedException(); - } - - public abstract void Run(A a, B b); - } - - public abstract class AEvent: IEvent - { - public void Handle() - { - throw new NotImplementedException(); - } - - public void Handle(object a) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b) - { - throw new NotImplementedException(); - } - - public void Handle(object a, object b, object c) - { - this.Run((A)a, (B)b, (C)c); - } - - public abstract void Run(A a, B b, C c); - } } \ No newline at end of file diff --git a/Unity/Assets/Model/Base/Object/EventProxy.cs b/Unity/Assets/Model/Base/Object/EventProxy.cs deleted file mode 100644 index 7237d642e4cb56b298acfba16aa1cc350617de19..0000000000000000000000000000000000000000 --- a/Unity/Assets/Model/Base/Object/EventProxy.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace ET -{ - public class EventProxy: IEvent - { - public Action> action; - public List param = new List(); - - public EventProxy(Action> action) - { - this.action = action; - } - - public void Handle() - { - this.param.Clear(); - this.action.Invoke(this.param); - } - - public void Handle(object a) - { - this.param.Clear(); - this.param.Add(a); - this.action.Invoke(this.param); - } - - public void Handle(object a, object b) - { - this.param.Clear(); - this.param.Add(a); - this.param.Add(b); - this.action.Invoke(this.param); - } - - public void Handle(object a, object b, object c) - { - this.param.Clear(); - this.param.Add(a); - this.param.Add(b); - this.param.Add(c); - this.action.Invoke(this.param); - } - } -} diff --git a/Unity/Assets/Model/Base/Object/EventSystem.cs b/Unity/Assets/Model/Base/Object/EventSystem.cs index f29bcbd0a9bd302fa000f2721c97b803fea849c8..e14706f148be744dca3bb32d5feb33345b04f8a4 100644 --- a/Unity/Assets/Model/Base/Object/EventSystem.cs +++ b/Unity/Assets/Model/Base/Object/EventSystem.cs @@ -36,7 +36,7 @@ namespace ET private readonly UnOrderMultiMapSet types = new UnOrderMultiMapSet(); - private readonly Dictionary> allEvents = new Dictionary>(); + private readonly Dictionary> allEvents = new Dictionary>(); private readonly UnOrderMultiMap awakeSystems = new UnOrderMultiMap(); @@ -140,19 +140,12 @@ namespace ET this.allEvents.Clear(); foreach (Type type in types[typeof(EventAttribute)]) { - object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); - - foreach (object attr in attrs) + object obj = Activator.CreateInstance(type); + if (!this.allEvents.ContainsKey(type)) { - EventAttribute aEventAttribute = (EventAttribute)attr; - object obj = Activator.CreateInstance(type); - IEvent iEvent = obj as IEvent; - if (iEvent == null) - { - Log.Error($"{obj.GetType().Name} 没有继承IEvent"); - } - this.RegisterEvent(aEventAttribute.Type, iEvent); + this.allEvents.Add(type, new List()); } + this.allEvents[type].Add(obj); } this.Load(); @@ -162,15 +155,6 @@ namespace ET { return this.assemblies[name]; } - - public void RegisterEvent(string eventId, IEvent e) - { - if (!this.allEvents.ContainsKey(eventId)) - { - this.allEvents.Add(eventId, new List()); - } - this.allEvents[eventId].Add(e); - } public HashSet GetTypes(Type systemAttributeType) { @@ -628,35 +612,10 @@ namespace ET ObjectHelper.Swap(ref this.lateUpdates, ref this.lateUpdates2); } - public void Run(string type) - { - List iEvents; - if (!this.allEvents.TryGetValue(type, out iEvents)) - { - return; - } - foreach (object obj in iEvents) - { - try - { - if (!(obj is AEvent aEvent)) - { - Log.Error($"event error: {obj.GetType().Name}"); - continue; - } - aEvent.Run(); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public void Run(string type, A a) + public void Publish(T a) where T: struct { List iEvents; - if (!this.allEvents.TryGetValue(type, out iEvents)) + if (!this.allEvents.TryGetValue(typeof(T), out iEvents)) { return; } @@ -664,7 +623,7 @@ namespace ET { try { - if (!(obj is AEvent aEvent)) + if (!(obj is AEvent aEvent)) { Log.Error($"event error: {obj.GetType().Name}"); continue; @@ -678,55 +637,6 @@ namespace ET } } - public void Run(string type, A a, B b) - { - List iEvents; - if (!this.allEvents.TryGetValue(type, out iEvents)) - { - return; - } - foreach (object obj in iEvents) - { - try - { - if (!(obj is AEvent aEvent)) - { - Log.Error($"event error: {obj.GetType().Name}"); - continue; - } - aEvent.Run(a, b); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public void Run(string type, A a, B b, C c) - { - List iEvents; - if (!this.allEvents.TryGetValue(type, out iEvents)) - { - return; - } - foreach (object obj in iEvents) - { - try - { - if (!(obj is AEvent aEvent)) - { - Log.Error($"event error: {obj.GetType().Name}"); - continue; - } - aEvent.Run(a, b, c); - } - catch (Exception e) - { - Log.Error(e); - } - } - } public override string ToString() { diff --git a/Unity/Assets/Model/Demo/Helper/LoginHelper.cs b/Unity/Assets/Model/Demo/Helper/LoginHelper.cs index 3f3829d1c475c2e113703000857aa919ec4b5077..67b1ba6abb003a35d17655a4ba1ba582f163ac54 100644 --- a/Unity/Assets/Model/Demo/Helper/LoginHelper.cs +++ b/Unity/Assets/Model/Demo/Helper/LoginHelper.cs @@ -34,7 +34,7 @@ namespace ET PlayerComponent playerComponent = Game.Scene.GetComponent(); playerComponent.MyPlayer = player; - Game.EventSystem.Run(EventIdType.LoginFinish); + Game.EventSystem.Publish(new EventType.LoginFinish()); // 测试消息有成员是class类型 G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo) await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo()); diff --git a/Unity/Assets/Model/Demo/Helper/MapHelper.cs b/Unity/Assets/Model/Demo/Helper/MapHelper.cs index 6fad6ef81ac0ee2054f789c6d9a53288219a4f11..9eaa81cc562dd8500dc5defbdc94f9ebd3a9299a 100644 --- a/Unity/Assets/Model/Demo/Helper/MapHelper.cs +++ b/Unity/Assets/Model/Demo/Helper/MapHelper.cs @@ -26,7 +26,7 @@ namespace ET Game.Scene.AddComponent(); - Game.EventSystem.Run(EventIdType.EnterMapFinish); + Game.EventSystem.Publish(new EventType.EnterMapFinish()); } catch (Exception e) { diff --git a/Unity/Assets/Model/Demo/Helper/UnitFactory.cs b/Unity/Assets/Model/Demo/Helper/UnitFactory.cs index 662b7c170da51e2fce0f9ac1ba4e98f36579a286..70ee95768c7177015a5b9dd76f55b11203c8903a 100644 --- a/Unity/Assets/Model/Demo/Helper/UnitFactory.cs +++ b/Unity/Assets/Model/Demo/Helper/UnitFactory.cs @@ -12,7 +12,7 @@ namespace ET unit.AddComponent(); unit.AddComponent(); - Game.EventSystem.Run(EventIdType.AfterUnitCreate, unit); + Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit}); UnitComponent unitComponent = Game.Scene.GetComponent(); unitComponent.Add(unit); diff --git a/Unity/Assets/Model/EventType.cs b/Unity/Assets/Model/EventType.cs new file mode 100644 index 0000000000000000000000000000000000000000..0ba15492915ab032997c317ec5f8412ea7b0a28a --- /dev/null +++ b/Unity/Assets/Model/EventType.cs @@ -0,0 +1,25 @@ +namespace ET +{ + namespace EventType + { + public struct LoginFinish + {} + + public struct LoadingBegin + { + public Scene Scene; + } + + public struct LoadingFinish + { + } + + public struct EnterMapFinish + {} + + public struct AfterUnitCreate + { + public Unit Unit; + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Model/Helper/BundleHelper.cs b/Unity/Assets/Model/Helper/BundleHelper.cs index 16e0706131f9f7deeb878745f931c20d4aa7c19e..d917d0877bb554cfe974a98809547f9294792cd8 100644 --- a/Unity/Assets/Model/Helper/BundleHelper.cs +++ b/Unity/Assets/Model/Helper/BundleHelper.cs @@ -17,12 +17,12 @@ namespace ET { await bundleDownloaderComponent.StartAsync(url); - Game.EventSystem.Run(EventIdType.LoadingBegin); + Game.EventSystem.Publish(new EventType.LoadingBegin() {Scene = Game.Scene}); await bundleDownloaderComponent.DownloadAsync(url); } - Game.EventSystem.Run(EventIdType.LoadingFinish); + Game.EventSystem.Publish(new EventType.LoadingFinish()); Game.Scene.GetComponent().LoadOneBundle("StreamingAssets"); ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent().GetAsset("StreamingAssets", "AssetBundleManifest"); diff --git a/Unity/Assets/Model/Module/Numeric/NumericComponent.cs b/Unity/Assets/Model/Module/Numeric/NumericComponent.cs index de6bca79324c25c365f50c343cbe8c45a9847c38..970f121621cc30ead457a077aef79ea586ea033d 100644 --- a/Unity/Assets/Model/Module/Numeric/NumericComponent.cs +++ b/Unity/Assets/Model/Module/Numeric/NumericComponent.cs @@ -2,6 +2,17 @@ namespace ET { + namespace EventType + { + public struct NumbericChange + { + public Entity Parent; + public NumericType NumericType; + public int Old; + public int New; + } + } + [ObjectSystem] public class NumericComponentAwakeSystem : AwakeSystem { @@ -92,9 +103,16 @@ namespace ET // 一个数值可能会多种情况影响,比如速度,加个buff可能增加速度绝对值100,也有些buff增加10%速度,所以一个值可以由5个值进行控制其最终结果 // final = (((base + add) * (100 + pct) / 100) + finalAdd) * (100 + finalPct) / 100; + int old = this.NumericDic[final]; int result = (int)(((this.GetByKey(bas) + this.GetByKey(add)) * (100 + this.GetAsFloat(pct)) / 100f + this.GetByKey(finalAdd)) * (100 + this.GetAsFloat(finalPct)) / 100f * 10000); this.NumericDic[final] = result; - Game.EventSystem.Run(EventIdType.NumbericChange, this.Parent.Id, (NumericType) final, result); + Game.EventSystem.Publish(new EventType.NumbericChange() + { + Parent = this.Parent, + NumericType = (NumericType) final, + Old = old, + New = result + }); } } } \ No newline at end of file diff --git a/Unity/Unity.HotfixView.csproj b/Unity/Unity.HotfixView.csproj index 75b98df05b5d63975971783ef4bb60760ffd2728..b8e89789b29894b04696869d15b0a51276518c62 100644 --- a/Unity/Unity.HotfixView.csproj +++ b/Unity/Unity.HotfixView.csproj @@ -1,4 +1,4 @@ - + latest @@ -67,7 +67,6 @@ - diff --git a/Unity/Unity.Model.csproj b/Unity/Unity.Model.csproj index 26f2db4ac03f7018e7bb9645099b89b1ba9e36cf..6ff5585783a9e12eff0ca8d8b9d415b1341b1709 100644 --- a/Unity/Unity.Model.csproj +++ b/Unity/Unity.Model.csproj @@ -1,4 +1,4 @@ - + latest @@ -73,7 +73,6 @@ - @@ -101,7 +100,6 @@ - @@ -158,6 +156,7 @@ +