2022-02-04 09:45:38 +00:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Shared.Packet.Packets;
|
|
|
|
|
|
|
|
|
|
[Packet(PacketType.Player)]
|
|
|
|
|
public struct PlayerPacket : IPacket {
|
2022-02-18 01:56:12 +00:00
|
|
|
|
public const int NameSize = 0x20;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
2022-02-22 03:39:12 +00:00
|
|
|
|
public Vector3 Position = default;
|
|
|
|
|
public Quaternion Rotation = default;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
2022-02-22 03:39:12 +00:00
|
|
|
|
public float[] AnimationBlendWeights = Array.Empty<float>();
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-22 03:39:12 +00:00
|
|
|
|
public float AnimationRate = 0;
|
|
|
|
|
public bool Is2d = false;
|
|
|
|
|
public bool ThrowingCap = false;
|
|
|
|
|
public bool IsIt = false;
|
|
|
|
|
public int ScenarioNum = 0;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-18 01:56:12 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x40)]
|
|
|
|
|
public string Stage = "";
|
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NameSize)]
|
2022-02-18 01:56:12 +00:00
|
|
|
|
public string Act = "";
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NameSize)]
|
2022-02-18 01:56:12 +00:00
|
|
|
|
public string SubAct = "";
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NameSize)]
|
2022-02-18 01:56:12 +00:00
|
|
|
|
public string Hack = "";
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
2022-02-22 03:39:12 +00:00
|
|
|
|
public PlayerPacket() { }
|
|
|
|
|
|
2022-02-04 09:45:38 +00:00
|
|
|
|
public void Serialize(Span<byte> data) {
|
|
|
|
|
int offset = 0;
|
|
|
|
|
MemoryMarshal.Write(data, ref Position);
|
|
|
|
|
offset += Marshal.SizeOf<Vector3>();
|
|
|
|
|
MemoryMarshal.Write(data[offset..], ref Rotation);
|
|
|
|
|
offset += Marshal.SizeOf<Quaternion>();
|
|
|
|
|
AnimationBlendWeights.CopyTo(MemoryMarshal.Cast<byte, float>(data[offset..(offset += 4 * 6)]));
|
|
|
|
|
MemoryMarshal.Write(data[offset..], ref AnimationRate);
|
|
|
|
|
offset += 4;
|
|
|
|
|
MemoryMarshal.Write(data[offset++..], ref Is2d);
|
|
|
|
|
MemoryMarshal.Write(data[offset++..], ref ThrowingCap);
|
|
|
|
|
MemoryMarshal.Write(data[offset++..], ref IsIt);
|
|
|
|
|
MemoryMarshal.Write(data[offset..], ref ScenarioNum);
|
|
|
|
|
offset += 5;
|
2022-02-18 01:56:12 +00:00
|
|
|
|
Encoding.UTF8.GetBytes(Stage).CopyTo(data[offset..(offset + 0x40)]);
|
|
|
|
|
offset += 0x40;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
Encoding.UTF8.GetBytes(Act).CopyTo(data[offset..(offset + NameSize)]);
|
|
|
|
|
offset += NameSize;
|
2022-02-18 01:56:12 +00:00
|
|
|
|
Encoding.UTF8.GetBytes(SubAct).CopyTo(data[offset..(offset + NameSize)]);
|
|
|
|
|
offset += NameSize;
|
|
|
|
|
Encoding.UTF8.GetBytes(Hack).CopyTo(data[offset..]);
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Deserialize(Span<byte> data) {
|
|
|
|
|
int offset = 0;
|
|
|
|
|
Position = MemoryMarshal.Read<Vector3>(data);
|
|
|
|
|
offset += Marshal.SizeOf<Vector3>();
|
|
|
|
|
Rotation = MemoryMarshal.Read<Quaternion>(data[offset..]);
|
|
|
|
|
offset += Marshal.SizeOf<Quaternion>();
|
|
|
|
|
AnimationBlendWeights = MemoryMarshal.Cast<byte, float>(data[offset..(offset += 4 * 6)]).ToArray();
|
|
|
|
|
AnimationRate = MemoryMarshal.Read<float>(data[offset..(offset += 4)]);
|
|
|
|
|
Is2d = MemoryMarshal.Read<bool>(data[offset++..]);
|
|
|
|
|
ThrowingCap = MemoryMarshal.Read<bool>(data[offset++..]);
|
|
|
|
|
IsIt = MemoryMarshal.Read<bool>(data[offset++..]);
|
|
|
|
|
// offset++; // padding
|
|
|
|
|
ScenarioNum = MemoryMarshal.Read<int>(data[offset..]);
|
|
|
|
|
offset += 5;
|
2022-02-18 01:56:12 +00:00
|
|
|
|
Stage = Encoding.UTF8.GetString(data[offset..(offset + 0x40)]).TrimEnd('\0');
|
|
|
|
|
offset += 0x40;
|
2022-02-08 16:15:31 +00:00
|
|
|
|
Act = Encoding.UTF8.GetString(data[offset..(offset + NameSize)]).TrimEnd('\0');
|
2022-02-04 09:45:38 +00:00
|
|
|
|
offset += NameSize;
|
2022-02-08 16:15:31 +00:00
|
|
|
|
SubAct = Encoding.UTF8.GetString(data[offset..(offset + NameSize)]).TrimEnd('\0');
|
2022-02-18 01:56:12 +00:00
|
|
|
|
offset += NameSize;
|
2022-02-22 20:11:06 +00:00
|
|
|
|
Hack = Encoding.UTF8.GetString(data[offset..(offset + NameSize)]).TrimEnd('\0');
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
2021-11-29 04:04:34 +00:00
|
|
|
|
}
|