Skip to main content

ShootComponent Class

Component for handling projectile shooting with rate limiting. More...

Declaration

class helios::engine::mechanics::combat::components::ShootComponent { ... }

Public Constructors Index

ShootComponent ()=default

Constructs a new ShootComponent with default settings. More...

ShootComponent (const ShootComponent &)=default
ShootComponent (ShootComponent &&) noexcept=default

Public Operators Index

ShootComponent &operator= (const ShootComponent &)=default
ShootComponent &operator= (ShootComponent &&) noexcept=default

Public Member Functions Index

boolisEnabled () const noexcept

Checks whether this component is enabled. More...

voidenable () noexcept

Enables this component. More...

voiddisable () noexcept

Disables this component. More...

voidshoot (const float intensity, const helios::math::vec3f sourceVelocity)

Sets the shooting intensity. More...

floatcooldownDelta () const noexcept

Returns the cooldown interval between shots. More...

floatintensity () const noexcept

Returns the current fire intensity. More...

floatcooldownTimer () const noexcept

Returns the accumulated time since last shot. More...

voidsetCooldownTimer (float cooldown) noexcept

Sets the accumulated cooldown timer. More...

voidupdateCooldownTimerBy (float delta) noexcept

Adds delta time to the cooldown timer. More...

floatprojectileSpeed () const noexcept

Returns the projectile speed. More...

voidsetProjectileSpeed (float speed) noexcept

Sets the projectile speed. More...

helios::math::vec3fsourceVelocity () const noexcept

Returns the source object's velocity. More...

floatfireRate () const noexcept

Returns the fire rate in projectiles per second. More...

voidsetFireRate (const float fireRate) noexcept

Sets the fire rate. More...

Protected Member Attributes Index

floatintensity_ = 0.0f

Current fire intensity (0.0 to 1.0). More...

floatcooldownDelta_ = 0.0f

Cooldown interval between shots, in seconds. More...

floatcooldownTimer_ = 0.0f

Accumulated time since last shot, in seconds. More...

floatprojectileSpeed_ = 60.0f

The projectile speed, in meters per second. More...

helios::math::vec3fsourceVelocity_

Velocity of the source object in three-dimensional space. More...

floatfireRate_ = 1.0f

Fire rate per second, i.e. projectiles than can be shot per second. More...

boolisEnabled_ = true

Whether this component is enabled. More...

Description

Component for handling projectile shooting with rate limiting.

Manages the shooting mechanics for a GameObject by coordinating with aim-components for direction and a projectile pool for projectile spawning. Implements a cooldown timer to control fire rate.

Example usage: ```cpp auto shootComponent = std::make_unique<ShootComponent>(); gameObject.add(std::move(shootComponent));

// Trigger shooting (typically from ShootCommand) shootComponent->shoot(1.0f); ```

Definition at line 38 of file ShootComponent.ixx.

Public Constructors

ShootComponent()

helios::engine::mechanics::combat::components::ShootComponent::ShootComponent ()
default

Constructs a new ShootComponent with default settings.

Definition at line 118 of file ShootComponent.ixx.

Referenced by operator=, operator=, ShootComponent and ShootComponent.

ShootComponent()

helios::engine::mechanics::combat::components::ShootComponent::ShootComponent (const ShootComponent &)
default

Definition at line 120 of file ShootComponent.ixx.

Reference ShootComponent.

ShootComponent()

helios::engine::mechanics::combat::components::ShootComponent::ShootComponent (ShootComponent &&)
noexcept default

Definition at line 122 of file ShootComponent.ixx.

Reference ShootComponent.

Public Operators

operator=()

ShootComponent & helios::engine::mechanics::combat::components::ShootComponent::operator= (const ShootComponent &)
default

Definition at line 121 of file ShootComponent.ixx.

Reference ShootComponent.

operator=()

ShootComponent & helios::engine::mechanics::combat::components::ShootComponent::operator= (ShootComponent &&)
noexcept default

Definition at line 123 of file ShootComponent.ixx.

Reference ShootComponent.

Public Member Functions

cooldownDelta()

float helios::engine::mechanics::combat::components::ShootComponent::cooldownDelta ()
inline nodiscard noexcept

Returns the cooldown interval between shots.

Returns

Cooldown interval in seconds (derived from 1.0 / fireRate).

