Explorar o código

1.每个Component都增加了一个InstanceId,这个id每个对象是唯一的,区分开来逻辑Id跟对象Id,比如Player对象的Id在整个游戏期间都是不变的,但是每次登录Player的InstanceId都应该不一样,actorid应该用InstanceId来处理。例如erlang的进程id是actorid,但是erlang进程中的玩家id不会是进程id。
2.加入instanceid是因为存在一个问题:Player的id是唯一的,但是断线重连,假如只有Player.Id系统无法区分,断线前的Player跟断线后的Player。
3.简化了EventSystem的实现,并且不需要ActorManagerComponent了,所有的Component都会注册在EventSystem里面,有很多好处,不细说了。
4.Disposer类删掉了,之前继承Disposer的类都可以通过继承Component来实现

tanghai %!s(int64=7) %!d(string=hai) anos
pai
achega
c4930ded5d
Modificáronse 60 ficheiros con 554 adicións e 641 borrados
  1. 1 1
      Client-Server.sln.DotSettings.user
  2. 6 6
      Config/StartConfig/127.0.0.1.txt
  3. 2 6
      Server/App/Program.cs
  4. 3 7
      Server/Hotfix/Module/Actor/ActorComponentSystem.cs
  5. 4 4
      Server/Hotfix/Module/DB/DBQueryBatchRequestHandler.cs
  6. 4 4
      Server/Hotfix/Module/DB/DBQueryJsonRequestHandler.cs
  7. 4 4
      Server/Hotfix/Module/DB/DBQueryRequestHandler.cs
  8. 4 4
      Server/Hotfix/Module/DB/DBSaveBatchRequestHandler.cs
  9. 3 3
      Server/Hotfix/Module/DB/DBSaveRequestHandler.cs
  10. 1 1
      Server/Hotfix/Module/FrameSync/C2G_EnterMapHandler.cs
  11. 1 0
      Server/Hotfix/Module/FrameSync/G2M_CreateUnitHandler.cs
  12. 2 2
      Server/Hotfix/Module/Message/InnerMessageDispatcher.cs
  13. 3 1
      Server/Hotfix/Module/Message/OuterMessageDispatcher.cs
  14. 1 1
      Server/Model/Component/AppManagerComponent.cs
  15. 4 4
      Server/Model/Component/BenchmarkComponent.cs
  16. 1 1
      Server/Model/Module/Actor/AMActorHandler.cs
  17. 7 18
      Server/Model/Module/Actor/ActorComponent.cs
  18. 0 58
      Server/Model/Module/Actor/ActorManagerComponent.cs
  19. 23 49
      Server/Model/Module/Actor/ActorProxy.cs
  20. 17 17
      Server/Model/Module/DB/DBCacheComponent.cs
  21. 13 13
      Server/Model/Module/DB/DBProxyComponent.cs
  22. 6 6
      Server/Model/Module/DB/DBQueryBatchTask.cs
  23. 2 2
      Server/Model/Module/DB/DBQueryJsonTask.cs
  24. 7 7
      Server/Model/Module/DB/DBQueryTask.cs
  25. 8 8
      Server/Model/Module/DB/DBSaveBatchTask.cs
  26. 3 3
      Server/Model/Module/DB/DBSaveTask.cs
  27. 1 1
      Server/Model/Module/DB/DBTaskQueue.cs
  28. 1 1
      Server/Model/Module/Message/AMRpcHandler.cs
  29. 5 5
      Server/Model/Module/Message/InnerMessage.cs
  30. 0 1
      Server/Model/Server.Model.csproj
  31. 1 1
      Unity/Assets/Editor/ExcelExporterEditor/ExcelExporterEditor.cs
  32. 59 4
      Unity/Assets/Scripts/Base/Object/Component.cs
  33. 48 48
      Unity/Assets/Scripts/Base/Object/ComponentFactory.cs
  34. 0 30
      Unity/Assets/Scripts/Base/Object/Disposer.cs
  35. 0 12
      Unity/Assets/Scripts/Base/Object/Disposer.cs.meta
  36. 3 3
      Unity/Assets/Scripts/Base/Object/Entity.cs
  37. 76 74
      Unity/Assets/Scripts/Base/Object/EventSystem.cs
  38. 10 11
      Unity/Assets/Scripts/Base/Object/ObjectPool.cs
  39. 1 1
      Unity/Assets/Scripts/Helper/BundleHelper.cs
  40. 1 1
      Unity/Assets/Scripts/Init.cs
  41. 1 1
      Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs
  42. 1 1
      Unity/Assets/Scripts/Module/Message/MessageDispatherComponent.cs
  43. 1 1
      Unity/Assets/Scripts/Module/Message/Network/KCP/KService.cs
  44. 2 2
      Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs
  45. 1 1
      Unity/Assets/Scripts/Module/Message/NetworkComponent.cs
  46. 3 2
      Unity/Assets/Scripts/Module/Message/Session.cs
  47. 1 1
      Unity/Assets/Scripts/UI/UILoading/Factory/UILoadingFactory.cs
  48. 0 1
      Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs
  49. 0 31
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Disposer_Binding.cs
  50. 66 5
      Unity/Hotfix/Base/Object/Component.cs
  51. 48 48
      Unity/Hotfix/Base/Object/ComponentFactory.cs
  52. 0 26
      Unity/Hotfix/Base/Object/Disposer.cs
  53. 2 2
      Unity/Hotfix/Base/Object/Entity.cs
  54. 71 76
      Unity/Hotfix/Base/Object/EventSystem.cs
  55. 11 11
      Unity/Hotfix/Base/Object/ObjectPool.cs
  56. 1 1
      Unity/Hotfix/Module/Message/MessageDispatherComponent.cs
  57. 1 1
      Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs
  58. 1 1
      Unity/Hotfix/UI/UILogin/Factory/UILoginFactory.cs
  59. 0 1
      Unity/Hotfix/Unity.Hotfix.csproj
  60. 7 5
      Unity/Unity.csproj

+ 1 - 1
Client-Server.sln.DotSettings.user

@@ -12,7 +12,7 @@
 	<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">HINT</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Unity/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Unity"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;DISABLED&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" /&gt;&lt;/Profile&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Unity</s:String>
-	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">-164,-76</s:String>
+	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">122,-178</s:String>
 	<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64>
 	<s:String x:Key="/Default/Profiling/Configurations/=1/@EntryIndexedValue">&lt;data&gt;&lt;HostParameters type="LocalHostParameters" /&gt;&lt;Argument type="StandaloneArgument"&gt;&lt;Arguments IsNull="False"&gt;&lt;/Arguments&gt;&lt;FileName IsNull="False"&gt;&lt;/FileName&gt;&lt;WorkingDirectory IsNull="False"&gt;&lt;/WorkingDirectory&gt;&lt;Scope&gt;&lt;ProcessFilters /&gt;&lt;/Scope&gt;&lt;/Argument&gt;&lt;Info type="TimelineInfo" /&gt;&lt;HostOptions type="HostOptions"&gt;&lt;HostTempPath IsNull="False"&gt;&lt;/HostTempPath&gt;&lt;/HostOptions&gt;&lt;/data&gt;</s:String>
 	</wpf:ResourceDictionary>

+ 6 - 6
Config/StartConfig/127.0.0.1.txt

