Adding an event system

This commit is contained in:
Zoe Roux
2021-06-01 17:06:35 +02:00
parent 9dca04e385
commit 2da5b219b9
7 changed files with 91 additions and 6 deletions
+28
View File
@@ -0,0 +1,28 @@
//
// Created by Zoe Roux on 6/1/21.
//
#include "EventSystem.hpp"
namespace BBM
{
EventSystem::EventSystem()
: WAL::System({})
{}
void EventSystem::dispatchEvent(const std::function<void(WAL::Entity &)> &event)
{
this->_events.emplace_back(event);
}
void EventSystem::onUpdate(WAL::Entity &entity, std::chrono::nanoseconds)
{
for (auto &event : this->_events)
event(entity);
}
void EventSystem::onSelfUpdate()
{
this->_events.clear();
}
}