r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
Weapon.hpp
Go to the documentation of this file.
1///
2/// @file Weapon.hpp
3/// @brief Handles weapon firing logic
4/// @namespace gme
5///
6
7#pragma once
8
9#include "ECS/Component.hpp"
11#include "ECS/Registry.hpp"
13
14namespace gme
15{
16 ///
17 /// @class WeaponSystem
18 /// @brief Manages weapon firing and charging
19 /// @namespace gme
20 ///
21 class WeaponSystem final : public ecs::ASystem
22 {
23 public:
24 explicit WeaponSystem(const std::shared_ptr<eng::IRenderer> & /* renderer */) {}
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 ///
37 void update(ecs::Registry &registry, float dt) override;
38
39 ///
40 /// @brief Reset weapon state
41 ///
42 void reset()
43 {
44 m_fireCooldown = 0.0f;
45 m_isCharging = false;
46 }
47
48 private:
49 float m_fireCooldown = 0.0f;
50 bool m_isCharging = false;
51
52 ///
53 /// @brief Try to fire basic projectile
54 /// @param registry The ECS registry
55 /// @param x X position
56 /// @param y Y position
57 /// @return True if fired successfully
58 ///
59 bool tryFireBasic(ecs::Registry &registry, float x, float y);
60
61 ///
62 /// @brief Try to fire supercharged projectile
63 /// @param registry The ECS registry
64 /// @param x X position
65 /// @param y Y position
66 /// @return True if fired successfully
67 ///
68 bool tryFireSupercharged(ecs::Registry &registry, float x, float y);
69
70 ///
71 /// @brief Show loading animation in front of the player
72 /// @param registry The ECS registry
73 /// @param playerEntity The player entity
74 /// @param playerTransform The player transform
75 ///
76 static void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity,
77 const ecs::Transform *playerTransform);
78
79 ///
80 /// @brief Hide loading animation
81 /// @param registry The ECS registry
82 /// @param playerEntity The player entity
83 ///
84 static void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity);
85
87
89 }; // class WeaponSystem
90} // namespace gme
This file contains the component definitions.
This file contains the IRenderer class declaration.
This file contains the interface for systems.
This file contains the Registry class declaration.
Abstract class for system.
Definition ISystems.hpp:34
Class for managing entities and their components.
Definition Registry.hpp:25
ECS system that manages weapon charging and visual effects in multiplayer.
Definition Weapon.hpp:22
bool m_isCharging
Whether weapon is currently charging.
Definition Weapon.hpp:90
ecs::Entity m_superShotAudioEntity
Entity for charged shot audio.
Definition Weapon.hpp:117
WeaponSystem & operator=(const WeaponSystem &)=delete
WeaponSystem(const WeaponSystem &)=delete
WeaponSystem(WeaponSystem &&)=delete
void ensureSuperShotAudio(ecs::Registry &registry)
void reset()
Reset weapon state.
Definition Weapon.hpp:42
~WeaponSystem() override=default
static void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
Show loading animation in front of the player.
WeaponSystem & operator=(WeaponSystem &&)=delete
void update(ecs::Registry &registry, float dt) override
Update weapon system.
static void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity)
Hide loading animation.
float m_fireCooldown
Remaining cooldown time before next shot (seconds)
Definition Weapon.hpp:89
WeaponSystem(const std::shared_ptr< eng::IRenderer > &)
Definition Weapon.hpp:24
bool tryFireBasic(ecs::Registry &registry, float x, float y)
Try to fire basic projectile.
Definition weapon.cpp:76
bool tryFireSupercharged(ecs::Registry &registry, float x, float y)
Try to fire supercharged projectile.
Definition weapon.cpp:86
std::uint32_t Entity
Definition Entity.hpp:13
constexpr Entity INVALID_ENTITY
Definition Entity.hpp:14