Skip to main content

Move2DCommand Class

Command that applies 2D directional movement to a GameObject. More...

Declaration

class helios::engine::modules::physics::motion::commands::Move2DCommand { ... }

Public Constructors Index

Move2DCommand (const helios::engine::ecs::EntityHandle entityHandle, const helios::math::vec2f direction, const float speedFactor)

Constructs a movement command with direction and speed. More...

Public Member Functions Index

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

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

Private Member Attributes Index

const floatspeedFactor_

The analog stick magnitude determining movement intensity. More...

const helios::math::vec2fdirection_

The normalized direction vector for movement. More...

const helios::engine::ecs::EntityHandleentityHandle_

Description

Command that applies 2D directional movement to a GameObject.

This command encapsulates a movement request consisting of a normalized direction vector and a speed factor derived from analog stick magnitude. When executed, it invokes Move2DComponent::move() to update rotation target and movement speed.

info

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

See Also

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

See Also

helios::engine::modules::physics::motion::components::Move2DComponent

Definition at line 35 of file Move2DCommand.ixx.

Public Constructors

Move2DCommand()

helios::engine::modules::physics::motion::commands::Move2DCommand::Move2DCommand (const helios::engine::ecs::EntityHandle entityHandle, const helios::math::vec2f direction, const float speedFactor)
inline explicit

Constructs a movement command with direction and speed.

Parameters
direction

Normalized 2D direction vector.

speedFactor

Magnitude of the stick input (0.0 to 1.0).

Definition at line 57 of file Move2DCommand.ixx.

57 explicit Move2DCommand(
58 const helios::engine::ecs::EntityHandle entityHandle,
59 const helios::math::vec2f direction,
60 const float speedFactor
61 ) :
62 entityHandle_(entityHandle),
63 direction_(direction),
64 speedFactor_(speedFactor)
65 {}

Public Member Functions

execute()

void helios::engine::modules::physics::motion::commands::Move2DCommand::execute (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Executes the movement command on a GameObject.

Parameters
gameObject

The target entity with a Move2DComponent.

Definition at line 72 of file Move2DCommand.ixx.

72 void execute(helios::engine::runtime::world::UpdateContext& updateContext) const noexcept {
73
74 auto gameObject = updateContext.find(entityHandle_);
75
76 if (!gameObject) {
77 return;
78 }
79
80 auto* moveComponent2D = gameObject->get<helios::engine::modules::physics::motion::components::Move2DComponent>();
81
82 if (moveComponent2D) {
83 moveComponent2D->move(direction_.toVec3(), speedFactor_);
84 }
85
86 }

Private Member Attributes

direction_

const helios::math::vec2f helios::engine::modules::physics::motion::commands::Move2DCommand::direction_

The normalized direction vector for movement.

Definition at line 45 of file Move2DCommand.ixx.

45 const helios::math::vec2f direction_;

entityHandle_

const helios::engine::ecs::EntityHandle helios::engine::modules::physics::motion::commands::Move2DCommand::entityHandle_

Definition at line 47 of file Move2DCommand.ixx.

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

speedFactor_

const float helios::engine::modules::physics::motion::commands::Move2DCommand::speedFactor_

The analog stick magnitude determining movement intensity.

Definition at line 40 of file Move2DCommand.ixx.

40 const float speedFactor_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.