mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
Compare commits
2 Commits
1605108e49
...
4512245e57
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4512245e57 | ||
![]() |
2e1b22c129 |
@ -10,7 +10,7 @@
|
|||||||
<RootNamespace>DCFApixels.DragonECS</RootNamespace>
|
<RootNamespace>DCFApixels.DragonECS</RootNamespace>
|
||||||
|
|
||||||
<Title>DragonECS</Title>
|
<Title>DragonECS</Title>
|
||||||
<Version>0.9.18</Version>
|
<Version>0.9.20</Version>
|
||||||
<Authors>DCFApixels</Authors>
|
<Authors>DCFApixels</Authors>
|
||||||
<Description>ECS Framework for Game Engines with C# and .Net Platform</Description>
|
<Description>ECS Framework for Game Engines with C# and .Net Platform</Description>
|
||||||
<Copyright>DCFApixels</Copyright>
|
<Copyright>DCFApixels</Copyright>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DragonECS",
|
"displayName": "DragonECS",
|
||||||
"description": "C# Entity Component System Framework",
|
"description": "C# Entity Component System Framework",
|
||||||
"unity": "2020.3",
|
"unity": "2020.3",
|
||||||
"version": "0.9.18",
|
"version": "0.9.20",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DragonECS.git"
|
"url": "https://github.com/DCFApixels/DragonECS.git"
|
||||||
|
@ -442,7 +442,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (++_count >= _dense.Length)
|
if (++_count >= _dense.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _dense, ArrayUtility.NextPow2(_count << 1));
|
Array.Resize(ref _dense, ArrayUtility.NextPow2(_count));
|
||||||
}
|
}
|
||||||
_dense[_count] = entityID;
|
_dense[_count] = entityID;
|
||||||
|
|
||||||
@ -576,7 +576,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (minSize >= _dense.Length)
|
if (minSize >= _dense.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _dense, ArrayUtility.NextPow2_ClampOverflow(minSize));
|
Array.Resize(ref _dense, ArrayUtility.CeilPow2_ClampOverflow(minSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (dynamicBuffer.Length < _count)
|
if (dynamicBuffer.Length < _count)
|
||||||
{
|
{
|
||||||
Array.Resize(ref dynamicBuffer, ArrayUtility.NextPow2(_count));
|
Array.Resize(ref dynamicBuffer, ArrayUtility.CeilPow2(_count));
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var e in this)
|
foreach (var e in this)
|
||||||
|
@ -98,7 +98,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (dynamicBuffer.Length < _values.Length)
|
if (dynamicBuffer.Length < _values.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref dynamicBuffer, ArrayUtility.NextPow2(_values.Length));
|
Array.Resize(ref dynamicBuffer, ArrayUtility.CeilPow2(_values.Length));
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var e in this)
|
foreach (var e in this)
|
||||||
@ -247,7 +247,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (dynamicBuffer.Length < _source.Count)
|
if (dynamicBuffer.Length < _source.Count)
|
||||||
{
|
{
|
||||||
Array.Resize(ref dynamicBuffer, ArrayUtility.NextPow2(_source.Count));
|
Array.Resize(ref dynamicBuffer, ArrayUtility.CeilPow2(_source.Count));
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var e in this)
|
foreach (var e in this)
|
||||||
|
@ -525,7 +525,7 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
{
|
{
|
||||||
if (id >= _stopwatchs.Length)
|
if (id >= _stopwatchs.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _stopwatchs, id << 1);
|
Array.Resize(ref _stopwatchs, ArrayUtility.NextPow2(id));
|
||||||
}
|
}
|
||||||
_stopwatchs[id] = new MarkerData(new System.Diagnostics.Stopwatch(), name, id);
|
_stopwatchs[id] = new MarkerData(new System.Diagnostics.Stopwatch(), name, id);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace DCFApixels.DragonECS
|
|||||||
get { return _anys; }
|
get { return _anys; }
|
||||||
}
|
}
|
||||||
public EcsMaskFlags Flags
|
public EcsMaskFlags Flags
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _flags; }
|
get { return _flags; }
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_sortAnyChunckBuffer.Length != 0)
|
if (_sortAnyChunckBuffer.Length != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _sortAnyChunckBuffer.Length; i++)
|
for (int i = 0; i < _sortAnyChunckBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +245,7 @@ namespace DCFApixels.DragonECS
|
|||||||
Configs.Instance.Set(config.Key, config.Value);
|
Configs.Instance.Set(config.Key, config.Value);
|
||||||
}
|
}
|
||||||
Layers.MergeWith(other.Layers);
|
Layers.MergeWith(other.Layers);
|
||||||
|
|
||||||
foreach (ref readonly SystemNode otherRecord in new LinkedListCountIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex))
|
foreach (ref readonly SystemNode otherRecord in new LinkedListCountIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex))
|
||||||
{
|
{
|
||||||
AddNode_Internal(otherRecord.system, otherRecord.layerName, otherRecord.sortOrder, otherRecord.isUnique);
|
AddNode_Internal(otherRecord.system, otherRecord.layerName, otherRecord.sortOrder, otherRecord.isUnique);
|
||||||
@ -351,7 +351,7 @@ namespace DCFApixels.DragonECS
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IEcsProcess[] allSystems = new IEcsProcess[allSystemsLength];
|
IEcsProcess[] allSystems = new IEcsProcess[allSystemsLength];
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -182,7 +182,11 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
if (worldID < 0 || (worldID == NULL_WORLD_ID && nullWorld == false))
|
if (worldID < 0 || (worldID == NULL_WORLD_ID && nullWorld == false))
|
||||||
{
|
{
|
||||||
worldID = (short)_worldIdDispenser.UseFree();
|
int newID = _worldIdDispenser.UseFree();
|
||||||
|
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||||
|
if (newID > short.MaxValue) { Throw.DeepDebugException(); }
|
||||||
|
#endif
|
||||||
|
worldID = (short)newID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -201,12 +205,12 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
_poolsMediator = new PoolsMediator(this);
|
_poolsMediator = new PoolsMediator(this);
|
||||||
|
|
||||||
int poolsCapacity = ArrayUtility.NextPow2(config.PoolsCapacity);
|
int poolsCapacity = ArrayUtility.CeilPow2Safe(config.PoolsCapacity);
|
||||||
_pools = new IEcsPoolImplementation[poolsCapacity];
|
_pools = new IEcsPoolImplementation[poolsCapacity];
|
||||||
_poolSlots = new PoolSlot[poolsCapacity];
|
_poolSlots = new PoolSlot[poolsCapacity];
|
||||||
ArrayUtility.Fill(_pools, _nullPool);
|
ArrayUtility.Fill(_pools, _nullPool);
|
||||||
|
|
||||||
int entitiesCapacity = ArrayUtility.NextPow2(config.EntitiesCapacity);
|
int entitiesCapacity = ArrayUtility.CeilPow2Safe(config.EntitiesCapacity);
|
||||||
_entityDispenser = new IdDispenser(entitiesCapacity, 0, OnEntityDispenserResized);
|
_entityDispenser = new IdDispenser(entitiesCapacity, 0, OnEntityDispenserResized);
|
||||||
|
|
||||||
_executorCoures = new Dictionary<(Type, object), IQueryExecutorImplementation>(config.PoolComponentsCapacity);
|
_executorCoures = new Dictionary<(Type, object), IQueryExecutorImplementation>(config.PoolComponentsCapacity);
|
||||||
@ -566,12 +570,12 @@ namespace DCFApixels.DragonECS
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool deepDebug = IsMatchesMaskDeepDebug(mask, entityID);
|
bool deepDebug = IsMatchesMaskDeepDebug(mask, entityID);
|
||||||
|
@ -202,7 +202,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
if (_items.Length <= itemIndex)
|
if (_items.Length <= itemIndex)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _items, _items.Length << 1);
|
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -234,15 +234,21 @@ namespace DCFApixels.DragonECS
|
|||||||
Array.Resize(ref _mapping, _worlds.Length);
|
Array.Resize(ref _mapping, _worlds.Length);
|
||||||
}
|
}
|
||||||
ref short itemIndex = ref _mapping[worldID];
|
ref short itemIndex = ref _mapping[worldID];
|
||||||
|
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||||
|
if (itemIndex >= _worlds.Length)
|
||||||
|
{
|
||||||
|
Throw.UndefinedException();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (itemIndex != 0)
|
if (itemIndex != 0)
|
||||||
{
|
{
|
||||||
_interface.OnDestroy(ref _items[itemIndex], _worlds[worldID]);
|
_interface.OnDestroy(ref _items[itemIndex], _worlds[worldID]);
|
||||||
if (_recycledItemsCount >= _recycledItems.Length)
|
if (_recycledItemsCount >= _recycledItems.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
Array.Resize(ref _recycledItems, ArrayUtility.NextPow2(_recycledItemsCount));
|
||||||
}
|
}
|
||||||
_items[itemIndex] = default;
|
|
||||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||||
|
_items[itemIndex] = default;
|
||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
var slots = _world._poolSlots;
|
var slots = _world._poolSlots;
|
||||||
for (int i = 1; i < _count; i++)
|
for (int i = 1; i < _count; i++)
|
||||||
{
|
{
|
||||||
if(_versions[i] == slots[_componentIDs[i]].version)
|
if (_versions[i] == slots[_componentIDs[i]].version)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private readonly Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
private readonly Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
||||||
private ReadOnlySpan<InjectionNodeBase> GetNodes(Type type)
|
private ReadOnlySpan<InjectionNodeBase> GetNodes(Type type)
|
||||||
{
|
{
|
||||||
if(_branches.TryGetValue(type, out InjectionBranch branch))
|
if (_branches.TryGetValue(type, out InjectionBranch branch))
|
||||||
{
|
{
|
||||||
return branch.Nodes;
|
return branch.Nodes;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private ReadOnlySpan<object> EndReadHistory_Internal(int startIndex)
|
private ReadOnlySpan<object> EndReadHistory_Internal(int startIndex)
|
||||||
{
|
{
|
||||||
_injectionTempHistoryReadersCount--;
|
_injectionTempHistoryReadersCount--;
|
||||||
if(_injectionTempHistoryReadersCount < 0)
|
if (_injectionTempHistoryReadersCount < 0)
|
||||||
{
|
{
|
||||||
Throw.OpeningClosingMethodsBalanceError();
|
Throw.OpeningClosingMethodsBalanceError();
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public readonly struct InjectionHistorySpanReader
|
public readonly struct InjectionHistorySpanReader
|
||||||
{
|
{
|
||||||
private readonly Injector _injector;
|
private readonly Injector _injector;
|
||||||
private readonly int _startIndex;
|
private readonly int _startIndex;
|
||||||
|
@ -60,7 +60,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
{
|
{
|
||||||
if (_debugInfos.Length <= _idDispenser.Count)
|
if (_debugInfos.Length <= _idDispenser.Count)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _debugInfos, _debugInfos.Length << 1);
|
Array.Resize(ref _debugInfos, ArrayUtility.NextPow2(_idDispenser.Count));
|
||||||
}
|
}
|
||||||
id = _idDispenser.UseFree();
|
id = _idDispenser.UseFree();
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,19 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
array = result;
|
array = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int NextPow2Safe(int v, int min = 4)
|
||||||
|
{
|
||||||
|
return NextPow2(v < min ? min : v);
|
||||||
|
}
|
||||||
public static int NextPow2(int v)
|
public static int NextPow2(int v)
|
||||||
|
{
|
||||||
|
return CeilPow2(v | 1);
|
||||||
|
}
|
||||||
|
public static int CeilPow2Safe(int v, int min = 4)
|
||||||
|
{
|
||||||
|
return CeilPow2(v < min ? min : v);
|
||||||
|
}
|
||||||
|
public static int CeilPow2(int v)
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
@ -157,7 +169,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
return ++v;
|
return ++v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static int NextPow2_ClampOverflow(int v)
|
public static int CeilPow2_ClampOverflow(int v)
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
@ -166,7 +178,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
{
|
{
|
||||||
return int.MaxValue;
|
return int.MaxValue;
|
||||||
}
|
}
|
||||||
return NextPow2(v);
|
return CeilPow2(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,19 +217,18 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
Array.Resize(ref array, minSize);
|
Array.Resize(ref array, minSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void UpsizeToNextPow2<T>(ref T[] array, int minSize)
|
//public static void UpsizeToCeilPow2<T>(ref T[] array, int newSize, int minSize = 4)
|
||||||
{
|
//{
|
||||||
if (array == null)
|
// newSize = CeilPow2(newSize < minSize ? minSize : newSize);
|
||||||
{
|
// if (array == null)
|
||||||
minSize = NextPow2(minSize);
|
// {
|
||||||
array = new T[minSize];
|
// array = new T[newSize];
|
||||||
}
|
// }
|
||||||
else if (minSize > array.Length)
|
// else if (newSize > array.Length)
|
||||||
{
|
// {
|
||||||
minSize = NextPow2(minSize);
|
// Array.Resize(ref array, newSize);
|
||||||
Array.Resize(ref array, minSize);
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
internal readonly struct EnumerableInt : IEnumerable<int>
|
internal readonly struct EnumerableInt : IEnumerable<int>
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private void Upsize_Internal(int minSize)
|
private void Upsize_Internal(int minSize)
|
||||||
{
|
{
|
||||||
Resize(ArrayUtility.NextPow2_ClampOverflow(minSize));
|
Resize(ArrayUtility.CeilPow2_ClampOverflow(minSize));
|
||||||
}
|
}
|
||||||
private void Resize(int newSize)
|
private void Resize(int newSize)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value <= _items.Length) { return; }
|
if (value <= _items.Length) { return; }
|
||||||
value = ArrayUtility.NextPow2(value);
|
value = ArrayUtility.CeilPow2Safe(value);
|
||||||
Array.Resize(ref _items, value);
|
Array.Resize(ref _items, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public StructList(int capacity)
|
public StructList(int capacity)
|
||||||
{
|
{
|
||||||
_items = new T[ArrayUtility.NextPow2(capacity)];
|
_items = new T[ArrayUtility.CeilPow2Safe(capacity)];
|
||||||
_count = 0;
|
_count = 0;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -226,7 +226,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Recreate(int newSize)
|
public void Recreate(int newSize)
|
||||||
{
|
{
|
||||||
_items = new T[ArrayUtility.NextPow2(newSize)];
|
_items = new T[ArrayUtility.CeilPow2Safe(newSize)];
|
||||||
_count = 0;
|
_count = 0;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public EcsPool() { }
|
public EcsPool() { }
|
||||||
public EcsPool(int capacity, int recycledCapacity = -1)
|
public EcsPool(int capacity, int recycledCapacity = -1)
|
||||||
{
|
{
|
||||||
capacity = ArrayUtility.NextPow2(capacity);
|
capacity = ArrayUtility.CeilPow2Safe(capacity);
|
||||||
if (recycledCapacity < 0)
|
if (recycledCapacity < 0)
|
||||||
{
|
{
|
||||||
recycledCapacity = capacity / 2;
|
recycledCapacity = capacity / 2;
|
||||||
@ -113,7 +113,7 @@ namespace DCFApixels.DragonECS
|
|||||||
var worldConfig = world.Configs.GetWorldConfigOrDefault();
|
var worldConfig = world.Configs.GetWorldConfigOrDefault();
|
||||||
if (_items == null)
|
if (_items == null)
|
||||||
{
|
{
|
||||||
_items = new T[ArrayUtility.NextPow2(worldConfig.PoolComponentsCapacity)];
|
_items = new T[ArrayUtility.CeilPow2Safe(worldConfig.PoolComponentsCapacity)];
|
||||||
}
|
}
|
||||||
if (_recycledItems == null)
|
if (_recycledItems == null)
|
||||||
{
|
{
|
||||||
@ -128,8 +128,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (entityID == EcsConsts.NULL_ENTITY_ID) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||||
if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (_source.IsUsed(entityID) == false) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||||
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
#elif DRAGONECS_STABILITY_MODE
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS
|
|||||||
itemIndex = ++_itemsCount;
|
itemIndex = ++_itemsCount;
|
||||||
if (itemIndex >= _items.Length)
|
if (itemIndex >= _items.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _items, _items.Length << 1);
|
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
@ -179,7 +179,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public ref T TryAddOrGet(int entityID)
|
public ref T TryAddOrGet(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (entityID == EcsConsts.NULL_ENTITY_ID) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||||
#endif
|
#endif
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
@ -199,7 +199,7 @@ namespace DCFApixels.DragonECS
|
|||||||
itemIndex = ++_itemsCount;
|
itemIndex = ++_itemsCount;
|
||||||
if (itemIndex >= _items.Length)
|
if (itemIndex >= _items.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _items, _items.Length << 1);
|
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
@ -222,7 +222,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (entityID == EcsConsts.NULL_ENTITY_ID) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||||
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
#elif DRAGONECS_STABILITY_MODE
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
@ -232,7 +232,7 @@ namespace DCFApixels.DragonECS
|
|||||||
DisableComponent(ref _items[itemIndex]);
|
DisableComponent(ref _items[itemIndex]);
|
||||||
if (_recycledItemsCount >= _recycledItems.Length)
|
if (_recycledItemsCount >= _recycledItems.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
Array.Resize(ref _recycledItems, ArrayUtility.NextPow2Safe(_recycledItemsCount));
|
||||||
}
|
}
|
||||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
|
@ -45,6 +45,11 @@ namespace DCFApixels.DragonECS.PoolsCore
|
|||||||
throw new ArgumentException($"Entity({entityID}) has no component {EcsDebugUtility.GetGenericTypeName<T>()}.");
|
throw new ArgumentException($"Entity({entityID}) has no component {EcsDebugUtility.GetGenericTypeName<T>()}.");
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
public static void ThrowEntityIsNotAlive(EcsWorld world, int entityID)
|
||||||
|
{
|
||||||
|
Throw.Ent_ThrowIsNotAlive((world, entityID));
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowAlreadyHasComponent(Type type, int entityID)
|
public static void ThrowAlreadyHasComponent(Type type, int entityID)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"Entity({entityID}) already has component {EcsDebugUtility.GetGenericTypeName(type)}.");
|
throw new ArgumentException($"Entity({entityID}) already has component {EcsDebugUtility.GetGenericTypeName(type)}.");
|
||||||
@ -316,7 +321,7 @@ namespace DCFApixels.DragonECS
|
|||||||
self.InvokeOnGet(entityID, self.Count);
|
self.InvokeOnGet(entityID, self.Count);
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal static void InvokeOnGet(this List<IEcsPoolEventListener> self, int entityID, int cachedCount)
|
public static void InvokeOnGet(this List<IEcsPoolEventListener> self, int entityID, int cachedCount)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < cachedCount; i++) { self[i].OnGet(entityID); }
|
for (int i = 1; i < cachedCount; i++) { self[i].OnGet(entityID); }
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public void Add(int entityID)
|
public void Add(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (_source.IsUsed(entityID) == false) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||||
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
#elif DRAGONECS_STABILITY_MODE
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
Loading…
Reference in New Issue
Block a user