@@ -1,9 +1,9 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10000, "Host2" : null }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10000, "Host2" : "127.0.0.1" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
 { "_t" : "StartConfig", "_id" : NumberLong("98565862653976"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 2, "AppType" : "Location", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20001 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : null }], "AppId" : 3, "AppType" : "Realm", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20002 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10003, "Host2" : null }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20003 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10004, "Host2" : null }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20004 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10005, "Host2" : null }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20005 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10006, "Host2" : null }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20001 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : "127.0.0.1" }], "AppId" : 3, "AppType" : "Realm", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20002 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10003, "Host2" : "127.0.0.1" }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20003 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10004, "Host2" : "127.0.0.1" }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20004 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10005, "Host2" : "127.0.0.1" }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20005 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10006, "Host2" : "127.0.0.1" }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
 { "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20006 }], "AppId" : 8, "AppType" : "Map", "ServerIP" : "*" }
 { "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "components" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20007 }], "AppId" : 9, "AppType" : "Map", "ServerIP" : "*" }

+ 2 - 6
Server/App/Program.cs

@@ -56,7 +56,6 @@ namespace App
 						break;
 					case AppType.Realm:
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<ActorManagerComponent>();
 						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
 						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
 						Game.Scene.AddComponent<LocationProxyComponent>();
@@ -65,7 +64,6 @@ namespace App
 					case AppType.Gate:
 						Game.Scene.AddComponent<PlayerComponent>();
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<ActorManagerComponent>();
 						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
 						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
 						Game.Scene.AddComponent<LocationProxyComponent>();
@@ -78,7 +76,6 @@ namespace App
 						break;
 					case AppType.Map:
 						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
-						Game.Scene.AddComponent<ActorManagerComponent>();
 						Game.Scene.AddComponent<UnitComponent>();
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorProxyComponent>();
@@ -94,7 +91,6 @@ namespace App
 						Game.Scene.AddComponent<DBCacheComponent>();
 						Game.Scene.AddComponent<LocationComponent>();
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<ActorManagerComponent>();
 						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
 						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
 						Game.Scene.AddComponent<LocationProxyComponent>();
@@ -122,13 +118,13 @@ namespace App
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 	}

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

@@ -41,8 +41,6 @@ namespace ETHotfix
 		{
 			self.entityActorHandler = new CommonEntityActorHandler();
 			self.queue = new Queue<ActorMessageInfo>();
-			self.actorId = self.Entity.Id;
-			Game.Scene.GetComponent<ActorManagerComponent>().Add((Entity)self.Parent);
 			self.HandleAsync();
 		}
 
@@ -50,8 +48,6 @@ namespace ETHotfix
 		{
 			self.entityActorHandler = iEntityActorHandler;
 			self.queue = new Queue<ActorMessageInfo>();
-			self.actorId = self.Entity.Id;
-			Game.Scene.GetComponent<ActorManagerComponent>().Add((Entity)self.Parent);
 			self.HandleAsync();
 		}
 
@@ -63,12 +59,12 @@ namespace ETHotfix
 
 		public static async Task AddLocation(this ActorComponent self)
 		{
-			await Game.Scene.GetComponent<LocationProxyComponent>().Add(self.actorId);
+			await Game.Scene.GetComponent<LocationProxyComponent>().Add(self.Parent.InstanceId);
 		}
 
 		public static async Task RemoveLocation(this ActorComponent self)
 		{
-			await Game.Scene.GetComponent<LocationProxyComponent>().Remove(self.actorId);
+			await Game.Scene.GetComponent<LocationProxyComponent>().Remove(self.Parent.InstanceId);
 		}
 
 		public static void Add(this ActorComponent self, ActorMessageInfo info)
@@ -116,7 +112,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 4 - 4
Server/Hotfix/Module/DB/DBQueryBatchRequestHandler.cs

@@ -13,15 +13,15 @@ namespace ETHotfix
 			try
 			{
 				DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
-				List<Component> disposers = await dbCacheComponent.GetBatch(message.CollectionName, message.IdList);
+				List<Component> components = await dbCacheComponent.GetBatch(message.CollectionName, message.IdList);
 
-				response.Disposers = disposers;
+				response.Components = components;
 
 				if (message.NeedCache)
 				{
-					foreach (Component disposer in disposers)
+					foreach (Component component in components)
 					{
-						dbCacheComponent.AddToCache(disposer, message.CollectionName);
+						dbCacheComponent.AddToCache(component, message.CollectionName);
 					}
 				}
 

+ 4 - 4
Server/Hotfix/Module/DB/DBQueryJsonRequestHandler.cs

@@ -13,15 +13,15 @@ namespace ETHotfix
 			try
 			{
 				DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
-				List<Component> disposers = await dbCacheComponent.GetJson(message.CollectionName, message.Json);
+				List<Component> components = await dbCacheComponent.GetJson(message.CollectionName, message.Json);
 
-				response.Disposers = disposers;
+				response.Components = components;
 
 				if (message.NeedCache)
 				{
-					foreach (Component disposer in disposers)
+					foreach (Component component in components)
 					{
-						dbCacheComponent.AddToCache(disposer, message.CollectionName);
+						dbCacheComponent.AddToCache(component, message.CollectionName);
 					}
 				}
 

+ 4 - 4
Server/Hotfix/Module/DB/DBQueryRequestHandler.cs

@@ -12,13 +12,13 @@ namespace ETHotfix
 			try
 			{
 				DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
-				Component disposer = await dbCacheComponent.Get(message.CollectionName, message.Id);
+				Component component = await dbCacheComponent.Get(message.CollectionName, message.Id);
 
-				response.Disposer = disposer;
+				response.Component = component;
 
-				if (message.NeedCache && disposer != null)
+				if (message.NeedCache && component != null)
 				{
-					dbCacheComponent.AddToCache(disposer, message.CollectionName);
+					dbCacheComponent.AddToCache(component, message.CollectionName);
 				}
 
 				reply(response);

+ 4 - 4
Server/Hotfix/Module/DB/DBSaveBatchRequestHandler.cs

@@ -15,18 +15,18 @@ namespace ETHotfix
 
 				if (string.IsNullOrEmpty(message.CollectionName))
 				{
-					message.CollectionName = message.Disposers[0].GetType().Name;
+					message.CollectionName = message.Components[0].GetType().Name;
 				}
 
 				if (message.NeedCache)
 				{
-					foreach (Component disposer in message.Disposers)
+					foreach (Component component in message.Components)
 					{
-						dbCacheComponent.AddToCache(disposer, message.CollectionName);
+						dbCacheComponent.AddToCache(component, message.CollectionName);
 					}
 				}
 
-				await dbCacheComponent.AddBatch(message.Disposers, message.CollectionName);
+				await dbCacheComponent.AddBatch(message.Components, message.CollectionName);
 
 				reply(response);
 			}

+ 3 - 3
Server/Hotfix/Module/DB/DBSaveRequestHandler.cs

@@ -14,14 +14,14 @@ namespace ETHotfix
 				DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
 				if (string.IsNullOrEmpty(message.CollectionName))
 				{
-					message.CollectionName = message.Disposer.GetType().Name;
+					message.CollectionName = message.Component.GetType().Name;
 				}
 
 				if (message.NeedCache)
 				{
-					dbCacheComponent.AddToCache(message.Disposer, message.CollectionName);
+					dbCacheComponent.AddToCache(message.Component, message.CollectionName);
 				}
-				await dbCacheComponent.Add(message.Disposer, message.CollectionName);
+				await dbCacheComponent.Add(message.Component, message.CollectionName);
 				reply(response);
 			}
 			catch (Exception e)

+ 1 - 1
Server/Hotfix/Module/FrameSync/C2G_EnterMapHandler.cs

@@ -16,7 +16,7 @@ namespace ETHotfix
 				// 在map服务器上创建战斗Unit
 				IPEndPoint mapAddress = Game.Scene.GetComponent<StartConfigComponent>().MapConfigs[0].GetComponent<InnerConfig>().IPEndPoint;
 				Session mapSession = Game.Scene.GetComponent<NetInnerComponent>().Get(mapAddress);
-				M2G_CreateUnit createUnit = (M2G_CreateUnit)await mapSession.Call(new G2M_CreateUnit() { PlayerId = player.Id, GateSessionId = session.Id });
+				M2G_CreateUnit createUnit = (M2G_CreateUnit)await mapSession.Call(new G2M_CreateUnit() { PlayerId = player.Id, GateSessionId = session.InstanceId });
 				player.UnitId = createUnit.UnitId;
 				response.UnitId = createUnit.UnitId;
 				response.Count = createUnit.Count;

+ 1 - 0
Server/Hotfix/Module/FrameSync/G2M_CreateUnitHandler.cs

@@ -12,6 +12,7 @@ namespace ETHotfix
 			try
 			{
 				Unit unit = ComponentFactory.Create<Unit>();
+
 				await unit.AddComponent<ActorComponent, IEntityActorHandler>(new MapUnitEntityActorHandler()).AddLocation();
 				unit.AddComponent<UnitGateComponent, long>(message.GateSessionId);
 				Game.Scene.GetComponent<UnitComponent>().Add(unit);

+ 2 - 2
Server/Hotfix/Module/Message/InnerMessageDispatcher.cs

@@ -14,10 +14,10 @@ namespace ETHotfix
 			// 收到actor消息,放入actor队列
 			if (message is IActorMessage iActorMessage)
 			{
-				Entity entity = Game.Scene.GetComponent<ActorManagerComponent>().Get(iActorMessage.ActorId);
+				Entity entity = Game.EventSystem.Get(iActorMessage.ActorId) as Entity;
 				if (entity == null)
 				{
-					Log.Debug($"not found actor: {iActorMessage.ActorId}");
+					Log.Warning($"not found actor: {iActorMessage.ActorId}");
 					ActorResponse response = new ActorResponse
 					{
 						Error = ErrorCode.ERR_NotFoundActor,

+ 3 - 1
Server/Hotfix/Module/Message/OuterMessageDispatcher.cs

@@ -10,7 +10,9 @@ namespace ETHotfix
 			ushort opcode = packet.Opcode();
 			Type messageType = session.Network.Entity.GetComponent<OpcodeTypeComponent>().GetType(opcode);
 			object message = session.Network.MessagePacker.DeserializeFrom(messageType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
-			
+
+			//Log.Debug($"recv: {JsonHelper.ToJson(message)}");
+
 			switch (message)
 			{
 				case IFrameMessage iFrameMessage: // 如果是帧消息,构造成OneFrameMessage发给对应的unit

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

@@ -65,7 +65,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 

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

@@ -31,7 +31,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 
@@ -51,11 +51,11 @@ namespace ETModel
 			}
 			catch (RpcException e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 
@@ -78,7 +78,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 

+ 1 - 1
Server/Model/Module/Actor/AMActorHandler.cs

@@ -46,7 +46,7 @@ namespace ETModel
 	{
 		protected static void ReplyError(Response response, Exception e, Action<Response> reply)
 		{
-			Log.Error(e.ToString());
+			Log.Error(e);
 			response.Error = ErrorCode.ERR_RpcFail;
 			response.Message = e.ToString();
 			reply(response);

+ 7 - 18
Server/Model/Module/Actor/ActorComponent.cs

@@ -17,8 +17,6 @@ namespace ETModel
 	{
 		public IEntityActorHandler entityActorHandler;
 
-		public long actorId;
-
 		// 队列处理消息
 		public Queue<ActorMessageInfo> queue;
 
@@ -26,25 +24,16 @@ namespace ETModel
 
 		public override void Dispose()
 		{
-			try
+			if (this.IsDisposed)
 			{
-				if (this.IsDisposed)
-				{
-					return;
-				}
-
-				base.Dispose();
+				return;
+			}
 
-				var t = this.tcs;
-				this.tcs = null;
-				t?.SetResult(new ActorMessageInfo());
+			base.Dispose();
 
-				Game.Scene.GetComponent<ActorManagerComponent>().Remove(actorId);
-			}
-			catch (Exception)
-			{
-				Log.Error($"unregister actor fail: {this.actorId}");
-			}
+			var t = this.tcs;
+			this.tcs = null;
+			t?.SetResult(new ActorMessageInfo());
 		}
 	}
 }

+ 0 - 58
Server/Model/Module/Actor/ActorManagerComponent.cs

@@ -1,58 +0,0 @@
-using System.Collections.Generic;
-
-namespace ETModel
-{
-	[ObjectSystem]
-	public class ActorManagerComponentAwakeSystem : AwakeSystem<ActorManagerComponent>
-	{
-		public override void Awake(ActorManagerComponent self)
-		{
-			self.Awake();
-		}
-	}
-
-	/// <summary>
-	/// 用来管理该服务器上所有的Actor对象
-	/// </summary>
-	public class ActorManagerComponent : Component
-	{
-		private readonly Dictionary<long, Entity> dictionary = new Dictionary<long, Entity>();
-
-		public void Awake()
-		{
-		}
-
-		public void Add(Entity entity)
-		{
-			Log.Info($"add actor: {entity.Id} {entity.GetType().Name}");
-			dictionary[entity.Id] = entity;
-		}
-
-		public void Remove(long id)
-		{
-			Entity entity;
-			if (!this.dictionary.TryGetValue(id, out entity))
-			{
-				return;
-			}
-			Log.Info($"remove actor: {entity.Id} {entity.GetType().Name}");
-			this.dictionary.Remove(id);
-		}
-
-		public Entity Get(long id)
-		{
-			Entity entity = null;
-			this.dictionary.TryGetValue(id, out entity);
-			return entity;
-		}
-
-		public override void Dispose()
-		{
-			if (this.IsDisposed)
-			{
-				return;
-			}
-			base.Dispose();
-		}
-	}
-}

+ 23 - 49
Server/Model/Module/Actor/ActorProxy.cs

@@ -31,19 +31,10 @@ namespace ETModel
 	{
 		// actor的地址
 		public IPEndPoint Address;
-
-		// 已发送等待回应的消息
-		public Queue<ActorTask> RunningTasks = new Queue<ActorTask>();
-
+		
 		// 还没发送的消息
 		public Queue<ActorTask> WaitingTasks = new Queue<ActorTask>();
-
-		// 发送窗口大小
-		public int WindowSize = 1;
-
-		// 最大窗口
-		public const int MaxWindowSize = 1;
-
+		
 		// 最近发送消息的时间
 		public long LastSendTime;
 
@@ -56,7 +47,6 @@ namespace ETModel
 		public void Awake()
 		{
 			this.LastSendTime = TimeHelper.Now();
-			this.WindowSize = 1;
 			this.tcs = null;
 			this.CancellationTokenSource = new CancellationTokenSource();
 		}
@@ -71,8 +61,13 @@ namespace ETModel
 			base.Dispose();
 			this.LastSendTime = 0;
 			this.Address = null;
-			this.RunningTasks.Clear();
-			this.WaitingTasks.Clear();
+
+			while (this.WaitingTasks.Count > 0)
+			{
+				ActorTask actorTask = this.WaitingTasks.Dequeue();
+				actorTask.RunFail(ErrorCode.ERR_NotFoundActor);
+			}
+
 			this.failTimes = 0;
 			var t = this.tcs;
 			this.tcs = null;
@@ -95,13 +90,11 @@ namespace ETModel
 		
 		private void AllowGet()
 		{
-			if (this.tcs == null || this.WaitingTasks.Count <= 0 || this.RunningTasks.Count >= this.WindowSize)
+			if (this.tcs == null || this.WaitingTasks.Count <= 0)
 			{
 				return;
 			}
-			
-			ActorTask task = this.WaitingTasks.Dequeue();
-			this.RunningTasks.Enqueue(task);
+			ActorTask task = this.WaitingTasks.Peek();
 
 			var t = this.tcs;
 			this.tcs = null;
@@ -112,8 +105,7 @@ namespace ETModel
 		{
 			if (this.WaitingTasks.Count > 0)
 			{
-				ActorTask task = this.WaitingTasks.Dequeue();
-				this.RunningTasks.Enqueue(task);
+				ActorTask task = this.WaitingTasks.Peek();
 				return Task.FromResult(task);
 			}
 			
@@ -132,51 +124,38 @@ namespace ETModel
 				}
 				try
 				{
-					this.RunTask(actorTask);
+					await this.RunTask(actorTask);
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 					return;
 				}
 			}
 		}
 
-		private async void RunTask(ActorTask task)
+		private async Task RunTask(ActorTask task)
 		{
 			try
 			{
 				IResponse response = await task.Run();
 
-				// 如果没找到Actor,发送窗口减少为1,重试
+				// 如果没找到Actor,重试
 				if (response.Error == ErrorCode.ERR_NotFoundActor)
 				{
 					this.CancellationTokenSource.Cancel();
-					this.WindowSize = 1;
 					++this.failTimes;
-
-					while (this.WaitingTasks.Count > 0)
-					{
-						ActorTask actorTask = this.WaitingTasks.Dequeue();
-						this.RunningTasks.Enqueue(actorTask);
-					}
-					ObjectHelper.Swap(ref this.RunningTasks, ref this.WaitingTasks);
 					
-					// 失败3次则清空actor发送队列,返回失败
-					if (this.failTimes > 3)
+					// 失败10次则清空actor发送队列,返回失败
+					if (this.failTimes > 10)
 					{
-						while (this.WaitingTasks.Count > 0)
-						{
-							ActorTask actorTask = this.WaitingTasks.Dequeue();
-							actorTask.RunFail(response.Error);
-						}
-
 						// 失败直接删除actorproxy
+						Log.Info($"actor send message fail, actorid: {this.Id}");
 						Game.Scene.GetComponent<ActorProxyComponent>().Remove(this.Id);
 						return;
 					}
-					// 等待一会再发送
-					await Game.Scene.GetComponent<TimerComponent>().WaitAsync(this.failTimes * 500);
+					// 等待1s再发送
+					await Game.Scene.GetComponent<TimerComponent>().WaitAsync(1000);
 					int appId = await Game.Scene.GetComponent<LocationProxyComponent>().Get(this.Id);
 					this.Address = Game.Scene.GetComponent<StartConfigComponent>().Get(appId).GetComponent<InnerConfig>().IPEndPoint;
 					this.CancellationTokenSource = new CancellationTokenSource();
@@ -187,17 +166,12 @@ namespace ETModel
 				// 发送成功
 				this.LastSendTime = TimeHelper.Now();
 				this.failTimes = 0;
-				if (this.WindowSize < MaxWindowSize)
-				{
-					++this.WindowSize;
-				}
 
-				this.RunningTasks.Dequeue();
-				this.AllowGet();
+				this.WaitingTasks.Dequeue();
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 

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

@@ -31,35 +31,35 @@ namespace ETModel
 			}
 		}
 
-		public Task<bool> Add(Component disposer, string collectionName = "")
+		public Task<bool> Add(Component component, string collectionName = "")
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
 
-			this.AddToCache(disposer, collectionName);
+			this.AddToCache(component, collectionName);
 
 			if (string.IsNullOrEmpty(collectionName))
 			{
-				collectionName = disposer.GetType().Name;
+				collectionName = component.GetType().Name;
 			}
-			DBSaveTask task = ComponentFactory.CreateWithId<DBSaveTask, Component, string, TaskCompletionSource<bool>>(disposer.Id, disposer, collectionName, tcs);
+			DBSaveTask task = ComponentFactory.CreateWithId<DBSaveTask, Component, string, TaskCompletionSource<bool>>(component.Id, component, collectionName, tcs);
 			this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
 
 			return tcs.Task;
 		}
 
-		public Task<bool> AddBatch(List<Component> disposers, string collectionName)
+		public Task<bool> AddBatch(List<Component> components, string collectionName)
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
-			DBSaveBatchTask task = ComponentFactory.Create<DBSaveBatchTask, List<Component>, string, TaskCompletionSource<bool>>(disposers, collectionName, tcs);
+			DBSaveBatchTask task = ComponentFactory.Create<DBSaveBatchTask, List<Component>, string, TaskCompletionSource<bool>>(components, collectionName, tcs);
 			this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
 			return tcs.Task;
 		}
 
-		public void AddToCache(Component disposer, string collectionName = "")
+		public void AddToCache(Component component, string collectionName = "")
 		{
 			if (string.IsNullOrEmpty(collectionName))
 			{
-				collectionName = disposer.GetType().Name;
+				collectionName = component.GetType().Name;
 			}
 			Dictionary<long, Component> collection;
 			if (!this.cache.TryGetValue(collectionName, out collection))
@@ -67,7 +67,7 @@ namespace ETModel
 				collection = new Dictionary<long, Component>();
 				this.cache.Add(collectionName, collection);
 			}
-			collection[disposer.Id] = disposer;
+			collection[component.Id] = component;
 		}
 
 		public Component GetFromCache(string collectionName, long id)
@@ -97,10 +97,10 @@ namespace ETModel
 
 		public Task<Component> Get(string collectionName, long id)
 		{
-			Component disposer = GetFromCache(collectionName, id);
-			if (disposer != null)
+			Component component = GetFromCache(collectionName, id);
+			if (component != null)
 			{
-				return Task.FromResult(disposer);
+				return Task.FromResult(component);
 			}
 
 			TaskCompletionSource<Component> tcs = new TaskCompletionSource<Component>();
@@ -112,22 +112,22 @@ namespace ETModel
 
 		public Task<List<Component>> GetBatch(string collectionName, List<long> idList)
 		{
-			List <Component> disposers = new List<Component>();
+			List <Component> components = new List<Component>();
 			bool isAllInCache = true;
 			foreach (long id in idList)
 			{
-				Component disposer = this.GetFromCache(collectionName, id);
-				if (disposer == null)
+				Component component = this.GetFromCache(collectionName, id);
+				if (component == null)
 				{
 					isAllInCache = false;
 					break;
 				}
-				disposers.Add(disposer);
+				components.Add(component);
 			}
 
 			if (isAllInCache)
 			{
-				return Task.FromResult(disposers);
+				return Task.FromResult(components);
 			}
 
 			TaskCompletionSource<List<Component>> tcs = new TaskCompletionSource<List<Component>>();

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

@@ -27,35 +27,35 @@ namespace ETModel
 			dbAddress = dbStartConfig.GetComponent<InnerConfig>().IPEndPoint;
 		}
 
-		public async Task Save(Component disposer, bool needCache = true)
+		public async Task Save(Component component, bool needCache = true)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
-			await session.Call(new DBSaveRequest { Disposer = disposer, NeedCache = needCache});
+			await session.Call(new DBSaveRequest { Component = component, NeedCache = needCache});
 		}
 
-		public async Task SaveBatch(List<Component> disposers, bool needCache = true)
+		public async Task SaveBatch(List<Component> components, bool needCache = true)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
-			await session.Call(new DBSaveBatchRequest { Disposers = disposers, NeedCache = needCache});
+			await session.Call(new DBSaveBatchRequest { Components = components, NeedCache = needCache});
 		}
 
-		public async Task Save(Component disposer, bool needCache, CancellationToken cancellationToken)
+		public async Task Save(Component component, bool needCache, CancellationToken cancellationToken)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
-			await session.Call(new DBSaveRequest { Disposer = disposer, NeedCache = needCache}, cancellationToken);
+			await session.Call(new DBSaveRequest { Component = component, NeedCache = needCache}, cancellationToken);
 		}
 
-		public async void SaveLog(Component disposer)
+		public async void SaveLog(Component component)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
-			await session.Call(new DBSaveRequest { Disposer = disposer,  NeedCache = false, CollectionName = "Log" });
+			await session.Call(new DBSaveRequest { Component = component,  NeedCache = false, CollectionName = "Log" });
 		}
 
 		public async Task<T> Query<T>(long id, bool needCache = true) where T: Component
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			DBQueryResponse dbQueryResponse = (DBQueryResponse)await session.Call(new DBQueryRequest { CollectionName = typeof(T).Name, Id = id, NeedCache = needCache });
-			return (T)dbQueryResponse.Disposer;
+			return (T)dbQueryResponse.Component;
 		}
 
 		public async Task<List<T>> QueryBatch<T>(List<long> ids, bool needCache = true) where T : Component
@@ -63,9 +63,9 @@ namespace ETModel
 			List<T> list = new List<T>();
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			DBQueryBatchResponse dbQueryBatchResponse = (DBQueryBatchResponse)await session.Call(new DBQueryBatchRequest { CollectionName = typeof(T).Name, IdList = ids, NeedCache = needCache});
-			foreach (Component disposer in dbQueryBatchResponse.Disposers)
+			foreach (Component component in dbQueryBatchResponse.Components)
 			{
-				list.Add((T)disposer);
+				list.Add((T)component);
 			}
 			return list;
 		}
@@ -75,9 +75,9 @@ namespace ETModel
 			List<T> list = new List<T>();
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			DBQueryJsonResponse dbQueryJsonResponse = (DBQueryJsonResponse)await session.Call(new DBQueryJsonRequest { CollectionName = typeof(T).Name, Json = json, NeedCache = needCache});
-			foreach (Component disposer in dbQueryJsonResponse.Disposers)
+			foreach (Component component in dbQueryJsonResponse.Components)
 			{
-				list.Add((T)disposer);
+				list.Add((T)component);
 			}
 			return list;
 		}

