using System.Runtime.InteropServices; using Shared.Packet.Packets; namespace Shared.Packet; [StructLayout(LayoutKind.Sequential)] public struct PacketHeader : IPacket { // public int Length; public Guid Id; public PacketType Type; public short PacketSize; public short Size => 20; public void Serialize(Span data) { MemoryMarshal.Write(data, ref Id); MemoryMarshal.Write(data[16..], ref Type); MemoryMarshal.Write(data[18..], ref PacketSize); } public void Deserialize(Span data) { Id = MemoryMarshal.Read(data); Type = MemoryMarshal.Read(data[16..]); PacketSize = MemoryMarshal.Read(data[16..]); } }