Skip to main content

ShootCommand Class

Command that triggers a shooting action on a GameObject. More...

Declaration

class helios::engine::mechanics::combat::commands::ShootCommand { ... }

Public Constructors Index

ShootCommand (const helios::engine::ecs::EntityHandle entityHandle, float intensity)

Constructs a ShootCommand with the specified intensity. More...

Public Member Functions Index

floatintensity () const noexcept

Returns the fire intensity. More...

voidexecute (helios::engine::runtime::world::UpdateContext &updateContext) const noexcept

Executes the shoot command on the target GameObject. More...

Private Member Attributes Index

const floatintensity_

The fire intensity factor (0.0 to 1.0). More...

const helios::engine::ecs::EntityHandleentityHandle_

Description

Command that triggers a shooting action on a GameObject.

ShootCommand is a TargetedCommand that initiates projectile firing on the target entity. The command carries an intensity value (typically from trigger pressure or button state) that controls fire rate or projectile behavior.

When executed, the command: 1. Retrieves the target's ShootComponent 2. Optionally retrieves Move2DComponent for velocity inheritance 3. Calls `ShootComponent::shoot()` with intensity and source velocity

The source velocity allows projectiles to inherit the shooter's momentum, preventing projectiles from spawning "behind" a fast-moving entity.

Example usage: ```cpp // In an input system float triggerValue = inputSnapshot.gamepadState().triggerRight(); if (triggerValue > 0.0f) { commandBuffer.add<ShootCommand>(player.guid(), triggerValue); } ```

info

The target GameObject must have a ShootComponent attached for this command to have any effect. Move2DComponent is optional.

See Also

ShootComponent

See Also

TargetedCommand

See Also

TwinStickInputSystem

Definition at line 52 of file ShootCommand.ixx.

Public Constructors

ShootCommand()

helios::engine::mechanics::combat::commands::ShootCommand::ShootCommand (const helios::engine::ecs::EntityHandle entityHandle, float intensity)
inline explicit

Constructs a ShootCommand with the specified intensity.

Parameters
intensity

Fire intensity factor (0.0 to 1.0). Typically from gamepad trigger pressure.

Definition at line 73 of file ShootCommand.ixx.

73 explicit ShootCommand(
74 const helios::engine::ecs::EntityHandle entityHandle,
75 float intensity
76 ) :
77 entityHandle_(entityHandle),
78 intensity_(intensity)
79 {}

Reference intensity.

Public Member Functions

execute()

void helios::engine::mechanics::combat::commands::ShootCommand::execute (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Executes the shoot command on the target GameObject.

Retrieves the ShootComponent and optionally the Move2DComponent from the target. Calls `ShootComponent::shoot()` with the intensity and the entity's current velocity for momentum inheritance.

Parameters
gameObject

The target entity with a ShootComponent.

Definition at line 99 of file ShootCommand.ixx.

99 void execute(helios::engine::runtime::world::UpdateContext& updateContext) const noexcept {
100
101 auto gameObject = updateContext.find(entityHandle_);
102
103 if (!gameObject) {
104 return;
105 }
106
107 auto* shootComponent = gameObject->get<helios::engine::mechanics::combat::components::ShootComponent>();
108
109 if (shootComponent) {
111
112 shootComponent->shoot(
113 intensity_,
114 m2d != nullptr ? m2d->velocity() : helios::math::vec3f{0.0f, 0.0f, 0.0f}
115 );
116 }
117
118 }

intensity()

float helios::engine::mechanics::combat::commands::ShootCommand::intensity ()
inline nodiscard noexcept

Returns the fire intensity.

Returns

The intensity value (0.0 to 1.0).

Definition at line 86 of file ShootCommand.ixx.

86 [[nodiscard]] float intensity() const noexcept {
87 return intensity_;
88 }

Referenced by ShootCommand.

Private Member Attributes

entityHandle_

const helios::engine::ecs::EntityHandle helios::engine::mechanics::combat::commands::ShootCommand::entityHandle_

Definition at line 63 of file ShootCommand.ixx.

63 const helios::engine::ecs::EntityHandle entityHandle_;

intensity_

const float helios::engine::mechanics::combat::commands::ShootCommand::intensity_

The fire intensity factor (0.0 to 1.0).

Derived from trigger pressure or button state. Higher values may affect fire rate or projectile properties.

Definition at line 60 of file ShootCommand.ixx.

60 const float intensity_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.