Simple C++ Game
Public Member Functions | Protected Member Functions | List of all members
EntitySystem Class Referenceabstract

A class representing a system that processes groups of Entity in an EntityEngine. More...

#include <EntitySystem.hpp>

Inheritance diagram for EntitySystem:
Inheritance graph
[legend]

Public Member Functions

 EntitySystem ()
 Construct a new default EntitySystem. More...
 
 EntitySystem (const std::shared_ptr< EntityFamily > &family)
 Construct a new EntitySystem that acts on a specified family. More...
 
virtual void engineEntityAdded (const std::shared_ptr< Entity > &entity)
 Performs any operations required after an entity has been added to an EntityEngine the system is a part of. More...
 
virtual void update (const sf::Time deltaTime)=0
 Performs any operations necessary in routine processing. More...
 

Protected Member Functions

virtual std::map< int, std::shared_ptr< Entity > > getEntities () const
 Get the Entities in the system. More...
 

Detailed Description

A class representing a system that processes groups of Entity in an EntityEngine.

An abstract class to be extended by specific implementations.

Constructor & Destructor Documentation

◆ EntitySystem() [1/2]

EntitySystem::EntitySystem ( )

Construct a new default EntitySystem.

This creates an EntitySystem that processes all Entities added to the EntityEngine if EntitySystem::engineEngineEntityAdded is not overridden.

◆ EntitySystem() [2/2]

EntitySystem::EntitySystem ( const std::shared_ptr< EntityFamily > &  family)

Construct a new EntitySystem that acts on a specified family.

Parameters
familyThe family of entities that this system will act on. The EntitySystem implementation of EntitySystem::engineEntityAdded adds all entities to the system for which this family's implementation of EntityFamily::isInFamily returns true.

Member Function Documentation

◆ engineEntityAdded()

virtual void EntitySystem::engineEntityAdded ( const std::shared_ptr< Entity > &  entity)
virtual

Performs any operations required after an entity has been added to an EntityEngine the system is a part of.

The default implementation adds the Entity to the Entities property (EntitySystem::getEntities) if the default constructor was called or the Entity is in the family provided to the family constructor.

Parameters
entityThe Entity recently added to the EntityEngine.

◆ getEntities()

virtual std::map<int, std::shared_ptr<Entity> > EntitySystem::getEntities ( ) const
protectedvirtual

Get the Entities in the system.

Returns
std::map<int, std::shared_ptr<Entity>> A mapping of IDs to the entity that has those IDs for the entities that are part of this system.

◆ update()

virtual void EntitySystem::update ( const sf::Time  deltaTime)
pure virtual

Performs any operations necessary in routine processing.

This method is pure virtual in EntitySystem.

Parameters
deltaTimeThe time that has passed since update() was last called.

Implemented in IteratingSystem.


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