Skip to main content

Aim2DCommand Class

Command that applies 2D aiming direction to a GameObject. More...

Declaration

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

Public Constructors Index

Aim2DCommand (const helios::engine::ecs::EntityHandle entityHandle, const helios::math::vec2f direction, const float freqFactor)

Constructs an aim command with direction and frequency. More...

Public Member Functions Index

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

Executes the aim command on a GameObject. More...

Private Member Attributes Index

const floatfreqFactor_

The analog stick magnitude determining fire frequency. More...

const helios::math::vec2fdirection_

The normalized direction vector for aiming. More...

const helios::engine::ecs::EntityHandleentityHandle_

Description

Command that applies 2D aiming direction to a GameObject.

This command encapsulates an aim request consisting of a normalized direction vector and a frequency factor derived from analog stick magnitude. When executed, it invokes Aim2DComponent::aim() to update the aiming direction and fire frequency.

info

The target GameObject must have an Aim2DComponent attached for this command to have any effect.

See Also

helios::engine::runtime::messaging::command::Command

See Also

helios::engine::mechanics::components::Aim2DComponent

Definition at line 32 of file Aim2DCommand.ixx.

Public Constructors

Aim2DCommand()

helios::engine::mechanics::combat::commands::Aim2DCommand::Aim2DCommand (const helios::engine::ecs::EntityHandle entityHandle, const helios::math::vec2f direction, const float freqFactor)
inline explicit

Constructs an aim command with direction and frequency.

Parameters
direction

Normalized 2D direction vector.

freqFactor

Magnitude of the stick input (0.0 to 1.0).

Definition at line 53 of file Aim2DCommand.ixx.

53 explicit Aim2DCommand(
54 const helios::engine::ecs::EntityHandle entityHandle,
55 const helios::math::vec2f direction,
56 const float freqFactor
57 ) :
58 entityHandle_(entityHandle),
59 direction_(direction),
60 freqFactor_(freqFactor)
61 {}

Public Member Functions

execute()

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

Executes the aim command on a GameObject.

Parameters
gameObject

The target entity with an Aim2DComponent.

Definition at line 69 of file Aim2DCommand.ixx.

69 void execute(helios::engine::runtime::world::UpdateContext& updateContext) const noexcept {
70
71 auto gameObject = updateContext.find(entityHandle_);
72
73 if (!gameObject) {
74 return;
75 }
76
77 auto* aimComponent = gameObject->get<helios::engine::mechanics::combat::components::Aim2DComponent>();
78
79 if (aimComponent) {
80 aimComponent->aim(direction_, freqFactor_);
81 }
82
83 }

Private Member Attributes

direction_

const helios::math::vec2f helios::engine::mechanics::combat::commands::Aim2DCommand::direction_

The normalized direction vector for aiming.

Definition at line 42 of file Aim2DCommand.ixx.

42 const helios::math::vec2f direction_;

entityHandle_

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

Definition at line 44 of file Aim2DCommand.ixx.

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

freqFactor_

const float helios::engine::mechanics::combat::commands::Aim2DCommand::freqFactor_

The analog stick magnitude determining fire frequency.

Definition at line 37 of file Aim2DCommand.ixx.

37 const float freqFactor_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.