Advertisement
Genral

MsgBossHarmRankingHandler

Dec 10th, 2023
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.98 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using ProtoBuf;
  4.  
  5. namespace Project_ConquerX.Game.MsgServer
  6. {
  7.     public static unsafe partial class MsgBuilder
  8.     {
  9.         public static unsafe ServerSockets.Packet CreateBossHarmRankList(this ServerSockets.Packet stream, MsgBossHarmRanking obj)
  10.         {
  11.             stream.InitWriter();
  12.             stream.ProtoBufferSerialize(obj);
  13.             stream.Finalize(GamePackets.MapLoading);
  14.             return stream;
  15.         }
  16.         public static unsafe void GetBossHarm(this ServerSockets.Packet stream, out MsgBossHarmRanking pQuery)
  17.         {
  18.             pQuery = new MsgBossHarmRanking();
  19.             pQuery = stream.ProtoBufferDeserialize<MsgBossHarmRanking>(pQuery);
  20.         }
  21.         [PacketAttribute(GamePackets.MapLoading)]
  22.         private unsafe static void Process(Client.GameClient client, ServerSockets.Packet stream)
  23.         {
  24.  
  25.             MsgBossHarmRanking Info;
  26.             stream.GetBossHarm(out Info);
  27.             switch (Info.Type)
  28.             {
  29.                 case (int)MsgBossHarmRanking.RankAction.Show:
  30.                     {
  31.                         if (client.Map.View.MapContain(Role.MapObjectType.Monster, Info.MonsterID))
  32.                         {
  33.                             var monster = client.Map.View.GetMapObject<MsgMonster.MonsterRole>(Role.MapObjectType.Monster, Info.MonsterID);
  34.                             client.Send(stream.CreateBossHarmRankList(new MsgBossHarmRanking() { Type = (int)MsgBossHarmRanking.RankAction.ShowRespondForFirstThree, MonsterID = Info.MonsterID, Hunters = monster.Hunters.Values.Take(3).ToArray() }));
  35.                             if (monster.Hunters.Count > 3)
  36.                                 client.Send(stream.CreateBossHarmRankList(new MsgBossHarmRanking() { Type = (int)MsgBossHarmRanking.RankAction.ShowRespondForTheRest, MonsterID = Info.MonsterID, Hunters = monster.Hunters.Values.Skip(3).ToArray() }));
  37.                         }
  38.                         break;
  39.                     }
  40.             }
  41.         }
  42.     }
  43.     [ProtoContract]
  44.     public struct MsgBossHarmRanking
  45.     {
  46.         [Flags]
  47.         public enum RankAction : int
  48.         {
  49.             Show = 0,
  50.             ShowRespondForFirstThree = 1,
  51.             ShowRespondForTheRest = 2,
  52.         }
  53.         [ProtoMember(1, IsRequired = true)]
  54.         public int Type;
  55.         [ProtoMember(2, IsRequired = true)]
  56.         public uint MonsterID;
  57.         [ProtoMember(3, IsRequired = true)]
  58.         public MsgBossHarmRankingEntry[] Hunters;
  59.     }
  60.     [ProtoContract]
  61.     public class MsgBossHarmRankingEntry
  62.     {
  63.  
  64.         [ProtoMember(1, IsRequired = true)]
  65.         public uint Rank;
  66.         [ProtoMember(2, IsRequired = true)]
  67.         public uint ServerID;//Which Sent In 2500 Packet
  68.         [ProtoMember(3, IsRequired = true)]
  69.         public uint HunterUID;
  70.         [ProtoMember(4, IsRequired = true)]
  71.         public string HunterName;
  72.         [ProtoMember(5, IsRequired = true)]
  73.         public uint HunterScore;
  74.     }
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement