mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-15 08:05:06 +00:00
19 lines
720 B
C#
19 lines
720 B
C#
|
using System.Runtime.InteropServices;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace Shared.Packet.Packets;
|
|||
|
|
|||
|
public class CapturePacket : IPacket {
|
|||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
|
|||
|
public string ModelName;
|
|||
|
public bool IsCaptured;
|
|||
|
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..]);
|
|||
|
}
|
|||
|
}
|