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

把Disposer的Id移动到Component中

tanghai 8 лет назад
Родитель
Сommit
93b10eca97
100 измененных файлов с 427 добавлено и 557 удалено
  1. 1 1
      Server/Hotfix/Handler/C2G_LoginGateHandler.cs
  2. 1 1
      Server/Hotfix/Handler/G2M_CreateUnitHandler.cs
  3. 3 3
      Server/Hotfix/Module/Actor/ActorComponentSystem.cs
  4. 2 2
      Server/Hotfix/Module/DB/DBQueryBatchRequestHandler.cs
  5. 2 2
      Server/Hotfix/Module/DB/DBQueryJsonRequestHandler.cs
  6. 1 1
      Server/Hotfix/Module/DB/DBQueryRequestHandler.cs
  7. 1 1
      Server/Hotfix/Module/DB/DBSaveBatchRequestHandler.cs
  8. 1 1
      Server/Hotfix/Module/Network/InnerMessageDispatcher.cs
  9. 1 1
      Server/Hotfix/System/ServerFrameComponentSystem.cs
  10. 2 2
      Server/Model/Base/Message/AMActorHandler.cs
  11. 1 1
      Server/Model/Base/Message/AMRpcHandler.cs
  12. 2 2
      Server/Model/Base/Object/EventSystem.cs
  13. 1 1
      Server/Model/Component/AppManagerComponent.cs
  14. 1 1
      Server/Model/Component/BenchmarkComponent.cs
  15. 2 2
      Server/Model/Component/HttpComponent.cs
  16. 1 1
      Server/Model/Component/KVComponent.cs
  17. 1 1
      Server/Model/Component/NumericComponent.cs
  18. 1 1
      Server/Model/Component/OpcodeTypeComponent.cs
  19. 1 1
      Server/Model/Component/PlayerComponent.cs
  20. 1 1
      Server/Model/Component/RobotComponent.cs
  21. 1 1
      Server/Model/Component/Session/SessionPlayerComponent.cs
  22. 2 2
      Server/Model/Component/Unit/LockComponent.cs
  23. 1 1
      Server/Model/Component/UnitComponent.cs
  24. 1 1
      Server/Model/Entity/Player.cs
  25. 1 1
      Server/Model/Entity/Scene.cs
  26. 1 1
      Server/Model/Entity/Unit.cs
  27. 5 5
      Server/Model/Message/InnerMessage.cs
  28. 1 1
      Server/Model/Module/Actor/ActorComponent.cs
  29. 1 1
      Server/Model/Module/Actor/ActorManagerComponent.cs
  30. 1 1
      Server/Model/Module/Actor/ActorMessageDispatherComponent.cs
  31. 4 4
      Server/Model/Module/Actor/ActorProxy.cs
  32. 3 3
      Server/Model/Module/Actor/ActorProxyComponent.cs
  33. 25 25
      Server/Model/Module/DB/DBCacheComponent.cs
  34. 2 2
      Server/Model/Module/DB/DBComponent.cs
  35. 9 9
      Server/Model/Module/DB/DBProxyComponent.cs
  36. 5 5
      Server/Model/Module/DB/DBQueryBatchTask.cs
  37. 5 5
      Server/Model/Module/DB/DBQueryJsonTask.cs
  38. 4 4
      Server/Model/Module/DB/DBQueryTask.cs
  39. 4 4
      Server/Model/Module/DB/DBSaveBatchTask.cs
  40. 3 3
      Server/Model/Module/DB/DBSaveTask.cs
  41. 3 2
      Server/Model/Module/DB/DBTask.cs
  42. 2 2
      Server/Model/Module/DB/DBTaskQueue.cs
  43. 1 1
      Server/Model/Module/Location/LocationComponent.cs
  44. 1 1
      Server/Model/Module/Location/LocationProxyComponent.cs
  45. 1 1
      Server/Model/Module/Network/MessageDispatherComponent.cs
  46. 0 1
      Server/Model/Server.Model.csproj
  47. 1 1
      Unity/Assets/Scripts/Base/Message/AMHandler.cs
  48. 7 6
      Unity/Assets/Scripts/Base/Object/Component.cs
  49. 68 8
      Unity/Assets/Scripts/Base/Object/ComponentFactory.cs
  50. 9 16
      Unity/Assets/Scripts/Base/Object/Disposer.cs
  51. 5 5
      Unity/Assets/Scripts/Base/Object/Entity.cs
  52. 0 65
      Unity/Assets/Scripts/Base/Object/EntityFactory.cs
  53. 0 3
      Unity/Assets/Scripts/Base/Object/EntityFactory.cs.meta
  54. 20 20
      Unity/Assets/Scripts/Base/Object/EventSystem.cs
  55. 3 2
      Unity/Assets/Scripts/Base/Object/ObjectPool.cs
  56. 1 1
      Unity/Assets/Scripts/Component/AnimatorComponent.cs
  57. 3 3
      Unity/Assets/Scripts/Component/BundleDownloaderComponent.cs
  58. 1 1
      Unity/Assets/Scripts/Component/ClientFrameComponent.cs
  59. 1 1
      Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
  60. 1 1
      Unity/Assets/Scripts/Component/MoveComponent.cs
  61. 4 4
      Unity/Assets/Scripts/Component/NetworkComponent.cs
  62. 1 1
      Unity/Assets/Scripts/Component/NumericComponent.cs
  63. 1 1
      Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs
  64. 1 1
      Unity/Assets/Scripts/Component/PlayerComponent.cs
  65. 4 4
      Unity/Assets/Scripts/Component/ResourcesComponent.cs
  66. 1 1
      Unity/Assets/Scripts/Component/SceneChangeComponent.cs
  67. 1 1
      Unity/Assets/Scripts/Component/SessionComponent.cs
  68. 1 1
      Unity/Assets/Scripts/Component/UIComponent.cs
  69. 1 1
      Unity/Assets/Scripts/Component/UnitComponent.cs
  70. 2 2
      Unity/Assets/Scripts/Entity/AssetsBundleLoaderAsync.cs
  71. 2 2
      Unity/Assets/Scripts/Entity/AssetsLoaderAsync.cs
  72. 1 1
      Unity/Assets/Scripts/Entity/Player.cs
  73. 1 1
      Unity/Assets/Scripts/Entity/Scene.cs
  74. 6 5
      Unity/Assets/Scripts/Entity/Session.cs
  75. 2 2
      Unity/Assets/Scripts/Entity/UI.cs
  76. 1 1
      Unity/Assets/Scripts/Entity/Unit.cs
  77. 2 2
      Unity/Assets/Scripts/Entity/UnityWebRequestAsync.cs
  78. 1 1
      Unity/Assets/Scripts/Entity/WWWAsync.cs
  79. 1 1
      Unity/Assets/Scripts/Factory/PlayerFactory.cs
  80. 1 1
      Unity/Assets/Scripts/Factory/UnitFactory.cs
  81. 1 1
      Unity/Assets/Scripts/UI/UILoading/Component/UILoadingComponent.cs
  82. 1 1
      Unity/Assets/Scripts/UI/UILoading/Factory/UILoadingFactory.cs
  83. 0 1
      Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs
  84. 0 48
      Unity/Assets/ThirdParty/ILRuntime/Generated/Model_Disposer_Binding.cs
  85. 3 58
      Unity/Assets/ThirdParty/ILRuntime/Generated/Model_EntityFactory_Binding.cs
  86. 5 8
      Unity/Hotfix/Base/Object/Component.cs
  87. 68 8
      Unity/Hotfix/Base/Object/ComponentFactory.cs
  88. 8 12
      Unity/Hotfix/Base/Object/Disposer.cs
  89. 5 5
      Unity/Hotfix/Base/Object/Entity.cs
  90. 0 65
      Unity/Hotfix/Base/Object/EntityFactory.cs
  91. 20 20
      Unity/Hotfix/Base/Object/EventSystem.cs
  92. 36 35
      Unity/Hotfix/Base/Object/ObjectPool.cs
  93. 1 1
      Unity/Hotfix/Entity/Scene.cs
  94. 2 2
      Unity/Hotfix/Entity/UI.cs
  95. 1 1
      Unity/Hotfix/Module/HotfixMessage/MessageDispatherComponent.cs
  96. 1 1
      Unity/Hotfix/Module/HotfixMessage/OpcodeTypeComponent.cs
  97. 1 1
      Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs
  98. 3 5
      Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
  99. 1 1
      Unity/Hotfix/UI/UILogin/Factory/UILoginFactory.cs
  100. 1 2
      Unity/Hotfix/Unity.Hotfix.csproj

+ 1 - 1
Server/Hotfix/Handler/C2G_LoginGateHandler.cs

@@ -19,7 +19,7 @@ namespace Hotfix
 					reply(response);
 					return;
 				}
-				Player player = EntityFactory.Create<Player, string>(account);
+				Player player = ComponentFactory.Create<Player, string>(account);
 				Game.Scene.GetComponent<PlayerComponent>().Add(player);
 				session.AddComponent<SessionPlayerComponent>().Player = player;
 				await session.AddComponent<ActorComponent, IEntityActorHandler>(new GateSessionEntityActorHandler()).AddLocation();

+ 1 - 1
Server/Hotfix/Handler/G2M_CreateUnitHandler.cs

@@ -11,7 +11,7 @@ namespace Hotfix
 			M2G_CreateUnit response = new M2G_CreateUnit();
 			try
 			{
-				Unit unit = EntityFactory.Create<Unit>();
+				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);

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

@@ -33,7 +33,7 @@ namespace Hotfix
 		{
 			self.entityActorHandler = new CommonEntityActorHandler();
 			self.queue = new Queue<ActorMessageInfo>();
-			self.actorId = self.Parent.Id;
+			self.actorId = self.Entity.Id;
 			Game.Scene.GetComponent<ActorManagerComponent>().Add((Entity)self.Parent);
 			self.HandleAsync();
 		}
@@ -42,7 +42,7 @@ namespace Hotfix
 		{
 			self.entityActorHandler = iEntityActorHandler;
 			self.queue = new Queue<ActorMessageInfo>();
-			self.actorId = self.Parent.Id;
+			self.actorId = self.Entity.Id;
 			Game.Scene.GetComponent<ActorManagerComponent>().Add((Entity)self.Parent);
 			self.HandleAsync();
 		}
@@ -92,7 +92,7 @@ namespace Hotfix
 		{
 			while (true)
 			{
-				if (self.Id == 0)
+				if (self.IsDisposed)
 				{
 					return;
 				}

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

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

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

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

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

@@ -12,7 +12,7 @@ namespace Hotfix
 			try
 			{
 				DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
-				Disposer disposer = await dbCacheComponent.Get(message.CollectionName, message.Id);
+				Component disposer = await dbCacheComponent.Get(message.CollectionName, message.Id);
 
 				response.Disposer = disposer;
 

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

@@ -20,7 +20,7 @@ namespace Hotfix
 
 				if (message.NeedCache)
 				{
-					foreach (Disposer disposer in message.Disposers)
+					foreach (Component disposer in message.Disposers)
 					{
 						dbCacheComponent.AddToCache(disposer, message.CollectionName);
 					}

+ 1 - 1
Server/Hotfix/Module/Network/InnerMessageDispatcher.cs

@@ -9,7 +9,6 @@ namespace Hotfix
 		{
 			Type messageType = Game.Scene.GetComponent<OpcodeTypeComponent>().GetType(packetInfo.Opcode);
 			IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(messageType, packetInfo.Bytes, packetInfo.Index, packetInfo.Length);
-
 			// 收到actor rpc request
 			if (message is ActorRequest actorRpcRequest)
 			{
@@ -24,6 +23,7 @@ namespace Hotfix
 					session.Reply(packetInfo.RpcId, response);
 					return;
 				}
+				
 				entity.GetComponent<ActorComponent>().Add(new ActorMessageInfo() { Session = session, RpcId = packetInfo.RpcId, Message = actorRpcRequest });
 				return;
 			}

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

@@ -27,7 +27,7 @@ namespace Hotfix
 
             while (true)
             {
-                if (self.Id == 0)
+                if (self.IsDisposed)
                 {
                     return;
                 }

+ 2 - 2
Server/Model/Base/Message/AMActorHandler.cs

@@ -25,7 +25,7 @@ namespace Model
 			await this.Run(e, msg);
 
 			// 等回调回来,session可以已经断开了,所以需要判断session id是否为0
-			if (session.Id == 0)
+			if (session.IsDisposed)
 			{
 				return;
 			}
@@ -70,7 +70,7 @@ namespace Model
 				await this.Run(e, request, response =>
 				{
 					// 等回调回来,session可以已经断开了,所以需要判断session id是否为0
-					if (session.Id == 0)
+					if (session.IsDisposed)
 					{
 						return;
 					}

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

@@ -26,7 +26,7 @@ namespace Model
 				this.Run(session, request, response =>
 				{
 					// 等回调回来,session可以已经断开了,所以需要判断session id是否为0
-					if (session.Id == 0)
+					if (session.IsDisposed)
 					{
 						return;
 					}

+ 2 - 2
Server/Model/Base/Object/EventSystem.cs

@@ -209,7 +209,7 @@ namespace Model
 			while (this.loaders.Count > 0)
 			{
 				Disposer disposer = this.loaders.Dequeue();
-				if (disposer.Id == 0)
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}
@@ -279,7 +279,7 @@ namespace Model
 			while (this.updates.Count > 0)
 			{
 				Disposer disposer = this.updates.Dequeue();
-				if (disposer.Id == 0)
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}

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

@@ -78,7 +78,7 @@ namespace Model
 			{
 				await Game.Scene.GetComponent<TimerComponent>().WaitAsync(5000);
 
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}

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

@@ -84,7 +84,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 2 - 2
Server/Model/Component/HttpComponent.cs

@@ -98,7 +98,7 @@ namespace Model
 		{
 			while (true)
 			{
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}
@@ -118,7 +118,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -32,7 +32,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -58,7 +58,7 @@ namespace Model
 				}
 
 				NumericDic[numericType] = value;
-				Game.EventSystem.Run(EventIdType.NumbericChange, this.Parent.Id, numericType, value);
+				Game.EventSystem.Run(EventIdType.NumbericChange, this.Entity.Id, numericType, value);
 			}
 		}
 

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

@@ -67,7 +67,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -56,7 +56,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -4,7 +4,7 @@
 	{
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Server/Model/Component/Session/SessionPlayerComponent.cs

@@ -6,7 +6,7 @@
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -83,7 +83,7 @@ namespace Model
 			{
 				Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(this.address);
 				string serverAddress = Game.Scene.GetComponent<StartConfigComponent>().StartConfig.ServerIP;
-				G2G_LockRequest request = new G2G_LockRequest { Id = this.Parent.Id, Address = serverAddress };
+				G2G_LockRequest request = new G2G_LockRequest { Id = this.Entity.Id, Address = serverAddress };
 				await session.Call(request);
 
 				this.status = LockStatus.Locked;
@@ -96,7 +96,7 @@ namespace Model
 			}
 			catch (Exception e)
 			{
-				Log.Error($"获取锁失败: {this.address} {this.Parent.Id} {e}");
+				Log.Error($"获取锁失败: {this.address} {this.Entity.Id} {e}");
 			}
 		}
 

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

@@ -9,7 +9,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -22,7 +22,7 @@
 		
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Server/Model/Entity/Scene.cs

@@ -31,7 +31,7 @@
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -32,7 +32,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -102,7 +102,7 @@ namespace Model
 		public string CollectionName;
 
 		[ProtoMember(3, IsRequired = true)]
-		public Disposer Disposer;
+		public Component Disposer;
 
 	}
 
@@ -128,7 +128,7 @@ namespace Model
 		public string CollectionName;
 
 		[ProtoMember(3)]
-		public List<Disposer> Disposers = new List<Disposer>();
+		public List<Component> Disposers = new List<Component>();
 
 	}
 
@@ -163,7 +163,7 @@ namespace Model
 	public partial class DBQueryResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1, IsRequired = true)]
-		public Disposer Disposer;
+		public Component Disposer;
 
 		[ProtoMember(90, IsRequired = true)]
 		public int Error { get; set; }
@@ -192,7 +192,7 @@ namespace Model
 	public partial class DBQueryBatchResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
-		public List<Disposer> Disposers = new List<Disposer>();
+		public List<Component> Disposers = new List<Component>();
 
 		[ProtoMember(90, IsRequired = true)]
 		public int Error { get; set; }
@@ -221,7 +221,7 @@ namespace Model
 	public partial class DBQueryJsonResponse: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
-		public List<Disposer> Disposers = new List<Disposer>();
+		public List<Component> Disposers = new List<Component>();
 
 		[ProtoMember(90, IsRequired = true)]
 		public int Error { get; set; }

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

@@ -29,7 +29,7 @@ namespace Model
 		{
 			try
 			{
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}

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

@@ -41,7 +41,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -83,7 +83,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 4 - 4
Server/Model/Module/Actor/ActorProxy.cs

@@ -89,7 +89,7 @@ namespace Model
 		}
 	}
 
-	public sealed class ActorProxy : Disposer
+	public sealed class ActorProxy : Component
 	{
 		// actor的地址
 		public IPEndPoint Address;
@@ -127,7 +127,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -153,7 +153,7 @@ namespace Model
 
 		private void Add(ActorTask task)
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				throw new Exception("ActorProxy Disposed! dont hold actorproxy");
 			}
@@ -204,7 +204,7 @@ namespace Model
 			while (true)
 			{
 				ActorTask actorTask = await this.GetAsync();
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}

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

@@ -16,7 +16,7 @@ namespace Model
 			{
 				await Game.Scene.GetComponent<TimerComponent>().WaitAsync(10000);
 
-				if (self.Id == 0)
+				if (self.IsDisposed)
 				{
 					return;
 				}
@@ -54,7 +54,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -73,7 +73,7 @@ namespace Model
 				return actorProxy;
 			}
 			
-			actorProxy = EntityFactory.CreateWithId<ActorProxy>(id);
+			actorProxy = ComponentFactory.CreateWithId<ActorProxy>(id);
 			this.ActorProxys[id] = actorProxy;
 			return actorProxy;
 		}

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

@@ -17,7 +17,7 @@ namespace Model
 	/// </summary>
 	public class DBCacheComponent : Component
 	{
-		public Dictionary<string, Dictionary<long, Disposer>> cache = new Dictionary<string, Dictionary<long, Disposer>>();
+		public Dictionary<string, Dictionary<long, Component>> cache = new Dictionary<string, Dictionary<long, Component>>();
 
 		public const int taskCount = 32;
 		public List<DBTaskQueue> tasks = new List<DBTaskQueue>(taskCount);
@@ -26,12 +26,12 @@ namespace Model
 		{
 			for (int i = 0; i < taskCount; ++i)
 			{
-				DBTaskQueue taskQueue = EntityFactory.Create<DBTaskQueue>();
+				DBTaskQueue taskQueue = ComponentFactory.Create<DBTaskQueue>();
 				this.tasks.Add(taskQueue);
 			}
 		}
 
-		public Task<bool> Add(Disposer disposer, string collectionName = "")
+		public Task<bool> Add(Component disposer, string collectionName = "")
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
 
@@ -41,43 +41,43 @@ namespace Model
 			{
 				collectionName = disposer.GetType().Name;
 			}
-			DBSaveTask task = EntityFactory.CreateWithId<DBSaveTask, Disposer, string, TaskCompletionSource<bool>>(disposer.Id, disposer, collectionName, tcs);
+			DBSaveTask task = ComponentFactory.CreateWithId<DBSaveTask, Component, string, TaskCompletionSource<bool>>(disposer.Id, disposer, collectionName, tcs);
 			this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
 
 			return tcs.Task;
 		}
 
-		public Task<bool> AddBatch(List<Disposer> disposers, string collectionName)
+		public Task<bool> AddBatch(List<Component> disposers, string collectionName)
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
-			DBSaveBatchTask task = EntityFactory.Create<DBSaveBatchTask, List<Disposer>, string, TaskCompletionSource<bool>>(disposers, collectionName, tcs);
+			DBSaveBatchTask task = ComponentFactory.Create<DBSaveBatchTask, List<Component>, string, TaskCompletionSource<bool>>(disposers, collectionName, tcs);
 			this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
 			return tcs.Task;
 		}
 
