r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
gme::WeaponSystem Class Referencefinal

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)
 
WeaponSystemoperator= (const WeaponSystem &)=delete
 Deleted copy assignment operator (non-copyable)
 
 WeaponSystem (WeaponSystem &&)=delete
 Deleted move constructor (non-movable)
 
WeaponSystemoperator= (WeaponSystem &&)=delete
 Deleted move assignment operator (non-movable)
 
void update (ecs::Registry &registry, 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
 
WeaponSystemoperator= (const WeaponSystem &)=delete
 
 WeaponSystem (WeaponSystem &&)=delete
 
WeaponSystemoperator= (WeaponSystem &&)=delete
 
void update (ecs::Registry &registry, 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 &registry)
 Ensure super shot audio entity exists.
 
bool tryFireBasic (ecs::Registry &registry, float x, float y)
 Try to fire basic projectile.
 
bool tryFireSupercharged (ecs::Registry &registry, float x, float y)
 Try to fire supercharged projectile.
 
void ensureSuperShotAudio (ecs::Registry &registry)
 

Static Private Member Functions

static void showLoadingAnimation (ecs::Registry &registry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
 Display charging/loading animation in front of player.
 
static void hideLoadingAnimation (ecs::Registry &registry, ecs::Entity playerEntity)
 Hide/remove the charging animation.
 
static void showLoadingAnimation (ecs::Registry &registry, ecs::Entity playerEntity, const ecs::Transform *playerTransform)
 Show loading animation in front of the player.
 
static void hideLoadingAnimation (ecs::Registry &registry, 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.
 

Detailed Description

ECS system that manages weapon charging and visual effects in multiplayer.

Manages weapon firing and charging.

This system handles client-side weapon mechanics including:

  • Weapon charge animation (for charged shots)
  • Loading/charging visual indicators
  • Fire cooldown management
  • Audio feedback for charged shots

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.

Constructor & Destructor Documentation

◆ WeaponSystem() [1/6]

gme::WeaponSystem::WeaponSystem ( const std::shared_ptr< eng::IRenderer > & )
inlineexplicit

Constructor.

Parameters
rendererShared pointer to the renderer (unused in current implementation)

Definition at line 43 of file Weapon.hpp.

◆ ~WeaponSystem() [1/2]

gme::WeaponSystem::~WeaponSystem ( )
overridedefault

Destructor.

◆ WeaponSystem() [2/6]

gme::WeaponSystem::WeaponSystem ( const WeaponSystem & )
delete

Deleted copy constructor (non-copyable)

◆ WeaponSystem() [3/6]

gme::WeaponSystem::WeaponSystem ( WeaponSystem && )
delete

Deleted move constructor (non-movable)

◆ WeaponSystem() [4/6]

gme::WeaponSystem::WeaponSystem ( const std::shared_ptr< eng::IRenderer > & )
inlineexplicit

Definition at line 24 of file Weapon.hpp.

◆ ~WeaponSystem() [2/2]

gme::WeaponSystem::~WeaponSystem ( )
overridedefault

◆ WeaponSystem() [5/6]

gme::WeaponSystem::WeaponSystem ( const WeaponSystem & )
delete

◆ WeaponSystem() [6/6]

gme::WeaponSystem::WeaponSystem ( WeaponSystem && )
delete

Member Function Documentation

◆ ensureSuperShotAudio() [1/2]

void gme::WeaponSystem::ensureSuperShotAudio ( ecs::Registry & registry)
private

Ensure super shot audio entity exists.

Parameters
registryECS 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:

◆ ensureSuperShotAudio() [2/2]

void gme::WeaponSystem::ensureSuperShotAudio ( ecs::Registry & registry)
private

◆ hideLoadingAnimation() [1/2]

void gme::WeaponSystem::hideLoadingAnimation ( ecs::Registry & registry,
ecs::Entity playerEntity )
staticprivate

Hide/remove the charging animation.

Parameters
registryECS registry
playerEntityEntity 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:

◆ hideLoadingAnimation() [2/2]

static void gme::WeaponSystem::hideLoadingAnimation ( ecs::Registry & registry,
ecs::Entity playerEntity )
staticprivate

Hide loading animation.

Parameters
registryThe ECS registry
playerEntityThe player entity

◆ operator=() [1/4]

WeaponSystem & gme::WeaponSystem::operator= ( const WeaponSystem & )
delete

Deleted copy assignment operator (non-copyable)

◆ operator=() [2/4]

WeaponSystem & gme::WeaponSystem::operator= ( const WeaponSystem & )
delete

◆ operator=() [3/4]

WeaponSystem & gme::WeaponSystem::operator= ( WeaponSystem && )
delete

Deleted move assignment operator (non-movable)

◆ operator=() [4/4]

WeaponSystem & gme::WeaponSystem::operator= ( WeaponSystem && )
delete

◆ reset() [1/2]

void gme::WeaponSystem::reset ( )
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.

◆ reset() [2/2]

void gme::WeaponSystem::reset ( )
inline

Reset weapon state.

Definition at line 42 of file Weapon.hpp.

References m_fireCooldown, and m_isCharging.

◆ showLoadingAnimation() [1/2]

void gme::WeaponSystem::showLoadingAnimation ( ecs::Registry & registry,
ecs::Entity playerEntity,
const ecs::Transform * playerTransform )
staticprivate

Display charging/loading animation in front of player.

Parameters
registryECS registry
playerEntityEntity ID of the player
playerTransformPointer 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:

◆ showLoadingAnimation() [2/2]

static void gme::WeaponSystem::showLoadingAnimation ( ecs::Registry & registry,
ecs::Entity playerEntity,
const ecs::Transform * playerTransform )
staticprivate

Show loading animation in front of the player.

Parameters
registryThe ECS registry
playerEntityThe player entity
playerTransformThe player transform

◆ tryFireBasic()

bool gme::WeaponSystem::tryFireBasic ( ecs::Registry & registry,
float x,
float y )
private

Try to fire basic projectile.

Parameters
registryThe ECS registry
xX position
yY position
Returns
True if fired successfully

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:

◆ tryFireSupercharged()

bool gme::WeaponSystem::tryFireSupercharged ( ecs::Registry & registry,
float x,
float y )
private

Try to fire supercharged projectile.

Parameters
registryThe ECS registry
xX position
yY position
Returns
True if fired successfully

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:

◆ update() [1/2]

void gme::WeaponSystem::update ( ecs::Registry & registry,
float dt )
overridevirtual

Update weapon system (called each frame)

Parameters
registryECS registry containing all entities and components
dtDelta 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:

◆ update() [2/2]

void gme::WeaponSystem::update ( ecs::Registry & registry,
float dt )
overridevirtual

Update weapon system.

Parameters
registryThe ECS registry
dtDelta time

Implements ecs::ISystem.

Member Data Documentation

◆ m_fireCooldown

float gme::WeaponSystem::m_fireCooldown = 0.0f
private

Remaining cooldown time before next shot (seconds)

Definition at line 89 of file Weapon.hpp.

Referenced by reset(), and update().

◆ m_isCharging

bool gme::WeaponSystem::m_isCharging = false
private

Whether weapon is currently charging.

Definition at line 90 of file Weapon.hpp.

Referenced by reset(), and update().

◆ m_superShotAudioEntity

ecs::Entity gme::WeaponSystem::m_superShotAudioEntity = ecs::INVALID_ENTITY
private

Entity for charged shot audio.

Definition at line 117 of file Weapon.hpp.


The documentation for this class was generated from the following files: