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

消息的Disposer改成Component

tanghai 7 лет назад
Родитель
Сommit
0fda3a64e6

+ 5 - 5
Proto/InnerMessage.proto

@@ -44,7 +44,7 @@
 
 		required string CollectionName = 2;
 
-		required Component Disposer = 3;
+		required Component Component = 3;
 	}
 
 
@@ -56,7 +56,7 @@
 	{
 		required bool NeedCache = 1;
 		required string CollectionName = 2;
-		repeated Component Disposers = 3;
+		repeated Component Components = 3;
 	}
 
 	message DBSaveResponse // IResponse
@@ -72,7 +72,7 @@
 
 	message DBQueryResponse // IResponse
 	{
-		required Component Disposer = 1;
+		required Component Component = 1;
 	}
 
 	message DBQueryBatchRequest // IRequest
@@ -84,7 +84,7 @@
 
 	message DBQueryBatchResponse // IResponse
 	{
-		repeated Component Disposers = 1;
+		repeated Component Components = 1;
 	}
 
 	message DBQueryJsonRequest // IRequest
@@ -96,7 +96,7 @@
 
 	message DBQueryJsonResponse // IResponse
 	{
-		repeated Component Disposers = 1;
+		repeated Component Components = 1;
 	}
 
 	message ObjectAddRequest // IRequest

+ 2 - 1
Unity/Assets/Scripts/Base/Object/Component.cs

@@ -7,7 +7,7 @@ namespace ETModel
 	public abstract partial class Component : Object, IDisposable
 	{
 		[BsonIgnore]
-		public long InstanceId { get; private set; }
+		public long InstanceId { get; protected set; }
 
 		[BsonIgnore]
 		private bool isFromPool;
@@ -68,6 +68,7 @@ namespace ETModel
 		{
 			this.InstanceId = IdGenerater.GenerateId();
 			Game.EventSystem.Add(this);
+			this.Id = this.InstanceId;
 		}
 
 		protected Component(long instanceId)

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

@@ -17,14 +17,12 @@ namespace ETModel
 
 		protected Entity()
 		{
-			this.Id = this.InstanceId;
 			this.components = new HashSet<Component>();
 			this.componentDict = new Dictionary<Type, Component>();
 		}
 
-		protected Entity(long id)
+		protected Entity(long id): base(id)
 		{
-			this.Id = id;
 			this.components = new HashSet<Component>();
 			this.componentDict = new Dictionary<Type, Component>();
 		}
@@ -202,6 +200,8 @@ namespace ETModel
 		{
 			try
 			{
+				this.InstanceId = IdGenerater.GenerateId();
+
 				this.componentDict.Clear();
 
 				if (this.components != null)

+ 4 - 2
Unity/Hotfix/Base/Object/Component.cs

@@ -8,7 +8,7 @@ namespace ETHotfix
 	public abstract partial class Component : Object, IDisposable2
 	{
 		[BsonIgnore]
-		public long InstanceId { get; private set; }
+		public long InstanceId { get; protected set; }
 
 		[BsonIgnore]
 		private bool isFromPool;
@@ -23,6 +23,7 @@ namespace ETHotfix
 			set
 			{
 				this.isFromPool = value;
+
 				if (this.InstanceId == 0)
 				{
 					this.InstanceId = IdGenerater.GenerateId();
@@ -68,6 +69,7 @@ namespace ETHotfix
 		{
 			this.InstanceId = IdGenerater.GenerateId();
 			Game.EventSystem.Add(this);
+			this.Id = this.InstanceId;
 		}
 
 		protected Component(long instanceId)
@@ -82,7 +84,7 @@ namespace ETHotfix
 			{
 				return;
 			}
-			
+
 			Game.EventSystem.Remove(this.InstanceId);
 
 			this.InstanceId = 0;

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

@@ -18,14 +18,12 @@ namespace ETHotfix
 
 		protected Entity()
 		{
-			this.Id = IdGenerater.GenerateId();
 			this.components = new HashSet<Component>();
 			this.componentDict = new Dictionary<Type, Component>();
 		}
 
-		protected Entity(long id)
+		protected Entity(long id) : base(id)
 		{
-			this.Id = id;
 			this.components = new HashSet<Component>();
 			this.componentDict = new Dictionary<Type, Component>();
 		}
@@ -203,6 +201,8 @@ namespace ETHotfix
 		{
 			try
 			{
+				this.InstanceId = IdGenerater.GenerateId();
+
 				this.componentDict.Clear();
 
 				if (this.components != null)