PSO2SERVER/Server/Protocol/Packets/21-PalettePacket/21-0F-NewDefaultPAsPacket.cs

62 lines
1.6 KiB
C#
Raw Normal View History

2024-09-16 17:09:36 +08:00
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
2024-09-22 11:14:48 +08:00
using System.IO;
2024-09-16 17:09:36 +08:00
using System.Linq;
using System.Text;
namespace PSO2SERVER.Protocol.Packets
2024-09-16 17:09:36 +08:00
{
public class NewDefaultPAsPacket : Packet
2024-09-16 17:09:36 +08:00
{
2024-09-22 11:14:48 +08:00
public const int SeekAfter = 0x240; // 576 bytes
2024-12-10 13:33:57 +08:00
public FixedList<uint> Default { get; set; } = new FixedList<uint>(0x1A0);
2024-09-16 17:09:36 +08:00
2024-12-10 13:33:57 +08:00
public NewDefaultPAsPacket(List<uint> Default)
2024-09-16 17:09:36 +08:00
{
2024-12-10 13:33:57 +08:00
foreach (var item in Default)
{
this.Default.Add(item);
}
2024-09-22 11:14:48 +08:00
}
public void ReadFromStream(PacketReader reader)
{
2024-12-10 13:33:57 +08:00
// 跳过填充
reader.BaseStream.Seek(SeekAfter, SeekOrigin.Current);
2024-09-22 11:14:48 +08:00
// 读取 Default
for (int i = 0; i < Default.Capacity; i++)
{
Default.Add(reader.ReadUInt32());
}
}
public void WriteToStream(PacketWriter writer)
{
2024-12-10 13:33:57 +08:00
// 写入前面的填充(如果需要,可以根据协议实际填充字节)
writer.BaseStream.Seek(SeekAfter, SeekOrigin.Current);
2024-09-22 11:14:48 +08:00
// 写入 Default
foreach (var value in Default)
{
writer.Write(value);
}
2024-09-16 17:09:36 +08:00
}
#region implemented abstract members of Packet
public override byte[] Build()
{
2024-09-22 00:08:44 +08:00
var writer = new PacketWriter();
2024-12-10 13:33:57 +08:00
WriteToStream(writer);
2024-09-22 00:08:44 +08:00
return writer.ToArray();
2024-09-16 17:09:36 +08:00
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x21, 0x0F, PacketFlags.None);
2024-09-16 17:09:36 +08:00
}
#endregion
}
}