فهرست منبع

actorLocation消息增加一个LocationType,可以给同一个Id的不同类对象发送消息,比如战斗Unit,系统Player,聊天单位,好友单位,这些Id都一样,只要知道Id就能给这些对象发送消息了

tanghai 2 سال پیش
والد
کامیت
462f043db4
43فایلهای تغییر یافته به همراه457 افزوده شده و 315 حذف شده
  1. 17 11
      Unity/Assets/Config/Proto/InnerMessage_S_20001.proto
  2. 24 18
      Unity/Assets/Config/Proto/OuterMessage_C_10001.proto
  3. 0 3
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneChangeHelper.cs
  4. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/SessionComponentSystem.cs
  5. 6 33
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/MessageHelper.cs
  6. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs
  7. 1 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs
  8. 5 3
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
  9. 0 20
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs
  10. 2 7
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs
  11. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  12. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs
  13. 0 13
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitGateComponentSystem.cs
  14. 4 4
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetServerComponentOnReadEvent.cs
  15. 9 5
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorHandleHelper.cs
  16. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageDispatcherComponentSystem.cs
  17. 69 40
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ActorLocationSenderComponentSystem.cs
  18. 0 11
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationComponentSystem.cs.meta
  19. 49 12
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs
  20. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs.meta
  21. 14 14
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationProxyComponentSystem.cs
  22. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs
  23. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs
  24. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs
  25. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs
  26. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs
  27. 13 1
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Session/SessionComponent.cs
  28. 31 13
      Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs
  29. 23 5
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs
  30. 31 13
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs
  31. 23 5
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs
  32. 31 13
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs
  33. 0 1
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerComponent.cs
  34. 15 2
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionInfoComponent.cs
  35. 13 1
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionPlayerComponent.cs
  36. 0 8
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Unit/UnitGateComponent.cs
  37. 1 1
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSender.cs
  38. 0 15
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderComponent.cs
  39. 0 11
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderComponent.cs.meta
  40. 28 0
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderOneType.cs
  41. 1 1
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderOneType.cs.meta
  42. 23 5
      Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/LocationComponent.cs
  43. 13 13
      Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockComponent.cs

+ 17 - 11
Unity/Assets/Config/Proto/InnerMessage_S_20001.proto

@@ -58,8 +58,9 @@ message G2G_LockReleaseResponse // IActorResponse
 message ObjectAddRequest // IActorRequest
 {
 	int32 RpcId = 1;
-	int64 Key = 2;
-	int64 InstanceId = 3;
+	int32 Type = 2;
+	int64 Key = 3;
+	int64 InstanceId = 4;
 }
 
 message ObjectAddResponse // IActorResponse
@@ -73,9 +74,10 @@ message ObjectAddResponse // IActorResponse
 message ObjectLockRequest // IActorRequest
 {
 	int32 RpcId = 1;
-	int64 Key = 2;
-	int64 InstanceId = 3;
-	int32 Time = 4;
+	int32 Type = 2;
+	int64 Key = 3;
+	int64 InstanceId = 4;
+	int32 Time = 5;
 }
 message ObjectLockResponse // IActorResponse
 {
@@ -88,9 +90,10 @@ message ObjectLockResponse // IActorResponse
 message ObjectUnLockRequest // IActorRequest
 {
 	int32 RpcId = 1;
-	int64 Key = 2;
-	int64 OldInstanceId = 3;
-	int64 InstanceId = 4;
+	int32 Type = 2;
+	int64 Key = 3;
+	int64 OldInstanceId = 4;
+	int64 InstanceId = 5;
 }
 message ObjectUnLockResponse // IActorResponse
 {
@@ -103,7 +106,8 @@ message ObjectUnLockResponse // IActorResponse
 message ObjectRemoveRequest // IActorRequest
 {
 	int32 RpcId = 1;
-	int64 Key = 2;
+	int32 Type = 2;
+	int64 Key = 3;
 }
 message ObjectRemoveResponse // IActorResponse
 {
@@ -116,14 +120,16 @@ message ObjectRemoveResponse // IActorResponse
 message ObjectGetRequest // IActorRequest
 {
 	int32 RpcId = 1;
-	int64 Key = 2;
+	int32 Type = 2;
+	int64 Key = 3;
 }
 message ObjectGetResponse // IActorResponse
 {
 	int32 RpcId = 1;
 	int32 Error = 2;
 	string Message = 3;
-	int64 InstanceId = 4;
+	int32 Type = 4;
+	int64 InstanceId = 5;
 }
 
 //ResponseType G2R_GetLoginKey

+ 24 - 18
Unity/Assets/Config/Proto/OuterMessage_C_10001.proto

@@ -75,24 +75,28 @@ message UnitInfo
 	MoveInfo MoveInfo = 7;
 }
 
-message M2C_CreateUnits // IActorMessage
+message M2C_CreateUnits // IActorLocationMessage
 {
-	repeated UnitInfo Units = 1;
+	int32 RpcId = 1;
+	repeated UnitInfo Units = 2;
 }
 
-message M2C_CreateMyUnit // IActorMessage
+message M2C_CreateMyUnit // IActorLocationMessage
 {
-	UnitInfo Unit = 1;
+	int32 RpcId = 1;
+	UnitInfo Unit = 2;
 }
 
-message M2C_StartSceneChange // IActorMessage
+message M2C_StartSceneChange // IActorLocationMessage
 {
-	int64 SceneInstanceId = 1;
-	string SceneName = 2;	
+	int32 RpcId = 1;
+	int64 SceneInstanceId = 2;
+	string SceneName = 3;	
 }
 
-message M2C_RemoveUnits // IActorMessage
+message M2C_RemoveUnits // IActorLocationMessage
 {
+	int32 RpcId = 1;
 	repeated int64 Units = 2;
 }
 
@@ -107,19 +111,21 @@ message C2M_Stop // IActorLocationMessage
 	int32 RpcId = 1;
 }
 
-message M2C_PathfindingResult // IActorMessage
+message M2C_PathfindingResult // IActorLocationMessage
 {
-	int64 Id = 1;
-	Unity.Mathematics.float3 Position = 2;
-	repeated Unity.Mathematics.float3 Points = 3;
+	int32 RpcId = 1;
+	int64 Id = 2;
+	Unity.Mathematics.float3 Position = 3;
+	repeated Unity.Mathematics.float3 Points = 4;
 }
 
-message M2C_Stop // IActorMessage
+message M2C_Stop // IActorLocationMessage
 {
-	int32 Error = 1;
-	int64 Id = 2;
-	Unity.Mathematics.float3 Position = 3;
-	Unity.Mathematics.quaternion Rotation = 4;
+	int32 RpcId = 1;
+	int32 Error = 2;
+	int64 Id = 3;
+	Unity.Mathematics.float3 Position = 4;
+	Unity.Mathematics.quaternion Rotation = 5;
 }
 
 //ResponseType G2C_Ping
@@ -216,7 +222,7 @@ message C2M_TestRobotCase2 // IActorLocationMessage
 	int32 N = 2;
 }
 
