ShootCommand Class
Command that triggers a shooting action on a GameObject. More...
Declaration
Public Constructors Index
| ShootCommand (const helios::engine::ecs::EntityHandle entityHandle, float intensity) | |
|
Constructs a ShootCommand with the specified intensity. More... | |
Public Member Functions Index
| float | intensity () const noexcept |
|
Returns the fire intensity. More... | |
| void | execute (helios::engine::runtime::world::UpdateContext &updateContext) const noexcept |
|
Executes the shoot command on the target GameObject. More... | |
Private Member Attributes Index
| const float | intensity_ |
|
The fire intensity factor (0.0 to 1.0). More... | |
| const helios::engine::ecs::EntityHandle | entityHandle_ |
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); } ```
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()
| 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.
Reference intensity.
Public Member Functions
execute()
| 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.
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.
Referenced by ShootCommand.
Private Member Attributes
entityHandle_
|
Definition at line 63 of file ShootCommand.ixx.
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.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.