Utility class for the EntityManager.
More...
#include <component_collection.h>
|
|
using | ChangeCallback = std::function< void(EntityId, Component &)> |
| | Callback for when a component has been added or removed.
|
| |
Utility class for the EntityManager.
A component collection handles components of one specific type. It offers functions to retrieve the component (if any) of a specific entity and callbacks for when a component has been added or removed (mainly used by the EntityFilter).
Component collections are pretty much read-only for anything but the EntityManager. Use the manager to actually add or remove components.
| bool ComponentCollection::empty |
( |
| ) |
const |
Checks whether this collection is empty.
- Returns
true if the collection is empty, false otherwise
| Component * ComponentCollection::get |
( |
EntityId |
entityId | ) |
const |
Retrieves a component from the collection.
- Parameters
-
| entityId | The entity the component belongs to |
- Returns
- A non-owning pointer to the component or
nullptr if no such component exists
| Component * ComponentCollection::operator[] |
( |
EntityId |
entityId | ) |
const |
Registers callbacks for when components are added or removed.
- Parameters
-
| onComponentAdded | Called when a component has been added |
| onComponentRemoved | Called when a component has been removed |
- Returns
- An identifier with which you can remove the callbacks.
- See also
- unregisterChangeCallbacks
| void ComponentCollection::unregisterChangeCallbacks |
( |
unsigned int |
id | ) |
|
Unregisters change callbacks.
If the id could not be found, does nothing.
- Parameters
-
| id | The id returned by registerChangeCallbacks |
The documentation for this class was generated from the following files:
- /home/hhyyrylainen/Projects/thrive_install/thrive/src/engine/component_collection.h
- /home/hhyyrylainen/Projects/thrive_install/thrive/src/engine/component_collection.cpp