xyginext  0.2.0
Second generation of xygine game creation framework
Public Types | Public Member Functions | Friends | List of all members
xy::Entity Class Referencefinal

Entity class Entity objects are handles to the underlying collection of components, and as such should be treated similarly to a pointer. That is, they are lightweight enough to copy around, but you should remain aware of the lifetime of the entity being handled, using Entity::isValid() or Entity::destroyed() More...

#include <Entity.hpp>

Public Types

using ID = sf::Uint32
 
using Generation = sf::Uint8
 

Public Member Functions

ID getIndex () const
 
Generation getGeneration () const
 Returns the generation of this entity.
 
bool destroyed () const
 Returns true if the entity is marked for destruction.
 
template<typename T >
void addComponent (const T &)
 Adds a copy of the given instance of a component to the entity.
 
template<typename T , typename... Args>
T & addComponent (Args &&...)
 
template<typename T >
bool hasComponent () const
 returns true if the component type exists on thie entity
 
template<typename T >
T & getComponent ()
 Returns a reference to the component if it exists.
 
template<typename T >
const T & getComponent () const
 
const ComponentMask & getComponentMask () const
 Returns a reference to the CompnentMask associated with this entity.
 
bool isValid () const
 Returns true if this entity has a valid scene associated with it ie it was created by Scene::createEntity()
 
void setLabel (const std::string &)
 Sets the label of this entity, useful for debugging.
 
const std::string & getLabel () const
 Returns the label assigned to t his entity. May be empty.
 
bool operator== (Entity r)
 
bool operator!= (Entity r)
 
bool operator< (Entity r)
 
bool operator<= (Entity r)
 
bool operator> (Entity r)
 
bool operator>= (Entity r)
 
template<typename T >
void addComponent (const T &component)
 
template<typename T , typename... Args>
T & addComponent (Args &&... args)
 
template<typename T >
bool hasComponent () const
 
template<typename T >
T & getComponent ()
 
template<typename T >
const T & getComponent () const
 

Friends

class EntityManager
 
bool operator< (const Entity &l, const Entity &r)
 
bool operator== (const Entity &l, const Entity &r)
 

Detailed Description

Entity class Entity objects are handles to the underlying collection of components, and as such should be treated similarly to a pointer. That is, they are lightweight enough to copy around, but you should remain aware of the lifetime of the entity being handled, using Entity::isValid() or Entity::destroyed()