mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
fixes, rename EcsVirtualPool to EcsAnonymousPool
This commit is contained in:
parent
281281f5f3
commit
ed40b87e9f
@ -29,7 +29,7 @@ namespace DCFApixels.DragonECS
|
|||||||
ref var pool = ref _pools[componentTypeID];
|
ref var pool = ref _pools[componentTypeID];
|
||||||
if (pool == _nullPool)
|
if (pool == _nullPool)
|
||||||
{
|
{
|
||||||
pool = new EcsVirtualPool();
|
pool = new EcsAnonymousPool();
|
||||||
pool.OnInit(this, _poolsMediator, componentTypeID);
|
pool.OnInit(this, _poolsMediator, componentTypeID);
|
||||||
}
|
}
|
||||||
return pool;
|
return pool;
|
||||||
@ -190,18 +190,19 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
|
|
||||||
var oldPool = _pools[componentTypeID];
|
var oldPool = _pools[componentTypeID];
|
||||||
if (oldPool is EcsVirtualPool virtualPool)
|
|
||||||
|
//if (oldPool.IsNullOrDummy() == false)
|
||||||
|
//{
|
||||||
|
// Throw.UndefinedException();
|
||||||
|
//}
|
||||||
|
|
||||||
|
_pools[componentTypeID] = newPool;
|
||||||
|
newPool.OnInit(this, _poolsMediator, componentTypeID);
|
||||||
|
if (oldPool is EcsAnonymousPool virtualPool)
|
||||||
{
|
{
|
||||||
var data = virtualPool.GetDevirtualizationData();
|
var data = virtualPool.GetDevirtualizationData();
|
||||||
newPool.OnDevirtualize(data);
|
newPool.OnDevirtualize(data);
|
||||||
}
|
}
|
||||||
if (oldPool.IsNullOrDummy() == false)
|
|
||||||
{
|
|
||||||
Throw.UndefinedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
_pools[componentTypeID] = newPool;
|
|
||||||
newPool.OnInit(this, _poolsMediator, componentTypeID);
|
|
||||||
return newPool;
|
return newPool;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -5,7 +5,8 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
//EcsAnonymousPool > EcsVirtualPool<T> > EcsPool<T>
|
||||||
|
public class EcsAnonymousPool : IEcsPoolImplementation, IEnumerable
|
||||||
{
|
{
|
||||||
private EcsWorld _source;
|
private EcsWorld _source;
|
||||||
private Type _componentType;
|
private Type _componentType;
|
||||||
@ -199,7 +200,7 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
|||||||
}
|
}
|
||||||
public readonly ref struct Data
|
public readonly ref struct Data
|
||||||
{
|
{
|
||||||
private readonly EcsVirtualPool _target;
|
private readonly EcsAnonymousPool _target;
|
||||||
|
|
||||||
public int ComponentsCount
|
public int ComponentsCount
|
||||||
{
|
{
|
||||||
@ -215,16 +216,16 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Data(EcsVirtualPool target)
|
public Data(EcsAnonymousPool target)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly ref struct ListenersIterator
|
public readonly ref struct ListenersIterator
|
||||||
{
|
{
|
||||||
private readonly EcsVirtualPool _target;
|
private readonly EcsAnonymousPool _target;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ListenersIterator(EcsVirtualPool target)
|
public ListenersIterator(EcsAnonymousPool target)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
}
|
}
|
||||||
@ -234,9 +235,9 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
|||||||
|
|
||||||
public readonly ref struct RawDataIterator
|
public readonly ref struct RawDataIterator
|
||||||
{
|
{
|
||||||
private readonly EcsVirtualPool _target;
|
private readonly EcsAnonymousPool _target;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public RawDataIterator(EcsVirtualPool target)
|
public RawDataIterator(EcsAnonymousPool target)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
}
|
}
|
||||||
@ -248,6 +249,7 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
|||||||
private readonly object[] _items;
|
private readonly object[] _items;
|
||||||
private readonly int _entitesCount;
|
private readonly int _entitesCount;
|
||||||
private int _entityID;
|
private int _entityID;
|
||||||
|
private int _itemIndex;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator(RawDataIterator devirtualizator)
|
public Enumerator(RawDataIterator devirtualizator)
|
||||||
{
|
{
|
||||||
@ -263,14 +265,15 @@ public class EcsVirtualPool : IEcsPoolImplementation, IEnumerable
|
|||||||
public EntityRawDataPair Current
|
public EntityRawDataPair Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return new EntityRawDataPair(_entityID, _items[_entityID]); }
|
get { return new EntityRawDataPair(_entityID, _items[_itemIndex]); }
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext()
|
||||||
{
|
{
|
||||||
while (_entityID++ < _entitesCount)
|
while (_entityID++ < _entitesCount)
|
||||||
{
|
{
|
||||||
if (_mapping[_entityID] != 0)
|
_itemIndex = _mapping[_entityID];
|
||||||
|
if (_itemIndex != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -306,6 +309,6 @@ public static class VirtualPoolExtensions
|
|||||||
{
|
{
|
||||||
public static bool IsVirtual(this IEcsPool self)
|
public static bool IsVirtual(this IEcsPool self)
|
||||||
{
|
{
|
||||||
return self is EcsVirtualPool;
|
return self is EcsAnonymousPool;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -210,7 +210,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_entities = new int[capacity];
|
_entities = new int[capacity];
|
||||||
_itemsCount = 0;
|
_itemsCount = 0;
|
||||||
}
|
}
|
||||||
void IEcsPoolImplementation.OnDevirtualize(EcsVirtualPool.Data data)
|
void IEcsPoolImplementation.OnDevirtualize(EcsAnonymousPool.Data data)
|
||||||
{
|
{
|
||||||
if (_items.Length < data.ComponentsCount)
|
if (_items.Length < data.ComponentsCount)
|
||||||
{
|
{
|
||||||
@ -424,7 +424,7 @@ public class HybridTypeMapping
|
|||||||
private EcsWorld _world;
|
private EcsWorld _world;
|
||||||
private Dictionary<Type, IEcsHybridPoolInternal> _declared = new Dictionary<Type, IEcsHybridPoolInternal>();
|
private Dictionary<Type, IEcsHybridPoolInternal> _declared = new Dictionary<Type, IEcsHybridPoolInternal>();
|
||||||
|
|
||||||
private HashSet<Type> _canInstantiatedTypes = new HashSet<Type>();
|
private Dictionary<Type, IEcsPool> _canInstantiatedTypes = new Dictionary<Type, IEcsPool>();
|
||||||
|
|
||||||
public void AddIntsanceType(object instance)
|
public void AddIntsanceType(object instance)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_items = new T[ArrayUtility.NormalizeSizeToPowerOfTwo(world.Config.Get_PoolComponentsCapacity())];
|
_items = new T[ArrayUtility.NormalizeSizeToPowerOfTwo(world.Config.Get_PoolComponentsCapacity())];
|
||||||
_itemsCount = 0;
|
_itemsCount = 0;
|
||||||
}
|
}
|
||||||
void IEcsPoolImplementation.OnDevirtualize(EcsVirtualPool.Data data)
|
void IEcsPoolImplementation.OnDevirtualize(EcsAnonymousPool.Data data)
|
||||||
{
|
{
|
||||||
if(_items.Length < data.ComponentsCount)
|
if(_items.Length < data.ComponentsCount)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public interface IEcsPoolImplementation : IEcsPool
|
public interface IEcsPoolImplementation : IEcsPool
|
||||||
{
|
{
|
||||||
void OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID);
|
void OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID);
|
||||||
void OnDevirtualize(EcsVirtualPool.Data data);
|
void OnDevirtualize(EcsAnonymousPool.Data data);
|
||||||
void OnWorldResize(int newSize);
|
void OnWorldResize(int newSize);
|
||||||
void OnReleaseDelEntityBuffer(ReadOnlySpan<int> buffer);
|
void OnReleaseDelEntityBuffer(ReadOnlySpan<int> buffer);
|
||||||
void OnWorldDestroy();
|
void OnWorldDestroy();
|
||||||
@ -114,7 +114,7 @@ namespace DCFApixels.DragonECS
|
|||||||
void IEcsPool.SetRaw(int entity, object dataRaw) => throw new NotImplementedException();
|
void IEcsPool.SetRaw(int entity, object dataRaw) => throw new NotImplementedException();
|
||||||
void IEcsPool.Copy(int fromEntityID, int toEntityID) => throw new NotImplementedException();
|
void IEcsPool.Copy(int fromEntityID, int toEntityID) => throw new NotImplementedException();
|
||||||
void IEcsPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException();
|
void IEcsPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException();
|
||||||
void IEcsPoolImplementation.OnDevirtualize(EcsVirtualPool.Data virtualPoolData)
|
void IEcsPoolImplementation.OnDevirtualize(EcsAnonymousPool.Data virtualPoolData)
|
||||||
{
|
{
|
||||||
Throw.UndefinedException();
|
Throw.UndefinedException();
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_mapping = new bool[world.Capacity];
|
_mapping = new bool[world.Capacity];
|
||||||
_count = 0;
|
_count = 0;
|
||||||
}
|
}
|
||||||
void IEcsPoolImplementation.OnDevirtualize(EcsVirtualPool.Data data)
|
void IEcsPoolImplementation.OnDevirtualize(EcsAnonymousPool.Data data)
|
||||||
{
|
{
|
||||||
_count = data.ComponentsCount;
|
_count = data.ComponentsCount;
|
||||||
foreach (var item in data.RawComponents)
|
foreach (var item in data.RawComponents)
|
||||||
|
Loading…
Reference in New Issue
Block a user