+ 6 - 6
Server/Model/Module/DB/DBQueryBatchTask.cs

@@ -36,18 +36,18 @@ namespace ETModel
 				// 执行查询数据库任务
 				foreach (long id in IdList)
 				{
-					Component disposer = dbCacheComponent.GetFromCache(this.CollectionName, id);
-					if (disposer == null)
+					Component component = dbCacheComponent.GetFromCache(this.CollectionName, id);
+					if (component == null)
 					{
-						disposer = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id).Result.FirstOrDefaultAsync();
-						dbCacheComponent.AddToCache(disposer);
+						component = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id).Result.FirstOrDefaultAsync();
+						dbCacheComponent.AddToCache(component);
 					}
 					
-					if (disposer == null)
+					if (component == null)
 					{
 						continue;
 					}
-					result.Add(disposer);
+					result.Add(component);
 				}
 				
 				this.Tcs.SetResult(result);

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

@@ -31,8 +31,8 @@ namespace ETModel
 			{
 				// 执行查询数据库任务
 				FilterDefinition<Component> filterDefinition = new JsonFilterDefinition<Component>(this.Json);
-				List<Component> disposers = await dbComponent.GetCollection(this.CollectionName).FindAsync(filterDefinition).Result.ToListAsync();
-				this.Tcs.SetResult(disposers);
+				List<Component> components = await dbComponent.GetCollection(this.CollectionName).FindAsync(filterDefinition).Result.ToListAsync();
+				this.Tcs.SetResult(components);
 			}
 			catch (Exception e)
 			{

+ 7 - 7
Server/Model/Module/DB/DBQueryTask.cs

@@ -25,21 +25,21 @@ namespace ETModel
 			DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
 			DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
 			// 执行查询前先看看cache中是否已经存在
-			Component disposer = dbCacheComponent.GetFromCache(this.CollectionName, this.Id);
-			if (disposer != null)
+			Component component = dbCacheComponent.GetFromCache(this.CollectionName, this.Id);
+			if (component != null)
 			{
-				this.Tcs.SetResult(disposer);
+				this.Tcs.SetResult(component);
 				return;
 			}
 			try
 			{
 				// 执行查询数据库任务
-				disposer = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == this.Id).Result.FirstOrDefaultAsync();
-				if (disposer != null)
+				component = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == this.Id).Result.FirstOrDefaultAsync();
+				if (component != null)
 				{
-					dbCacheComponent.AddToCache(disposer);
+					dbCacheComponent.AddToCache(component);
 				}
