Skip to main content

ScoreValueComponent.ixx File

Template component for storing score values on entities. More...

Included Headers

#include <type_traits> #include <helios.engine.mechanics.scoring.types.Score>

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...

namespacescoring

Score management and tracking system for game mechanics. More...

namespacecomponents

Score-related ECS components. More...

Classes Index

classScoreValueComponent<T>

Template component that stores a score value of a specific type. More...

Description

Template component for storing score values on entities.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file ScoreValueComponent.ixx
3 * @brief Template component for storing score values on entities.
4 */
5module;
6
7#include <type_traits>
8
9export module helios.engine.mechanics.scoring.components.ScoreValueComponent;
10
11
12
13import helios.engine.mechanics.scoring.types.Score;
14
16
17 /**
18 * @brief Template component that stores a score value of a specific type.
19 *
20 * Attached to entities to define the score value awarded when that entity
21 * is involved in a scoring event (e.g., enemy killed). The template parameter
22 * must derive from Score.
23 *
24 * @tparam T The score type (must derive from Score).
25 */
26 template<typename T>
27 requires std::is_base_of_v<helios::engine::mechanics::scoring::types::Score, T>
29
30 private:
31
32 /**
33 * @brief The score value instance.
34 */
35 T score_{};
36
37 /**
38 * @brief Whether this component is enabled.
39 */
40 bool isEnabled_ = true;
41
42
43 public:
44
45 /**
46 * @brief Checks whether this component is enabled.
47 *
48 * @return True if enabled, false otherwise.
49 */
50 [[nodiscard]] bool isEnabled() const noexcept {
51 return isEnabled_;
52 }
53
54 /**
55 * @brief Enables this component.
56 */
57 void enable() noexcept {
58 isEnabled_ = true;
59 }
60
61 /**
62 * @brief Disables this component.
63 */
64 void disable() noexcept {
65 isEnabled_ = false;
66 }
67
68 /**
69 * @brief Constructs a ScoreValueComponent with forwarded arguments.
70 *
71 * @tparam Args Argument types for Score construction.
72 * @param args Arguments forwarded to the Score constructor.
73 */
74 template<typename... Args>
75 explicit ScoreValueComponent(Args&&... args) : score_(std::forward<Args>(args)...) {}
76
77 /**
78 * @brief Copy constructor.
79 *
80 * @param other The component to copy from.
81 */
82 ScoreValueComponent(const ScoreValueComponent& other) : score_(other.score_) {}
83
85
86 ScoreValueComponent(ScoreValueComponent&& other) noexcept = default;
87 ScoreValueComponent& operator=(ScoreValueComponent&& other) noexcept = default;
88
89
90
91 /**
92 * @brief Returns the stored score value.
93 *
94 * @return The score instance.
95 */
96 [[nodiscard]] T score() const noexcept {
97 return score_;
98 }
99
100 };
101
102
103}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.