Provides access to Entities.
EntityManager(size_t threads = 0);An EntityManager can be constructed with a number of threads, which will be used for its ThreadPool.
template<typename Func> // Func: void(Entity &);
Entity createEntity(Func && postCreate);Creates a new Entity, calls postCreate on it, and registers it to the existing Systems.
template<typename Func> // Func: void(Entity &)
Entity operator+=(Func && postCreate);Equivalent to createEntity. Allows for syntax such as:
em += [](Entity & e) {
e += TransformComponent{};
};void removeEntity(Entity e);
void removeEntity(Entity::ID id);Entity getEntity(Entity::ID id);auto getEntities();Returns an iteratable collection over all Entities.
template<typename ...Comps>
auto getEntities<Comps...>();Returns an iteratable collection over all Entities which have each component listed in Comps.
Dereferencing the iterator returns an std::tuple<Entity, Comps &...>, which means you can write the following:
for (const auto & [e, transform, lua] : em.getEntities<TransformComponent, LuaComponent>()) {
std::cout << "Pitch: " << transform.pitch << '\n';
// do stuff
}template<typename T>
struct no;Can be used as a template parameter for getEntities<Comps...> to filter out Entities which have a specific Component:
for (const auto & [e, transform, noSelected] : em.getEntities<TransformComponent, no<SelectedComponent>>) {
// Entities with a SelectedComponent will be filtered out
std::cout << e.id << " has a TransformComponent but no SelectedComponent" << '\n';
}