-				this.Tcs.SetResult(disposer);
+				this.Tcs.SetResult(component);
 			}
 			catch (Exception e)
 			{

+ 8 - 8
Server/Model/Module/DB/DBSaveBatchTask.cs

@@ -9,9 +9,9 @@ namespace ETModel
 	[ObjectSystem]
 	public class DbSaveBatchTaskSystem : AwakeSystem<DBSaveBatchTask, List<Component>, string, TaskCompletionSource<bool>>
 	{
-		public override void Awake(DBSaveBatchTask self, List<Component> disposers, string collectionName, TaskCompletionSource<bool> tcs)
+		public override void Awake(DBSaveBatchTask self, List<Component> components, string collectionName, TaskCompletionSource<bool> tcs)
 		{
-			self.Disposers = disposers;
+			self.Components = components;
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;
 		}
@@ -21,7 +21,7 @@ namespace ETModel
 	{
 		public string CollectionName { get; set; }
 
-		public List<Component> Disposers;
+		public List<Component> Components;
 
 		public TaskCompletionSource<bool> Tcs;
 	
@@ -29,9 +29,9 @@ namespace ETModel
 		{
 			DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
 
-			foreach (Component disposer in this.Disposers)
+			foreach (Component component in this.Components)
 			{
-				if (disposer == null)
+				if (component == null)
 				{
 					continue;
 				}
@@ -39,12 +39,12 @@ namespace ETModel
 				try
 				{
 					// 执行保存数据库任务
-					await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == disposer.Id, disposer, new UpdateOptions { IsUpsert = true });
+					await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == component.Id, component, new UpdateOptions { IsUpsert = true });
 				}
 				catch (Exception e)
 				{
-					Log.Debug($"{disposer.GetType().Name} {disposer.ToJson()} {e}");
-					this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {this.Disposers.ListToString()}", e));
+					Log.Debug($"{component.GetType().Name} {component.ToJson()} {e}");
+					this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {this.Components.ListToString()}", e));
 				}
 			}
 			this.Tcs.SetResult(true);

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

@@ -10,7 +10,7 @@ namespace ETModel
 	{
 		public override void Awake(DBSaveTask self, Component entity, string collectionName, TaskCompletionSource<bool> tcs)
 		{
-			self.Disposer = entity;
+			self.Component = entity;
 			self.CollectionName = collectionName;
 			self.Tcs = tcs;
 		}
@@ -18,7 +18,7 @@ namespace ETModel
 
 	public sealed class DBSaveTask : DBTask
 	{
-		public Component Disposer;
+		public Component Component;
 
 		public string CollectionName { get; set; }
 
@@ -31,7 +31,7 @@ namespace ETModel
 			try
 			{
 				// 执行保存数据库任务
-				await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == this.Disposer.Id, this.Disposer, new UpdateOptions {IsUpsert = true});
+				await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == this.Component.Id, this.Component, new UpdateOptions {IsUpsert = true});
 				this.Tcs.SetResult(true);
 			}
 			catch (Exception e)

+ 1 - 1
Server/Model/Module/DB/DBTaskQueue.cs

@@ -35,7 +35,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 1 - 1
Server/Model/Module/Message/AMRpcHandler.cs

@@ -6,7 +6,7 @@ namespace ETModel
 	{
 		protected static void ReplyError(Response response, Exception e, Action<Response> reply)
 		{
-			Log.Error(e.ToString());
+			Log.Error(e);
 			response.Error = ErrorCode.ERR_RpcFail;
 			response.Message = e.ToString();
 			reply(response);

+ 5 - 5
Server/Model/Module/Message/InnerMessage.cs

@@ -132,7 +132,7 @@ namespace ETModel
 		public string CollectionName;
 
 		[ProtoMember(3, IsRequired = true)]
-		public Component Disposer;
+		public Component Component;
 
 	}
 
@@ -165,7 +165,7 @@ namespace ETModel
 		public string CollectionName;
 
 		[ProtoMember(3)]
-		public List<Component> Disposers = new List<Component>();
+		public List<Component> Components = new List<Component>();
 
 	}
 
@@ -216,7 +216,7 @@ namespace ETModel
 		public string Message { get; set; }
 
 		[ProtoMember(1, IsRequired = true)]
-		public Component Disposer;
+		public Component Component;
 
 	}
 
@@ -252,7 +252,7 @@ namespace ETModel
 		public string Message { get; set; }
 
 		[ProtoMember(1)]
-		public List<Component> Disposers = new List<Component>();
+		public List<Component> Components = new List<Component>();
 
 	}
 
