Преглед на файлове

客户端切换场景完成

tanghai преди 2 години
родител
ревизия
3aacecf5fc
променени са 78 файла, в които са добавени 785 реда и са изтрити 78 реда
  1. 5 0
      DotNet/Hotfix/DotNet.Hotfix.csproj
  2. 1 8
      Unity/Assets/Config/Proto/LockStepInner_S_21001.proto
  3. 26 0
      Unity/Assets/Config/Proto/LockStepOuter_C_11001.proto
  4. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep.meta
  5. 12 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs
  6. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs.meta
  7. 32 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LockStepSceneChangeHelper.cs
  8. 11 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LockStepSceneChangeHelper.cs.meta
  9. 12 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs
  10. 11 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs.meta
  11. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Scene.meta
  12. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetServerComponentOnReadEvent.cs
  13. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep.meta
  14. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate.meta
  15. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs
  16. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs.meta
  17. 3 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs
  18. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs.meta
  19. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map.meta
  20. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room.meta
  21. 43 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/C2Room_ChangeSceneFinishHandler.cs
  22. 11 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/C2Room_ChangeSceneFinishHandler.cs.meta
  23. 2 3
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/Match2Map_GetRoomHandler.cs
  24. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/Match2Map_GetRoomHandler.cs.meta
  25. 21 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomComponentSystem.cs
  26. 11 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomComponentSystem.cs.meta
  27. 2 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomManagerComponentSystem.cs
  28. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomManagerComponentSystem.cs.meta
  29. 16 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomMessageHelper.cs
  30. 11 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomMessageHelper.cs.meta
  31. 8 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match.meta
  32. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs
  33. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs.meta
  34. 11 8
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/MatchComponentSystem.cs
  35. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/MatchComponentSystem.cs.meta
  36. 5 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorHandleHelper.cs
  37. 2 0
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageSenderComponentSystem.cs
  38. 0 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Message/NetInnerComponentSystem.cs
  39. 2 0
      Unity/Assets/Scripts/Codes/Hotfix/Share/ConstValue.cs
  40. 8 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep.meta
  41. 22 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs
  42. 11 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs.meta
  43. 8 0
      Unity/Assets/Scripts/Codes/Model/Client/LockStep.meta
  44. 12 0
      Unity/Assets/Scripts/Codes/Model/Client/LockStep/WaitType.cs
  45. 11 0
      Unity/Assets/Scripts/Codes/Model/Client/LockStep/WaitType.cs.meta
  46. 50 0
      Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/LockStepOuter_C_11001.cs
  47. 3 14
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepInner_S_21001.cs
  48. 50 0
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepOuter_C_11001.cs
  49. 3 14
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepInner_S_21001.cs
  50. 50 0
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepOuter_C_11001.cs
  51. 0 2
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/Player.cs
  52. 20 0
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerSessionComponent.cs
  53. 11 0
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerSessionComponent.cs.meta
  54. 1 20
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionInfoComponent.cs
  55. 8 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep.meta
  56. 8 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate.meta
  57. 9 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate/PlayerRoomComponent.cs
  58. 11 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate/PlayerRoomComponent.cs.meta
  59. 8 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map.meta
  60. 8 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/Room.meta
  61. 10 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomComponent.cs
  62. 11 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomComponent.cs.meta
  63. 0 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomManagerComponent.cs
  64. 1 1
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomManagerComponent.cs.meta
  65. 10 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomPlayer.cs
  66. 11 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomPlayer.cs.meta
  67. 8 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match.meta
  68. 0 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match/MatchComponent.cs
  69. 0 0
      Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match/MatchComponent.cs.meta
  70. 8 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep.meta
  71. 13 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/EventType.cs
  72. 11 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/EventType.cs.meta
  73. 28 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/FUnit.cs
  74. 11 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/FUnit.cs.meta
  75. 7 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/IActorRoom.cs
  76. 11 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/IActorRoom.cs.meta
  77. 7 0
      Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs
  78. 7 0
      Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs

+ 5 - 0
DotNet/Hotfix/DotNet.Hotfix.csproj

@@ -40,5 +40,10 @@
         <ProjectReference Include="..\Loader\DotNet.Loader.csproj" />
         <ProjectReference Include="..\Model\DotNet.Model.csproj" />
     </ItemGroup>
+    <ItemGroup>
+      <Folder Include="..\..\Unity\Assets\Scripts\Codes\Hotfix\Server\LockStep\Map">
+        <Link>Server\LockStep\Map</Link>
+      </Folder>
+    </ItemGroup>
 
 </Project>

