mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
Update EcsPool.cs
This commit is contained in:
parent
85100b7d62
commit
2595c25db4
@ -95,6 +95,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 (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
if (_source.IsUsed(entityID) == false) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
||||||
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
@ -144,6 +145,9 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public ref T TryAddOrGet(int entityID)
|
public ref T TryAddOrGet(int entityID)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
if (entityID == EcsConsts.NULL_ENTITY_ID) { Throw.Ent_ThrowIsNotAlive(_source, entityID); }
|
||||||
|
#endif
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
{ //Add block
|
{ //Add block
|
||||||
@ -185,6 +189,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 (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
|
||||||
@ -237,9 +242,8 @@ namespace DCFApixels.DragonECS
|
|||||||
#elif DRAGONECS_STABILITY_MODE
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
if (_isLocked) { return; }
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_recycledItemsCount = 0; // спереди потому чтобы обнулялось, так как Del не обнуляет
|
_recycledItemsCount = 0; // ñïåðåäè ÷òîáû îáíóëÿëîñü, òàê êàê Del íå îáíóëÿåò
|
||||||
if (_itemsCount <= 0) { return; }
|
if (_itemsCount <= 0) { return; }
|
||||||
_itemsCount = 0;
|
|
||||||
var span = _source.Where(out SingleAspect<T> _);
|
var span = _source.Where(out SingleAspect<T> _);
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
{
|
{
|
||||||
@ -251,6 +255,8 @@ namespace DCFApixels.DragonECS
|
|||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
_itemsCount = 0;
|
||||||
|
_recycledItemsCount = 0;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user