Definition at line 151 of file ShootComponent.ixx.

151 [[nodiscard]] float cooldownDelta() const noexcept {
152 return cooldownDelta_;
153 }

Reference cooldownDelta_.

cooldownTimer()

float helios::engine::mechanics::combat::components::ShootComponent::cooldownTimer ()
inline nodiscard noexcept

Returns the accumulated time since last shot.

Returns

Accumulated cooldown timer in seconds.

Definition at line 169 of file ShootComponent.ixx.

169 [[nodiscard]] float cooldownTimer() const noexcept {
170 return cooldownTimer_;
171 }

Reference cooldownTimer_.

disable()

void helios::engine::mechanics::combat::components::ShootComponent::disable ()
inline noexcept

Disables this component.

Definition at line 111 of file ShootComponent.ixx.

111 void disable() noexcept {
112 isEnabled_ = false;
113 }

Reference isEnabled_.

enable()

void helios::engine::mechanics::combat::components::ShootComponent::enable ()
inline noexcept

Enables this component.

Definition at line 104 of file ShootComponent.ixx.

104 void enable() noexcept {
105 isEnabled_ = true;
106 }

Reference isEnabled_.

fireRate()

float helios::engine::mechanics::combat::components::ShootComponent::fireRate ()
inline nodiscard noexcept

Returns the fire rate in projectiles per second.

Returns

Fire rate (projectiles/second).

Definition at line 224 of file ShootComponent.ixx.

224 [[nodiscard]] float fireRate() const noexcept {
225 return fireRate_;
226 }

Reference fireRate_.

Referenced by setFireRate.

intensity()

float helios::engine::mechanics::combat::components::ShootComponent::intensity ()
inline nodiscard noexcept

Returns the current fire intensity.

Returns

The intensity value (0.0 to 1.0).

Definition at line 160 of file ShootComponent.ixx.

160 [[nodiscard]] float intensity() const noexcept {
161 return intensity_;
162 }

Reference intensity_.

Referenced by shoot.

isEnabled()

bool helios::engine::mechanics::combat::components::ShootComponent::isEnabled ()
inline nodiscard noexcept

Checks whether this component is enabled.

Returns

True if enabled, false otherwise.

Definition at line 97 of file ShootComponent.ixx.

97 [[nodiscard]] bool isEnabled() const noexcept {
98 return isEnabled_;
99 }

Reference isEnabled_.

projectileSpeed()

float helios::engine::mechanics::combat::components::ShootComponent::projectileSpeed ()
inline nodiscard noexcept

Returns the projectile speed.

Returns

Projectile speed in meters per second.

Definition at line 196 of file ShootComponent.ixx.

196 [[nodiscard]] float projectileSpeed() const noexcept {
197 return projectileSpeed_;
198 }

Reference projectileSpeed_.

setCooldownTimer()

void helios::engine::mechanics::combat::components::ShootComponent::setCooldownTimer (float cooldown)
inline noexcept

Sets the accumulated cooldown timer.

Parameters
cooldown

New timer value in seconds.

Definition at line 178 of file ShootComponent.ixx.

178 void setCooldownTimer(float cooldown) noexcept {
179 cooldownTimer_ = cooldown;
180 }

Reference cooldownTimer_.

setFireRate()

void helios::engine::mechanics::combat::components::ShootComponent::setFireRate (const float fireRate)
inline noexcept

Sets the fire rate.

Updates the cooldown delta based on the new fire rate.

Parameters
fireRate

The number of projectiles per second. Must be greater than zero.

Definition at line 235 of file ShootComponent.ixx.

235 void setFireRate(const float fireRate) noexcept {
237
240 }

References cooldownDelta_, helios::math::EPSILON_LENGTH, fireRate and fireRate_.

setProjectileSpeed()

void helios::engine::mechanics::combat::components::ShootComponent::setProjectileSpeed (float speed)
inline noexcept

Sets the projectile speed.

Parameters
speed

New projectile speed in meters per second.

Definition at line 205 of file ShootComponent.ixx.

205 void setProjectileSpeed(float speed) noexcept {
206 projectileSpeed_ = speed;
207 }

Reference projectileSpeed_.

shoot()

void helios::engine::mechanics::combat::components::ShootComponent::shoot (const float intensity, const helios::math::vec3f sourceVelocity)
inline

