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

Awake Update LateUpdate Start Load等System改成可订阅机制,不同模块可以多次订阅,从此,Event事件,消息事件,System事件都可以多次订阅了

tanghai 8 лет назад
Родитель
Сommit
3f0ec5cf51
88 измененных файлов с 1253 добавлено и 700 удалено
  1. 2 2
      Server/App/NLog.config
  2. 15 7
      Server/Hotfix/Module/Actor/ActorComponentSystem.cs
  3. 16 8
      Server/Hotfix/Module/Network/NetInnerComponentSystem.cs
  4. 15 7
      Server/Hotfix/Module/Network/NetOuterComponentSystem.cs
  5. 3 3
      Server/Hotfix/System/RealmGateAddressComponentSystem.cs
  6. 5 5
      Server/Hotfix/System/ServerFrameComponentSystem.cs
  7. 135 114
      Server/Model/Base/Object/EventSystem.cs
  8. 3 3
      Server/Model/Component/AppManagerComponent.cs
  9. 3 3
      Server/Model/Component/BenchmarkComponent.cs
  10. 10 6
      Server/Model/Component/HttpComponent.cs
  11. 3 3
      Server/Model/Component/NumericComponent.cs
  12. 10 6
      Server/Model/Component/OpcodeTypeComponent.cs
  13. 3 3
      Server/Model/Component/OptionComponent.cs
  14. 3 3
      Server/Model/Component/PlayerComponent.cs
  15. 3 3
      Server/Model/Component/StartConfigComponent.cs
  16. 3 3
      Server/Model/Component/Unit/LockComponent.cs
  17. 3 3
      Server/Model/Component/Unit/UnitGateComponent.cs
  18. 3 3
      Server/Model/Entity/Player.cs
  19. 3 3
      Server/Model/Entity/Unit.cs
  20. 3 3
      Server/Model/Module/Actor/ActorManagerComponent.cs
  21. 10 6
      Server/Model/Module/Actor/ActorMessageDispatherComponent.cs
  22. 9 5
      Server/Model/Module/Actor/ActorProxy.cs
  23. 2 4
      Server/Model/Module/Actor/ActorProxyComponent.cs
  24. 3 3
      Server/Model/Module/DB/DBCacheComponent.cs
  25. 3 3
      Server/Model/Module/DB/DBComponent.cs
  26. 3 3
      Server/Model/Module/DB/DBProxyComponent.cs
  27. 2 4
      Server/Model/Module/DB/DBQueryBatchTask.cs
  28. 2 4
      Server/Model/Module/DB/DBQueryJsonTask.cs
  29. 2 3
      Server/Model/Module/DB/DBQueryTask.cs
  30. 2 4
      Server/Model/Module/DB/DBSaveBatchTask.cs
  31. 2 4
      Server/Model/Module/DB/DBSaveTask.cs
  32. 7 6
      Server/Model/Module/DB/DBTaskQueue.cs
  33. 3 3
      Server/Model/Module/Location/LocationProxyComponent.cs
  34. 9 5
      Server/Model/Module/Network/MessageDispatherComponent.cs
  35. 1 0
      Server/Model/Server.Model.csproj
  36. 3 3
      Unity/Assets/Editor/BehaviorTreeEditor/Component/BTNodeInfoComponent.cs
  37. 5 0
      Unity/Assets/Scripts/Base/MultiMap.cs
  38. 130 124
      Unity/Assets/Scripts/Base/Object/EventSystem.cs
  39. 61 9
      Unity/Assets/Scripts/Base/Object/IAwake.cs
  40. 21 3
      Unity/Assets/Scripts/Base/Object/ILateUpdate.cs
  41. 21 3
      Unity/Assets/Scripts/Base/Object/ILoad.cs
  42. 21 3
      Unity/Assets/Scripts/Base/Object/IStart.cs
  43. 21 3
      Unity/Assets/Scripts/Base/Object/IUpdate.cs
  44. 163 0
      Unity/Assets/Scripts/Base/UnOrderMultiMap.cs
  45. 12 0
      Unity/Assets/Scripts/Base/UnOrderMultiMap.cs.meta
  46. 9 5
      Unity/Assets/Scripts/Component/AnimatorComponent.cs
  47. 11 7
      Unity/Assets/Scripts/Component/BehaviorTreeComponent.cs
  48. 2 4
      Unity/Assets/Scripts/Component/BundleDownloaderComponent.cs
  49. 9 5
      Unity/Assets/Scripts/Component/CameraComponent.cs
  50. 6 7
      Unity/Assets/Scripts/Component/ClientFrameComponent.cs
  51. 9 5
      Unity/Assets/Scripts/Component/ConfigComponent.cs
  52. 3 3
      Unity/Assets/Scripts/Component/GlobalConfigComponent.cs
  53. 9 5
      Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
  54. 9 5
      Unity/Assets/Scripts/Component/MoveComponent.cs
  55. 10 6
      Unity/Assets/Scripts/Component/NetOuterComponent.cs
  56. 4 4
      Unity/Assets/Scripts/Component/NumericComponent.cs
  57. 10 6
      Unity/Assets/Scripts/Component/NumericWatcherComponent.cs
  58. 3 3
      Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs
  59. 3 3
      Unity/Assets/Scripts/Component/PlayerComponent.cs
  60. 3 3
      Unity/Assets/Scripts/Component/SessionComponent.cs
  61. 3 3
      Unity/Assets/Scripts/Component/TimerComponent.cs
  62. 9 5
      Unity/Assets/Scripts/Component/UIComponent.cs
  63. 3 3
      Unity/Assets/Scripts/Component/UnitComponent.cs
  64. 4 4
      Unity/Assets/Scripts/Entity/AssetsBundleLoaderAsync.cs
  65. 11 7
      Unity/Assets/Scripts/Entity/AssetsLoaderAsync.cs
  66. 9 5
      Unity/Assets/Scripts/Entity/Session.cs
  67. 4 5
      Unity/Assets/Scripts/Entity/UI.cs
  68. 1 6
      Unity/Assets/Scripts/Entity/Unit.cs
  69. 3 3
      Unity/Assets/Scripts/Entity/UnityWebRequestAsync.cs
  70. 3 3
      Unity/Assets/Scripts/Entity/WWWAsync.cs
  71. 10 9
      Unity/Assets/Scripts/UI/UILoading/Component/UILoadingComponent.cs
  72. 0 1
      Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs
  73. 0 29
      Unity/Assets/ThirdParty/ILRuntime/Generated/Model_IStart_Binding.cs
  74. 138 101
      Unity/Hotfix/Base/Object/EventSystem.cs
  75. 60 9
      Unity/Hotfix/Base/Object/IAwake.cs
  76. 21 3
      Unity/Hotfix/Base/Object/ILateUpdate.cs
  77. 21 3
      Unity/Hotfix/Base/Object/ILoad.cs
  78. 25 0
      Unity/Hotfix/Base/Object/IStart.cs
  79. 21 3
      Unity/Hotfix/Base/Object/IUpdate.cs
  80. 13 9
      Unity/Hotfix/Component/OperaComponent.cs
  81. 9 5
      Unity/Hotfix/Component/UIComponent.cs
  82. 3 3
      Unity/Hotfix/Entity/UI.cs
  83. 9 5
      Unity/Hotfix/Module/HotfixMessage/MessageDispatherComponent.cs
  84. 3 3
      Unity/Hotfix/Module/HotfixMessage/OpcodeTypeComponent.cs
  85. 3 3
      Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs
  86. 3 3
      Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
  87. 1 0
      Unity/Hotfix/Unity.Hotfix.csproj
  88. 1 0
      Unity/Unity.csproj

+ 2 - 2
Server/App/NLog.config

@@ -14,9 +14,9 @@
 		<target name="trace" xsi:type="File"
 			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Trace.txt"
 			deleteOldFileOnStartup="false"
-			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=3:skipFrames=0}" />
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}" />
 		<target name="trace" type="ColoredConsole"
-				layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=3:skipFrames=0}" />
+				layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=10:skipFrames=0}" />
 	</targets>
 	
 	<targets>

+ 15 - 7
Server/Hotfix/Module/Actor/ActorComponentSystem.cs