-		public void AddToCache(Disposer disposer, string collectionName = "")
+		public void AddToCache(Component disposer, string collectionName = "")
 		{
 			if (string.IsNullOrEmpty(collectionName))
 			{
 				collectionName = disposer.GetType().Name;
 			}
-			Dictionary<long, Disposer> collection;
+			Dictionary<long, Component> collection;
 			if (!this.cache.TryGetValue(collectionName, out collection))
 			{
-				collection = new Dictionary<long, Disposer>();
+				collection = new Dictionary<long, Component>();
 				this.cache.Add(collectionName, collection);
 			}
 			collection[disposer.Id] = disposer;
 		}
 
-		public Disposer GetFromCache(string collectionName, long id)
+		public Component GetFromCache(string collectionName, long id)
 		{
-			Dictionary<long, Disposer> d;
+			Dictionary<long, Component> d;
 			if (!this.cache.TryGetValue(collectionName, out d))
 			{
 				return null;
 			}
-			Disposer result;
+			Component result;
 			if (!d.TryGetValue(id, out result))
 			{
 				return null;
@@ -87,7 +87,7 @@ namespace Model
 
 		public void RemoveFromCache(string collectionName, long id)
 		{
-			Dictionary<long, Disposer> d;
+			Dictionary<long, Component> d;
 			if (!this.cache.TryGetValue(collectionName, out d))
 			{
 				return;
@@ -95,28 +95,28 @@ namespace Model
 			d.Remove(id);
 		}
 
-		public Task<Disposer> Get(string collectionName, long id)
+		public Task<Component> Get(string collectionName, long id)
 		{
-			Disposer disposer = GetFromCache(collectionName, id);
+			Component disposer = GetFromCache(collectionName, id);
 			if (disposer != null)
 			{
 				return Task.FromResult(disposer);
 			}
 
-			TaskCompletionSource<Disposer> tcs = new TaskCompletionSource<Disposer>();
-			DBQueryTask dbQueryTask = EntityFactory.CreateWithId<DBQueryTask, string, TaskCompletionSource<Disposer>>(id, collectionName, tcs);
+			TaskCompletionSource<Component> tcs = new TaskCompletionSource<Component>();
+			DBQueryTask dbQueryTask = ComponentFactory.CreateWithId<DBQueryTask, string, TaskCompletionSource<Component>>(id, collectionName, tcs);
 			this.tasks[(int)((ulong)id % taskCount)].Add(dbQueryTask);
 
 			return tcs.Task;
 		}
 
-		public Task<List<Disposer>> GetBatch(string collectionName, List<long> idList)
+		public Task<List<Component>> GetBatch(string collectionName, List<long> idList)
 		{
-			List <Disposer> disposers = new List<Disposer>();
+			List <Component> disposers = new List<Component>();
 			bool isAllInCache = true;
 			foreach (long id in idList)
 			{
-				Disposer disposer = this.GetFromCache(collectionName, id);
+				Component disposer = this.GetFromCache(collectionName, id);
 				if (disposer == null)
 				{
 					isAllInCache = false;
@@ -130,18 +130,18 @@ namespace Model
 				return Task.FromResult(disposers);
 			}
 
-			TaskCompletionSource<List<Disposer>> tcs = new TaskCompletionSource<List<Disposer>>();
-			DBQueryBatchTask dbQueryBatchTask = EntityFactory.Create<DBQueryBatchTask, List<long>, string, TaskCompletionSource<List<Disposer>>>(idList, collectionName, tcs);
+			TaskCompletionSource<List<Component>> tcs = new TaskCompletionSource<List<Component>>();
+			DBQueryBatchTask dbQueryBatchTask = ComponentFactory.Create<DBQueryBatchTask, List<long>, string, TaskCompletionSource<List<Component>>>(idList, collectionName, tcs);
 			this.tasks[(int)((ulong)dbQueryBatchTask.Id % taskCount)].Add(dbQueryBatchTask);
 
 			return tcs.Task;
 		}
 
-		public Task<List<Disposer>> GetJson(string collectionName, string json)
+		public Task<List<Component>> GetJson(string collectionName, string json)
 		{
-			TaskCompletionSource<List<Disposer>> tcs = new TaskCompletionSource<List<Disposer>>();
+			TaskCompletionSource<List<Component>> tcs = new TaskCompletionSource<List<Component>>();
 			
-			DBQueryJsonTask dbQueryJsonTask = EntityFactory.Create<DBQueryJsonTask, string, string, TaskCompletionSource<List<Disposer>>>(collectionName, json, tcs);
+			DBQueryJsonTask dbQueryJsonTask = ComponentFactory.Create<DBQueryJsonTask, string, string, TaskCompletionSource<List<Component>>>(collectionName, json, tcs);
 			this.tasks[(int)((ulong)dbQueryJsonTask.Id % taskCount)].Add(dbQueryJsonTask);
 
 			return tcs.Task;

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

@@ -27,9 +27,9 @@ namespace Model
 			//this.database = this.mongoClient.GetDatabase(config.DBName);
 		}
 
-		public IMongoCollection<Disposer> GetCollection(string name)
+		public IMongoCollection<Component> GetCollection(string name)
 		{
-			return this.database.GetCollection<Disposer>(name);
+			return this.database.GetCollection<Component>(name);
 		}
 	}
 }

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

@@ -27,55 +27,55 @@ namespace Model
 			dbAddress = dbStartConfig.GetComponent<InnerConfig>().IPEndPoint;
 		}
 
-		public async Task Save(Disposer disposer, bool needCache = true)
+		public async Task Save(Component disposer, bool needCache = true)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			await session.Call(new DBSaveRequest { Disposer = disposer, NeedCache = needCache});
 		}
 
-		public async Task SaveBatch(List<Disposer> disposers, bool needCache = true)
+		public async Task SaveBatch(List<Component> disposers, bool needCache = true)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			await session.Call(new DBSaveBatchRequest { Disposers = disposers, NeedCache = needCache});
 		}
 
-		public async Task Save(Disposer disposer, bool needCache, CancellationToken cancellationToken)
+		public async Task Save(Component disposer, bool needCache, CancellationToken cancellationToken)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			await session.Call(new DBSaveRequest { Disposer = disposer, NeedCache = needCache}, cancellationToken);
 		}
 
