64 lines
1.7 KiB
C#
64 lines
1.7 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, 0);
|
|
|
|
public NewDefaultPAsPacket(List<uint> Default)
|
|
{
|
|
this.Default.SetListItem(Default);
|
|
}
|
|
|
|
public NewDefaultPAsPacket(FixedList<uint> Default)
|
|
{
|
|
this.Default = Default;
|
|
}
|
|
|
|
public void ReadFromStream(PacketReader reader)
|
|
{
|
|
// 跳过填充
|
|
reader.BaseStream.Seek(SeekAfter, SeekOrigin.Current);
|
|
// 读取 Default
|
|
for (int i = 0; i < Default.Capacity; i++)
|
|
{
|
|
Default.SetItem(i, 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
|
|
}
|
|
} |