0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-05 19:25:04 +00:00
SmoOnlineServer/Shared/Packet/Packets/CapPacket.cs

25 lines
762 B
C#
Raw Normal View History

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:22:09 +00:00
[Packet(PacketType.Cap)]
public struct CapPacket : IPacket {
public const int NameSize = 0x30;
public Vector3 Position;
public Quaternion Rotation;
public string CapAnim;
2022-02-10 01:44:50 +00:00
public void Serialize(Span<byte> data) {
MemoryMarshal.Write(data, ref Position);
MemoryMarshal.Write(data[12..], ref Position);
Encoding.UTF8.GetBytes(CapAnim).CopyTo(data[28..]);
}
public void Deserialize(Span<byte> data) {
Position = MemoryMarshal.Read<Vector3>(data);
Rotation = MemoryMarshal.Read<Quaternion>(data[12..]);
CapAnim = Encoding.UTF8.GetString(data[28..]).TrimEnd('\0');
}
}