Skip to main content

StateToViewportPolicyUpdateSystem.ixx File

System that updates active viewports based on game/match state. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacemodules

Domain-specific components and systems. More...

namespacerendering

Rendering components for game entities. More...

namespaceviewport

State-based viewport management for conditional rendering. More...

namespacesystems

Systems for viewport state updates. More...

Classes Index

classStateToViewportPolicyUpdateSystem<StateLft, StateRgt>

Updates the session's active viewport list based on state policy. More...

Description

System that updates active viewports based on game/match state.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file StateToViewportPolicyUpdateSystem.ixx
3 * @brief System that updates active viewports based on game/match state.
4 */
5module;
6
7
8#include <cassert>
9#include <vector>
10
11export module helios.engine.modules.rendering.viewport.systems.StateToViewportPolicyUpdateSystem;
12
13import helios.engine.runtime.world.GameWorld;
14import helios.engine.runtime.world.Session;
15
16import helios.engine.state.StateToIdMapPair;
17
18
19import helios.engine.runtime.world.UpdateContext;
20
21import helios.engine.common.types.ViewportId;
22
23using namespace helios::engine::state;
25
26import helios.engine.common.tags.SystemRole;
27
29
30 /**
31 * @brief Updates the session's active viewport list based on state policy.
32 *
33 * @details Queries the current states from the session using the configured
34 * template parameters, then uses StateToIdMapPair to determine which viewports
35 * should be active. The resulting viewport IDs are stored in the session
36 * for use by the rendering system.
37 *
38 * ## Usage
39 *
40 * ```cpp
41 * StateToIdMapPair<GameState, MatchState, ViewportId> policy;
42 * policy.add(GameState::Running, ViewportId("game"));
43 * policy.add(MatchState::GameOver, ViewportId("game_over"));
44 * policy.freeze();
45 *
46 * gameLoop.phase(PhaseType::Pre)
47 * .addPass<GameState>(GameState::Any)
48 * .addSystem<StateToViewportPolicyUpdateSystem<GameState, MatchState>>(
49 * std::move(policy)
50 * );
51 * ```
52 *
53 * @tparam StateLft The left/primary state type (e.g., GameState).
54 * @tparam StateRgt The right/secondary state type (e.g., MatchState).
55 *
56 * @see StateToIdMapPair
57 * @see Session
58 */
59 template<typename StateLft, typename StateRgt>
61
62 /**
63 * @brief Policy defining viewport-to-state mappings.
64 */
66
67 public:
68
70
71 /**
72 * @brief Constructs the system with a state-to-ID map pair.
73 *
74 * @param stateToIdMapPair Policy mapping states to viewport IDs.
75 */
77 : stateToIdMapPair_(std::move(stateToIdMapPair)){}
78
79 /**
80 * @brief Updates the session's active viewport IDs.
81 *
82 * @details Clears the current viewport IDs and sets them based on
83 * the current game and match state combination.
84 *
85 * @param updateContext The current frame's update context.
86 */
88
89 auto& session = updateContext.session();
90
91 auto gameState = session.state<StateLft>();
92 auto matchState = session.state<StateRgt>();
93
94 session.clearViewportIds();
95
96 auto viewportIds = stateToIdMapPair_.ids(gameState, matchState);
97 session.setViewportIds(viewportIds);
98
99
100
101
102 }
103
104 };
105
106}
107

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.