diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index fa2cae6..f440b2b 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -365,6 +365,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public int NewEntity(int entityID) { + _entityDispenser.Upsize(entityID + 1); #if DEBUG if (IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); } #elif DRAGONECS_STABILITY_MODE @@ -1257,9 +1258,12 @@ namespace DCFApixels.DragonECS { EntitySlotInfo[] result = new EntitySlotInfo[_world.Count]; int i = 0; - foreach (var e in _world.ToSpan()) + using (_world.DisableAutoReleaseDelEntBuffer()) { - result[i++] = _world.GetEntitySlotInfoDebug(e); + foreach (var e in _world.ToSpan()) + { + result[i++] = _world.GetEntitySlotInfoDebug(e); + } } return result; } diff --git a/src/Executors/EcsWhereExecutor.cs b/src/Executors/EcsWhereExecutor.cs index 9c88512..66d84d7 100644 --- a/src/Executors/EcsWhereExecutor.cs +++ b/src/Executors/EcsWhereExecutor.cs @@ -91,10 +91,22 @@ namespace DCFApixels.DragonECS.Internal Execute_Iternal(); #if DEBUG || DRAGONECS_DEEP_DEBUG var newSpan = new EcsSpan(World.ID, _filteredAllEntities, _filteredAllEntitiesCount); - foreach (var e in newSpan) + using (EcsGroup group = EcsGroup.New(World)) { - if (World.IsMatchesMask(Mask, e) == false) + foreach (var e in World.Entities) { + if (World.IsMatchesMask(Mask, e)) + { + group.Add(e); + } + } + + if (group.SetEquals(newSpan) == false) + { + int[] array = new int[_filteredAllEntities.Length]; + var count = _iterator.IterateTo(World.Entities, ref array); + + EcsDebug.PrintError(newSpan.ToString() + "\r\n" + group.ToSpan().ToString()); Throw.DeepDebugException(); } } diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 655e44a..bca9c8c 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -95,6 +95,7 @@ namespace DCFApixels.DragonECS { ref int itemIndex = ref _mapping[entityID]; #if DEBUG + if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent(entityID); } if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); } #elif DRAGONECS_STABILITY_MODE diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs index 1bec619..64aa373 100644 --- a/src/Pools/EcsTagPool.cs +++ b/src/Pools/EcsTagPool.cs @@ -104,6 +104,7 @@ namespace DCFApixels.DragonECS public void Add(int entityID) { #if DEBUG + if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent(entityID); } if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); } #elif DRAGONECS_STABILITY_MODE diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index ef53bf6..d4086a3 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -118,6 +118,11 @@ namespace DCFApixels.DragonECS.Internal throw new InvalidOperationException($"The method {methodName} can only be executed before creating entities in the world."); } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Ent_ThrowIsNotAlive(EcsWorld world, int entityID) + { + Ent_ThrowIsNotAlive((world, entityID)); + } [MethodImpl(MethodImplOptions.NoInlining)] internal static void Ent_ThrowIsNotAlive(entlong entity) {