Skip to main content

GameState.ixx File

Game state enumeration and bitmask operations. More...

Included Headers

#include <cstdint>

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

namespacegamestate

Game state management for the helios engine. More...

namespacetypes

Core types for game state management. More...

Description

Game state enumeration and bitmask operations.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file GameState.ixx
3 * @brief Game state enumeration and bitmask operations.
4 */
5module;
6
7#include <cstdint>
8
9export module helios.engine.mechanics.gamestate.types.GameState;
10
11
12
14
15 /**
16 * @brief Underlying type for GameState bitmask values.
17 */
18 using GameStateType = uint16_t;
19
20 constexpr size_t GameStateTypeSize = 16;
21
22 /**
23 * @brief Enumeration of possible game states.
24 *
25 * States can be combined using bitwise operators for masking.
26 */
27 enum class GameState : GameStateType {
28
30
31 Booting = 1 << 0,
32
33 Booted = 1 << 1,
34
35 Warmup = 1 << 2,
36
37 Title = 1 << 3,
38
39 MatchReady = 1 << 4,
40
41 Running = 1 << 5,
42
43 Paused = 1 << 6,
44
45 Shutdown = 1 << 7,
46
47
48 /**
49 * @brief Bitmask representing all base/ single-bit state flags.
50 */
52
53 /**
54 * @brief Bitmask representing any running state, i.e. any state except Booting, Booted, Warmup and Shutdown.
55 */
57
58
59 };
60
61 /**
62 * @brief Bitwise OR operator for combining game states.
63 */
64 [[nodiscard]] constexpr GameState operator|(const GameState lhs, const GameState rhs) noexcept {
65 return static_cast<GameState>(static_cast<GameStateType>(lhs) | static_cast<GameStateType>(rhs));
66 }
67
68 /**
69 * @brief Bitwise AND operator for masking game states.
70 */
71 [[nodiscard]] constexpr GameState operator&(const GameState lhs, const GameState rhs) noexcept {
72 return static_cast<GameState>(static_cast<GameStateType>(lhs) & static_cast<GameStateType>(rhs));
73 }
74
75 /**
76 * @brief Bitwise NOT operator for inverting game state bits.
77 */
78 [[nodiscard]] constexpr GameState operator~(const GameState lhs) noexcept {
79 return static_cast<GameState>((~static_cast<GameStateType>(lhs)) & static_cast<GameStateType>(GameState::Any));
80 }
81
82
83 /**
84 * @brief Checks if a flag is set in a state mask.
85 *
86 * @param mask The state mask to check.
87 * @param flag The flag to check for.
88 * @return True if the flag is set in the mask.
89 */
90 [[nodiscard]] constexpr bool hasFlag(const GameState mask, const GameState flag) noexcept {
91 return (mask & flag) == flag;
92 }
93
94}
95

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.