initial commit

This commit is contained in:
2025-07-09 21:15:31 +03:00
commit 7b809a2c60
228 changed files with 504652 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using UnityEngine;
namespace FastArena
{
internal struct Hash256
[StructLayout(LayoutKind.Sequential)]
internal readonly struct ConnectionRequestTCP
{
internal readonly PacketHeader header;
private SHA256 _sha256;
public ConnectionRequestTCP()
{
header = new PacketHeader(PacketType.ConnectionRequestTCP);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 973e6f96c4a74c8299406cfe25e29414
timeCreated: 1752080764

View File

@@ -0,0 +1,18 @@
using System.Runtime.InteropServices;
namespace FastArena;
[StructLayout(LayoutKind.Sequential)]
internal readonly struct CreateObjectPacket
{
internal readonly PacketHeader header;
internal readonly int gameObjectId;
internal readonly string prefabPath;
internal CreateObjectPacket(int _gameObjectId, string _prefabPath)
{
header = new PacketHeader(PacketType.CreateObject);
gameObjectId = _gameObjectId;
prefabPath = _prefabPath;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a0bc94f4527d493d88a018b32d36ae4f
timeCreated: 1752080638

View File

@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;
namespace FastArena
{
internal enum PacketType : ushort
{
Invalid = 0, // not packet
ConnectionRequestTCP,
ConnectionRequestUDP,
ConnectionResponseTCP,
ConnectionResponseUDP,
TransformUpdate,
CreateObject
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal readonly struct PacketHeader
{
internal const ushort MAGIC_CONST = 0x6313;
internal readonly ushort magic;
internal readonly PacketType type;
internal PacketHeader(PacketType t)
{
magic = MAGIC_CONST;
type = t;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c5d47bd361a840ab95f8411ad0d2458a
timeCreated: 1719857658

View File

@@ -0,0 +1,15 @@
namespace FastArena;
internal static class PacketParser
{
internal static PacketType ReadHeader(byte[] data)
{
var h = StructBinaryConverter.ReadStruct<PacketHeader>(data);
return h.magic == PacketHeader.MAGIC_CONST ? h.type : PacketType.Invalid;
}
internal static T ReadPacket<T>(byte[] data) where T : unmanaged
{
return StructBinaryConverter.ReadStruct<T>(data);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6f0a0f3489a547308cf0e57b45bed6c6
timeCreated: 1752080621

View File

@@ -0,0 +1,21 @@
using System.Runtime.InteropServices;
using UnityEngine;
namespace FastArena;
[StructLayout(LayoutKind.Sequential)]
internal readonly struct TransformUpdatePacket
{
internal readonly PacketHeader header;
internal readonly int gameObjectId;
internal readonly Vector3 position;
internal readonly Quaternion rotation;
internal TransformUpdatePacket(int _gameObjectId, Transform transform)
{
header = new PacketHeader(PacketType.TransformUpdate);
gameObjectId = _gameObjectId;
position = transform.position;
rotation = transform.rotation;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b57b439f5bd74ca1a4fdbe3621fae51d
timeCreated: 1752080633