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 Weapon system for R-Type multiplayer client
4/// @details This file contains the weapon system that manages weapon firing, charging mechanics,
5/// and visual feedback for the multiplayer client. The system handles client-side
6/// weapon animations and effects while the actual projectile spawning is managed
7/// by the server for authoritative gameplay.
8/// @namespace gme
9/// @author R-Type Team
10/// @date 2025
11///
12
13#pragma once
14
15#include "ECS/Component.hpp"
17#include "ECS/Registry.hpp"
19
20namespace gme
21{
22 ///
23 /// @class WeaponSystem
24 /// @brief ECS system that manages weapon charging and visual effects in multiplayer
25 /// @details This system handles client-side weapon mechanics including:
26 /// - Weapon charge animation (for charged shots)
27 /// - Loading/charging visual indicators
28 /// - Fire cooldown management
29 /// - Audio feedback for charged shots
30 ///
31 /// In multiplayer mode, actual projectile creation is server-authoritative.
32 /// This system only provides visual and audio feedback to the player.
33 ///
34 /// @namespace gme
35 ///
36 class WeaponSystem final : public ecs::ASystem
37 {
38 public:
39 ///
40 /// @brief Constructor
41 /// @param renderer Shared pointer to the renderer (unused in current implementation)
42 ///
43 explicit WeaponSystem(const std::shared_ptr<eng::IRenderer> & /* renderer */) {}
44
45 ///
46 /// @brief Destructor
47 ///
48 ~WeaponSystem() override = default;
49
50 ///
51 /// @brief Deleted copy constructor (non-copyable)
52 ///
53 WeaponSystem(const WeaponSystem &) = delete;
54
55 ///
56 /// @brief Deleted copy assignment operator (non-copyable)
57 ///
59 ///
60 /// @brief Deleted move constructor (non-movable)
61 ///
63
64 ///
65 /// @brief Deleted move assignment operator (non-movable)
66 ///
68
69 ///
70 /// @brief Update weapon system (called each frame)
71 /// @param registry ECS registry containing all entities and components
72 /// @param dt Delta time since last frame (in seconds)
73 /// @details Handles weapon charge animation state and cooldown timers.
74 /// Updates visual charging indicators based on player input state.
75 ///
76 void update(ecs::Registry &registry, float dt) override;
77
78 ///
79 /// @brief Reset weapon state to initial values
80 /// @details Resets fire cooldown and charging state. Used when resetting game state.
81 ///
82 void reset()
83 {
84 m_fireCooldown = 0.0f;
85 m_isCharging = false;
86 }
87
88 private:
89 float m_fireCooldown = 0.0f; ///< Remaining cooldown time before next shot (seconds)
90 bool m_isCharging = false; ///< Whether weapon is currently charging
91
92 ///
93 /// @brief Display charging/loading animation in front of player
94 /// @param registry ECS registry
95 /// @param playerEntity Entity ID of the player
96 /// @param playerTransform Pointer to player's transform component
97 /// @details Creates or updates a visual indicator showing weapon charge progress
98 ///
99 static void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity,
100 const ecs::Transform *playerTransform);
101
102 ///
103 /// @brief Hide/remove the charging animation
104 /// @param registry ECS registry
105 /// @param playerEntity Entity ID of the player
106 /// @details Removes the visual charging indicator when charging is complete or cancelled
107 ///
108 static void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity);
109
110 ///
111 /// @brief Ensure super shot audio entity exists
112 /// @param registry ECS registry
113 /// @details Creates the audio entity for charged shot sound if it doesn't exist
114 ///
115 void ensureSuperShotAudio(ecs::Registry &registry);
116
117 ecs::Entity m_superShotAudioEntity = ecs::INVALID_ENTITY; ///< Entity for charged shot audio
118 }; // class WeaponSystem
119} // 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
static void hideLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity)
Hide/remove the charging animation.
Definition weapon.cpp:91
static void showLoadingAnimation(ecs::Registry &registry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
Display charging/loading animation in front of player.
Definition weapon.cpp:62
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
Deleted copy assignment operator (non-copyable)
WeaponSystem(const WeaponSystem &)=delete
Deleted copy constructor (non-copyable)
WeaponSystem(WeaponSystem &&)=delete
Deleted move constructor (non-movable)
void ensureSuperShotAudio(ecs::Registry &registry)
Ensure super shot audio entity exists.
Definition weapon.cpp:126
void reset()
Reset weapon state to initial values.
Definition Weapon.hpp:82
~WeaponSystem() override=default
Destructor.
WeaponSystem & operator=(WeaponSystem &&)=delete
Deleted move assignment operator (non-movable)
void update(ecs::Registry &registry, float dt) override
Update weapon system (called each frame)
Definition weapon.cpp:8
float m_fireCooldown
Remaining cooldown time before next shot (seconds)
Definition Weapon.hpp:89
WeaponSystem(const std::shared_ptr< eng::IRenderer > &)
Constructor.
Definition Weapon.hpp:43
std::uint32_t Entity
Definition Entity.hpp:13
constexpr Entity INVALID_ENTITY
Definition Entity.hpp:14