@@ -288,7 +288,7 @@ namespace ETModel
 		public string Message { get; set; }
 
 		[ProtoMember(1)]
-		public List<Component> Disposers = new List<Component>();
+		public List<Component> Components = new List<Component>();
 
 	}
 

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

@@ -43,7 +43,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Base\MultiMap.cs" Link="Base\MultiMap.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Component.cs" Link="Base\Object\Component.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ComponentFactory.cs" Link="Base\Object\ComponentFactory.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Disposer.cs" Link="Base\Object\Disposer.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Entity.cs" Link="Base\Object\Entity.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\EventSystem.cs" Link="Base\Object\EventSystem.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IAwake.cs" Link="Base\Object\IAwake.cs" />

+ 1 - 1
Unity/Assets/Editor/ExcelExporterEditor/ExcelExporterEditor.cs

@@ -82,7 +82,7 @@ public class ExcelExporterEditor : EditorWindow
 		}
 		catch (Exception e)
 		{
-			Log.Error(e.ToString());
+			Log.Error(e);
 		}
 	}
 

+ 59 - 4
Unity/Assets/Scripts/Base/Object/Component.cs

@@ -1,10 +1,46 @@
-using MongoDB.Bson.Serialization.Attributes;
+using System;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace ETModel
 {
 	[BsonIgnoreExtraElements]
-	public abstract partial class Component: Disposer
+	public abstract partial class Component : Object, IDisposable
 	{
+		[BsonIgnore]
+		public long InstanceId { get; private set; }
+
+		[BsonIgnore]
+		private bool isFromPool;
+
+		[BsonIgnore]
+		public bool IsFromPool
+		{
+			get
+			{
+				return this.isFromPool;
+			}
+			set
+			{
+				this.isFromPool = value;
+
+				if (this.InstanceId == 0)
+				{
+					this.InstanceId = IdGenerater.GenerateId();
+					Game.EventSystem.Add(this);
+				}
+			}
+		}
+
+		[BsonIgnore]
+		public bool IsDisposed
+		{
+			get
+			{
+				return this.InstanceId == 0;
+			}
+		}
+
+
 		[BsonIgnoreIfDefault]
 		[BsonDefaultValue(0L)]
 		[BsonElement]
@@ -28,14 +64,33 @@ namespace ETModel
 			}
 		}
 
-		public override void Dispose()
+		protected Component()
+		{
+			this.InstanceId = IdGenerater.GenerateId();
+			Game.EventSystem.Add(this);
+		}
+
+		protected Component(long instanceId)
+		{
+			this.InstanceId = instanceId;
+			Game.EventSystem.Add(this);
+		}
+
+		public virtual void Dispose()
 		{
 			if (this.IsDisposed)
 			{
 				return;
 			}
 
-			base.Dispose();
+			Game.EventSystem.Remove(this.InstanceId);
+
+			this.InstanceId = 0;
+
+			if (this.IsFromPool)
+			{
+				Game.ObjectPool.Recycle(this);
+			}
 		}
 	}
 }

+ 48 - 48
Unity/Assets/Scripts/Base/Object/ComponentFactory.cs

