fix GetComponents debug method

This commit is contained in:
Mikhail 2024-03-03 05:42:01 +08:00
parent b910c9d0e2
commit c05cd91c4e

View File

@ -628,15 +628,12 @@ namespace DCFApixels.DragonECS
{ {
list.Clear(); list.Clear();
var itemsCount = GetComponentsCount(entityID); var itemsCount = GetComponentsCount(entityID);
if (itemsCount <= 0) if (itemsCount <= 0) { return; }
{ int poolIndex = 0;
return;
}
int poolIndex = entityID;
uint bit; uint bit;
for (int chunkIndex = 0; chunkIndex < _entityComponentMaskLength; chunkIndex++) for (int chunkIndex = entityID * _entityComponentMaskLength, chunkIndexMax = chunkIndex + _entityComponentMaskLength; chunkIndex < chunkIndexMax; chunkIndex++)
{ {
bit = 0x8000_0000; bit = 0x0000_0001;
int chunk = _entityComponentMasks[chunkIndex]; int chunk = _entityComponentMasks[chunkIndex];
if (chunk == 0) if (chunk == 0)
{ {
@ -650,12 +647,9 @@ namespace DCFApixels.DragonECS
{ {
itemsCount--; itemsCount--;
list.Add(_pools[poolIndex].GetRaw(entityID)); list.Add(_pools[poolIndex].GetRaw(entityID));
if (itemsCount <= 0) if (itemsCount <= 0) { goto exit; }
{
goto exit;
}
} }
bit >>= 1; bit <<= 1;
poolIndex++; poolIndex++;
} }
} }
@ -666,15 +660,12 @@ namespace DCFApixels.DragonECS
{ {
typeSet.Clear(); typeSet.Clear();
var itemsCount = GetComponentsCount(entityID); var itemsCount = GetComponentsCount(entityID);
if(itemsCount <= 0) if(itemsCount <= 0) { return; }
{ int poolIndex = 0;
return;
}
int poolIndex = entityID;
uint bit; uint bit;
for (int chunkIndex = 0; chunkIndex < _entityComponentMaskLength; chunkIndex++) for (int chunkIndex = entityID * _entityComponentMaskLength, chunkIndexMax = chunkIndex + _entityComponentMaskLength; chunkIndex < chunkIndexMax; chunkIndex++)
{ {
bit = 0x8000_0000; bit = 0x0000_0001;
int chunk = _entityComponentMasks[chunkIndex]; int chunk = _entityComponentMasks[chunkIndex];
if (chunk == 0) if (chunk == 0)
{ {
@ -688,12 +679,9 @@ namespace DCFApixels.DragonECS
{ {
itemsCount--; itemsCount--;
typeSet.Add(_pools[poolIndex].ComponentType); typeSet.Add(_pools[poolIndex].ComponentType);
if (itemsCount <= 0) if (itemsCount <= 0) { goto exit; }
{
goto exit;
}
} }
bit >>= 1; bit <<= 1;
poolIndex++; poolIndex++;
} }
} }