-message M2C_TestRobotCase2 // IActorMessage
+message M2C_TestRobotCase2 // IActorLocationMessage
 {
 	int32 RpcId = 1;
 	int32 N = 2;

+ 0 - 3
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneChangeHelper.cs

@@ -14,17 +14,14 @@
          
             // 可以订阅这个事件中创建Loading界面
             EventSystem.Instance.Publish(clientScene, new EventType.SceneChangeStart());
-
             // 等待CreateMyUnit的消息
             Wait_CreateMyUnit waitCreateMyUnit = await clientScene.GetComponent<ObjectWait>().Wait<Wait_CreateMyUnit>();
             M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
             Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
             unitComponent.Add(unit);
-            
             clientScene.RemoveComponent<AIComponent>();
             
             EventSystem.Instance.Publish(currentScene, new EventType.SceneChangeFinish());
-
             // 通知等待场景切换的协程
             clientScene.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
         }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/SessionComponentSystem.cs

@@ -4,7 +4,7 @@
 	{
 		protected override void Destroy(SessionComponent self)
 		{
-			self.Session.Dispose();
+			self.Session?.Dispose();
 		}
 	}
 }

+ 6 - 33
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/MessageHelper.cs

@@ -21,30 +21,25 @@ namespace ET.Server
             MessageHelper.SendToClient(unit, removeUnits);
         }
         
-        public static void Broadcast(Unit unit, IActorMessage message)
+        public static void Broadcast(Unit unit, IActorLocationMessage message)
         {
             Dictionary<long, AOIEntity> dict = unit.GetBeSeePlayers();
             // 网络底层做了优化,同一个消息不会多次序列化
             foreach (AOIEntity u in dict.Values)
             {
-                ActorMessageSenderComponent.Instance.Send(u.Unit.GetComponent<UnitGateComponent>().GateSessionActorId, message);
+                ActorLocationSenderComponent.Instance.Get(LocationType.Player).Send(u.Unit.Id, message);
             }
         }
         
-        public static void SendToClient(Unit unit, IActorMessage message)
+        public static void SendToClient(Unit unit, IActorLocationMessage message)
         {
-            SendActor(unit.GetComponent<UnitGateComponent>().GateSessionActorId, message);
+            SendToLocationActor(LocationType.Player, unit.Id, message);
         }
         
         
-        /// <summary>
-        /// 发送协议给ActorLocation
-        /// </summary>
-        /// <param name="id">注册Actor的Id</param>
-        /// <param name="message"></param>
-        public static void SendToLocationActor(long id, IActorLocationMessage message)
+        public static void SendToLocationActor(int locationType, long id, IActorLocationMessage message)
         {
-            ActorLocationSenderComponent.Instance.Send(id, message);
+            ActorLocationSenderComponent.Instance.Get(locationType).Send(id, message);
         }
         
         /// <summary>
@@ -56,27 +51,5 @@ namespace ET.Server
         {
             ActorMessageSenderComponent.Instance.Send(actorId, message);
         }
-        
-        /// <summary>
-        /// 发送RPC协议给Actor
-        /// </summary>
-        /// <param name="actorId">注册Actor的InstanceId</param>
-        /// <param name="message"></param>
-        /// <returns></returns>
-        public static async ETTask<IActorResponse> CallActor(long actorId, IActorRequest message)
-        {
-            return await ActorMessageSenderComponent.Instance.Call(actorId, message);
-        }
-        
-        /// <summary>
-        /// 发送RPC协议给ActorLocation
-        /// </summary>
-        /// <param name="id">注册Actor的Id</param>
-        /// <param name="message"></param>
-        /// <returns></returns>
-        public static async ETTask<IActorResponse> CallLocationActor(long id, IActorLocationRequest message)
-        {
-            return await ActorLocationSenderComponent.Instance.Call(id, message);
-        }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs

@@ -36,7 +36,7 @@ namespace ET.Server
                     scene.AddComponent<AOIManagerComponent>();
                     break;
                 case SceneType.Location:
-                    scene.AddComponent<LocationComponent>();
+                    scene.AddComponent<LocationManagerComoponent>();
                     break;
                 case SceneType.Robot:
                     scene.AddComponent<RobotManagerComponent>();

+ 1 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs

@@ -5,7 +5,7 @@
 	{
 		protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response)
 		{
-			Player player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
+			Player player = session.GetComponent<SessionPlayerComponent>().Player;
 
 			// 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
 			GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
@@ -15,7 +15,6 @@
 			
 			// 这里可以从DB中加载Unit
 			Unit unit = UnitFactory.Create(scene, player.Id, UnitType.Player);
-			unit.AddComponent<UnitGateComponent, long>(session.InstanceId);
 			
 			StartSceneConfig startSceneConfig = StartSceneConfigCategory.Instance.GetBySceneName(session.DomainZone(), "Map1");
 			response.MyId = player.Id;

+ 5 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs

@@ -21,9 +21,11 @@ namespace ET.Server
 
 			PlayerComponent playerComponent = scene.GetComponent<PlayerComponent>();
 			Player player = playerComponent.AddChild<Player, string>(account);
-			playerComponent.Add(player);
-			session.AddComponent<SessionPlayerComponent>().PlayerId = player.Id;
-			session.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
+			player.AddComponent<SessionInfoComponent>().Session = session;
+			player.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
+			await player.AddLocation(LocationType.Player);
+			
+			session.AddComponent<SessionPlayerComponent>().Player = player;
 
 			response.PlayerId = player.Id;
 			await ETTask.CompletedTask;

+ 0 - 20
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/PlayerComponentSystem.cs

@@ -5,25 +5,5 @@ namespace ET.Server
     [FriendOf(typeof(PlayerComponent))]
     public static class PlayerComponentSystem
     {
-        public static void Add(this PlayerComponent self, Player player)
-        {
-            self.idPlayers.Add(player.Id, player);
-        }
-
-        public static Player Get(this PlayerComponent self, long id)
-        {
-            self.idPlayers.TryGetValue(id, out Player gamer);
-            return gamer;
-        }
-
-        public static void Remove(this PlayerComponent self, long id)
-        {
-            self.idPlayers.Remove(id);
-        }
-
-        public static Player[] GetAll(this PlayerComponent self)
-        {
-            return self.idPlayers.Values.ToArray();
-        }
     }
 }

+ 2 - 7
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/SessionPlayerComponentSystem.cs

@@ -9,14 +9,9 @@ namespace ET.Server
 			protected override void Destroy(SessionPlayerComponent self)
 			{
 				// 发送断线消息
-				ActorLocationSenderComponent.Instance?.Send(self.PlayerId, new G2M_SessionDisconnect());
-				self.DomainScene().GetComponent<PlayerComponent>()?.Remove(self.PlayerId);
+				ActorLocationSenderComponent.Instance?.Get(LocationType.Unit)?.Send(self.Player.Id, new G2M_SessionDisconnect());
+				self.DomainScene().GetComponent<PlayerComponent>()?.RemoveChild(self.Player.Id);
 			}
 		}
-
-		public static Player GetMyPlayer(this SessionPlayerComponent self)
-		{
-			return self.DomainScene().GetComponent<PlayerComponent>().Get(self.PlayerId);
-		}
 	}
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -39,7 +39,7 @@ namespace ET.Server
 			unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);
 			
 			// 解锁location,可以接收发给Unit的消息
-			await LocationProxyComponent.Instance.UnLock(unit.Id, request.OldInstanceId, unit.InstanceId);
+			await LocationProxyComponent.Instance.UnLock(LocationType.Unit, unit.Id, request.OldInstanceId, unit.InstanceId);
 		}
 	}
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs

@@ -31,7 +31,7 @@ namespace ET.Server
             }
             unit.Dispose();
             
-            await LocationProxyComponent.Instance.Lock(unitId, unitInstanceId);
+            await LocationProxyComponent.Instance.Lock(LocationType.Unit, unitId, unitInstanceId);
             await ActorMessageSenderComponent.Instance.Call(sceneInstanceId, request);
         }
     }

+ 0 - 13
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitGateComponentSystem.cs

@@ -1,13 +0,0 @@
-namespace ET.Server
-{
-    public static class UnitGateComponentSystem
-    {
-        public class UnitGateComponentAwakeSystem : AwakeSystem<UnitGateComponent, long>
-        {
-            protected override void Awake(UnitGateComponent self, long a)
-            {
-                self.GateSessionActorId = a;
-            }
-        }
-    }
-}

+ 4 - 4
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetServerComponentOnReadEvent.cs

@@ -19,10 +19,10 @@
             {
                 case IActorLocationRequest actorLocationRequest: // gate session收到actor rpc消息,先向actor 发送rpc请求,再将请求结果返回客户端
                 {
-                    long unitId = session.GetComponent<SessionPlayerComponent>().PlayerId;
+                    long unitId = session.GetComponent<SessionPlayerComponent>().Player.Id;
                     int rpcId = actorLocationRequest.RpcId; // 这里要保存客户端的rpcId
                     long instanceId = session.InstanceId;
-                    IResponse iResponse = await ActorLocationSenderComponent.Instance.Call(unitId, actorLocationRequest);
+                    IResponse iResponse = await ActorLocationSenderComponent.Instance.Get(LocationType.Unit).Call(unitId, actorLocationRequest);
                     iResponse.RpcId = rpcId;
                     // session可能已经断开了,所以这里需要判断
                     if (session.InstanceId == instanceId)
@@ -33,8 +33,8 @@
                 }
                 case IActorLocationMessage actorLocationMessage:
                 {
-                    long unitId = session.GetComponent<SessionPlayerComponent>().PlayerId;
-                    ActorLocationSenderComponent.Instance.Send(unitId, actorLocationMessage);
+                    long unitId = session.GetComponent<SessionPlayerComponent>().Player.Id;
+                    ActorLocationSenderComponent.Instance.Get(LocationType.Unit).Send(unitId, actorLocationMessage);
                     break;
                 }
                 case IActorRequest actorRequest:  // 分发IActorRequest消息,目前没有用到,需要的自己添加

+ 9 - 5
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorHandleHelper.cs

@@ -72,6 +72,15 @@ namespace ET.Server
                     break;
                 }
                 case MailboxType.GateSession:
+                {
+                    if (entity is Player player)
+                    {
+                        player.GetComponent<SessionInfoComponent>()?.Session?.Send(iActorRequest);
+                    }
+                    IActorResponse response = ActorHelper.CreateResponse(iActorRequest, 0);
+                    Reply(fromProcess, response);
+                    break;
+                }
                 default:
                     throw new Exception($"no mailboxtype: {mailBoxComponent.MailboxType} {iActorRequest}");
             }
@@ -123,11 +132,6 @@ namespace ET.Server
                 }
                 case MailboxType.GateSession:
                 {
-                    if (entity is Session gateSession)
-                    {
-                        // 发送给客户端
-                        gateSession.Send(iActorMessage);
-                    }
                     break;
                 }
                 default:

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageDispatcherComponentSystem.cs