@@ -6,102 +6,102 @@ namespace ETModel
 	{
 		public static Component CreateWithParent(Type type, Component parent)
 		{
-			Component disposer = (Component)Game.ObjectPool.Fetch(type);
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			Component component = (Component)Game.ObjectPool.Fetch(type);
+			component.Parent = parent;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithParent<T>(Component parent) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A>(Component parent, A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A, B>(Component parent, A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A, B, C>(Component parent, A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 
 		public static T Create<T>() where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T Create<T, A>(A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T Create<T, A, B>(A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T Create<T, A, B, C>(A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 
 		public static T CreateWithId<T>(long id) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithId<T, A>(long id, A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T CreateWithId<T, A, B>(long id, A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 	}
 }

+ 0 - 30
Unity/Assets/Scripts/Base/Object/Disposer.cs

@@ -1,30 +0,0 @@
-using System;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace ETModel
-{
-	[BsonKnownTypes(typeof(Component))]
-	public abstract class Disposer : Object, IDisposable
-	{
-		[BsonIgnore]
-		public bool IsFromPool { get; set; }
-
-		[BsonIgnore]
-		public bool IsDisposed { get; set; }
-	
-		public virtual void Dispose()
-		{
-			if (this.IsDisposed)
-			{
-				return;
-			}
-
-			this.IsDisposed = true;
-
-			if (this.IsFromPool)
-			{
-				Game.ObjectPool.Recycle(this);
-			}
-		}
-	}
-}

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

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

+ 3 - 3
Unity/Assets/Scripts/Base/Object/Entity.cs

@@ -17,7 +17,7 @@ namespace ETModel
 
 		protected Entity()
 		{
-			this.Id = IdGenerater.GenerateId();
+			this.Id = this.InstanceId;
 			this.components = new HashSet<Component>();
 			this.componentDict = new Dictionary<Type, Component>();
 		}
@@ -46,7 +46,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 
@@ -215,7 +215,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 	}

+ 76 - 74
Unity/Assets/Scripts/Base/Object/EventSystem.cs

@@ -14,6 +14,8 @@ namespace ETModel
 
 	public sealed class EventSystem
 	{
+		private readonly Dictionary<long, Component> allComponents = new Dictionary<long, Component>();
+
 		private readonly Dictionary<DLLType, Assembly> assemblies = new Dictionary<DLLType, Assembly>();
 
 		private readonly Dictionary<string, List<IEvent>> allEvents = new Dictionary<string, List<IEvent>>();
@@ -28,18 +30,16 @@ namespace ETModel
 
 		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
 
-		private Queue<Component> updates = new Queue<Component>();
-		private Queue<Component> updates2 = new Queue<Component>();
+		private Queue<long> updates = new Queue<long>();
+		private Queue<long> updates2 = new Queue<long>();
 		
-		private readonly Queue<Component> starts = new Queue<Component>();
-
-		private Queue<Component> loaders = new Queue<Component>();
-		private Queue<Component> loaders2 = new Queue<Component>();
+		private readonly Queue<long> starts = new Queue<long>();
 
-		private Queue<Component> lateUpdates = new Queue<Component>();
-		private Queue<Component> lateUpdates2 = new Queue<Component>();
+		private Queue<long> loaders = new Queue<long>();
+		private Queue<long> loaders2 = new Queue<long>();
 
-		private readonly HashSet<Component> unique = new HashSet<Component>();
+		private Queue<long> lateUpdates = new Queue<long>();
+		private Queue<long> lateUpdates2 = new Queue<long>();
 
 		public void Add(DLLType dllType, Assembly assembly)
 		{
@@ -134,36 +134,48 @@ namespace ETModel
 			return this.assemblies.Values.ToArray();
 		}
 
-		public void Add(Component disposer)
+		public void Add(Component component)
 		{
-			Type type = disposer.GetType();
+			this.allComponents.Add(component.InstanceId, component);
+
+			Type type = component.GetType();
 
 			if (this.loadEvents.ContainsKey(type))
 			{
-				this.loaders.Enqueue(disposer);
+				this.loaders.Enqueue(component.InstanceId);
 			}
 
 			if (this.updateEvents.ContainsKey(type))
 			{
-				this.updates.Enqueue(disposer);
+				this.updates.Enqueue(component.InstanceId);
 			}
 
 			if (this.startEvents.ContainsKey(type))
 			{
-				this.starts.Enqueue(disposer);
+				this.starts.Enqueue(component.InstanceId);
 			}
 
 			if (this.lateUpdateEvents.ContainsKey(type))
 			{
-				this.lateUpdates.Enqueue(disposer);
+				this.lateUpdates.Enqueue(component.InstanceId);
 			}
 		}
 
-		public void Awake(Component disposer)
+		public void Remove(long instanceId)
 		{
-			this.Add(disposer);
+			this.allComponents.Remove(instanceId);
+		}
 
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+		public Component Get(long instanceId)
+		{
+			Component component = null;
+			this.allComponents.TryGetValue(instanceId, out component);
+			return component;
+		}
+
+		public void Awake(Component component)
+		{
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -181,15 +193,13 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(disposer);
+				iAwake.Run(component);
 			}
 		}
 
-		public void Awake<P1>(Component disposer, P1 p1)
+		public void Awake<P1>(Component component, P1 p1)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -207,15 +217,13 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1);
+				iAwake.Run(component, p1);
 			}
 		}
 
-		public void Awake<P1, P2>(Component disposer, P1 p1, P2 p2)
+		public void Awake<P1, P2>(Component component, P1 p1, P2 p2)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -233,15 +241,13 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1, p2);
+				iAwake.Run(component, p1, p2);
 			}
 		}
 
-		public void Awake<P1, P2, P3>(Component disposer, P1 p1, P2 p2, P3 p3)
+		public void Awake<P1, P2, P3>(Component component, P1 p1, P2 p2, P3 p3)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -259,43 +265,42 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1, p2, p3);
+				iAwake.Run(component, p1, p2, p3);
 			}
 		}
 
 		public void Load()
 		{
-			unique.Clear();
 			while (this.loaders.Count > 0)
 			{
-				Component disposer = this.loaders.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.loaders.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
-
-				List<ALoadSystem> aLoadSystems = this.loadEvents[disposer.GetType()];
+				
+				List<ALoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
 				if (aLoadSystems == null)
 				{
 					continue;
 				}
 
-				this.loaders2.Enqueue(disposer);
+				this.loaders2.Enqueue(instanceId);
 
 				foreach (ALoadSystem aLoadSystem in aLoadSystems)
 				{
 					try
 					{
-						aLoadSystem.Run(disposer);
+						aLoadSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -305,17 +310,16 @@ namespace ETModel
 
 		private void Start()
 		{
-			unique.Clear();
 			while (this.starts.Count > 0)
 			{
-				Component disposer = this.starts.Dequeue();
-
-				if (!this.unique.Add(disposer))
+				long instanceId = this.starts.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
 
-				List<AStartSystem> aStartSystems = this.startEvents[disposer.GetType()];
+				List<AStartSystem> aStartSystems = this.startEvents[component.GetType()];
 				if (aStartSystems == null)
 				{
 					continue;
@@ -325,11 +329,11 @@ namespace ETModel
 				{
 					try
 					{
-						aStartSystem.Run(disposer);
+						aStartSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -338,38 +342,37 @@ namespace ETModel
 		public void Update()
 		{
 			this.Start();
-
-			this.unique.Clear();
+			
 			while (this.updates.Count > 0)
 			{
-				Component disposer = this.updates.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.updates.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
 				
-				List<AUpdateSystem> aUpdateSystems = this.updateEvents[disposer.GetType()];
+				List<AUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
 				if (aUpdateSystems == null)
 				{
 					continue;
 				}
 
-				this.updates2.Enqueue(disposer);
+				this.updates2.Enqueue(instanceId);
 
 				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
 					try
 					{
-						aUpdateSystem.Run(disposer);
+						aUpdateSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -379,37 +382,36 @@ namespace ETModel
 
 		public void LateUpdate()
 		{
-			this.unique.Clear();
 			while (this.lateUpdates.Count > 0)
 			{
-				Component disposer = this.lateUpdates.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.lateUpdates.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
 
-				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[disposer.GetType()];
+				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
 				if (aLateUpdateSystems == null)
 				{
 					continue;
 				}
 
-				this.lateUpdates2.Enqueue(disposer);
+				this.lateUpdates2.Enqueue(instanceId);
 
 				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
 					try
 					{
-						aLateUpdateSystem.Run(disposer);
+						aLateUpdateSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -432,7 +434,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -452,7 +454,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -472,7 +474,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -492,7 +494,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 10 - 11
Unity/Assets/Scripts/Base/Object/ObjectPool.cs

@@ -5,42 +5,41 @@ namespace ETModel
 {
     public class ObjectPool
     {
-        private readonly Dictionary<Type, Queue<Disposer>> dictionary = new Dictionary<Type, Queue<Disposer>>();
+        private readonly Dictionary<Type, Queue<Component>> dictionary = new Dictionary<Type, Queue<Component>>();
 
-        public Disposer Fetch(Type type)
+        public Component Fetch(Type type)
         {
-	        Queue<Disposer> queue;
+	        Queue<Component> queue;
             if (!this.dictionary.TryGetValue(type, out queue))
             {
-                queue = new Queue<Disposer>();
+                queue = new Queue<Component>();
                 this.dictionary.Add(type, queue);
             }
-	        Disposer obj;
+	        Component obj;
 			if (queue.Count > 0)
             {
 				obj = queue.Dequeue();
-	            obj.IsDisposed = false;
 	            obj.IsFromPool = true;
 				return obj;
             }
-	        obj = (Disposer)Activator.CreateInstance(type);
+	        obj = (Component)Activator.CreateInstance(type);
             return obj;
         }
 
-        public T Fetch<T>() where T: Disposer
+        public T Fetch<T>() where T: Component
 		{
             T t = (T) this.Fetch(typeof(T));
 			t.IsFromPool = true;
 			return t;
 		}
         
-        public void Recycle(Disposer obj)
+        public void Recycle(Component obj)
         {
             Type type = obj.GetType();
-	        Queue<Disposer> queue;
+	        Queue<Component> queue;
             if (!this.dictionary.TryGetValue(type, out queue))
             {
-                queue = new Queue<Disposer>();
+                queue = new Queue<Component>();
 				this.dictionary.Add(type, queue);
             }
             queue.Enqueue(obj);

+ 1 - 1
Unity/Assets/Scripts/Helper/BundleHelper.cs

@@ -28,7 +28,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 
 			}

+ 1 - 1
Unity/Assets/Scripts/Init.cs

@@ -49,7 +49,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 

+ 1 - 1
Unity/Assets/Scripts/Module/AssetsBundle/ResourcesComponent.cs

@@ -11,7 +11,7 @@ using UnityEditor;
 
 namespace ETModel
 {
-	public class ABInfo : Disposer
+	public class ABInfo : Component
 	{
 		private int refCount;
 		public string Name { get; }

+ 1 - 1
Unity/Assets/Scripts/Module/Message/MessageDispatherComponent.cs

@@ -91,7 +91,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 1 - 1
Unity/Assets/Scripts/Module/Message/Network/KCP/KService.cs

@@ -86,7 +86,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 					continue;
 				}
 

+ 2 - 2
Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs

@@ -171,7 +171,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 				this.OnError(SocketError.SocketError);
 			}
 		}
@@ -225,7 +225,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 				this.OnError(SocketError.SocketError);
 			}
 		}

+ 1 - 1
Unity/Assets/Scripts/Module/Message/NetworkComponent.cs

@@ -114,7 +114,7 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 				return null;
 			}
 		}

+ 3 - 2
Unity/Assets/Scripts/Module/Message/Session.cs

@@ -110,7 +110,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 					continue;
 				}
 				
@@ -120,7 +120,7 @@ namespace ETModel
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -155,6 +155,7 @@ namespace ETModel
 			OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent<OpcodeTypeComponent>();
 			Type responseType = opcodeTypeComponent.GetType(opcode);
 			object message = this.Network.MessagePacker.DeserializeFrom(responseType, packet.Bytes, Packet.Index, packet.Length - Packet.Index);
+			//Log.Debug($"recv: {JsonHelper.ToJson(message)}");
 
 			IResponse response = message as IResponse;
 			if (response == null)

+ 1 - 1
Unity/Assets/Scripts/UI/UILoading/Factory/UILoadingFactory.cs

@@ -20,7 +20,7 @@ namespace ETModel
 	        }
 	        catch (Exception e)
 	        {
-				Log.Error(e.ToString());
+				Log.Error(e);
 		        return null;
 	        }
 		}

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

@@ -91,7 +91,6 @@ namespace ILRuntime.Runtime.Generated
             ETModel_CanvasConfig_Binding.Register(app);
             UnityEngine_Transform_Binding.Register(app);
             System_Collections_Generic_List_1_String_Binding.Register(app);
-            ETModel_Disposer_Binding.Register(app);
             ETModel_Scene_Binding.Register(app);
             UnityEngine_Object_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_String_ILTypeInstance_Binding_ValueCollection_Binding.Register(app);

+ 0 - 31
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Disposer_Binding.cs

@@ -15,37 +15,6 @@ namespace ILRuntime.Runtime.Generated
 {
     unsafe class ETModel_Disposer_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(ETModel.Disposer);
-            args = new Type[]{};
-            method = type.GetMethod("Dispose", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Dispose_0);
-
-
-        }
-
-
-        static StackObject* Dispose_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);
-            ETModel.Disposer instance_of_this_method;
-            instance_of_this_method = (ETModel.Disposer)typeof(ETModel.Disposer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            instance_of_this_method.Dispose();
-
-            return __ret;
-        }
-
-
 
     }
 }

+ 66 - 5
Unity/Hotfix/Base/Object/Component.cs

@@ -1,9 +1,50 @@
-using MongoDB.Bson.Serialization.Attributes;
+using System;
+using ETModel;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace ETHotfix
 {
-	public abstract class Component : Disposer
+	[BsonIgnoreExtraElements]
+	public abstract partial class Component : Object, IDisposable2
 	{
+		[BsonIgnore]
+		public long InstanceId { get; private set; }
+
+		[BsonIgnore]
+		private bool isFromPool;
+
+		[BsonIgnore]
+		public bool IsFromPool
+		{
+			get
+			{
+				return this.isFromPool;
+			}
+			set
+			{
+				this.isFromPool = value;
+				if (this.InstanceId == 0)
+				{
+					this.InstanceId = IdGenerater.GenerateId();
+					Game.EventSystem.Add(this);
+				}
+			}
+		}
+
+		[BsonIgnore]
+		public bool IsDisposed
+		{
+			get
+			{
+				return this.InstanceId == 0;
+			}
+		}
+
+
+		[BsonIgnoreIfDefault]
+		[BsonDefaultValue(0L)]
+		[BsonElement]
+		[BsonId]
 		public long Id { get; set; }
 
 		[BsonIgnore]
@@ -14,6 +55,7 @@ namespace ETHotfix
 			return this.Parent as T;
 		}
 
+		[BsonIgnore]
 		public Entity Entity
 		{
 			get
@@ -21,15 +63,34 @@ namespace ETHotfix
 				return this.Parent as Entity;
 			}
 		}
-		
-		public override void Dispose()
+
+		protected Component()
+		{
+			this.InstanceId = IdGenerater.GenerateId();
+			Game.EventSystem.Add(this);
+		}
+
+		protected Component(long instanceId)
+		{
+			this.InstanceId = instanceId;
+			Game.EventSystem.Add(this);
+		}
+
+		public virtual void Dispose()
 		{
 			if (this.IsDisposed)
 			{
 				return;
 			}
+			
+			Game.EventSystem.Remove(this.InstanceId);
+
+			this.InstanceId = 0;
 
-			base.Dispose();
+			if (this.IsFromPool)
+			{
+				Game.ObjectPool.Recycle(this);
+			}
 		}
 	}
 }

+ 48 - 48
Unity/Hotfix/Base/Object/ComponentFactory.cs

@@ -6,102 +6,102 @@ namespace ETHotfix
 	{
 		public static Component CreateWithParent(Type type, Component parent)
 		{
-			Component disposer = (Component)Game.ObjectPool.Fetch(type);
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			Component component = (Component)Game.ObjectPool.Fetch(type);
+			component.Parent = parent;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithParent<T>(Component parent) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A>(Component parent, A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A, B>(Component parent, A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T CreateWithParent<T, A, B, C>(Component parent, A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = parent;
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Parent = parent;
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 
 		public static T Create<T>() where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T Create<T, A>(A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T Create<T, A, B>(A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T Create<T, A, B, C>(A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 
 		public static T CreateWithId<T>(long id) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component);
+			return component;
 		}
 
 		public static T CreateWithId<T, A>(long id, A a) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a);
+			return component;
 		}
 
 		public static T CreateWithId<T, A, B>(long id, A a, B b) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a, b);
+			return component;
 		}
 
 		public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : Component
 		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
+			T component = Game.ObjectPool.Fetch<T>();
+			component.Id = id;
+			Game.EventSystem.Awake(component, a, b, c);
+			return component;
 		}
 	}
 }

+ 0 - 26
Unity/Hotfix/Base/Object/Disposer.cs

@@ -1,26 +0,0 @@
-using ETModel;
-
-namespace ETHotfix
-{
-	public abstract class Disposer : Object, IDisposable2
-	{
-		public bool IsFromPool { get; set; }
-		
-		public bool IsDisposed { get; set; }
-
-		public virtual void Dispose()
-		{
-			if (this.IsDisposed)
-			{
-				return;
-			}
-
-			this.IsDisposed = true;
-
-			if (this.IsFromPool)
-			{
-				Game.ObjectPool.Recycle(this);
-			}
-		}
-	}
-}

+ 2 - 2
Unity/Hotfix/Base/Object/Entity.cs

@@ -47,7 +47,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 
@@ -216,7 +216,7 @@ namespace ETHotfix
 			}
 			catch (Exception e)
 			{
-				Log.Error(e.ToString());
+				Log.Error(e);
 			}
 		}
 	}

