Skip to main content

Move2DCommand.ixx File

Command for applying directional 2D movement to a GameObject. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespacephysics

Physics simulation and collision detection subsystem for the game engine. More...

namespacemotion

Motion physics components and systems. More...

namespacecommands

Classes Index

classMove2DCommand

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

Description

Command for applying directional 2D movement to a GameObject.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file Move2DCommand.ixx
3 * @brief Command for applying directional 2D movement to a GameObject.
4 */
5module;
6
7export module helios.engine.modules.physics.motion.commands.Move2DCommand;
8
9import helios.engine.runtime.messaging.command.TargetedCommand;
10import helios.engine.ecs.GameObject;
11import helios.math.types;
12import helios.engine.modules.physics.motion.components.Move2DComponent;
13import helios.engine.modules.physics.motion.components.DirectionComponent;
14
16
17 /**
18 * @brief Command that applies 2D directional movement to a GameObject.
19 *
20 * @details This command encapsulates a movement request consisting of a normalized
21 * direction vector and a speed factor derived from analog stick magnitude. When
22 * executed, it invokes Move2DComponent::move() to update rotation target
23 * and movement speed.
24 *
25 * @note The target GameObject must have a Move2DComponent attached for this
26 * command to have any effect.
27 *
28 * @see helios::engine::runtime::messaging::command::Command
29 * @see helios::engine::modules::physics::motion::components::Move2DComponent
30 */
32
33 /**
34 * @brief The analog stick magnitude determining movement intensity.
35 */
36 const float speedFactor_;
37
38 /**
39 * @brief The normalized direction vector for movement.
40 */
41 const helios::math::vec2f direction_;
42
43 public:
44
45 /**
46 * @brief Constructs a movement command with direction and speed.
47 *
48 * @param direction Normalized 2D direction vector.
49 * @param speedFactor Magnitude of the stick input (0.0 to 1.0).
50 */
51 explicit Move2DCommand(
52 const helios::math::vec2f direction,
53 const float speedFactor
54 ) :
55 direction_(direction),
56 speedFactor_(speedFactor)
57 {}
58
59 /**
60 * @brief Executes the movement command on a GameObject.
61 *
62 * @param gameObject The target entity with a Move2DComponent.
63 */
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 }
73
74 };
75
76
77}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.