@@ -98,7 +98,7 @@ namespace ET.Server
             List<ActorMessageDispatcherInfo> list;
             if (!self.ActorMessageHandlers.TryGetValue(message.GetType(), out list))
             {
-                throw new Exception($"not found message handler: {message}");
+                throw new Exception($"not found message handler: {message} {entity.GetType().Name}");
             }
 
             SceneType sceneType = entity.DomainScene().SceneType;

+ 69 - 40
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ActorLocationSenderComponentSystem.cs

@@ -4,50 +4,48 @@ using MongoDB.Bson;
 
 namespace ET.Server
 {
-    [Invoke(TimerInvokeType.ActorLocationSenderChecker)]
-    public class ActorLocationSenderChecker: ATimer<ActorLocationSenderComponent>
+    [FriendOf(typeof(ActorLocationSenderOneType))]
+    [FriendOf(typeof(ActorLocationSender))]
+    public static class ActorLocationSenderComponentSystem
     {
-        protected override void Run(ActorLocationSenderComponent self)
+        [Invoke(TimerInvokeType.ActorLocationSenderChecker)]
+        public class ActorLocationSenderChecker: ATimer<ActorLocationSenderOneType>
         {
-            try
+            protected override void Run(ActorLocationSenderOneType self)
             {
-                self.Check();
-            }
-            catch (Exception e)
-            {
-                Log.Error($"move timer error: {self.Id}\n{e}");
+                try
+                {
+                    self.Check();
+                }
+                catch (Exception e)
+                {
+                    Log.Error($"move timer error: {self.Id}\n{e}");
+                }
             }
         }
-    }
     
-    [ObjectSystem]
-    public class ActorLocationSenderComponentAwakeSystem: AwakeSystem<ActorLocationSenderComponent>
-    {
-        protected override void Awake(ActorLocationSenderComponent self)
+        [ObjectSystem]
+        public class AwakeSystem: AwakeSystem<ActorLocationSenderOneType, int>
         {
-            ActorLocationSenderComponent.Instance = self;
-
-            // 每10s扫描一次过期的actorproxy进行回收,过期时间是2分钟
-            // 可能由于bug或者进程挂掉,导致ActorLocationSender发送的消息没有确认,结果无法自动删除,每一分钟清理一次这种ActorLocationSender
-            self.CheckTimer = TimerComponent.Instance.NewRepeatedTimer(10 * 1000, TimerInvokeType.ActorLocationSenderChecker, self);
+            protected override void Awake(ActorLocationSenderOneType self, int locationType)
+            {
+                self.LocationType = locationType;
+                // 每10s扫描一次过期的actorproxy进行回收,过期时间是2分钟
+                // 可能由于bug或者进程挂掉,导致ActorLocationSender发送的消息没有确认,结果无法自动删除,每一分钟清理一次这种ActorLocationSender
+                self.CheckTimer = TimerComponent.Instance.NewRepeatedTimer(10 * 1000, TimerInvokeType.ActorLocationSenderChecker, self);
+            }
         }
-    }
 
-    [ObjectSystem]
-    public class ActorLocationSenderComponentDestroySystem: DestroySystem<ActorLocationSenderComponent>
-    {
-        protected override void Destroy(ActorLocationSenderComponent self)
+        [ObjectSystem]
+        public class DestroySystem: DestroySystem<ActorLocationSenderOneType>
         {
-            ActorLocationSenderComponent.Instance = null;
-            TimerComponent.Instance?.Remove(ref self.CheckTimer);
+            protected override void Destroy(ActorLocationSenderOneType self)
+            {
+                TimerComponent.Instance?.Remove(ref self.CheckTimer);
+            }
         }
-    }
-
-    [FriendOf(typeof(ActorLocationSenderComponent))]
-    [FriendOf(typeof(ActorLocationSender))]
-    public static class ActorLocationSenderComponentSystem
-    {
-        public static void Check(this ActorLocationSenderComponent self)
+        
+        public static void Check(this ActorLocationSenderOneType self)
         {
             using (ListComponent<long> list = ListComponent<long>.Create())
             {
@@ -56,7 +54,7 @@ namespace ET.Server
                 {
                     ActorLocationSender actorLocationMessageSender = (ActorLocationSender) value;
 
-                    if (timeNow > actorLocationMessageSender.LastSendOrRecvTime + ActorLocationSenderComponent.TIMEOUT_TIME)
+                    if (timeNow > actorLocationMessageSender.LastSendOrRecvTime + ActorLocationSenderOneType.TIMEOUT_TIME)
                     {
                         list.Add(key);
                     }
@@ -69,7 +67,7 @@ namespace ET.Server
             }
         }
 
-        private static ActorLocationSender GetOrCreate(this ActorLocationSenderComponent self, long id)
+        private static ActorLocationSender GetOrCreate(this ActorLocationSenderOneType self, long id)
         {
             if (id == 0)
             {
@@ -85,7 +83,7 @@ namespace ET.Server
             return (ActorLocationSender) actorLocationSender;
         }
 
-        private static void Remove(this ActorLocationSenderComponent self, long id)
+        private static void Remove(this ActorLocationSenderOneType self, long id)
         {
             if (!self.Children.TryGetValue(id, out Entity actorMessageSender))
             {
@@ -95,12 +93,12 @@ namespace ET.Server
             actorMessageSender.Dispose();
         }
 
-        public static void Send(this ActorLocationSenderComponent self, long entityId, IActorRequest message)
+        public static void Send(this ActorLocationSenderOneType self, long entityId, IActorRequest message)
         {
             self.Call(entityId, message).Coroutine();
         }
 
-        public static async ETTask<IActorResponse> Call(this ActorLocationSenderComponent self, long entityId, IActorRequest iActorRequest)
+        public static async ETTask<IActorResponse> Call(this ActorLocationSenderOneType self, long entityId, IActorRequest iActorRequest)
         {
             ActorLocationSender actorLocationSender = self.GetOrCreate(entityId);
 
@@ -139,7 +137,7 @@ namespace ET.Server
             }
         }
 
-        private static async ETTask<IActorResponse> CallInner(this ActorLocationSenderComponent self, ActorLocationSender actorLocationSender, int rpcId, IActorRequest iActorRequest)
+        private static async ETTask<IActorResponse> CallInner(this ActorLocationSenderOneType self, ActorLocationSender actorLocationSender, int rpcId, IActorRequest iActorRequest)
         {
             int failTimes = 0;
             long instanceId = actorLocationSender.InstanceId;
@@ -149,7 +147,7 @@ namespace ET.Server
             {
                 if (actorLocationSender.ActorId == 0)
                 {
-                    actorLocationSender.ActorId = await LocationProxyComponent.Instance.Get(actorLocationSender.Id);
+                    actorLocationSender.ActorId = await LocationProxyComponent.Instance.Get(self.LocationType, actorLocationSender.Id);
                     if (actorLocationSender.InstanceId != instanceId)
                     {
                         throw new RpcException(ErrorCore.ERR_ActorLocationSenderTimeout2, $"{iActorRequest}");
@@ -206,4 +204,35 @@ namespace ET.Server
             }
         }
     }
+
+    [FriendOf(typeof (ActorLocationSenderComponent))]
+    public static class ActorLocationSenderManagerComponentSystem
+    {
+        [ObjectSystem]
+        public class AwakeSystem: AwakeSystem<ActorLocationSenderComponent>
+        {
+            protected override void Awake(ActorLocationSenderComponent self)
+            {
+                ActorLocationSenderComponent.Instance = self;
+                for (int i = 0; i < self.ActorLocationSenderComponents.Length; ++i)
+                {
+                    self.ActorLocationSenderComponents[i] = self.AddChild<ActorLocationSenderOneType, int>(i);
+                }
+            }
+        }
+
+        [ObjectSystem]
+        public class DestroySystem: DestroySystem<ActorLocationSenderComponent>
+        {
+            protected override void Destroy(ActorLocationSenderComponent self)
+            {
+                ActorLocationSenderComponent.Instance = null;
+            }
+        }
+        
+        public static ActorLocationSenderOneType Get(this ActorLocationSenderComponent self, int locationType)
+        {
+            return self.ActorLocationSenderComponents[locationType];
+        }
+    }
 }

+ 0 - 11
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationComponentSystem.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 56cc9ee06032d814c922dfa91e0976cd
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 49 - 12
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs

@@ -1,4 +1,6 @@
-namespace ET.Server
+using System;
+
+namespace ET.Server
 {
     [ObjectSystem]
     public class LockInfoAwakeSystem: AwakeSystem<LockInfo, long, CoroutineLock>
@@ -20,31 +22,43 @@
         }
     }
     
-    [FriendOf(typeof(LocationComponent))]
+    [FriendOf(typeof(LocationOneType))]
     [FriendOf(typeof(LockInfo))]
-    public static class LocationComponentSystem
+    public static class LocationOneTypeSystem
     {
-        public static async ETTask Add(this LocationComponent self, long key, long instanceId)
+        [ObjectSystem]
+        public class LocationOneTypeAwakeSystem: AwakeSystem<LocationOneType, int>
+        {
+            protected override void Awake(LocationOneType self, int locationType)
+            {
+                self.LocationType = locationType;
+            }
+        }
+        
+        public static async ETTask Add(this LocationOneType self, long key, long instanceId)
         {
-            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key))
+            int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
+            using (await CoroutineLockComponent.Instance.Wait(coroutineLockType, key))
             {
                 self.locations[key] = instanceId;
                 Log.Info($"location add key: {key} instanceId: {instanceId}");
             }
         }
 
-        public static async ETTask Remove(this LocationComponent self, long key)
+        public static async ETTask Remove(this LocationOneType self, long key)
         {
-            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key))
+            int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
+            using (await CoroutineLockComponent.Instance.Wait(coroutineLockType, key))
             {
                 self.locations.Remove(key);
                 Log.Info($"location remove key: {key}");
             }
         }
 
