Просмотр исходного кода

EventSystem 事件方法修改,改名成publish,参数改成统一为struct,这样的好处是,不会出现订阅的事件与发布的事件参数不一致的问题

tanghai 5 лет назад
Родитель
Сommit
b32a959740
27 измененных файлов с 105 добавлено и 357 удалено
  1. 1 1
      Server/App/Program.cs
  2. 8 8
      Server/Hotfix/Module/Scene/AppStart_InitGame.cs
  3. 0 8
      Server/Model/Base/Event/EventIdType.cs
  4. 9 0
      Server/Model/EventType.cs
  5. 1 1
      Server/Model/Other/Options.cs
  6. 0 3
      Server/Model/Server.Model.csproj
  7. 4 4
      Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs
  8. 4 4
      Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs
  9. 3 3
      Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs
  10. 4 6
      Unity/Assets/HotfixView/Demo/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs
  11. 3 3
      Unity/Assets/HotfixView/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs
  12. 0 14
      Unity/Assets/HotfixView/Demo/UI/UILogin/InitSceneStart_CreateLoginUI.cs
  13. 3 3
      Unity/Assets/HotfixView/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs
  14. 4 4
      Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs
  15. 0 6
      Unity/Assets/Model/Base/Event/EventAttribute.cs
  16. 0 30
      Unity/Assets/Model/Base/Event/EventIdType.cs
  17. 1 104
      Unity/Assets/Model/Base/Event/IEvent.cs
  18. 0 46
      Unity/Assets/Model/Base/Object/EventProxy.cs
  19. 8 98
      Unity/Assets/Model/Base/Object/EventSystem.cs
  20. 1 1
      Unity/Assets/Model/Demo/Helper/LoginHelper.cs
  21. 1 1
      Unity/Assets/Model/Demo/Helper/MapHelper.cs
  22. 1 1
      Unity/Assets/Model/Demo/Helper/UnitFactory.cs
  23. 25 0
      Unity/Assets/Model/EventType.cs
  24. 2 2
      Unity/Assets/Model/Helper/BundleHelper.cs
  25. 19 1
      Unity/Assets/Model/Module/Numeric/NumericComponent.cs
  26. 1 2
      Unity/Unity.HotfixView.csproj
  27. 2 3
      Unity/Unity.Model.csproj

+ 1 - 1
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)
 				{

+ 8 - 8
Server/Hotfix/Module/Scene/AfterScenesAdd_CreateScene.cs → 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<EventType.AppStart>
     {
-        public override void Run()
+        public override void Run(EventType.AppStart args)
+        {
+            RunAsync().Coroutine();
+        }
+        
+        public async ETVoid RunAsync()
         {
             Game.Scene.AddComponent<ConfigComponent>();
 
@@ -30,11 +35,6 @@ namespace ET
 				
             Game.Scene.AddComponent<NetInnerComponent, string>(processConfig.InnerAddress);
             
-            RunInner().Coroutine();
-        }
-
-        public async ETVoid RunInner()
-        {
             var processScenes = StartSceneConfigCategory.Instance.GetByProcess(IdGenerater.Process);
             foreach (StartSceneConfig startConfig in processScenes)
             {

+ 0 - 8
Server/Model/Base/Event/EventIdType.cs

@@ -1,8 +0,0 @@
-namespace ET
-{
-	public static class EventIdType
-	{
-		public const string NumbericChange = "NumbericChange";
-		public const string AfterScenesAdd = "AfterScenesAdd";
-	}
-}

+ 9 - 0
Server/Model/EventType.cs

@@ -0,0 +1,9 @@
+namespace ET
+{
+	namespace EventType
+	{
+		public struct AppStart
+		{
+		}
+	}
+}

+ 1 - 1
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; }
 	}
 }

+ 0 - 3
Server/Model/Server.Model.csproj

@@ -77,9 +77,6 @@
     <Compile Include="..\..\Unity\Assets\Model\Base\Object\EntityFactory.cs">
       <Link>Base\Object\EntityFactory.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Model\Base\Object\EventProxy.cs">
-      <Link>Base\Object\EventProxy.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Model\Base\Object\EventSystem.cs">
       <Link>Base\Object\EventSystem.cs</Link>
     </Compile>

+ 4 - 4
Unity/Assets/Hotfix/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs

@@ -1,12 +1,12 @@
 namespace ET
 {
 	// 分发数值监听
-	[Event(EventIdType.NumbericChange)]
-	public class NumericChangeEvent_NotifyWatcher: AEvent<long, NumericType, int>
+	[Event]
+	public class NumericChangeEvent_NotifyWatcher: AEvent<EventType.NumbericChange>
 	{
-		public override void Run(long id, NumericType numericType, int value)
+		public override void Run(EventType.NumbericChange args)
 		{
-			Game.Scene.GetComponent<NumericWatcherComponent>().Run(numericType, id, value);
+			Game.Scene.GetComponent<NumericWatcherComponent>().Run(args.NumericType, args.Parent.Id, args.New);
 		}
 	}
 }

+ 4 - 4
Unity/Assets/HotfixView/Demo/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs

@@ -2,12 +2,12 @@
 
 namespace ET
 {
-    [Event(EventIdType.LoadingBegin)]
-    public class LoadingBeginEvent_CreateLoadingUI : AEvent<Entity>
+    [Event()]
+    public class LoadingBeginEvent_CreateLoadingUI : AEvent<EventType.LoadingBegin>
     {
-        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<UIComponent>().Add(ui);
         }
     }

+ 3 - 3
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<EventType.LoadingFinish>
     {
-        public override void Run()
+        public override void Run(EventType.LoadingFinish args)
         {
 			Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILoading);
         }

+ 4 - 6
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<EventType.EnterMapFinish>
 	{
-		public override void Run()
+		public override void Run(EventType.EnterMapFinish args)
 		{
 			Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILobby);
 			Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle(UIType.UILobby.StringToAB());

+ 3 - 3
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<EventType.LoginFinish>
 	{
-		public override void Run()
+		public override void Run(EventType.LoginFinish args)
 		{
 			UI ui = UILobbyFactory.Create();
 			Game.Scene.GetComponent<UIComponent>().Add(ui);

+ 0 - 14
Unity/Assets/HotfixView/Demo/UI/UILogin/InitSceneStart_CreateLoginUI.cs

@@ -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<UIComponent>().Add(ui);
-		}
-	}
-}

+ 3 - 3
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<EventType.LoginFinish>
 	{
-		public override void Run()
+		public override void Run(EventType.LoginFinish args)
 		{
 			Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILogin);
 			Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle(UIType.UILogin.StringToAB());

+ 4 - 4
Unity/Assets/HotfixView/Demo/Unit/AfterUnitCreate_CreateUnitView.cs

@@ -2,10 +2,10 @@
 
 namespace ET
 {
-    [Event(EventIdType.AfterUnitCreate)]
-    public class AfterUnitCreate_CreateUnitView: AEvent<Unit>
+    [Event]
+    public class AfterUnitCreate_CreateUnitView: AEvent<EventType.AfterUnitCreate>
     {
-        public override void Run(Unit unit)
+        public override void Run(EventType.AfterUnitCreate args)
         {
             // Unit View层
             ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
@@ -14,7 +14,7 @@ namespace ET
 	        
             GameObject go = UnityEngine.Object.Instantiate(prefab);
             
-            unit.AddComponent<AnimatorComponent>();
+            args.Unit.AddComponent<AnimatorComponent>();
         }
     }
 }

+ 0 - 6
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;
-		}
 	}
 }

