Bomberman
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
WAL::Scene Class Reference

Represent a single scene that contains entities. More...

#include <Scene.hpp>

Collaboration diagram for WAL::Scene:

Public Member Functions

int getID () const
 Get the ID of this scene. More...
 
std::list< Entity > & getEntities ()
 Get the list of entities. More...
 
EntityaddEntity (const std::string &name)
 Add a new entity to the scene. More...
 
EntityscheduleNewEntity (const std::string &name)
 Add a new entity to the scene, this entity will be added on the next call to applyChanges. More...
 
template<typename ... Components>
View< Components... > & view ()
 
void applyChanges ()
 Delete entities marked as deleted and create scheduled entities. More...
 
 Scene ()=default
 A default constructor. More...
 
 Scene (const Scene &)=delete
 A scene is not copy constructable. More...
 
 ~Scene ()=default
 A default destructor. More...
 
Sceneoperator= (const Scene &)
 A scene is assignable. More...
 

Public Attributes

friend Entity
 

Private Member Functions

void _componentAdded (Entity &entity, const std::type_index &type)
 Notify this scene that a component has been added to the given entity. More...
 
void _componentRemoved (const Entity &entity, const std::type_index &type)
 Notify this scene that a component has been removed to the given entity. More...
 
void _entityRemoved (const Entity &entity)
 Remove an entity from every views. More...
 

Private Attributes

int _id = _nextID++
 An ID representing this scene. More...
 
std::list< Entity_entities = {}
 The list of registered entities. More...
 
std::list< Entity_newEntities = {}
 The list of entities to add on the next call to applyChanges. More...
 
std::vector< std::shared_ptr< IView > > _views = {}
 The list of cached views to update. More...
 

Static Private Attributes

static int _nextID = 0
 

Detailed Description

Represent a single scene that contains entities.

Constructor & Destructor Documentation

◆ Scene() [1/2]

WAL::Scene::Scene ( )
default

A default constructor.

◆ Scene() [2/2]

WAL::Scene::Scene ( const Scene )
delete

A scene is not copy constructable.

◆ ~Scene()

WAL::Scene::~Scene ( )
default

A default destructor.

Member Function Documentation

◆ _componentAdded()

void WAL::Scene::_componentAdded ( Entity entity,
const std::type_index &  type 
)
private

Notify this scene that a component has been added to the given entity.

Parameters
entityThe entity with the new component
typeThe type of the component added.

◆ _componentRemoved()

void WAL::Scene::_componentRemoved ( const Entity entity,
const std::type_index &  type 
)
private

Notify this scene that a component has been removed to the given entity.

Parameters
entityThe entity with the removed component
typeThe type of the component removed.

◆ _entityRemoved()

void WAL::Scene::_entityRemoved ( const Entity entity)
private

Remove an entity from every views.

Parameters
entityThe entity to remove.

◆ addEntity()

Entity & WAL::Scene::addEntity ( const std::string &  name)

Add a new entity to the scene.

Parameters
nameThe name of the created entity.
Returns
The created entity is returned.

◆ applyChanges()

void WAL::Scene::applyChanges ( )

Delete entities marked as deleted and create scheduled entities.

◆ getEntities()

std::list< Entity > & WAL::Scene::getEntities ( )

Get the list of entities.

◆ getID()

int WAL::Scene::getID ( ) const

Get the ID of this scene.

◆ operator=()

Scene & WAL::Scene::operator= ( const Scene )

A scene is assignable.

◆ scheduleNewEntity()

Entity & WAL::Scene::scheduleNewEntity ( const std::string &  name)

Add a new entity to the scene, this entity will be added on the next call to applyChanges.

Parameters
nameThe name of the created entity.
Returns
The created entity is returned.

◆ view()

template<typename ... Components>
View<Components...>& WAL::Scene::view ( )
inline

Member Data Documentation

◆ _entities

std::list<Entity> WAL::Scene::_entities = {}
private

The list of registered entities.

◆ _id

int WAL::Scene::_id = _nextID++
private

An ID representing this scene.

◆ _newEntities

std::list<Entity> WAL::Scene::_newEntities = {}
private

The list of entities to add on the next call to applyChanges.

◆ _nextID

int WAL::Scene::_nextID = 0
staticprivate

◆ _views

std::vector<std::shared_ptr<IView> > WAL::Scene::_views = {}
private

The list of cached views to update.

◆ Entity

friend WAL::Scene::Entity

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