diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs index 2c8b49b..b1b2815 100644 --- a/src/EcsWorld.pools.cs +++ b/src/EcsWorld.pools.cs @@ -100,7 +100,7 @@ namespace DCFApixels.DragonECS } #endregion - #region Declare/Create + #region Declare private int DeclareOrGetComponentTypeID(int componentTypeCode) { if (_cmpTypeCode_2_CmpTypeIDs.TryGetValue(componentTypeCode, out int ComponentTypeID) == false) @@ -120,6 +120,9 @@ namespace DCFApixels.DragonECS } return false; } + #endregion + + #region Create private TPool CreatePool() where TPool : IEcsPoolImplementation, new() { int poolTypeCode = EcsTypeCode.Get(); @@ -186,7 +189,13 @@ namespace DCFApixels.DragonECS } - if (_pools[componentTypeID] != _nullPool) + var oldPool = _pools[componentTypeID]; + if (oldPool is EcsVirtualPool virtualPool) + { + var data = virtualPool.GetDevirtualizationData(); + newPool.OnDevirtualize(data); + } + if (oldPool.IsNullOrDummy() == false) { Throw.UndefinedException(); } @@ -197,7 +206,6 @@ namespace DCFApixels.DragonECS } #endregion - #region Pools mediation [MethodImpl(MethodImplOptions.AggressiveInlining)] private void RegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit) diff --git a/src/Pools/EcsHybridPool.cs b/src/Pools/EcsHybridPool.cs index 838ea92..57a7d33 100644 --- a/src/Pools/EcsHybridPool.cs +++ b/src/Pools/EcsHybridPool.cs @@ -201,7 +201,7 @@ namespace DCFApixels.DragonECS _componentTypeID = componentTypeID; _maskBit = EcsMaskChunck.FromID(componentTypeID); - const int capacity = 512; + const int capacity = 512;//TODO заменить на значение из конфига _mapping = new int[world.Capacity]; _recycledItems = new int[128]; diff --git a/src/Pools/EcsVirtualPool.cs b/src/Pools/EcsVirtualPool.cs index 45e57cc..4f9a166 100644 --- a/src/Pools/EcsVirtualPool.cs +++ b/src/Pools/EcsVirtualPool.cs @@ -22,6 +22,8 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable private EcsWorld.PoolsMediator _mediator; + private bool _isDevirtualized = false; + #region Properties public int ComponentID { @@ -43,6 +45,10 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable { get { return _mapping.Length; } } + public bool IsDevirtualized + { + get { return _isDevirtualized; } + } #endregion #region Callbacks @@ -187,6 +193,10 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable #endregion #region Devirtualization + public Data GetDevirtualizationData() + { + return new Data(this); + } public readonly ref struct Data { private readonly EcsVirtualPool _target;