|
ProtoZed
awesome branch
A simple but powerful game framework
|
Manager for entities, components and the relationship between them. More...
Public Member Functions | |
| EntityManager (Application &application) | |
| ~EntityManager () | |
| bool | CreateEntity (const EntityID &id) |
| Creates an entity. | |
| bool | CreateEntity (const EntityID &id, MetaEntity &entity) |
| Creates an entity. | |
| bool | CreateFromArchetype (const std::string &name, const EntityID &id) |
| Creates an entity from an archetype. | |
| bool | CreateFromArchetype (const std::string &name, const EntityID &id, MetaEntity &entity) |
| Creates an entity from an archetype. | |
| bool | DestroyEntity (const EntityID &id) |
| Flags the entity for destruction. | |
| void | DestroyPendingEntities () |
| Destroys flagged entities. | |
| bool | HasEntity (const EntityID &id) const |
| Query if the entity 'id' exists. | |
| MetaEntity | GetEntity (const EntityID &id) const |
| Gets an entity. | |
| void | ClearEntities () |
| Clears all entities. | |
| void | GetAllEntities (EntityList &list) const |
| Gets a list of every entity. | |
| EntityList::size_type | GetEntityCount () const |
| Gets the number of entities. | |
| bool | RegisterArchetype (Archetype *archetype) |
| Registers an archetype. | |
| bool | UnregisterArchetype (const std::string &name) |
| Unregisters the archetype described by name. | |
| void | UnregisterAllArchetypes () |
| Unregisters all archetypes. | |
| template<class T > | |
| bool | RegisterComponent () |
| Registers a component. | |
| template<class T > | |
| bool | UnregisterComponent () |
| Unregisters a component. | |
| void | GetAllRegisteredComponents (std::vector< HashString > &list) const |
| Gets all registered components. | |
| template<class T > | |
| T * | AddComponent (const EntityID &id) |
| Adds a component to 'id'. | |
| Component * | AddComponent (const EntityID &id, const HashString &family) |
| Adds a component to 'id'. | |
| template<class T > | |
| bool | RemoveComponent (const EntityID &id) |
| Removes the component. | |
| bool | RemoveComponent (const EntityID &id, const HashString &family) |
| Removes the component. | |
| template<class T > | |
| bool | HasComponent (const EntityID &id) const |
| Query if 'id' has a component. | |
| bool | HasComponent (const EntityID &id, const HashString &family) const |
| Query if 'id' has a component. | |
| template<class T > | |
| T * | GetComponent (const EntityID &id) const |
| Gets a component. | |
| Component * | GetComponent (const EntityID &id, const HashString &family) const |
| Gets a component. | |
| void | GetAllComponents (const EntityID &id, ComponentList &list) const |
| Gets all components for an entity. | |
| template<class T > | |
| const EntityComponentMap & | GetEntitiesWith () const |
| Gets the entities with a certain component. | |
| const EntityComponentMap & | GetEntitiesWith (const HashString &family) const |
| Gets all components for an entity. | |
| void | UpdateAll (float deltaTime) |
| Updates all components. | |
Public Member Functions inherited from PZ::EventHandler | |
| EventHandler () | |
| virtual | ~EventHandler () |
| bool | SubscribeTo (EventHandler &handler) |
| bool | UnsubscribeTo (EventHandler &handler) |
| template<class T , class EventT > | |
| bool | RegisterEvent (T *obj, void(T::*memFn)(EventT &)) |
| template<class T , class EventT > | |
| bool | UnregisterEvent (T *obj, void(T::*memFn)(EventT &)) |
| void | HandleEvent (const Event &e) |
| void | EmitEvent (const Event &e) const |
Additional Inherited Members | |
Protected Member Functions inherited from PZ::NonCopyable | |
| NonCopyable () | |
Manager for entities, components and the relationship between them.
| PZ::EntityManager::EntityManager | ( | Application & | application | ) |
| PZ::EntityManager::~EntityManager | ( | ) |
|
inline |
Adds a component to 'id'.
| id | The identifier. |
|
inline |
Adds a component to 'id'.
| id | The identifier. |
| family | The family of the component. |
| void PZ::EntityManager::ClearEntities | ( | ) |
Clears all entities.
| bool PZ::EntityManager::CreateEntity | ( | const EntityID & | id | ) |
Creates an entity.
| id | The identifier. |
| bool PZ::EntityManager::CreateEntity | ( | const EntityID & | id, |
| MetaEntity & | entity | ||
| ) |
Creates an entity.
| id | The identifier. | |
| [out] | entity | The created entity (will be unchanged if it fails). |
| bool PZ::EntityManager::CreateFromArchetype | ( | const std::string & | name, |
| const EntityID & | id | ||
| ) |
Creates an entity from an archetype.
| name | The name of the archetype. |
| id | The identifier. |
| bool PZ::EntityManager::CreateFromArchetype | ( | const std::string & | name, |
| const EntityID & | id, | ||
| MetaEntity & | entity | ||
| ) |
Creates an entity from an archetype.
| name | The name of the archetype. | |
| id | The identifier. | |
| [out] | entity | The created entity (will be unchanged if it fails). |
| bool PZ::EntityManager::DestroyEntity | ( | const EntityID & | id | ) |
Flags the entity for destruction.
| id | The identifier. |
| void PZ::EntityManager::DestroyPendingEntities | ( | ) |
Destroys flagged entities.
| void PZ::EntityManager::GetAllComponents | ( | const EntityID & | id, |
| ComponentList & | list | ||
| ) | const |
Gets all components for an entity.
| id | The identifier. | |
| [in,out] | list | The list. |
| void PZ::EntityManager::GetAllEntities | ( | EntityList & | list | ) | const |
Gets a list of every entity.
| void PZ::EntityManager::GetAllRegisteredComponents | ( | std::vector< HashString > & | list | ) | const |
Gets all registered components.
| [in,out] | list | The list. |
|
inline |
Gets a component.
| id | The identifier. |
|
inline |
Gets a component.
| id | The identifier. |
| family | The family of the component. |
|
inline |
Gets the entities with a certain component.
|
inline |
Gets all components for an entity.
| family | The family of the component. |
| MetaEntity PZ::EntityManager::GetEntity | ( | const EntityID & | id | ) | const |
Gets an entity.
| id | The identifier. |
| EntityList::size_type PZ::EntityManager::GetEntityCount | ( | ) | const |
Gets the number of entities.
|
inline |
Query if 'id' has a component.
| id | The identifier. |
|
inline |
Query if 'id' has a component.
| id | The identifier. |
| family | The family of the component. |
| bool PZ::EntityManager::HasEntity | ( | const EntityID & | id | ) | const |
Query if the entity 'id' exists.
| id | The identifier. |
| bool PZ::EntityManager::RegisterArchetype | ( | Archetype * | archetype | ) |
Registers an archetype.
EntityManager takes ownership of the Archetype instance.
| [in] | archetype | The archetype. |
|
inline |
Registers a component.
|
inline |
Removes the component.
| id | The identifier. |
|
inline |
Removes the component.
| id | The identifier. |
| family | The family of the component. |
| void PZ::EntityManager::UnregisterAllArchetypes | ( | ) |
Unregisters all archetypes.
| bool PZ::EntityManager::UnregisterArchetype | ( | const std::string & | name | ) |
Unregisters the archetype described by name.
| name | The name. |
|
inline |
Unregisters a component.
| void PZ::EntityManager::UpdateAll | ( | float | deltaTime | ) |
Updates all components.
| deltaTime | Time since last frame. |
1.8.2