Browse Source

【优化】BattleEventPushToServer

johnclot69 1 month ago
parent
commit
3ce07ae016

+ 2 - 2
DotNet/Hotfix/Module/IceBattle/BattleEventHandler.cs

@@ -9,7 +9,7 @@
 
             SessionPlayerComponent component = session.GetComponent<SessionPlayerComponent>();
             //message.data
-            FastStreamComponent.Instance.SendData(component.PlayerId.ToString(), message.data);
+            session.DomainScene().GetComponent<FastStreamComponent>().SendData(component.PlayerId.ToString(), message.data);
 
             await ETTask.CompletedTask;
         }
@@ -30,7 +30,7 @@
             }
             if (player.Map != null)
             {
-                player.Map.PlayerReady(player);
+                player.Map.OnReady(player);
             }
             await ETTask.CompletedTask;
         }

+ 1 - 1
DotNet/Hotfix/Scenes/Game/Handler/C2G_AddUnitsToMapHandler.cs

@@ -46,8 +46,8 @@ namespace ET.Server
             //     await player.Map.AddUnitPlayer(_openId, request.UnitId, request.Force, request.Flag, request.X, request.Y, GetRandomPlayerName(), GetRandomUrl());
             //     break;
             // }
-            await ETTask.CompletedTask;
             reply();
+            await ETTask.CompletedTask;
         }
 
         private string GetRandomPlayerName()

+ 0 - 78
DotNet/Hotfix/Scenes/Game/Handler/C2G_BattleNotifyHandler.cs

@@ -31,84 +31,6 @@ namespace ET.Server
                 return;
             }
 
-            //客户端测试功能
-            // if (request.Message.StartsWith("test:"))
-            // {
-            //     var map = player.Map;
-            //     if(map == null || map.UnitPlayers == null)
-            //     {
-            //         Log.Debug("map not exist, abort cmd");
-            //         return;
-            //     }
-            //
-            //     long roomId = 0;
-            //     var maphash = GameMapComponent.Instance.rooms;
-            //     foreach ( var rid in maphash.Keys )
-            //     {
-            //         if (maphash[rid] == map.Id)
-            //         {
-            //             roomId = rid;
-            //             break;
-            //         }
-            //     }
-            //
-            //     long instanceid = 0;
-            //     List<StartSceneConfig> list = RealmGateAddressHelper.GetAllGame(1);
-            //     foreach (StartSceneConfig config in list.Where(config => config is { Id: 10001 }))
-            //     {
-            //         instanceid = config.InstanceId;
-            //         break;
-            //     }
-            //
-            //     var funcIndex = int.Parse(request.Message[5..]);
-            //     if(funcIndex == 8)
-            //     {
-            //         string _openId = "xx";
-            //         while (true)
-            //         {
-            //             _openId = (10000 + new Random().Next(99999999)).ToString();
-            //             if (player.Map.GetUnitPlayerByOpenId(_openId) != null) continue;
-            //             break;
-            //         }
-            //         var name = GetRandomPlayerName();
-            //         var url = GetRandomUrl();
-            //         string[] content = { "1", "2", "3", "4" };
-            //         MessageHelper.SendActor(instanceid, new R2G_LiveComment() { OpenId = _openId, Url = url, RoomId = roomId, NickName = name, Content =  RandomGenerator.RandomArray(content)});
-            //     }
-            //
-            //     var players = map.UnitPlayers.Values.ToArray();
-            //     if (players.Length == 0)
-            //     {
-            //         Log.Debug("Player count == 0, abort cmd");
-            //         return;
-            //     }
-            //     var rand = new Random();
-            //     var randunit = players[rand.Next(players.Length)];
-            //     if (funcIndex == 7)
-            //     {
-            //         MessageHelper.SendActor(instanceid, new R2G_LiveLike() { OpenId = randunit.OpenId, RoomId = roomId, NickName = randunit.Name, Url = randunit.Url, Likes = 30 });
-            //     }
-            //     else if(funcIndex <= 6 && funcIndex >= 1)
-            //     {
-            //         string[] GIFT = { DouyinItem.GiftId_1, DouyinItem.GiftId_10, DouyinItem.GiftId_52, DouyinItem.GiftId_99, DouyinItem.GiftId_199, DouyinItem.GiftId_520 };
-            //         int[] GiftValue = { 10, 100, 520, 990, 1990, 5200 };
-            //         int cnt = 1;
-            //         switch(funcIndex)
-            //         {
-            //             case 1:
-            //                 cnt = (int)Math.Sqrt(rand.Next(1, 100));
-            //                 break;
-            //             case 2:
-            //                 cnt = rand.Next(1, 10);
-            //                 break;
-            //         }
-            //
-            //         MessageHelper.SendActor(instanceid, new R2G_LiveGift() { OpenId = randunit.OpenId, RoomId = roomId, NickName = randunit.Name, Url = randunit.Url, GiftId = GIFT[funcIndex-1], GiftNum = cnt, GiftValue = GiftValue[funcIndex-1] * cnt });
-            //     }
-            //
-            //     return;
-            // }
-
             // 通知战斗服
             player.GetXmdsManager().notifyBattleServer(player.Map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(new Struct.TriggerEventNotify() { message = request.Message }));
 

+ 1 - 1
DotNet/Hotfix/Scenes/Game/Map/MapSystem.cs

@@ -113,7 +113,7 @@ namespace ET.Server
         /// </summary>
         /// <param name="self"></param>
         /// <param name="player"></param>
-        public static void PlayerReady(this Map self, WNPlayer player)
+        public static void OnReady(this Map self, WNPlayer player)
         {
 
         }

+ 2 - 0
DotNet/Hotfix/Scenes/Game/Player/PlayerSystem.cs

@@ -176,6 +176,8 @@ namespace ET.Server
         /** 客户端资源加载完成通知 给客户端推送的数据要在这里 **/
         public static void OnReady(this WNPlayer self)
         {
+            // self.OnEndEnterScene();
+
             // 登录第一次进场景处理,此次登陆登出期间只处理一次
             if (self.ReadyFirst)
             {