Skip to main content

MaxScoreObserverSystem.ixx File

System that updates MaxScoreObserverComponents from ScorePool data. 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...

namespacescoring

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

namespacesystems

Systems for score processing and observation. More...

Classes Index

classMaxScoreObserverSystem

System that propagates high score snapshots to MaxScoreObserverComponents. More...

Description

System that updates MaxScoreObserverComponents from ScorePool data.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file MaxScoreObserverSystem.ixx
3 * @brief System that updates MaxScoreObserverComponents from ScorePool data.
4 */
5module;
6
7
8#include <format>
9
10
11export module helios.engine.mechanics.scoring.systems.MaxScoreObserverSystem;
12
13import helios.engine.mechanics.scoring.ScorePoolManager;
14import helios.engine.mechanics.scoring.commands;
15import helios.engine.mechanics.scoring.components;
16import helios.engine.mechanics.scoring.types;
17
18import helios.engine.runtime.world.GameWorld;
19import helios.engine.runtime.world.UpdateContext;
20
21
22import helios.engine.modules.physics.collision.events;
23
24import helios.engine.mechanics.lifecycle.components.Active;
25
26
27import helios.util.log;
28
29
30import helios.engine.common.tags.SystemRole;
31
33
34
35 /**
36 * @brief System that propagates high score snapshots to MaxScoreObserverComponents.
37 *
38 * Each frame, queries all active entities with a MaxScoreObserverComponent
39 * and updates them with the current MaxScorePoolSnapshot from the
40 * ScorePoolManager. The component's revision-based change detection
41 * ensures that downstream consumers (e.g. UI bindings) are only notified
42 * when the high score actually changes.
43 *
44 * @see MaxScoreObserverClearSystem
45 * @see MaxScoreObserverComponent
46 * @see ScorePoolManager
47 */
49
50 /**
51 * @brief Reference to the ScorePoolManager that owns the score pools.
52 */
53 ScorePoolManager& scorePoolManager_;
54
55 public:
56
58
59 /**
60 * @brief Constructs the system with a reference to the ScorePoolManager.
61 *
62 * @param scorePoolManager The ScorePoolManager providing score pool state.
63 */
64 explicit MaxScoreObserverSystem(ScorePoolManager& scorePoolManager)
65 : scorePoolManager_(scorePoolManager) {}
66
67 /**
68 * @brief Updates all active MaxScoreObserverComponents with current high score data.
69 *
70 * @param updateContext The current frame's update context.
71 */
73
74 for (auto [entity, soc, active] : updateContext.view<
77 >().whereEnabled()) {
78
79
80 const auto scorePoolId = soc->scorePoolId();
81 auto* scorePool = scorePoolManager_.scorePool(scorePoolId);
82
83 if (!scorePool) {
84 continue;
85 }
86
87 if (soc->scorePoolRevision() != scorePool->revision()) {
88 soc->setMaxScorePoolSnapshot(scorePool->maxScoreSnapshot());
89 }
90
91
92 }
93
94 }
95
96 };
97
98}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.