Sets the shooting intensity.

Call with a non-zero value to start shooting, or zero to stop. The intensity affects whether projectiles are spawned during update().

Parameters
intensity

Fire intensity (0.0 to 1.0). Zero stops firing.

sourceVelocity

The velocity of the object emitting the projectile.

Definition at line 135 of file ShootComponent.ixx.

135 void shoot(const float intensity, const helios::math::vec3f sourceVelocity) {
136
138 intensity_ = 0.0f;
139 return;
140 }
143 }

References helios::math::EPSILON_LENGTH, intensity, intensity_, shoot, sourceVelocity and sourceVelocity_.

Referenced by shoot.

sourceVelocity()

helios::math::vec3f helios::engine::mechanics::combat::components::ShootComponent::sourceVelocity ()
inline nodiscard noexcept

Returns the source object's velocity.

Returns

Velocity vector used for projectile trajectory adjustment.

Definition at line 215 of file ShootComponent.ixx.

215 [[nodiscard]] helios::math::vec3f sourceVelocity() const noexcept {
216 return sourceVelocity_;
217 }

Reference sourceVelocity_.

Referenced by shoot.

updateCooldownTimerBy()

void helios::engine::mechanics::combat::components::ShootComponent::updateCooldownTimerBy (float delta)
inline noexcept

Adds delta time to the cooldown timer.

Parameters
delta

Time to add in seconds.

Definition at line 187 of file ShootComponent.ixx.

187 void updateCooldownTimerBy(float delta) noexcept {
188 cooldownTimer_ += delta;
189 }

Reference cooldownTimer_.

Protected Member Attributes

cooldownDelta_

float helios::engine::mechanics::combat::components::ShootComponent::cooldownDelta_ = 0.0f
protected

Cooldown interval between shots, in seconds.

Derived from fireRate (1.0 / fireRate). Determines the minimum time that must pass between consecutive projectile spawns.

Definition at line 56 of file ShootComponent.ixx.

56 float cooldownDelta_ = 0.0f;

Referenced by cooldownDelta and setFireRate.

cooldownTimer_

float helios::engine::mechanics::combat::components::ShootComponent::cooldownTimer_ = 0.0f
protected

Accumulated time since last shot, in seconds.

Accumulates delta time multiplied by intensity. When this value exceeds cooldownDelta, projectiles are spawned and the timer is reduced.

Definition at line 64 of file ShootComponent.ixx.

64 float cooldownTimer_ = 0.0f;

Referenced by cooldownTimer, setCooldownTimer and updateCooldownTimerBy.

fireRate_

float helios::engine::mechanics::combat::components::ShootComponent::fireRate_ = 1.0f
protected

Fire rate per second, i.e. projectiles than can be shot per second.

Definition at line 83 of file ShootComponent.ixx.

83 float fireRate_ = 1.0f;

Referenced by fireRate and setFireRate.

intensity_

float helios::engine::mechanics::combat::components::ShootComponent::intensity_ = 0.0f
protected

Current fire intensity (0.0 to 1.0).

Set by shoot() and cleared when intensity is zero. Controls whether projectiles are spawned during update().

Definition at line 48 of file ShootComponent.ixx.

48 float intensity_ = 0.0f;

Referenced by intensity and shoot.

isEnabled_

bool helios::engine::mechanics::combat::components::ShootComponent::isEnabled_ = true
protected

Whether this component is enabled.

Definition at line 88 of file ShootComponent.ixx.

88 bool isEnabled_ = true;

Referenced by disable, enable and isEnabled.

projectileSpeed_

float helios::engine::mechanics::combat::components::ShootComponent::projectileSpeed_ = 60.0f
protected

The projectile speed, in meters per second.

Definition at line 70 of file ShootComponent.ixx.

70 float projectileSpeed_ = 60.0f;

Referenced by projectileSpeed and setProjectileSpeed.

sourceVelocity_

helios::math::vec3f helios::engine::mechanics::combat::components::ShootComponent::sourceVelocity_
protected

Velocity of the source object in three-dimensional space.

Used to adjust the trajectory of projectiles emitted by the source's movement.

Definition at line 77 of file ShootComponent.ixx.

Referenced by shoot and sourceVelocity.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.