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

Manages weapon firing and charging. More...

#include <Weapon.hpp>

+ Inheritance diagram for cli::WeaponSystem:
+ Collaboration diagram for cli::WeaponSystem:

Public Member Functions

 WeaponSystem ()=default
 
 ~WeaponSystem () override=default
 
 WeaponSystem (const WeaponSystem &)=delete
 
WeaponSystemoperator= (const WeaponSystem &)=delete
 
 WeaponSystem (WeaponSystem &&)=delete
 
WeaponSystemoperator= (WeaponSystem &&)=delete
 
void update (ecs::Registry &registry, float dt, bool spacePressed)
 Update weapon system.
 
void update (ecs::Registry &registry, float dt) override
 
void reset ()
 Reset weapon state.
 
- Public Member Functions inherited from eng::ASystem
bool isEnable () override
 
void setEnable (const bool enable) override
 
- Public Member Functions inherited from eng::ISystem
virtual ~ISystem ()=default
 

Private Member Functions

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

Private Attributes

float m_fireCooldown = 0.0f
 
bool m_isCharging = false
 

Detailed Description

Manages weapon firing and charging.

Definition at line 21 of file Weapon.hpp.

Constructor & Destructor Documentation

◆ WeaponSystem() [1/3]

cli::WeaponSystem::WeaponSystem ( )
default

◆ ~WeaponSystem()

cli::WeaponSystem::~WeaponSystem ( )
overridedefault

◆ WeaponSystem() [2/3]

cli::WeaponSystem::WeaponSystem ( const WeaponSystem & )
delete

◆ WeaponSystem() [3/3]

cli::WeaponSystem::WeaponSystem ( WeaponSystem && )
delete

Member Function Documentation

◆ hideLoadingAnimation()

void cli::WeaponSystem::hideLoadingAnimation ( ecs::Registry & registry,
ecs::Entity playerEntity )
private

Hide loading animation.

Parameters
registryThe ECS registry
playerEntityThe player entity

Definition at line 154 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:

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ reset()

void cli::WeaponSystem::reset ( )

Reset weapon state.

Definition at line 95 of file weapon.cpp.

References m_fireCooldown, and m_isCharging.

◆ showLoadingAnimation()

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

Show loading animation in front of the player.

Parameters
registryThe ECS registry
playerEntityThe player entity
playerTransformThe player transform

Definition at line 121 of file weapon.cpp.

References ecs::Registry::createEntity(), ecs::Registry::getAll(), ecs::Registry::getComponent(), cli::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:

◆ tryFireBasic()

bool cli::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 101 of file weapon.cpp.

References cli::ProjectileManager::createBasicProjectile(), and m_fireCooldown.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tryFireSupercharged()

bool cli::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 113 of file weapon.cpp.

References cli::ProjectileManager::createSuperchargedProjectile().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update() [1/2]

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

Implements eng::ISystem.

◆ update() [2/2]

void cli::WeaponSystem::update ( ecs::Registry & registry,
float dt,
bool spacePressed )

Update weapon system.

Parameters
registryThe ECS registry
dtDelta time
spacePressedWhether space is pressed

Definition at line 13 of file weapon.cpp.

References ecs::Registry::getAll(), ecs::Registry::getComponent(), hideLoadingAnimation(), m_fireCooldown, m_isCharging, showLoadingAnimation(), cli::GameConfig::Player::SPRITE_HEIGHT, cli::GameConfig::Player::SPRITE_WIDTH, tryFireBasic(), and tryFireSupercharged().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_fireCooldown

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

Definition at line 47 of file Weapon.hpp.

Referenced by reset(), tryFireBasic(), and update().

◆ m_isCharging

bool cli::WeaponSystem::m_isCharging = false
private

Definition at line 48 of file Weapon.hpp.

Referenced by reset(), and update().


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