2022-02-04 09:45:38 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2022-02-08 16:15:31 +00:00
|
|
|
|
using System.Text;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
namespace Shared.Packet.Packets;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
|
|
|
|
[Packet(PacketType.Costume)]
|
|
|
|
|
public struct CostumePacket : IPacket {
|
|
|
|
|
public string BodyName;
|
|
|
|
|
public string CapName;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-03-11 05:59:02 +00:00
|
|
|
|
public short Size => Constants.CostumeNameSize * 2;
|
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
public void Serialize(Span<byte> data) {
|
2022-02-08 16:15:31 +00:00
|
|
|
|
Encoding.UTF8.GetBytes(BodyName).CopyTo(data[..Constants.CostumeNameSize]);
|
|
|
|
|
Encoding.UTF8.GetBytes(CapName).CopyTo(data[Constants.CostumeNameSize..]);
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 04:29:34 +00:00
|
|
|
|
public void Deserialize(ReadOnlySpan<byte> data) {
|
2022-02-08 16:15:31 +00:00
|
|
|
|
BodyName = Encoding.UTF8.GetString(data[..Constants.CostumeNameSize]).TrimNullTerm();
|
|
|
|
|
CapName = Encoding.UTF8.GetString(data[Constants.CostumeNameSize..]).TrimNullTerm();
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
2021-11-29 04:04:34 +00:00
|
|
|
|
}
|