Skip to main content

Lives2UiTextUpdateSystem.ixx File

System that synchronises a UI text element with a LivesComponent. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespaceui

User interface components and systems for game entities. More...

namespacebinding

Data binding systems for UI components. More...

namespacesystems

UI data binding systems. More...

Classes Index

classLives2UiTextUpdateSystem

Updates UiTextComponents bound to a LivesComponent via LivesBindingComponent. More...

Description

System that synchronises a UI text element with a LivesComponent.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file Lives2UiTextUpdateSystem.ixx
3 * @brief System that synchronises a UI text element with a LivesComponent.
4 */
5module;
6
7
8#include <format>
9
10
11
12export module helios.engine.modules.ui.binding.systems.Lives2UiTextUpdateSystem;
13
14import helios.engine.mechanics.match.components;
15import helios.engine.mechanics.match.types;
16
17import helios.engine.runtime.world.GameWorld;
18import helios.engine.runtime.world.UpdateContext;
19
20
21import helios.engine.modules.ui.widgets;
22import helios.engine.modules.ui.layout;
23
24import helios.engine.mechanics.lifecycle.components.Active;
25
28
29import helios.engine.common.tags.SystemRole;
30
32
33 /**
34 * @brief Updates UiTextComponents bound to a LivesComponent via LivesBindingComponent.
35 *
36 * Each frame, the system compares the stored LivesRevision in the
37 * binding against the target's current revision. On mismatch the
38 * formatted lives value is written into the UiTextComponent.
39 */
41
42 public:
43
44
46 /**
47 * @brief Synchronises bound text elements with their target lives values.
48 *
49 * @param updateContext Current frame context.
50 */
52
53 for (auto [entity, lbc, dfc, txt, active] : updateContext.view<
58 >().whereEnabled()) {
59
60 auto go = updateContext.find(lbc->target());
61
62 if (!go) {
63 continue;
64 }
65
66 if (auto* lc = go->get<LivesComponent>()) {
67 if (lbc->livesRevision() != lc->livesRevision()) {
68 txt->setText(dfc->format(lc->lives()));
69 lbc->setLivesRevision(lc->livesRevision());
70 }
71 }
72
73 }
74 }
75
76 };
77
78}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.