-        public static async ETTask Lock(this LocationComponent self, long key, long instanceId, int time = 0)
+        public static async ETTask Lock(this LocationOneType self, long key, long instanceId, int time = 0)
         {
-            CoroutineLock coroutineLock = await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key);
+            int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
+            CoroutineLock coroutineLock = await CoroutineLockComponent.Instance.Wait(coroutineLockType, key);
 
             LockInfo lockInfo = self.AddChild<LockInfo, long, CoroutineLock>(instanceId, coroutineLock);
             self.lockInfos.Add(key, lockInfo);
@@ -68,7 +82,7 @@
             }
         }
 
-        public static void UnLock(this LocationComponent self, long key, long oldInstanceId, long newInstanceId)
+        public static void UnLock(this LocationOneType self, long key, long oldInstanceId, long newInstanceId)
         {
             if (!self.lockInfos.TryGetValue(key, out LockInfo lockInfo))
             {
@@ -92,9 +106,10 @@
             lockInfo.Dispose();
         }
 
-        public static async ETTask<long> Get(this LocationComponent self, long key)
+        public static async ETTask<long> Get(this LocationOneType self, long key)
         {
-            using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key))
+            int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
+            using (await CoroutineLockComponent.Instance.Wait(coroutineLockType, key))
             {
                 self.locations.TryGetValue(key, out long instanceId);
                 Log.Info($"location get key: {key} instanceId: {instanceId}");
@@ -102,4 +117,26 @@
             }
         }
     }
+
+
+    [FriendOf(typeof (LocationManagerComoponent))]
+    public static class LocationComoponentSystem
+    {
+        [ObjectSystem]
+        public class AwakeSystem: AwakeSystem<LocationManagerComoponent>
+        {
+            protected override void Awake(LocationManagerComoponent self)
+            {
+                for (int i = 0; i < self.LocationOneTypes.Length; ++i)
+                {
+                    self.LocationOneTypes[i] = self.AddChild<LocationOneType, int>(i);
+                }
+            }
+        }
+        
+        public static LocationOneType Get(this LocationManagerComoponent self, int locationType)
+        {
+            return self.LocationOneTypes[locationType];
+        }
+    }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Unit/UnitGateComponent.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 53531ea67172a81479588e30942a2df9
+guid: c4a35bb25143640b1a80652d551b4ce9
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 14 - 14
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationProxyComponentSystem.cs

