Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
ScoreSystem.hpp
Go to the documentation of this file.
1
9#ifndef SCORE_SYSTEM_HPP
10#define SCORE_SYSTEM_HPP
11
13#include "RType/ECS/ISystem.hpp"
15
16namespace rtp::client
17{
18 class ScoreSystem : public ecs::ISystem {
19 public:
20 explicit ScoreSystem(ecs::Registry &r) : _r(r)
21 {
22 }
23
24 void update(float dt) override
25 {
26 auto view = _r.view<ecs::components::Score>();
27
28 for (auto &&score : view) {
29 const int increment = static_cast<int>(dt * 100.0f);
30 score.value += (increment > 0) ? increment : 1;
31 }
32 }
33
34 private:
36 };
37}
38
39#endif // SCORE_SYSTEM_HPP
Interface for ECS systems.
ScoreSystem(ecs::Registry &r)
void update(float dt) override
Update system logic for one frame.
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
auto view(this Self &self)
R-Type client namespace.
Component representing an entity's score.
Definition Score.hpp:15
int value
Current score value.
Definition Score.hpp:16