-		public async void SaveLog(Disposer disposer)
+		public async void SaveLog(Component disposer)
 		{
 			Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(dbAddress);
 			await session.Call(new DBSaveRequest { Disposer = disposer,  NeedCache = false, CollectionName = "Log" });
 		}
 
-		public async Task<T> Query<T>(long id, bool needCache = true) where T: Disposer
+		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;
 		}
 
-		public async Task<List<T>> QueryBatch<T>(List<long> ids, bool needCache = true) where T : Disposer
+		public async Task<List<T>> QueryBatch<T>(List<long> ids, bool needCache = true) where T : Component
 		{
 			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 (Disposer disposer in dbQueryBatchResponse.Disposers)
+			foreach (Component disposer in dbQueryBatchResponse.Disposers)
 			{
 				list.Add((T)disposer);
 			}
 			return list;
 		}
 
-		public async Task<List<T>> QueryJson<T>(string json, bool needCache = true) where T : Disposer
+		public async Task<List<T>> QueryJson<T>(string json, bool needCache = true) where T : Component
 		{
 			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 (Disposer disposer in dbQueryJsonResponse.Disposers)
+			foreach (Component disposer in dbQueryJsonResponse.Disposers)
 			{
 				list.Add((T)disposer);
 			}

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

@@ -7,9 +7,9 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryBatchTaskSystem : ObjectSystem<DBQueryBatchTask>, IAwake<List<long>, string, TaskCompletionSource<List<Disposer>>>
+	public class DbQueryBatchTaskSystem : ObjectSystem<DBQueryBatchTask>, IAwake<List<long>, string, TaskCompletionSource<List<Component>>>
 	{
-		public void Awake(List<long> idList, string collectionName, TaskCompletionSource<List<Disposer>> tcs)
+		public void Awake(List<long> idList, string collectionName, TaskCompletionSource<List<Component>> tcs)
 		{
 			DBQueryBatchTask self = this.Get();
 
@@ -25,20 +25,20 @@ namespace Model
 
 		public List<long> IdList { get; set; }
 
-		public TaskCompletionSource<List<Disposer>> Tcs { get; set; }
+		public TaskCompletionSource<List<Component>> Tcs { get; set; }
 		
 		public override async Task Run()
 		{
 			DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
 			DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
-			List<Disposer> result = new List<Disposer>();
+			List<Component> result = new List<Component>();
 
 			try
 			{
 				// 执行查询数据库任务
 				foreach (long id in IdList)
 				{
-					Disposer disposer = dbCacheComponent.GetFromCache(this.CollectionName, id);
+					Component disposer = dbCacheComponent.GetFromCache(this.CollectionName, id);
 					if (disposer == null)
 					{
 						disposer = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id).Result.FirstOrDefaultAsync();

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

@@ -6,9 +6,9 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryJsonTaskSystem : ObjectSystem<DBQueryJsonTask>, IAwake<string, string, TaskCompletionSource<List<Disposer>>>
+	public class DbQueryJsonTaskSystem : ObjectSystem<DBQueryJsonTask>, IAwake<string, string, TaskCompletionSource<List<Component>>>
 	{
-		public void Awake(string collectionName, string json, TaskCompletionSource<List<Disposer>> tcs)
+		public void Awake(string collectionName, string json, TaskCompletionSource<List<Component>> tcs)
 		{
 			DBQueryJsonTask self = this.Get();
 			
@@ -24,7 +24,7 @@ namespace Model
 
 		public string Json { get; set; }
 
-		public TaskCompletionSource<List<Disposer>> Tcs { get; set; }
+		public TaskCompletionSource<List<Component>> Tcs { get; set; }
 		
 		public override async Task Run()
 		{
@@ -32,8 +32,8 @@ namespace Model
 			try
 			{
 				// 执行查询数据库任务
-				FilterDefinition<Disposer> filterDefinition = new JsonFilterDefinition<Disposer>(this.Json);
-				List<Disposer> disposers = await dbComponent.GetCollection(this.CollectionName).FindAsync(filterDefinition).Result.ToListAsync();
+				FilterDefinition<Component> filterDefinition = new JsonFilterDefinition<Component>(this.Json);
+				List<Component> disposers = await dbComponent.GetCollection(this.CollectionName).FindAsync(filterDefinition).Result.ToListAsync();
 				this.Tcs.SetResult(disposers);
 			}
 			catch (Exception e)

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

@@ -5,9 +5,9 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbQueryTaskSystem : ObjectSystem<DBQueryTask>, IAwake<string, TaskCompletionSource<Disposer>>
+	public class DbQueryTaskSystem : ObjectSystem<DBQueryTask>, IAwake<string, TaskCompletionSource<Component>>
 	{
-		public void Awake(string collectionName, TaskCompletionSource<Disposer> tcs)
+		public void Awake(string collectionName, TaskCompletionSource<Component> tcs)
 		{
 			DBQueryTask self = this.Get();
 			self.CollectionName = collectionName;
@@ -19,14 +19,14 @@ namespace Model
 	{
 		public string CollectionName { get; set; }
 
-		public TaskCompletionSource<Disposer> Tcs { get; set; }
+		public TaskCompletionSource<Component> Tcs { get; set; }
 
 		public override async Task Run()
 		{
 			DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
 			DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
 			// 执行查询前先看看cache中是否已经存在
-			Disposer disposer = dbCacheComponent.GetFromCache(this.CollectionName, this.Id);
+			Component disposer = dbCacheComponent.GetFromCache(this.CollectionName, this.Id);
 			if (disposer != null)
 			{
 				this.Tcs.SetResult(disposer);

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

@@ -7,9 +7,9 @@ using MongoDB.Driver;
 namespace Model
 {
 	[ObjectSystem]
-	public class DbSaveBatchTaskSystem : ObjectSystem<DBSaveBatchTask>, IAwake<List<Disposer>, string, TaskCompletionSource<bool>>
+	public class DbSaveBatchTaskSystem : ObjectSystem<DBSaveBatchTask>, IAwake<List<Component>, string, TaskCompletionSource<bool>>
 	{
-		public void Awake(List<Disposer> disposers, string collectionName, TaskCompletionSource<bool> tcs)
+		public void Awake(List<Component> disposers, string collectionName, TaskCompletionSource<bool> tcs)
 		{
 			DBSaveBatchTask self = this.Get();
 			
@@ -23,7 +23,7 @@ namespace Model
 	{
 		public string CollectionName { get; set; }
 
-		public List<Disposer> Disposers;
+		public List<Component> Disposers;
 
 		public TaskCompletionSource<bool> Tcs;
 	
@@ -31,7 +31,7 @@ namespace Model
 		{
 			DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
 
-			foreach (Disposer disposer in this.Disposers)
+			foreach (Component disposer in this.Disposers)
 			{
 				if (disposer == null)
 				{

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

@@ -6,9 +6,9 @@ namespace Model
 {
 
 	[ObjectSystem]
-	public class DbSaveTaskSystem : ObjectSystem<DBSaveTask>, IAwake<Disposer, string, TaskCompletionSource<bool>>
+	public class DbSaveTaskSystem : ObjectSystem<DBSaveTask>, IAwake<Component, string, TaskCompletionSource<bool>>
 	{
-		public void Awake(Disposer entity, string collectionName, TaskCompletionSource<bool> tcs)
+		public void Awake(Component entity, string collectionName, TaskCompletionSource<bool> tcs)
 		{
 			DBSaveTask self = this.Get();
 
@@ -20,7 +20,7 @@ namespace Model
 
 	public sealed class DBSaveTask : DBTask
 	{
-		public Disposer Disposer;
+		public Component Disposer;
 
 		public string CollectionName { get; set; }
 

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

@@ -2,14 +2,15 @@
 
 namespace Model
 {
-	public abstract class DBTask : Disposer
+	public abstract class DBTask : Component
 	{
 		protected DBTask()
 		{
 		}
 
-		protected DBTask(long id): base(id)
+		protected DBTask(long id)
 		{
+			this.Id = id;
 		}
 		
 		public abstract Task Run();

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

@@ -19,7 +19,7 @@ namespace Model
 
 			while (true)
 			{
-				if (self.Id == 0)
+				if (self.IsDisposed)
 				{
 					return;
 				}
@@ -40,7 +40,7 @@ namespace Model
 		}
 	}
 
-	public sealed class DBTaskQueue : Disposer
+	public sealed class DBTaskQueue : Component
 	{
 		public Queue<DBTask> queue = new Queue<DBTask>();
 

+ 1 - 1
Server/Model/Module/Location/LocationComponent.cs

@@ -230,7 +230,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -60,7 +60,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Server/Model/Module/Network/MessageDispatherComponent.cs

@@ -91,7 +91,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -62,7 +62,6 @@
     <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\EntityFactory.cs" Link="Base\Object\EntityFactory.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IAwake.cs" Link="Base\Object\IAwake.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILateUpdate.cs" Link="Base\Object\ILateUpdate.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILoad.cs" Link="Base\Object\ILoad.cs" />

+ 1 - 1
Unity/Assets/Scripts/Base/Message/AMHandler.cs

@@ -14,7 +14,7 @@ namespace Model
 				Log.Error($"消息类型转换错误: {msg.GetType().Name} to {typeof(Message).Name}");
 				return;
 			}
-			if (session.Id == 0)
+			if (session.IsDisposed)
 			{
 				Log.Error($"session disconnect {msg}");
 				return;

+ 7 - 6
Unity/Assets/Scripts/Base/Object/Component.cs

@@ -5,6 +5,12 @@ namespace Model
 	[BsonIgnoreExtraElements]
 	public abstract partial class Component: Disposer
 	{
+		[BsonIgnoreIfDefault]
+		[BsonDefaultValue(0L)]
+		[BsonElement]
+		[BsonId]
+		public long Id { get; set; }
+
 		[BsonIgnore]
 		public Disposer Parent { get; set; }
 
@@ -21,14 +27,9 @@ namespace Model
 			}
 		}
 
-		protected Component()
-		{
-			this.Id = 1;
-		}
-
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 68 - 8
Unity/Assets/Scripts/Base/Object/ComponentFactory.cs

@@ -2,34 +2,94 @@
 {
 	public static class ComponentFactory
 	{
-		public static T Create<T>(Entity entity) where T : Component
+		public static T CreateWithParent<T>(Component parent) where T : Component
 		{
 			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
 			Game.EventSystem.Awake(disposer);
 			return disposer;
 		}
 
-		public static T Create<T, A>(Entity entity, A a) where T : Component
+		public static T CreateWithParent<T, A>(Component parent, A a) where T : Component
 		{
 			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
 			Game.EventSystem.Awake(disposer, a);
 			return disposer;
 		}
 
-		public static T Create<T, A, B>(Entity entity, A a, B b) where T : 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 = entity;
+			disposer.Parent = parent;
 			Game.EventSystem.Awake(disposer, a, b);
 			return disposer;
 		}
 
-		public static T Create<T, A, B, C>(Entity entity, A a, B b, C c) where T : 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 = entity;
+			disposer.Parent = parent;
+			Game.EventSystem.Awake(disposer, a, b, c);
+			return disposer;
+		}
+
+		public static T Create<T>() where T : Component
+		{
+			T disposer = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(disposer);
+			return disposer;
+		}
+
+		public static T Create<T, A>(A a) where T : Component
+		{
+			T disposer = Game.ObjectPool.Fetch<T>();
+			Game.EventSystem.Awake(disposer, a);
+			return disposer;
+		}
+
+		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;
+		}
+
+		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;
+		}
+
+		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;
+		}
+
+		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;
+		}
+
+		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;
+		}
+
+		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;
 		}

+ 9 - 16
Unity/Assets/Scripts/Base/Object/Disposer.cs

@@ -6,28 +6,21 @@ namespace Model
 	[BsonKnownTypes(typeof(Component))]
 	public abstract class Disposer : Object, IDisposable
 	{
-		[BsonIgnoreIfDefault]
-		[BsonDefaultValue(1L)]
-		[BsonElement]
-		[BsonId]
-		public long Id { get; set; }
-
 		[BsonIgnore]
 		public bool IsFromPool { get; set; }
+
+		[BsonIgnore]
+		public bool IsDisposed { get; set; }
 	
-		protected Disposer()
+		public virtual void Dispose()
 		{
-			this.Id = IdGenerater.GenerateId();
-		}
+			if (this.IsDisposed)
+			{
+				return;
+			}
 
-		protected Disposer(long id)
-		{
-			this.Id = id;
-		}
+			this.IsDisposed = true;
 
-		public virtual void Dispose()
-		{
-			this.Id = 0;
 			if (this.IsFromPool)
 			{
 				Game.ObjectPool.Recycle(this);

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

@@ -31,7 +31,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -56,7 +56,7 @@ namespace Model
 
 		public K AddComponent<K>() where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K>(this);
+			K component = ComponentFactory.CreateWithParent<K>(this);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -73,7 +73,7 @@ namespace Model
 
 		public K AddComponent<K, P1>(P1 p1) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1>(this, p1);
+			K component = ComponentFactory.CreateWithParent<K, P1>(this, p1);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -90,7 +90,7 @@ namespace Model
 
 		public K AddComponent<K, P1, P2>(P1 p1, P2 p2) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1, P2>(this, p1, p2);
+			K component = ComponentFactory.CreateWithParent<K, P1, P2>(this, p1, p2);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -107,7 +107,7 @@ namespace Model
 
 		public K AddComponent<K, P1, P2, P3>(P1 p1, P2 p2, P3 p3) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1, P2, P3>(this, p1, p2, p3);
+			K component = ComponentFactory.CreateWithParent<K, P1, P2, P3>(this, p1, p2, p3);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{

+ 0 - 65
Unity/Assets/Scripts/Base/Object/EntityFactory.cs

@@ -1,65 +0,0 @@
-namespace Model
-{
-	public static class EntityFactory
-	{
-		public static T Create<T>() where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer);
-			return disposer;
-		}
-
-		public static T Create<T, A>(A a) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
-		}
-
-		public static T Create<T, A, B>(A a, B b) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
-		}
-
-		public static T Create<T, A, B, C>(A a, B b, C c) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
-		}
-
-		public static T CreateWithId<T>(long id) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A>(long id, A a) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A, B>(long id, A a, B b) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : Disposer
-		{
-			T disposer = Game.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Game.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
-		}
-	}
-}

+ 0 - 3
Unity/Assets/Scripts/Base/Object/EntityFactory.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 3a5156e0921549728e8ffeceeeee34a3
-timeCreated: 1504236309

+ 20 - 20
Unity/Assets/Scripts/Base/Object/EventSystem.cs

@@ -60,18 +60,18 @@ namespace Model
 
 		private readonly Dictionary<Type, IObjectSystem> disposerEvents = new Dictionary<Type, IObjectSystem>();
 
-		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 Queue<Disposer> lateUpdates = new Queue<Disposer>();
-		private Queue<Disposer> lateUpdates2 = new Queue<Disposer>();
+		private Queue<Component> lateUpdates = new Queue<Component>();
+		private Queue<Component> lateUpdates2 = new Queue<Component>();
 
-		private readonly HashSet<Disposer> unique = new HashSet<Disposer>();
+		private readonly HashSet<Component> unique = new HashSet<Component>();
 
 		public void LoadHotfixDll()
 		{
@@ -150,7 +150,7 @@ namespace Model
 			return this.assemblies.Values.ToArray();
 		}
 
-		public void Add(Disposer disposer)
+		public void Add(Component disposer)
 		{
 			IObjectSystem objectSystem;
 			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
@@ -179,7 +179,7 @@ namespace Model
 			}
 		}
 
-		public void Awake(Disposer disposer)
+		public void Awake(Component disposer)
 		{
 			this.Add(disposer);
 
@@ -197,7 +197,7 @@ namespace Model
 			iAwake.Awake();
 		}
 
-		public void Awake<P1>(Disposer disposer, P1 p1)
+		public void Awake<P1>(Component disposer, P1 p1)
 		{
 			this.Add(disposer);
 
@@ -215,7 +215,7 @@ namespace Model
 			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);
 
@@ -233,7 +233,7 @@ namespace Model
 			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);
 
@@ -256,8 +256,8 @@ namespace Model
 			unique.Clear();
 			while (this.loaders.Count > 0)
 			{
-				Disposer disposer = this.loaders.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.loaders.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}
@@ -299,7 +299,7 @@ namespace Model
 			unique.Clear();
 			while (this.starts.Count > 0)
 			{
-				Disposer disposer = this.starts.Dequeue();
+				Component disposer = this.starts.Dequeue();
 
 				if (!this.unique.Add(disposer))
 				{
@@ -328,8 +328,8 @@ namespace Model
 			this.unique.Clear();
 			while (this.updates.Count > 0)
 			{
-				Disposer disposer = this.updates.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.updates.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}
@@ -371,8 +371,8 @@ namespace Model
 			this.unique.Clear();
 			while (this.lateUpdates.Count > 0)
 			{
-				Disposer disposer = this.lateUpdates.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.lateUpdates.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}

+ 3 - 2
Unity/Assets/Scripts/Base/Object/ObjectPool.cs

@@ -19,8 +19,9 @@ namespace Model
 			if (queue.Count > 0)
             {
 				obj = queue.Dequeue();
-	            obj.Id = IdGenerater.GenerateId();
-	            return obj;
+	            obj.IsDisposed = false;
+	            obj.IsFromPool = true;
+				return obj;
             }
 	        obj = (Disposer)Activator.CreateInstance(type);
             return obj;

+ 1 - 1
Unity/Assets/Scripts/Component/AnimatorComponent.cs

@@ -213,7 +213,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -40,7 +40,7 @@ namespace Model
 
 		public async Task StartAsync()
 		{
-			using (UnityWebRequestAsync request = EntityFactory.Create<UnityWebRequestAsync>())
+			using (UnityWebRequestAsync request = ComponentFactory.Create<UnityWebRequestAsync>())
 			{
 				string versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt";
 				Log.Debug(versionUrl);
@@ -126,7 +126,7 @@ namespace Model
 				{
 					try
 					{
-						using (this.downloadingRequest = EntityFactory.Create<UnityWebRequestAsync>())
+						using (this.downloadingRequest = ComponentFactory.Create<UnityWebRequestAsync>())
 						{
 							await this.downloadingRequest.DownloadAsync(GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + this.downloadingBundle);
 							byte[] data = this.downloadingRequest.Request.downloadHandler.data;
@@ -202,7 +202,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Component/ClientFrameComponent.cs

@@ -58,7 +58,7 @@ namespace Model
 
                 await timerComponent.WaitAsync(waitTime);
 
-                if (this.Id == 0)
+                if (this.IsDisposed)
                 {
                     return;
                 }

+ 1 - 1
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs

@@ -95,7 +95,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Component/MoveComponent.cs

@@ -265,7 +265,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -61,7 +61,7 @@ namespace Model
 		{
 			while (true)
 			{
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}
@@ -73,7 +73,7 @@ namespace Model
 		public virtual async Task<Session> Accept()
 		{
 			AChannel channel = await this.Service.AcceptChannel();
-			Session session = EntityFactory.Create<Session, NetworkComponent, AChannel>(this, channel);
+			Session session = ComponentFactory.CreateWithId<Session, NetworkComponent, AChannel>(IdGenerater.GenerateId(), this, channel);
 			session.Parent = this;
 			channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
 			this.sessions.Add(session.Id, session);
@@ -106,7 +106,7 @@ namespace Model
 			try
 			{
 				AChannel channel = this.Service.ConnectChannel(ipEndPoint);
-				Session session = EntityFactory.Create<Session, NetworkComponent, AChannel>(this, channel);
+				Session session = ComponentFactory.CreateWithId<Session, NetworkComponent, AChannel>(IdGenerater.GenerateId(), this, channel);
 				session.Parent = this;
 				channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
 				this.sessions.Add(session.Id, session);
@@ -130,7 +130,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -83,7 +83,7 @@ namespace Model
 			// 一个数值可能会多种情况影响,比如速度,加个buff可能增加速度绝对值100,也有些buff增加10%速度,所以一个值可以由5个值进行控制其最终结果
 			// final = (((base + add) * (100 + pct) / 100) + finalAdd) * (100 + finalPct) / 100;
 			this.NumericDic[final] = ((this.GetByKey(bas) + this.GetByKey(add)) * (100 + this.GetByKey(pct)) / 100 + this.GetByKey(finalAdd)) * (100 + this.GetByKey(finalPct)) / 100;
-			Game.EventSystem.Run(EventIdType.NumbericChange, this.Parent.Id, numericType, final);
+			Game.EventSystem.Run(EventIdType.NumbericChange, this.Entity.Id, numericType, final);
 		}
 	}
 }

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

@@ -48,7 +48,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -57,7 +57,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -41,7 +41,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -67,7 +67,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -279,7 +279,7 @@ namespace Model
 			}
 
 			AssetBundle assetBundle;
-			using (AssetsBundleLoaderAsync assetsBundleLoaderAsync = EntityFactory.Create<AssetsBundleLoaderAsync>())
+			using (AssetsBundleLoaderAsync assetsBundleLoaderAsync = ComponentFactory.Create<AssetsBundleLoaderAsync>())
 			{
 				assetBundle = await assetsBundleLoaderAsync.LoadAsync(assetBundleName);
 			}
@@ -288,7 +288,7 @@ namespace Model
 			{
 				// 异步load资源到内存cache住
 				UnityEngine.Object[] assets;
-				using (AssetsLoaderAsync assetsLoaderAsync = EntityFactory.Create<AssetsLoaderAsync, AssetBundle>(assetBundle))
+				using (AssetsLoaderAsync assetsLoaderAsync = ComponentFactory.Create<AssetsLoaderAsync, AssetBundle>(assetBundle))
 				{
 					assets = await assetsLoaderAsync.LoadAllAssetsAsync();
 				}

+ 1 - 1
Unity/Assets/Scripts/Component/SceneChangeComponent.cs

@@ -38,7 +38,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -22,7 +22,7 @@
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Component/UIComponent.cs

@@ -30,7 +30,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -27,7 +27,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -13,7 +13,7 @@ namespace Model
 		}
 	}
 
-	public class AssetsBundleLoaderAsync : Disposer, IUpdate
+	public class AssetsBundleLoaderAsync : Component, IUpdate
 	{
 		private AssetBundleCreateRequest request;
 
@@ -32,7 +32,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 2 - 2
Unity/Assets/Scripts/Entity/AssetsLoaderAsync.cs

@@ -18,7 +18,7 @@ namespace Model
 		}
 	}
 
-	public class AssetsLoaderAsync : Disposer, IUpdate
+	public class AssetsLoaderAsync : Component, IUpdate
 	{
 		private AssetBundle assetBundle;
 
@@ -44,7 +44,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Entity/Player.cs

@@ -6,7 +6,7 @@
 		
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Entity/Scene.cs

@@ -31,7 +31,7 @@
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -53,7 +53,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -92,7 +92,7 @@ namespace Model
 		{
 			while (true)
 			{
-				if (this.Id == 0)
+				if (this.IsDisposed)
 				{
 					return;
 				}
@@ -101,7 +101,8 @@ namespace Model
 				try
 				{
 					packet = await this.channel.Recv();
-					if (this.Id == 0)
+					
+					if (this.IsDisposed)
 					{
 						return;
 					}
@@ -217,7 +218,7 @@ namespace Model
 
 		public void Send(ushort opcode, byte[] bytes)
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				throw new Exception("session已经被Dispose了");
 			}
@@ -227,7 +228,7 @@ namespace Model
 
 		public void Reply(ushort opcode, uint rpcId, byte[] bytes)
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				throw new Exception("session已经被Dispose了");
 			}

+ 2 - 2
Unity/Assets/Scripts/Entity/UI.cs

@@ -44,7 +44,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -95,7 +95,7 @@ namespace Model
 			{
 				return null;
 			}
-			child = EntityFactory.Create<UI, Scene, UI, GameObject>(this.Scene, this, childGameObject);
+			child = ComponentFactory.Create<UI, Scene, UI, GameObject>(this.Scene, this, childGameObject);
 			this.Add(child);
 			return child;
 		}

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

@@ -49,7 +49,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -15,7 +15,7 @@ namespace Model
 		}
 	}
 	
-	public class UnityWebRequestAsync : Disposer
+	public class UnityWebRequestAsync : Component
 	{
 		public UnityWebRequest Request;
 
@@ -25,7 +25,7 @@ namespace Model
 		
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -106,7 +106,7 @@ namespace Model
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 1 - 1
Unity/Assets/Scripts/Factory/PlayerFactory.cs

@@ -4,7 +4,7 @@
     {
         public static Player Create(long id)
         {
-            Player player = EntityFactory.CreateWithId<Player>(id);
+            Player player = ComponentFactory.CreateWithId<Player>(id);
             PlayerComponent playerComponent = Game.Scene.GetComponent<PlayerComponent>();
             playerComponent.Add(player);
             return player;

+ 1 - 1
Unity/Assets/Scripts/Factory/UnitFactory.cs

@@ -12,7 +12,7 @@ namespace Model
 	        
             UnitComponent unitComponent = Game.Scene.GetComponent<UnitComponent>();
             
-	        Unit unit = EntityFactory.CreateWithId<Unit>(id);
+	        Unit unit = ComponentFactory.CreateWithId<Unit>(id);
 	        unit.GameObject = UnityEngine.Object.Instantiate(prefab);
 	        GameObject parent = GameObject.Find($"/Global/Unit");
 	        unit.GameObject.transform.SetParent(parent.transform, false);

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

@@ -22,7 +22,7 @@ namespace Model
 			{
 				await timerComponent.WaitAsync(1000);
 				
-				if (self.Id == 0)
+				if (self.IsDisposed)
 				{
 					return;
 				}

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

@@ -13,7 +13,7 @@ namespace Model
 				GameObject bundleGameObject = ((GameObject)Resources.Load("KV")).Get<GameObject>("UILoading");
 				GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);
 				go.layer = LayerMask.NameToLayer(LayerNames.UI);
-				UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, go);
+				UI ui = ComponentFactory.Create<UI, Scene, UI, GameObject>(scene, null, go);
 
 				ui.AddComponent<UILoadingComponent>();
 				return ui;

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

@@ -109,7 +109,6 @@ namespace ILRuntime.Runtime.Generated
             Model_GlobalProto_Binding.Register(app);
             Model_NetworkHelper_Binding.Register(app);
             UnityEngine_UI_InputField_Binding.Register(app);
-            Model_EntityFactory_Binding.Register(app);
         }
     }
 }

+ 0 - 48
Unity/Assets/ThirdParty/ILRuntime/Generated/Model_Disposer_Binding.cs

@@ -17,55 +17,7 @@ namespace ILRuntime.Runtime.Generated
     {
         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.Disposer);
-            args = new Type[]{};
-            method = type.GetMethod("get_Id", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_Id_0);
-            args = new Type[]{};
-            method = type.GetMethod("Dispose", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Dispose_1);
 
-
-        }
-
-
-        static StackObject* get_Id_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.Disposer instance_of_this_method;
-            instance_of_this_method = (Model.Disposer)typeof(Model.Disposer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            var result_of_this_method = instance_of_this_method.Id;
-
-            __ret->ObjectType = ObjectTypes.Long;
-            *(long*)&__ret->Value = result_of_this_method;
-            return __ret + 1;
         }
-
-        static StackObject* Dispose_1(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.Disposer instance_of_this_method;
-            instance_of_this_method = (Model.Disposer)typeof(Model.Disposer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            instance_of_this_method.Dispose();
-
-            return __ret;
-        }
-
-
-
     }
 }

+ 3 - 58
Unity/Assets/ThirdParty/ILRuntime/Generated/Model_EntityFactory_Binding.cs

@@ -13,62 +13,7 @@ using ILRuntime.CLR.Utils;
 
 namespace ILRuntime.Runtime.Generated
 {
-    unsafe class Model_EntityFactory_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.EntityFactory);
-            Dictionary<string, List<MethodInfo>> genericMethods = new Dictionary<string, List<MethodInfo>>();
-            List<MethodInfo> lst = null;                    
-            foreach(var m in type.GetMethods())
-            {
-                if(m.IsGenericMethodDefinition)
-                {
-                    if (!genericMethods.TryGetValue(m.Name, out lst))
-                    {
-                        lst = new List<MethodInfo>();
-                        genericMethods[m.Name] = lst;
-                    }
-                    lst.Add(m);
-                }
-            }
-            args = new Type[]{typeof(Model.Player)};
-            if (genericMethods.TryGetValue("CreateWithId", out lst))
-            {
-                foreach(var m in lst)
-                {
-                    if(m.GetParameters().Length == 1)
-                    {
-                        method = m.MakeGenericMethod(args);
-                        app.RegisterCLRMethodRedirection(method, CreateWithId_0);
-
-                        break;
-                    }
-                }
-            }
-
-
-        }
-
-
-        static StackObject* CreateWithId_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);
-            System.Int64 id = *(long*)&ptr_of_this_method->Value;
-
-            var result_of_this_method = Model.EntityFactory.CreateWithId<Model.Player>(id);
-
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-
-
-    }
+		unsafe class Model_EntityFactory_Binding
+		{
+		}
 }

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

@@ -4,8 +4,10 @@ namespace Hotfix
 {
 	public abstract class Component : Disposer
 	{
+		public long Id { get; set; }
+
 		[BsonIgnore]
-		public Disposer Parent { get; set; }
+		public Component Parent { get; set; }
 
 		public T GetParent<T>() where T : Entity
 		{
@@ -19,15 +21,10 @@ namespace Hotfix
 				return this.Parent as Entity;
 			}
 		}
-
-		protected Component()
-		{
-			this.Id = 1;
-		}
-
+		
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

+ 68 - 8
Unity/Hotfix/Base/Object/ComponentFactory.cs

@@ -4,34 +4,94 @@ namespace Hotfix
 {
 	public static class ComponentFactory
 	{
-		public static T Create<T>(Entity entity) where T : Component
+		public static T CreateWithParent<T>(Component parent) where T : Component
 		{
 			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
 			Hotfix.EventSystem.Awake(disposer);
 			return disposer;
 		}
 
-		public static T Create<T, A>(Entity entity, A a) where T : Component
+		public static T CreateWithParent<T, A>(Component parent, A a) where T : Component
 		{
 			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
 			Hotfix.EventSystem.Awake(disposer, a);
 			return disposer;
 		}
 
-		public static T Create<T, A, B>(Entity entity, A a, B b) where T : Component
+		public static T CreateWithParent<T, A, B>(Component parent, A a, B b) where T : Component
 		{
 			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
 			Hotfix.EventSystem.Awake(disposer, a, b);
 			return disposer;
 		}
 
-		public static T Create<T, A, B, C>(Entity entity, A a, B b, C c) where T : Component
+		public static T CreateWithParent<T, A, B, C>(Component parent, A a, B b, C c) where T : Component
 		{
 			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Parent = entity;
+			disposer.Parent = parent;
+			Hotfix.EventSystem.Awake(disposer, a, b, c);
+			return disposer;
+		}
+
+		public static T Create<T>() where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			Hotfix.EventSystem.Awake(disposer);
+			return disposer;
+		}
+
+		public static T Create<T, A>(A a) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			Hotfix.EventSystem.Awake(disposer, a);
+			return disposer;
+		}
+
+		public static T Create<T, A, B>(A a, B b) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			Hotfix.EventSystem.Awake(disposer, a, b);
+			return disposer;
+		}
+
+		public static T Create<T, A, B, C>(A a, B b, C c) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			Hotfix.EventSystem.Awake(disposer, a, b, c);
+			return disposer;
+		}
+
+		public static T CreateWithId<T>(long id) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			disposer.Id = id;
+			Hotfix.EventSystem.Awake(disposer);
+			return disposer;
+		}
+
+		public static T CreateWithId<T, A>(long id, A a) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			disposer.Id = id;
+			Hotfix.EventSystem.Awake(disposer, a);
+			return disposer;
+		}
+
+		public static T CreateWithId<T, A, B>(long id, A a, B b) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			disposer.Id = id;
+			Hotfix.EventSystem.Awake(disposer, a, b);
+			return disposer;
+		}
+
+		public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : Component
+		{
+			T disposer = Hotfix.ObjectPool.Fetch<T>();
+			disposer.Id = id;
 			Hotfix.EventSystem.Awake(disposer, a, b, c);
 			return disposer;
 		}

+ 8 - 12
Unity/Hotfix/Base/Object/Disposer.cs

@@ -4,23 +4,19 @@ namespace Hotfix
 {
 	public abstract class Disposer : Object, IDisposable2
 	{
-		public long Id { get; set; }
-
 		public bool IsFromPool { get; set; }
+		
+		public bool IsDisposed { get; set; }
 
-		protected Disposer()
+		public virtual void Dispose()
 		{
-			this.Id = IdGenerater.GenerateId();
-		}
+			if (this.IsDisposed)
+			{
+				return;
+			}
 
-		protected Disposer(long id)
-		{
-			this.Id = id;
-		}
+			this.IsDisposed = true;
 
-		public virtual void Dispose()
-		{
-			this.Id = 0;
 			if (this.IsFromPool)
 			{
 				Hotfix.ObjectPool.Recycle(this);

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

@@ -32,7 +32,7 @@ namespace Hotfix
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -57,7 +57,7 @@ namespace Hotfix
 
 		public K AddComponent<K>() where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K>(this);
+			K component = ComponentFactory.CreateWithParent<K>(this);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -74,7 +74,7 @@ namespace Hotfix
 
 		public K AddComponent<K, P1>(P1 p1) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1>(this, p1);
+			K component = ComponentFactory.CreateWithParent<K, P1>(this, p1);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -91,7 +91,7 @@ namespace Hotfix
 
 		public K AddComponent<K, P1, P2>(P1 p1, P2 p2) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1, P2>(this, p1, p2);
+			K component = ComponentFactory.CreateWithParent<K, P1, P2>(this, p1, p2);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{
@@ -108,7 +108,7 @@ namespace Hotfix
 
 		public K AddComponent<K, P1, P2, P3>(P1 p1, P2 p2, P3 p3) where K : Component, new()
 		{
-			K component = ComponentFactory.Create<K, P1, P2, P3>(this, p1, p2, p3);
+			K component = ComponentFactory.CreateWithParent<K, P1, P2, P3>(this, p1, p2, p3);
 
 			if (this.componentDict.ContainsKey(component.GetType()))
 			{

+ 0 - 65
Unity/Hotfix/Base/Object/EntityFactory.cs

@@ -1,65 +0,0 @@
-namespace Hotfix
-{
-	public static class EntityFactory
-	{
-		public static T Create<T>() where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			Hotfix.EventSystem.Awake(disposer);
-			return disposer;
-		}
-
-		public static T Create<T, A>(A a) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			Hotfix.EventSystem.Awake(disposer, a);
-			return disposer;
-		}
-
-		public static T Create<T, A, B>(A a, B b) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			Hotfix.EventSystem.Awake(disposer, a, b);
-			return disposer;
-		}
-
-		public static T Create<T, A, B, C>(A a, B b, C c) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			Hotfix.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
-		}
-
-		public static T CreateWithId<T>(long id) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Hotfix.EventSystem.Awake(disposer);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A>(long id, A a) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Hotfix.EventSystem.Awake(disposer, a);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A, B>(long id, A a, B b) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Hotfix.EventSystem.Awake(disposer, a, b);
-			return disposer;
-		}
-
-		public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : Disposer
-		{
-			T disposer = Hotfix.ObjectPool.Fetch<T>();
-			disposer.Id = id;
-			Hotfix.EventSystem.Awake(disposer, a, b, c);
-			return disposer;
-		}
-	}
-}

+ 20 - 20
Unity/Hotfix/Base/Object/EventSystem.cs

@@ -36,18 +36,18 @@ namespace Hotfix
 
 		private readonly Dictionary<int, List<IEvent>> allEvents = new Dictionary<int, List<IEvent>>();
 
-		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 Queue<Disposer> lateUpdates = new Queue<Disposer>();
-		private Queue<Disposer> lateUpdates2 = new Queue<Disposer>();
+		private Queue<Component> lateUpdates = new Queue<Component>();
+		private Queue<Component> lateUpdates2 = new Queue<Component>();
 
-		private readonly HashSet<Disposer> unique = new HashSet<Disposer>();
+		private readonly HashSet<Component> unique = new HashSet<Component>();
 
 		public EventSystem()
 		{
@@ -126,7 +126,7 @@ namespace Hotfix
 			}
 		}
 
-		public void Add(Disposer disposer)
+		public void Add(Component disposer)
 		{
 			if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectSystem objectSystem))
 			{
@@ -154,7 +154,7 @@ namespace Hotfix
 			}
 		}
 
-		public void Awake(Disposer disposer)
+		public void Awake(Component disposer)
 		{
 			this.Add(disposer);
 
@@ -171,7 +171,7 @@ namespace Hotfix
 			iAwake.Awake();
 		}
 
-		public void Awake<P1>(Disposer disposer, P1 p1)
+		public void Awake<P1>(Component disposer, P1 p1)
 		{
 			this.Add(disposer);
 
@@ -188,7 +188,7 @@ namespace Hotfix
 			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);
 
@@ -205,7 +205,7 @@ namespace Hotfix
 			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);
 
@@ -227,8 +227,8 @@ namespace Hotfix
 			unique.Clear();
 			while (this.loaders.Count > 0)
 			{
-				Disposer disposer = this.loaders.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.loaders.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}
@@ -269,7 +269,7 @@ namespace Hotfix
 			unique.Clear();
 			while (this.starts.Count > 0)
 			{
-				Disposer disposer = this.starts.Dequeue();
+				Component disposer = this.starts.Dequeue();
 
 				if (!this.unique.Add(disposer))
 				{
@@ -297,8 +297,8 @@ namespace Hotfix
 			unique.Clear();
 			while (this.updates.Count > 0)
 			{
-				Disposer disposer = this.updates.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.updates.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}
@@ -339,8 +339,8 @@ namespace Hotfix
 			unique.Clear();
 			while (this.lateUpdates.Count > 0)
 			{
-				Disposer disposer = this.lateUpdates.Dequeue();
-				if (disposer.Id == 0)
+				Component disposer = this.lateUpdates.Dequeue();
+				if (disposer.IsDisposed)
 				{
 					continue;
 				}

+ 36 - 35
Unity/Hotfix/Base/Object/ObjectPool.cs

@@ -1,47 +1,48 @@
 using System;
 using System.Collections.Generic;
-using Model;
 
 namespace Hotfix
 {
-    public class ObjectPool
-    {
-        private readonly Dictionary<Type, Queue<Disposer>> dictionary = new Dictionary<Type, Queue<Disposer>>();
+	public class ObjectPool
+	{
+		private readonly Dictionary<Type, Queue<Disposer>> dictionary = new Dictionary<Type, Queue<Disposer>>();
 
-        public Disposer Fetch(Type type)
-        {
-	        Queue<Disposer> queue;
-            if (!this.dictionary.TryGetValue(type, out queue))
-            {
-                queue = new Queue<Disposer>();
-                this.dictionary.Add(type, queue);
-            }
-	        Disposer obj;
+		private Disposer Fetch(Type type)
+		{
+			Queue<Disposer> queue;
+			if (!this.dictionary.TryGetValue(type, out queue))
+			{
+				queue = new Queue<Disposer>();
+				this.dictionary.Add(type, queue);
+			}
+			Disposer obj;
 			if (queue.Count > 0)
-            {
+			{
 				obj = queue.Dequeue();
-	            obj.Id = IdGenerater.GenerateId();
-	            return obj;
-            }
-	        obj = (Disposer)Activator.CreateInstance(type);
-            return obj;
-        }
+				obj.IsDisposed = false;
+				obj.IsFromPool = true;
+				return obj;
+			}
+			obj = (Disposer)Activator.CreateInstance(type);
+			return obj;
+		}
+
+		public T Fetch<T>() where T : Disposer
+		{
+			T t = (T)this.Fetch(typeof(T));
+			return t;
+		}
 
-        public T Fetch<T>() where T: Disposer
+		public void Recycle(Disposer obj)
 		{
-            return (T) this.Fetch(typeof(T));
-        }
-        
-        public void Recycle(Disposer obj)
-        {
-            Type type = obj.GetType();
-	        Queue<Disposer> queue;
-            if (!this.dictionary.TryGetValue(type, out queue))
-            {
-                queue = new Queue<Disposer>();
+			Type type = obj.GetType();
+			Queue<Disposer> queue;
+			if (!this.dictionary.TryGetValue(type, out queue))
+			{
+				queue = new Queue<Disposer>();
 				this.dictionary.Add(type, queue);
-            }
-            queue.Enqueue(obj);
-        }
-    }
+			}
+			queue.Enqueue(obj);
+		}
+	}
 }

+ 1 - 1
Unity/Hotfix/Entity/Scene.cs

@@ -31,7 +31,7 @@
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -44,7 +44,7 @@ namespace Hotfix
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}
@@ -94,7 +94,7 @@ namespace Hotfix
 			{
 				return null;
 			}
-			child = EntityFactory.Create<UI, Scene, UI, GameObject>(this.Scene, this, childGameObject);
+			child = ComponentFactory.Create<UI, Scene, UI, GameObject>(this.Scene, this, childGameObject);
 			this.Add(child);
 			return child;
 		}

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

@@ -108,7 +108,7 @@ namespace Hotfix
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -51,7 +51,7 @@ namespace Hotfix
 
 		public override void Dispose()
 		{
-			if (this.Id == 0)
+			if (this.IsDisposed)
 			{
 				return;
 			}

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

@@ -16,7 +16,7 @@ namespace Hotfix
 				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}.unity3d", $"{type}");
 				GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
 				lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
-				UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, lobby);
+				UI ui = ComponentFactory.Create<UI, Scene, UI, GameObject>(scene, null, lobby);
 
 				ui.AddComponent<UILobbyComponent>();
 				return ui;

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

@@ -41,18 +41,16 @@ namespace Hotfix
 				{
 					r2CLogin = (R2C_Login) await session.Call(new C2R_Login() { Account = text, Password = "111111" });
 				}
-				
-				
+
 				connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
 				Session gateSession = Game.Scene.GetComponent<NetOuterComponent>().Create(connetEndPoint);
 				Game.Scene.AddComponent<SessionComponent>().Session = gateSession;
-
 				G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate() { Key = r2CLogin.Key });
-				
+
 				Log.Info("登陆gate成功!");
 
 				// 创建Player
-				Player player = Model.EntityFactory.CreateWithId<Player>(g2CLoginGate.PlayerId);
+				Player player = Model.ComponentFactory.CreateWithId<Player>(g2CLoginGate.PlayerId);
 				PlayerComponent playerComponent = Game.Scene.GetComponent<PlayerComponent>();
 				playerComponent.MyPlayer = player;
 

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

@@ -16,7 +16,7 @@ namespace Hotfix
 				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}.unity3d", $"{type}");
 				GameObject login = UnityEngine.Object.Instantiate(bundleGameObject);
 				login.layer = LayerMask.NameToLayer(LayerNames.UI);
-		        UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, login);
+		        UI ui = ComponentFactory.Create<UI, Scene, UI, GameObject>(scene, null, login);
 
 				ui.AddComponent<UILoginComponent>();
 				return ui;

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

@@ -19,7 +19,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>..\Temp\UnityVS_bin\Debug\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;ILRuntime</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <Prefer32Bit>false</Prefer32Bit>
@@ -69,7 +69,6 @@
     <Compile Include="Base\Object\ComponentFactory.cs" />
     <Compile Include="Base\Object\Disposer.cs" />
     <Compile Include="Base\Object\Entity.cs" />
-    <Compile Include="Base\Object\EntityFactory.cs" />
     <Compile Include="Base\Object\EntityType.cs" />
     <Compile Include="Base\Object\IAwake.cs" />
     <Compile Include="Base\Object\ILateUpdate.cs" />

Некоторые файлы не были показаны из-за большого количества измененных файлов