Initial Commit

This commit is contained in:
Sebastian Cabrera 2021-08-02 05:44:37 -04:00
parent 53eb92e9af
commit 270ab7d11f
15341 changed files with 700234 additions and 0 deletions

View file

@ -0,0 +1,33 @@
using System.Runtime.InteropServices;
namespace MLAPI.Serialization
{
[StructLayout(LayoutKind.Explicit)]
internal struct ByteBool
{
[FieldOffset(0)]
public bool BoolValue;
[FieldOffset(0)]
public byte ByteValue;
public byte Collapse() =>
ByteValue = (byte)((
// Collapse all bits to position 1 and reassign as bit
(ByteValue >> 7) |
(ByteValue >> 6) |
(ByteValue >> 5) |
(ByteValue >> 4) |
(ByteValue >> 3) |
(ByteValue >> 2) |
(ByteValue >> 1) |
ByteValue
) & 1);
public byte Collapse(bool b)
{
BoolValue = b;
return Collapse();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a92848ab7f6eed144b5247f7b06bbbb0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using System.Runtime.InteropServices;
namespace MLAPI.Serialization
{
/// <summary>
/// A struct with a explicit memory layout. The struct has 4 fields. float,uint,double and ulong.
/// Every field has the same starting point in memory. If you insert a float value, it can be extracted as a uint.
/// This is to allow for lockless and garbage free conversion from float to uint and double to ulong.
/// This allows for VarInt encoding and other integer encodings.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
internal struct UIntFloat
{
[FieldOffset(0)]
public float FloatValue;
[FieldOffset(0)]
public uint UIntValue;
[FieldOffset(0)]
public double DoubleValue;
[FieldOffset(0)]
public ulong ULongValue;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b04241ccff0cf024d81c9d62d24fe077
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: