207 lines
7.2 KiB
C#
207 lines
7.2 KiB
C#
// <auto-generated> arpack </auto-generated>
|
|
// Code generated by arpack. DO NOT EDIT.
|
|
#pragma warning disable CS8500
|
|
|
|
using System;
|
|
using System.Text;
|
|
|
|
namespace Arpack.Messages
|
|
{
|
|
public enum Opcode : ushort
|
|
{
|
|
Unknown = 0,
|
|
Authorize = 1,
|
|
JoinRoom = 2
|
|
}
|
|
|
|
public unsafe struct Vector3
|
|
{
|
|
public float X;
|
|
public float Y;
|
|
public float Z;
|
|
|
|
public int Serialize(byte* buffer)
|
|
{
|
|
byte* ptr = buffer;
|
|
*(ushort*)ptr = (ushort)((X - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
|
|
*(ushort*)ptr = (ushort)((Y - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
|
|
*(ushort*)ptr = (ushort)((Z - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
|
|
public static int Deserialize(byte* buffer, out Vector3 msg)
|
|
{
|
|
byte* ptr = buffer;
|
|
msg = default;
|
|
msg.X = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
|
|
msg.Y = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
|
|
msg.Z = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
}
|
|
|
|
public unsafe struct MoveMessage
|
|
{
|
|
public Vector3 Position;
|
|
public float[] Velocity;
|
|
public Vector3[] Waypoints;
|
|
public uint PlayerID;
|
|
public bool Active;
|
|
public bool Visible;
|
|
public bool Ghost;
|
|
public string Name;
|
|
|
|
public int Serialize(byte* buffer)
|
|
{
|
|
byte* ptr = buffer;
|
|
ptr += Position.Serialize(ptr);
|
|
for (int _iVelocity = 0; _iVelocity < 3; _iVelocity++)
|
|
{
|
|
*(float*)ptr = Velocity[_iVelocity]; ptr += 4;
|
|
}
|
|
*(ushort*)ptr = (ushort)(Waypoints?.Length ?? 0); ptr += 2;
|
|
if (Waypoints != null)
|
|
{
|
|
for (int _iWaypoints = 0; _iWaypoints < Waypoints.Length; _iWaypoints++)
|
|
{
|
|
ptr += Waypoints[_iWaypoints].Serialize(ptr);
|
|
}
|
|
}
|
|
*(uint*)ptr = PlayerID; ptr += 4;
|
|
byte _boolByte4 = 0;
|
|
if (Active) _boolByte4 |= (byte)(1 << 0);
|
|
if (Visible) _boolByte4 |= (byte)(1 << 1);
|
|
if (Ghost) _boolByte4 |= (byte)(1 << 2);
|
|
*ptr = _boolByte4; ptr++;
|
|
int _slenName = Name != null ? Encoding.UTF8.GetByteCount(Name) : 0;
|
|
*(ushort*)ptr = (ushort)_slenName; ptr += 2;
|
|
if (Name != null && _slenName > 0)
|
|
{
|
|
fixed (char* _charsName = Name)
|
|
{
|
|
Encoding.UTF8.GetBytes(_charsName, Name.Length, ptr, _slenName);
|
|
}
|
|
}
|
|
ptr += _slenName;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
|
|
public static int Deserialize(byte* buffer, out MoveMessage msg)
|
|
{
|
|
byte* ptr = buffer;
|
|
msg = default;
|
|
ptr += Vector3.Deserialize(ptr, out msg.Position);
|
|
msg.Velocity = new float[3];
|
|
for (int _iVelocity = 0; _iVelocity < 3; _iVelocity++)
|
|
{
|
|
msg.Velocity[_iVelocity] = *(float*)ptr; ptr += 4;
|
|
}
|
|
int _lenWaypoints = *(ushort*)ptr; ptr += 2;
|
|
msg.Waypoints = new Vector3[_lenWaypoints];
|
|
for (int _iWaypoints = 0; _iWaypoints < _lenWaypoints; _iWaypoints++)
|
|
{
|
|
ptr += Vector3.Deserialize(ptr, out msg.Waypoints[_iWaypoints]);
|
|
}
|
|
msg.PlayerID = *(uint*)ptr; ptr += 4;
|
|
byte _boolByte4 = *ptr; ptr++;
|
|
msg.Active = (_boolByte4 & (1 << 0)) != 0;
|
|
msg.Visible = (_boolByte4 & (1 << 1)) != 0;
|
|
msg.Ghost = (_boolByte4 & (1 << 2)) != 0;
|
|
int _slenmsg_Name = *(ushort*)ptr; ptr += 2;
|
|
msg.Name = _slenmsg_Name > 0 ? Encoding.UTF8.GetString(ptr, _slenmsg_Name) : string.Empty;
|
|
ptr += _slenmsg_Name;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
}
|
|
|
|
public unsafe struct SpawnMessage
|
|
{
|
|
public ulong EntityID;
|
|
public Vector3 Position;
|
|
public short Health;
|
|
public string[] Tags;
|
|
public byte[] Data;
|
|
|
|
public int Serialize(byte* buffer)
|
|
{
|
|
byte* ptr = buffer;
|
|
*(ulong*)ptr = EntityID; ptr += 8;
|
|
ptr += Position.Serialize(ptr);
|
|
*(short*)ptr = Health; ptr += 2;
|
|
*(ushort*)ptr = (ushort)(Tags?.Length ?? 0); ptr += 2;
|
|
if (Tags != null)
|
|
{
|
|
for (int _iTags = 0; _iTags < Tags.Length; _iTags++)
|
|
{
|
|
int _slenTags__iTags_ = Tags[_iTags] != null ? Encoding.UTF8.GetByteCount(Tags[_iTags]) : 0;
|
|
*(ushort*)ptr = (ushort)_slenTags__iTags_; ptr += 2;
|
|
if (Tags[_iTags] != null && _slenTags__iTags_ > 0)
|
|
{
|
|
fixed (char* _charsTags__iTags_ = Tags[_iTags])
|
|
{
|
|
Encoding.UTF8.GetBytes(_charsTags__iTags_, Tags[_iTags].Length, ptr, _slenTags__iTags_);
|
|
}
|
|
}
|
|
ptr += _slenTags__iTags_;
|
|
}
|
|
}
|
|
*(ushort*)ptr = (ushort)(Data?.Length ?? 0); ptr += 2;
|
|
if (Data != null)
|
|
{
|
|
for (int _iData = 0; _iData < Data.Length; _iData++)
|
|
{
|
|
*ptr = Data[_iData]; ptr += 1;
|
|
}
|
|
}
|
|
return (int)(ptr - buffer);
|
|
}
|
|
|
|
public static int Deserialize(byte* buffer, out SpawnMessage msg)
|
|
{
|
|
byte* ptr = buffer;
|
|
msg = default;
|
|
msg.EntityID = *(ulong*)ptr; ptr += 8;
|
|
ptr += Vector3.Deserialize(ptr, out msg.Position);
|
|
msg.Health = *(short*)ptr; ptr += 2;
|
|
int _lenTags = *(ushort*)ptr; ptr += 2;
|
|
msg.Tags = new string[_lenTags];
|
|
for (int _iTags = 0; _iTags < _lenTags; _iTags++)
|
|
{
|
|
int _slenmsg_Tags__iTags_ = *(ushort*)ptr; ptr += 2;
|
|
msg.Tags[_iTags] = _slenmsg_Tags__iTags_ > 0 ? Encoding.UTF8.GetString(ptr, _slenmsg_Tags__iTags_) : string.Empty;
|
|
ptr += _slenmsg_Tags__iTags_;
|
|
}
|
|
int _lenData = *(ushort*)ptr; ptr += 2;
|
|
msg.Data = new byte[_lenData];
|
|
for (int _iData = 0; _iData < _lenData; _iData++)
|
|
{
|
|
msg.Data[_iData] = *ptr; ptr += 1;
|
|
}
|
|
return (int)(ptr - buffer);
|
|
}
|
|
}
|
|
|
|
public unsafe struct EnvelopeMessage
|
|
{
|
|
public Opcode Code;
|
|
public byte Counter;
|
|
|
|
public int Serialize(byte* buffer)
|
|
{
|
|
byte* ptr = buffer;
|
|
*(ushort*)ptr = (ushort)Code; ptr += 2;
|
|
*ptr = Counter; ptr += 1;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
|
|
public static int Deserialize(byte* buffer, out EnvelopeMessage msg)
|
|
{
|
|
byte* ptr = buffer;
|
|
msg = default;
|
|
msg.Code = (Opcode)(*(ushort*)ptr); ptr += 2;
|
|
msg.Counter = *ptr; ptr += 1;
|
|
return (int)(ptr - buffer);
|
|
}
|
|
}
|
|
}
|