mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
update collections, add EcsLongsSpan
This commit is contained in:
parent
1b0f716a03
commit
fda8419dbf
@ -44,6 +44,11 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _source.CapacityDense; }
|
get { return _source.CapacityDense; }
|
||||||
}
|
}
|
||||||
|
public EcsLongsSpan Longs
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _source.Longs; }
|
||||||
|
}
|
||||||
public bool IsReleazed
|
public bool IsReleazed
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -70,19 +75,21 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int IndexOf(int entityID) { return _source.IndexOf(entityID); }
|
public int IndexOf(int entityID) { return _source.IndexOf(entityID); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsGroup.Enumerator GetEnumerator() { return _source.GetEnumerator(); }
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public EcsGroup Clone() { return _source.Clone(); }
|
public EcsGroup Clone() { return _source.Clone(); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int[] Bake() { return _source.Bake(); }
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public int Bake(ref int[] entities) { return _source.Bake(ref entities); }
|
public int Bake(ref int[] entities) { return _source.Bake(ref entities); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Bake(List<int> entities) { _source.Bake(entities); }
|
public void Bake(List<int> entities) { _source.Bake(entities); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start) { return _source.Slice(start); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start, int length) { return _source.Slice(start, length); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan ToSpan() { return _source.ToSpan(); }
|
public EcsSpan ToSpan() { return _source.ToSpan(); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan ToSpan(int start, int length) { return _source.ToSpan(start, length); }
|
public int[] ToArray() { return _source.ToArray(); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsGroup.Enumerator GetEnumerator() { return _source.GetEnumerator(); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsGroup.LongsIterator GetLongs() { return _source.GetLongs(); }
|
public EcsGroup.LongsIterator GetLongs() { return _source.GetLongs(); }
|
||||||
|
|
||||||
@ -118,7 +125,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
#region Internal
|
#region Internal
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal EcsGroup GetSource_Internal() => _source;
|
internal EcsGroup GetSource_Internal() { return _source; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
@ -174,6 +181,11 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return new EcsReadonlyGroup(this); }
|
get { return new EcsReadonlyGroup(this); }
|
||||||
}
|
}
|
||||||
|
public EcsLongsSpan Longs
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return new EcsLongsSpan(this); }
|
||||||
|
}
|
||||||
public bool IsReleased
|
public bool IsReleased
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -291,7 +303,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Clear
|
#region Clear
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
if(_count == 0)
|
if (_count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -303,7 +315,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region CopyFrom/Clone/Bake/ToSpan
|
#region CopyFrom/Clone/Bake/Slice/ToSpan/ToArray
|
||||||
public void CopyFrom(EcsGroup group)
|
public void CopyFrom(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
@ -335,18 +347,14 @@ namespace DCFApixels.DragonECS
|
|||||||
Add_Internal(span[i]);
|
Add_Internal(span[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsGroup Clone()
|
public EcsGroup Clone()
|
||||||
{
|
{
|
||||||
EcsGroup result = _source.GetFreeGroup();
|
EcsGroup result = _source.GetFreeGroup();
|
||||||
result.CopyFrom(this);
|
result.CopyFrom(this);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public int[] Bake()
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
{
|
|
||||||
int[] result = new int[_count];
|
|
||||||
Array.Copy(_dense, 1, result, 0, _count);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public int Bake(ref int[] entities)
|
public int Bake(ref int[] entities)
|
||||||
{
|
{
|
||||||
if (entities.Length < _count)
|
if (entities.Length < _count)
|
||||||
@ -356,6 +364,7 @@ namespace DCFApixels.DragonECS
|
|||||||
Array.Copy(_dense, 1, entities, 0, _count);
|
Array.Copy(_dense, 1, entities, 0, _count);
|
||||||
return _count;
|
return _count;
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Bake(List<int> entities)
|
public void Bake(List<int> entities)
|
||||||
{
|
{
|
||||||
entities.Clear();
|
entities.Clear();
|
||||||
@ -364,17 +373,31 @@ namespace DCFApixels.DragonECS
|
|||||||
entities.Add(e);
|
entities.Add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start)
|
||||||
|
{
|
||||||
|
return Slice(start, _count - start + 1);
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start, int length)
|
||||||
|
{
|
||||||
|
start++;
|
||||||
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
|
if (start < 1 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
||||||
|
#endif
|
||||||
|
return new EcsSpan(WorldID, _dense, start, length);
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan ToSpan()
|
public EcsSpan ToSpan()
|
||||||
{
|
{
|
||||||
return new EcsSpan(WorldID, _dense, 1, _count);
|
return new EcsSpan(WorldID, _dense, 1, _count);
|
||||||
}
|
}
|
||||||
public EcsSpan ToSpan(int start, int length)
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int[] ToArray()
|
||||||
{
|
{
|
||||||
start -= 1;
|
int[] result = new int[_count];
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
Array.Copy(_dense, 1, result, 0, _count);
|
||||||
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
return result;
|
||||||
#endif
|
|
||||||
return new EcsSpan(WorldID, _dense, start, length);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -848,16 +871,16 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return CollectionUtility.EntitiesToString(_dense.Skip(1).Take(_count), "group");
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int First() { return _dense[1]; }
|
public int First() { return _dense[1]; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int Last() { return _dense[_count]; }
|
public int Last() { return _dense[_count]; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal void OnWorldResize(int newSize) { Array.Resize(ref _sparse, newSize); }
|
internal void OnWorldResize(int newSize) { Array.Resize(ref _sparse, newSize); }
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return CollectionUtility.EntitiesToString(_dense.Skip(1).Take(_count), "group");
|
||||||
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator EcsReadonlyGroup(EcsGroup a) { return a.Readonly; }
|
public static implicit operator EcsReadonlyGroup(EcsGroup a) { return a.Readonly; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -888,58 +911,4 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#if false
|
|
||||||
public static class EcsGroupAliases
|
|
||||||
{
|
|
||||||
/// <summary>Alias for UnionWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Add(this EcsGroup self, EcsGroup group)
|
|
||||||
{
|
|
||||||
self.UnionWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for UnionWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Add(this EcsGroup self, EcsReadonlyGroup group)
|
|
||||||
{
|
|
||||||
self.UnionWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for ExceptWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Remove(this EcsGroup self, EcsGroup group)
|
|
||||||
{
|
|
||||||
self.ExceptWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for ExceptWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Remove(this EcsGroup self, EcsReadonlyGroup group)
|
|
||||||
{
|
|
||||||
self.ExceptWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for SymmetricExceptWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Xor(this EcsGroup self, EcsGroup group)
|
|
||||||
{
|
|
||||||
self.SymmetricExceptWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for SymmetricExceptWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void Xor(this EcsGroup self, EcsReadonlyGroup group)
|
|
||||||
{
|
|
||||||
self.SymmetricExceptWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for IntersectWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void And(this EcsGroup self, EcsGroup group)
|
|
||||||
{
|
|
||||||
self.IntersectWith(group);
|
|
||||||
}
|
|
||||||
/// <summary>Alias for IntersectWith</summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void And(this EcsGroup self, EcsReadonlyGroup group)
|
|
||||||
{
|
|
||||||
self.IntersectWith(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
@ -33,6 +33,11 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _values.Length; }
|
get { return _values.Length; }
|
||||||
}
|
}
|
||||||
|
public EcsLongsSpan Longs
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return new EcsLongsSpan(this); }
|
||||||
|
}
|
||||||
public int this[int index]
|
public int this[int index]
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -66,12 +71,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methdos
|
#region Bake/Slice/ToArry
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public int[] Bake()
|
|
||||||
{
|
|
||||||
return _values.ToArray();
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int Bake(ref int[] entities)
|
public int Bake(ref int[] entities)
|
||||||
{
|
{
|
||||||
@ -79,8 +79,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
Array.Resize(ref entities, _values.Length);
|
Array.Resize(ref entities, _values.Length);
|
||||||
}
|
}
|
||||||
int[] result = new int[_values.Length];
|
_values.CopyTo(entities);
|
||||||
_values.CopyTo(result);
|
|
||||||
return _values.Length;
|
return _values.Length;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -92,6 +91,12 @@ namespace DCFApixels.DragonECS
|
|||||||
entities.Add(e);
|
entities.Add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start) { return new EcsSpan(_worldID, _values.Slice(start)); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan Slice(int start, int length) { return new EcsSpan(_worldID, _values.Slice(start, length)); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int[] ToArray() { return _values.ToArray(); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region operators
|
#region operators
|
||||||
@ -106,11 +111,9 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan Slice(int start) { return new EcsSpan(_worldID, _values.Slice(start)); }
|
public int First() { return _values[0]; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan Slice(int start, int length) { return new EcsSpan(_worldID, _values.Slice(start, length)); }
|
public int Last() { return _values[_values.Length - 1]; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public int[] ToArray() { return _values.ToArray(); }
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return CollectionUtility.EntitiesToString(_values.ToArray(), "span");
|
return CollectionUtility.EntitiesToString(_values.ToArray(), "span");
|
||||||
@ -149,7 +152,132 @@ namespace DCFApixels.DragonECS
|
|||||||
span._values.CopyTo(_values);
|
span._values.CopyTo(_values);
|
||||||
_worldID = span._worldID;
|
_worldID = span._worldID;
|
||||||
}
|
}
|
||||||
|
public DebuggerProxy(EcsLongsSpan span) : this(span.ToSpan()) { }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DebuggerTypeProxy(typeof(EcsSpan.DebuggerProxy))]
|
||||||
|
public readonly ref struct EcsLongsSpan
|
||||||
|
{
|
||||||
|
private readonly EcsSpan _source;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
public bool IsNull
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _source.IsNull; }
|
||||||
|
}
|
||||||
|
public int WorldID
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _source.WorldID; }
|
||||||
|
}
|
||||||
|
public EcsWorld World
|
||||||
|
{
|
||||||
|
get { return _source.World; }
|
||||||
|
}
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _source.Count; }
|
||||||
|
}
|
||||||
|
public int this[int index]
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _source[index]; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
internal EcsLongsSpan(EcsSpan span)
|
||||||
|
{
|
||||||
|
_source = span;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Bake/Slice/ToArry
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int Bake(ref entlong[] entities)
|
||||||
|
{
|
||||||
|
EcsWorld world = World;
|
||||||
|
if (entities.Length < _source.Count)
|
||||||
|
{
|
||||||
|
Array.Resize(ref entities, _source.Count);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < _source.Count; i++)
|
||||||
|
{
|
||||||
|
entities[i] = world.GetEntityLong(_source[i]);
|
||||||
|
}
|
||||||
|
return _source.Count;
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Bake(List<entlong> entities)
|
||||||
|
{
|
||||||
|
entities.Clear();
|
||||||
|
foreach (var e in this)
|
||||||
|
{
|
||||||
|
entities.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsLongsSpan Slice(int start) { return new EcsLongsSpan(_source.Slice(start)); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsLongsSpan Slice(int start, int length) { return new EcsLongsSpan(_source.Slice(start, length)); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EcsSpan ToSpan() { return _source; }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int[] ToArray() { return _source.ToArray(); }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region operators
|
||||||
|
public static bool operator ==(EcsLongsSpan left, EcsLongsSpan right) { return left._source == right._source; }
|
||||||
|
public static bool operator !=(EcsLongsSpan left, EcsLongsSpan right) { return left._source != right._source; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Enumerator
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public Enumerator GetEnumerator() { return new Enumerator(_source.World, _source.GetEnumerator()); }
|
||||||
|
public ref struct Enumerator
|
||||||
|
{
|
||||||
|
private readonly EcsWorld _world;
|
||||||
|
private ReadOnlySpan<int>.Enumerator _enumerator;
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public Enumerator(EcsWorld world, ReadOnlySpan<int>.Enumerator enumerator)
|
||||||
|
{
|
||||||
|
_world = world;
|
||||||
|
_enumerator = enumerator;
|
||||||
|
}
|
||||||
|
public entlong Current
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _world.GetEntityLong(_enumerator.Current); }
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool MoveNext() { return _enumerator.MoveNext(); }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Other
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public entlong First() { return _source.World.GetEntityLong(_source.First()); }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public entlong Last() { return _source.World.GetEntityLong(_source.Last()); }
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return CollectionUtility.EntitiesToString(_source.ToArray(), "longs_span");
|
||||||
|
}
|
||||||
|
#pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
[Obsolete("Equals() on EcsLongSpan will always throw an exception. Use the equality operator instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override bool Equals(object obj) { throw new NotSupportedException(); }
|
||||||
|
[Obsolete("GetHashCode() on EcsLongSpan will always throw an exception.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override int GetHashCode() { throw new NotSupportedException(); }
|
||||||
|
#pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static implicit operator EcsSpan(EcsLongsSpan a) { return a.ToSpan(); }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user