2022-02-08 16:15:31 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
namespace Shared.Packet.Packets;
|
2022-02-08 16:15:31 +00:00
|
|
|
|
|
2022-02-08 16:22:09 +00:00
|
|
|
|
[Packet(PacketType.Capture)]
|
|
|
|
|
public struct CapturePacket : IPacket {
|
2022-02-08 16:15:31 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
|
|
|
|
|
public string ModelName;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-08 16:15:31 +00:00
|
|
|
|
public bool IsCaptured;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-08 16:15:31 +00:00
|
|
|
|
public void Serialize(Span<byte> data) {
|
|
|
|
|
Encoding.UTF8.GetBytes(ModelName).CopyTo(data[..Constants.CostumeNameSize]);
|
|
|
|
|
MemoryMarshal.Write(data[Constants.CostumeNameSize..], ref IsCaptured);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Deserialize(Span<byte> data) {
|
|
|
|
|
ModelName = Encoding.UTF8.GetString(data[..Constants.CostumeNameSize]).TrimNullTerm();
|
|
|
|
|
IsCaptured = MemoryMarshal.Read<bool>(data[Constants.CostumeNameSize..]);
|
|
|
|
|
}
|
|
|
|
|
}
|