2022-02-08 16:15:31 +00:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
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.Cap)]
|
|
|
|
|
public struct CapPacket : IPacket {
|
2022-02-08 16:15:31 +00:00
|
|
|
|
public const int NameSize = 0x30;
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
public Quaternion Rotation;
|
2022-03-13 11:14:01 +00:00
|
|
|
|
public bool CapOut;
|
2022-02-08 16:15:31 +00:00
|
|
|
|
public string CapAnim;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-03-13 11:14:01 +00:00
|
|
|
|
public short Size => 0x50;
|
2022-03-11 05:59:02 +00:00
|
|
|
|
|
2022-02-08 16:15:31 +00:00
|
|
|
|
public void Serialize(Span<byte> data) {
|
|
|
|
|
MemoryMarshal.Write(data, ref Position);
|
2022-03-13 11:14:01 +00:00
|
|
|
|
MemoryMarshal.Write(data[12..], ref Rotation);
|
|
|
|
|
MemoryMarshal.Write(data[28..], ref CapOut);
|
|
|
|
|
Encoding.UTF8.GetBytes(CapAnim).CopyTo(data[32..(32 + NameSize)]);
|
2022-02-08 16:15:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Deserialize(Span<byte> data) {
|
|
|
|
|
Position = MemoryMarshal.Read<Vector3>(data);
|
|
|
|
|
Rotation = MemoryMarshal.Read<Quaternion>(data[12..]);
|
2022-03-13 11:14:01 +00:00
|
|
|
|
CapOut = MemoryMarshal.Read<bool>(data[28..]);
|
|
|
|
|
CapAnim = Encoding.UTF8.GetString(data[32..(32 + NameSize)]).TrimEnd('\0');
|
2022-02-08 16:15:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|