@@ -27,35 +27,35 @@ namespace ET.Server
             return StartSceneConfigCategory.Instance.LocationConfig.InstanceId;
         }
 
-        public static async ETTask Add(this LocationProxyComponent self, long key, long instanceId)
+        public static async ETTask Add(this LocationProxyComponent self, int type, long key, long instanceId)
         {
             Log.Info($"location proxy add {key}, {instanceId} {TimeHelper.ServerNow()}");
             await ActorMessageSenderComponent.Instance.Call(GetLocationSceneId(key),
-                new ObjectAddRequest() { Key = key, InstanceId = instanceId });
+                new ObjectAddRequest() { Type = type, Key = key, InstanceId = instanceId });
         }
 
-        public static async ETTask Lock(this LocationProxyComponent self, long key, long instanceId, int time = 60000)
+        public static async ETTask Lock(this LocationProxyComponent self, int type, long key, long instanceId, int time = 60000)
         {
             Log.Info($"location proxy lock {key}, {instanceId} {TimeHelper.ServerNow()}");
             await ActorMessageSenderComponent.Instance.Call(GetLocationSceneId(key),
-                new ObjectLockRequest() { Key = key, InstanceId = instanceId, Time = time });
+                new ObjectLockRequest() { Type = type, Key = key, InstanceId = instanceId, Time = time });
         }
 
-        public static async ETTask UnLock(this LocationProxyComponent self, long key, long oldInstanceId, long instanceId)
+        public static async ETTask UnLock(this LocationProxyComponent self, int type, long key, long oldInstanceId, long instanceId)
         {
             Log.Info($"location proxy unlock {key}, {instanceId} {TimeHelper.ServerNow()}");
             await ActorMessageSenderComponent.Instance.Call(GetLocationSceneId(key),
-                new ObjectUnLockRequest() { Key = key, OldInstanceId = oldInstanceId, InstanceId = instanceId });
+                new ObjectUnLockRequest() { Type = type, Key = key, OldInstanceId = oldInstanceId, InstanceId = instanceId });
         }
 
-        public static async ETTask Remove(this LocationProxyComponent self, long key)
+        public static async ETTask Remove(this LocationProxyComponent self, int type, long key)
         {
             Log.Info($"location proxy add {key}, {TimeHelper.ServerNow()}");
             await ActorMessageSenderComponent.Instance.Call(GetLocationSceneId(key),
-                new ObjectRemoveRequest() { Key = key });
+                new ObjectRemoveRequest() { Type = type, Key = key });
         }
 
-        public static async ETTask<long> Get(this LocationProxyComponent self, long key)
+        public static async ETTask<long> Get(this LocationProxyComponent self, int type, long key)
         {
             if (key == 0)
             {
@@ -65,18 +65,18 @@ namespace ET.Server
             // location server配置到共享区,一个大战区可以配置N多个location server,这里暂时为1
             ObjectGetResponse response =
                     (ObjectGetResponse) await ActorMessageSenderComponent.Instance.Call(GetLocationSceneId(key),
-                        new ObjectGetRequest() { Key = key });
+                        new ObjectGetRequest() { Type = type, Key = key });
             return response.InstanceId;
         }
 
-        public static async ETTask AddLocation(this Entity self)
+        public static async ETTask AddLocation(this Entity self, int type)
         {
-            await LocationProxyComponent.Instance.Add(self.Id, self.InstanceId);
+            await LocationProxyComponent.Instance.Add(type, self.Id, self.InstanceId);
         }
 
-        public static async ETTask RemoveLocation(this Entity self)
+        public static async ETTask RemoveLocation(this Entity self, int type)
         {
-            await LocationProxyComponent.Instance.Remove(self.Id);
+            await LocationProxyComponent.Instance.Remove(type, self.Id);
         }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         protected override async ETTask Run(Scene scene, ObjectAddRequest request, ObjectAddResponse response)
         {
-            await scene.GetComponent<LocationComponent>().Add(request.Key, request.InstanceId);
+            await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Add(request.Key, request.InstanceId);
         }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         protected override async ETTask Run(Scene scene, ObjectGetRequest request, ObjectGetResponse response)
         {
-            long instanceId = await scene.GetComponent<LocationComponent>().Get(request.Key);
+            long instanceId = await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Get(request.Key);
             response.InstanceId = instanceId;
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         protected override async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response)
         {
-            await scene.GetComponent<LocationComponent>().Lock(request.Key, request.InstanceId, request.Time);
+            await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Lock(request.Key, request.InstanceId, request.Time);
         }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         protected override async ETTask Run(Scene scene, ObjectRemoveRequest request, ObjectRemoveResponse response)
         {
-            await scene.GetComponent<LocationComponent>().Remove(request.Key);
+            await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Remove(request.Key);
         }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         protected override async ETTask Run(Scene scene, ObjectUnLockRequest request, ObjectUnLockResponse response)
         {
-            scene.GetComponent<LocationComponent>().UnLock(request.Key, request.OldInstanceId, request.InstanceId);
+            scene.GetComponent<LocationManagerComoponent>().Get(request.Type).UnLock(request.Key, request.OldInstanceId, request.InstanceId);
 
             await ETTask.CompletedTask;
         }

+ 13 - 1
Unity/Assets/Scripts/Codes/Model/Client/Demo/Session/SessionComponent.cs

@@ -3,6 +3,18 @@
 	[ComponentOf(typeof(Scene))]
 	public class SessionComponent: Entity, IAwake, IDestroy
 	{
-		public Session Session { get; set; }
+		private long sessionInstanceId;
+
+		public Session Session
+		{
+			get
+			{
+				return Root.Instance.Get(this.sessionInstanceId) as Session;
+			}
+			set
+			{
+				this.sessionInstanceId = value.InstanceId;
+			}
+		}
 	}
 }

+ 31 - 13
Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs

