Simple C++ Game
Public Member Functions | List of all members
ComponentFamily Class Reference

An EntityFamily that defines a class as having a component of each of the specified types. More...

#include <ComponentFamily.hpp>

Inheritance diagram for ComponentFamily:
Inheritance graph
[legend]
Collaboration diagram for ComponentFamily:
Collaboration graph
[legend]

Public Member Functions

 ComponentFamily ()
 Construct a default new Component Family object. More...
 
 ComponentFamily (const std::unordered_set< std::string > componentIds)
 Construct a new Component Family object. More...
 
bool isInFamily (const Entity &entity) const
 Checks if the entity has all of the required componets to fit the family. More...
 

Detailed Description

An EntityFamily that defines a class as having a component of each of the specified types.

Constructor & Destructor Documentation

◆ ComponentFamily() [1/2]

ComponentFamily::ComponentFamily ( )

Construct a default new Component Family object.

The default constructor doesn't require any specific families, so all entities will be considered 'in the family'.

◆ ComponentFamily() [2/2]

ComponentFamily::ComponentFamily ( const std::unordered_set< std::string >  componentIds)

Construct a new Component Family object.

Constructs a ComponentFamily that accepts all entities that have a component for each of the provided IDs.

Parameters
componentIdsThe IDs of the required component classes. These are idiomatically implemented as const static std::string members of the Component's class.

Member Function Documentation

◆ isInFamily()

bool ComponentFamily::isInFamily ( const Entity entity) const
virtual

Checks if the entity has all of the required componets to fit the family.

Parameters
entityThe entity to evaluate if it is has all the components to be in the family.
Returns
true if the entity is in the family.
false if the entity is not in the family.

Implements EntityFamily.


The documentation for this class was generated from the following file: