Skip to main content

LastDamageComponent.ixx File

Component for tracking the last entity that attacked this entity. 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...

namespacedamage

Damage dealing system for game entities. More...

namespacecomponents

Damage-related ECS components. More...

Classes Index

classLastDamageComponent

Component that stores information about the last damage received. More...

Description

Component for tracking the last entity that attacked this entity.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file LastDamageComponent.ixx
3 * @brief Component for tracking the last entity that attacked this entity.
4 */
5module;
6
7export module helios.engine.mechanics.damage.components.LastDamageComponent;
8
9
10
11import helios.engine.common.types.DamageContext;
12
14
16
17 /**
18 * @brief Component that stores information about the last damage received.
19 *
20 * Used to track which entity last dealt damage to this entity. This enables
21 * attribution of kills for scoring and other game logic. The damage context
22 * is updated by the damage system when damage is applied.
23 */
25
26 private:
27
28 /**
29 * @brief Context of the most recent damage received.
30 */
32
33 /**
34 * @brief Whether this component is enabled.
35 */
36 bool isEnabled_ = true;
37
38 public:
39
40 /**
41 * @brief Checks whether this component is enabled.
42 *
43 * @return True if enabled, false otherwise.
44 */
45 [[nodiscard]] bool isEnabled() const noexcept {
46 return isEnabled_;
47 }
48
49 /**
50 * @brief Enables this component.
51 */
52 void enable() noexcept {
53 isEnabled_ = true;
54 }
55
56 /**
57 * @brief Disables this component.
58 */
59 void disable() noexcept {
60 isEnabled_ = false;
61 }
62
63 LastDamageComponent() = default;
64
65 /**
66 * @brief Copy constructor (creates empty state).
67 *
68 * @param other The component to copy from (state is not copied).
69 */
70 LastDamageComponent(const LastDamageComponent& other) = default;
71
74 LastDamageComponent& operator=(LastDamageComponent&&) noexcept = default;
75
76 /**
77 * @brief Sets the last damage context.
78 *
79 * @param damageContext The damage context to store.
80 */
82 damageContext_ = damageContext;
83 }
84
85 /**
86 * @brief Returns the last damage context.
87 *
88 * @return The stored AttackContext.
89 */
90 [[nodiscard]] DamageContext damageContext() const noexcept {
91 return damageContext_;
92 }
93
94 /**
95 * @brief Resets the component to its initial state.
96 */
97 void reset() {
98 damageContext_ = {};
99 }
100
101 /**
102 * @brief Called when this entity is acquired from a pool.
103 *
104 * @details Resets the damage context to ensure no stale data.
105 */
106 void onAcquire() noexcept {
107 reset();
108 }
109
110 /**
111 * @brief Called when this entity is released back to a pool.
112 *
113 * @details Resets the damage context to ensure no stale data.
114 */
115 void onRelease() noexcept {
116 reset();
117 }
118
119 };
120
121
122}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.