ECS system that manages weapon charging and visual effects in multiplayer. More...
#include <Weapon.hpp>
Inheritance diagram for gme::WeaponSystem:
Collaboration diagram for gme::WeaponSystem:Public Member Functions | |
| WeaponSystem (const std::shared_ptr< eng::IRenderer > &) | |
| Constructor. | |
| ~WeaponSystem () override=default | |
| Destructor. | |
| WeaponSystem (const WeaponSystem &)=delete | |
| Deleted copy constructor (non-copyable) | |
| WeaponSystem & | operator= (const WeaponSystem &)=delete |
| Deleted copy assignment operator (non-copyable) | |
| WeaponSystem (WeaponSystem &&)=delete | |
| Deleted move constructor (non-movable) | |
| WeaponSystem & | operator= (WeaponSystem &&)=delete |
| Deleted move assignment operator (non-movable) | |
| void | update (ecs::Registry ®istry, float dt) override |
| Update weapon system (called each frame) | |
| void | reset () |
| Reset weapon state to initial values. | |
| WeaponSystem (const std::shared_ptr< eng::IRenderer > &) | |
| ~WeaponSystem () override=default | |
| WeaponSystem (const WeaponSystem &)=delete | |
| WeaponSystem & | operator= (const WeaponSystem &)=delete |
| WeaponSystem (WeaponSystem &&)=delete | |
| WeaponSystem & | operator= (WeaponSystem &&)=delete |
| void | update (ecs::Registry ®istry, float dt) override |
| Update weapon system. | |
| void | reset () |
| Reset weapon state. | |
Public Member Functions inherited from ecs::ASystem | |
| bool | isEnable () override |
| void | setEnable (const bool enable) override |
Public Member Functions inherited from ecs::ISystem | |
| virtual | ~ISystem ()=default |
Private Member Functions | |
| void | ensureSuperShotAudio (ecs::Registry ®istry) |
| Ensure super shot audio entity exists. | |
| bool | tryFireBasic (ecs::Registry ®istry, float x, float y) |
| Try to fire basic projectile. | |
| bool | tryFireSupercharged (ecs::Registry ®istry, float x, float y) |
| Try to fire supercharged projectile. | |
| void | ensureSuperShotAudio (ecs::Registry ®istry) |
Static Private Member Functions | |
| static void | showLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity, const ecs::Transform *playerTransform) |
| Display charging/loading animation in front of player. | |
| static void | hideLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity) |
| Hide/remove the charging animation. | |
| static void | showLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity, const ecs::Transform *playerTransform) |
| Show loading animation in front of the player. | |
| static void | hideLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity) |
| Hide loading animation. | |
Private Attributes | |
| float | m_fireCooldown = 0.0f |
| Remaining cooldown time before next shot (seconds) | |
| bool | m_isCharging = false |
| Whether weapon is currently charging. | |
| ecs::Entity | m_superShotAudioEntity = ecs::INVALID_ENTITY |
| Entity for charged shot audio. | |
ECS system that manages weapon charging and visual effects in multiplayer.
Manages weapon firing and charging.
This system handles client-side weapon mechanics including:
In multiplayer mode, actual projectile creation is server-authoritative. This system only provides visual and audio feedback to the player.
Definition at line 21 of file Weapon.hpp.
|
inlineexplicit |
Constructor.
| renderer | Shared pointer to the renderer (unused in current implementation) |
Definition at line 43 of file Weapon.hpp.
|
overridedefault |
Destructor.
|
delete |
Deleted copy constructor (non-copyable)
|
delete |
Deleted move constructor (non-movable)
|
inlineexplicit |
Definition at line 24 of file Weapon.hpp.
|
overridedefault |
|
delete |
|
delete |
|
private |
Ensure super shot audio entity exists.
| registry | ECS registry |
Creates the audio entity for charged shot sound if it doesn't exist
Definition at line 126 of file weapon.cpp.
References utl::Path::Audio::AUDIO_SUPERCHARGED_SHOT, ecs::Registry::createEntity(), ecs::Registry::hasComponent(), ecs::INVALID_ENTITY, and ecs::Registry::EntityBuilder::with().
Here is the call graph for this function:
|
private |
|
staticprivate |
Hide/remove the charging animation.
| registry | ECS registry |
| playerEntity | Entity ID of the player |
Removes the visual charging indicator when charging is complete or cancelled
Definition at line 91 of file weapon.cpp.
References ecs::Registry::getAll(), ecs::Registry::hasComponent(), and ecs::Registry::removeComponent().
Referenced by update().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Hide loading animation.
| registry | The ECS registry |
| playerEntity | The player entity |
|
delete |
Deleted copy assignment operator (non-copyable)
|
delete |
|
delete |
Deleted move assignment operator (non-movable)
|
delete |
|
inline |
Reset weapon state to initial values.
Resets fire cooldown and charging state. Used when resetting game state.
Definition at line 82 of file Weapon.hpp.
References m_fireCooldown, and m_isCharging.
|
inline |
Reset weapon state.
Definition at line 42 of file Weapon.hpp.
References m_fireCooldown, and m_isCharging.
|
staticprivate |
Display charging/loading animation in front of player.
| registry | ECS registry |
| playerEntity | Entity ID of the player |
| playerTransform | Pointer to player's transform component |
Creates or updates a visual indicator showing weapon charge progress
Definition at line 62 of file weapon.cpp.
References utl::GameConfig::LoadingAnimation::ANIMATION_DURATION, utl::GameConfig::LoadingAnimation::ANIMATION_FRAMES, ecs::Registry::createEntity(), ecs::Registry::getAll(), ecs::Registry::getComponent(), utl::GameConfig::LoadingAnimation::OFFSET_X, utl::GameConfig::LoadingAnimation::OFFSET_Y, utl::GameConfig::LoadingAnimation::SPRITE_HEIGHT, utl::GameConfig::LoadingAnimation::SPRITE_WIDTH, utl::Path::Texture::TEXTURE_SHOOT_LOADING, ecs::Registry::EntityBuilder::with(), ecs::Transform::x, and ecs::Transform::y.
Referenced by update().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Show loading animation in front of the player.
| registry | The ECS registry |
| playerEntity | The player entity |
| playerTransform | The player transform |
|
private |
Try to fire basic projectile.
| registry | The ECS registry |
| x | X position |
| y | Y position |
Definition at line 76 of file weapon.cpp.
References gme::ProjectileManager::createBasicProjectile(), utl::GameConfig::Projectile::Basic::FIRE_COOLDOWN, and utl::GameConfig::Projectile::Basic::SPEED.
Here is the call graph for this function:
|
private |
Try to fire supercharged projectile.
| registry | The ECS registry |
| x | X position |
| y | Y position |
Definition at line 86 of file weapon.cpp.
References gme::ProjectileManager::createSuperchargedProjectile(), ecs::Registry::getComponent(), ecs::INVALID_ENTITY, and utl::GameConfig::Projectile::Supercharged::SPEED.
Here is the call graph for this function:
|
overridevirtual |
Update weapon system (called each frame)
| registry | ECS registry containing all entities and components |
| dt | Delta time since last frame (in seconds) |
Handles weapon charge animation state and cooldown timers. Updates visual charging indicators based on player input state.
Implements ecs::ISystem.
Definition at line 8 of file weapon.cpp.
References utl::GameConfig::Beam::CHARGE_RATE, ecs::Registry::getAll(), ecs::Registry::getComponent(), hideLoadingAnimation(), m_fireCooldown, m_isCharging, showLoadingAnimation(), and ecs::KeyboardInput::space_pressed.
Here is the call graph for this function:
|
overridevirtual |
|
private |
Remaining cooldown time before next shot (seconds)
Definition at line 89 of file Weapon.hpp.
|
private |
Whether weapon is currently charging.
Definition at line 90 of file Weapon.hpp.
|
private |
Entity for charged shot audio.
Definition at line 117 of file Weapon.hpp.