diff --git a/include/UECS/EntityMngr.hpp b/include/UECS/EntityMngr.hpp index b0298c0..f965198 100644 --- a/include/UECS/EntityMngr.hpp +++ b/include/UECS/EntityMngr.hpp @@ -55,6 +55,9 @@ namespace Ubpa::UECS { std::vector Components(Entity, AccessMode) const; std::vector WriteComponents(Entity e) const { return Components(e, AccessMode::WRITE); } std::vector ReadComponents(Entity e) const { return Components(e, AccessMode::LATEST); } + + // chunk + index in chunk + std::tuple GetChunk(Entity e) const; bool Exist(Entity) const noexcept; diff --git a/src/core/EntityMngr.cpp b/src/core/EntityMngr.cpp index baf41fe..7f932ba 100644 --- a/src/core/EntityMngr.cpp +++ b/src/core/EntityMngr.cpp @@ -622,3 +622,9 @@ void EntityMngr::NewFrame() noexcept { for (auto& [ts, a] : ts2a) a->NewFrame(); } + +std::tuple EntityMngr::GetChunk(Entity e) const { + if(!Exist(e)) throw std::invalid_argument("Entity is invalid"); + const auto& info = entityTable[e.index]; + return { info.archetype->GetChunks()[info.chunkIdx],info.idxInChunk }; +}