+ 1 - 8
Unity/Assets/Config/Proto/LockStepInner_S_21001.proto

@@ -23,6 +23,7 @@ message Match2G_Match // IActorResponse
 message Match2Map_GetRoom // IActorRequest
 {
 	int32 RpcId = 1;
+	map<int64, int64> PlayerInfo = 2;
 }
 
 message Map2Match_GetRoom // IActorResponse
@@ -33,12 +34,4 @@ message Map2Match_GetRoom // IActorResponse
 	
 	// 房间的instanceId
 	int64 InstanceId = 4;
-}
-
-message Match2G_NotifyMatchSuccess // IActorMessage
-{
-	int32 RpcId = 1;
-
-	// 房间的instanceId
-	int64 InstanceId = 2;
 }

+ 26 - 0
Unity/Assets/Config/Proto/LockStepOuter_C_11001.proto

@@ -14,3 +14,29 @@ message G2C_Match // IResponse
 	string Message = 3;
 }
 
+// 匹配成功,通知客户端切换场景
+message Match2G_NotifyMatchSuccess // IActorMessage
+{
+	// 房间的instanceId
+	int64 InstanceId = 1;
+}
+
+// 客户端通知房间切换场景完成
+message C2Room_ChangeSceneFinish // IActorRoom
+{
+	int64 PlayerId = 1;
+}
+
+message LockStepUnitInfo
+{
+	int64 PlayerId = 1;
+	TrueSync.TSVector Position = 2;
+	TrueSync.TSQuaternion Rotation = 3;
+}
+
+// 房间通知客户端进入战斗
+message Room2C_EnterMap // IActorMessage
+{
+	repeated LockStepUnitInfo UnitInfo = 1;
+}
+

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c99aac44889414b359c3c2427356076f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 12 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs

