39 std::vector<uint32_t> _generations;
40 std::queue<uint32_t> _freeIndices;
45 EntityManager() =
default;
79 uint32_t
get_alive_count()
const {
return static_cast<uint32_t
>(_generations.size() - _freeIndices.size()); };
Defines the Entity alias and the free functions used to pack and unpack it.
uint32_t Entity
A packed identifier: 20 bits of index, 12 bits of generation.
Definition Entity.hpp:20
bool is_valid(Entity) const
Checks whether an Entity handle is still valid.
Definition EntityManager.cpp:67
void destroy(Entity)
Destroys an Entity, freeing its index for future reuse.
Definition EntityManager.cpp:43
uint32_t get_alive_count() const
Returns the number of currently-alive entities.
Definition EntityManager.hpp:79
Entity create()
Creates a new Entity, reusing a freed index when one is available.
Definition EntityManager.cpp:9