diff --git a/src/EcsAspect.cs b/src/EcsAspect.cs index 656f8b8..1844bf6 100644 --- a/src/EcsAspect.cs +++ b/src/EcsAspect.cs @@ -496,7 +496,7 @@ namespace DCFApixels.DragonECS EcsWorld world = EcsWorld.GetWorld(worldID); foreach (var incTypeID in _mask._inc) { - var pool = world.GetPoolInstance(incTypeID); + var pool = world.FindPoolInstance(incTypeID); if (pool != null) { if (pool.Has(entityID) == false) @@ -513,7 +513,7 @@ namespace DCFApixels.DragonECS } foreach (var excTypeID in _mask._exc) { - var pool = world.GetPoolInstance(excTypeID); + var pool = world.FindPoolInstance(excTypeID); if (pool != null && pool.Has(entityID)) { pool.Del(entityID); diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs index d8944d7..0fb1595 100644 --- a/src/EcsWorld.pools.cs +++ b/src/EcsWorld.pools.cs @@ -16,34 +16,49 @@ namespace DCFApixels.DragonECS private readonly PoolsMediator _poolsMediator; - private EcsNullPool _nullPool = EcsNullPool.instance; + private readonly EcsNullPool _nullPool = EcsNullPool.instance; - #region Getters + #region FindPoolInstance + [Obsolete("The GetPoolInstance(int componentTypeID) method will be removed in future updates, use FindPoolInstance(Type componentType)")] public IEcsPool GetPoolInstance(int componentTypeID) + { + return FindPoolInstance(componentTypeID); + } + [Obsolete("The GetPoolInstance(Type componentType) method will be removed in future updates, use FindPoolInstance(Type componentType)")] + public IEcsPool GetPoolInstance(Type componentType) + { + return FindPoolInstance(componentType); + } + + public IEcsPool FindPoolInstance(int componentTypeID) { if (IsComponentTypeDeclared(componentTypeID)) { - var resuult = _pools[componentTypeID]; -#if DEBUG - if (resuult != _nullPool && resuult.ComponentTypeID != componentTypeID) { Throw.UndefinedException(); } -#endif - return resuult; + return FindPoolInstance_Internal(componentTypeID); } return null; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public IEcsPool GetPoolInstance(Type componentType) + public IEcsPool FindPoolInstance(Type componentType) { - int componentTypeID = GetComponentTypeID(componentType); - ref var pool = ref _pools[componentTypeID]; - if (pool == _nullPool) - { - return null; - } - return pool; + return FindPoolInstance_Internal(GetComponentTypeID(componentType)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private IEcsPool FindPoolInstance_Internal(int componentTypeID) + { + ref var result = ref _pools[componentTypeID]; + if (result != _nullPool) + { +#if (DEBUG && !DISABLE_DEBUG) + if (result.ComponentTypeID != componentTypeID) { Throw.UndefinedException(); } +#endif + return result; + } + return null; + } + #endregion + #region GetPoolInstance #if UNITY_2020_3_OR_NEWER [UnityEngine.Scripting.Preserve] #endif