Bomberman
Public Member Functions | Private Attributes | List of all members
BBM::EventSystem Class Reference

#include <EventSystem.hpp>

Inheritance diagram for BBM::EventSystem:
Collaboration diagram for BBM::EventSystem:

Public Member Functions

void dispatchEvent (const std::function< void(WAL::Entity &)> &event)
 Inform the system that a new event has occurred and it should run the given method on every entities. More...
 
void dispatchEvent (const std::function< void(WAL::Wal &)> &event)
 Inform the system that a new event has occurred and it should run the given method on every entities. More...
 
void onUpdate (WAL::ViewEntity<> &entity, std::chrono::nanoseconds dtime) override
 
void onSelfUpdate (std::chrono::nanoseconds dtime) override
 A method called after all entities that this system manage has been updated. More...
 
 EventSystem (WAL::Wal &wal)
 A default constructor. More...
 
 EventSystem (const EventSystem &)=default
 An event system is copy constructable. More...
 
 ~EventSystem () override=default
 A default destructor. More...
 
EventSystemoperator= (const EventSystem &)=delete
 An event system is not assignable. More...
 
- Public Member Functions inherited from WAL::System<>
 ~System () override=default
 A virtual, default, destructor. More...
 
 System (System &&) noexcept=default
 A system can be moved. More...
 
View< Dependencies... > & getView () override
 Get a view of all entities containing every dependencies of this system. More...
 
virtual void onUpdate (ViewEntity< Dependencies... > &entity, std::chrono::nanoseconds dtime)
 Update the corresponding component of the given entity. More...
 
virtual void onFixedUpdate (ViewEntity< Dependencies... > &entity)
 An alternative of onUpdate that is called every 8ms (120 times per seconds). If the system slow down, it will try to catch up. More...
 
void update (std::chrono::nanoseconds dtime) final
 Update the whole system (every entities that this system is responsible can be updated. More...
 
void fixedUpdate () final
 An alternative of update that is called every 8ms (120 times per seconds). If the system slow down, it will try to catch up. More...
 
- Public Member Functions inherited from WAL::ISystem
virtual ~ISystem ()=default
 A virtual default destructor. More...
 

Private Attributes

std::list< std::function< void(WAL::Entity &)> > _events
 The list of events that occurred in the last update. More...
 
std::list< std::function< void(WAL::Wal &)> > _globalEvents
 The list of events that occurred in the last update. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WAL::System<>
 System (Wal &wal)
 A system can't be instantiated, it should be derived. More...
 
 System (const System &)=default
 A system can't be instantiated, it should be derived. More...
 
Systemoperator= (const System &)=default
 A system can't be instantiated, it should be derived. More...
 
- Protected Attributes inherited from WAL::System<>
Wal_wal
 A reference to the ECS. More...
 

Constructor & Destructor Documentation

◆ EventSystem() [1/2]

BBM::EventSystem::EventSystem ( WAL::Wal wal)
explicit

A default constructor.

◆ EventSystem() [2/2]

BBM::EventSystem::EventSystem ( const EventSystem )
default

An event system is copy constructable.

◆ ~EventSystem()

BBM::EventSystem::~EventSystem ( )
overridedefault

A default destructor.

Member Function Documentation

◆ dispatchEvent() [1/2]

void BBM::EventSystem::dispatchEvent ( const std::function< void(WAL::Entity &)> &  event)

Inform the system that a new event has occurred and it should run the given method on every entities.

◆ dispatchEvent() [2/2]

void BBM::EventSystem::dispatchEvent ( const std::function< void(WAL::Wal &)> &  event)

Inform the system that a new event has occurred and it should run the given method on every entities.

◆ onSelfUpdate()

void BBM::EventSystem::onSelfUpdate ( std::chrono::nanoseconds  dtime)
overridevirtual

A method called after all entities that this system manage has been updated.

Parameters
dtimeThe delta time.

Reimplemented from WAL::System<>.

◆ onUpdate()

void BBM::EventSystem::onUpdate ( WAL::ViewEntity<> &  entity,
std::chrono::nanoseconds  dtime 
)
override

◆ operator=()

EventSystem& BBM::EventSystem::operator= ( const EventSystem )
delete

An event system is not assignable.

Member Data Documentation

◆ _events

std::list<std::function<void (WAL::Entity &)> > BBM::EventSystem::_events
private

The list of events that occurred in the last update.

◆ _globalEvents

std::list<std::function<void (WAL::Wal &)> > BBM::EventSystem::_globalEvents
private

The list of events that occurred in the last update.


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