Adding a timer component

This commit is contained in:
Zoe Roux
2021-05-31 17:19:23 +02:00
parent 8009c0619b
commit 44b68b15e6
3 changed files with 70 additions and 1 deletions
@@ -0,0 +1,32 @@
//
// Created by Zoe Roux on 5/31/21.
//
#include "TimerComponent.hpp"
#include <utility>
namespace BBM
{
TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay)
: WAL::Component(entity),
ringIn(delay)
{}
TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, const WAL::Callback<WAL::Entity &> &callback)
: WAL::Component(entity),
ringIn(delay),
callback(callback)
{}
TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, std::function<void(WAL::Entity &)> callback)
: WAL::Component(entity),
ringIn(delay),
callback(std::move(callback))
{}
WAL::Component *TimerComponent::clone(WAL::Entity &entity) const
{
return new TimerComponent(entity, this->ringIn, this->callback);
}
}