Skip to main content

Aim2DCommand.ixx File

Command for applying 2D aiming direction to GameObjects. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacemechanics

High-level gameplay systems and components for game logic. More...

namespacecombat

Combat-related gameplay systems, components, and commands. More...

namespacecommands

Combat-related commands for translating input into combat actions. More...

Classes Index

classAim2DCommand

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

Description

Command for applying 2D aiming direction to GameObjects.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file Aim2DCommand.ixx
3 * @brief Command for applying 2D aiming direction to GameObjects.
4 */
5module;
6
7export module helios.engine.mechanics.combat.commands.Aim2DCommand;
8
9import helios.engine.ecs;
10import helios.math.types;
11import helios.engine.mechanics.combat.components.Aim2DComponent;
12
13import helios.engine.runtime.world.UpdateContext;
14import helios.engine.runtime.world.GameWorld;
15
17
18 /**
19 * @brief Command that applies 2D aiming direction to a GameObject.
20 *
21 * @details This command encapsulates an aim request consisting of a normalized
22 * direction vector and a frequency factor derived from analog stick magnitude.
23 * When executed, it invokes Aim2DComponent::aim() to update the aiming direction
24 * and fire frequency.
25 *
26 * @note The target GameObject must have an Aim2DComponent attached for this
27 * command to have any effect.
28 *
29 * @see helios::engine::runtime::messaging::command::Command
30 * @see helios::engine::mechanics::components::Aim2DComponent
31 */
33
34 /**
35 * @brief The analog stick magnitude determining fire frequency.
36 */
37 const float freqFactor_;
38
39 /**
40 * @brief The normalized direction vector for aiming.
41 */
42 const helios::math::vec2f direction_;
43
44 const helios::engine::ecs::EntityHandle entityHandle_;
45 public:
46
47 /**
48 * @brief Constructs an aim command with direction and frequency.
49 *
50 * @param direction Normalized 2D direction vector.
51 * @param freqFactor Magnitude of the stick input (0.0 to 1.0).
52 */
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 {}
62
63
64 /**
65 * @brief Executes the aim command on a GameObject.
66 *
67 * @param gameObject The target entity with an Aim2DComponent.
68 */
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 }
84
85
86 };
87
88
89}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.