Atlas
A Convenient Entity Component System
 All Classes Namespaces Files Functions Variables Typedefs Friends
Atlas::EntityManager Class Reference

Manages all Entities and Components within the a World. More...

#include <EntityManager.h>

Inheritance diagram for Atlas::EntityManager:
Collaboration diagram for Atlas::EntityManager:

Public Member Functions

 EntityManager (World &world)
 Creates a new EntityManager. More...
 
void update ()
 Removes all entities that have been set to inactive. More...
 
EntitycreateEntity ()
 Creates an empty Entity. More...
 
EntitygetEntity (const Entity::ID &ID) const
 Retreives an active Entity. More...
 
void addComponent (Entity &entity, Component::Ptr component)
 Attaches a Component to an Entity. More...
 
void removeComponent (Entity &entity, const ComponentIdentifier &componentIdentifier)
 Removes a Component from an Entity. More...
 
template<typename T >
T * getComponentFor (const Entity &entity) const
 Retrieve a specific Component from an Entity. More...
 
template<typename T >
T * getComponentFor (const Entity::ID &ID) const
 Retrieve a specific Component from an Entity. More...
 
std::vector< Component * > getAllComponentsFor (const Entity &entity)
 Retrieves all the Components attached to an Entity. More...
 
void removeAllComponentsFor (Entity &entity)
 Removes and destroys all the Components attached to a Entity. More...
 
void toString ()
 Prints the contents of all active Entities and displays the number of inactive Entities. More...
 
- Public Member Functions inherited from Atlas::NonCopyable
 NonCopyable ()=default
 Default Constructor. More...
 
virtual ~NonCopyable ()
 

Detailed Description

Manages all Entities and Components within the a World.

Entities and Components will be directly or indirectly retrieved and added through the EntityManager.

Constructor & Destructor Documentation

Atlas::EntityManager::EntityManager ( World world)

Creates a new EntityManager.

Parameters
world- the World object that owns this EntityManager

Member Function Documentation

void Atlas::EntityManager::addComponent ( Entity entity,
Component::Ptr  component 
)

Attaches a Component to an Entity.

Usage Example:

entityManager.addComponent(entity, Atlas::Component::Ptr(new HealthComponent()));
Parameters
entity- The Entity to add the Component to
component- Component to add
Entity& Atlas::EntityManager::createEntity ( )

Creates an empty Entity.

Returns
Reference to the new Entity
std::vector<Component*> Atlas::EntityManager::getAllComponentsFor ( const Entity entity)

Retrieves all the Components attached to an Entity.

Parameters
entity- The targeted Entity
Returns
Vector of Component pointers from the Entity
template<typename T >
T* Atlas::EntityManager::getComponentFor ( const Entity entity) const
inline

Retrieve a specific Component from an Entity.

Parameters
entity- The targeted Entity
Returns
Pointer to the derived type Component

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
T* Atlas::EntityManager::getComponentFor ( const Entity::ID ID) const
inline

Retrieve a specific Component from an Entity.

Usage Example:

HealthComponent* health = entityManager.getComponentFor<HealthComponent>(ID);
health->hitpoints -= damage;
Parameters
ID- The targeted Entity's ID
Returns
Pointer to the derived type Component
Entity& Atlas::EntityManager::getEntity ( const Entity::ID ID) const

Retreives an active Entity.

Parameters
ID- The Entity's ID
Returns
Reference to the Entity
void Atlas::EntityManager::removeAllComponentsFor ( Entity entity)

Removes and destroys all the Components attached to a Entity.

Parameters
entity- The targeted Entity
void Atlas::EntityManager::removeComponent ( Entity entity,
const ComponentIdentifier componentIdentifier 
)

Removes a Component from an Entity.

Usage Example:

healthIdentifier = ComponentIdentifierManager::getType<HealthComponent>();
entityManager.removeComponent(entity, healthIdentifier);
Parameters
entity- The Entity to remove a Component from
componentIdentifier- Identifier for the Component

Here is the caller graph for this function:

void Atlas::EntityManager::toString ( )

Prints the contents of all active Entities and displays the number of inactive Entities.

void Atlas::EntityManager::update ( )

Removes all entities that have been set to inactive.


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