|
R-Type
Distributed multiplayer game engine in C++
|
Component for entities capable of shooting projectiles. More...
#include <Weapon.hpp>


Public Member Functions | |
| Weapon (float fireRate, float cooldown, int projectileType, int damage) | |
| Constructor with weapon parameters. | |
| ~Weapon () override=default | |
| float | getFireRate () const |
| Get fire rate. | |
| float | getCooldown () const |
| Get current cooldown. | |
| int | getProjectileType () const |
| Get projectile type. | |
| float | getDamage () const |
| Get damage value. | |
| bool | shouldShoot () const |
| Check if the weapon should shoot. | |
| float | getBaseFireRate () const |
| Get base fire rate (before buffs). | |
| int | getBaseDamage () const |
| Get base damage (before buffs). | |
| void | setFireRate (float fireRate) |
| Set fire rate. | |
| void | setCooldown (float cooldown) |
| Set cooldown timer. | |
| void | setProjectileType (int projectileType) |
| Set projectile type. | |
| void | setDamage (float damage) |
| Set damage value. | |
| void | setShouldShoot (bool shouldShoot) |
| Set whether the weapon should shoot. | |
| bool | isCharging () const |
| Check if weapon is currently charging. | |
| void | setCharging (bool charging) |
| Set charging state. | |
| float | getChargeLevel () const |
| Get current charge level. | |
| void | setChargeLevel (float level) |
| Set charge level. | |
| float | getChargeRate () const |
| Get charge rate (how fast the weapon charges). | |
| void | setChargeRate (float rate) |
| Set charge rate. | |
| ComponentType | getType () const override |
| Get the component type ID. | |
Public Member Functions inherited from ecs::IComponent | |
| virtual | ~IComponent ()=default |
| Virtual destructor. | |
Private Attributes | |
| float | _fireRate |
| Shots per second. | |
| float | _cooldown |
| Current cooldown timer in seconds. | |
| int | _projectileType |
| Type of projectile spawned. | |
| float | _damage |
| Base damage dealt. | |
| bool | _shouldShoot = false |
| Whether the weapon is currently set to shoot. | |
| float | _baseFireRate |
| Base fire rate (before buffs) | |
| int | _baseDamage |
| Base damage (before buffs) | |
| bool | _isCharging = false |
| Whether the weapon is currently charging. | |
| float | _chargeLevel = 0.0F |
| Current charge level (0.0 to 1.0) | |
| float | _chargeRate = 1.0F |
| How fast the weapon charges per second. | |
Component for entities capable of shooting projectiles.
Manages weapon characteristics including fire rate, cooldown timer, projectile type spawned, base damage dealt, and charged shot mechanics.
Weapons support a charging mechanic where holding the fire button accumulates charge over time. When released:
Charge accumulation is controlled by the chargeRate field (default: 1.0 = full charge in 1 second).
Definition at line 28 of file Weapon.hpp.
|
inline |
Constructor with weapon parameters.
| fireRate | Shots per second (higher = faster) |
| cooldown | Current cooldown timer (in seconds) |
| projectileType | Type of projectile spawned |
| damage | Base damage dealt by this weapon |
Definition at line 37 of file Weapon.hpp.
|
overridedefault |
|
inline |
Get base damage (before buffs).
Definition at line 86 of file Weapon.hpp.
References _baseDamage.
Referenced by ecs::BuffSystem::_applyDamageBoost().
|
inline |
Get base fire rate (before buffs).
Definition at line 80 of file Weapon.hpp.
References _baseFireRate.
Referenced by ecs::BuffSystem::_applyFireRateBoost().
|
inline |
Get current charge level.
Definition at line 134 of file Weapon.hpp.
References _chargeLevel.
|
inline |
Get charge rate (how fast the weapon charges).
Definition at line 148 of file Weapon.hpp.
References _chargeRate.
|
inline |
Get current cooldown.
Definition at line 56 of file Weapon.hpp.
References _cooldown.
|
inline |
Get damage value.
Definition at line 68 of file Weapon.hpp.
References _damage.
Referenced by ecs::WeaponSystem::fireChargedShot(), and ecs::WeaponSystem::fireWeapon().
|
inline |
Get fire rate.
Definition at line 50 of file Weapon.hpp.
References _fireRate.
Referenced by ecs::WeaponSystem::createProjectile().
|
inline |
Get projectile type.
Definition at line 62 of file Weapon.hpp.
References _projectileType.
|
inlineoverridevirtual |
Get the component type ID.
Implements ecs::IComponent.
Definition at line 160 of file Weapon.hpp.
|
inline |
Check if weapon is currently charging.
Definition at line 122 of file Weapon.hpp.
References _isCharging.
|
inline |
Set charge level.
| level | Charge level (clamped to 0.0-1.0) |
Definition at line 140 of file Weapon.hpp.
References _chargeLevel.
|
inline |
Set charge rate.
| rate | Charge rate per second |
Definition at line 154 of file Weapon.hpp.
References _chargeRate.
|
inline |
Set charging state.
| charging | True to start charging, false to stop |
Definition at line 128 of file Weapon.hpp.
References _isCharging.
|
inline |
Set cooldown timer.
| cooldown | New cooldown value in seconds |
Definition at line 98 of file Weapon.hpp.
References _cooldown.
Referenced by ecs::WeaponSystem::update().
|
inline |
Set damage value.
| damage | New damage value |
Definition at line 110 of file Weapon.hpp.
References _damage.
Referenced by ecs::BuffSystem::_applyDamageBoost().
|
inline |
Set fire rate.
| fireRate | New shots per second |
Definition at line 92 of file Weapon.hpp.
References _fireRate.
Referenced by ecs::BuffSystem::_applyFireRateBoost().
|
inline |
Set projectile type.
| projectileType | New projectile type |
Definition at line 104 of file Weapon.hpp.
References _projectileType.
|
inline |
Set whether the weapon should shoot.
| shouldShoot | True to enable shooting, false to disable |
Definition at line 116 of file Weapon.hpp.
References _shouldShoot, and shouldShoot().
Referenced by server::GameLogic::_applyPlayerInput(), and ecs::AISystem::update().

