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 { ... }

Base class

classTargetedCommand

Abstract base class for commands targeting a specific GameObject. More...

Public Constructors Index

Move2DCommand (const helios::math::vec2f direction, const float speedFactor)

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

Public Member Functions Index

voidexecute (helios::engine::ecs::GameObject gameObject) const noexcept override

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...

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 31 of file Move2DCommand.ixx.

Public Constructors

Move2DCommand()

helios::engine::modules::physics::motion::commands::Move2DCommand::Move2DCommand (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 51 of file Move2DCommand.ixx.

51 explicit Move2DCommand(
52 const helios::math::vec2f direction,
53 const float speedFactor
54 ) :
55 direction_(direction),
56 speedFactor_(speedFactor)
57 {}

Public Member Functions

execute()

void helios::engine::modules::physics::motion::commands::Move2DCommand::execute (helios::engine::ecs::GameObject gameObject)
inline noexcept virtual

Executes the movement command on a GameObject.

Parameters
gameObject

The target entity with a Move2DComponent.

Definition at line 64 of file Move2DCommand.ixx.

64 void execute(helios::engine::ecs::GameObject gameObject) const noexcept override {
65
66 auto* moveComponent2D = gameObject.get<helios::engine::modules::physics::motion::components::Move2DComponent>();
67
68 if (moveComponent2D) {
69 moveComponent2D->move(direction_.toVec3(), speedFactor_);
70 }
71
72 }

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 41 of file Move2DCommand.ixx.

41 const helios::math::vec2f direction_;

speedFactor_

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

The analog stick magnitude determining movement intensity.

Definition at line 36 of file Move2DCommand.ixx.

36 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.