mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-14 01:35:54 +08:00
update ecsgroup
This commit is contained in:
parent
1e6598d1fb
commit
cbfb54b32e
@ -184,6 +184,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
#endif
|
#endif
|
||||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
|
//TODO переработать EcsGroup в структуру-обертку, чтобы когда вызывается Release то можно было занулить эту структуру
|
||||||
public class EcsGroup : IDisposable, IEnumerable<int>, IEntityStorage, ISet<int>
|
public class EcsGroup : IDisposable, IEnumerable<int>, IEntityStorage, ISet<int>
|
||||||
{
|
{
|
||||||
private EcsWorld _source;
|
private EcsWorld _source;
|
||||||
@ -353,6 +354,9 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void RemoveUnchecked(int entityID)
|
public void RemoveUnchecked(int entityID)
|
||||||
{
|
{
|
||||||
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
|
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
||||||
|
#endif
|
||||||
Remove_Internal(entityID);
|
Remove_Internal(entityID);
|
||||||
}
|
}
|
||||||
public bool Remove(int entityID)
|
public bool Remove(int entityID)
|
||||||
@ -365,11 +369,8 @@ namespace DCFApixels.DragonECS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal void Remove_Internal(int entityID)
|
private void Remove_Internal(int entityID)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
|
||||||
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
|
||||||
#endif
|
|
||||||
_dense[_sparse[entityID]] = _dense[_count];
|
_dense[_sparse[entityID]] = _dense[_count];
|
||||||
_sparse[_dense[_count--]] = _sparse[entityID];
|
_sparse[_dense[_count--]] = _sparse[entityID];
|
||||||
_sparse[entityID] = 0;
|
_sparse[entityID] = 0;
|
||||||
@ -402,7 +403,6 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Upsize
|
#region Upsize
|
||||||
public void Upsize(int minSize)
|
public void Upsize(int minSize)
|
||||||
{
|
{
|
||||||
@ -1302,10 +1302,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal void OnReleaseDelEntityBuffer_Internal(ReadOnlySpan<int> buffer)
|
internal void OnReleaseDelEntityBuffer_Internal(ReadOnlySpan<int> buffer)
|
||||||
{
|
{
|
||||||
if (_count <= 0)
|
if (_count <= 0) { return; }
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach (var entityID in buffer)
|
foreach (var entityID in buffer)
|
||||||
{
|
{
|
||||||
if (Has(entityID))
|
if (Has(entityID))
|
||||||
@ -1318,6 +1315,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return CollectionUtility.EntitiesToString(_dense.Skip(1).Take(_count), "group");
|
return CollectionUtility.EntitiesToString(_dense.Skip(1).Take(_count), "group");
|
||||||
}
|
}
|
||||||
|
void ICollection<int>.Add(int item) { Add(item); }
|
||||||
|
bool ICollection<int>.Contains(int item) { return Has(item); }
|
||||||
|
|
||||||
[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; }
|
||||||
@ -1348,16 +1347,5 @@ namespace DCFApixels.DragonECS
|
|||||||
public DebuggerProxy(EcsReadonlyGroup group) : this(group.GetSource_Internal()) { }
|
public DebuggerProxy(EcsReadonlyGroup group) : this(group.GetSource_Internal()) { }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ISet
|
|
||||||
void ICollection<int>.Add(int item)
|
|
||||||
{
|
|
||||||
Add(item);
|
|
||||||
}
|
|
||||||
bool ICollection<int>.Contains(int item)
|
|
||||||
{
|
|
||||||
return Has(item);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user