hx3d  1
2D/3D Simple Game Framework
Public Member Functions | List of all members
hx3d::ecs::Engine Class Reference

Manages entity in a world. More...

#include <engine.hpp>

Public Member Functions

Ptr< EntitycreateEntity ()
 Create a new entity with the last entity id available. More...
 
void registerEntity (const Ptr< Entity > &entity)
 Affect an ID to a uninitialized entity. More...
 
void removeEntity (const Ptr< Entity > &entity)
 Mark the entity for deletion from the engine. More...
 
template<class T >
Ptr< T > getComponent (const Ptr< Entity > &entity)
 Get the component for an entity. More...
 
template<class T >
void addComponent (const Ptr< Entity > &entity, const Ptr< Component > &component)
 Add a component for an entity. More...
 
template<class T , class... Args>
void createComponent (const Ptr< Entity > &entity, Args...args)
 Create a component for an entity with variable args. More...
 
template<class T >
void addSystem (const Ptr< System > &sys)
 Add a system to the engine. More...
 
template<class T , class... Args>
void createSystem (Args...args)
 Create a system into the engine. More...
 
unsigned int getComponentSize (const Ptr< Entity > &entity)
 Get the number of components for an entity. More...
 
unsigned int getEntityCount ()
 Get the number of entities. More...
 
unsigned int getBits (const Ptr< Entity > &entity)
 Get the bits corresponding to the entity components. More...
 
template<class T >
void registerComponentAdded (std::function< void(const Ptr< Component > &, const Ptr< Entity > &)> callback)
 Register a callback for a certain component type when it's added. More...
 
template<class T >
void registerComponentRemoved (std::function< void(const Ptr< Component > &, const Ptr< Entity > &)> callback)
 Register a callback for a certain component type when it's removed. More...
 
void update (const float delta)
 Update the engine. More...
 
void clear ()
 Remove everything from the engine.
 

Detailed Description

Manages entity in a world.

Definition at line 41 of file engine.hpp.

Member Function Documentation

template<class T >
void hx3d::ecs::Engine::addComponent ( const Ptr< Entity > &  entity,
const Ptr< Component > &  component 
)

Add a component for an entity.

Parameters
entityEntity (Ptr)
componentComponent (Ptr)

Definition at line 42 of file engine.inl.hpp.

template<class T >
void hx3d::ecs::Engine::addSystem ( const Ptr< System > &  sys)

Add a system to the engine.

Parameters
sysSystem (Ptr)

Definition at line 80 of file engine.inl.hpp.

template<class T , class... Args>
void hx3d::ecs::Engine::createComponent ( const Ptr< Entity > &  entity,
Args...  args 
)

Create a component for an entity with variable args.

Parameters
entityEntity (Ptr)
argsArguments

Definition at line 47 of file engine.inl.hpp.

Ptr< Entity > hx3d::ecs::Engine::createEntity ( )

Create a new entity with the last entity id available.

Returns
Entity (Ptr)

Definition at line 28 of file engine.cpp.

template<class T , class... Args>
void hx3d::ecs::Engine::createSystem ( Args...  args)

Create a system into the engine.

Parameters
argsArguments

Definition at line 88 of file engine.inl.hpp.

unsigned int hx3d::ecs::Engine::getBits ( const Ptr< Entity > &  entity)

Get the bits corresponding to the entity components.

Parameters
entityEntity (Ptr)
Returns
Entity components bits

Definition at line 67 of file engine.cpp.

template<class T >
Ptr< T > hx3d::ecs::Engine::getComponent ( const Ptr< Entity > &  entity)

Get the component for an entity.

Parameters
entityEntity (Ptr)
Returns
Component

Definition at line 25 of file engine.inl.hpp.

unsigned int hx3d::ecs::Engine::getComponentSize ( const Ptr< Entity > &  entity)

Get the number of components for an entity.

Parameters
entityEntity (Ptr)
Returns
Number of components

Definition at line 53 of file engine.cpp.

unsigned int hx3d::ecs::Engine::getEntityCount ( )

Get the number of entities.

Returns
Number of entities

Definition at line 63 of file engine.cpp.

template<class T >
void hx3d::ecs::Engine::registerComponentAdded ( std::function< void(const Ptr< Component > &, const Ptr< Entity > &)>  callback)

Register a callback for a certain component type when it's added.

Parameters
callbackCallback function

Definition at line 96 of file engine.inl.hpp.

template<class T >
void hx3d::ecs::Engine::registerComponentRemoved ( std::function< void(const Ptr< Component > &, const Ptr< Entity > &)>  callback)

Register a callback for a certain component type when it's removed.

Parameters
callbackCallback function

Definition at line 101 of file engine.inl.hpp.

void hx3d::ecs::Engine::registerEntity ( const Ptr< Entity > &  entity)

Affect an ID to a uninitialized entity.

Parameters
entityEntity (Ptr)

Definition at line 37 of file engine.cpp.

void hx3d::ecs::Engine::removeEntity ( const Ptr< Entity > &  entity)

Mark the entity for deletion from the engine.

The deletion is delayed until the next update.

Parameters
entityEntity (Ptr)

Definition at line 49 of file engine.cpp.

void hx3d::ecs::Engine::update ( const float  delta)

Update the engine.

Parameters
deltaDelta time

Definition at line 72 of file engine.cpp.


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