8 for (
auto &&[idx, weapon, position, type] :
IndexedZipper(weapons, positions, types)) {
9 if (!weapon || !position || !type)
continue;
14 if (weapon->shot && weapon->cooldown <= 0) {
17 weapon->cooldown = 1.0f / weapon->fire_rate;
26 if (weapons.size() <=
id)
return;
29 weapons[id]->
shot =
true;
@ P_SHOOT
Represents a player shooting event.
void spawn_missile(Registry &r, const float pos_x, const float pos_y, const type_enum owner)
Spawns a missile at the specified position.
void weapon_system(Registry &r, ComponentContainer< Weapon > &weapons, ComponentContainer< Position > &positions, ComponentContainer< Type > &types)
Handles the firing of weapons and updates their states.
void make_shot(Registry &r, std::size_t id)
Changes the state of the weapon.
Manages a collection of components associated with entities in an ECS (Entity-Component-System) archi...
void notify(const GameMessage &event)
Notifies the subscribed listener of an event.
Combines multiple containers into a single iterable unit, iterating over corresponding elements from ...
Manages entities and their associated components, enabling the creation, deletion,...
EventDispatcher * dispatcher
ComponentContainer< Component > & get_components()
Retrieves the component container for a specific type.
float deltaTime
The time difference between the current frame and the last frame.
Represents a weapon and its attributes in the game.