+ 0 - 30
Unity/Assets/Model/Base/Event/EventIdType.cs

@@ -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";
-	}
-}

+ 1 - 104
Unity/Assets/Model/Base/Event/IEvent.cs

@@ -2,111 +2,8 @@
 
 namespace ET
 {
-	public interface IEvent
+	public abstract class AEvent<A> 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<A>: 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<A, B>: 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<A, B, C>: 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);
-	}
 }

+ 0 - 46
Unity/Assets/Model/Base/Object/EventProxy.cs

@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace ET
-{
-	public class EventProxy: IEvent
-	{
-		public Action<List<object>> action;
-		public List<object> param = new List<object>();
-
-		public EventProxy(Action<List<object>> 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);
-		}
-	}
-}

+ 8 - 98
Unity/Assets/Model/Base/Object/EventSystem.cs

@@ -36,7 +36,7 @@ namespace ET
 		
 		private readonly UnOrderMultiMapSet<Type, Type> types = new UnOrderMultiMapSet<Type, Type>();
 
-		private readonly Dictionary<string, List<object>> allEvents = new Dictionary<string, List<object>>();
+		private readonly Dictionary<Type, List<object>> allEvents = new Dictionary<Type, List<object>>();
 
 		private readonly UnOrderMultiMap<Type, IAwakeSystem> awakeSystems = new UnOrderMultiMap<Type, IAwakeSystem>();
 
@@ -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<object>());
 				}
+				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<object>());
-			}
-			this.allEvents[eventId].Add(e);
-		}
 		
 		public HashSet<Type> GetTypes(Type systemAttributeType)
 		{
@@ -628,35 +612,10 @@ namespace ET
 			ObjectHelper.Swap(ref this.lateUpdates, ref this.lateUpdates2);
 		}
 
-		public void Run(string type)
-		{
-			List<object> 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<A>(string type, A a)
+		public void Publish<T>(T a) where T: struct
 		{
 			List<object> 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<A> aEvent))
+					if (!(obj is AEvent<T> aEvent))
 					{
 						Log.Error($"event error: {obj.GetType().Name}");
 						continue;
@@ -678,55 +637,6 @@ namespace ET
 			}
 		}
 
