R-Type 0.1
Loading...
Searching...
No Matches
Bullet.hpp
1#pragma once
2
3#include <cstdint>
4#include <nlohmann/json.hpp>
5
6#include <Registry.hpp>
7
8namespace component {
17struct Bullet {
18 float damage{10.0f};
19};
20
27inline void bulletFromJson(rtk::ecs::Registry &reg, std::size_t entity,
28 const nlohmann::json &data) {
29 component::Bullet bullet{};
30 bullet.damage = data.value("damage", 10.0f);
31
32 reg.get_components<component::Bullet>().insert_at(entity, bullet);
33}
34
36} // namespace component
void bulletFromJson(rtk::ecs::Registry &reg, std::size_t entity, const nlohmann::json &data)
Adds a Bullet to an entity from its blueprint data.
Definition Bullet.hpp:27
Marks an entity as a projectile.
Definition Bullet.hpp:17
float damage
Damage dealt on hit.
Definition Bullet.hpp:18