Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::ComponentGroup< Component > Class Template Reference

Effectively a list of tuples each entry containing an Entity and ComponentReference to each of the component type in the group. These Entity must have the specified components, or else there will be unexpected behaviour. When an Entity no longer has all the required components, it must be removed from the Group. More...

#include <componentGroup.h>

Inheritance diagram for Saga::ComponentGroup< Component >:
Collaboration diagram for Saga::ComponentGroup< Component >:

Public Member Functions

virtual ~ComponentGroup ()
 Destroy the Component Group object.
 
virtual void addEntity (std::shared_ptr< GameWorld > world, const Entity &entity) override
 Add an Entity to the Group. This entity must contain all the required components. If such an entity already exists in the group, do nothing.
 
virtual void removeEntity (Entity entity) override
 Remove an entity from the ComponentGroup.
 
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::iterator begin ()
 
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::iterator end ()
 
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::const_iterator begin () const
 
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::const_iterator end () const
 
- Public Member Functions inherited from Saga::IComponentGroup
virtual ~IComponentGroup ()=default
 Destroy the IComponentGroup object.
 
virtual void addEntity (std::shared_ptr< GameWorld > world, const Entity &entity)=0
 Handle adding an entity to a group. This entity must have all the components specified by the group.
 
virtual void removeEntity (Entity entity)=0
 Handle removing an entity from a group.
 

Detailed Description

template<typename... Component>
class Saga::ComponentGroup< Component >

Effectively a list of tuples each entry containing an Entity and ComponentReference to each of the component type in the group. These Entity must have the specified components, or else there will be unexpected behaviour. When an Entity no longer has all the required components, it must be removed from the Group.

Template Parameters
Componenta list of components all entities in the Group shares. This list must be in alphabetical order.

Constructor & Destructor Documentation

◆ ~ComponentGroup()

template<typename... Component>
virtual Saga::ComponentGroup< Component >::~ComponentGroup ( )
inlinevirtual

Destroy the Component Group object.

Member Function Documentation

◆ addEntity()

template<typename... Component>
void Saga::ComponentGroup< Component >::addEntity ( std::shared_ptr< GameWorld world,
const Entity &  entity 
)
overridevirtual

Add an Entity to the Group. This entity must contain all the required components. If such an entity already exists in the group, do nothing.

Parameters
world
entity

Implements Saga::IComponentGroup.

◆ begin() [1/2]

template<typename... Component>
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::iterator Saga::ComponentGroup< Component >::begin

◆ begin() [2/2]

template<typename... Component>
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::const_iterator Saga::ComponentGroup< Component >::begin

◆ end() [1/2]

template<typename... Component>
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::iterator Saga::ComponentGroup< Component >::end

◆ end() [2/2]

template<typename... Component>
std::vector< std::tuple< Entity, ComponentReference< Component >... > >::const_iterator Saga::ComponentGroup< Component >::end

◆ removeEntity()

template<typename... Component>
void Saga::ComponentGroup< Component >::removeEntity ( Entity  entity)
overridevirtual

Remove an entity from the ComponentGroup.

Parameters
entity

Implements Saga::IComponentGroup.


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