@@ -159,38 +159,50 @@ namespace ET
 
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public List<UnitInfo> Units { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public UnitInfo Unit { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long SceneInstanceId { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public long SceneInstanceId { get; set; }
+
+		[ProtoMember(3)]
 		public string SceneName { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: ProtoObject, IActorLocationMessage
 	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
 		[ProtoMember(2)]
 		public List<long> Units { get; set; }
 
@@ -219,33 +231,39 @@ namespace ET
 
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long Id { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(3)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(4)]
 		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public int Error { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Id { get; set; }
+		public int Error { get; set; }
 
 		[ProtoMember(3)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(4)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(5)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
 
 	}
@@ -443,7 +461,7 @@ namespace ET
 
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorMessage
+	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }

+ 23 - 5
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs

@@ -116,9 +116,12 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
+		public long Key { get; set; }
+
+		[ProtoMember(4)]
 		public long InstanceId { get; set; }
 
 	}
@@ -147,12 +150,15 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
-		public long InstanceId { get; set; }
+		public long Key { get; set; }
 
 		[ProtoMember(4)]
+		public long InstanceId { get; set; }
+
+		[ProtoMember(5)]
 		public int Time { get; set; }
 
 	}
@@ -181,12 +187,15 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
-		public long OldInstanceId { get; set; }
+		public long Key { get; set; }
 
 		[ProtoMember(4)]
+		public long OldInstanceId { get; set; }
+
+		[ProtoMember(5)]
 		public long InstanceId { get; set; }
 
 	}
@@ -215,6 +224,9 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public int Type { get; set; }
+
+		[ProtoMember(3)]
 		public long Key { get; set; }
 
 	}
@@ -243,6 +255,9 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public int Type { get; set; }
+
+		[ProtoMember(3)]
 		public long Key { get; set; }
 
 	}
@@ -261,6 +276,9 @@ namespace ET
 		public string Message { get; set; }
 
 		[ProtoMember(4)]
+		public int Type { get; set; }
+
+		[ProtoMember(5)]
 		public long InstanceId { get; set; }
 
 	}

+ 31 - 13
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs

@@ -159,38 +159,50 @@ namespace ET
 
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public List<UnitInfo> Units { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public UnitInfo Unit { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long SceneInstanceId { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public long SceneInstanceId { get; set; }
+
+		[ProtoMember(3)]
 		public string SceneName { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: ProtoObject, IActorLocationMessage
 	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
 		[ProtoMember(2)]
 		public List<long> Units { get; set; }
 
@@ -219,33 +231,39 @@ namespace ET
 
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long Id { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(3)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(4)]
 		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public int Error { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Id { get; set; }
+		public int Error { get; set; }
 
 		[ProtoMember(3)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(4)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(5)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
 
 	}
@@ -443,7 +461,7 @@ namespace ET
 
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorMessage
+	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }

+ 23 - 5
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs

@@ -116,9 +116,12 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
+		public long Key { get; set; }
+
+		[ProtoMember(4)]
 		public long InstanceId { get; set; }
 
 	}
@@ -147,12 +150,15 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
-		public long InstanceId { get; set; }
+		public long Key { get; set; }
 
 		[ProtoMember(4)]
+		public long InstanceId { get; set; }
+
+		[ProtoMember(5)]
 		public int Time { get; set; }
 
 	}
@@ -181,12 +187,15 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Key { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(3)]
-		public long OldInstanceId { get; set; }
+		public long Key { get; set; }
 
 		[ProtoMember(4)]
+		public long OldInstanceId { get; set; }
+
+		[ProtoMember(5)]
 		public long InstanceId { get; set; }
 
 	}
@@ -215,6 +224,9 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public int Type { get; set; }
+
+		[ProtoMember(3)]
 		public long Key { get; set; }
 
 	}
@@ -243,6 +255,9 @@ namespace ET
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public int Type { get; set; }
+
+		[ProtoMember(3)]
 		public long Key { get; set; }
 
 	}
@@ -261,6 +276,9 @@ namespace ET
 		public string Message { get; set; }
 
 		[ProtoMember(4)]
+		public int Type { get; set; }
+
+		[ProtoMember(5)]
 		public long InstanceId { get; set; }
 
 	}

+ 31 - 13
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs

