Implement tag packet serde

This commit is contained in:
Sanae 2022-03-15 01:39:33 -06:00
parent 3a8b38142e
commit fca90851ad
1 changed files with 8 additions and 2 deletions

View File

@ -12,11 +12,17 @@ public struct TagPacket : IPacket {
public short Size => 4;
public void Serialize(Span<byte> data) {
MemoryMarshal.Write(data, ref IsIt);
MemoryMarshal.Write(data, ref UpdateType);
MemoryMarshal.Write(data[1..], ref IsIt);
MemoryMarshal.Write(data[2..], ref Seconds);
MemoryMarshal.Write(data[3..], ref Minutes);
}
public void Deserialize(Span<byte> data) {
IsIt = MemoryMarshal.Read<bool>(data);
UpdateType = MemoryMarshal.Read<bool>(data);
IsIt = MemoryMarshal.Read<bool>(data[1..]);
Seconds = MemoryMarshal.Read<byte>(data[2..]);
Minutes = MemoryMarshal.Read<ushort>(data[3..]);
}
[Flags]