r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
Weapon.hpp
Go to the documentation of this file.
1///
2/// @file WeaponSystem.hpp
3/// @brief Handles weapon firing logic
4/// @namespace cli
5///
6
7#pragma once
8
9#include "ECS/Component.hpp"
10#include "ECS/Registry.hpp"
11
13
14namespace cli
15{
16 ///
17 /// @class WeaponSystem
18 /// @brief Manages weapon firing and charging
19 /// @namespace cli
20 ///
21 class WeaponSystem final : public eng::ASystem
22 {
23 public:
24 WeaponSystem() = default;
25 ~WeaponSystem() override = default;
26
27 WeaponSystem(const WeaponSystem &) = delete;
31
32 ///
33 /// @brief Update weapon system
34 /// @param registry The ECS registry
35 /// @param dt Delta time
36 /// @param spacePressed Whether space is pressed
37 ///
38 void update(ecs::Registry &registry, float dt, bool spacePressed);
39 void update(ecs::Registry &registry, float dt) override;
40
41 ///
42 /// @brief Reset weapon state
43 ///
44 void reset();
45
46 private:
47 float m_fireCooldown = 0.0f;
48 bool m_isCharging = false;
49
50 ///
51 /// @brief Try to fire basic projectile
52 /// @param registry The ECS registry
53 /// @param x X position
54 /// @param y Y position
55 /// @return True if fired successfully
56 ///
57 bool tryFireBasic(ecs::Registry &registry, float x, float y);
58
59 ///
60 /// @brief Try to fire supercharged projectile
61 /// @param registry The ECS registry
62 /// @param x X position
63 /// @param y Y position
64 /// @return True if fired successfully
65 ///
66 bool tryFireSupercharged(ecs::Registry &registry, float x, float y);
67
68 ///
69 /// @brief Show loading animation in front of the player
70 /// @param registry The ECS registry
71 /// @param playerEntity The player entity
72 /// @param playerTransform The player transform
73 ///
74 void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity,
75 const ecs::Transform *playerTransform);
76
77 ///
78 /// @brief Hide loading animation
79 /// @param registry The ECS registry
80 /// @param playerEntity The player entity
81 ///
82 void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity);
83 }; // class WeaponSystem
84} // namespace cli
This file contains the component definitions.
This file contains the Registry class declaration.
Manages weapon firing and charging.
Definition Weapon.hpp:22
void reset()
Reset weapon state.
Definition weapon.cpp:95
WeaponSystem & operator=(WeaponSystem &&)=delete
WeaponSystem(const WeaponSystem &)=delete
void update(ecs::Registry &registry, float dt, bool spacePressed)
Update weapon system.
Definition weapon.cpp:13
bool tryFireSupercharged(ecs::Registry &registry, float x, float y)
Try to fire supercharged projectile.
Definition weapon.cpp:113
void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity)
Hide loading animation.
Definition weapon.cpp:154
void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
Show loading animation in front of the player.
Definition weapon.cpp:121
float m_fireCooldown
Definition Weapon.hpp:47
WeaponSystem(WeaponSystem &&)=delete
WeaponSystem()=default
WeaponSystem & operator=(const WeaponSystem &)=delete
bool tryFireBasic(ecs::Registry &registry, float x, float y)
Try to fire basic projectile.
Definition weapon.cpp:101
void update(ecs::Registry &registry, float dt) override
~WeaponSystem() override=default
Class for managing entities and their components.
Definition Registry.hpp:25
std::uint32_t Entity
Definition Entity.hpp:13