Skip to main content

Aim2DComponent.ixx File

Component for handling 2D aiming direction. 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...

namespacecomponents

Combat-specific components for aiming, shooting, and attack tracking. More...

Classes Index

classAim2DComponent

Component for handling 2D aiming direction and fire frequency. More...

Description

Component for handling 2D aiming direction.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file Aim2DComponent.ixx
3 * @brief Component for handling 2D aiming direction.
4 */
5module;
6
7export module helios.engine.mechanics.combat.components.Aim2DComponent;
8
9import helios.math.types;
10import helios.engine.runtime.world.UpdateContext;
11
12
13import helios.math;
14
15import helios.engine.core.data.ComponentTypeId;
16
18
19 /**
20 * @brief Component for handling 2D aiming direction and fire frequency.
21 *
22 * @details Receives aim direction and frequency factor from Aim2DCommand.
23 * Derived classes can override to implement specific aiming behaviors such
24 * as cannon rotation or crosshair positioning.
25 *
26 * @note This is a base implementation with empty methods. Derive from this
27 * class to implement game-specific aiming logic.
28 */
30
31 protected:
32
33 /**
34 * @brief Current aim direction as normalized 2D vector.
35 */
37
38 /**
39 * @brief Current frequency factor (0.0 to 1.0) for additional fire rate control.
40 */
41 float frequency_ = 0.0f;
42
43 /**
44 * @brief Whether this component is enabled.
45 */
46 bool isEnabled_ = true;
47
48 public:
49
50 /**
51 * @brief Checks whether this component is enabled.
52 *
53 * @return True if enabled, false otherwise.
54 */
55 [[nodiscard]] bool isEnabled() const noexcept {
56 return isEnabled_;
57 }
58
59 /**
60 * @brief Enables this component.
61 */
62 void enable() noexcept {
63 isEnabled_ = true;
64 }
65
66 /**
67 * @brief Disables this component.
68 */
69 void disable() noexcept {
70 isEnabled_ = false;
71 }
72
73 Aim2DComponent() = default;
74 Aim2DComponent(const Aim2DComponent&) = default;
76 Aim2DComponent(Aim2DComponent&&) noexcept = default;
77 Aim2DComponent& operator=(Aim2DComponent&&) noexcept = default;
78
79 /**
80 * @brief Sets the aim direction and fire frequency.
81 *
82 * @param direction Normalized 2D direction vector.
83 * @param freq Fire frequency factor (0.0 to 1.0).
84 */
85 void aim(helios::math::vec2f direction, float freq) {
87 direction_ = {};
88 frequency_ = 0.0f;
89 }
91 frequency_ = freq;
92 }
93
94
95 /**
96 * @brief Returns the current aim direction.
97 *
98 * @return Const reference to the normalized 2D direction vector.
99 */
100 [[nodiscard]] const helios::math::vec2f& direction() const noexcept {
101 return direction_;
102 }
103
104 /**
105 * @brief Returns the current frequency factor.
106 *
107 * @return Fire frequency factor in range [0.0, 1.0].
108 */
109 [[nodiscard]] float frequency() const noexcept {
110 return frequency_;
111 }
112
113
114 };
115
116
117}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.