Skip to main content

EmittedByComponent.ixx File

Component tracking the source entity that emitted a spawned object. 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...

namespacespawn

Entity spawning and lifecycle management. More...

namespacecomponents

Components for spawn-related entity tracking. More...

Classes Index

classEmittedByComponent

Component that tracks which entity emitted/spawned this object. More...

Description

Component tracking the source entity that emitted a spawned object.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file EmittedByComponent.ixx
3 * @brief Component tracking the source entity that emitted a spawned object.
4 */
5module;
6
7export module helios.engine.mechanics.spawn.components.EmittedByComponent;
8
9
10import helios.engine.runtime.spawn.types.SpawnProfileId;
11import helios.core.types;
12import helios.util;
13
14import helios.engine.ecs.EntityHandle;
15
17
18
19 /**
20 * @brief Component that tracks which entity emitted/spawned this object.
21 *
22 * Used to establish a relationship between a spawned entity (e.g., a projectile)
23 * and its source entity (e.g., the player or enemy that fired it). This enables
24 * game logic to attribute actions like damage or scoring to the correct source.
25 */
27
28 /**
29 * @brief Handle of the entity that emitted this object.
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 /**
64 * @brief Default constructor.
65 */
66 EmittedByComponent() = default;
67
68 /**
69 * @brief Copy constructor (creates empty state).
70 *
71 * @param other The component to copy from (state is not copied).
72 */
74
77 EmittedByComponent& operator=(EmittedByComponent&&) noexcept = default;
78
79 /**
80 * @brief Sets the source entity that emitted this object.
81 *
82 * @param source Handle of the emitting entity.
83 */
84 void setSource(const helios::engine::ecs::EntityHandle source) noexcept {
85 source_ = source;
86 }
87
88 /**
89 * @brief Returns the handle of the source entity.
90 *
91 * @return Handle of the entity that emitted this object.
92 */
93 [[nodiscard]] helios::engine::ecs::EntityHandle source() const noexcept {
94 return source_;
95 }
96
97 /**
98 * @brief Resets the component to its initial state.
99 */
100 void reset() {
102 }
103
104 /**
105 * @brief Called when this entity is acquired from a pool.
106 *
107 * @details Resets the source handle to prevent stale references.
108 */
109 void onAcquire() noexcept {
110 reset();
111 }
112
113 /**
114 * @brief Called when this entity is released back to a pool.
115 *
116 * @details Resets the source handle to prevent stale references.
117 */
118 void onRelease() noexcept {
119 reset();
120 }
121
122 };
123
124}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.