+ 71 - 76
Unity/Hotfix/Base/Object/EventSystem.cs

@@ -6,6 +6,8 @@ namespace ETHotfix
 {
 	public sealed class EventSystem
 	{
+		private readonly Dictionary<long, Component> allComponents = new Dictionary<long, Component>();
+
 		private readonly Dictionary<string, List<IEvent>> allEvents = new Dictionary<string, List<IEvent>>();
 
 		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
@@ -18,18 +20,16 @@ namespace ETHotfix
 
 		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
 
-		private Queue<Component> updates = new Queue<Component>();
-		private Queue<Component> updates2 = new Queue<Component>();
-
-		private readonly Queue<Component> starts = new Queue<Component>();
+		private Queue<long> updates = new Queue<long>();
+		private Queue<long> updates2 = new Queue<long>();
 
-		private Queue<Component> loaders = new Queue<Component>();
-		private Queue<Component> loaders2 = new Queue<Component>();
+		private readonly Queue<long> starts = new Queue<long>();
 
-		private Queue<Component> lateUpdates = new Queue<Component>();
-		private Queue<Component> lateUpdates2 = new Queue<Component>();
+		private Queue<long> loaders = new Queue<long>();
+		private Queue<long> loaders2 = new Queue<long>();
 
-		private readonly HashSet<Component> unique = new HashSet<Component>();
+		private Queue<long> lateUpdates = new Queue<long>();
+		private Queue<long> lateUpdates2 = new Queue<long>();
 
 		public EventSystem()
 		{
@@ -129,36 +129,41 @@ namespace ETHotfix
 			this.allEvents[eventId].Add(e);
 		}
 
-		public void Add(Component disposer)
+		public void Add(Component component)
 		{
-			Type type = disposer.GetType();
+			this.allComponents.Add(component.InstanceId, component);
+
+			Type type = component.GetType();
 
 			if (this.loadEvents.ContainsKey(type))
 			{
-				this.loaders.Enqueue(disposer);
+				this.loaders.Enqueue(component.InstanceId);
 			}
 
 			if (this.updateEvents.ContainsKey(type))
 			{
-				this.updates.Enqueue(disposer);
+				this.updates.Enqueue(component.InstanceId);
 			}
 
 			if (this.startEvents.ContainsKey(type))
 			{
-				this.starts.Enqueue(disposer);
+				this.starts.Enqueue(component.InstanceId);
 			}
 
 			if (this.lateUpdateEvents.ContainsKey(type))
 			{
-				this.lateUpdates.Enqueue(disposer);
+				this.lateUpdates.Enqueue(component.InstanceId);
 			}
 		}
 
-		public void Awake(Component disposer)
+		public void Remove(long instanceId)
 		{
-			this.Add(disposer);
+			this.allComponents.Remove(instanceId);
+		}
 
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+		public void Awake(Component component)
+		{
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -176,15 +181,13 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(disposer);
+				iAwake.Run(component);
 			}
 		}
 
-		public void Awake<P1>(Component disposer, P1 p1)
+		public void Awake<P1>(Component component, P1 p1)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -202,15 +205,13 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1);
+				iAwake.Run(component, p1);
 			}
 		}
 