-		public void Run<A, B>(string type, A a, B b)
-		{
-			List<object> iEvents;
-			if (!this.allEvents.TryGetValue(type, out iEvents))
-			{
-				return;
-			}
-			foreach (object obj in iEvents)
-			{
-				try
-				{
-					if (!(obj is AEvent<A, B> aEvent))
-					{
-						Log.Error($"event error: {obj.GetType().Name}");
-						continue;
-					}
-					aEvent.Run(a, b);
-				}
-				catch (Exception e)
-				{
-					Log.Error(e);
-				}
-			}
-		}
-
-		public void Run<A, B, C>(string type, A a, B b, C c)
-		{
-			List<object> iEvents;
-			if (!this.allEvents.TryGetValue(type, out iEvents))
-			{
-				return;
-			}
-			foreach (object obj in iEvents)
-			{
-				try
-				{
-					if (!(obj is AEvent<A, B, C> aEvent))
-					{
-						Log.Error($"event error: {obj.GetType().Name}");
-						continue;
-					}
-					aEvent.Run(a, b, c);
-				}
-				catch (Exception e)
-				{
-					Log.Error(e);
-				}
-			}
-		}
 		
 		public override string ToString()
 		{

+ 1 - 1
Unity/Assets/Model/Demo/Helper/LoginHelper.cs

@@ -34,7 +34,7 @@ namespace ET
                 PlayerComponent playerComponent = Game.Scene.GetComponent<PlayerComponent>();
                 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());

+ 1 - 1
Unity/Assets/Model/Demo/Helper/MapHelper.cs

@@ -26,7 +26,7 @@ namespace ET
 				
                 Game.Scene.AddComponent<OperaComponent>();
 				
-                Game.EventSystem.Run(EventIdType.EnterMapFinish);
+                Game.EventSystem.Publish(new EventType.EnterMapFinish());
             }
             catch (Exception e)
             {

+ 1 - 1
Unity/Assets/Model/Demo/Helper/UnitFactory.cs

@@ -12,7 +12,7 @@ namespace ET
 	        unit.AddComponent<TurnComponent>();
 	        unit.AddComponent<UnitPathComponent>();
 
-	        Game.EventSystem.Run(EventIdType.AfterUnitCreate, unit);
+	        Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit});
 	        
 	        UnitComponent unitComponent = Game.Scene.GetComponent<UnitComponent>();
             unitComponent.Add(unit);

+ 25 - 0
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;
+		}
+	}
+}

+ 2 - 2
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<ResourcesComponent>().LoadOneBundle("StreamingAssets");
 					ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent<ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");

+ 19 - 1
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<NumericComponent>
 	{
@@ -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
+			});
 		}
 	}
 }

+ 1 - 2
Unity/Unity.HotfixView.csproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <LangVersion>latest</LangVersion>
@@ -67,7 +67,6 @@
      <Compile Include="Assets\HotfixView\Demo\UI\UILobby\LoginFinish_CreateLobbyUI.cs" />
      <Compile Include="Assets\HotfixView\Demo\UI\UILobby\UILobbyComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\Demo\UI\UILobby\UILobbyFactory.cs" />
-     <Compile Include="Assets\HotfixView\Demo\UI\UILogin\InitSceneStart_CreateLoginUI.cs" />
      <Compile Include="Assets\HotfixView\Demo\UI\UILogin\LoginFinish_RemoveLoginUI.cs" />
      <Compile Include="Assets\HotfixView\Demo\UI\UILogin\UILoginComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\Demo\UI\UILogin\UILoginFactory.cs" />

+ 2 - 3
Unity/Unity.Model.csproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <LangVersion>latest</LangVersion>
@@ -73,7 +73,6 @@
      <Compile Include="Assets\Model\Base\Event\Env.cs" />
      <Compile Include="Assets\Model\Base\Event\EnvKey.cs" />
      <Compile Include="Assets\Model\Base\Event\EventAttribute.cs" />
-     <Compile Include="Assets\Model\Base\Event\EventIdType.cs" />
      <Compile Include="Assets\Model\Base\Event\IEvent.cs" />
      <Compile Include="Assets\Model\Base\Helper\ByteHelper.cs" />
      <Compile Include="Assets\Model\Base\Helper\Dumper.cs" />
@@ -101,7 +100,6 @@
      <Compile Include="Assets\Model\Base\Object\EntityCreateComponet.cs" />
      <Compile Include="Assets\Model\Base\Object\EntityEventAttribute.cs" />
      <Compile Include="Assets\Model\Base\Object\EntityFactory.cs" />
-     <Compile Include="Assets\Model\Base\Object\EventProxy.cs" />
      <Compile Include="Assets\Model\Base\Object\EventSystem.cs" />
      <Compile Include="Assets\Model\Base\Object\HideInHierarchy.cs" />
      <Compile Include="Assets\Model\Base\Object\IAwakeSystem.cs" />
@@ -158,6 +156,7 @@
      <Compile Include="Assets\Model\Entity\SceneChangeComponent.cs" />
      <Compile Include="Assets\Model\Entity\SceneType.cs" />
      <Compile Include="Assets\Model\Entity\TimerComponent.cs" />
+     <Compile Include="Assets\Model\EventType.cs" />
      <Compile Include="Assets\Model\Helper\BundleHelper.cs" />
      <Compile Include="Assets\Model\Helper\PathHelper.cs" />
      <Compile Include="Assets\Model\Helper\PositionHelper.cs" />