mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-12 16:45:55 +08:00
code style refactoring
This commit is contained in:
parent
51a4327358
commit
002894ce9c
@ -229,8 +229,7 @@ namespace DCFApixels.DragonECS
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _isReleased; }
|
||||
}
|
||||
|
||||
bool ICollection<int>.IsReadOnly => throw new NotImplementedException();
|
||||
bool ICollection<int>.IsReadOnly { get { return false; } }
|
||||
|
||||
public int this[int index]
|
||||
{
|
||||
@ -473,7 +472,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
/// <summary>as Union sets</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void UnionWith(EcsReadonlyGroup group) => UnionWith(group.GetSource_Internal());
|
||||
public void UnionWith(EcsReadonlyGroup group) { UnionWith(group.GetSource_Internal()); }
|
||||
/// <summary>as Union sets</summary>
|
||||
public void UnionWith(EcsSpan span)
|
||||
{
|
||||
@ -1226,19 +1225,14 @@ namespace DCFApixels.DragonECS
|
||||
public int Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _dense[_index];
|
||||
get { return _dense[_index]; }
|
||||
}
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
// проверка с учтом что отсчет начинается с индекса 1
|
||||
return --_index > 0;
|
||||
}
|
||||
public bool MoveNext() { return --_index > 0; } // проверка с учтом что отсчет начинается с индекса 1
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { }
|
||||
void IDisposable.Dispose() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@ -62,9 +62,9 @@ namespace DCFApixels.DragonECS
|
||||
private sealed class DummyHandler : IEcsComponentLifecycle<T>
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enable(ref T component) => component = default;
|
||||
public void Enable(ref T component) { component = default; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Disable(ref T component) => component = default;
|
||||
public void Disable(ref T component) { component = default; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -95,7 +95,7 @@ namespace DCFApixels.DragonECS
|
||||
private sealed class DummyHandler : IEcsComponentCopy<T>
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Copy(ref T from, ref T to) => to = from;
|
||||
public void Copy(ref T from, ref T to) { to = from; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -460,7 +460,7 @@ namespace DCFApixels.DragonECS
|
||||
return true;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override int GetHashCode() => hash;
|
||||
public override int GetHashCode() { return hash; }
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@ -429,7 +429,7 @@ namespace DCFApixels.DragonECS
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { _index = -1; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() { }
|
||||
void IDisposable.Dispose() { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ namespace DCFApixels.DragonECS
|
||||
where T : IEcsPoolImplementation, new()
|
||||
{
|
||||
public readonly T instance;
|
||||
public PoolCache(T instance) => this.instance = instance;
|
||||
public PoolCache(T instance) { this.instance = instance; }
|
||||
void IEcsWorldComponent<PoolCache<T>>.Init(ref PoolCache<T> component, EcsWorld world)
|
||||
{
|
||||
component = new PoolCache<T>(world.CreatePool<T>());
|
||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
||||
where T : EcsAspect, new()
|
||||
{
|
||||
public readonly T instance;
|
||||
public AspectCache(T instance) => this.instance = instance;
|
||||
public AspectCache(T instance) { this.instance = instance; }
|
||||
void IEcsWorldComponent<AspectCache<T>>.Init(ref AspectCache<T> component, EcsWorld world)
|
||||
{
|
||||
component = new AspectCache<T>(EcsAspect.Builder.New<T>(world));
|
||||
@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS
|
||||
where T : EcsQueryExecutor, new()
|
||||
{
|
||||
public readonly T instance;
|
||||
public ExeccutorCache(T instance) => this.instance = instance;
|
||||
public ExeccutorCache(T instance) { this.instance = instance; }
|
||||
void IEcsWorldComponent<ExeccutorCache<T>>.Init(ref ExeccutorCache<T> component, EcsWorld world)
|
||||
{
|
||||
T instance = new T();
|
||||
|
||||
@ -10,9 +10,9 @@ namespace DCFApixels.DragonECS
|
||||
public struct EcsWorldCmp<T> where T : struct
|
||||
{
|
||||
private short _worldID;
|
||||
public EcsWorldCmp(short worldID) => _worldID = worldID;
|
||||
public EcsWorld World => EcsWorld.GetWorld(_worldID);
|
||||
public ref T Value => ref EcsWorld.GetData<T>(_worldID);
|
||||
public EcsWorldCmp(short worldID) { _worldID = worldID; }
|
||||
public EcsWorld World { get { return EcsWorld.GetWorld(_worldID); } }
|
||||
public ref T Value { get { return ref EcsWorld.GetData<T>(_worldID); } }
|
||||
}
|
||||
public partial class EcsWorld
|
||||
{
|
||||
|
||||
@ -11,52 +11,6 @@ namespace DCFApixels.DragonECS.Internal
|
||||
{
|
||||
int Next { get; }
|
||||
}
|
||||
internal readonly struct LinkedIndexesIterator<T> : IEnumerable<int>
|
||||
where T : ILinkedNext
|
||||
{
|
||||
private readonly T[] _array;
|
||||
private readonly int _count;
|
||||
private readonly int _startIndex;
|
||||
public LinkedIndexesIterator(T[] array, int count, int startIndex)
|
||||
{
|
||||
_array = array;
|
||||
_count = count;
|
||||
_startIndex = startIndex;
|
||||
}
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return new Enumerator(_array, _count, _startIndex);
|
||||
}
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private readonly T[] _array;
|
||||
private readonly int _count;
|
||||
private int _index;
|
||||
private int _counter;
|
||||
public Enumerator(T[] array, int count, int index)
|
||||
{
|
||||
_array = array;
|
||||
_count = count;
|
||||
_index = index;
|
||||
_counter = 0;
|
||||
}
|
||||
public int Current { get { return _index; } }
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (++_counter > _count) { return false; }
|
||||
if (_counter > 1)
|
||||
{
|
||||
_index = _array[_index].Next;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Dispose() { }
|
||||
public void Reset() { }
|
||||
}
|
||||
}
|
||||
internal readonly struct LinkedListIterator<T> : IEnumerable<T>
|
||||
where T : ILinkedNext
|
||||
{
|
||||
@ -88,7 +42,11 @@ namespace DCFApixels.DragonECS.Internal
|
||||
_index = index;
|
||||
_counter = 0;
|
||||
}
|
||||
public ref readonly T Current { get { return ref _array[_index]; } }
|
||||
public ref T Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return ref _array[_index]; }
|
||||
}
|
||||
T IEnumerator<T>.Current { get { return _array[_index]; } }
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
public bool MoveNext()
|
||||
@ -100,10 +58,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Dispose() { }
|
||||
public void Reset() { throw new NotSupportedException(); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ArrayUtility
|
||||
{
|
||||
private static int GetHighBitNumber(uint bits)
|
||||
@ -183,12 +143,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
}
|
||||
public static EnumerableInt Range(int start, int length) => new EnumerableInt(start, length);
|
||||
public static EnumerableInt StartEnd(int start, int end) => new EnumerableInt(start, end - start);
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public static EnumerableInt Range(int start, int length) { return new EnumerableInt(start, length); }
|
||||
public static EnumerableInt StartEnd(int start, int end) { return new EnumerableInt(start, end - start); }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator() => new Enumerator(start, start + length);
|
||||
public Enumerator GetEnumerator() { return new Enumerator(start, start + length); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private readonly int _max;
|
||||
@ -202,16 +162,16 @@ namespace DCFApixels.DragonECS.Internal
|
||||
public int Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _current;
|
||||
get { return _current; }
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext() => ++_current < _max;
|
||||
public bool MoveNext() { return ++_current < _max; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() { }
|
||||
void IDisposable.Dispose() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
|
||||
}
|
||||
}
|
||||
internal static unsafe class UnmanagedArrayUtility
|
||||
|
||||
@ -512,9 +512,9 @@ namespace DCFApixels.DragonECS.Internal
|
||||
byte result = ToByte(bitsString);
|
||||
return *(bool*)&result;
|
||||
}
|
||||
public static short ToShort(string bitsString) => (short)ToUShort(bitsString);
|
||||
public static int ToInt(string bitsString) => (int)ToUInt(bitsString);
|
||||
public static long ToLong(string bitsString) => (long)ToULong(bitsString);
|
||||
public static short ToShort(string bitsString) { return (short)ToUShort(bitsString); }
|
||||
public static int ToInt(string bitsString) { return (int)ToUInt(bitsString); }
|
||||
public static long ToLong(string bitsString) { return (long)ToULong(bitsString); }
|
||||
#endregion
|
||||
|
||||
#region XorShift
|
||||
@ -625,249 +625,18 @@ namespace DCFApixels.DragonECS.Internal
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region FindBitsResult removed
|
||||
/*
|
||||
public unsafe struct FindBitsResult8 : IEnumerable<byte>
|
||||
{
|
||||
private fixed byte _numbers[8];
|
||||
public readonly byte Count;
|
||||
public int this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _numbers[index];
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResult8(uint bits)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Count = (byte)CountBits(bits);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int number = GetHighBitNumber(bits);
|
||||
_numbers[i] = (byte)number;
|
||||
bits ^= 1u << number;
|
||||
}
|
||||
}
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult8 a)
|
||||
{
|
||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<byte> ToSpan()
|
||||
{
|
||||
return CreateSpanInternal(this);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult8 a)
|
||||
{
|
||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResultEnumerator GetEnumerator()
|
||||
{
|
||||
return GetEnumeratorInternal(this);
|
||||
}
|
||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
public unsafe struct FindBitsResult16 : IEnumerable<byte>
|
||||
{
|
||||
private fixed byte _numbers[16];
|
||||
public readonly byte Count;
|
||||
public int this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _numbers[index];
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResult16(uint bits)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Count = (byte)CountBits(bits);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int number = GetHighBitNumber(bits);
|
||||
_numbers[i] = (byte)number;
|
||||
bits ^= 1u << number;
|
||||
}
|
||||
}
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult16 a)
|
||||
{
|
||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<byte> ToSpan()
|
||||
{
|
||||
return CreateSpanInternal(this);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult16 a)
|
||||
{
|
||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResultEnumerator GetEnumerator()
|
||||
{
|
||||
return GetEnumeratorInternal(this);
|
||||
}
|
||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
public unsafe struct FindBitsResult32 : IEnumerable<byte>
|
||||
{
|
||||
public fixed byte _numbers[32];
|
||||
public readonly byte Count;
|
||||
public int this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _numbers[index];
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResult32(uint bits)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Count = (byte)CountBits(bits);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int number = GetHighBitNumber(bits);
|
||||
_numbers[i] = (byte)number;
|
||||
bits ^= 1u << number;
|
||||
}
|
||||
}
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult32 a)
|
||||
{
|
||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<byte> ToSpan()
|
||||
{
|
||||
return CreateSpanInternal(this);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult32 a)
|
||||
{
|
||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResultEnumerator GetEnumerator()
|
||||
{
|
||||
return GetEnumeratorInternal(this);
|
||||
}
|
||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
public unsafe struct FindBitsResult64 : IEnumerable<byte>
|
||||
{
|
||||
private fixed byte _numbers[64];
|
||||
public readonly byte Count;
|
||||
public int this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _numbers[index];
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResult64(ulong bits)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Count = (byte)CountBits(bits);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int number = GetHighBitNumber(bits);
|
||||
_numbers[i] = (byte)number;
|
||||
bits ^= 1u << number;
|
||||
}
|
||||
}
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult64 a)
|
||||
{
|
||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<byte> ToSpan()
|
||||
{
|
||||
return CreateSpanInternal(this);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult64 a)
|
||||
{
|
||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResultEnumerator GetEnumerator()
|
||||
{
|
||||
return GetEnumeratorInternal(this);
|
||||
}
|
||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
public unsafe struct FindBitsResultEnumerator : IEnumerator<byte>
|
||||
{
|
||||
private byte* _numbers;
|
||||
private byte _count;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsResultEnumerator(byte* numbers, byte count)
|
||||
{
|
||||
_numbers = numbers;
|
||||
_count = count;
|
||||
}
|
||||
public byte Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
return *_numbers;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _count-- > 0;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { }
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region FindBitsIterator
|
||||
public struct FindBitsIterator8 : IEnumerable<int>
|
||||
{
|
||||
private Enumerator _enumerator;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator8(sbyte bits)
|
||||
{
|
||||
_enumerator = new Enumerator((byte)bits);
|
||||
}
|
||||
public FindBitsIterator8(sbyte bits) { _enumerator = new Enumerator((byte)bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator8(byte bits)
|
||||
{
|
||||
_enumerator = new Enumerator(bits);
|
||||
}
|
||||
public FindBitsIterator8(byte bits) { _enumerator = new Enumerator(bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return _enumerator;
|
||||
}
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public Enumerator GetEnumerator() { return _enumerator; }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private uint _bits;
|
||||
@ -888,16 +657,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
return number;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _count-- > 0;
|
||||
}
|
||||
public bool MoveNext() { return _count-- > 0; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IEnumerator.Reset() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -905,22 +670,13 @@ namespace DCFApixels.DragonECS.Internal
|
||||
{
|
||||
private Enumerator _enumerator;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator16(short bits)
|
||||
{
|
||||
_enumerator = new Enumerator((ushort)bits);
|
||||
}
|
||||
public FindBitsIterator16(short bits) { _enumerator = new Enumerator((ushort)bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator16(ushort bits)
|
||||
{
|
||||
_enumerator = new Enumerator(bits);
|
||||
}
|
||||
public FindBitsIterator16(ushort bits) { _enumerator = new Enumerator(bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return _enumerator;
|
||||
}
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public Enumerator GetEnumerator() { return _enumerator; }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private uint _bits;
|
||||
@ -941,16 +697,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
return number;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _count-- > 0;
|
||||
}
|
||||
public bool MoveNext() { return _count-- > 0; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IEnumerator.Reset() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -958,22 +710,13 @@ namespace DCFApixels.DragonECS.Internal
|
||||
{
|
||||
private Enumerator _enumerator;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator32(int bits)
|
||||
{
|
||||
_enumerator = new Enumerator((uint)bits);
|
||||
}
|
||||
public FindBitsIterator32(int bits) { _enumerator = new Enumerator((uint)bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator32(uint bits)
|
||||
{
|
||||
_enumerator = new Enumerator(bits);
|
||||
}
|
||||
public FindBitsIterator32(uint bits) { _enumerator = new Enumerator(bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return _enumerator;
|
||||
}
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public Enumerator GetEnumerator() { return _enumerator; }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private uint _bits;
|
||||
@ -994,16 +737,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
return number;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _count-- > 0;
|
||||
}
|
||||
public bool MoveNext() { return _count-- > 0; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IEnumerator.Reset() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1011,22 +750,13 @@ namespace DCFApixels.DragonECS.Internal
|
||||
{
|
||||
private Enumerator _enumerator;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator64(long bits)
|
||||
{
|
||||
_enumerator = new Enumerator((ulong)bits);
|
||||
}
|
||||
public FindBitsIterator64(long bits) { _enumerator = new Enumerator((ulong)bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public FindBitsIterator64(ulong bits)
|
||||
{
|
||||
_enumerator = new Enumerator(bits);
|
||||
}
|
||||
public FindBitsIterator64(ulong bits) { _enumerator = new Enumerator(bits); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return _enumerator;
|
||||
}
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public Enumerator GetEnumerator() { return _enumerator; }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
{
|
||||
private ulong _bits;
|
||||
@ -1047,16 +777,12 @@ namespace DCFApixels.DragonECS.Internal
|
||||
return number;
|
||||
}
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _count-- > 0;
|
||||
}
|
||||
public bool MoveNext() { return _count-- > 0; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IEnumerator.Reset() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -261,10 +261,8 @@ namespace DCFApixels.DragonECS.Internal
|
||||
#endregion
|
||||
|
||||
#region Enumerable
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return new Enumerator(_dense, 0, _usedCount);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator() { return new Enumerator(_dense, 0, _usedCount); }
|
||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
public struct Enumerator : IEnumerator<int>
|
||||
@ -272,17 +270,25 @@ namespace DCFApixels.DragonECS.Internal
|
||||
private readonly int[] _dense;
|
||||
private readonly int _count;
|
||||
private int _index;
|
||||
public int Current => _dense[_index];
|
||||
object IEnumerator.Current => Current;
|
||||
public int Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _dense[_index]; }
|
||||
}
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator(int[] dense, int startIndex, int count)
|
||||
{
|
||||
_dense = dense;
|
||||
_count = startIndex + count;
|
||||
_index = startIndex - 1;
|
||||
}
|
||||
public bool MoveNext() => ++_index < _count;
|
||||
public void Dispose() { }
|
||||
public void Reset() => _index = -1;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext() { return ++_index < _count; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IDisposable.Dispose() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { _index = -1; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -303,19 +309,15 @@ namespace DCFApixels.DragonECS.Internal
|
||||
private static class ThrowHalper
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ThrowIsAlreadyInUse(int id) => throw new ArgumentException($"Id {id} is already in use.");
|
||||
public static void ThrowIsAlreadyInUse(int id) { throw new ArgumentException($"Id {id} is already in use."); }
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ThrowIsHasBeenReserved(int id) => throw new ArgumentException($"Id {id} has been reserved.");
|
||||
|
||||
public static void ThrowIsHasBeenReserved(int id) { throw new ArgumentException($"Id {id} has been reserved."); }
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ThrowIsNotUsed(int id) => throw new ArgumentException($"Id {id} is not used.");
|
||||
|
||||
public static void ThrowIsNotUsed(int id) { throw new ArgumentException($"Id {id} is not used."); }
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ThrowIsNotAvailable(int id) => throw new ArgumentException($"Id {id} is not available.");
|
||||
|
||||
public static void ThrowIsNotAvailable(int id) { throw new ArgumentException($"Id {id} is not available."); }
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void ThrowIsNullID(int id) => throw new ArgumentException($"Id {id} cannot be released because it is used as a null id.");
|
||||
|
||||
public static void ThrowIsNullID(int id) { throw new ArgumentException($"Id {id} cannot be released because it is used as a null id."); }
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void UndefinedException() { throw new Exception(); }
|
||||
}
|
||||
|
||||
@ -32,15 +32,15 @@ namespace DCFApixels.DragonECS.Internal
|
||||
#region Properties
|
||||
public TValue this[int keyX, int keyY]
|
||||
{
|
||||
get => _entries[FindEntry((keyX << 16) | keyY)].value;
|
||||
set => Insert(keyX + (keyY << 16), value);
|
||||
get { return _entries[FindEntry((keyX << 16) | keyY)].value; }
|
||||
set { Insert(keyX + (keyY << 16), value); }
|
||||
}
|
||||
public TValue this[int key]
|
||||
{
|
||||
get => _entries[FindEntry(key)].value;
|
||||
set => Insert(key, value);
|
||||
get { return _entries[FindEntry(key)].value; }
|
||||
set { Insert(key, value); }
|
||||
}
|
||||
public int Count => _count;
|
||||
public int Count { get { return _count; } }
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -57,22 +57,21 @@ namespace DCFApixels.DragonECS.Internal
|
||||
|
||||
#region Add/Contains/Remove
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Add(int keyX, int keyY, TValue value) => Add((keyX << 16) | keyY, value);
|
||||
public void Add(int keyX, int keyY, TValue value) { Add((keyX << 16) | keyY, value); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Add(int key, TValue value)
|
||||
{
|
||||
#if DEBUG
|
||||
if (Contains(key))
|
||||
throw new ArgumentException("Contains(hashKey) is true");
|
||||
if (Contains(key)) { throw new ArgumentException("Contains(hashKey) is true"); }
|
||||
#endif
|
||||
Insert(key, value);
|
||||
}
|
||||
|
||||
public bool Contains(int keyX, int keyY) => FindEntry((keyX << 16) | keyY) >= 0;
|
||||
public bool Contains(int key) => FindEntry(key) >= 0;
|
||||
public bool Contains(int keyX, int keyY) { return FindEntry((keyX << 16) | keyY) >= 0; }
|
||||
public bool Contains(int key) { return FindEntry(key) >= 0; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Remove(int keyX, int keyY) => Remove((keyX << 16) | keyY);
|
||||
public bool Remove(int keyX, int keyY) { return Remove((keyX << 16) | keyY); }
|
||||
public bool Remove(int key)
|
||||
{
|
||||
int bucket = key & _modBitMask;
|
||||
|
||||
@ -55,10 +55,10 @@ namespace DCFApixels.DragonECS.Internal
|
||||
return CollectionUtility.AutoToString(EnumerableInt.Range(0, Length).Select(i => ptr[i]), "ua");
|
||||
}
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return GetEnumerator(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator() => new Enumerator(ptr, Length);
|
||||
public Enumerator GetEnumerator() { return new Enumerator(ptr, Length); }
|
||||
public struct Enumerator : IEnumerator<T>
|
||||
{
|
||||
private readonly T* _ptr;
|
||||
@ -74,15 +74,14 @@ namespace DCFApixels.DragonECS.Internal
|
||||
public T Current
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr[_index];
|
||||
get { return _ptr[_index]; }
|
||||
}
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current { get { return Current; } }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext() => ++_index < _length;
|
||||
public bool MoveNext() { return ++_index < _length; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Reset() { }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() { }
|
||||
void IDisposable.Dispose() { }
|
||||
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
internal class DebuggerProxy
|
||||
|
||||
@ -270,8 +270,8 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region IEnumerator - IntelliSense hack
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => throw new NotImplementedException();
|
||||
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() { throw new NotImplementedException(); }
|
||||
IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
|
||||
#endregion
|
||||
|
||||
#region MarkersConverter
|
||||
|
||||
Loading…
Reference in New Issue
Block a user