71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
using PSO2SERVER.Models;
|
||
using static PSO2SERVER.Models.PSOPalette;
|
||
|
||
namespace PSO2SERVER.Protocol.Packets
|
||
{
|
||
public class LoadPalettePacket : Packet
|
||
{
|
||
#region implemented abstract members of Packet
|
||
|
||
public uint CurPalette { get; set; }
|
||
public uint CurSubpalette { get; set; }
|
||
public uint CurBook { get; set; }
|
||
public WeaponPalette[] Palettes { get; set; } = new WeaponPalette[6];
|
||
public SubPalette[] Subpalettes { get; set; } = new SubPalette[6];
|
||
|
||
public LoadPalettePacket()
|
||
{
|
||
CurPalette = 1;
|
||
CurSubpalette = 0;
|
||
CurBook = 0;
|
||
|
||
// 初始化 Palettes
|
||
for (int i = 0; i < Palettes.Length; i++)
|
||
{
|
||
Palettes[i] = new WeaponPalette();
|
||
}
|
||
|
||
// 初始化 Subpalettes(根据需要可以进行自定义初始化)
|
||
for (int i = 0; i < Subpalettes.Length; i++)
|
||
{
|
||
Subpalettes[i] = new SubPalette(); // 这里可以根据需要进行初始化
|
||
}
|
||
}
|
||
|
||
public override byte[] Build()
|
||
{
|
||
var pkt = new PacketWriter();
|
||
pkt.Write(CurPalette);
|
||
pkt.Write(CurSubpalette);
|
||
pkt.Write(CurBook);
|
||
|
||
// 初始化 Palettes
|
||
for (int i = 0; i < Palettes.Length; i++)
|
||
{
|
||
Palettes[i].WriteToStream(pkt);
|
||
}
|
||
|
||
// 初始化 Subpalettes(根据需要可以进行自定义初始化)
|
||
for (int i = 0; i < Subpalettes.Length; i++)
|
||
{
|
||
Subpalettes[i].WriteToStream(pkt);
|
||
}
|
||
|
||
//// Enable flag
|
||
//pkt.Write((byte) 1);
|
||
|
||
//// Blank out the rest (skills)
|
||
//for (var i = 0; i < 1091; i++)
|
||
// pkt.Write((byte) 0);
|
||
|
||
return pkt.ToArray();
|
||
}
|
||
|
||
public override PacketHeader GetHeader()
|
||
{
|
||
return new PacketHeader(0x21, 0x01, PacketFlags.None);
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
} |