-		public void Awake<P1, P2>(Component disposer, P1 p1, P2 p2)
+		public void Awake<P1, P2>(Component component, P1 p1, P2 p2)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -228,15 +229,13 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1, p2);
+				iAwake.Run(component, p1, p2);
 			}
 		}
 
-		public void Awake<P1, P2, P3>(Component disposer, P1 p1, P2 p2, P3 p3)
+		public void Awake<P1, P2, P3>(Component component, P1 p1, P2 p2, P3 p3)
 		{
-			this.Add(disposer);
-
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[disposer.GetType()];
+			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
@@ -254,43 +253,42 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(disposer, p1, p2, p3);
+				iAwake.Run(component, p1, p2, p3);
 			}
 		}
 
 		public void Load()
 		{
-			unique.Clear();
 			while (this.loaders.Count > 0)
 			{
-				Component disposer = this.loaders.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.loaders.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
-
-				List<ALoadSystem> aLoadSystems = this.loadEvents[disposer.GetType()];
+				
+				List<ALoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
 				if (aLoadSystems == null)
 				{
 					continue;
 				}
 
-				this.loaders2.Enqueue(disposer);
+				this.loaders2.Enqueue(instanceId);
 
 				foreach (ALoadSystem aLoadSystem in aLoadSystems)
 				{
 					try
 					{
-						aLoadSystem.Run(disposer);
+						aLoadSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -300,17 +298,16 @@ namespace ETHotfix
 
 		private void Start()
 		{
-			unique.Clear();
 			while (this.starts.Count > 0)
 			{
-				Component disposer = this.starts.Dequeue();
-
-				if (!this.unique.Add(disposer))
+				long instanceId = this.starts.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
 
-				List<AStartSystem> aStartSystems = this.startEvents[disposer.GetType()];
+				List<AStartSystem> aStartSystems = this.startEvents[component.GetType()];
 				if (aStartSystems == null)
 				{
 					continue;
@@ -320,11 +317,11 @@ namespace ETHotfix
 				{
 					try
 					{
-						aStartSystem.Run(disposer);
+						aStartSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -333,38 +330,37 @@ namespace ETHotfix
 		public void Update()
 		{
 			this.Start();
-
-			this.unique.Clear();
+			
 			while (this.updates.Count > 0)
 			{
-				Component disposer = this.updates.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.updates.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
-
-				List<AUpdateSystem> aUpdateSystems = this.updateEvents[disposer.GetType()];
+				
+				List<AUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
 				if (aUpdateSystems == null)
 				{
 					continue;
 				}
 
-				this.updates2.Enqueue(disposer);
+				this.updates2.Enqueue(instanceId);
 
 				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
 					try
 					{
-						aUpdateSystem.Run(disposer);
+						aUpdateSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -374,37 +370,36 @@ namespace ETHotfix
 
 		public void LateUpdate()
 		{
-			this.unique.Clear();
 			while (this.lateUpdates.Count > 0)
 			{
-				Component disposer = this.lateUpdates.Dequeue();
-				if (disposer.IsDisposed)
+				long instanceId = this.lateUpdates.Dequeue();
+				Component component;
+				if (!this.allComponents.TryGetValue(instanceId, out component))
 				{
 					continue;
 				}
-
-				if (!this.unique.Add(disposer))
+				if (component.IsDisposed)
 				{
 					continue;
 				}
-
-				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[disposer.GetType()];
+				
+				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
 				if (aLateUpdateSystems == null)
 				{
 					continue;
 				}
 
-				this.lateUpdates2.Enqueue(disposer);
+				this.lateUpdates2.Enqueue(instanceId);
 
 				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
 					try
 					{
-						aLateUpdateSystem.Run(disposer);
+						aLateUpdateSystem.Run(component);
 					}
 					catch (Exception e)
 					{
-						Log.Error(e.ToString());
+						Log.Error(e);
 					}
 				}
 			}
@@ -427,7 +422,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -447,7 +442,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -467,7 +462,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}
@@ -487,7 +482,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 11 - 11
Unity/Hotfix/Base/Object/ObjectPool.cs

@@ -5,41 +5,41 @@ namespace ETHotfix
 {
 	public class ObjectPool
 	{
-		private readonly Dictionary<Type, Queue<Disposer>> dictionary = new Dictionary<Type, Queue<Disposer>>();
+		private readonly Dictionary<Type, Queue<Component>> dictionary = new Dictionary<Type, Queue<Component>>();
 
-		public Disposer Fetch(Type type)
+		public Component Fetch(Type type)
 		{
-			Queue<Disposer> queue;
+			Queue<Component> queue;
 			if (!this.dictionary.TryGetValue(type, out queue))
 			{
-				queue = new Queue<Disposer>();
+				queue = new Queue<Component>();
 				this.dictionary.Add(type, queue);
 			}
-			Disposer obj;
+			Component obj;
 			if (queue.Count > 0)
 			{
 				obj = queue.Dequeue();
-				obj.IsDisposed = false;
 				obj.IsFromPool = true;
 				return obj;
 			}
-			obj = (Disposer)Activator.CreateInstance(type);
+			obj = (Component)Activator.CreateInstance(type);
 			return obj;
 		}
 
-		public T Fetch<T>() where T : Disposer
+		public T Fetch<T>() where T : Component
 		{
 			T t = (T)this.Fetch(typeof(T));
+			t.IsFromPool = true;
 			return t;
 		}
 
-		public void Recycle(Disposer obj)
+		public void Recycle(Component obj)
 		{
 			Type type = obj.GetType();
-			Queue<Disposer> queue;
+			Queue<Component> queue;
 			if (!this.dictionary.TryGetValue(type, out queue))
 			{
-				queue = new Queue<Disposer>();
+				queue = new Queue<Component>();
 				this.dictionary.Add(type, queue);
 			}
 			queue.Enqueue(obj);

+ 1 - 1
Unity/Hotfix/Module/Message/MessageDispatherComponent.cs

@@ -105,7 +105,7 @@ namespace ETHotfix
 				}
 				catch (Exception e)
 				{
-					Log.Error(e.ToString());
+					Log.Error(e);
 				}
 			}
 		}

+ 1 - 1
Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs

@@ -23,7 +23,7 @@ namespace ETHotfix
 	        }
 	        catch (Exception e)
 	        {
-				Log.Error(e.ToString());
+				Log.Error(e);
 		        return null;
 	        }
 		}

+ 1 - 1
Unity/Hotfix/UI/UILogin/Factory/UILoginFactory.cs

@@ -23,7 +23,7 @@ namespace ETHotfix
 	        }
 	        catch (Exception e)
 	        {
-				Log.Error(e.ToString());
+				Log.Error(e);
 		        return null;
 	        }
 		}

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

@@ -75,7 +75,6 @@
     <Compile Include="Module\Message\IMHandler.cs" />
     <Compile Include="Base\Object\Component.cs" />
     <Compile Include="Base\Object\ComponentFactory.cs" />
-    <Compile Include="Base\Object\Disposer.cs" />
     <Compile Include="Base\Object\Entity.cs" />
     <Compile Include="Base\Object\EntityType.cs" />
     <Compile Include="Base\Object\IAwake.cs" />

+ 7 - 5
Unity/Unity.csproj

@@ -12,12 +12,15 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile></TargetFrameworkProfile>
-    <CompilerResponseFile></CompilerResponseFile>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <CompilerResponseFile>
+    </CompilerResponseFile>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows:5</UnityBuildTarget>
     <UnityVersion>2017.1.1p4</UnityVersion>
-    <RootNamespace></RootNamespace>
+    <RootNamespace>
+    </RootNamespace>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
@@ -156,7 +159,6 @@
     <Compile Include="Assets\Scripts\Base\Object\Component.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ComponentAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ComponentFactory.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\Disposer.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Entity.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityEventAttribute.cs" />
@@ -780,4 +782,4 @@
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>