Quellcode durchsuchen

【优化】进入场景时的一些问题

johnclot69 vor 1 Jahr
Ursprung
Commit
0744c476d4

+ 8 - 5
DotNet/Hotfix/Helper/MapHelper.cs

@@ -144,6 +144,14 @@ namespace ET.Server
             if (prop != null)
             {
                 map = player.DomainScene().GetComponent<GameMapComponent>().Get(playerMapInfo.mapInstanceId);
+                if (map == null)
+                {
+                    Map[] list = player.DomainScene().GetComponent<GameMapComponent>().GetAll();
+                    if (list is { Length: > 0 })
+                    {
+                        map = list[0];
+                    }
+                }
             }
 
             if (map != null)
@@ -151,11 +159,6 @@ namespace ET.Server
                 return map;
             }
 
-            if (map == null)
-            {
-                playerMapInfo.mapId = 10098;
-            }
-
             // 创建一个场景
             JObject jsonObject = new JObject();
             jsonObject.Add("id", player.GetId());

+ 1 - 1
DotNet/Hotfix/Scenes/Game/GameMapComponentSystem.cs

@@ -45,7 +45,7 @@ namespace ET.Server
             self.allMaps.Remove(instanceId);
         }
 
-        public static Map[] GerAll(this GameMapComponent self)
+        public static Map[] GetAll(this GameMapComponent self)
         {
             return self.allMaps.Values.ToArray();
         }

+ 7 - 39
DotNet/Hotfix/Scenes/Game/Handler/C2G_EnterMapHandler.cs

@@ -42,50 +42,18 @@ namespace ET.Server
                 return;
             }
 
-            // map.PlayerEnterRequest(player);
-            // map.OnPlayerEntered(player);
-            // player.OnEndEnterScene();
+            map.PlayerEnterRequest(player);
+            map.OnPlayerEntered(player);
 
-            // response.MapInstanceId = player.Map.Id;
-            // reply();
+            response.MapInstanceId = player.Map.Id;
+            reply();
 
-            // player进入副本,把player基本信息上报给战斗服
-            map.GetZoneManager().begin_playerEnterRequest(player.GetId().ToString(), map.Id.ToString().Trim(), player.toJSON4EnterScene(map))
-                    .whenCompleted(() =>
-                        {
-                            response.MapInstanceId = player.Map.Id;
-                            reply();
-                            WaitPlayerReady(session.DomainScene(), request.InstanceId, player.Id).Coroutine();
-                        },
-                        (Ice.Exception ex) =>
-                        {
-                            if (ex != null)
-                            {
-                                Log.Error($"进入场景失败...{ex.Message}");
-                                response.Error = -1;
-                                response.Message = ex.Message;
-                                reply();
-                            }
-                        });
-            await ETTask.CompletedTask;
-        }
-
-        private static async ETTask WaitPlayerReady(Scene scene, long scnInstance, long playerid)
-        {
             //等待client ready消息
-            await scene.GetComponent<ObjectWait>().Wait<Wait_PlayerReady>();
-            //告诉战斗服 i am ready
-
-            string playidstr = playerid.ToString();
-            //设置ice战斗服中player状态为ready
-            XmdsManagerPrx IceXmds = BattleIceAgentComponent.Instance.IceXmdsManager;
-            IceXmds.playerReady(playidstr);
+            await session.DomainScene().GetComponent<ObjectWait>().Wait<Wait_PlayerReady>();
 
-            //PKMode设置为All
-            IceXmds.refreshPlayerPKMode(playidstr, false, (int)PkModel.All);
+            player.OnEndEnterScene();
 
-            //设置为自动战斗
-            IceXmds.autoBattle(scnInstance.ToString(), playidstr, true);
+            await ETTask.CompletedTask;
         }
     }
 }

+ 6 - 1
DotNet/Hotfix/Scenes/Game/Player/PlayerSystem.cs

@@ -178,7 +178,12 @@ namespace ET.Server
         /** 向客户端推送角色相关数据 **/
         public static void OnEndEnterScene(this WNPlayer self)
         {
-            // self.GetXmdsManager().playerReady(self.GetId().ToString().Trim());
+            self.GetXmdsManager().playerReady(self.GetId().ToString().Trim());
+            //PKMode设置为All
+            self.GetXmdsManager().refreshPlayerPKMode(self.GetId().ToString().Trim(), false, (int)PkModel.All);
+            //设置为自动战斗
+            self.GetXmdsManager().autoBattle(self.Map.Id.ToString().Trim(), self.GetId().ToString().Trim(), true);
+
             // MessageHelper.SendToClient(self, new G2C_EnterSceneReady() { MapId = self.Map.MapId, MapInstanceId = self.Map.Id });
         }