0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-15 08:05:06 +00:00
SmoOnlineServer/Shared/Packet/Packets/CapturePacket.cs

22 lines
751 B
C#
Raw Normal View History

using System.Runtime.InteropServices;
using System.Text;
2022-02-10 01:44:50 +00:00
namespace Shared.Packet.Packets;
2022-02-08 16:22:09 +00:00
[Packet(PacketType.Capture)]
public struct CapturePacket : IPacket {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
public string ModelName;
2022-02-10 01:44:50 +00:00
public bool IsCaptured;
2022-02-10 01:44:50 +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..]);
}
}