@@ -159,38 +159,50 @@ namespace ET
 
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public List<UnitInfo> Units { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
 		public UnitInfo Unit { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long SceneInstanceId { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
+		public long SceneInstanceId { get; set; }
+
+		[ProtoMember(3)]
 		public string SceneName { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: ProtoObject, IActorLocationMessage
 	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
 		[ProtoMember(2)]
 		public List<long> Units { get; set; }
 
@@ -219,33 +231,39 @@ namespace ET
 
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public long Id { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(3)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(4)]
 		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
-		public int Error { get; set; }
+		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public long Id { get; set; }
+		public int Error { get; set; }
 
 		[ProtoMember(3)]
-		public Unity.Mathematics.float3 Position { get; set; }
+		public long Id { get; set; }
 
 		[ProtoMember(4)]
+		public Unity.Mathematics.float3 Position { get; set; }
+
+		[ProtoMember(5)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
 
 	}
@@ -443,7 +461,7 @@ namespace ET
 
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorMessage
+	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }

+ 0 - 1
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerComponent.cs

@@ -6,6 +6,5 @@ namespace ET.Server
 	[ComponentOf(typeof(Scene))]
 	public class PlayerComponent : Entity, IAwake, IDestroy
 	{
-		public readonly Dictionary<long, Player> idPlayers = new Dictionary<long, Player>();
 	}
 }

+ 15 - 2
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionInfoComponent.cs

@@ -1,7 +1,20 @@
 namespace ET.Server
 {
-	public class SessionInfoComponent : Entity
+	[ComponentOf(typeof(Player))]
+	public class SessionInfoComponent : Entity, IAwake
 	{
-		public Session Session;
+		private long sessionInstanceId;
+
+		public Session Session
+		{
+			get
+			{
+				return Root.Instance.Get(this.sessionInstanceId) as Session;
+			}
+			set
+			{
+				this.sessionInstanceId = value.InstanceId;
+			}
+		}
 	}
 }

+ 13 - 1
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionPlayerComponent.cs

@@ -3,6 +3,18 @@
 	[ComponentOf(typeof(Session))]
 	public class SessionPlayerComponent : Entity, IAwake, IDestroy
 	{
-		public long PlayerId { get; set; }
+		private long playerInstanceId;
+
+		public Player Player
+		{
+			get
+			{
+				return Root.Instance.Get(this.playerInstanceId) as Player;
+			}
+			set
+			{
+				this.playerInstanceId = value.InstanceId;
+			}
+		}
 	}
 }

+ 0 - 8
Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Unit/UnitGateComponent.cs

@@ -1,8 +0,0 @@
-namespace ET.Server
-{
-    [ComponentOf(typeof(Unit))]
-    public class UnitGateComponent : Entity, IAwake<long>, ITransfer
-    {
-        public long GateSessionActorId { get; set; }
-    }
-}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSender.cs

@@ -3,7 +3,7 @@
 namespace ET.Server
 {
     // 知道对方的Id,使用这个类发actor消息
-    [ChildOf(typeof(ActorLocationSenderComponent))]
+    [ChildOf(typeof(ActorLocationSenderOneType))]
     public class ActorLocationSender: Entity, IAwake, IDestroy
     {
         public long ActorId;

+ 0 - 15
Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderComponent.cs

@@ -1,15 +0,0 @@
-using System.Collections.Generic;
-
-namespace ET.Server
-{
-    
-    [ComponentOf(typeof(Scene))]
-    public class ActorLocationSenderComponent: Entity, IAwake, IDestroy
-    {
-        public const long TIMEOUT_TIME = 60 * 1000;
-
-        public static ActorLocationSenderComponent Instance { get; set; }
-
-        public long CheckTimer;
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderComponent.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 19114b219bda30f4b9eee11debb49f52
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 28 - 0
Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderOneType.cs

@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+
+namespace ET.Server
+{
+    
+    [ChildOf(typeof(ActorLocationSenderComponent))]
+    public class ActorLocationSenderOneType: Entity, IAwake<int>, IDestroy
+    {
+        public const long TIMEOUT_TIME = 60 * 1000;
+
+        public long CheckTimer;
+
+        public int LocationType;
+    }
+    
+    
+    [ComponentOf(typeof(Scene))]
+    public class ActorLocationSenderComponent: Entity, IAwake, IDestroy
+    {
+        public const long TIMEOUT_TIME = 60 * 1000;
+
+        public static ActorLocationSenderComponent Instance { get; set; }
+
+        public long CheckTimer;
+
+        public ActorLocationSenderOneType[] ActorLocationSenderComponents = new ActorLocationSenderOneType[LocationType.Max];
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitGateComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/ActorLocationSenderOneType.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: befd9f6a3bef0024f85d0ff3e65dae37
+guid: fe4c532cd914d4ad498b494298be81b6
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 23 - 5
Unity/Assets/Scripts/Codes/Model/Server/Module/ActorLocation/LocationComponent.cs

@@ -1,20 +1,38 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
 
 namespace ET.Server
 {
-    [ChildOf(typeof(LocationComponent))]
+    [UniqueId(0, 100)]
+    public static class LocationType
+    {
+        public const int Unit = 0;
+        public const int Player = 1;
+        public const int Friend = 2;
+        public const int Chat = 3;
+        public const int Max = 100;
+    }
+    
+    [ChildOf(typeof(LocationOneType))]
     public class LockInfo: Entity, IAwake<long, CoroutineLock>, IDestroy
     {
         public long LockInstanceId;
 
         public CoroutineLock CoroutineLock;
     }
-    
-    [ComponentOf(typeof(Scene))]
-    public class LocationComponent: Entity, IAwake
+
+    [ChildOf(typeof(LocationManagerComoponent))]
+    public class LocationOneType: Entity, IAwake<int>
     {
+        public int LocationType;
+        
         public readonly Dictionary<long, long> locations = new Dictionary<long, long>();
 
         public readonly Dictionary<long, LockInfo> lockInfos = new Dictionary<long, LockInfo>();
     }
+
+    [ComponentOf(typeof(Scene))]
+    public class LocationManagerComoponent: Entity, IAwake
+    {
+        public LocationOneType[] LocationOneTypes = new LocationOneType[LocationType.Max];
+    }
 }

+ 13 - 13
Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -5,21 +5,11 @@ namespace ET
 {
     public class CoroutineLockComponent: Singleton<CoroutineLockComponent>, ISingletonUpdate
     {
-        private readonly List<CoroutineLockQueueType> list = new List<CoroutineLockQueueType>(CoroutineLockType.Max);
+        private readonly Dictionary<int, CoroutineLockQueueType> dictionary = new();
         private readonly Queue<(int, long, int)> nextFrameRun = new Queue<(int, long, int)>();
 
-        public CoroutineLockComponent()
-        {
-            for (int i = 0; i < CoroutineLockType.Max; ++i)
-            {
-                CoroutineLockQueueType coroutineLockQueueType = new CoroutineLockQueueType(i);
-                this.list.Add(coroutineLockQueueType);
-            }
-        }
-
         public override void Dispose()
         {
-            this.list.Clear();
             this.nextFrameRun.Clear();
         }
 
@@ -46,13 +36,23 @@ namespace ET
 
         public async ETTask<CoroutineLock> Wait(int coroutineLockType, long key, int time = 60000)
         {
-            CoroutineLockQueueType coroutineLockQueueType = this.list[coroutineLockType];
+            CoroutineLockQueueType coroutineLockQueueType;
+            if (!this.dictionary.TryGetValue(coroutineLockType, out coroutineLockQueueType))
+            {
+                coroutineLockQueueType = new CoroutineLockQueueType(coroutineLockType);
+                this.dictionary.Add(coroutineLockType, coroutineLockQueueType);
+            }
             return await coroutineLockQueueType.Wait(key, time);
         }
 
         private void Notify(int coroutineLockType, long key, int level)
         {
-            CoroutineLockQueueType coroutineLockQueueType = this.list[coroutineLockType];
+            CoroutineLockQueueType coroutineLockQueueType;
+            if (!this.dictionary.TryGetValue(coroutineLockType, out coroutineLockQueueType))
+            {
+                return;
+            }
+            
             coroutineLockQueueType.Notify(key, level);
         }
     }