From cbfb54b32e80ab6089a05cddb2f03fb17a52965b Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:02:18 +0800 Subject: [PATCH] update ecsgroup --- src/Collections/EcsGroup.cs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Collections/EcsGroup.cs b/src/Collections/EcsGroup.cs index f5e411e..cc5ce0c 100644 --- a/src/Collections/EcsGroup.cs +++ b/src/Collections/EcsGroup.cs @@ -184,6 +184,7 @@ namespace DCFApixels.DragonECS [Il2CppSetOption(Option.ArrayBoundsChecks, false)] #endif [DebuggerTypeProxy(typeof(DebuggerProxy))] + //TODO переработать EcsGroup в структуру-обертку, чтобы когда вызывается Release то можно было занулить эту структуру public class EcsGroup : IDisposable, IEnumerable, IEntityStorage, ISet { private EcsWorld _source; @@ -353,6 +354,9 @@ namespace DCFApixels.DragonECS 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); } public bool Remove(int entityID) @@ -365,11 +369,8 @@ namespace DCFApixels.DragonECS return true; } [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]; _sparse[_dense[_count--]] = _sparse[entityID]; _sparse[entityID] = 0; @@ -402,7 +403,6 @@ namespace DCFApixels.DragonECS } #endregion - #region Upsize public void Upsize(int minSize) { @@ -1302,10 +1302,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void OnReleaseDelEntityBuffer_Internal(ReadOnlySpan buffer) { - if (_count <= 0) - { - return; - } + if (_count <= 0) { return; } foreach (var entityID in buffer) { if (Has(entityID)) @@ -1318,6 +1315,8 @@ namespace DCFApixels.DragonECS { return CollectionUtility.EntitiesToString(_dense.Skip(1).Take(_count), "group"); } + void ICollection.Add(int item) { Add(item); } + bool ICollection.Contains(int item) { return Has(item); } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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()) { } } #endregion - - #region ISet - void ICollection.Add(int item) - { - Add(item); - } - bool ICollection.Contains(int item) - { - return Has(item); - } - #endregion } } \ No newline at end of file