libes  0.5.3
an Entity System library for C++
Public Member Functions | List of all members
es::LocalSystem Class Reference

A local system. More...

#include <es/LocalSystem.h>

Inheritance diagram for es::LocalSystem:
Inheritance graph
[legend]

Public Member Functions

 LocalSystem (int priority, std::set< ComponentType > needed, Manager *manager, int width, int height)
 Create a local system. More...
 
virtual void update (float delta)
 Update all the entities in the current time step. More...
 
virtual void updateEntity (float delta, Entity e)
 Update an entity in the current time step. More...
 
void reset (int width, int height)
 Reset the grid dimensions. More...
 
void setFocus (int x, int y)
 Set the focus for local systems. More...
 
bool addLocalEntity (Entity e, int x, int y)
 Add an entity in the (x,y) cell of the grid. More...
 
bool removeLocalEntity (Entity e, int x, int y)
 Remove an entity from the (x,y) cell of the grid. More...
 
- Public Member Functions inherited from es::System
 System (int priority, std::set< ComponentType > needed, Manager *manager)
 A system constructor. More...
 
virtual ~System ()
 
int getPriority () const
 Get the priority of the system. More...
 
std::set< ComponentTypegetNeededComponents () const
 Get the needed component types. More...
 
ManagergetManager ()
 Get the manager. More...
 
virtual bool addEntity (Entity e)=0
 Add an entity in the system. More...
 
virtual bool removeEntity (Entity e)=0
 Removes an entity from the system. More...
 
virtual void init ()
 Initialize the system. More...
 
virtual void preUpdate (float delta)
 Do something before the individual update of each entity. More...
 
virtual void postUpdate (float delta)
 Do something after the individual update of each entity. More...
 

Detailed Description

A local system.

A local system handles the entities in a rectangular grid and updates the entities that are in the focused cell.

Constructor & Destructor Documentation

es::LocalSystem::LocalSystem ( int  priority,
std::set< ComponentType needed,
Manager manager,
int  width,
int  height 
)
inline

Create a local system.

Parameters
prioritythe priority of the system (small priority will be executed first)
neededthe set of needed component types that an entity must have to be handled properly by this system
managerthe manager (that is saved in the system so that the system can easily access the manager)
widththe width of the grid
heightthe height of the grid

Member Function Documentation

bool es::LocalSystem::addLocalEntity ( Entity  e,
int  x,
int  y 
)

Add an entity in the (x,y) cell of the grid.

Parameters
ethe entity
xthe x coordinate
ythe y coordinate
Returns
true if the entity was added
bool es::LocalSystem::removeLocalEntity ( Entity  e,
int  x,
int  y 
)

Remove an entity from the (x,y) cell of the grid.

Parameters
ethe entity
xthe x coordinate
ythe y coordinate
Returns
true if the entity was added
void es::LocalSystem::reset ( int  width,
int  height 
)

Reset the grid dimensions.

Parameters
widththe width of the grid
heightthe height of the grid
void es::LocalSystem::setFocus ( int  x,
int  y 
)
inline

Set the focus for local systems.

Parameters
xthe x-coordinate of the focus
ythe y-coordinate of the focus
virtual void es::LocalSystem::update ( float  delta)
virtual

Update all the entities in the current time step.

Parameters
deltathe time (in second) since the last update

Reimplemented from es::System.

virtual void es::LocalSystem::updateEntity ( float  delta,
Entity  e 
)
virtual

Update an entity in the current time step.

This function is called by update. By default, do nothing.

Parameters
deltathe time (in second) since the last update
ethe entity