using System; using PSO2SERVER.Models; using PSO2SERVER.Protocol.Packets; namespace PSO2SERVER.Protocol.Handlers { [PacketHandlerAttr(0x21, 0x0A)] public class SetDefaultPAs : PacketHandler { public class SetDefaultPAsPacket { public FixedList Default { get; set; } = new FixedList(0x1A0, 0); // 从数据流中读取数据并填充到 Default 列表 public static SetDefaultPAsPacket ReadFromStream(PacketReader reader) { // 假设 Default 是该类的静态字段,因此直接访问 SetDefaultPAsPacket packet = new SetDefaultPAsPacket(); // 从流中读取 uint 类型的数据并填充到 Default 列表 for (var i = 0; i < (int)packet.Default.Capacity; i++) { packet.Default[i] = reader.ReadUInt32(); // 读取 uint 值并存入 Default 列表 } return packet; } // 将 Default 列表的数据写入到数据流 public void WriteToStream(PacketWriter writer) { // 将 Default 列表中的每个 uint 元素写入数据流 for (var i = 0; i < (int)Default.Capacity; i++) { writer.Write(Default[i]); // 写入 uint 值 } } } public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); Logger.WriteHex(info, data); var reader = new PacketReader(data, position, size); var packet = SetDefaultPAsPacket.ReadFromStream(reader); context.SendPacket(new NewDefaultPAsPacket(packet.Default)); } } }