Files
Bomberman/sources/System/Timer/TimerSystem.cpp
2021-06-07 14:40:24 +02:00

25 lines
511 B
C++

//
// Created by Zoe Roux on 5/31/21.
//
#include "TimerSystem.hpp"
#include "Component/Timer/TimerComponent.hpp"
using namespace std::chrono_literals;
namespace BBM
{
TimerSystem::TimerSystem(WAL::Wal &wal)
: System(wal)
{}
void TimerSystem::onUpdate(WAL::ViewEntity<TimerComponent> &entity, std::chrono::nanoseconds dtime)
{
auto &timer = entity.get<TimerComponent>();
timer.ringIn -= dtime;
if (timer.ringIn <= 0ns) {
timer.setDisable(true);
timer.callback(entity, this->_wal);
}
}
}