|
inline |
Check if the weapon should shoot.
Definition at line 74 of file Weapon.hpp.
References _shouldShoot.
Referenced by setShouldShoot().
|
private |
Base damage (before buffs)
Definition at line 169 of file Weapon.hpp.
Referenced by getBaseDamage().
|
private |
Base fire rate (before buffs)
Definition at line 168 of file Weapon.hpp.
Referenced by getBaseFireRate().
|
private |
Current charge level (0.0 to 1.0)
Definition at line 173 of file Weapon.hpp.
Referenced by getChargeLevel(), and setChargeLevel().
|
private |
How fast the weapon charges per second.
Definition at line 174 of file Weapon.hpp.
Referenced by getChargeRate(), and setChargeRate().
|
private |
Current cooldown timer in seconds.
Definition at line 164 of file Weapon.hpp.
Referenced by getCooldown(), and setCooldown().
|
private |
Base damage dealt.
Definition at line 166 of file Weapon.hpp.
Referenced by getDamage(), and setDamage().
|
private |
Shots per second.
Definition at line 163 of file Weapon.hpp.
Referenced by getFireRate(), and setFireRate().
|
private |
Whether the weapon is currently charging.
Definition at line 172 of file Weapon.hpp.
Referenced by isCharging(), and setCharging().
|
private |
Type of projectile spawned.
Definition at line 165 of file Weapon.hpp.
Referenced by getProjectileType(), and setProjectileType().
|
private |
Whether the weapon is currently set to shoot.
Definition at line 167 of file Weapon.hpp.
Referenced by setShouldShoot(), and shouldShoot().