@@ -6,21 +6,29 @@ using Model;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class ActorComponentSystem : ObjectSystem<ActorComponent>, IAwake, IAwake<IEntityActorHandler>, ILoad
+	public class ActorComponentAwakeSystem : AwakeSystem<ActorComponent>
 	{
-		public void Awake()
+		public override void Awake(ActorComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Awake(IEntityActorHandler iEntityActorHandler)
+	[ObjectSystem]
+	public class ActorComponentAwake1System : AwakeSystem<ActorComponent, IEntityActorHandler>
+	{
+		public override void Awake(ActorComponent self, IEntityActorHandler iEntityActorHandler)
 		{
-			this.Get().Awake(iEntityActorHandler);
+			self.Awake(iEntityActorHandler);
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class ActorComponentLoadSystem : LoadSystem<ActorComponent>
+	{
+		public override void Load(ActorComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 16 - 8
Server/Hotfix/Module/Network/NetInnerComponentSystem.cs

@@ -4,24 +4,32 @@ using Model;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class NetInnerComponentSystem : ObjectSystem<NetInnerComponent>, IAwake, IAwake<IPEndPoint>, IUpdate
+	public class NetInnerComponentAwakeSystem : AwakeSystem<NetInnerComponent>
 	{
-		public void Awake()
+		public override void Awake(NetInnerComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Awake(IPEndPoint ipEndPoint)
+	[ObjectSystem]
+	public class NetInnerComponentAwake1System : AwakeSystem<NetInnerComponent, IPEndPoint>
+	{
+		public override void Awake(NetInnerComponent self, IPEndPoint a)
 		{
-			this.Get().Awake(ipEndPoint);
+			self.Awake(a);
 		}
+	}
 
-		public void Update()
+	[ObjectSystem]
+	public class NetInnerComponentUpdateSystem : UpdateSystem<NetInnerComponent>
+	{
+		public override void Update(NetInnerComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
-	
+
 	public static class NetInnerComponentEx
 	{
 		public static void Awake(this NetInnerComponent self)

+ 15 - 7
Server/Hotfix/Module/Network/NetOuterComponentSystem.cs

@@ -4,21 +4,29 @@ using Model;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class NetOuterComponentSystem : ObjectSystem<NetOuterComponent>, IAwake, IAwake<IPEndPoint>, IUpdate
+	public class NetOuterComponentAwakeSystem : AwakeSystem<NetOuterComponent>
 	{
-		public void Awake()
+		public override void Awake(NetOuterComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Awake(IPEndPoint ipEndPoint)
+	[ObjectSystem]
+	public class NetOuterComponentAwake1System : AwakeSystem<NetOuterComponent, IPEndPoint>
+	{
+		public override void Awake(NetOuterComponent self, IPEndPoint a)
 		{
-			this.Get().Awake(ipEndPoint);
+			self.Awake(a);
 		}
+	}
 
-		public void Update()
+	[ObjectSystem]
+	public class NetOuterComponentUpdateSystem : UpdateSystem<NetOuterComponent>
+	{
+		public override void Update(NetOuterComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 

+ 3 - 3
Server/Hotfix/System/RealmGateAddressComponentSystem.cs

@@ -3,11 +3,11 @@
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class RealmGateAddressComponentSystem : ObjectSystem<RealmGateAddressComponent>, IStart
+	public class RealmGateAddressComponentSystem : StartSystem<RealmGateAddressComponent>
 	{
-		public void Start()
+		public override void Start(RealmGateAddressComponent self)
 		{
-			this.Get().Start();
+			self.Start();
 		}
 	}
 	

+ 5 - 5
Server/Hotfix/System/ServerFrameComponentSystem.cs

@@ -3,12 +3,12 @@
 namespace Hotfix
 {
     [ObjectSystem]
-    public class ServerFrameComponentSystem : ObjectSystem<ServerFrameComponent>, IAwake
+    public class ServerFrameComponentSystem : AwakeSystem<ServerFrameComponent>
     {
-        public void Awake()
-        {
-            this.Get().Awake();
-        }
+	    public override void Awake(ServerFrameComponent self)
+	    {
+		    self.Awake();
+	    }
     }
 	
     public static class ServerFrameComponentEx

+ 135 - 114
Server/Model/Base/Object/EventSystem.cs

@@ -9,49 +9,32 @@ namespace Model
 	{
 		Model,
 		Hotfix,
+		Editor,
 	}
 
-	public interface IObjectSystem
+	public sealed class EventSystem
 	{
-		Type Type();
-		void Set(object value);
-	}
+		private readonly Dictionary<DLLType, Assembly> assemblies = new Dictionary<DLLType, Assembly>();
 
-	public abstract class ObjectSystem<T> : IObjectSystem
-	{
-		private T value;
+		private readonly Dictionary<EventIdType, List<object>> allEvents = new Dictionary<EventIdType, List<object>>();
 
-		protected T Get()
-		{
-			return value;
-		}
+		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
 
-		public void Set(object v)
-		{
-			this.value = (T)v;
-		}
+		private readonly UnOrderMultiMap<Type, AStartSystem> startEvents = new UnOrderMultiMap<Type, AStartSystem>();
 
-		public Type Type()
-		{
-			return typeof(T);
-		}
-	}
+		private readonly UnOrderMultiMap<Type, ALoadSystem> loadEvents = new UnOrderMultiMap<Type, ALoadSystem>();
 
-	public sealed class EventSystem
-	{
-		private readonly Dictionary<DLLType, Assembly> assemblies = new Dictionary<DLLType, Assembly>();
+		private readonly UnOrderMultiMap<Type, AUpdateSystem> updateEvents = new UnOrderMultiMap<Type, AUpdateSystem>();
 
-		private readonly Dictionary<EventIdType, List<object>> allEvents = new Dictionary<EventIdType, List<object>>();
-
-		private readonly Dictionary<Type, IObjectSystem> disposerEvents = new Dictionary<Type, IObjectSystem>();
+		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
 
-		private Queue<Disposer> updates = new Queue<Disposer>();
-		private Queue<Disposer> updates2 = new Queue<Disposer>();
+		private Queue<Component> updates = new Queue<Component>();
+		private Queue<Component> updates2 = new Queue<Component>();
 
-		private readonly Queue<Disposer> starts = new Queue<Disposer>();
+		private readonly Queue<Component> starts = new Queue<Component>();
 
-		private Queue<Disposer> loaders = new Queue<Disposer>();
-		private Queue<Disposer> loaders2 = new Queue<Disposer>();
+		private Queue<Component> loaders = new Queue<Component>();
+		private Queue<Component> loaders2 = new Queue<Component>();
 
 		private readonly HashSet<Disposer> unique = new HashSet<Disposer>();
 
@@ -59,8 +42,12 @@ namespace Model
 		{
 			this.assemblies[dllType] = assembly;
 
-			this.disposerEvents.Clear();
-
+			this.awakeEvents.Clear();
+			this.lateUpdateEvents.Clear();
+			this.updateEvents.Clear();
+			this.startEvents.Clear();
+			this.loadEvents.Clear();
+			
 			Type[] types = DllHelper.GetMonoTypes();
 			foreach (Type type in types)
 			{
@@ -72,13 +59,36 @@ namespace Model
 				}
 
 				object obj = Activator.CreateInstance(type);
-				IObjectSystem objectSystem = obj as IObjectSystem;
-				if (objectSystem == null)
+
+				AAwakeSystem objectSystem = obj as AAwakeSystem;
+				if (objectSystem != null)
 				{
-					Log.Error($"组件事件没有继承IObjectEvent: {type.Name}");
-					continue;
+					this.awakeEvents.Add(objectSystem.Type(), objectSystem);
+				}
+
+				AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
+				if (aUpdateSystem != null)
+				{
+					this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
+				}
+
+				ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
+				if (aLateUpdateSystem != null)
+				{
+					this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
+				}
+
+				AStartSystem aStartSystem = obj as AStartSystem;
+				if (aStartSystem != null)
+				{
+					this.startEvents.Add(aStartSystem.Type(), aStartSystem);
+				}
+
+				ALoadSystem aLoadSystem = obj as ALoadSystem;
+				if (aLoadSystem != null)
+				{
+					this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
 				}
-				this.disposerEvents[objectSystem.Type()] = objectSystem;
 			}
 
 
@@ -112,95 +122,104 @@ namespace Model
 			return this.assemblies.Values.ToArray();
 		}
 
-		public void Add(Disposer disposer)
+		public void Add(Component disposer)
 		{
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
-			{
-				return;
-			}
+			Type type = disposer.GetType();
 
-			if (objectEvent is ILoad)
+			if (this.loadEvents.ContainsKey(type))
 			{
 				this.loaders.Enqueue(disposer);
 			}
 
-			if (objectEvent is IUpdate)
+			if (this.updateEvents.ContainsKey(type))
 			{
 				this.updates.Enqueue(disposer);
 			}
 
-			if (objectEvent is IStart)
+			if (this.startEvents.ContainsKey(type))
 			{
 				this.starts.Enqueue(disposer);
 			}
 		}
 
-		public void Awake(Disposer disposer)
+		public void Awake(Component disposer)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake iAwake = objectEvent as IAwake;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake();
 		}
 
-		public void Awake<P1>(Disposer disposer, P1 p1)
+		public void Awake<P1>(Component disposer, P1 p1)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake1");
+				return;
 			}
-			IAwake<P1> iAwake = objectEvent as IAwake<P1>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake1");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1);
 		}
 
-		public void Awake<P1, P2>(Disposer disposer, P1 p1, P2 p2)
+		public void Awake<P1, P2>(Component disposer, P1 p1, P2 p2)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake2");
+				return;
 			}
-			IAwake<P1, P2> iAwake = objectEvent as IAwake<P1, P2>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake2");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1, p2);
 		}
 
-		public void Awake<P1, P2, P3>(Disposer disposer, P1 p1, P2 p2, P3 p3)
+		public void Awake<P1, P2, P3>(Component disposer, P1 p1, P2 p2, P3 p3)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake3");
+				return;
 			}
-			IAwake<P1, P2, P3> iAwake = objectEvent as IAwake<P1, P2, P3>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake3");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2, p3);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1, p2, p3);
 		}
 
 		public void Load()
@@ -208,7 +227,7 @@ namespace Model
 			unique.Clear();
 			while (this.loaders.Count > 0)
 			{
-				Disposer disposer = this.loaders.Dequeue();
+				Component disposer = this.loaders.Dequeue();
 				if (disposer.IsDisposed)
 				{
 					continue;
@@ -219,26 +238,24 @@ namespace Model
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<ALoadSystem> aLoadSystems = this.loadEvents[disposer.GetType()];
+				if (aLoadSystems == null)
 				{
 					continue;
 				}
 
 				this.loaders2.Enqueue(disposer);
 
-				ILoad iLoad = objectEvent as ILoad;
-				if (iLoad == null)
+				foreach (ALoadSystem aLoadSystem in aLoadSystems)
 				{
-					continue;
-				}
-				objectEvent.Set(disposer);
-				try
-				{
-					iLoad.Load();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aLoadSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 
@@ -250,24 +267,30 @@ namespace Model
 			unique.Clear();
 			while (this.starts.Count > 0)
 			{
-				Disposer disposer = this.starts.Dequeue();
+				Component disposer = this.starts.Dequeue();
 
 				if (!this.unique.Add(disposer))
 				{
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<AStartSystem> aStartSystems = this.startEvents[disposer.GetType()];
+				if (aStartSystems == null)
 				{
 					continue;
 				}
-				IStart iStart = objectEvent as IStart;
-				if (iStart == null)
+
+				foreach (AStartSystem aStartSystem in aStartSystems)
 				{
-					continue;
+					try
+					{
+						aStartSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
-				objectEvent.Set(disposer);
-				iStart.Start();
 			}
 		}
 
@@ -275,10 +298,10 @@ namespace Model
 		{
 			this.Start();
 
-			unique.Clear();
+			this.unique.Clear();
 			while (this.updates.Count > 0)
 			{
-				Disposer disposer = this.updates.Dequeue();
+				Component disposer = this.updates.Dequeue();
 				if (disposer.IsDisposed)
 				{
 					continue;
@@ -289,29 +312,27 @@ namespace Model
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<AUpdateSystem> aUpdateSystems = this.updateEvents[disposer.GetType()];
+				if (aUpdateSystems == null)
 				{
 					continue;
 				}
 
 				this.updates2.Enqueue(disposer);
 
-				IUpdate iUpdate = objectEvent as IUpdate;
-				if (iUpdate == null)
-				{
-					continue;
-				}
-				objectEvent.Set(disposer);
-				try
-				{
-					iUpdate.Update();
-				}
-				catch (Exception e)
+				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
-					Log.Error(e.ToString());
+					try
+					{
+						aUpdateSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
-			
+
 			ObjectHelper.Swap(ref this.updates, ref this.updates2);
 		}
 

+ 3 - 3
Server/Model/Component/AppManagerComponent.cs

@@ -6,11 +6,11 @@ using System.Linq;
 namespace Model
 {
 	[ObjectSystem]
-	public class AppManagerComponentSystem : ObjectSystem<AppManagerComponent>, IStart
+	public class AppManagerComponentStartSystem : StartSystem<AppManagerComponent>
 	{
-		public void Start()
+		public override void Start(AppManagerComponent self)
 		{
-			this.Get().Start();
+			self.Start();
 		}
 	}
 

+ 3 - 3
Server/Model/Component/BenchmarkComponent.cs

@@ -5,11 +5,11 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class BenchmarkComponentSystem : ObjectSystem<BenchmarkComponent>, IAwake<IPEndPoint>
+	public class BenchmarkComponentSystem : AwakeSystem<BenchmarkComponent, IPEndPoint>
 	{
-		public void Awake(IPEndPoint ipEndPoint)
+		public override void Awake(BenchmarkComponent self, IPEndPoint a)
 		{
-			this.Get().Awake(ipEndPoint);
+			self.Awake(a);
 		}
 	}
 

+ 10 - 6
Server/Model/Component/HttpComponent.cs

@@ -5,19 +5,23 @@ using System.Net;
 namespace Model
 {
 	[ObjectSystem]
-	public class HttpComponentComponentSystem : ObjectSystem<HttpComponent>, IAwake, ILoad
+	public class HttpComponentComponentAwakeSystem : AwakeSystem<HttpComponent>
 	{
-		public void Awake()
+		public override void Awake(HttpComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class HttpComponentComponentLoadSystem : LoadSystem<HttpComponent>
+	{
+		public override void Load(HttpComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
-	
+
 	/// <summary>
 	/// http请求分发器
 	/// </summary>

+ 3 - 3
Server/Model/Component/NumericComponent.cs

@@ -5,11 +5,11 @@ using MongoDB.Bson.Serialization.Options;
 namespace Model
 {
 	[ObjectSystem]
-	public class NumericComponentSystem : ObjectSystem<NumericComponent>, IAwake
+	public class NumericComponentSystem : AwakeSystem<NumericComponent>
 	{
-		public void Awake()
+		public override void Awake(NumericComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 10 - 6
Server/Model/Component/OpcodeTypeComponent.cs

@@ -4,19 +4,23 @@ using System.Collections.Generic;
 namespace Model
 {
 	[ObjectSystem]
-	public class OpcodeTypeComponentSystem : ObjectSystem<OpcodeTypeComponent>, IAwake, ILoad
+	public class OpcodeTypeComponentAwakeSystem : AwakeSystem<OpcodeTypeComponent>
 	{
-		public void Awake()
+		public override void Awake(OpcodeTypeComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class OpcodeTypeComponentLoadSystem : LoadSystem<OpcodeTypeComponent>
+	{
+		public override void Load(OpcodeTypeComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
-	
+
 	public class OpcodeTypeComponent : Component
 	{
 		private Dictionary<ushort, Type> opcodeType { get; set; }

+ 3 - 3
Server/Model/Component/OptionComponent.cs

@@ -4,11 +4,11 @@ using CommandLine;
 namespace Model
 {
 	[ObjectSystem]
-	public class OptionComponentSystem : ObjectSystem<OptionComponent>, IAwake<string[]>
+	public class OptionComponentSystem : AwakeSystem<OptionComponent, string[]>
 	{
-		public void Awake(string[] args)
+		public override void Awake(OptionComponent self, string[] a)
 		{
-			this.Get().Awake(args);
+			self.Awake(a);
 		}
 	}
 	

+ 3 - 3
Server/Model/Component/PlayerComponent.cs

@@ -4,11 +4,11 @@ using System.Linq;
 namespace Model
 {
 	[ObjectSystem]
-	public class PlayerComponentSystem : ObjectSystem<PlayerComponent>, IAwake
+	public class PlayerComponentSystem : AwakeSystem<PlayerComponent>
 	{
-		public void Awake()
+		public override void Awake(PlayerComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 3 - 3
Server/Model/Component/StartConfigComponent.cs

@@ -6,11 +6,11 @@ using System.Linq;
 namespace Model
 {
 	[ObjectSystem]
-	public class StartConfigComponentSystem : ObjectSystem<StartConfigComponent>, IAwake<string, int>
+	public class StartConfigComponentSystem : AwakeSystem<StartConfigComponent, string, int>
 	{
-		public void Awake(string a, int b)
+		public override void Awake(StartConfigComponent self, string a, int b)
 		{
-			this.Get().Awake(a, b);
+			self.Awake(a, b);
 		}
 	}
 	

+ 3 - 3
Server/Model/Component/Unit/LockComponent.cs

@@ -13,11 +13,11 @@ namespace Model
 	}
 
 	[ObjectSystem]
-	public class LockComponentSystem : ObjectSystem<LockComponent>, IAwake<IPEndPoint>
+	public class LockComponentAwakeSystem : AwakeSystem<LockComponent, IPEndPoint>
 	{
-		public void Awake(IPEndPoint a)
+		public override void Awake(LockComponent self, IPEndPoint a)
 		{
-			this.Get().Awake(a);
+			self.Awake(a);
 		}
 	}
 

+ 3 - 3
Server/Model/Component/Unit/UnitGateComponent.cs

@@ -1,11 +1,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class UnitGateComponentSystem : ObjectSystem<UnitGateComponent>, IAwake<long>
+	public class UnitGateComponentAwakeSystem : AwakeSystem<UnitGateComponent, long>
 	{
-		public void Awake(long gateSessionId)
+		public override void Awake(UnitGateComponent self, long a)
 		{
-			this.Get().Awake(gateSessionId);
+			self.Awake(a);
 		}
 	}
 

+ 3 - 3
Server/Model/Entity/Player.cs

@@ -1,11 +1,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class PlayerSystem : ObjectSystem<Player>, IAwake<string>
+	public class PlayerSystem : AwakeSystem<Player, string>
 	{
-		public void Awake(string account)
+		public override void Awake(Player self, string a)
 		{
-			this.Get().Awake(account);
+			self.Awake(a);
 		}
 	}
 

+ 3 - 3
Server/Model/Entity/Unit.cs

@@ -10,11 +10,11 @@ namespace Model
 	}
 
 	[ObjectSystem]
-	public class UnitSystem : ObjectSystem<Unit>, IAwake<UnitType>
+	public class UnitSystem : AwakeSystem<Unit, UnitType>
 	{
-		public void Awake(UnitType unitType)
+		public override void Awake(Unit self, UnitType a)
 		{
-			this.Get().Awake(unitType);
+			self.Awake(a);
 		}
 	}
 

+ 3 - 3
Server/Model/Module/Actor/ActorManagerComponent.cs

@@ -3,11 +3,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class ActorManagerComponentSystem : ObjectSystem<ActorManagerComponent>, IAwake
+	public class ActorManagerComponentAwakeSystem : AwakeSystem<ActorManagerComponent>
 	{
-		public void Awake()
+		public override void Awake(ActorManagerComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 10 - 6
Server/Model/Module/Actor/ActorMessageDispatherComponent.cs

@@ -5,16 +5,20 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class ActorMessageDispatherComponentSystem : ObjectSystem<ActorMessageDispatherComponent>, IStart, ILoad
+	public class ActorMessageDispatherComponentStartSystem : AwakeSystem<ActorMessageDispatherComponent>
 	{
-		public void Start()
+		public override void Awake(ActorMessageDispatherComponent self)
 		{
-			this.Get().Start();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class ActorMessageDispatherComponentLoadSystem : LoadSystem<ActorMessageDispatherComponent>
+	{
+		public override void Load(ActorMessageDispatherComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 
@@ -25,7 +29,7 @@ namespace Model
 	{
 		private Dictionary<Type, IMActorHandler> handlers;
 		
-		public void Start()
+		public void Awake()
 		{
 			this.Load();
 		}

+ 9 - 5
Server/Model/Module/Actor/ActorProxy.cs

@@ -7,16 +7,20 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class ActorProxySystem : ObjectSystem<ActorProxy>, IAwake, IStart
+	public class ActorProxyAwakeSystem : AwakeSystem<ActorProxy>
 	{
-		public void Awake()
+		public override void Awake(ActorProxy self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Start()
+	[ObjectSystem]
+	public class ActorProxyStartSystem : StartSystem<ActorProxy>
+	{
+		public override void Start(ActorProxy self)
 		{
-			this.Get().Start();
+			self.Start();
 		}
 	}
 

+ 2 - 4
Server/Model/Module/Actor/ActorProxyComponent.cs

@@ -3,13 +3,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class ActorProxyComponentSystem : ObjectSystem<ActorProxyComponent>, IStart
+	public class ActorProxyComponentSystem : StartSystem<ActorProxyComponent>
 	{
 		// 每10s扫描一次过期的actorproxy进行回收,过期时间是1分钟
-		public async void Start()
+		public override async void Start(ActorProxyComponent self)
 		{
-			ActorProxyComponent self = this.Get();
-
 			List<long> timeoutActorProxyIds = new List<long>();
 
 			while (true)

+ 3 - 3
Server/Model/Module/DB/DBCacheComponent.cs

@@ -4,11 +4,11 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbCacheComponentSystem : ObjectSystem<DBCacheComponent>, IAwake
+	public class DbCacheComponentSystem : AwakeSystem<DBCacheComponent>
 	{
-		public void Awake()
+		public override void Awake(DBCacheComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 3 - 3
Server/Model/Module/DB/DBComponent.cs

@@ -3,11 +3,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class DbComponentSystem : ObjectSystem<DBComponent>, IAwake
+	public class DbComponentSystem : AwakeSystem<DBComponent>
 	{
-		public void Awake()
+		public override void Awake(DBComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 3 - 3
Server/Model/Module/DB/DBProxyComponent.cs

@@ -6,11 +6,11 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbProxyComponentSystem : ObjectSystem<DBProxyComponent>, IAwake
+	public class DbProxyComponentSystem : AwakeSystem<DBProxyComponent>
 	{
-		public void Awake()
+		public override void Awake(DBProxyComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 2 - 4
Server/Model/Module/DB/DBQueryBatchTask.cs

@@ -7,12 +7,10 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryBatchTaskSystem : ObjectSystem<DBQueryBatchTask>, IAwake<List<long>, string, TaskCompletionSource<List<Component>>>
+	public class DbQueryBatchTaskSystem : AwakeSystem<DBQueryBatchTask, List<long>, string, TaskCompletionSource<List<Component>>>
 	{
-		public void Awake(List<long> idList, string collectionName, TaskCompletionSource<List<Component>> tcs)
+		public override void Awake(DBQueryBatchTask self, List<long> idList, string collectionName, TaskCompletionSource<List<Component>> tcs)
 		{
-			DBQueryBatchTask self = this.Get();
-
 			self.IdList = idList;
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;

+ 2 - 4
Server/Model/Module/DB/DBQueryJsonTask.cs

@@ -6,12 +6,10 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryJsonTaskSystem : ObjectSystem<DBQueryJsonTask>, IAwake<string, string, TaskCompletionSource<List<Component>>>
+	public class DBQueryJsonTaskAwakeSystem : AwakeSystem<DBQueryJsonTask, string, string, TaskCompletionSource<List<Component>>>
 	{
-		public void Awake(string collectionName, string json, TaskCompletionSource<List<Component>> tcs)
+		public override void Awake(DBQueryJsonTask self, string collectionName, string json, TaskCompletionSource<List<Component>> tcs)
 		{
-			DBQueryJsonTask self = this.Get();
-			
 			self.CollectionName = collectionName;
 			self.Json = json;
 			self.Tcs = tcs;

+ 2 - 3
Server/Model/Module/DB/DBQueryTask.cs

@@ -5,11 +5,10 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryTaskSystem : ObjectSystem<DBQueryTask>, IAwake<string, TaskCompletionSource<Component>>
+	public class DBQueryTaskSystem : AwakeSystem<DBQueryTask, string, TaskCompletionSource<Component>>
 	{
-		public void Awake(string collectionName, TaskCompletionSource<Component> tcs)
+		public override void Awake(DBQueryTask self, string collectionName, TaskCompletionSource<Component> tcs)
 		{
-			DBQueryTask self = this.Get();
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;
 		}

+ 2 - 4
Server/Model/Module/DB/DBSaveBatchTask.cs

@@ -7,12 +7,10 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbSaveBatchTaskSystem : ObjectSystem<DBSaveBatchTask>, IAwake<List<Component>, string, TaskCompletionSource<bool>>
+	public class DbSaveBatchTaskSystem : AwakeSystem<DBSaveBatchTask, List<Component>, string, TaskCompletionSource<bool>>
 	{
-		public void Awake(List<Component> disposers, string collectionName, TaskCompletionSource<bool> tcs)
+		public override void Awake(DBSaveBatchTask self, List<Component> disposers, string collectionName, TaskCompletionSource<bool> tcs)
 		{
-			DBSaveBatchTask self = this.Get();
-			
 			self.Disposers = disposers;
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;

+ 2 - 4
Server/Model/Module/DB/DBSaveTask.cs

@@ -6,12 +6,10 @@ namespace Model
 {
 
 	[ObjectSystem]
-	public class DbSaveTaskSystem : ObjectSystem<DBSaveTask>, IAwake<Component, string, TaskCompletionSource<bool>>
+	public class DbSaveTaskAwakeSystem : AwakeSystem<DBSaveTask, Component, string, TaskCompletionSource<bool>>
 	{
-		public void Awake(Component entity, string collectionName, TaskCompletionSource<bool> tcs)
+		public override void Awake(DBSaveTask self, Component entity, string collectionName, TaskCompletionSource<bool> tcs)
 		{
-			DBSaveTask self = this.Get();
-
 			self.Disposer = entity;
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;

+ 7 - 6
Server/Model/Module/DB/DBTaskQueue.cs

@@ -5,18 +5,19 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbTaskQueueSystem : ObjectSystem<DBTaskQueue>, IAwake, IStart
+	public class DbTaskQueueAwakeSystem : AwakeSystem<DBTaskQueue>
 	{
-		public void Awake()
+		public override void Awake(DBTaskQueue self)
 		{
-			DBTaskQueue self = this.Get();
 			self.queue.Clear();
 		}
+	}
 
-		public async void Start()
+	[ObjectSystem]
+	public class DbTaskQueueStartSystem : StartSystem<DBTaskQueue>
+	{
+		public override async void Start(DBTaskQueue self)
 		{
-			DBTaskQueue self = this.Get();
-
 			while (true)
 			{
 				if (self.IsDisposed)

+ 3 - 3
Server/Model/Module/Location/LocationProxyComponent.cs

@@ -4,11 +4,11 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class LocationProxyComponentSystem : ObjectSystem<LocationProxyComponent>, IAwake
+	public class LocationProxyComponentSystem : AwakeSystem<LocationProxyComponent>
 	{
-		public void Awake()
+		public override void Awake(LocationProxyComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 9 - 5
Server/Model/Module/Network/MessageDispatherComponent.cs

@@ -4,16 +4,20 @@ using System.Collections.Generic;
 namespace Model
 {
 	[ObjectSystem]
-	public class MessageDispatherComponentSystem : ObjectSystem<MessageDispatherComponent>, IAwake, ILoad
+	public class MessageDispatherComponentAwakeSystem : AwakeSystem<MessageDispatherComponent>
 	{
-		public void Awake()
+		public override void Awake(MessageDispatherComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class MessageDispatherComponentLoadSystem : LoadSystem<MessageDispatherComponent>
+	{
+		public override void Load(MessageDispatherComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

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

@@ -73,6 +73,7 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ObjectSystemAttribute.cs" Link="Base\Object\ObjectSystemAttribute.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\QueueDictionary.cs" Link="Base\QueueDictionary.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\TryLocker.cs" Link="Base\TryLocker.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\UnOrderMultiMap.cs" Link="Base\UnOrderMultiMap.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Component\ConfigComponent.cs" Link="Component\ConfigComponent.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Component\Config\ClientConfig.cs" Link="Component\Config\ClientConfig.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Component\Config\DBConfig.cs" Link="Component\Config\DBConfig.cs" />

+ 3 - 3
Unity/Assets/Editor/BehaviorTreeEditor/Component/BTNodeInfoComponent.cs

@@ -5,11 +5,11 @@ using Model;
 namespace MyEditor
 {
 	[ObjectSystem]
-	public class BtNodeInfoComponentSystem : ObjectSystem<BTNodeInfoComponent>, IAwake
+	public class BtNodeInfoComponentSystem : AwakeSystem<BTNodeInfoComponent>
 	{
-		public void Awake()
+		public override void Awake(BTNodeInfoComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 5 - 0
Unity/Assets/Scripts/Base/MultiMap.cs

@@ -145,5 +145,10 @@ namespace Model
 			}
 			return list.Contains(k);
 		}
+
+		public bool ContainsKey(T t)
+		{
+			return this.dictionary.ContainsKey(t);
+		}
 	}
 }

+ 130 - 124
Unity/Assets/Scripts/Base/Object/EventSystem.cs

@@ -12,32 +12,6 @@ namespace Model
 		Editor,
 	}
 
-	public interface IObjectSystem
-	{
-		Type Type();
-		void Set(object value);
-	}
-
-	public abstract class ObjectSystem<T> : IObjectSystem
-	{
-		private T value;
-
-		protected T Get()
-		{
-			return value;
-		}
-
-		public void Set(object v)
-		{
-			this.value = (T)v;
-		}
-
-		public Type Type()
-		{
-			return typeof(T);
-		}
-	}
-
 	public sealed class EventSystem
 	{
 		private Assembly hotfixAssembly;
@@ -58,7 +32,15 @@ namespace Model
 
 		private readonly Dictionary<int, List<IEvent>> allEvents = new Dictionary<int, List<IEvent>>();
 
-		private readonly Dictionary<Type, IObjectSystem> disposerEvents = new Dictionary<Type, IObjectSystem>();
+		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
+
+		private readonly UnOrderMultiMap<Type, AStartSystem> startEvents = new UnOrderMultiMap<Type, AStartSystem>();
+
+		private readonly UnOrderMultiMap<Type, ALoadSystem> loadEvents = new UnOrderMultiMap<Type, ALoadSystem>();
+
+		private readonly UnOrderMultiMap<Type, AUpdateSystem> updateEvents = new UnOrderMultiMap<Type, AUpdateSystem>();
+
+		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
 
 		private Queue<Component> updates = new Queue<Component>();
 		private Queue<Component> updates2 = new Queue<Component>();
@@ -80,18 +62,19 @@ namespace Model
 #else
 			this.HotfixAssembly = DllHelper.LoadHotfixAssembly();
 #endif
-			this.Register();
 			this.Load();
 		}
 
 		public void Add(DLLType dllType, Assembly assembly)
 		{
 			this.assemblies[dllType] = assembly;
-			this.Register();
-		}
 
-		private void Register()
-		{
+			this.awakeEvents.Clear();
+			this.lateUpdateEvents.Clear();
+			this.updateEvents.Clear();
+			this.startEvents.Clear();
+			this.loadEvents.Clear();
+
 			Type[] types = DllHelper.GetMonoTypes();
 			foreach (Type type in types)
 			{
@@ -103,13 +86,36 @@ namespace Model
 				}
 
 				object obj = Activator.CreateInstance(type);
-				IObjectSystem objectSystem = obj as IObjectSystem;
-				if (objectSystem == null)
+
+				AAwakeSystem objectSystem = obj as AAwakeSystem;
+				if (objectSystem != null)
 				{
-					Log.Error($"组件事件没有继承IObjectEvent: {type.Name}");
-					continue;
+					this.awakeEvents.Add(objectSystem.Type(), objectSystem);
+				}
+
+				AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
+				if (aUpdateSystem != null)
+				{
+					this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
+				}
+
+				ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
+				if (aLateUpdateSystem != null)
+				{
+					this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
+				}
+
+				AStartSystem aStartSystem = obj as AStartSystem;
+				if (aStartSystem != null)
+				{
+					this.startEvents.Add(aStartSystem.Type(), aStartSystem);
+				}
+
+				ALoadSystem aLoadSystem = obj as ALoadSystem;
+				if (aLoadSystem != null)
+				{
+					this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
 				}
-				this.disposerEvents[objectSystem.Type()] = objectSystem;
 			}
 
 			this.allEvents.Clear();
@@ -152,28 +158,24 @@ namespace Model
 
 		public void Add(Component disposer)
 		{
-			IObjectSystem objectSystem;
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
-			{
-				return;
-			}
+			Type type = disposer.GetType();
 
-			if (objectSystem is ILoad)
+			if (this.loadEvents.ContainsKey(type))
 			{
 				this.loaders.Enqueue(disposer);
 			}
 
-			if (objectSystem is IUpdate)
+			if (this.updateEvents.ContainsKey(type))
 			{
 				this.updates.Enqueue(disposer);
 			}
 
-			if (objectSystem is IStart)
+			if (this.startEvents.ContainsKey(type))
 			{
 				this.starts.Enqueue(disposer);
 			}
 
-			if (objectSystem is ILateUpdate)
+			if (this.lateUpdateEvents.ContainsKey(type))
 			{
 				this.lateUpdates.Enqueue(disposer);
 			}
@@ -183,72 +185,80 @@ namespace Model
 		{
 			this.Add(disposer);
 
-			IObjectSystem objectSystem;
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake iAwake = objectSystem as IAwake;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer);
 			}
-			objectSystem.Set(disposer);
-			iAwake.Awake();
 		}
 
 		public void Awake<P1>(Component disposer, P1 p1)
 		{
 			this.Add(disposer);
 
-			IObjectSystem objectSystem;
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake<P1> iAwake = objectSystem as IAwake<P1>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1);
 			}
-			objectSystem.Set(disposer);
-			iAwake.Awake(p1);
 		}
 
 		public void Awake<P1, P2>(Component disposer, P1 p1, P2 p2)
 		{
 			this.Add(disposer);
 
-			IObjectSystem objectSystem;
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake<P1, P2> iAwake = objectSystem as IAwake<P1, P2>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2);
 			}
-			objectSystem.Set(disposer);
-			iAwake.Awake(p1, p2);
 		}
 
 		public void Awake<P1, P2, P3>(Component disposer, P1 p1, P2 p2, P3 p3)
 		{
 			this.Add(disposer);
 
-			IObjectSystem objectSystem;
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake<P1, P2, P3> iAwake = objectSystem as IAwake<P1, P2, P3>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2, p3);
 			}
-			objectSystem.Set(disposer);
-			iAwake.Awake(p1, p2, p3);
 		}
 
 		public void Load()
@@ -267,27 +277,24 @@ namespace Model
 					continue;
 				}
 
-				IObjectSystem objectSystem;
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+				List<ALoadSystem> aLoadSystems = this.loadEvents[disposer.GetType()];
+				if (aLoadSystems == null)
 				{
 					continue;
 				}
 
 				this.loaders2.Enqueue(disposer);
 
-				ILoad iLoad = objectSystem as ILoad;
-				if (iLoad == null)
-				{
-					continue;
-				}
-				objectSystem.Set(disposer);
-				try
+				foreach (ALoadSystem aLoadSystem in aLoadSystems)
 				{
-					iLoad.Load();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aLoadSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 
@@ -306,18 +313,23 @@ namespace Model
 					continue;
 				}
 
-				IObjectSystem objectSystem;
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+				List<AStartSystem> aStartSystems = this.startEvents[disposer.GetType()];
+				if (aStartSystems == null)
 				{
 					continue;
 				}
-				IStart iStart = objectSystem as IStart;
-				if (iStart == null)
+				
+				foreach (AStartSystem aStartSystem in aStartSystems)
 				{
-					continue;
+					try
+					{
+						aStartSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
-				objectSystem.Set(disposer);
-				iStart.Start();
 			}
 		}
 
@@ -338,28 +350,25 @@ namespace Model
 				{
 					continue;
 				}
-
-				IObjectSystem objectSystem;
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+				
+				List<AUpdateSystem> aUpdateSystems = this.updateEvents[disposer.GetType()];
+				if (aUpdateSystems == null)
 				{
 					continue;
 				}
 
 				this.updates2.Enqueue(disposer);
 
-				IUpdate iUpdate = objectSystem as IUpdate;
-				if (iUpdate == null)
+				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
-					continue;
-				}
-				objectSystem.Set(disposer);
-				try
-				{
-					iUpdate.Update();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aUpdateSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 
@@ -382,27 +391,24 @@ namespace Model
 					continue;
 				}
 
-				IObjectSystem objectSystem;
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[disposer.GetType()];
+				if (aLateUpdateSystems == null)
 				{
 					continue;
 				}
 
 				this.lateUpdates2.Enqueue(disposer);
 
-				ILateUpdate iLateUpdate = objectSystem as ILateUpdate;
-				if (iLateUpdate == null)
+				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
-					continue;
-				}
-				objectSystem.Set(disposer);
-				try
-				{
-					iLateUpdate.LateUpdate();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aLateUpdateSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 

+ 61 - 9
Unity/Assets/Scripts/Base/Object/IAwake.cs

@@ -1,22 +1,74 @@
-namespace Model
+using System;
+
+namespace Model
 {
-	public interface IAwake
+	public abstract class AAwakeSystem
 	{
-		void Awake();
+		public abstract Type Type();
+
+		public virtual void Run(object o){ }
+		public virtual void Run(object o, object a) { }
+		public virtual void Run(object o, object a, object b) { }
+		public virtual void Run(object o, object a, object b, object c) { }
 	}
 
-	public interface IAwake<A>
+	public abstract class AwakeSystem<T> : AAwakeSystem
 	{
-		void Awake(A a);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o)
+		{
+			this.Awake((T)o);
+		}
+
+		public abstract void Awake(T self);
 	}
 
-	public interface IAwake<A, B>
+	public abstract class AwakeSystem<T, A> : AAwakeSystem
 	{
-		void Awake(A a, B b);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a)
+		{
+			this.Awake((T)o, (A)a);
+		}
+
+		public abstract void Awake(T self, A a);
 	}
 
-	public interface IAwake<A, B, C>
+	public abstract class AwakeSystem<T, A, B> : AAwakeSystem
 	{
-		void Awake(A a, B b, C c);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a, object b)
+		{
+			this.Awake((T)o, (A)a, (B)b);
+		}
+
+		public abstract void Awake(T self, A a, B b);
+	}
+
+	public abstract class AwakeSystem<T, A, B, C> : AAwakeSystem
+	{
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a, object b, object c)
+		{
+			this.Awake((T)o, (A)a, (B)b, (C)c);
+		}
+
+		public abstract void Awake(T self, A a, B b, C c);
 	}
 }

+ 21 - 3
Unity/Assets/Scripts/Base/Object/ILateUpdate.cs

@@ -1,7 +1,25 @@
-namespace Model
+using System;
+
+namespace Model
 {
-	public interface ILateUpdate
+	public abstract class ALateUpdateSystem
 	{
-		void LateUpdate();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class LateUpdateSystem<T> : ALateUpdateSystem
+	{
+		public override void Run(object o)
+		{
+			this.LateUpdate((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void LateUpdate(T self);
 	}
 }

+ 21 - 3
Unity/Assets/Scripts/Base/Object/ILoad.cs

@@ -1,7 +1,25 @@
-namespace Model
+using System;
+
+namespace Model
 {
-	public interface ILoad
+	public abstract class ALoadSystem
 	{
-		void Load();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class LoadSystem<T> : ALoadSystem
+	{
+		public override void Run(object o)
+		{
+			this.Load((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Load(T self);
 	}
 }

+ 21 - 3
Unity/Assets/Scripts/Base/Object/IStart.cs

@@ -1,7 +1,25 @@
-namespace Model
+using System;
+
+namespace Model
 {
-	public interface IStart
+	public abstract class AStartSystem
 	{
-		void Start();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class StartSystem<T> : AStartSystem
+	{
+		public override void Run(object o)
+		{
+			this.Start((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Start(T self);
 	}
 }

+ 21 - 3
Unity/Assets/Scripts/Base/Object/IUpdate.cs

@@ -1,7 +1,25 @@
-namespace Model
+using System;
+
+namespace Model
 {
-	public interface IUpdate
+	public abstract class AUpdateSystem
 	{
-		void Update();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class UpdateSystem<T> : AUpdateSystem
+	{
+		public override void Run(object o)
+		{
+			this.Update((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Update(T self);
 	}
 }

+ 163 - 0
Unity/Assets/Scripts/Base/UnOrderMultiMap.cs

@@ -0,0 +1,163 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Model
+{
+	public class UnOrderMultiMap<T, K>
+	{
+		private readonly Dictionary<T, List<K>> dictionary = new Dictionary<T, List<K>>();
+
+		// 重用list
+		private readonly Queue<List<K>> queue = new Queue<List<K>>();
+
+		public Dictionary<T, List<K>> GetDictionary()
+		{
+			return this.dictionary;
+		}
+
+		public void Add(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				list = this.FetchList();
+			}
+			list.Add(k);
+			this.dictionary[t] = list;
+		}
+
+		public KeyValuePair<T, List<K>> First()
+		{
+			return this.dictionary.First();
+		}
+
+		public int Count
+		{
+			get
+			{
+				return this.dictionary.Count;
+			}
+		}
+
+		private List<K> FetchList()
+		{
+			if (this.queue.Count > 0)
+			{
+				List<K> list = this.queue.Dequeue();
+				list.Clear();
+				return list;
+			}
+			return new List<K>();
+		}
+
+		private void RecycleList(List<K> list)
+		{
+			// 防止暴涨
+			if (this.queue.Count > 100)
+			{
+				return;
+			}
+			list.Clear();
+			this.queue.Enqueue(list);
+		}
+
+		public bool Remove(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return false;
+			}
+			if (!list.Remove(k))
+			{
+				return false;
+			}
+			if (list.Count == 0)
+			{
+				this.RecycleList(list);
+				this.dictionary.Remove(t);
+			}
+			return true;
+		}
+
+		public bool Remove(T t)
+		{
+			List<K> list = null;
+			this.dictionary.TryGetValue(t, out list);
+			if (list != null)
+			{
+				this.RecycleList(list);
+			}
+			return this.dictionary.Remove(t);
+		}
+
+		/// <summary>
+		/// 不返回内部的list,copy一份出来
+		/// </summary>
+		/// <param name="t"></param>
+		/// <returns></returns>
+		public K[] GetAll(T t)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return new K[0];
+			}
+			return list.ToArray();
+		}
+
+		/// <summary>
+		/// 返回内部的list
+		/// </summary>
+		/// <param name="t"></param>
+		/// <returns></returns>
+		public List<K> this[T t]
+		{
+			get
+			{
+				List<K> list;
+				this.dictionary.TryGetValue(t, out list);
+				return list;
+			}
+		}
+
+		public K GetOne(T t)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list != null && list.Count > 0)
+			{
+				return list[0];
+			}
+			return default(K);
+		}
+
+		public bool Contains(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return false;
+			}
+			return list.Contains(k);
+		}
+
+		public bool ContainsKey(T t)
+		{
+			return this.dictionary.ContainsKey(t);
+		}
+
+		public void Clear()
+		{
+			foreach (KeyValuePair<T, List<K>> keyValuePair in this.dictionary)
+			{
+				this.RecycleList(keyValuePair.Value);
+			}
+			this.dictionary.Clear();
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Base/UnOrderMultiMap.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 13b5e5dfdc231344dab29690a52a24c4
+timeCreated: 1518431380
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 5
Unity/Assets/Scripts/Component/AnimatorComponent.cs

@@ -5,16 +5,20 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class AnimatorComponentSystem : ObjectSystem<AnimatorComponent>, IAwake, IUpdate
+	public class AnimatorComponentAwakeSystem : AwakeSystem<AnimatorComponent>
 	{
-		public void Awake()
+		public override void Awake(AnimatorComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Update()
+	[ObjectSystem]
+	public class AnimatorComponentUpdateSystem : UpdateSystem<AnimatorComponent>
+	{
+		public override void Update(AnimatorComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 

+ 11 - 7
Unity/Assets/Scripts/Component/BehaviorTreeComponent.cs

@@ -6,19 +6,23 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class BehaviorTreeComponentSystem : ObjectSystem<BehaviorTreeComponent>, IAwake, ILoad
+	public class BehaviorTreeComponentAwakeSystem : AwakeSystem<BehaviorTreeComponent>
 	{
-		public void Awake()
+		public override void Awake(BehaviorTreeComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
-		
-		public void Load()
+	}
+
+	[ObjectSystem]
+	public class BehaviorTreeComponentLoadSystem : LoadSystem<BehaviorTreeComponent>
+	{
+		public override void Load(BehaviorTreeComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
-	
+
 	public class BehaviorTreeComponent : Component
 	{
 		public static BehaviorTreeComponent Instance;

+ 2 - 4
Unity/Assets/Scripts/Component/BundleDownloaderComponent.cs

@@ -7,12 +7,10 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class UiBundleDownloaderComponentSystem : ObjectSystem<BundleDownloaderComponent>, IAwake
+	public class UiBundleDownloaderComponentAwakeSystem : AwakeSystem<BundleDownloaderComponent>
 	{
-		public void Awake()
+		public override void Awake(BundleDownloaderComponent self)
 		{
-			BundleDownloaderComponent self = this.Get();
-
 			self.bundles = new Queue<string>();
 			self.downloadedBundles = new HashSet<string>();
 			self.downloadingBundle = "";

+ 9 - 5
Unity/Assets/Scripts/Component/CameraComponent.cs

@@ -3,16 +3,20 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class CameraComponentSystem : ObjectSystem<CameraComponent>, IAwake, ILateUpdate
+	public class CameraComponentAwakeSystem : AwakeSystem<CameraComponent>
 	{
-		public void Awake()
+		public override void Awake(CameraComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void LateUpdate()
+	[ObjectSystem]
+	public class CameraComponentLateUpdateSystem : LateUpdateSystem<CameraComponent>
+	{
+		public override void LateUpdate(CameraComponent self)
 		{
-			this.Get().LateUpdate();
+			self.LateUpdate();
 		}
 	}
 

+ 6 - 7
Unity/Assets/Scripts/Component/ClientFrameComponent.cs

@@ -9,15 +9,14 @@ namespace Model
     }
     
     [ObjectSystem]
-    public class ClientFrameComponentSystem : ObjectSystem<ClientFrameComponent>, IStart
+    public class ClientFrameComponentStartSystem : StartSystem<ClientFrameComponent>
     {
-        public void Start()
-        {
-            this.Get().Start();
-        }
+	    public override void Start(ClientFrameComponent t)
+	    {
+		    t.Start();
+	    }
     }
-
-    public class ClientFrameComponent: Component
+	public class ClientFrameComponent: Component
     {
         public int Frame;
 

+ 9 - 5
Unity/Assets/Scripts/Component/ConfigComponent.cs

@@ -4,16 +4,20 @@ using System.Collections.Generic;
 namespace Model
 {
 	[ObjectSystem]
-	public class ConfigComponentSystem : ObjectSystem<ConfigComponent>, IAwake, ILoad
+	public class ConfigComponentAwakeSystem : AwakeSystem<ConfigComponent>
 	{
-		public void Awake()
+		public override void Awake(ConfigComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class ConfigComponentLoadSystem : LoadSystem<ConfigComponent>
+	{
+		public override void Load(ConfigComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 3 - 3
Unity/Assets/Scripts/Component/GlobalConfigComponent.cs

@@ -1,11 +1,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class GlobalConfigComponentSystem : ObjectSystem<GlobalConfigComponent>, IAwake
+	public class GlobalConfigComponentAwakeSystem : AwakeSystem<GlobalConfigComponent>
 	{
-		public void Awake()
+		public override void Awake(GlobalConfigComponent t)
 		{
-			this.Get().Awake();
+			t.Awake();
 		}
 	}
 

+ 9 - 5
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs

@@ -4,16 +4,20 @@ using System.Collections.Generic;
 namespace Model
 {
 	[ObjectSystem]
-	public class MessageDispatherComponentSystem : ObjectSystem<MessageDispatherComponent>, IAwake, ILoad
+	public class MessageDispatherComponentAwakeSystem : AwakeSystem<MessageDispatherComponent>
 	{
-		public void Awake()
+		public override void Awake(MessageDispatherComponent t)
 		{
-			this.Get().Awake();
+			t.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class MessageDispatherComponentLoadSystem : LoadSystem<MessageDispatherComponent>
+	{
+		public override void Load(MessageDispatherComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 9 - 5
Unity/Assets/Scripts/Component/MoveComponent.cs

@@ -4,16 +4,20 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class MoveComponentSystem : ObjectSystem<MoveComponent>, IAwake, IUpdate
+	public class MoveComponentAwakeSystem : AwakeSystem<MoveComponent>
 	{
-		public void Awake()
+		public override void Awake(MoveComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Update()
+	[ObjectSystem]
+	public class MoveComponentUpdateSystem : UpdateSystem<MoveComponent>
+	{
+		public override void Update(MoveComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 

+ 10 - 6
Unity/Assets/Scripts/Component/NetOuterComponent.cs

@@ -1,16 +1,20 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class NetOuterComponentSystem : ObjectSystem<NetOuterComponent>, IAwake, IUpdate
+	public class NetOuterComponentAwakeSystem : AwakeSystem<NetOuterComponent>
 	{
-		public void Awake()
+		public override void Awake(NetOuterComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
-		
-		public void Update()
+	}
+
+	[ObjectSystem]
+	public class NetOuterComponentUpdateSystem : UpdateSystem<NetOuterComponent>
+	{
+		public override void Update(NetOuterComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 

+ 4 - 4
Unity/Assets/Scripts/Component/NumericComponent.cs

@@ -3,14 +3,14 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class NumericComponentSystem : ObjectSystem<NumericComponent>, IAwake
+	public class NumericComponentAwakeSystem : AwakeSystem<NumericComponent>
 	{
-		public void Awake()
+		public override void Awake(NumericComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
-	
+
 	public class NumericComponent: Component
 	{
 		public readonly Dictionary<int, int> NumericDic = new Dictionary<int, int>();

+ 10 - 6
Unity/Assets/Scripts/Component/NumericWatcherComponent.cs

@@ -4,19 +4,23 @@ using System.Collections.Generic;
 namespace Model
 {
 	[ObjectSystem]
-	public class NumericWatcherComponentSystem : ObjectSystem<NumericWatcherComponent>, IAwake, ILoad
+	public class NumericWatcherComponentAwakeSystem : AwakeSystem<NumericWatcherComponent>
 	{
-		public void Awake()
+		public override void Awake(NumericWatcherComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class NumericWatcherComponentLoadSystem : LoadSystem<NumericWatcherComponent>
+	{
+		public override void Load(NumericWatcherComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
-	
+
 	/// <summary>
 	/// 监视数值变化组件,分发监听
 	/// </summary>

+ 3 - 3
Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs

@@ -3,11 +3,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class OpcodeTypeComponentSystem : ObjectSystem<OpcodeTypeComponent>, IAwake
+	public class OpcodeTypeComponentSystem : AwakeSystem<OpcodeTypeComponent>
 	{
-		public void Awake()
+		public override void Awake(OpcodeTypeComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 3 - 3
Unity/Assets/Scripts/Component/PlayerComponent.cs

@@ -4,11 +4,11 @@ using System.Linq;
 namespace Model
 {
 	[ObjectSystem]
-	public class PlayerComponentSystem : ObjectSystem<PlayerComponent>, IAwake
+	public class PlayerComponentAwakeSystem : AwakeSystem<PlayerComponent>
 	{
-		public void Awake()
+		public override void Awake(PlayerComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 3 - 3
Unity/Assets/Scripts/Component/SessionComponent.cs

@@ -1,11 +1,11 @@
 namespace Model
 {
 	[ObjectSystem]
-	public class SessionComponentSystem : ObjectSystem<SessionComponent>, IAwake
+	public class SessionComponentAwakeSystem : AwakeSystem<SessionComponent>
 	{
-		public void Awake()
+		public override void Awake(SessionComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 3 - 3
Unity/Assets/Scripts/Component/TimerComponent.cs

@@ -12,11 +12,11 @@ namespace Model
 	}
 
 	[ObjectSystem]
-	public class TimerComponentSystem : ObjectSystem<TimerComponent>, IUpdate
+	public class TimerComponentUpdateSystem : UpdateSystem<TimerComponent>
 	{
-		public void Update()
+		public override void Update(TimerComponent self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 

+ 9 - 5
Unity/Assets/Scripts/Component/UIComponent.cs

@@ -6,16 +6,20 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class UiComponentSystem : ObjectSystem<UIComponent>, IAwake, ILoad
+	public class UiComponentAwakeSystem : AwakeSystem<UIComponent>
 	{
-		public void Awake()
+		public override void Awake(UIComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class UiComponentLoadSystem : LoadSystem<UIComponent>
+	{
+		public override void Load(UIComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 3 - 3
Unity/Assets/Scripts/Component/UnitComponent.cs

@@ -4,11 +4,11 @@ using System.Linq;
 namespace Model
 {
 	[ObjectSystem]
-	public class UnitComponentSystem : ObjectSystem<UnitComponent>, IAwake
+	public class UnitComponentSystem : AwakeSystem<UnitComponent>
 	{
-		public void Awake()
+		public override void Awake(UnitComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 4 - 4
Unity/Assets/Scripts/Entity/AssetsBundleLoaderAsync.cs

@@ -5,15 +5,15 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class AssetsBundleLoaderAsyncSystem : ObjectSystem<AssetsBundleLoaderAsync>, IUpdate
+	public class AssetsBundleLoaderAsyncSystem : UpdateSystem<AssetsBundleLoaderAsync>
 	{
-		public void Update()
+		public override void Update(AssetsBundleLoaderAsync self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 
-	public class AssetsBundleLoaderAsync : Component, IUpdate
+	public class AssetsBundleLoaderAsync : Component
 	{
 		private AssetBundleCreateRequest request;
 

+ 11 - 7
Unity/Assets/Scripts/Entity/AssetsLoaderAsync.cs

@@ -5,20 +5,24 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class AssetsLoaderAsyncSystem : ObjectSystem<AssetsLoaderAsync>, IUpdate, IAwake<AssetBundle>
+	public class AssetsLoaderAsyncAwakeSystem : AwakeSystem<AssetsLoaderAsync, AssetBundle>
 	{
-		public void Awake(AssetBundle assetBundle)
+		public override void Awake(AssetsLoaderAsync self, AssetBundle a)
 		{
-			this.Get().Awake(assetBundle);
+			self.Awake(a);
 		}
-		
-		public void Update()
+	}
+
+	[ObjectSystem]
+	public class AssetsLoaderAsyncUpdateSystem : UpdateSystem<AssetsLoaderAsync>
+	{
+		public override void Update(AssetsLoaderAsync self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 
-	public class AssetsLoaderAsync : Component, IUpdate
+	public class AssetsLoaderAsync : Component
 	{
 		private AssetBundle assetBundle;
 

+ 9 - 5
Unity/Assets/Scripts/Entity/Session.cs

@@ -8,16 +8,20 @@ using System.Threading.Tasks;
 namespace Model
 {
 	[ObjectSystem]
-	public class SessionSystem : ObjectSystem<Session>, IAwake<NetworkComponent, AChannel>, IStart
+	public class SessionAwakeSystem : AwakeSystem<Session, NetworkComponent, AChannel>
 	{
-		public void Awake(NetworkComponent network, AChannel channel)
+		public override void Awake(Session self, NetworkComponent a, AChannel b)
 		{
-			this.Get().Awake(network, channel);
+			self.Awake(a, b);
 		}
+	}
 
-		public void Start()
+	[ObjectSystem]
+	public class SessionStartSystem : StartSystem<Session>
+	{
+		public override void Start(Session self)
 		{
-			this.Get().Start();
+			self.Start();
 		}
 	}
 

+ 4 - 5
Unity/Assets/Scripts/Entity/UI.cs

@@ -4,15 +4,14 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class UiSystem : ObjectSystem<UI>, IAwake<Scene, UI, GameObject>
+	public class UiAwakeSystem : AwakeSystem<UI, Scene, UI, GameObject>
 	{
-		public void Awake(Scene scene, UI parent, GameObject gameObject)
+		public override void Awake(UI self, Scene scene, UI parent, GameObject gameObject)
 		{
-			this.Get().Awake(scene, parent, gameObject);
+			self.Awake(scene, parent, gameObject);
 		}
 	}
-	
-	
+
 	public sealed class UI: Entity
 	{
 		public Scene Scene { get; set; }

+ 1 - 6
Unity/Assets/Scripts/Entity/Unit.cs

@@ -7,12 +7,7 @@ namespace Model
 		Hero,
 		Npc
 	}
-
-	[ObjectSystem]
-	public class UnitSystem : ObjectSystem<Unit>
-	{
-	}
-
+	
 	public sealed class Unit: Entity
 	{
 		public VInt3 IntPos;

+ 3 - 3
Unity/Assets/Scripts/Entity/UnityWebRequestAsync.cs

@@ -7,11 +7,11 @@ using UnityEngine.Networking;
 namespace Model
 {
 	[ObjectSystem]
-	public class UnityWebRequestSystem : ObjectSystem<UnityWebRequestAsync>, IUpdate
+	public class UnityWebRequestSystem : UpdateSystem<UnityWebRequestAsync>
 	{
-		public void Update()
+		public override void Update(UnityWebRequestAsync self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 	

+ 3 - 3
Unity/Assets/Scripts/Entity/WWWAsync.cs

@@ -6,11 +6,11 @@ using UnityEngine;
 namespace Model
 {
 	[ObjectSystem]
-	public class WwwAsyncSystem : ObjectSystem<WWWAsync>, IUpdate
+	public class WwwAsyncUpdateSystem : UpdateSystem<WWWAsync>
 	{
-		public void Update()
+		public override void Update(WWWAsync self)
 		{
-			this.Get().Update();
+			self.Update();
 		}
 	}
 	

+ 10 - 9
Unity/Assets/Scripts/UI/UILoading/Component/UILoadingComponent.cs

@@ -4,24 +4,25 @@ using UnityEngine.UI;
 namespace Model
 {
 	[ObjectSystem]
-	public class UiLoadingComponentSystem : ObjectSystem<UILoadingComponent>, IAwake, IStart
+	public class UiLoadingComponentAwakeSystem : AwakeSystem<UILoadingComponent>
 	{
-		public void Awake()
+		public override void Awake(UILoadingComponent self)
 		{
-			UILoadingComponent self = this.Get();
 			self.text = self.GetParent<UI>().GameObject.Get<GameObject>("Text").GetComponent<Text>();
 		}
+	}
 
-		public async void Start()
+	[ObjectSystem]
+	public class UiLoadingComponentStartSystem : StartSystem<UILoadingComponent>
+	{
+		public override async void Start(UILoadingComponent self)
 		{
-			UILoadingComponent self = this.Get();
-
 			TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
-			
+
 			while (true)
 			{
 				await timerComponent.WaitAsync(1000);
-				
+
 				if (self.IsDisposed)
 				{
 					return;
@@ -36,7 +37,7 @@ namespace Model
 			}
 		}
 	}
-	
+
 	public class UILoadingComponent : Component
 	{
 		public Text text;

+ 0 - 1
Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs

@@ -59,7 +59,6 @@ namespace ILRuntime.Runtime.Generated
             System_Collections_Generic_List_1_ILTypeInstance_Binding.Register(app);
             System_Collections_Generic_List_1_Object_Binding.Register(app);
             System_Collections_Generic_Queue_1_ILTypeInstance_Binding.Register(app);
-            Model_IStart_Binding.Register(app);
             System_Collections_Generic_List_1_ILTypeInstance_Binding_Enumerator_Binding.Register(app);
             Model_DllHelper_Binding.Register(app);
             System_Activator_Binding.Register(app);

+ 0 - 29
Unity/Assets/ThirdParty/ILRuntime/Generated/Model_IStart_Binding.cs

@@ -15,35 +15,6 @@ namespace ILRuntime.Runtime.Generated
 {
     unsafe class Model_IStart_Binding
     {
-        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
-        {
-            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
-            MethodBase method;
-            FieldInfo field;
-            Type[] args;
-            Type type = typeof(Model.IStart);
-            args = new Type[]{};
-            method = type.GetMethod("Start", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Start_0);
-
-
-        }
-
-
-        static StackObject* Start_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            Model.IStart instance_of_this_method;
-            instance_of_this_method = (Model.IStart)typeof(Model.IStart).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            instance_of_this_method.Start();
-
-            return __ret;
-        }
 
 
 

+ 138 - 101
Unity/Hotfix/Base/Object/EventSystem.cs

@@ -32,10 +32,18 @@ namespace Hotfix
 
 	public sealed class EventSystem
 	{
-		private readonly Dictionary<Type, IObjectSystem> disposerEvents = new Dictionary<Type, IObjectSystem>();
-
 		private readonly Dictionary<int, List<IEvent>> allEvents = new Dictionary<int, List<IEvent>>();
 
+		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
+
+		private readonly UnOrderMultiMap<Type, AStartSystem> startEvents = new UnOrderMultiMap<Type, AStartSystem>();
+
+		private readonly UnOrderMultiMap<Type, ALoadSystem> loadEvents = new UnOrderMultiMap<Type, ALoadSystem>();
+
+		private readonly UnOrderMultiMap<Type, AUpdateSystem> updateEvents = new UnOrderMultiMap<Type, AUpdateSystem>();
+
+		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
+
 		private Queue<Component> updates = new Queue<Component>();
 		private Queue<Component> updates2 = new Queue<Component>();
 
@@ -51,8 +59,6 @@ namespace Hotfix
 
 		public EventSystem()
 		{
-			this.disposerEvents.Clear();
-
 			Type[] types = DllHelper.GetHotfixTypes();
 			foreach (Type type in types)
 			{
@@ -64,13 +70,36 @@ namespace Hotfix
 				}
 
 				object obj = Activator.CreateInstance(type);
-				IObjectSystem objectSystem = obj as IObjectSystem;
-				if (objectSystem == null)
+
+				AAwakeSystem objectSystem = obj as AAwakeSystem;
+				if (objectSystem != null)
 				{
-					Log.Error($"组件事件没有继承IObjectEvent: {type.Name}");
-					continue;
+					this.awakeEvents.Add(objectSystem.Type(), objectSystem);
+				}
+
+				AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
+				if (aUpdateSystem != null)
+				{
+					this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
+				}
+
+				ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
+				if (aLateUpdateSystem != null)
+				{
+					this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
+				}
+
+				AStartSystem aStartSystem = obj as AStartSystem;
+				if (aStartSystem != null)
+				{
+					this.startEvents.Add(aStartSystem.Type(), aStartSystem);
+				}
+
+				ALoadSystem aLoadSystem = obj as ALoadSystem;
+				if (aLoadSystem != null)
+				{
+					this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
 				}
-				this.disposerEvents[objectSystem.Type()] = objectSystem;
 			}
 
 			this.allEvents.Clear();
@@ -98,15 +127,6 @@ namespace Hotfix
 			this.Load();
 		}
 
-		public void RegisterEvent(int eventId, IEvent e)
-		{
-			if (!this.allEvents.ContainsKey(eventId))
-			{
-				this.allEvents.Add(eventId, new List<IEvent>());
-			}
-			this.allEvents[eventId].Add(e);
-		}
-
 		public static void Handle(int type, List<object> param)
 		{
 			switch (param.Count)
@@ -125,30 +145,36 @@ namespace Hotfix
 					break;
 			}
 		}
-
-		public void Add(Component disposer)
+		
+		public void RegisterEvent(int eventId, IEvent e)
 		{
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectSystem))
+			if (!this.allEvents.ContainsKey(eventId))
 			{
-				return;
+				this.allEvents.Add(eventId, new List<IEvent>());
 			}
+			this.allEvents[eventId].Add(e);
+		}
+
+		public void Add(Component disposer)
+		{
+			Type type = disposer.GetType();
 
-			if (objectSystem is ILoad)
+			if (this.loadEvents.ContainsKey(type))
 			{
 				this.loaders.Enqueue(disposer);
 			}
 
-			if (objectSystem is IUpdate)
+			if (this.updateEvents.ContainsKey(type))
 			{
 				this.updates.Enqueue(disposer);
 			}
 
-			if (objectSystem is IStart)
+			if (this.startEvents.ContainsKey(type))
 			{
 				this.starts.Enqueue(disposer);
 			}
 
-			if (objectSystem is ILateUpdate)
+			if (this.lateUpdateEvents.ContainsKey(type))
 			{
 				this.lateUpdates.Enqueue(disposer);
 			}
@@ -158,68 +184,80 @@ namespace Hotfix
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
 				return;
 			}
-			IAwake iAwake = objectEvent as IAwake;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				return;
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake();
 		}
 
 		public void Awake<P1>(Component disposer, P1 p1)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake1");
+				return;
 			}
-			IAwake<P1> iAwake = objectEvent as IAwake<P1>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake1");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1);
 		}
 
 		public void Awake<P1, P2>(Component disposer, P1 p1, P2 p2)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake2");
+				return;
 			}
-			IAwake<P1, P2> iAwake = objectEvent as IAwake<P1, P2>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake2");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1, p2);
 		}
 
 		public void Awake<P1, P2, P3>(Component disposer, P1 p1, P2 p2, P3 p3)
 		{
 			this.Add(disposer);
 
-			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			if (iAwakeSystems == null)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake3");
+				return;
 			}
-			IAwake<P1, P2, P3> iAwake = objectEvent as IAwake<P1, P2, P3>;
-			if (iAwake == null)
+
+			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
-				throw new Exception($"{disposer.GetType().Name} not found awake3");
+				if (aAwakeSystem == null)
+				{
+					continue;
+				}
+				aAwakeSystem.Run(disposer, p1, p2, p3);
 			}
-			objectEvent.Set(disposer);
-			iAwake.Awake(p1, p2, p3);
 		}
 
 		public void Load()
@@ -238,26 +276,24 @@ namespace Hotfix
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<ALoadSystem> aLoadSystems = this.loadEvents[disposer.GetType()];
+				if (aLoadSystems == null)
 				{
 					continue;
 				}
 
 				this.loaders2.Enqueue(disposer);
 
-				ILoad iLoad = objectEvent as ILoad;
-				if (iLoad == null)
-				{
-					continue;
-				}
-				objectEvent.Set(disposer);
-				try
-				{
-					iLoad.Load();
-				}
-				catch (Exception e)
+				foreach (ALoadSystem aLoadSystem in aLoadSystems)
 				{
-					Log.Error(e.ToString());
+					try
+					{
+						aLoadSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 
@@ -276,17 +312,23 @@ namespace Hotfix
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<AStartSystem> aStartSystems = this.startEvents[disposer.GetType()];
+				if (aStartSystems == null)
 				{
 					continue;
 				}
-				IStart iStart = objectEvent as IStart;
-				if (iStart == null)
+
+				foreach (AStartSystem aStartSystem in aStartSystems)
 				{
-					continue;
+					try
+					{
+						aStartSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
-				objectEvent.Set(disposer);
-				iStart.Start();
 			}
 		}
 
@@ -294,7 +336,7 @@ namespace Hotfix
 		{
 			this.Start();
 
-			unique.Clear();
+			this.unique.Clear();
 			while (this.updates.Count > 0)
 			{
 				Component disposer = this.updates.Dequeue();
@@ -308,26 +350,24 @@ namespace Hotfix
 					continue;
 				}
 
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectEvent))
+				List<AUpdateSystem> aUpdateSystems = this.updateEvents[disposer.GetType()];
+				if (aUpdateSystems == null)
 				{
 					continue;
 				}
 
 				this.updates2.Enqueue(disposer);
 
-				IUpdate iUpdate = objectEvent as IUpdate;
-				if (iUpdate == null)
+				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
-					continue;
-				}
-				objectEvent.Set(disposer);
-				try
-				{
-					iUpdate.Update();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aUpdateSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 
@@ -336,7 +376,7 @@ namespace Hotfix
 
 		public void LateUpdate()
 		{
-			unique.Clear();
+			this.unique.Clear();
 			while (this.lateUpdates.Count > 0)
 			{
 				Component disposer = this.lateUpdates.Dequeue();
@@ -350,27 +390,24 @@ namespace Hotfix
 					continue;
 				}
 
-				IObjectSystem objectSystem;
-				if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
+				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[disposer.GetType()];
+				if (aLateUpdateSystems == null)
 				{
 					continue;
 				}
 
 				this.lateUpdates2.Enqueue(disposer);
 
-				ILateUpdate iLateUpdate = objectSystem as ILateUpdate;
-				if (iLateUpdate == null)
+				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
-					continue;
-				}
-				objectSystem.Set(disposer);
-				try
-				{
-					iLateUpdate.LateUpdate();
-				}
-				catch (Exception e)
-				{
-					Log.Error(e.ToString());
+					try
+					{
+						aLateUpdateSystem.Run(disposer);
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
 				}
 			}
 

+ 60 - 9
Unity/Hotfix/Base/Object/IAwake.cs

@@ -1,22 +1,73 @@
-namespace Hotfix
+using System;
+
+namespace Hotfix
 {
-	public interface IAwake
+	public abstract class AAwakeSystem
+	{
+		public abstract Type Type();
+		public virtual void Run(object o) { }
+		public virtual void Run(object o, object a) { }
+		public virtual void Run(object o, object a, object b) { }
+		public virtual void Run(object o, object a, object b, object c) { }
+	}
+
+	public abstract class AwakeSystem<T> : AAwakeSystem
 	{
-		void Awake();
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o)
+		{
+			this.Awake((T)o);
+		}
+
+		public abstract void Awake(T self);
 	}
 
-	public interface IAwake<A>
+	public abstract class AwakeSystem<T, A> : AAwakeSystem
 	{
-		void Awake(A a);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a)
+		{
+			this.Awake((T)o, (A)a);
+		}
+
+		public abstract void Awake(T self, A a);
 	}
 
-	public interface IAwake<A, B>
+	public abstract class AwakeSystem<T, A, B> : AAwakeSystem
 	{
-		void Awake(A a, B b);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a, object b)
+		{
+			this.Awake((T)o, (A)a, (B)b);
+		}
+
+		public abstract void Awake(T self, A a, B b);
 	}
 
-	public interface IAwake<A, B, C>
+	public abstract class AwakeSystem<T, A, B, C> : AAwakeSystem
 	{
-		void Awake(A a, B b, C c);
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public override void Run(object o, object a, object b, object c)
+		{
+			this.Awake((T)o, (A)a, (B)b, (C)c);
+		}
+
+		public abstract void Awake(T self, A a, B b, C c);
 	}
 }

+ 21 - 3
Unity/Hotfix/Base/Object/ILateUpdate.cs

@@ -1,7 +1,25 @@
-namespace Hotfix
+using System;
+
+namespace Hotfix
 {
-	public interface ILateUpdate
+	public abstract class ALateUpdateSystem
 	{
-		void LateUpdate();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class LateUpdateSystem<T> : ALateUpdateSystem
+	{
+		public override void Run(object o)
+		{
+			this.LateUpdate((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void LateUpdate(T self);
 	}
 }

+ 21 - 3
Unity/Hotfix/Base/Object/ILoad.cs

@@ -1,7 +1,25 @@
-namespace Hotfix
+using System;
+
+namespace Hotfix
 {
-	public interface ILoad
+	public abstract class ALoadSystem
 	{
-		void Load();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class LoadSystem<T> : ALoadSystem
+	{
+		public override void Run(object o)
+		{
+			this.Load((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Load(T self);
 	}
 }

+ 25 - 0
Unity/Hotfix/Base/Object/IStart.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace Hotfix
+{
+	public abstract class AStartSystem
+	{
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class StartSystem<T> : AStartSystem
+	{
+		public override void Run(object o)
+		{
+			this.Start((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Start(T self);
+	}
+}

+ 21 - 3
Unity/Hotfix/Base/Object/IUpdate.cs

@@ -1,7 +1,25 @@
-namespace Hotfix
+using System;
+
+namespace Hotfix
 {
-	public interface IUpdate
+	public abstract class AUpdateSystem
 	{
-		void Update();
+		public abstract Type Type();
+		public abstract void Run(object o);
+	}
+
+	public abstract class UpdateSystem<T> : AUpdateSystem
+	{
+		public override void Run(object o)
+		{
+			this.Update((T)o);
+		}
+
+		public override Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Update(T self);
 	}
 }

+ 13 - 9
Unity/Hotfix/Component/OperaComponent.cs

@@ -4,20 +4,24 @@ using UnityEngine;
 namespace Hotfix
 {
     [ObjectSystem]
-    public class OperaComponentSystem : ObjectSystem<OperaComponent>, IUpdate, IAwake
+    public class OperaComponentAwakeSystem : AwakeSystem<OperaComponent>
     {
-        public void Update()
-        {
-            this.Get().Update();
-        }
-
-	    public void Awake()
+	    public override void Awake(OperaComponent self)
 	    {
-		    this.Get().Awake();
+		    self.Awake();
 	    }
     }
 
-    public class OperaComponent: Component
+	[ObjectSystem]
+	public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
+	{
+		public override void Update(OperaComponent self)
+		{
+			self.Update();
+		}
+	}
+
+	public class OperaComponent: Component
     {
         public Vector3 ClickPoint;
 

+ 9 - 5
Unity/Hotfix/Component/UIComponent.cs

@@ -7,16 +7,20 @@ using UnityEngine;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class UiComponentSystem : ObjectSystem<UIComponent>, IAwake, ILoad
+	public class UiComponentAwakeSystem : AwakeSystem<UIComponent>
 	{
-		public void Awake()
+		public override void Awake(UIComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class UiComponentLoadSystem : LoadSystem<UIComponent>
+	{
+		public override void Load(UIComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 3 - 3
Unity/Hotfix/Entity/UI.cs

@@ -4,11 +4,11 @@ using UnityEngine;
 namespace Hotfix
 {
 	[Model.ObjectSystem]
-	public class UiSystem : ObjectSystem<UI>, IAwake<Scene, UI, GameObject>
+	public class UiSystem : AwakeSystem<UI, Scene, UI, GameObject>
 	{
-		public void Awake(Scene scene, UI parent, GameObject gameObject)
+		public override void Awake(UI self, Scene scene, UI parent, GameObject gameObject)
 		{
-			this.Get().Awake(scene, parent, gameObject);
+			self.Awake(scene, parent, gameObject);
 		}
 	}
 	

+ 9 - 5
Unity/Hotfix/Module/HotfixMessage/MessageDispatherComponent.cs

@@ -5,16 +5,20 @@ using Model;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class MessageDispatherComponentSystem : ObjectSystem<MessageDispatherComponent>, IAwake, ILoad
+	public class MessageDispatherComponentAwakeSystem : AwakeSystem<MessageDispatherComponent>
 	{
-		public void Awake()
+		public override void Awake(MessageDispatherComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
+	}
 
-		public void Load()
+	[ObjectSystem]
+	public class MessageDispatherComponentLoadSystem : LoadSystem<MessageDispatherComponent>
+	{
+		public override void Load(MessageDispatherComponent self)
 		{
-			this.Get().Load();
+			self.Load();
 		}
 	}
 

+ 3 - 3
Unity/Hotfix/Module/HotfixMessage/OpcodeTypeComponent.cs

@@ -4,11 +4,11 @@ using Model;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class OpcodeTypeComponentSystem : ObjectSystem<OpcodeTypeComponent>, IAwake
+	public class OpcodeTypeComponentAwakeSystem : AwakeSystem<OpcodeTypeComponent>
 	{
-		public void Awake()
+		public override void Awake(OpcodeTypeComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 

+ 3 - 3
Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs

@@ -6,11 +6,11 @@ using UnityEngine.UI;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class UiLobbyComponentSystem : ObjectSystem<UILobbyComponent>, IAwake
+	public class UiLobbyComponentSystem : AwakeSystem<UILobbyComponent>
 	{
-		public void Awake()
+		public override void Awake(UILobbyComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 3 - 3
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs

@@ -7,11 +7,11 @@ using UnityEngine.UI;
 namespace Hotfix
 {
 	[ObjectSystem]
-	public class UiLoginComponentSystem : ObjectSystem<UILoginComponent>, IAwake
+	public class UiLoginComponentSystem : AwakeSystem<UILoginComponent>
 	{
-		public void Awake()
+		public override void Awake(UILoginComponent self)
 		{
-			this.Get().Awake();
+			self.Awake();
 		}
 	}
 	

+ 1 - 0
Unity/Hotfix/Unity.Hotfix.csproj

@@ -54,6 +54,7 @@
     <Compile Include="Base\Helper\ArrayHelper.cs" />
     <Compile Include="Base\Helper\AssetBundleHelper.cs" />
     <Compile Include="Base\Helper\ExceptionHelper.cs" />
+    <Compile Include="Base\Object\IStart.cs" />
     <Compile Include="Component\OperaComponent.cs" />
     <Compile Include="Event\TestHotfixSubscribMonoEvent_LogString.cs" />
     <Compile Include="Handler\Actor_CreateUnitsHandler.cs" />

+ 1 - 0
Unity/Unity.csproj

@@ -230,6 +230,7 @@
     <Compile Include="Assets\Scripts\Base\Message\OpcodeHelper.cs" />
     <Compile Include="Assets\Scripts\Base\Message\ProtobufPacker.cs" />
     <Compile Include="Assets\Scripts\Base\Message\RpcException.cs" />
+    <Compile Include="Assets\Scripts\Base\UnOrderMultiMap.cs" />
     <Compile Include="Assets\Scripts\Base\MultiMap.cs" />
     <Compile Include="Assets\Scripts\Base\Network\AChannel.cs" />
     <Compile Include="Assets\Scripts\Base\Network\AService.cs" />