add EntitesMatrix

This commit is contained in:
Mikhail 2024-11-08 17:20:05 +08:00
parent 2d64b3088a
commit ed698fbbd8

View File

@ -45,4 +45,42 @@ namespace DCFApixels.DragonECS.UncheckedCore
return true;
}
}
public readonly struct EntitesMatrix
{
private readonly EcsWorld _world;
public EntitesMatrix(EcsWorld world)
{
_world = world;
}
public int PoolsCount
{
get { return _world.PoolsCount; }
}
public int EntitesCount
{
get { return _world.Capacity; }
}
public int GetEntityComponentsCount(int entityID)
{
return _world.GetComponentsCount(entityID);
}
public int GetEntityGen(int entityID)
{
return _world.GetGen(entityID);
}
public bool IsEntityUsed(int entityID)
{
return _world.IsUsed(entityID);
}
public bool this[int entityID, int poolID]
{
get
{
int entityStartChunkIndex = entityID << _world._entityComponentMaskLengthBitShift;
var chunkInfo = EcsMaskChunck.FromID(poolID);
return (_world._entityComponentMasks[entityStartChunkIndex + chunkInfo.chunkIndex] & chunkInfo.mask) != 0;
}
}
}
}