Skip to main content

SteeringCommand.ixx File

Command for updating the heading of 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

classSteeringCommand

Command that updates the heading direction of a GameObject. More...

Description

Command for updating the heading of a GameObject.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SteeringCommand.ixx
3 * @brief Command for updating the heading of a GameObject.
4 */
5module;
6
7export module helios.engine.modules.physics.motion.commands.SteeringCommand;
8
9import helios.engine.ecs;
10import helios.math.types;
11import helios.engine.modules.physics.motion.components.SteeringComponent;
12
13
14import helios.engine.runtime.world.UpdateContext;
15import helios.engine.runtime.world.GameWorld;
16
18
19
20 /**
21 * @brief Command that updates the heading direction of a GameObject.
22 *
23 * @details
24 * This command encapsulates a request to change the heading (facing direction)
25 * of a GameObject. It targets the SteeringComponent and applies the specified
26 * direction and turn factor (interpolation speed).
27 */
29
30
31 /**
32 * @brief The interpolation factor for the turn (0.0 to 1.0).
33 */
34 const float turnFactor_;
35
36 /**
37 * @brief The target direction vector.
38 */
39 const helios::math::vec2f direction_{};
40
41
42 const helios::engine::ecs::EntityHandle entityHandle_;
43
44 public:
45
46 /**
47 * @brief Constructs a new SteeringCommand.
48 *
49 * @param direction The target direction vector (should be normalized).
50 * @param turnFactor The speed/interpolation factor for the turn.
51 */
53 const helios::engine::ecs::EntityHandle entityHandle,
54 const helios::math::vec2f direction,
55 float turnFactor
56 ) :
57 entityHandle_(entityHandle),
58 direction_(direction),
59 turnFactor_(turnFactor)
60 {}
61
62
63 /**
64 * @brief Executes the heading update on the target GameObject.
65 *
66 * @details
67 * Retrieves the SteeringComponent from the GameObject and calls setHeading()
68 * with the stored direction and turn factor. If the component is missing,
69 * the command does nothing.
70 *
71 * @param gameObject The GameObject to apply the command to.
72 */
73 void execute(helios::engine::runtime::world::UpdateContext& updateContext) const noexcept {
74
75 auto gameObject = updateContext.find(entityHandle_);
76
77 if (!gameObject) {
78 return;
79 }
80
82
83 if (hc) {
84 hc->setHeading(direction_.toVec3(), turnFactor_);
85 }
86
87 }
88
89 };
90
91
92}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.