Files
2021-06-17 14:34:29 +02:00

36 lines
735 B
C++

//
// Created by Zoe Roux on 6/1/21.
//
#include "EventSystem.hpp"
namespace BBM
{
EventSystem::EventSystem(WAL::Wal &wal)
: System(wal)
{}
void EventSystem::dispatchEvent(const std::function<void(WAL::Entity &)> &event)
{
this->_events.emplace_back(event);
}
void EventSystem::dispatchEvent(const std::function<void(WAL::Wal &)> &event)
{
this->_globalEvents.emplace_back(event);
}
void EventSystem::onUpdate(WAL::ViewEntity<> &entity, std::chrono::nanoseconds)
{
for (auto &event : this->_events)
event(entity);
}
void EventSystem::onSelfUpdate(std::chrono::nanoseconds dtime)
{
for (auto &event : this->_globalEvents)
event(this->_wal);
this->_events.clear();
this->_globalEvents.clear();
}
}