PSO2SERVER/Server/Protocol/Packets/21-PalettePacket/21-0F-NewDefaultPAsPacket.cs
2024-12-10 13:33:57 +08:00

62 lines
1.6 KiB
C#

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