@@ -0,0 +1,12 @@
+namespace ET.Client
+{
+
+    [MessageHandler(SceneType.Client)]
+    public class Match2G_NotifyMatchSuccessHandler: AMHandler<Match2G_NotifyMatchSuccess>
+    {
+        protected override async ETTask Run(Session session, Match2G_NotifyMatchSuccess message)
+        {
+            await LockStepSceneChangeHelper.SceneChangeTo(session.DomainScene(), "Map1", message.InstanceId);
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionInfoComponent.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: a408bcdde79d9fb43a8418227d4297bc
+guid: cbf8b88a563eb46bfbaf987167d6a451
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 32 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LockStepSceneChangeHelper.cs

@@ -0,0 +1,32 @@
+namespace ET.Client
+{
+
+    public static class LockStepSceneChangeHelper
+    {
+        // 场景切换协程
+        public static async ETTask SceneChangeTo(Scene clientScene, string sceneName, long sceneInstanceId)
+        {
+            clientScene.RemoveComponent<AIComponent>();
+
+            CurrentScenesComponent currentScenesComponent = clientScene.GetComponent<CurrentScenesComponent>();
+            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
+            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, clientScene.Zone, sceneName, currentScenesComponent);
+
+            // 等待表现层订阅的事件完成
+            await EventSystem.Instance.PublishAsync(clientScene, new EventType.LockStepSceneChangeStart());
+
+            clientScene.GetComponent<SessionComponent>().Session.Send(new C2Room_ChangeSceneFinish());
+            
+            // 等待Room2C_EnterMap消息
+            WaitType.Wait_Room2C_EnterMap waitRoom2CEnterMap = await clientScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_Room2C_EnterMap>();
+            UnitComponent unitComponent = currentScene.GetComponent<UnitComponent>();
+            foreach (LockStepUnitInfo lockStepUnitInfo in waitRoom2CEnterMap.Message.UnitInfo)
+            {
+                FUnit unit = unitComponent.AddChild<FUnit>();
+                unit.Position = lockStepUnitInfo.Position;
+                unit.Rotation = lockStepUnitInfo.Rotation;
+            }
+            
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LockStepSceneChangeHelper.cs.meta

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

+ 12 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs

@@ -0,0 +1,12 @@
+namespace ET.Client
+{
+    [MessageHandler(SceneType.Client)]
+    public class Room2C_EnterMapHandler: AMHandler<Room2C_EnterMap>
+    {
+        protected override async ETTask Run(Session session, Room2C_EnterMap message)
+        {
+            session.DomainScene().GetComponent<ObjectWait>().Notify(new WaitType.Wait_Room2C_EnterMap() {Message = message});
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/Scene.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 67e9202dd1ddb43f3b92fbdf77ba6877
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

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

@@ -17,6 +17,14 @@
             // 根据消息接口判断是不是Actor消息,不同的接口做不同的处理,比如需要转发给Chat Scene,可以做一个IChatMessage接口
             switch (message)
             {
+                case IActorRoom actorRoom:
+                {
+                    Player player = session.GetComponent<SessionPlayerComponent>().Player;
+                    long roomInstanceId = player.GetComponent<PlayerRoomComponent>().RoomInstanceId;
+                    actorRoom.PlayerId = player.Id;
+                    ActorMessageSenderComponent.Instance.Send(roomInstanceId, actorRoom);
+                    break;
+                }
                 case IActorLocationMessage actorLocationMessage:
                 {
                     long unitId = session.GetComponent<SessionPlayerComponent>().Player.Id;

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: bad29a92a5a8b41f7b3ec3f4bd23bc34
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b29453dd6d8294ba982500d139b81ed5
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_MatchHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs

@@ -5,12 +5,12 @@
 	{
 		protected override async ETTask Run(Session session, C2G_Match request, G2C_Match response)
 		{
-			Player player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
+			Player player = session.GetComponent<SessionPlayerComponent>().Player;
 
 			StartSceneConfig startSceneConfig = StartSceneConfigCategory.Instance.Match;
 
 			await ActorMessageSenderComponent.Instance.Call(startSceneConfig.InstanceId,
-				new G2Match_Match() { InstanceId = player.InstanceId, Id = player.Id });
+				new G2Match_Match() { InstanceId = player.InstanceId, Id = session.InstanceId });
 		}
 	}
 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_MatchHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: b2cd4c6efaf2f43fba7c4abab2b8de00
+guid: 04a4b6c3a76cb4d53ab4655a2cc4f7eb
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 3 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/Match2G_NotifyMatchSuccessHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs

@@ -8,6 +8,9 @@ namespace ET.Server
 	{
 		protected override async ETTask Run(Player player, Match2G_NotifyMatchSuccess message)
 		{
+			player.AddComponent<PlayerRoomComponent>().RoomInstanceId = message.InstanceId;
+			
+			player.GetComponent<PlayerSessionComponent>().Session.Send(message);
 			await ETTask.CompletedTask;
 		}
 	}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/Match2G_NotifyMatchSuccessHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 100bb4b84e7e641feb8535ab6829dd3a
+guid: d2320b5939fd246359a4871b18ac94d8
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a86d2aec3f36c405fa581cf362886820
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d9bfa3831ad064782a79f4aaf93bcfa5
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/C2Room_ChangeSceneFinishHandler.cs

@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using TrueSync;
+
+namespace ET.Server
+{
+    [ActorMessageHandler(SceneType.Room)]
+    [FriendOf(typeof (RoomComponent))]
+    public class C2Room_ChangeSceneFinishHandler: AMActorHandler<Scene, C2Room_ChangeSceneFinish>
+    {
+        protected override async ETTask Run(Scene scene, C2Room_ChangeSceneFinish message)
+        {
+            RoomComponent roomComponent = scene.GetComponent<RoomComponent>();
+            RoomPlayer roomPlayer = scene.GetComponent<RoomComponent>().GetChild<RoomPlayer>(message.PlayerId);
+            roomPlayer.IsJoinRoom = true;
+            roomComponent.AlreadyJoinRoomCount++;
+
+            if (roomComponent.AlreadyJoinRoomCount <= ConstValue.MatchCount)
+            {
+                // 通知给已加进来的客户端每个玩家的进度
+            }
+
+            if (roomComponent.AlreadyJoinRoomCount == ConstValue.MatchCount)
+            {
+                await TimerComponent.Instance.WaitAsync(1000);
+
+                Room2C_EnterMap room2CEnterMap = new Room2C_EnterMap() {UnitInfo = new List<LockStepUnitInfo>()};
+                foreach (var kv in roomComponent.Children)
+                {
+                    room2CEnterMap.UnitInfo.Add(new LockStepUnitInfo()
+                    {
+                        PlayerId = kv.Key, 
+                        Position = new TSVector(10, 0, 10), 
+                        Rotation = TSQuaternion.identity
+                    });
+                }
+
+                RoomMessageHelper.BroadCast(scene, room2CEnterMap);
+            }
+
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/C2Room_ChangeSceneFinishHandler.cs.meta

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

+ 2 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Room/Match2Map_GetRoomHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/Match2Map_GetRoomHandler.cs

@@ -8,11 +8,10 @@ namespace ET.Server
 	{
 		protected override async ETTask Run(Scene scene, Match2Map_GetRoom request, Map2Match_GetRoom response)
 		{
-			Log.Debug($"11111111111111111111111111111111111111a1");
 			RoomManagerComponent roomManagerComponent = scene.GetComponent<RoomManagerComponent>();
-			Scene room = await roomManagerComponent.CreateRoom();
+			Scene room = await roomManagerComponent.CreateRoom(request);
+			room.AddComponent<RoomComponent, Match2Map_GetRoom>(request);
 			response.InstanceId = room.InstanceId;
-			Log.Debug($"11111111111111111111111111111111111111a2");
 			await ETTask.CompletedTask;
 		}
 	}

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Room/Match2Map_GetRoomHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/Match2Map_GetRoomHandler.cs.meta


+ 21 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomComponentSystem.cs

@@ -0,0 +1,21 @@
+using System;
+
+namespace ET.Server
+{
+    [FriendOf(typeof(RoomComponent))]
+    public static class RoomComponentSystem
+    {
+        [ObjectSystem]
+        public class RoomComponentAwakeSystem: AwakeSystem<RoomComponent, Match2Map_GetRoom>
+        {
+            protected override void Awake(RoomComponent self, Match2Map_GetRoom match2MapGetRoom)
+            {
+                foreach (var kv in match2MapGetRoom.PlayerInfo)
+                {
+                    RoomPlayer roomPlayer = self.AddChildWithId<RoomPlayer>(kv.Key);
+                    roomPlayer.SessionInstanceId = kv.Value;
+                }
+            }
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomComponentSystem.cs.meta

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

+ 2 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Room/RoomManagerComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomManagerComponentSystem.cs

@@ -5,12 +5,13 @@ namespace ET.Server
 
     public static class RoomManagerComponentSystem
     {
-        public static async ETTask<Scene> CreateRoom(this RoomManagerComponent self)
+        public static async ETTask<Scene> CreateRoom(this RoomManagerComponent self, Match2Map_GetRoom match2MapGetRoom)
         {
             long instanceId = IdGenerater.Instance.GenerateInstanceId();
             Scene room = await SceneFactory.CreateServerScene(
                 self, instanceId, instanceId, 
                 self.DomainZone(), "Room", SceneType.Room);
+            
             return room;
         }
     }

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Room/RoomManagerComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomManagerComponentSystem.cs.meta


+ 16 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomMessageHelper.cs

@@ -0,0 +1,16 @@
+namespace ET.Server
+{
+
+    public static class RoomMessageHelper
+    {
+        public static void BroadCast(Scene room, IActorMessage message)
+        {
+            RoomComponent roomComponent = room.GetComponent<RoomComponent>();
+            foreach (var kv in roomComponent.Children)
+            {
+                RoomPlayer roomPlayer = kv.Value as RoomPlayer;
+                ActorMessageSenderComponent.Instance.Send(roomPlayer.SessionInstanceId, message);
+            }
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Room/RoomMessageHelper.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 397b1655e0ba94b23abb42a1a3c6cca8
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Match/G2Match_MatchHandler.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Match/G2Match_MatchHandler.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs.meta


+ 11 - 8
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Match/MatchComponentSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/MatchComponentSystem.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 
 namespace ET.Server
 {
@@ -15,8 +16,6 @@ namespace ET.Server
             }
         }
 
-        private const int MatchCount = 1;
-
         public static async ETTask Match(this MatchComponent self, (long, long) playerInfo)
         {
             if (self.waitMatchPlayers.Contains(playerInfo))
@@ -26,22 +25,26 @@ namespace ET.Server
             
             self.waitMatchPlayers.Add(playerInfo);
 
-            if (self.waitMatchPlayers.Count < MatchCount)
+            if (self.waitMatchPlayers.Count < ConstValue.MatchCount)
             {
                 return;
             }
             
             // 申请一个房间
             StartSceneConfig startSceneConfig = RandomGenerator.RandomArray(StartSceneConfigCategory.Instance.Maps);
+            Match2Map_GetRoom match2MapGetRoom = new Match2Map_GetRoom() {PlayerInfo = new Dictionary<long, long>()};
+            foreach ((long id, long sessionInstanceId) in self.waitMatchPlayers)
+            {
+                match2MapGetRoom.PlayerInfo.Add(id, sessionInstanceId);
+            }
+            self.waitMatchPlayers.Clear();
             
-            Log.Debug($"11111111111111111111111111111111111111");
             Map2Match_GetRoom map2MatchGetRoom = await ActorMessageSenderComponent.Instance.Call(
-                startSceneConfig.InstanceId, new Match2Map_GetRoom()) as Map2Match_GetRoom;
-            Log.Debug($"11111111111111111111111111111111111112");
-            for (int i = 0; i < MatchCount; ++i)
+                startSceneConfig.InstanceId, match2MapGetRoom) as Map2Match_GetRoom;
+            foreach (var kv in match2MapGetRoom.PlayerInfo) // 这里发送消息线程不会修改PlayerInfo,所以可以直接使用
             {
                 ActorMessageSenderComponent.Instance.Send(
-                    startSceneConfig.InstanceId, new Match2G_NotifyMatchSuccess() {InstanceId = map2MatchGetRoom.InstanceId});
+                    kv.Value, new Match2G_NotifyMatchSuccess() {InstanceId = map2MatchGetRoom.InstanceId});
                 // 等待进入房间的确认消息,如果超时要通知所有玩家退出房间,重新匹配
             }
         }

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Match/MatchComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Match/MatchComponentSystem.cs.meta


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

@@ -36,7 +36,7 @@ namespace ET.Server
             int fromProcess = instanceIdStruct.Process;
             instanceIdStruct.Process = Options.Instance.Process;
             long realActorId = instanceIdStruct.ToLong();
-
+            
             Entity entity = Root.Instance.Get(realActorId);
             if (entity == null)
             {
@@ -44,6 +44,8 @@ namespace ET.Server
                 Reply(fromProcess, response);
                 return;
             }
+            
+            OpcodeHelper.LogMsg(entity.DomainScene(), iActorRequest);
 
             MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
             if (mailBoxComponent == null)
@@ -98,6 +100,8 @@ namespace ET.Server
                 return;
             }
             
+            OpcodeHelper.LogMsg(entity.DomainScene(), iActorMessage);
+            
             MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
             if (mailBoxComponent == null)
             {

+ 2 - 0
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageSenderComponentSystem.cs

@@ -119,6 +119,8 @@ namespace ET.Server
             session.Send(processActorId.ActorId, message);
         }
 
+
+
         public static int GetRpcId(this ActorMessageSenderComponent self)
         {
             return ++self.RpcId;

+ 0 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Message/NetInnerComponentSystem.cs

@@ -83,7 +83,6 @@ namespace ET.Server
 
         public static void HandleMessage(this NetInnerComponent self, long actorId, object message)
         {
-            OpcodeHelper.LogMsg(self.DomainScene(), message);
             EventSystem.Instance.Publish(Root.Instance.Scene, new NetInnerComponentOnRead() { ActorId = actorId, Message = message });
         }
 

+ 2 - 0
Unity/Assets/Scripts/Codes/Hotfix/Share/ConstValue.cs

@@ -5,5 +5,7 @@ namespace ET
         public const string RouterHttpHost = "127.0.0.1";
         public const int RouterHttpPort = 30300;
         public const int SessionTimeoutTime = 30 * 1000;
+        
+        public const int MatchCount = 1;
     }
 }

+ 8 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b355cc1e135264afb962c15b5a6f34c6
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs

@@ -0,0 +1,22 @@
+using UnityEngine.SceneManagement;
+
+namespace ET.Client
+{
+    [Event(SceneType.Client)]
+    public class LockStepSceneChangeStart_AddComponent: AEvent<EventType.LockStepSceneChangeStart>
+    {
+        protected override async ETTask Run(Scene scene, EventType.LockStepSceneChangeStart args)
+        {
+            Scene currentScene = scene.CurrentScene();
+            
+            // 加载场景资源
+            await ResourcesComponent.Instance.LoadBundleAsync($"{currentScene.Name}.unity3d");
+            // 切换到map场景
+
+            await SceneManager.LoadSceneAsync(currentScene.Name);
+			
+
+            currentScene.AddComponent<OperaComponent>();
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Client/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 913d59a68856e4244ab6a43c8f55c5fb
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 12 - 0
Unity/Assets/Scripts/Codes/Model/Client/LockStep/WaitType.cs

@@ -0,0 +1,12 @@
+namespace ET
+{
+    namespace WaitType
+    {
+        public struct Wait_Room2C_EnterMap: IWaitType
+        {
+            public int Error { get; set; }
+
+            public Room2C_EnterMap Message;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Client/LockStep/WaitType.cs.meta

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

+ 50 - 0
Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/LockStepOuter_C_11001.cs

@@ -28,9 +28,59 @@ namespace ET
 
 	}
 
+// 匹配成功,通知客户端切换场景
+	[Message(LockStepOuter.Match2G_NotifyMatchSuccess)]
+	[ProtoContract]
+	public partial class Match2G_NotifyMatchSuccess: ProtoObject, IActorMessage
+	{
+// 房间的instanceId
+		[ProtoMember(1)]
+		public long InstanceId { get; set; }
+
+	}
+
+// 客户端通知房间切换场景完成
+	[Message(LockStepOuter.C2Room_ChangeSceneFinish)]
+	[ProtoContract]
+	public partial class C2Room_ChangeSceneFinish: ProtoObject, IActorRoom
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+	}
+
+	[Message(LockStepOuter.LockStepUnitInfo)]
+	[ProtoContract]
+	public partial class LockStepUnitInfo: ProtoObject
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+		[ProtoMember(2)]
+		public TrueSync.TSVector Position { get; set; }
+
+		[ProtoMember(3)]
+		public TrueSync.TSQuaternion Rotation { get; set; }
+
+	}
+
+// 房间通知客户端进入战斗
+	[Message(LockStepOuter.Room2C_EnterMap)]
+	[ProtoContract]
+	public partial class Room2C_EnterMap: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public List<LockStepUnitInfo> UnitInfo { get; set; }
+
+	}
+
 	public static class LockStepOuter
 	{
 		 public const ushort C2G_Match = 11002;
 		 public const ushort G2C_Match = 11003;
+		 public const ushort Match2G_NotifyMatchSuccess = 11004;
+		 public const ushort C2Room_ChangeSceneFinish = 11005;
+		 public const ushort LockStepUnitInfo = 11006;
+		 public const ushort Room2C_EnterMap = 11007;
 	}
 }

+ 3 - 14
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepInner_S_21001.cs

@@ -43,6 +43,9 @@ namespace ET
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
 
+		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
+		[ProtoMember(2)]
+		public Dictionary<long, long> PlayerInfo { get; set; }
 	}
 
 	[Message(LockStepInner.Map2Match_GetRoom)]
@@ -64,25 +67,11 @@ namespace ET
 
 	}
 
-	[Message(LockStepInner.Match2G_NotifyMatchSuccess)]
-	[ProtoContract]
-	public partial class Match2G_NotifyMatchSuccess: ProtoObject, IActorMessage
-	{
-		[ProtoMember(1)]
-		public int RpcId { get; set; }
-
-// 房间的instanceId
-		[ProtoMember(2)]
-		public long InstanceId { get; set; }
-
-	}
-
 	public static class LockStepInner
 	{
 		 public const ushort G2Match_Match = 21002;
 		 public const ushort Match2G_Match = 21003;
 		 public const ushort Match2Map_GetRoom = 21004;
 		 public const ushort Map2Match_GetRoom = 21005;
-		 public const ushort Match2G_NotifyMatchSuccess = 21006;
 	}
 }

+ 50 - 0
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepOuter_C_11001.cs

@@ -28,9 +28,59 @@ namespace ET
 
 	}
 
+// 匹配成功,通知客户端切换场景
+	[Message(LockStepOuter.Match2G_NotifyMatchSuccess)]
+	[ProtoContract]
+	public partial class Match2G_NotifyMatchSuccess: ProtoObject, IActorMessage
+	{
+// 房间的instanceId
+		[ProtoMember(1)]
+		public long InstanceId { get; set; }
+
+	}
+
+// 客户端通知房间切换场景完成
+	[Message(LockStepOuter.C2Room_ChangeSceneFinish)]
+	[ProtoContract]
+	public partial class C2Room_ChangeSceneFinish: ProtoObject, IActorRoom
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+	}
+
+	[Message(LockStepOuter.LockStepUnitInfo)]
+	[ProtoContract]
+	public partial class LockStepUnitInfo: ProtoObject
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+		[ProtoMember(2)]
+		public TrueSync.TSVector Position { get; set; }
+
+		[ProtoMember(3)]
+		public TrueSync.TSQuaternion Rotation { get; set; }
+
+	}
+
+// 房间通知客户端进入战斗
+	[Message(LockStepOuter.Room2C_EnterMap)]
+	[ProtoContract]
+	public partial class Room2C_EnterMap: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public List<LockStepUnitInfo> UnitInfo { get; set; }
+
+	}
+
 	public static class LockStepOuter
 	{
 		 public const ushort C2G_Match = 11002;
 		 public const ushort G2C_Match = 11003;
+		 public const ushort Match2G_NotifyMatchSuccess = 11004;
+		 public const ushort C2Room_ChangeSceneFinish = 11005;
+		 public const ushort LockStepUnitInfo = 11006;
+		 public const ushort Room2C_EnterMap = 11007;
 	}
 }

+ 3 - 14
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepInner_S_21001.cs

@@ -43,6 +43,9 @@ namespace ET
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
 
+		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
+		[ProtoMember(2)]
+		public Dictionary<long, long> PlayerInfo { get; set; }
 	}
 
 	[Message(LockStepInner.Map2Match_GetRoom)]
@@ -64,25 +67,11 @@ namespace ET
 
 	}
 
-	[Message(LockStepInner.Match2G_NotifyMatchSuccess)]
-	[ProtoContract]
-	public partial class Match2G_NotifyMatchSuccess: ProtoObject, IActorMessage
-	{
-		[ProtoMember(1)]
-		public int RpcId { get; set; }
-
-// 房间的instanceId
-		[ProtoMember(2)]
-		public long InstanceId { get; set; }
-
-	}
-
 	public static class LockStepInner
 	{
 		 public const ushort G2Match_Match = 21002;
 		 public const ushort Match2G_Match = 21003;
 		 public const ushort Match2Map_GetRoom = 21004;
 		 public const ushort Map2Match_GetRoom = 21005;
-		 public const ushort Match2G_NotifyMatchSuccess = 21006;
 	}
 }

+ 50 - 0
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepOuter_C_11001.cs

@@ -28,9 +28,59 @@ namespace ET
 
 	}
 
+// 匹配成功,通知客户端切换场景
+	[Message(LockStepOuter.Match2G_NotifyMatchSuccess)]
+	[ProtoContract]
+	public partial class Match2G_NotifyMatchSuccess: ProtoObject, IActorMessage
+	{
+// 房间的instanceId
+		[ProtoMember(1)]
+		public long InstanceId { get; set; }
+
+	}
+
+// 客户端通知房间切换场景完成
+	[Message(LockStepOuter.C2Room_ChangeSceneFinish)]
+	[ProtoContract]
+	public partial class C2Room_ChangeSceneFinish: ProtoObject, IActorRoom
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+	}
+
+	[Message(LockStepOuter.LockStepUnitInfo)]
+	[ProtoContract]
+	public partial class LockStepUnitInfo: ProtoObject
+	{
+		[ProtoMember(1)]
+		public long PlayerId { get; set; }
+
+		[ProtoMember(2)]
+		public TrueSync.TSVector Position { get; set; }
+
+		[ProtoMember(3)]
+		public TrueSync.TSQuaternion Rotation { get; set; }
+
+	}
+
+// 房间通知客户端进入战斗
+	[Message(LockStepOuter.Room2C_EnterMap)]
+	[ProtoContract]
+	public partial class Room2C_EnterMap: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public List<LockStepUnitInfo> UnitInfo { get; set; }
+
+	}
+
 	public static class LockStepOuter
 	{
 		 public const ushort C2G_Match = 11002;
 		 public const ushort G2C_Match = 11003;
+		 public const ushort Match2G_NotifyMatchSuccess = 11004;
+		 public const ushort C2Room_ChangeSceneFinish = 11005;
+		 public const ushort LockStepUnitInfo = 11006;
+		 public const ushort Room2C_EnterMap = 11007;
 	}
 }

