|
Thrive
|
Filters for entities that contain specific components. More...
#include <entity_filter.h>
Classes | |
| struct | Implementation |
Public Types | |
| using | ComponentGroup = std::tuple< typename detail::ExtractComponentType< ComponentTypes >::PointerType... > |
| Typedef for the filter's component tuple. More... | |
| using | EntityMap = std::unordered_map< EntityId, ComponentGroup > |
| Typedef for the filter's list of relevant entities. | |
Public Member Functions | |
| EntityFilter (bool recordChanges=false) | |
| Constructor. More... | |
| ~EntityFilter () | |
| Destructor. | |
| EntityMap & | addedEntities () |
| Returns the entities added to this filter. More... | |
| EntityMap::const_iterator | begin () const |
| Iterator. More... | |
| void | clearChanges () |
| Clears the lists for added and removed entities. | |
| bool | containsEntity (EntityId id) const |
| Checks whether an entity id is contained in this filter. More... | |
| EntityMap::const_iterator | end () const |
| Iterator. More... | |
| const EntityMap & | entities () const |
| The relevant entities. More... | |
| std::unordered_set< EntityId > & | removedEntities () |
| Returns the entities removed from this filter. More... | |
| EntityManager * | entityManager () |
| Gets the current entiyManager. More... | |
| void | setEntityManager (EntityManager *entityManager) |
| Sets the entity manager this filter applies to. More... | |
Filters for entities that contain specific components.
An entity filter helps a system in finding the entities that have exactly the right components to be relevant for the system.
| ComponentTypes | The component classes to watch for. You can wrap a class with the Optional template if you want to know if it's there, but it's not required. |
Usage example:
| using thrive::EntityFilter< ComponentTypes >::ComponentGroup = std::tuple< typename detail::ExtractComponentType<ComponentTypes>::PointerType... > |
Typedef for the filter's component tuple.
All elements of the tuple are pointers. An optional component may be nullptr if not present.
| thrive::EntityFilter< ComponentTypes >::EntityFilter | ( | bool | recordChanges = false | ) |
Constructor.
| recordChanges | If true, you can query the added and removed entities through this filter. |
| EntityFilter< ComponentTypes... >::EntityMap & thrive::EntityFilter< ComponentTypes >::addedEntities | ( | ) |
Returns the entities added to this filter.
When you have processed the collection, please call clear() on it.
| EntityFilter< ComponentTypes... >::EntityMap::const_iterator thrive::EntityFilter< ComponentTypes >::begin | ( | ) | const |
| bool thrive::EntityFilter< ComponentTypes >::containsEntity | ( | EntityId | id | ) | const |
Checks whether an entity id is contained in this filter.
| id | The entity to check for |
true if this id can be found in this filter, false otherwise | EntityFilter< ComponentTypes... >::EntityMap::const_iterator thrive::EntityFilter< ComponentTypes >::end | ( | ) | const |
| const EntityFilter< ComponentTypes... >::EntityMap & thrive::EntityFilter< ComponentTypes >::entities | ( | ) | const |
The relevant entities.
The returned collection maps the entity id to the components required by this filter. Optional components may be nullptr.
| EntityManager * thrive::EntityFilter< ComponentTypes >::entityManager | ( | ) |
Gets the current entiyManager.
| std::unordered_set< EntityId > & thrive::EntityFilter< ComponentTypes >::removedEntities | ( | ) |
Returns the entities removed from this filter.
When you have processed the collection, please call clear() on it.
| void thrive::EntityFilter< ComponentTypes >::setEntityManager | ( | EntityManager * | entityManager | ) |
Sets the entity manager this filter applies to.
| entityManager | The new entity manager to listen to. If nullptr, the filter stays empty. |
1.8.10