diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 3cc73f4..375257a 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 (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent(entityID); } if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); } @@ -144,6 +145,9 @@ namespace DCFApixels.DragonECS } public ref T TryAddOrGet(int entityID) { +#if DEBUG + if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } +#endif ref int itemIndex = ref _mapping[entityID]; if (itemIndex <= 0) { //Add block @@ -185,6 +189,7 @@ namespace DCFApixels.DragonECS { ref int itemIndex = ref _mapping[entityID]; #if DEBUG + if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); } if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent(entityID); } if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); } #elif DRAGONECS_STABILITY_MODE @@ -237,9 +242,8 @@ namespace DCFApixels.DragonECS #elif DRAGONECS_STABILITY_MODE if (_isLocked) { return; } #endif - _recycledItemsCount = 0; // спереди потому чтобы обнулялось, так как Del не обнуляет + _recycledItemsCount = 0; // спереди чтобы обнулялось, так как Del не обнуляет if (_itemsCount <= 0) { return; } - _itemsCount = 0; var span = _source.Where(out SingleAspect _); foreach (var entityID in span) { @@ -251,6 +255,8 @@ namespace DCFApixels.DragonECS _listeners.InvokeOnDel(entityID, _listenersCachedCount); #endif } + _itemsCount = 0; + _recycledItemsCount = 0; } #endregion