+ 0 - 2
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/Player.cs

@@ -4,7 +4,5 @@
     public sealed class Player : Entity, IAwake<string>
     {
         public string Account { get; set; }
-		
-        public long UnitId { get; set; }
     }
 }

+ 20 - 0
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerSessionComponent.cs

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

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/PlayerSessionComponent.cs.meta

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

+ 1 - 20
Unity/Assets/Scripts/Codes/Model/Server/Demo/Gate/SessionInfoComponent.cs

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 78a1c559ee23b4ca2878b8d4710adc3f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 4c628457f77814ca1a92b6d757ef4063
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate/PlayerRoomComponent.cs

@@ -0,0 +1,9 @@
+namespace ET.Server
+{
+
+    [ComponentOf(typeof (Player))]
+    public class PlayerRoomComponent: Entity, IAwake
+    {
+        public long RoomInstanceId { get; set; }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Gate/PlayerRoomComponent.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d0f1c516742bc43d586c085b7a26e12d
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/Room.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 888a163bd066e435584056c8c92ab289
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 10 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomComponent.cs

@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace ET.Server
+{
+    [ComponentOf(typeof(Scene))]
+    public class RoomComponent: Entity, IAwake<Match2Map_GetRoom>
+    {
+        public int AlreadyJoinRoomCount;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomComponent.cs.meta

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

+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Room/RoomManagerComponent.cs → Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomManagerComponent.cs


+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Room/RoomManagerComponent.cs.meta → Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomManagerComponent.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 7a50cc2f84720402883e45772d5cef09
+guid: 48baea120fed34a2492026794df7f64b
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 10 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomPlayer.cs

@@ -0,0 +1,10 @@
+namespace ET.Server
+{
+
+    [ChildOf(typeof (RoomComponent))]
+    public class RoomPlayer: Entity, IAwake
+    {
+        public long SessionInstanceId { get; set; }
+        public bool IsJoinRoom { get; set; }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Map/RoomPlayer.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d3d85a4b2a3594b9fa6887cc3b574056
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Server/Demo/Match/MatchComponent.cs → Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match/MatchComponent.cs


+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Server/Demo/Match/MatchComponent.cs.meta → Unity/Assets/Scripts/Codes/Model/Server/LockStep/Match/MatchComponent.cs.meta


+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e8c5c383e6c7b48d9ba137530d2e924b
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/EventType.cs

@@ -0,0 +1,13 @@
+namespace ET
+{
+    namespace EventType
+    {
+        public struct LockStepSceneChangeStart
+        {
+        }
+        
+        public struct LockStepSceneChangeFinish
+        {
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/EventType.cs.meta

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

+ 28 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/FUnit.cs

@@ -0,0 +1,28 @@
+using MongoDB.Bson.Serialization.Attributes;
+using TrueSync;
+
+namespace ET
+{
+    [ChildOf(typeof(UnitComponent))]
+    public class FUnit: Entity, IAwake, ISerializeToEntity
+    {
+        public TSVector Position
+        {
+            get;
+            set;
+        }
+
+        [BsonIgnore]
+        public TSVector Forward
+        {
+            get => this.Rotation * TSVector.forward;
+            set => this.Rotation = TSQuaternion.LookRotation(value, TSVector.up);
+        }
+        
+        public TSQuaternion Rotation
+        {
+            get;
+            set;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/FUnit.cs.meta

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

+ 7 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/IActorRoom.cs

@@ -0,0 +1,7 @@
+namespace ET
+{
+    public interface IActorRoom: IActorMessage
+    {
+        long PlayerId { get; set; }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/IActorRoom.cs.meta

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

+ 7 - 0
Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs

@@ -8,6 +8,7 @@ using MongoDB.Bson.IO;
 using MongoDB.Bson.Serialization;
 using MongoDB.Bson.Serialization.Conventions;
 using MongoDB.Bson.Serialization.Serializers;
+using TrueSync;
 using Unity.Mathematics;
 
 namespace ET
@@ -93,6 +94,12 @@ namespace ET
             RegisterStruct<float3>();
             RegisterStruct<float4>();
             RegisterStruct<quaternion>();
+            
+            RegisterStruct<FP>();
+            RegisterStruct<TSVector>();
+            RegisterStruct<TSVector2>();
+            RegisterStruct<TSVector4>();
+            RegisterStruct<TSQuaternion>();
 
             Dictionary<string, Type> types = EventSystem.Instance.GetTypes();
             foreach (Type type in types.Values)

+ 7 - 0
Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs

@@ -2,6 +2,7 @@
 using System.ComponentModel;
 using System.IO;
 using ProtoBuf.Meta;
+using TrueSync;
 using Unity.Mathematics;
 
 namespace ET
@@ -18,6 +19,12 @@ namespace ET
 			RuntimeTypeModel.Default.Add(typeof(float3), false).Add("x", "y", "z");
 			RuntimeTypeModel.Default.Add(typeof(float4), false).Add("x", "y", "z", "w");
 			RuntimeTypeModel.Default.Add(typeof(quaternion), false).Add("value");
+			
+			RuntimeTypeModel.Default.Add(typeof(FP), false).Add("_serializedValue");
+			RuntimeTypeModel.Default.Add(typeof(TSVector2), false).Add("x", "y");
+			RuntimeTypeModel.Default.Add(typeof(TSVector), false).Add("x", "y", "z");
+			RuntimeTypeModel.Default.Add(typeof(TSVector4), false).Add("x", "y", "z", "w");
+			RuntimeTypeModel.Default.Add(typeof(TSQuaternion), false).Add("x", "y", "z", "w");
 		}
 		
 		public static object Deserialize(Type type, byte[] bytes, int index, int count)