diff --git a/src/Pools/EcsHybridPool.cs b/src/Pools/EcsHybridPool.cs index 2653295..c620ed1 100644 --- a/src/Pools/EcsHybridPool.cs +++ b/src/Pools/EcsHybridPool.cs @@ -18,9 +18,6 @@ namespace DCFApixels.DragonECS private int[] _recycledItems; private int _recycledItemsCount; - private IEcsComponentReset _componentResetHandler = EcsComponentResetHandler.instance; - private IEcsComponentCopy _componentCopyHandler = EcsComponentCopyHandler.instance; - private List _listeners = new List(); #region Properites @@ -67,6 +64,7 @@ namespace DCFApixels.DragonECS } this.IncrementEntityComponentCount(entityID); _listeners.InvokeOnAdd(entityID); + component.OnAddToPool(); _items[itemIndex] = component; } public void Set(int entityID, T component) @@ -90,10 +88,10 @@ namespace DCFApixels.DragonECS else {//not null _listeners.InvokeOnDel(entityID); - if (_items[itemIndex] is IDisposable disposable) - disposable.Dispose(); + component.OnDelFromPool(); } _listeners.InvokeOnAdd(entityID); + component.OnAddToPool(); _items[itemIndex] = component; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -125,8 +123,7 @@ namespace DCFApixels.DragonECS #endif ref int itemIndex = ref _mapping[entityID]; T component = _items[itemIndex]; - if (component is IDisposable disposable) - disposable.Dispose(); + component.OnDelFromPool(); if (_recycledItemsCount >= _recycledItems.Length) Array.Resize(ref _recycledItems, _recycledItems.Length << 1); _recycledItems[_recycledItemsCount++] = itemIndex;