diff --git a/src/Debug/EcsDebug.cs b/src/Debug/EcsDebug.cs index d798785..fe8d6db 100644 --- a/src/Debug/EcsDebug.cs +++ b/src/Debug/EcsDebug.cs @@ -1,4 +1,4 @@ -using DCFApixels.DragonECS.Utils; +using DCFApixels.DragonECS.Internal; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/EcsMask.cs b/src/EcsMask.cs index 90682e1..f30774c 100644 --- a/src/EcsMask.cs +++ b/src/EcsMask.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace DCFApixels.DragonECS { diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 06923d2..b1e0336 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -1,5 +1,4 @@ using DCFApixels.DragonECS.Internal; -using DCFApixels.DragonECS.Utils; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -189,7 +188,7 @@ namespace DCFApixels.DragonECS #endregion #region Entity - + #region New/Del [MethodImpl(MethodImplOptions.AggressiveInlining)] public int NewEntity() diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs index 71ef175..06f0bde 100644 --- a/src/EcsWorld.pools.cs +++ b/src/EcsWorld.pools.cs @@ -1,5 +1,4 @@ using DCFApixels.DragonECS.Internal; -using DCFApixels.DragonECS.Utils; using System; using System.Linq; using System.Runtime.CompilerServices; diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index 3789982..e715d7d 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -1,4 +1,4 @@ -using DCFApixels.DragonECS.Utils; +using DCFApixels.DragonECS.Internal; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/src/Utils/ArraySortHalperX.cs b/src/Internal/ArraySortHalperX.cs similarity index 100% rename from src/Utils/ArraySortHalperX.cs rename to src/Internal/ArraySortHalperX.cs diff --git a/src/Utils/ArraySortHalperX.cs.meta b/src/Internal/ArraySortHalperX.cs.meta similarity index 100% rename from src/Utils/ArraySortHalperX.cs.meta rename to src/Internal/ArraySortHalperX.cs.meta diff --git a/src/Utils/ArrayUtility.cs b/src/Internal/ArrayUtility.cs similarity index 100% rename from src/Utils/ArrayUtility.cs rename to src/Internal/ArrayUtility.cs diff --git a/src/Utils/ArrayUtility.cs.meta b/src/Internal/ArrayUtility.cs.meta similarity index 100% rename from src/Utils/ArrayUtility.cs.meta rename to src/Internal/ArrayUtility.cs.meta diff --git a/src/Utils/BitsUtility.cs b/src/Internal/BitsUtility.cs similarity index 99% rename from src/Utils/BitsUtility.cs rename to src/Internal/BitsUtility.cs index ab898bd..40fef17 100644 --- a/src/Utils/BitsUtility.cs +++ b/src/Internal/BitsUtility.cs @@ -3,11 +3,11 @@ using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text.RegularExpressions; -using static DCFApixels.BitsUtility; +using static DCFApixels.DragonECS.Internal.BitsUtility; -namespace DCFApixels +namespace DCFApixels.DragonECS.Internal { - public unsafe static class BitsUtility + internal unsafe static class BitsUtility { private const char DEFAULT_SEPARATOR = '_'; private const int BYTE_BITS = 8; diff --git a/src/Utils/BitsUtility.cs.meta b/src/Internal/BitsUtility.cs.meta similarity index 100% rename from src/Utils/BitsUtility.cs.meta rename to src/Internal/BitsUtility.cs.meta diff --git a/src/Utils/EcsTypeCode.cs b/src/Internal/EcsTypeCode.cs similarity index 60% rename from src/Utils/EcsTypeCode.cs rename to src/Internal/EcsTypeCode.cs index 142e394..2d53f00 100644 --- a/src/Utils/EcsTypeCode.cs +++ b/src/Internal/EcsTypeCode.cs @@ -8,22 +8,26 @@ namespace DCFApixels.DragonECS.Internal public static class EcsTypeCode { private static readonly Dictionary _codes = new Dictionary(); - private static int _incremetn = 1; - public static int Count => _codes.Count; + private static int _increment = 1; + public static int Count + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _codes.Count; } + } public static int Get(Type type) { if (!_codes.TryGetValue(type, out int code)) { - code = _incremetn++; + code = _increment++; _codes.Add(type, code); } return code; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Get() => EcsTypeCodeCache.code; - public static bool Has(Type type) => _codes.ContainsKey(type); - public static bool Has() => _codes.ContainsKey(typeof(T)); - public static IEnumerable GetDeclared() => _codes.Select(o => new TypeCodeInfo(o.Key, o.Value)); + public static int Get() { return EcsTypeCodeCache.code; } + public static bool Has(Type type) { return _codes.ContainsKey(type); } + public static bool Has() { return _codes.ContainsKey(typeof(T)); } + public static IEnumerable GetDeclaredTypes() { return _codes.Select(o => new TypeCodeInfo(o.Key, o.Value)); } } public static class EcsTypeCodeCache { @@ -38,10 +42,9 @@ namespace DCFApixels.DragonECS.Internal this.type = type; this.code = code; } - public override string ToString() { - return this.AutoToString(false) + "\n\r"; + return this.AutoToString(false); } } } \ No newline at end of file diff --git a/src/Utils/EcsTypeCode.cs.meta b/src/Internal/EcsTypeCode.cs.meta similarity index 100% rename from src/Utils/EcsTypeCode.cs.meta rename to src/Internal/EcsTypeCode.cs.meta diff --git a/src/Utils/GenericEnumerable.cs b/src/Internal/GenericEnumerable.cs similarity index 89% rename from src/Utils/GenericEnumerable.cs rename to src/Internal/GenericEnumerable.cs index a03a71d..b726099 100644 --- a/src/Utils/GenericEnumerable.cs +++ b/src/Internal/GenericEnumerable.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; namespace DCFApixels.DragonECS.Internal { - public readonly struct GenericEnumerable : IEnumerable where TEnumerator : IEnumerator + internal readonly struct GenericEnumerable : IEnumerable where TEnumerator : IEnumerator { public readonly TEnumerator _enumerator; [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/Utils/GenericEnumerable.cs.meta b/src/Internal/GenericEnumerable.cs.meta similarity index 100% rename from src/Utils/GenericEnumerable.cs.meta rename to src/Internal/GenericEnumerable.cs.meta diff --git a/src/Utils/IdDispenser.cs b/src/Internal/IdDispenser.cs similarity index 99% rename from src/Utils/IdDispenser.cs rename to src/Internal/IdDispenser.cs index 470e10c..485b7eb 100644 --- a/src/Utils/IdDispenser.cs +++ b/src/Internal/IdDispenser.cs @@ -1,11 +1,10 @@ -using DCFApixels.DragonECS.Internal; -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; -namespace DCFApixels.DragonECS.Utils +namespace DCFApixels.DragonECS.Internal { [Serializable] [DebuggerTypeProxy(typeof(DebuggerProxy))] @@ -164,7 +163,7 @@ namespace DCFApixels.DragonECS.Utils int freeIndex = _usedCount; for (int i = 0; i < _size; i++) { - if(_sparse[i] > 0) + if (_sparse[i] > 0) { _sparse[i] = usedIndex; _dense[usedIndex++] = i; diff --git a/src/Utils/IdDispenser.cs.meta b/src/Internal/IdDispenser.cs.meta similarity index 100% rename from src/Utils/IdDispenser.cs.meta rename to src/Internal/IdDispenser.cs.meta diff --git a/src/Utils/SparseArray.cs b/src/Internal/SparseArray.cs similarity index 99% rename from src/Utils/SparseArray.cs rename to src/Internal/SparseArray.cs index 23fed2d..21188c5 100644 --- a/src/Utils/SparseArray.cs +++ b/src/Internal/SparseArray.cs @@ -6,7 +6,7 @@ using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace DCFApixels.DragonECS.Utils +namespace DCFApixels.DragonECS.Internal { public class SparseArray { diff --git a/src/Utils/SparseArray.cs.meta b/src/Internal/SparseArray.cs.meta similarity index 100% rename from src/Utils/SparseArray.cs.meta rename to src/Internal/SparseArray.cs.meta diff --git a/src/Utils/SparseArray64.cs b/src/Internal/SparseArray64.cs similarity index 99% rename from src/Utils/SparseArray64.cs rename to src/Internal/SparseArray64.cs index 946f800..2920103 100644 --- a/src/Utils/SparseArray64.cs +++ b/src/Internal/SparseArray64.cs @@ -6,7 +6,7 @@ using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace DCFApixels.DragonECS.Utils +namespace DCFApixels.DragonECS.Internal { internal class SparseArray64 { diff --git a/src/Utils/SparseArray64.cs.meta b/src/Internal/SparseArray64.cs.meta similarity index 100% rename from src/Utils/SparseArray64.cs.meta rename to src/Internal/SparseArray64.cs.meta diff --git a/src/Utils/UnsafeArray.cs b/src/Internal/UnsafeArray.cs similarity index 100% rename from src/Utils/UnsafeArray.cs rename to src/Internal/UnsafeArray.cs diff --git a/src/Utils/UnsafeArray.cs.meta b/src/Internal/UnsafeArray.cs.meta similarity index 100% rename from src/Utils/UnsafeArray.cs.meta rename to src/Internal/UnsafeArray.cs.meta diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index f1fce0f..7a05af1 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -1,8 +1,23 @@ using System; using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using static Leopotam.EcsLite.EcsWorld; +namespace DCFApixels.DragonECS +{ + [Serializable] + public class EcsFrameworkException : Exception + { + public EcsFrameworkException() { } + public EcsFrameworkException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { } + public EcsFrameworkException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { } + } + [Serializable] + public class EcsRunnerImplementationException : EcsFrameworkException + { + public EcsRunnerImplementationException() { } + public EcsRunnerImplementationException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { } + public EcsRunnerImplementationException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { } + } +} namespace DCFApixels.DragonECS.Internal { @@ -105,20 +120,3 @@ namespace DCFApixels.DragonECS.Internal } } -namespace DCFApixels.DragonECS -{ - [Serializable] - public class EcsFrameworkException : Exception - { - public EcsFrameworkException() { } - public EcsFrameworkException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { } - public EcsFrameworkException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { } - } - [Serializable] - public class EcsRunnerImplementationException : EcsFrameworkException - { - public EcsRunnerImplementationException() { } - public EcsRunnerImplementationException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { } - public EcsRunnerImplementationException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { } - } -} diff --git a/src/Utils/IntDispenser.cs b/src/Utils/IntDispenser.cs deleted file mode 100644 index df975e4..0000000 --- a/src/Utils/IntDispenser.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Concurrent; -using System.Threading; - -namespace DCFApixels.DragonECS.Utils -{ - internal sealed class IntDispenser - { - private readonly ConcurrentQueue _freeInts; - private int _increment; - - #region Properties - public int LastInt => _increment; - public int FreeConut => _freeInts.Count; - #endregion - - #region Constructor - public IntDispenser(int startIncrement = 0) - { - _freeInts = new ConcurrentQueue(); - _increment = startIncrement; - } - #endregion - - #region GetFree/Release - public int GetFree() - { - if (!_freeInts.TryDequeue(out int result)) - { - result = Interlocked.Increment(ref _increment); - } - return result; - } - - public void Release(int released) - { - _freeInts.Enqueue(released); - } - #endregion - } -} diff --git a/src/Utils/IntDispenser.cs.meta b/src/Utils/IntDispenser.cs.meta deleted file mode 100644 index b28c4e4..0000000 --- a/src/Utils/IntDispenser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a20cbd833c35ff3438f9fe003903c0c3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: