R-Type 0.1
Loading...
Searching...
No Matches
Controllable.hpp
1#pragma once
2
3#include <cstdint>
4#include <nlohmann/json.hpp>
5
6#include <Registry.hpp>
7
8namespace component {
18 float speed{300.0f};
19 bool isChargingShoot{false};
20};
21
28inline void controllableFromJson(rtk::ecs::Registry &reg, std::size_t entity,
29 const nlohmann::json &data) {
30 component::Controllable controllable{};
31 controllable.speed = data.value("speed", 300.0f);
32 controllable.isChargingShoot = data.value("isChargingShoot", false);
33
34 reg.get_components<component::Controllable>().insert_at(entity, controllable);
35}
36
38} // namespace component
void controllableFromJson(rtk::ecs::Registry &reg, std::size_t entity, const nlohmann::json &data)
Adds a Controllable to an entity from its blueprint data.
Definition Controllable.hpp:28
Marks an entity as a ship driven by player inputs.
Definition Controllable.hpp:17
float speed
Movement speed in pixels per second.
Definition Controllable.hpp:18
bool isChargingShoot
True while the shoot button is held.
Definition Controllable.hpp:19