diff --git a/Networking/Encoders/Base/ArrayEncoderBase.cs b/Networking/Encoders/Base/ArrayEncoderBase.cs new file mode 100644 index 0000000..36865d1 --- /dev/null +++ b/Networking/Encoders/Base/ArrayEncoderBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Text; +using Progression.IO.Encoders.Special; +using Progression.Util; + +namespace Progression.IO.Encoders.Base +{ + public abstract class ArrayEncoderBase:Derived1EncoderBase + { + protected ArrayEncoderBase(IEncoder baseEncoder, IEncoder rootEncoder) : base(baseEncoder, rootEncoder, "Array", new Guid("F9251789-FEAA-4184-A9D4-9090ED902E92")) {} + + + public abstract void EncodeHeadless(TBase[] objs, PacketData data); + public abstract TBase[] DecodeHeadless(PacketData data, int arrayLength); + + public override TBase[] Decode(PacketData data) + { + int arrayLength = Types.Int32.Decode(data); + return DecodeHeadless(data, arrayLength); + } + + public override void Encode(TBase[] objs, PacketData data) + { + Types.Int32.Encode(objs.Length, data); + EncodeHeadless(objs, data); + } + + public override int Estimate(TBase[] objs) + { + if (BaseEncoder.FixedSize) return objs.Length * BaseEncoder.ByteSize + 4; + + int result = 4; + foreach (var obj in objs) { + result += BaseEncoder.Estimate(obj); + } + return result; + } + + + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/Derived1EncoderBase.cs b/Networking/Encoders/Base/Derived1EncoderBase.cs new file mode 100644 index 0000000..a09a84c --- /dev/null +++ b/Networking/Encoders/Base/Derived1EncoderBase.cs @@ -0,0 +1,35 @@ +using System; +using Progression.IO.Encoders.Special; +using Progression.Util; + +namespace Progression.IO.Encoders.Base { + public abstract class Derived1EncoderBase:DerivedEncoderBase + { + public Derived1EncoderBase(IEncoder baseEncoder, IEncoder rootEncoder, string derivationTypeName, Guid guidNamespace ) + { + BaseEncoder = baseEncoder; + RootEncoder = rootEncoder; + var name = $"{derivationTypeName}<{BaseEncoder.Name}>"; + Guid = GuidUtil.Create(guidNamespace, name); + Name = name; + } + public IEncoder BaseEncoder { get; } + public IEncoder RootEncoder { get; } + + public override string Name { get; } + public override Guid Guid { get; } + + + protected override NullableEncoderBase CreateNullable() + { + return new NullableEncoder(this, RootEncoder); + } + + protected override ArrayEncoderBase CreateArray() + { + return new ArrayEncoder(this, RootEncoder); + } + + public override bool FixedSize => false; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/Derived2EncoderBase.cs b/Networking/Encoders/Base/Derived2EncoderBase.cs new file mode 100644 index 0000000..68cd338 --- /dev/null +++ b/Networking/Encoders/Base/Derived2EncoderBase.cs @@ -0,0 +1,35 @@ +using System; +using Progression.IO.Encoders.Special; +using Progression.Util; + +namespace Progression.IO.Encoders.Base { + public abstract class Derived2EncoderBase:DerivedEncoderBase + { + public Derived2EncoderBase(IEncoder base1Encoder, IEncoder base2Encoder, string derivationTypeName, Guid guidNamespace ) + { + Base1Encoder = base1Encoder; + Base2Encoder = base2Encoder; + var name = $"{derivationTypeName}<{Base1Encoder.Name}, {Base2Encoder.Name}>"; + Guid = GuidUtil.Create(guidNamespace, name); + Name = name; + } + public IEncoder Base1Encoder { get; } + public IEncoder Base2Encoder { get; } + + public override string Name { get; } + public override Guid Guid { get; } + + + protected override NullableEncoderBase CreateNullable() + { + return new NullableEncoder(this, this); + } + + protected override ArrayEncoderBase CreateArray() + { + return new ArrayEncoder(this, this); + } + + public override bool FixedSize => false; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/DerivedEncoderBase.cs b/Networking/Encoders/Base/DerivedEncoderBase.cs new file mode 100644 index 0000000..90ebb72 --- /dev/null +++ b/Networking/Encoders/Base/DerivedEncoderBase.cs @@ -0,0 +1,7 @@ +namespace Progression.IO.Encoders.Base +{ + public abstract class DerivedEncoderBase:EncoderBase + { + public override bool IsBaseEncoder => false; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/EncoderBase.cs b/Networking/Encoders/Base/EncoderBase.cs new file mode 100644 index 0000000..7ac1622 --- /dev/null +++ b/Networking/Encoders/Base/EncoderBase.cs @@ -0,0 +1,69 @@ +using System; +using System.Linq; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders.Base +{ + public abstract class EncoderBase : IEncoder + { + protected EncoderBase() + { + // ReSharper disable once VirtualMemberCallInConstructor + if (IsBaseEncoder) { + if (!Types._registeredBaseTypes.Contains(this)) { + Types._registeredBaseTypes.Add(this); + } + } + } + public abstract void Encode(TType obj, PacketData data); + void IEncoder.Encode(object obj, PacketData data) => Encode((TType) obj, data); + + object IEncoder.Decode(PacketData data) => Decode(data); + + int IEncoder.Estimate(object obj) => Estimate((TType) obj); + + public override bool Equals(object obj) + { + return obj != null & obj is IEncoder & ((IEncoder) obj)?.EncodingType == EncodingType; + } + + public abstract TType Decode(PacketData data); + public abstract int Estimate(TType obj); + public abstract string Name { get; } + public abstract Guid Guid { get; } + public abstract bool FixedSize { get; } + + public virtual int ByteSize => -1; + + public virtual bool IsBaseEncoder => typeof(TType) == typeof(TRoot); + + IEncoder IEncoder.Nullable => NullableObject; + protected virtual IEncoder NullableObject => Nullable; + + IEncoder IEncoder.Array => Array; + public Type EncodingType => typeof(TRoot); + + + private NullableEncoderBase _nullable; + public NullableEncoderBase Nullable => _nullable = _nullable ?? CreateNullable(); + + protected abstract NullableEncoderBase CreateNullable(); + + private ArrayEncoderBase _array; + public ArrayEncoderBase Array => _array = _array ?? CreateArray(); + + protected abstract ArrayEncoderBase CreateArray(); + } + + public abstract class EncoderBase : EncoderBase { + + protected override ArrayEncoderBase CreateArray() + { + return new ArrayEncoder(this, this); + } + protected override NullableEncoderBase CreateNullable() + { + return new NullableEncoder(this, this); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/IEncoder.cs b/Networking/Encoders/Base/IEncoder.cs new file mode 100644 index 0000000..b326ac7 --- /dev/null +++ b/Networking/Encoders/Base/IEncoder.cs @@ -0,0 +1,27 @@ +using System; + +namespace Progression.IO.Encoders.Base { + public interface IEncoder : IEncoder { + void Encode(TType obj, PacketData data); + new TType Decode(PacketData data); + int Estimate(TType obj); + } + + public interface IEncoder : IEncoder { + new NullableEncoderBase Nullable { get; } + new ArrayEncoderBase Array { get; } + } + + public interface IEncoder { + void Encode(object obj, PacketData data); + object Decode(PacketData data); + int Estimate(object obj); + string Name { get; } + Guid Guid { get; } + bool FixedSize { get; } + int ByteSize { get; } + IEncoder Nullable { get; } + IEncoder Array { get; } + Type EncodingType { get; } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/NullableEncoderBase.cs b/Networking/Encoders/Base/NullableEncoderBase.cs new file mode 100644 index 0000000..ac55fe4 --- /dev/null +++ b/Networking/Encoders/Base/NullableEncoderBase.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders.Base { + public abstract class NullableEncoderBase : Derived1EncoderBase + { + protected NullableEncoderBase(IEncoder baseEncoder, IEncoder rootEncoder) : base(baseEncoder, rootEncoder, "Nullable", new Guid("F0691A4D-F47D-4FF6-901F-C8832A434ABE")) { } + + protected override NullableEncoderBase CreateNullable() + { + return this; + } + + protected override ArrayEncoderBase CreateArray() + { + return new NullableArrayEncoder(BaseEncoder, RootEncoder); + } + + public override int Estimate(TType obj) + { + return EqualityComparer.Default.Equals(obj, default(TType))?1:BaseEncoder.Estimate(obj) + 1; + } + + public override bool FixedSize => false; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Base/StructEncoderBase.cs b/Networking/Encoders/Base/StructEncoderBase.cs new file mode 100644 index 0000000..6f1e4c8 --- /dev/null +++ b/Networking/Encoders/Base/StructEncoderBase.cs @@ -0,0 +1,128 @@ +using System; +using System.Diagnostics; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders.Base +{ + public abstract class StructEncoderBase : EncoderBase where T : struct + { + public StructEncoderBase() + { + _wrapper = new NullableStructWrapper(this); + } + + public override bool FixedSize => true; + + public abstract override int ByteSize { get; } + + public sealed override int Estimate(T obj) + { + return ByteSize; + } + + private readonly NullableStructWrapper _wrapper; + + protected override IEncoder NullableObject => Nullable; + private NullableEncoderBase _nullable; + public new NullableEncoderBase Nullable => _nullable = _nullable ?? CreateNullable(); + + protected new NullableEncoderBase CreateNullable() + { + return new NullableEncoder(_wrapper, this); + } + + private class NullableStructWrapper : IEncoder + { + private readonly StructEncoderBase _encoderImplementation; + public NullableStructWrapper(StructEncoderBase encoderImplementation) + { + _encoderImplementation = encoderImplementation; + } + + public void Encode(T? obj, PacketData data) + { + + _encoderImplementation.Encode(obj.Value, data); + } + + public void Encode(object obj, PacketData data) + { + ((IEncoder) _encoderImplementation).Encode(obj, data); + } + + object IEncoder.Decode(PacketData data) + { + return ((IEncoder) _encoderImplementation).Decode(data); + } + + public int Estimate(object obj) + { + return ((IEncoder) _encoderImplementation).Estimate(obj); + } + + public T? Decode(PacketData data) + { + return _encoderImplementation.Decode(data); + } + + public int Estimate(T? obj) + { + return _encoderImplementation.Estimate(obj.Value); + } + + public string Name => _encoderImplementation.Name; + + public Guid Guid => _encoderImplementation.Guid; + + public bool FixedSize => _encoderImplementation.FixedSize; + + public int ByteSize => _encoderImplementation.ByteSize; + IEncoder IEncoder.Nullable => ((IEncoder) _encoderImplementation).Nullable; + + IEncoder IEncoder.Array => ((IEncoder) _encoderImplementation).Array; + public Type EncodingType => _encoderImplementation.EncodingType; + + public NullableEncoderBase Nullable => _encoderImplementation.Nullable; + + public ArrayEncoderBase Array => Nullable.Array; + + public static implicit operator StructEncoderBase(NullableStructWrapper value) + { + return value._encoderImplementation; + } + + + public static implicit operator NullableStructWrapper(StructEncoderBase value) + { + return value._wrapper; + } + + public static bool operator ==(NullableStructWrapper obj1, StructEncoderBase obj2) + { + if (ReferenceEquals(obj1, null)) { + return false; + } + if (ReferenceEquals(obj2, null)) { + return false; + } + + return ReferenceEquals(obj1._encoderImplementation, obj2); + } + + public static bool operator !=(NullableStructWrapper obj1, StructEncoderBase obj2) + { + return !(obj1 == obj2); + } + + public override int GetHashCode() + { + return _encoderImplementation.GetHashCode(); + } + + public override bool Equals(object obj) + { + return ReferenceEquals(this, obj) | (obj is StructEncoderBase & (StructEncoderBase ) obj == this); + } + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/BoolEncoder.cs b/Networking/Encoders/BoolEncoder.cs new file mode 100644 index 0000000..97370b3 --- /dev/null +++ b/Networking/Encoders/BoolEncoder.cs @@ -0,0 +1,33 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders +{ + public class BoolEncoder : StructEncoderBase + + { + public override void Encode(bool obj, PacketData data) + { + data.Data[data.Position] = obj ? (byte)1 : (byte)0; + data.ShiftPosition(1); + } + + public override bool Decode(PacketData data) + { + var result = data.Data[data.Position] != 0; + data.ShiftPosition(1); + return result; + } + + + public override string Name => "Bool"; + public override Guid Guid { get; } = new Guid("73F87080-2C2E-4470-AD91-96C89C322D1F"); + public override int ByteSize => 1; + + protected override ArrayEncoderBase CreateArray() + { + return new BoolArrayEncoder(this); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Collections/Base/CollectionEncoderBase.cs b/Networking/Encoders/Collections/Base/CollectionEncoderBase.cs new file mode 100644 index 0000000..8ade1b2 --- /dev/null +++ b/Networking/Encoders/Collections/Base/CollectionEncoderBase.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Collections.Base +{ + public abstract class CollectionEncoderBase:EnumerableEncoderBase where TCollection : IReadOnlyCollection + { + public CollectionEncoderBase(IEncoder baseEncoder, IEncoder rootEncoder, string derivationTypeName, Guid guidNamespace) : base(baseEncoder, rootEncoder, derivationTypeName, guidNamespace) { } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Collections/Base/DictionaryEncoderBase.cs b/Networking/Encoders/Collections/Base/DictionaryEncoderBase.cs new file mode 100644 index 0000000..f1cde82 --- /dev/null +++ b/Networking/Encoders/Collections/Base/DictionaryEncoderBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders.Collections.Base { + public abstract class DictionaryEncoderBase : Derived2EncoderBase where TDictionary : IReadOnlyDictionary + { + public ArrayEncoderBase<(TBase1 key, TBase2 value), (TBase1 key, TBase2 value)> InternalArrayEncoder { get; } + public Tuple2Encoder InternalTupleEncoder{ get; } + + protected DictionaryEncoderBase(IEncoder base1Encoder, + IEncoder base2Encoder, string derivationTypeName, Guid guidNamespace) : base( + base1Encoder, base2Encoder, derivationTypeName, guidNamespace) + { + InternalTupleEncoder = new Tuple2Encoder(base1Encoder, base2Encoder); + InternalArrayEncoder = InternalTupleEncoder.Array; + } + + public override void Encode(TDictionary obj, PacketData data) + { + //InternalArrayEncoder.Encode(obj.ToArray(), data); + //todo: with current design achievable but not in a nice way + } + + public override TDictionary Decode(PacketData data) + { + var array = InternalArrayEncoder.Decode(data); + return createObject(array, data); + } + + protected abstract TDictionary createObject((TBase1 key, TBase2 value)[] content, PacketData data); + + public override int Estimate(TDictionary obj) + { + //InternalArrayEncoder.Estimate(obj.ToArray()); //array created two times. there might be a more elegant solution with no array conversion at all + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Collections/Base/EnumerableEncoderBase.cs b/Networking/Encoders/Collections/Base/EnumerableEncoderBase.cs new file mode 100644 index 0000000..c81223f --- /dev/null +++ b/Networking/Encoders/Collections/Base/EnumerableEncoderBase.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Collections.Base +{ + public abstract class EnumerableEncoderBase:Derived1EncoderBase where TEnumerable : IEnumerable + { + public ArrayEncoderBase InternalArrayEncoder { get; } + + public EnumerableEncoderBase(IEncoder baseEncoder, IEncoder rootEncoder, + string derivationTypeName, Guid guidNamespace) : base(baseEncoder, rootEncoder, derivationTypeName, + guidNamespace) + { + InternalArrayEncoder = baseEncoder.Array; + } + + public override void Encode(TEnumerable obj, PacketData data) + { + InternalArrayEncoder.Encode(obj.ToArray(), data); + } + + public override TEnumerable Decode(PacketData data) + { + var array = InternalArrayEncoder.Decode(data); + return createObject(array); + } + + protected abstract TEnumerable createObject(TBase[] content); + + public override int Estimate(TEnumerable obj) + { + return InternalArrayEncoder.Estimate(obj.ToArray()); //array created two times. there might be a more elegant solution with no array conversion at all + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Float32Encoder.cs b/Networking/Encoders/Float32Encoder.cs new file mode 100644 index 0000000..1c18f83 --- /dev/null +++ b/Networking/Encoders/Float32Encoder.cs @@ -0,0 +1,44 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class Float32Encoder : StructEncoderBase + { + public override void Encode(float obj, PacketData data) + { + Int32Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + } else { + bytes[pos + 3] = conv.Byte0; + bytes[pos + 2] = conv.Byte1; + bytes[pos + 1] = conv.Byte2; + bytes[pos] = conv.Byte3; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 4; + + public override float Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int32Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3]) + : new Int32Converter(bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "Float32"; + public override Guid Guid { get; } = new Guid("895A8E1C-2C29-4810-BD82-4E94048FF318"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/Float64Encoder.cs b/Networking/Encoders/Float64Encoder.cs new file mode 100644 index 0000000..ac93ad8 --- /dev/null +++ b/Networking/Encoders/Float64Encoder.cs @@ -0,0 +1,52 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class Float64Encoder : StructEncoderBase + { + public override void Encode(double obj, PacketData data) + { + Int64Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + bytes[pos + 4] = conv.Byte4; + bytes[pos + 5] = conv.Byte5; + bytes[pos + 6] = conv.Byte6; + bytes[pos + 7] = conv.Byte7; + } else { + bytes[pos + 7] = conv.Byte0; + bytes[pos + 6] = conv.Byte1; + bytes[pos + 5] = conv.Byte2; + bytes[pos + 4] = conv.Byte3; + bytes[pos + 3] = conv.Byte4; + bytes[pos + 2] = conv.Byte5; + bytes[pos + 1] = conv.Byte6; + bytes[pos] = conv.Byte7; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 8; + + public override double Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int64Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3], bytes[pos + 4], bytes[pos + 5], bytes[pos + 6], bytes[pos + 7]) + : new Int64Converter(bytes[pos + 7], bytes[pos + 6], bytes[pos + 5], bytes[pos + 4], bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "Float64"; + public override Guid Guid { get; } = new Guid("6E1BE3C5-D34C-435B-8CE4-BE6EC5804D9F"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/GuidEncoder.cs b/Networking/Encoders/GuidEncoder.cs new file mode 100644 index 0000000..e1ddc86 --- /dev/null +++ b/Networking/Encoders/GuidEncoder.cs @@ -0,0 +1,51 @@ +using System; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders +{ + public class GuidEncoder : StructEncoderBase + + { + public override void Encode(Guid obj, PacketData data) + { + var bytes = obj.ToByteArray(); + if (BitConverter.IsLittleEndian) FlipEndianness(bytes); + System.Array.Copy(bytes, 0, data.Data, data.Position, ByteSize); + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 16; + + public override Guid Decode(PacketData data) + { + var bytes = new byte[ByteSize]; + System.Array.Copy(data.Data, data.Position, bytes, 0, ByteSize); + if (BitConverter.IsLittleEndian) FlipEndianness(bytes); + data.ShiftPosition(ByteSize); + return new Guid(bytes); + } + + private static void FlipEndianness(byte[] bytes) + { + var temp = bytes[3]; + bytes[3] = bytes[0]; + bytes[0] = temp; + + temp = bytes[2]; + bytes[2] = bytes[1]; + bytes[1] = temp; + + temp = bytes[5]; + bytes[5] = bytes[4]; + bytes[4] = temp; + + temp = bytes[7]; + bytes[7] = bytes[6]; + bytes[6] = temp; + } + + + public override string Name => "Guid"; + public override Guid Guid { get; } = new Guid("A5BF0DF0-D612-4DF7-8CC0-432CB1ADC606"); + } +} \ No newline at end of file diff --git a/Networking/Encoders/Int16Encoder.cs b/Networking/Encoders/Int16Encoder.cs new file mode 100644 index 0000000..81bf638 --- /dev/null +++ b/Networking/Encoders/Int16Encoder.cs @@ -0,0 +1,40 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class Int16Encoder : StructEncoderBase + { + public override void Encode(short obj, PacketData data) + { + Int16Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + } else { + bytes[pos + 1] = conv.Byte0; + bytes[pos] = conv.Byte1; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 2; + + public override short Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int16Converter(bytes[pos], bytes[pos + 1]) + : new Int16Converter(bytes[pos + 1], bytes[pos]); + } + + public override string Name => "SInt16"; + public override Guid Guid { get; } = new Guid("460A4E1C-4E12-4210-8324-754B8230CA45"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/Int32Encoder.cs b/Networking/Encoders/Int32Encoder.cs new file mode 100644 index 0000000..cc82d57 --- /dev/null +++ b/Networking/Encoders/Int32Encoder.cs @@ -0,0 +1,44 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class Int32Encoder : StructEncoderBase + { + public override void Encode(int obj, PacketData data) + { + Int32Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + } else { + bytes[pos + 3] = conv.Byte0; + bytes[pos + 2] = conv.Byte1; + bytes[pos + 1] = conv.Byte2; + bytes[pos] = conv.Byte3; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 4; + + public override int Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int32Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3]) + : new Int32Converter(bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "SInt32"; + public override Guid Guid { get; } = new Guid("7181A9C2-1B40-4557-8819-84251370709D"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/Int64Encoder.cs b/Networking/Encoders/Int64Encoder.cs new file mode 100644 index 0000000..2900b1a --- /dev/null +++ b/Networking/Encoders/Int64Encoder.cs @@ -0,0 +1,52 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class Int64Encoder : StructEncoderBase + { + public override void Encode(long obj, PacketData data) + { + Int64Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + bytes[pos + 4] = conv.Byte4; + bytes[pos + 5] = conv.Byte5; + bytes[pos + 6] = conv.Byte6; + bytes[pos + 7] = conv.Byte7; + } else { + bytes[pos + 7] = conv.Byte0; + bytes[pos + 6] = conv.Byte1; + bytes[pos + 5] = conv.Byte2; + bytes[pos + 4] = conv.Byte3; + bytes[pos + 3] = conv.Byte4; + bytes[pos + 2] = conv.Byte5; + bytes[pos + 1] = conv.Byte6; + bytes[pos] = conv.Byte7; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 8; + + public override long Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int64Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3], bytes[pos + 4], bytes[pos + 5], bytes[pos + 6], bytes[pos + 7]) + : new Int64Converter(bytes[pos + 7], bytes[pos + 6], bytes[pos + 5], bytes[pos + 4], bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "SInt64"; + public override Guid Guid { get; } = new Guid("AA5FAA27-6607-4414-BFCF-E522F8127775"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/Int8Encoder.cs b/Networking/Encoders/Int8Encoder.cs new file mode 100644 index 0000000..6293351 --- /dev/null +++ b/Networking/Encoders/Int8Encoder.cs @@ -0,0 +1,27 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Special; + +namespace Progression.IO.Encoders { + public class Int8Encoder : StructEncoderBase + + { + public override void Encode(sbyte obj, PacketData data) + { + data.Data[data.Position] = (byte)obj; + data.ShiftPosition(1); + } + + public override sbyte Decode(PacketData data) + { + var result = (sbyte)data.Data[data.Position]; + data.ShiftPosition(1); + return result; + } + + + public override string Name => "SInt8"; + public override Guid Guid { get; } = new Guid("B4F02878-94D3-424A-8F2F-A120E237C30B"); + public override int ByteSize => 1; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Special/ArrayEncoder.cs b/Networking/Encoders/Special/ArrayEncoder.cs new file mode 100644 index 0000000..88d69cc --- /dev/null +++ b/Networking/Encoders/Special/ArrayEncoder.cs @@ -0,0 +1,25 @@ +using System; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Special +{ + public class ArrayEncoder:ArrayEncoderBase + { + public ArrayEncoder(IEncoder baseEncoder, IEncoder rootEncoder) : base(baseEncoder, rootEncoder) { } + public override void EncodeHeadless(TBase[] objs, PacketData data) + { + foreach (var obj in objs) { + BaseEncoder.Encode(obj, data); + } + } + + public override TBase[] DecodeHeadless(PacketData data, int arrayLength) + { + var result = new TBase[arrayLength]; + for (int i = 0; i < arrayLength; i++) { + result[i] = BaseEncoder.Decode(data); + } + return result; + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Special/BoolArrayEncoder.cs b/Networking/Encoders/Special/BoolArrayEncoder.cs new file mode 100644 index 0000000..51aade0 --- /dev/null +++ b/Networking/Encoders/Special/BoolArrayEncoder.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Special { + public class BoolArrayEncoder : ArrayEncoder + { + public BoolArrayEncoder(IEncoder boolEncoder) : base(boolEncoder, boolEncoder) { } + + public override int Estimate(bool[] objs) + { + return getBytesLength(objs.Length) + 4; //rounds up and adds 4 + } + + + public override bool[] DecodeHeadless(PacketData data, int arrayLength) + { + var result = new bool[arrayLength]; + DecodeBoolArray(data, arrayLength, index => result[index] = true); + return result; + } + + public override void EncodeHeadless(bool[] objs, PacketData data) + { + EncodeBoolArray(objs, data, index => { }); //i hope this delegates dont have a lot of overhead but i want to reuse code and not copy and paste + } + + + public static void DecodeBoolArray(PacketData data, int arrayLength, Process setValue) + { + var bytesLength = getBytesLength(arrayLength); //rounds up + int pos = data.Position; + data.ShiftPosition(bytesLength); + int i = 0; + for (int index = pos; index < pos + bytesLength; index++) { + byte current = data.Data[index]; + for (int j = 0; j < 8 & i < arrayLength; j++) { + if ((current&1)==1) { + setValue(i); + } + current <<= 1; + i++; + } + } + } + + + public delegate void Process(int arrayIndex); + + public static void EncodeBoolArray(T[] objs, PacketData data, Process process) + { + var arrayLength = objs.Length; + var bytesLength = getBytesLength(arrayLength); //rounds up + int pos = data.Position; + data.ShiftPosition(bytesLength); + int i = 0; + for (int index = pos; index < pos + bytesLength; index++) { + byte current = 0; + for (int j = 0; j < 8 & i < arrayLength; j++) { + if (!EqualityComparer.Default.Equals(objs[i], default(T))) { + current++; + process(i); + } + current <<= 1; + i++; + } + data.Data[index] = current; + } + } + + public static int getBytesLength(int arrayLength) => (arrayLength + 7) / 8; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Special/NullableArrayEncoder.cs b/Networking/Encoders/Special/NullableArrayEncoder.cs new file mode 100644 index 0000000..67bd07f --- /dev/null +++ b/Networking/Encoders/Special/NullableArrayEncoder.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Special +{ + public class NullableArrayEncoder : ArrayEncoder + { + public NullableArrayEncoder(IEncoder baseEncoder, IEncoder rootEncoder) : base(baseEncoder, rootEncoder) { } + + public override void EncodeHeadless(TBase[] objs, PacketData data) + { + BoolArrayEncoder.EncodeBoolArray(objs, data, index => BaseEncoder.Encode(objs[index], data)); + } + + public override TBase[] DecodeHeadless(PacketData data, int arrayLength) + { + var result = new TBase[arrayLength]; + BoolArrayEncoder.DecodeBoolArray(data, arrayLength, index => result[index] = BaseEncoder.Decode(data)); + return result; + } + + public override int Estimate(TBase[] objs) + { + int bytes = 0; + foreach (var obj in objs) { + if (!EqualityComparer.Default.Equals(obj, default(TBase))) bytes+=BaseEncoder.Estimate(obj); + } + + return bytes + BoolArrayEncoder.getBytesLength(objs.Length) + 4; + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Special/NullableEncoder.cs b/Networking/Encoders/Special/NullableEncoder.cs new file mode 100644 index 0000000..6641135 --- /dev/null +++ b/Networking/Encoders/Special/NullableEncoder.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Special +{ + public class NullableEncoder : NullableEncoderBase + { + public NullableEncoder(IEncoder baseEncoder, IEncoder rootEncoder) : base(baseEncoder, rootEncoder) { } + public override void Encode(TType obj, PacketData data) + { + var isNull = EqualityComparer.Default.Equals(obj, default(TType)); + Types.Bool.Encode(isNull, data); + if (!isNull) { + BaseEncoder.Encode(obj, data); + } + } + + public override TType Decode(PacketData data) + { + var isNull = Types.Bool.Decode(data); + return isNull ? default(TType) : BaseEncoder.Decode(data); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Special/Tuple2Encoder.cs b/Networking/Encoders/Special/Tuple2Encoder.cs new file mode 100644 index 0000000..e5c8000 --- /dev/null +++ b/Networking/Encoders/Special/Tuple2Encoder.cs @@ -0,0 +1,27 @@ +using System; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders.Special +{ + public class Tuple2Encoder : Derived2EncoderBase<(TBase1, TBase2), TBase1, TRoot1, TBase2, TRoot2> + + { + public Tuple2Encoder(IEncoder base1Encoder, IEncoder base2Encoder) : base(base1Encoder, base2Encoder, "Tuple2", new Guid("C837157D-7629-4FD7-A701-0D9C3A15598A")) { } + public override void Encode((TBase1, TBase2) obj, PacketData data) + { + Base1Encoder.Encode(obj.Item1, data); + Base2Encoder.Encode(obj.Item2, data); + } + + public override (TBase1, TBase2) Decode(PacketData data) + { + return (Base1Encoder.Decode(data), Base2Encoder.Decode(data)); + } + + public override int Estimate((TBase1, TBase2) obj) + { + return Base1Encoder.Estimate(obj.Item1) + Base2Encoder.Estimate(obj.Item2); + } + + } +} \ No newline at end of file diff --git a/Networking/Encoders/StringEncoder.cs b/Networking/Encoders/StringEncoder.cs new file mode 100644 index 0000000..06309ba --- /dev/null +++ b/Networking/Encoders/StringEncoder.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using Progression.IO.Encoders.Base; +using Progression.Util; + +namespace Progression.IO.Encoders +{ + public class StringEncoder : EncoderBase + { + public readonly Encoding Encoding; + public static readonly Guid GuidNamespace = new Guid("DEF1D9D6-69FE-4378-9BD8-553B1722C013"); + + + public StringEncoder(Encoding encoding) + { + Encoding = encoding; + Name = $"String {Encoding.WebName}"; + Guid = GuidUtil.Create(GuidNamespace, Encoding.WebName); + } + + public override void Encode(string obj, PacketData data) + { + //int32 encoder is yet to shift pos + var encodedLength = Encoding.GetBytes(obj, 0, obj.Length, data.Data, data.Position+4); + Types.Int32.Encode(encodedLength, data); + data.ShiftPosition(encodedLength); + } + + public override int Estimate(string obj) + { + return Encoding.GetByteCount(obj) + 4; + } + + public override string Decode(PacketData data) + { + var encodedLength = Types.Int32.Decode(data); + //pos already shifted + var pos = data.Position; + data.ShiftPosition(encodedLength); + return Encoding.GetString(data.Data, pos, encodedLength); + } + + public override string Name { get; } + public override Guid Guid { get; } + public override bool FixedSize => false; + + public override bool Equals(object obj) + { + return obj != null & obj is StringEncoder & Equals((obj as StringEncoder)?.Encoding, Encoding) ; + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/UInt16Encoder.cs b/Networking/Encoders/UInt16Encoder.cs new file mode 100644 index 0000000..cac13bb --- /dev/null +++ b/Networking/Encoders/UInt16Encoder.cs @@ -0,0 +1,41 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class UInt16Encoder : StructEncoderBase + { + public override void Encode(ushort obj, PacketData data) + { + Int16Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + } else { + bytes[pos + 1] = conv.Byte0; + bytes[pos] = conv.Byte1; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 2; + + + public override ushort Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int16Converter(bytes[pos], bytes[pos + 1]) + : new Int16Converter(bytes[pos + 1], bytes[pos]); + } + + public override string Name => "UInt16"; + public override Guid Guid { get; } = new Guid("E7B449D6-D64D-4B2E-9677-96992F1A5C10"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/UInt32Encoder.cs b/Networking/Encoders/UInt32Encoder.cs new file mode 100644 index 0000000..f260830 --- /dev/null +++ b/Networking/Encoders/UInt32Encoder.cs @@ -0,0 +1,45 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders +{ + public class UInt32Encoder : StructEncoderBase + { + public override void Encode(uint obj, PacketData data) + { + Int32Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + } else { + bytes[pos + 3] = conv.Byte0; + bytes[pos + 2] = conv.Byte1; + bytes[pos + 1] = conv.Byte2; + bytes[pos] = conv.Byte3; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 4; + + public override uint Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int32Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3]) + : new Int32Converter(bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "UInt32"; + public override Guid Guid { get; } = new Guid("7181A9C2-1B40-4557-8819-84251370709D"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/UInt64Encoder.cs b/Networking/Encoders/UInt64Encoder.cs new file mode 100644 index 0000000..d611399 --- /dev/null +++ b/Networking/Encoders/UInt64Encoder.cs @@ -0,0 +1,52 @@ +using System; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Util; + +namespace Progression.IO.Encoders { + public class UInt64Encoder : StructEncoderBase + { + public override void Encode(ulong obj, PacketData data) + { + Int64Converter conv = obj; + var pos = data.Position; + var bytes = data.Data; + if (BitConverter.IsLittleEndian) { + bytes[pos] = conv.Byte0; + bytes[pos + 1] = conv.Byte1; + bytes[pos + 2] = conv.Byte2; + bytes[pos + 3] = conv.Byte3; + bytes[pos + 4] = conv.Byte4; + bytes[pos + 5] = conv.Byte5; + bytes[pos + 6] = conv.Byte6; + bytes[pos + 7] = conv.Byte7; + } else { + bytes[pos + 7] = conv.Byte0; + bytes[pos + 6] = conv.Byte1; + bytes[pos + 5] = conv.Byte2; + bytes[pos + 4] = conv.Byte3; + bytes[pos + 3] = conv.Byte4; + bytes[pos + 2] = conv.Byte5; + bytes[pos + 1] = conv.Byte6; + bytes[pos] = conv.Byte7; + } + + data.ShiftPosition(ByteSize); + } + + public override int ByteSize => 8; + + public override ulong Decode(PacketData data) + { + var pos = data.Position; + var bytes = data.Data; + data.ShiftPosition(ByteSize); + return BitConverter.IsLittleEndian + ? new Int64Converter(bytes[pos], bytes[pos + 1], bytes[pos + 2], bytes[pos + 3], bytes[pos + 4], bytes[pos + 5], bytes[pos + 6], bytes[pos + 7]) + : new Int64Converter(bytes[pos + 7], bytes[pos + 6], bytes[pos + 5], bytes[pos + 4], bytes[pos + 3], bytes[pos + 2], bytes[pos + 1], bytes[pos]); + } + + public override string Name => "UInt64"; + public override Guid Guid { get; } = new Guid("5AFBB7A4-BFE5-4297-AB2F-F49921DE4C40"); + + } +} \ No newline at end of file diff --git a/Networking/Encoders/UInt8Encoder.cs b/Networking/Encoders/UInt8Encoder.cs new file mode 100644 index 0000000..c36a503 --- /dev/null +++ b/Networking/Encoders/UInt8Encoder.cs @@ -0,0 +1,26 @@ +using System; +using Progression.IO.Encoders.Base; + +namespace Progression.IO.Encoders { + public class UInt8Encoder : StructEncoderBase + + { + public override void Encode(byte obj, PacketData data) + { + data.Data[data.Position] = obj; + data.ShiftPosition(1); + } + + public override byte Decode(PacketData data) + { + var result = data.Data[data.Position]; + data.ShiftPosition(1); + return result; + } + + + public override string Name => "UInt8"; + public override Guid Guid { get; } = new Guid("734F3761-2135-42C8-ABF4-9E4C70759080"); + public override int ByteSize => 1; + } +} \ No newline at end of file diff --git a/Networking/Encoders/Util/Int16Converter.cs b/Networking/Encoders/Util/Int16Converter.cs new file mode 100644 index 0000000..e1edb23 --- /dev/null +++ b/Networking/Encoders/Util/Int16Converter.cs @@ -0,0 +1,55 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Progression.IO.Encoders.Util { + //warning platform endianness specific + [StructLayout(LayoutKind.Explicit)] + struct Int16Converter + { + [FieldOffset(0)] public readonly short Int0; + [FieldOffset(0)] public readonly ushort UInt0; + [FieldOffset(0)] public readonly byte Byte0; + [FieldOffset(1)] public readonly byte Byte1; + + public Int16Converter(short int0) + { + UInt0 = Byte0 = Byte1 = 0; + Int0 = int0; + } + + public Int16Converter(ushort uint0) + { + Int0 = Byte0 = Byte1 = 0; + UInt0 = uint0; + } + + public Int16Converter(byte byte0, byte byte1) : this() + { + Int0 = 0; + UInt0 = 0; + Byte0 = byte0; + Byte1 = byte1; + } + + public static implicit operator Int16(Int16Converter value) + { + return value.Int0; + } + + public static implicit operator Int16Converter(short value) + { + return new Int16Converter(value); + } + + public static implicit operator UInt16(Int16Converter value) + { + return value.UInt0; + } + + public static implicit operator Int16Converter(ushort value) + { + return new Int16Converter(value); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Util/Int32Converter.cs b/Networking/Encoders/Util/Int32Converter.cs new file mode 100644 index 0000000..f5d3091 --- /dev/null +++ b/Networking/Encoders/Util/Int32Converter.cs @@ -0,0 +1,80 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Progression.IO.Encoders.Util { + //warning platform endianness specific + [StructLayout(LayoutKind.Explicit)] + struct Int32Converter + { + [FieldOffset(0)] public readonly int Int0; + [FieldOffset(0)] public readonly uint UInt0; + [FieldOffset(0)] public readonly float Float0; //no clue if this is save to do but dotnet currently misses a function for it + [FieldOffset(0)] public readonly byte Byte0; + [FieldOffset(1)] public readonly byte Byte1; + [FieldOffset(2)] public readonly byte Byte2; + [FieldOffset(3)] public readonly byte Byte3; + + public Int32Converter(int int0) + { + UInt0 = Byte0 = Byte1 = Byte2 = Byte3 = 0; + Float0 = 0; + Int0 = int0; + } + + public Int32Converter(uint uint0) + { + Int0 = Byte0 = Byte1 = Byte2 = Byte3 = 0; + Float0 = 0; + UInt0 = uint0; + } + + public Int32Converter(float float0) + { + Int0 = Byte0 = Byte1 = Byte2 = Byte3 = 0; + UInt0 = 0; + Float0 = float0; + } + + public Int32Converter(byte byte0, byte byte1, byte byte2, byte byte3) : this() + { + Int0 = 0; + UInt0 = 0; + Float0 = 0; + Byte0 = byte0; + Byte1 = byte1; + Byte2 = byte2; + Byte3 = byte3; + } + + public static implicit operator Int32(Int32Converter value) + { + return value.Int0; + } + + public static implicit operator Int32Converter(int value) + { + return new Int32Converter(value); + } + + public static implicit operator UInt32(Int32Converter value) + { + return value.UInt0; + } + + public static implicit operator Int32Converter(uint value) + { + return new Int32Converter(value); + } + + public static implicit operator Single(Int32Converter value) + { + return value.Float0; + } + + public static implicit operator Int32Converter(float value) + { + return new Int32Converter(value); + } + } +} \ No newline at end of file diff --git a/Networking/Encoders/Util/Int64Converter.cs b/Networking/Encoders/Util/Int64Converter.cs new file mode 100644 index 0000000..89e6859 --- /dev/null +++ b/Networking/Encoders/Util/Int64Converter.cs @@ -0,0 +1,78 @@ + +using System; +using System.Runtime.InteropServices; + +namespace Progression.IO.Encoders.Util { + //warning platform endianness specific + [StructLayout(LayoutKind.Explicit)] + struct Int64Converter + { + [FieldOffset(0)] public readonly long Int0; + [FieldOffset(0)] public readonly ulong UInt0; + [FieldOffset(0)] public readonly byte Byte0; + [FieldOffset(1)] public readonly byte Byte1; + [FieldOffset(2)] public readonly byte Byte2; + [FieldOffset(3)] public readonly byte Byte3; + [FieldOffset(4)] public readonly byte Byte4; + [FieldOffset(5)] public readonly byte Byte5; + [FieldOffset(6)] public readonly byte Byte6; + [FieldOffset(7)] public readonly byte Byte7; + + public Int64Converter(long int0) + { + UInt0 = Byte0 = Byte1 = Byte2 = Byte3 = Byte4 = Byte5 = Byte6 = Byte7 = 0; + Int0 = int0; + } + + public Int64Converter(ulong uint0) + { + Int0 = Byte0 = Byte1 = Byte2 = Byte3 = Byte4 = Byte5 = Byte6 = Byte7 = 0; + UInt0 = uint0; + } + + public Int64Converter(byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7) : this() + { + Int0 = 0; + UInt0 = 0; + Byte0 = byte0; + Byte1 = byte1; + Byte2 = byte2; + Byte3 = byte3; + Byte4 = byte4; + Byte5 = byte5; + Byte6 = byte6; + Byte7 = byte7; + + } + + public static implicit operator Int64(Int64Converter value) + { + return value.Int0; + } + + public static implicit operator Int64Converter(long value) + { + return new Int64Converter(value); + } + + public static implicit operator UInt64(Int64Converter value) + { + return value.UInt0; + } + + public static implicit operator Int64Converter(ulong value) + { + return new Int64Converter(value); + } + + public static implicit operator Double(Int64Converter value) + { + return BitConverter.Int64BitsToDouble(value.Int0); + } + + public static implicit operator Int64Converter(double value) + { + return new Int64Converter(BitConverter.DoubleToInt64Bits(value)); + } + } +} \ No newline at end of file diff --git a/Networking/Networking.csproj b/Networking/Networking.csproj new file mode 100644 index 0000000..db3cbc1 --- /dev/null +++ b/Networking/Networking.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9} + Library + Properties + Progression.IO + Networking + v4.7.1 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {bf8e1e3f-8e30-4496-b69c-2e07036c4e67} + ProgressionUtil + + + + + \ No newline at end of file diff --git a/Networking/PacketData.cs b/Networking/PacketData.cs new file mode 100644 index 0000000..871b77a --- /dev/null +++ b/Networking/PacketData.cs @@ -0,0 +1,38 @@ +namespace Progression.IO +{ + public class PacketData + { + public int EstLength { get; private set; } + public int Length => Data?.Length ?? 0; + public byte[] Data{ get; private set; } + public int Position{ get; private set; } + + public void Reset() + { + EstLength = 0; + Data = null; + Position = 0; + } + + public void InitArray() + { + Data = new byte[EstLength]; + Position = 0; + } + + public void Flip() + { + Position = 0; + } + + public void AddEstimate(int i) + { + EstLength += i; + } + + public void ShiftPosition(int i) + { + Position += i; + } + } +} \ No newline at end of file diff --git a/Networking/Properties/AssemblyInfo.cs b/Networking/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..368c274 --- /dev/null +++ b/Networking/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Networking")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Networking")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Networking/Types.cs b/Networking/Types.cs new file mode 100644 index 0000000..046e827 --- /dev/null +++ b/Networking/Types.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; +using Progression.IO.Encoders; +using Progression.IO.Encoders.Base; + +namespace Progression.IO +{ + public static class Types + { + internal static readonly Collection _registeredBaseTypes = new Collection(); + public static readonly IReadOnlyCollection RegisteredBaseTypes = _registeredBaseTypes; + + public static readonly StringEncoder StringUTF8 = new StringEncoder(Encoding.UTF8); + public static readonly StringEncoder StringUTF16 = new StringEncoder(Encoding.Unicode); //UTF16 + public static readonly StringEncoder StringUTF32 = new StringEncoder(Encoding.UTF32); + public static readonly StringEncoder StringASCII = new StringEncoder(Encoding.ASCII); + public static readonly Int8Encoder Int8 = new Int8Encoder(); + public static readonly UInt8Encoder UInt8 = new UInt8Encoder(); + public static readonly Int16Encoder Int16 = new Int16Encoder(); + public static readonly UInt16Encoder UInt16 = new UInt16Encoder(); + public static readonly Int32Encoder Int32 = new Int32Encoder(); + public static readonly UInt32Encoder UInt32 = new UInt32Encoder(); + public static readonly Float32Encoder Float32 = new Float32Encoder(); + public static readonly Int64Encoder Int64 = new Int64Encoder(); + public static readonly UInt64Encoder UInt64 = new UInt64Encoder(); + public static readonly Float64Encoder Float64 = new Float64Encoder(); + public static readonly BoolEncoder Bool = new BoolEncoder(); + public static readonly GuidEncoder Guid = new GuidEncoder(); + } +} \ No newline at end of file diff --git a/NetworkingTest/NetworkingTest.csproj b/NetworkingTest/NetworkingTest.csproj new file mode 100644 index 0000000..61e48d0 --- /dev/null +++ b/NetworkingTest/NetworkingTest.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + NetworkingTest + NetworkingTest + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + + + ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + + + + + + + + + {db4bc21b-896e-4d8b-a97a-1365e8e4d4c9} + Networking + + + + + \ No newline at end of file diff --git a/NetworkingTest/Properties/AssemblyInfo.cs b/NetworkingTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..484d271 --- /dev/null +++ b/NetworkingTest/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("NetworkingTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NetworkingTest")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/NetworkingTest/Tests.cs b/NetworkingTest/Tests.cs new file mode 100644 index 0000000..f05187a --- /dev/null +++ b/NetworkingTest/Tests.cs @@ -0,0 +1,91 @@ +using System; +using System.Diagnostics; +using Progression.IO; +using Progression.IO.Encoders.Base; +using Progression.IO.Encoders.Special; +using Xunit; + +namespace NetworkingTest +{ + public class Tests + { + [Fact] + public void Test1() + { + TestEncoderStruct(Types.Bool, true, false); + TestEncoderStruct(Types.Bool, false, true); + TestEncoderStruct(Types.Int8, (sbyte)0 ,(sbyte)1 ); + TestEncoderStruct(Types.Int8, (sbyte)127,(sbyte)1); + TestEncoderStruct(Types.UInt8, (byte)0,(byte)1); + TestEncoderStruct(Types.UInt8, (byte)255,(byte)1); + TestEncoderStruct(Types.Int16, (sbyte)0,(sbyte)1); + TestEncoderStruct(Types.Int16, (sbyte)127,(sbyte)1); + TestEncoderStruct(Types.UInt16, (byte)0,(byte)1); + TestEncoderStruct(Types.UInt16, (byte)255,(byte)1); + TestEncoderStruct(Types.Int32, 0,1); + TestEncoderStruct(Types.Int32, 127,1); + TestEncoderStruct(Types.UInt32, (byte)0,(byte)1); + TestEncoderStruct(Types.UInt32, (byte)255,(byte)1); + TestEncoderStruct(Types.Int64, 0,1); + TestEncoderStruct(Types.Int64, 127,1); + TestEncoderStruct(Types.UInt64, (byte)0,(byte)1); + TestEncoderStruct(Types.UInt64, (byte)255,(byte)1); + TestEncoderStruct(Types.Float32, 0,1); + TestEncoderStruct(Types.Float32, 127,1); + TestEncoderStruct(Types.Float64, 0,1); + TestEncoderStruct(Types.Float64, 255,1); + TestEncoderStruct(Types.Guid, Guid.NewGuid(), Guid.NewGuid()); + TestEncoderClass(Types.StringUTF8, "Hello World. 世界はおはようございますー!", ""); + TestEncoderClass(Types.StringUTF16, "Hello World. 世界はおはようございますー!", ""); + TestEncoderClass(Types.StringUTF32, "Hello World. 世界はおはようございますー!", ""); + TestEncoderClass(Types.StringASCII, "Hello World.", ""); + TestEncoderStruct(new Tuple2Encoder(Types.Int32, Types.StringASCII), (1, "2"), (3, "4"), false); + } + + public void TestEncoderStruct(IEncoder encoder, TType in1 , TType in2, bool testnull=true) where TType : struct + { + TestEncoderBase(encoder, in1, in2, testnull); + } + public void TestEncoderClass(IEncoder encoder, TType in1 , TType in2) where TType : class + { + TestEncoderBase(encoder, in1, in2, true); + } + + public void TestEncoderBase(IEncoder encoder, TType in1 , TType in2, bool testnull) + { + TType[] arrayIn1 = new[] {in1, in2}; + TArray[] arrayIn2 = new TArray[] {(TArray)(object)in1, (TArray)(object)null, (TArray)(object)in2}; + + + PacketData data = new PacketData(); + data.AddEstimate(encoder.Estimate(in1)); + data.AddEstimate(encoder.Array.Estimate(arrayIn1)); + if (testnull) { + data.AddEstimate(encoder.Nullable.Estimate(null)); + data.AddEstimate(encoder.Nullable.Estimate(in1)); + data.AddEstimate(encoder.Nullable.Array.Estimate(arrayIn2)); + } + data.InitArray(); + encoder.Encode(in1, data); + encoder.Array.Encode(arrayIn1, data); + if (testnull) { + encoder.Nullable.Encode(null, data); + encoder.Nullable.Encode(in1, data); + encoder.Nullable.Array.Encode(arrayIn2, data); + } + data.Flip(); + + TType out1 = encoder.Decode(data); + TType[] arrayOut1 = (TType[]) encoder.Array.Decode(data); + if (testnull) { + TArray outNull = (TArray) encoder.Nullable.Decode(data); + TArray out1Null = (TArray) encoder.Nullable.Decode(data); + TArray[] arrayOut2 = (TArray[]) encoder.Nullable.Array.Decode(data); + } + + Assert.True(Equals(in1, out1), $"Not consistent {in1} {out1}"); + + + } + } +} \ No newline at end of file diff --git a/NetworkingTest/packages.config b/NetworkingTest/packages.config new file mode 100644 index 0000000..69a4ec4 --- /dev/null +++ b/NetworkingTest/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Progression.sln b/Progression.sln index 90cb72b..07d00e2 100644 --- a/Progression.sln +++ b/Progression.sln @@ -24,7 +24,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgressionUtil", "Progress EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlSupport", "YamlSupport\YamlSupport.csproj", "{8B34FFDB-8810-4369-9918-B9EADACBB760}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC};{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1}") = "UnityTestRenderer", "UnityTestRenderer\Assembly-CSharp.csproj", "{957D0551-F09D-A940-ED89-7167706A19F2}" +Project("{00000000-0000-0000-0000-000000000000}") = "UnityTestRenderer", "UnityTestRenderer\Assembly-CSharp.csproj", "{957D0551-F09D-A940-ED89-7167706A19F2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgressionUI", "ProgressionUI\ProgressionUI.csproj", "{84925E74-B8B2-45CB-9D21-91331330EA0F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Networking", "Networking\Networking.csproj", "{DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkingTest", "NetworkingTest\NetworkingTest.csproj", "{8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -148,6 +154,42 @@ Global {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}.Debug|Any CPU.Build.0 = Debug|Any CPU {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}.Release|Any CPU.ActiveCfg = Release|Any CPU {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}.Release|Any CPU.Build.0 = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|x64.ActiveCfg = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|x64.Build.0 = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|x86.ActiveCfg = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Debug|x86.Build.0 = Debug|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|Any CPU.Build.0 = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|x64.ActiveCfg = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|x64.Build.0 = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|x86.ActiveCfg = Release|Any CPU + {84925E74-B8B2-45CB-9D21-91331330EA0F}.Release|x86.Build.0 = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|x64.Build.0 = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Debug|x86.Build.0 = Debug|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|Any CPU.Build.0 = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|x64.ActiveCfg = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|x64.Build.0 = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|x86.ActiveCfg = Release|Any CPU + {DB4BC21B-896E-4D8B-A97A-1365E8E4D4C9}.Release|x86.Build.0 = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|x64.ActiveCfg = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|x64.Build.0 = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|x86.ActiveCfg = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Debug|x86.Build.0 = Debug|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|Any CPU.Build.0 = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|x64.ActiveCfg = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|x64.Build.0 = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|x86.ActiveCfg = Release|Any CPU + {8CC1D2A9-C9ED-4A89-8F7F-DD0E977A634C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Progression.sln.DotSettings b/Progression.sln.DotSettings index d4bea66..8b6720c 100644 --- a/Progression.sln.DotSettings +++ b/Progression.sln.DotSettings @@ -11,6 +11,7 @@ False False AI + ASCII CSI IO SGR @@ -18,6 +19,7 @@ True True True + True True True True diff --git a/ProgressionUI/ProgressionUI.csproj b/ProgressionUI/ProgressionUI.csproj new file mode 100644 index 0000000..f29bc5f --- /dev/null +++ b/ProgressionUI/ProgressionUI.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {84925E74-B8B2-45CB-9D21-91331330EA0F} + Library + Properties + Progression.UI + ProgressionUI + v4.7.1 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + {7a0311e6-40f8-4e36-adfa-c23dfc1bf491} + ProgressionCore + + + {bf8e1e3f-8e30-4496-b69c-2e07036c4e67} + ProgressionUtil + + + {05e278ae-1235-4993-9f1d-d9d84a1d85c7} + ResourceManager + + + + + \ No newline at end of file diff --git a/ProgressionUI/Properties/AssemblyInfo.cs b/ProgressionUI/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..50e4cf8 --- /dev/null +++ b/ProgressionUI/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ProgressionUI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProgressionUI")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("84925E74-B8B2-45CB-9D21-91331330EA0F")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/ProgressionUI/TileUI/Action.cs b/ProgressionUI/TileUI/Action.cs new file mode 100644 index 0000000..cd3bde1 --- /dev/null +++ b/ProgressionUI/TileUI/Action.cs @@ -0,0 +1,17 @@ +using Progression.Util.Keys; + +namespace Progression.UI.TileUI +{ + public class Action : IKeyNameable + { + public Action(Key key, string name, ActionType type) + { + Key = key; + Name = name; + Type = type; + } + public Key Key { get; } + public string Name { get; } + public ActionType Type { get; } + } +} \ No newline at end of file diff --git a/ProgressionUI/TileUI/ActionTrigger.cs b/ProgressionUI/TileUI/ActionTrigger.cs new file mode 100644 index 0000000..9483c30 --- /dev/null +++ b/ProgressionUI/TileUI/ActionTrigger.cs @@ -0,0 +1,7 @@ +namespace Progression.UI.TileUI +{ + public class ActionTrigger + { + + } +} \ No newline at end of file diff --git a/ProgressionUI/TileUI/ActionType.cs b/ProgressionUI/TileUI/ActionType.cs new file mode 100644 index 0000000..cba19db --- /dev/null +++ b/ProgressionUI/TileUI/ActionType.cs @@ -0,0 +1,8 @@ +namespace Progression.UI.TileUI +{ + public enum ActionType + { + SimpleAction, + TileAction + } +} \ No newline at end of file diff --git a/ProgressionUI/TileUI/EventDelegates.cs b/ProgressionUI/TileUI/EventDelegates.cs new file mode 100644 index 0000000..59e0910 --- /dev/null +++ b/ProgressionUI/TileUI/EventDelegates.cs @@ -0,0 +1,5 @@ +namespace Progression.UI.TileUI +{ + public delegate void TileAction(Action action, Engine.Core.World.Tile tile) ; + public delegate void SimpleAction(Action action); +} \ No newline at end of file diff --git a/ProgressionUI/TileUI/KeyMap.cs b/ProgressionUI/TileUI/KeyMap.cs new file mode 100644 index 0000000..d667d3e --- /dev/null +++ b/ProgressionUI/TileUI/KeyMap.cs @@ -0,0 +1,7 @@ +namespace Progression.UI.TileUI +{ + public class KeyMap + { + + } +} \ No newline at end of file diff --git a/ProgressionUI/TileUI/TileUI.cs b/ProgressionUI/TileUI/TileUI.cs new file mode 100644 index 0000000..1239965 --- /dev/null +++ b/ProgressionUI/TileUI/TileUI.cs @@ -0,0 +1,12 @@ +using Progression.Engine.Core.World; + +namespace Progression.UI.TileUI +{ + public interface ITileUi + { + void displayWorld(TileWorld world); + void centerOn(Coordinate coordinate); + event SimpleAction SimpleAction; + event TileAction TileAction; //todo make each action have own event + } +} \ No newline at end of file diff --git a/ProgressionUtil/ProgressionUtil.csproj b/ProgressionUtil/ProgressionUtil.csproj index e38fa3c..7ee2adf 100644 --- a/ProgressionUtil/ProgressionUtil.csproj +++ b/ProgressionUtil/ProgressionUtil.csproj @@ -60,6 +60,7 @@ + diff --git a/ProgressionUtil/Util/GuidUtil.cs b/ProgressionUtil/Util/GuidUtil.cs new file mode 100644 index 0000000..dc0e5d3 --- /dev/null +++ b/ProgressionUtil/Util/GuidUtil.cs @@ -0,0 +1,101 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace Progression.Util +{ + //took from https://github.com/LogosBible/Logos.Utility/blob/master/src/Logos.Utility/GuidUtility.cs license is permissive + public static class GuidUtil + { + /// + /// Creates a name-based UUID using the algorithm from RFC 4122 §4.3. + /// + /// The ID of the namespace. + /// The name (within that namespace). + /// A UUID derived from the namespace and name. + /// See Generating a deterministic GUID. + public static Guid Create(Guid namespaceId, string name) + { + return Create(namespaceId, name, 5); + } + + /// + /// Creates a name-based UUID using the algorithm from RFC 4122 §4.3. + /// + /// The ID of the namespace. + /// The name (within that namespace). + /// The version number of the UUID to create; this value must be either + /// 3 (for MD5 hashing) or 5 (for SHA-1 hashing). + /// A UUID derived from the namespace and name. + /// See Generating a deterministic GUID. + public static Guid Create(Guid namespaceId, string name, int version) + { + if (name == null) + throw new ArgumentNullException("name"); + if (version != 3 && version != 5) + throw new ArgumentOutOfRangeException("version", "version must be either 3 or 5."); + + // convert the name to a sequence of octets (as defined by the standard or conventions of its namespace) (step 3) + // ASSUME: UTF-8 encoding is always appropriate + byte[] nameBytes = Encoding.UTF8.GetBytes(name); + + // convert the namespace UUID to network order (step 3) + byte[] namespaceBytes = namespaceId.ToByteArray(); + SwapByteOrder(namespaceBytes); + + // comput the hash of the name space ID concatenated with the name (step 4) + byte[] hash; + using (HashAlgorithm algorithm = version == 3 ? (HashAlgorithm) MD5.Create() : SHA1.Create()) + { + algorithm.TransformBlock(namespaceBytes, 0, namespaceBytes.Length, null, 0); + algorithm.TransformFinalBlock(nameBytes, 0, nameBytes.Length); + hash = algorithm.Hash; + } + + // most bytes from the hash are copied straight to the bytes of the new GUID (steps 5-7, 9, 11-12) + byte[] newGuid = new byte[16]; + Array.Copy(hash, 0, newGuid, 0, 16); + + // set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the appropriate 4-bit version number from Section 4.1.3 (step 8) + newGuid[6] = (byte) ((newGuid[6] & 0x0F) | (version << 4)); + + // set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively (step 10) + newGuid[8] = (byte) ((newGuid[8] & 0x3F) | 0x80); + + // convert the resulting UUID to local byte order (step 13) + SwapByteOrder(newGuid); + return new Guid(newGuid); + } + + /// + /// The namespace for fully-qualified domain names (from RFC 4122, Appendix C). + /// + public static readonly Guid DnsNamespace = new Guid("6ba7b810-9dad-11d1-80b4-00c04fd430c8"); + + /// + /// The namespace for URLs (from RFC 4122, Appendix C). + /// + public static readonly Guid UrlNamespace = new Guid("6ba7b811-9dad-11d1-80b4-00c04fd430c8"); + + /// + /// The namespace for ISO OIDs (from RFC 4122, Appendix C). + /// + public static readonly Guid IsoOidNamespace = new Guid("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); + + // Converts a GUID (expressed as a byte array) to/from network order (MSB-first). + internal static void SwapByteOrder(byte[] guid) + { + SwapBytes(guid, 0, 3); + SwapBytes(guid, 1, 2); + SwapBytes(guid, 4, 5); + SwapBytes(guid, 6, 7); + } + + private static void SwapBytes(byte[] guid, int left, int right) + { + byte temp = guid[left]; + guid[left] = guid[right]; + guid[right] = temp; + } + } +} \ No newline at end of file diff --git a/UnityTestRenderer/Assembly-CSharp.csproj b/UnityTestRenderer/Assembly-CSharp.csproj new file mode 100644 index 0000000..c4ac293 --- /dev/null +++ b/UnityTestRenderer/Assembly-CSharp.csproj @@ -0,0 +1,664 @@ + + + + 6 + {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + <_TargetFrameworkDirectories>non_empty_path_generated_by_rider_editor_plugin + <_FullFrameworkReferenceAssemblyPaths>non_empty_path_generated_by_rider_editor_plugin + + + Debug + AnyCPU + 10.0.20506 + 2.0 + ../ + {957D0551-F09D-A940-ED89-7167706A19F2} + Library + Properties + Assembly-CSharp + v4.7.1 + 512 + . + + + true + full + false + Temp\bin\Debug\ + DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_2_18;UNITY_2018_2;UNITY_2018;PLATFORM_ARCH_64;UNITY_64;UNITY_ANALYTICS;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITES;ENABLE_GRID;ENABLE_TILEMAP;ENABLE_TERRAIN;ENABLE_TEXTURE_STREAMING;ENABLE_DIRECTOR;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_TIMELINE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;ENABLE_MONO_BDWGC;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_VIDEO;ENABLE_PACKMAN;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_LOCALIZATION;PLATFORM_STANDALONE_WIN;PLATFORM_STANDALONE;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_OUT_OF_PROCESS_CRASH_HANDLER;ENABLE_EVENT_QUEUE;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;ENABLE_VR;ENABLE_AR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_4_6;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE + prompt + 4 + 0169 + False + + + pdbonly + true + Temp\bin\Release\ + prompt + 4 + 0169 + False + + + true + true + false + false + false + + + + C:\Program Files\Unity\Editor\Data\Managed/UnityEngine/UnityEngine.dll + + + C:\Program Files\Unity\Editor\Data\Managed/UnityEditor.dll + + + C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api\Microsoft.CSharp.dll + + + + + + + + + + + + + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Library/ScriptAssemblies/UnityEditor.StandardEvents.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Library/ScriptAssemblies/Unity.TextMeshPro.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.AIModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ARModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.AccessibilityModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.AnimationModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.AssetBundleModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.AudioModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.BaselibModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ClothModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.CloudWebServicesModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ClusterInputModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ClusterRendererModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.CoreModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.CrashReportingModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.DirectorModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.FacebookModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.FileSystemHttpModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.GameCenterModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.GridModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.HotReloadModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.IMGUIModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ImageConversionModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.InputModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.JSONSerializeModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.LocalizationModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ParticleSystemModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ParticlesLegacyModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.PerformanceReportingModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.PhysicsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.Physics2DModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ProfilerModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.ScreenCaptureModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.SharedInternalsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.SpriteMaskModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.SpriteShapeModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.StreamingModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.StyleSheetsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.SubstanceModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TLSModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TerrainModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TerrainPhysicsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TextRenderingModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TilemapModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.TimelineModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UIModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UIElementsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UNETModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UmbraModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityAnalyticsModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityConnectModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityWebRequestModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityWebRequestAssetBundleModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityWebRequestAudioModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityWebRequestTextureModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.UnityWebRequestWWWModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.VRModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.VehiclesModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.VideoModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.WindModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/UnityEngine/UnityEngine.XRModule.dll + + + C:/Program Files/Unity/Editor/Data/Managed/Unity.Locator.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Timeline/RuntimeEditor/UnityEngine.Timeline.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityGoogleAudioSpatializer/RuntimeEditor/UnityEngine.GoogleAudioSpatializer.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll + + + C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Assets/Plugins/Engine/Newtonsoft.Json.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Assets/Plugins/Engine/ProgressionCore.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Assets/Plugins/Engine/ProgressionUtil.dll + + + C:/Users/sirati97/OneDrive/Dokumente/Visual Studio 2017/Projects/Progression/UnityTestRenderer/Assets/Plugins/Engine/ResourceManager.dll + + + C:/Users/sirati97/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.analytics@2.0.16/UnityEngine.Analytics.dll + + + C:/Users/sirati97/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.standardevents@1.0.13/UnityEngine.StandardEvents.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Core.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Runtime.Serialization.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Xml.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Xml.Linq.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Numerics.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Numerics.Vectors.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Net.Http.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Microsoft.CSharp.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/System.Data.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/Microsoft.Win32.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/netstandard.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.AppContext.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Collections.Concurrent.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Collections.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Collections.NonGeneric.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Collections.Specialized.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ComponentModel.Annotations.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ComponentModel.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ComponentModel.EventBasedAsync.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ComponentModel.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ComponentModel.TypeConverter.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Console.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Data.Common.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.Contracts.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.Debug.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.FileVersionInfo.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.Process.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.StackTrace.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.TextWriterTraceListener.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.Tools.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Diagnostics.TraceSource.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Drawing.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Dynamic.Runtime.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Globalization.Calendars.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Globalization.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Globalization.Extensions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.Compression.ZipFile.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.FileSystem.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.FileSystem.DriveInfo.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.FileSystem.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.FileSystem.Watcher.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.IsolatedStorage.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.MemoryMappedFiles.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.Pipes.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.IO.UnmanagedMemoryStream.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Linq.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Linq.Expressions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Linq.Parallel.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Linq.Queryable.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Http.Rtc.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.NameResolution.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.NetworkInformation.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Ping.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Requests.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Security.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.Sockets.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.WebHeaderCollection.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.WebSockets.Client.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Net.WebSockets.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ObjectModel.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.Emit.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.Emit.ILGeneration.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.Emit.Lightweight.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.Extensions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Reflection.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Resources.Reader.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Resources.ResourceManager.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Resources.Writer.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.CompilerServices.VisualC.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Extensions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Handles.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.InteropServices.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.InteropServices.RuntimeInformation.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.InteropServices.WindowsRuntime.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Numerics.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Serialization.Formatters.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Serialization.Json.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Serialization.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Runtime.Serialization.Xml.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Claims.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Cryptography.Algorithms.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Cryptography.Csp.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Cryptography.Encoding.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Cryptography.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Cryptography.X509Certificates.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.Principal.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Security.SecureString.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ServiceModel.Duplex.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ServiceModel.Http.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ServiceModel.NetTcp.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ServiceModel.Primitives.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ServiceModel.Security.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Text.Encoding.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Text.Encoding.Extensions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Text.RegularExpressions.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.Overlapped.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.Tasks.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.Tasks.Parallel.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.Thread.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.ThreadPool.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Threading.Timer.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.ValueTuple.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.ReaderWriter.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.XDocument.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.XmlDocument.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.XmlSerializer.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.XPath.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/Facades/System.Xml.XPath.XDocument.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/unityscript/UnityScript.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/unityscript/UnityScript.Lang.dll + + + C:/Program Files/Unity/Editor/Data/MonoBleedingEdge/lib/mono/unityscript/Boo.Lang.dll + + + + + \ No newline at end of file diff --git a/UnityTestRenderer/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll b/UnityTestRenderer/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll index 76c68b0..f33966c 100644 Binary files a/UnityTestRenderer/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll and b/UnityTestRenderer/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll differ diff --git a/UnityTestRenderer/Assets/Plugins/Engine/ProgressionCore.dll b/UnityTestRenderer/Assets/Plugins/Engine/ProgressionCore.dll index 76a133b..9dfd44d 100644 Binary files a/UnityTestRenderer/Assets/Plugins/Engine/ProgressionCore.dll and b/UnityTestRenderer/Assets/Plugins/Engine/ProgressionCore.dll differ diff --git a/UnityTestRenderer/Assets/Util/TextureHelper.cs b/UnityTestRenderer/Assets/Util/TextureHelper.cs index d80c165..7fafbb7 100644 --- a/UnityTestRenderer/Assets/Util/TextureHelper.cs +++ b/UnityTestRenderer/Assets/Util/TextureHelper.cs @@ -13,7 +13,7 @@ public static class TextureHelper public static Texture2D FontAtlas; public static Texture2D TextureAtlas; private static List _texturedFeatures = new List(); - public const int TextureSize = 256; + public const int TextureSize = 64; public const int FontSize = 16; public static readonly AttachmentKey TextureLocation = new AttachmentKey(); @@ -53,7 +53,7 @@ public static void InitTexture() TextureAtlas.filterMode = FilterMode.Point; TextureAtlas.Apply(); - byte[] bytes = TextureAtlas.EncodeToPNG(); + /*byte[] bytes = TextureAtlas.EncodeToPNG(); var rnd = new System.Random(); File.WriteAllBytes("C:\\Users\\sirati97\\Desktop\\" + rnd.Next() + ".png", bytes);/**/ diff --git a/UnityTestRenderer/ProjectSettings/QualitySettings.asset b/UnityTestRenderer/ProjectSettings/QualitySettings.asset index 03e01da..a850407 100644 --- a/UnityTestRenderer/ProjectSettings/QualitySettings.asset +++ b/UnityTestRenderer/ProjectSettings/QualitySettings.asset @@ -196,7 +196,7 @@ QualitySettings: softVegetation: 1 realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 - vSyncCount: 1 + vSyncCount: 0 lodBias: 2 maximumLODLevel: 0 streamingMipmapsActive: 0 diff --git a/UnityTestRenderer/UnityTestRenderer.sln b/UnityTestRenderer/UnityTestRenderer.sln new file mode 100644 index 0000000..3b192bf --- /dev/null +++ b/UnityTestRenderer/UnityTestRenderer.sln @@ -0,0 +1,22 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{957D0551-F09D-A940-ED89-7167706A19F2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {957D0551-F09D-A940-ED89-7167706A19F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {957D0551-F09D-A940-ED89-7167706A19F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {957D0551-F09D-A940-ED89-7167706A19F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {957D0551-F09D-A940-ED89-7167706A19F2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = UnityTestRenderer.csproj + EndGlobalSection +EndGlobal