mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-15 08:05:06 +00:00
27 lines
No EOL
794 B
C#
27 lines
No EOL
794 B
C#
using System.Numerics;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace Shared.Packet.Packets;
|
|
|
|
[Packet(PacketType.Cap)]
|
|
public struct CapPacket : IPacket {
|
|
public const int NameSize = 0x30;
|
|
public Vector3 Position;
|
|
public Quaternion Rotation;
|
|
public string CapAnim;
|
|
|
|
public short Size => 0x4C;
|
|
|
|
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');
|
|
}
|
|
} |