Manages weapon firing and charging. More...
#include <Weapon.hpp>
Public Member Functions | |
WeaponSystem ()=default | |
~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, bool spacePressed) |
Update weapon system. | |
void | update (ecs::Registry ®istry, float dt) override |
void | reset () |
Reset weapon state. | |
![]() | |
bool | isEnable () override |
void | setEnable (const bool enable) override |
![]() | |
virtual | ~ISystem ()=default |
Private Member Functions | |
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 | showLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity, const ecs::Transform *playerTransform) |
Show loading animation in front of the player. | |
void | hideLoadingAnimation (ecs::Registry ®istry, ecs::Entity playerEntity) |
Hide loading animation. | |
Private Attributes | |
float | m_fireCooldown = 0.0f |
bool | m_isCharging = false |
Manages weapon firing and charging.
Definition at line 21 of file Weapon.hpp.
|
default |
|
overridedefault |
|
delete |
|
delete |
|
private |
Hide loading animation.
registry | The ECS registry |
playerEntity | The player entity |
Definition at line 154 of file weapon.cpp.
References ecs::Registry::getAll(), ecs::Registry::hasComponent(), and ecs::Registry::removeComponent().
Referenced by update().
|
delete |
|
delete |
void cli::WeaponSystem::reset | ( | ) |
Reset weapon state.
Definition at line 95 of file weapon.cpp.
References m_fireCooldown, and m_isCharging.
|
private |
Show loading animation in front of the player.
registry | The ECS registry |
playerEntity | The player entity |
playerTransform | The 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().
|
private |
Try to fire basic projectile.
registry | The ECS registry |
x | X position |
y | Y position |
Definition at line 101 of file weapon.cpp.
References cli::ProjectileManager::createBasicProjectile(), and m_fireCooldown.
Referenced by update().
|
private |
Try to fire supercharged projectile.
registry | The ECS registry |
x | X position |
y | Y position |
Definition at line 113 of file weapon.cpp.
References cli::ProjectileManager::createSuperchargedProjectile().
Referenced by update().
|
overridevirtual |
Implements eng::ISystem.
void cli::WeaponSystem::update | ( | ecs::Registry & | registry, |
float | dt, | ||
bool | spacePressed ) |
Update weapon system.
registry | The ECS registry |
dt | Delta time |
spacePressed | Whether 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().
|
private |
Definition at line 47 of file Weapon.hpp.
Referenced by reset(), tryFireBasic(), and update().
|
private |
Definition at line 48 of file Weapon.hpp.