bumperComponent + fix map

This commit is contained in:
Askou
2021-06-10 11:24:47 +02:00
parent 69563ad075
commit 4a1e7b085f
9 changed files with 153 additions and 6 deletions
@@ -0,0 +1,25 @@
//
// Created by Tom Augier on 2021-06-09.
//
#include "BumperTimerSystem.hpp"
namespace BBM
{
BumperTimerSystem::BumperTimerSystem(WAL::Wal &wal)
: System(wal)
{}
void BumperTimerSystem::onUpdate(WAL::ViewEntity<BumperTimerComponent> &entity, std::chrono::nanoseconds dtime)
{
auto &bumperTimer = entity.get<BumperTimerComponent>();
if (bumperTimer._isReseting) {
bumperTimer.nextReset -= dtime;
if (bumperTimer.nextReset <= 0ns) {
bumperTimer.nextReset = bumperTimer.resetRate;
bumperTimer._isReseting = false;
}
}
}
}
@@ -0,0 +1,29 @@
//
// Created by Tom Augier on 2021-06-09.
//
#pragma once
#include "Component/Movable/MovableComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/BumperTimer/BumperTimerComponent.hpp"
#include "System/System.hpp"
namespace BBM
{
//! @brief A system to handle BumperTimer entities.
class BumperTimerSystem : public WAL::System<BumperTimerComponent>
{
public:
//! @inherit
void onUpdate(WAL::ViewEntity<BumperTimerComponent> &entity, std::chrono::nanoseconds dtime) override;
//! @brief A default constructor
explicit BumperTimerSystem(WAL::Wal &wal);
//! @brief A BumperTimer system is copy constructable
BumperTimerSystem(const BumperTimerSystem &) = default;
//! @brief A default destructor
~BumperTimerSystem() override = default;
//! @brief A system is not assignable.
BumperTimerSystem &operator=(const BumperTimerSystem &) = delete;
};
}