mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 09:24:37 +08:00
Squashed commit of the following:
commit 1914307cbab5ee9b69d71014505d4b371b14eb75 Author: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Tue Aug 26 14:50:20 2025 +0800 up version to 0.9.19 commit d15d4412f1a5a31aaf227e5893c1b3aaba35bf05 Author: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Tue Aug 26 14:47:55 2025 +0800 fix array growth commit7015bbcc1b
Author: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Sat Aug 23 22:48:39 2025 +0800 fix commit64fd11b072
Author: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Sat Aug 23 22:45:32 2025 +0800 fix
This commit is contained in:
parent
1605108e49
commit
2e1b22c129
@ -10,7 +10,7 @@
|
||||
<RootNamespace>DCFApixels.DragonECS</RootNamespace>
|
||||
|
||||
<Title>DragonECS</Title>
|
||||
<Version>0.9.18</Version>
|
||||
<Version>0.9.19</Version>
|
||||
<Authors>DCFApixels</Authors>
|
||||
<Description>ECS Framework for Game Engines with C# and .Net Platform</Description>
|
||||
<Copyright>DCFApixels</Copyright>
|
||||
|
@ -8,7 +8,7 @@
|
||||
"displayName": "DragonECS",
|
||||
"description": "C# Entity Component System Framework",
|
||||
"unity": "2020.3",
|
||||
"version": "0.9.18",
|
||||
"version": "0.9.19",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DCFApixels/DragonECS.git"
|
||||
|
@ -525,7 +525,7 @@ namespace DCFApixels.DragonECS.Core
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -182,7 +182,11 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
if (_items.Length <= itemIndex)
|
||||
{
|
||||
Array.Resize(ref _items, _items.Length << 1);
|
||||
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
@ -234,15 +234,21 @@ namespace DCFApixels.DragonECS
|
||||
Array.Resize(ref _mapping, _worlds.Length);
|
||||
}
|
||||
ref short itemIndex = ref _mapping[worldID];
|
||||
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||
if (itemIndex >= _worlds.Length)
|
||||
{
|
||||
Throw.UndefinedException();
|
||||
}
|
||||
#endif
|
||||
if (itemIndex != 0)
|
||||
{
|
||||
_interface.OnDestroy(ref _items[itemIndex], _worlds[worldID]);
|
||||
if (_recycledItemsCount >= _recycledItems.Length)
|
||||
{
|
||||
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
||||
Array.Resize(ref _recycledItems, ArrayUtility.NextPow2(_recycledItemsCount));
|
||||
}
|
||||
_items[itemIndex] = default;
|
||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||
_items[itemIndex] = default;
|
||||
itemIndex = 0;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
||||
{
|
||||
if (_debugInfos.Length <= _idDispenser.Count)
|
||||
{
|
||||
Array.Resize(ref _debugInfos, _debugInfos.Length << 1);
|
||||
Array.Resize(ref _debugInfos, ArrayUtility.NextPow2(_idDispenser.Count));
|
||||
}
|
||||
id = _idDispenser.UseFree();
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
ref int itemIndex = ref _mapping[entityID];
|
||||
#if DEBUG
|
||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
||||
if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||
if (_source.IsUsed(entityID) == false) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||
#elif DRAGONECS_STABILITY_MODE
|
||||
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS
|
||||
itemIndex = ++_itemsCount;
|
||||
if (itemIndex >= _items.Length)
|
||||
{
|
||||
Array.Resize(ref _items, _items.Length << 1);
|
||||
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||
}
|
||||
}
|
||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||
@ -179,7 +179,7 @@ namespace DCFApixels.DragonECS
|
||||
public ref T TryAddOrGet(int entityID)
|
||||
{
|
||||
#if DEBUG
|
||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
||||
if (entityID == EcsConsts.NULL_ENTITY_ID) { EcsPoolThrowHelper.ThrowEntityIsNotAlive(_source, entityID); }
|
||||
#endif
|
||||
ref int itemIndex = ref _mapping[entityID];
|
||||
if (itemIndex <= 0)
|
||||
@ -199,7 +199,7 @@ namespace DCFApixels.DragonECS
|
||||
itemIndex = ++_itemsCount;
|
||||
if (itemIndex >= _items.Length)
|
||||
{
|
||||
Array.Resize(ref _items, _items.Length << 1);
|
||||
Array.Resize(ref _items, ArrayUtility.NextPow2(itemIndex));
|
||||
}
|
||||
}
|
||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||
@ -222,7 +222,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
ref int itemIndex = ref _mapping[entityID];
|
||||
#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 (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||
#elif DRAGONECS_STABILITY_MODE
|
||||
@ -232,7 +232,7 @@ namespace DCFApixels.DragonECS
|
||||
DisableComponent(ref _items[itemIndex]);
|
||||
if (_recycledItemsCount >= _recycledItems.Length)
|
||||
{
|
||||
Array.Resize(ref _recycledItems, _recycledItems.Length << 1);
|
||||
Array.Resize(ref _recycledItems, ArrayUtility.NextPow2(_recycledItemsCount));
|
||||
}
|
||||
_recycledItems[_recycledItemsCount++] = itemIndex;
|
||||
itemIndex = 0;
|
||||
|
@ -45,6 +45,11 @@ namespace DCFApixels.DragonECS.PoolsCore
|
||||
throw new ArgumentException($"Entity({entityID}) has no component {EcsDebugUtility.GetGenericTypeName<T>()}.");
|
||||
}
|
||||
[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)
|
||||
{
|
||||
throw new ArgumentException($"Entity({entityID}) already has component {EcsDebugUtility.GetGenericTypeName(type)}.");
|
||||
@ -316,7 +321,7 @@ namespace DCFApixels.DragonECS
|
||||
self.InvokeOnGet(entityID, self.Count);
|
||||
}
|
||||
[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); }
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS
|
||||
public void Add(int entityID)
|
||||
{
|
||||
#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 (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||
#elif DRAGONECS_STABILITY_MODE
|
||||
|
Loading…
Reference in New Issue
Block a user