Skip to main content

StateComponent.ixx File

Component storing current state for an entity. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacestate

Generic, template-based state management system. More...

namespacecomponents

State storage components. More...

Classes Index

classStateComponent<StateType>

Stores the current state and last transition for an entity. More...

Description

Component storing current state for an entity.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file StateComponent.ixx
3 * @brief Component storing current state for an entity.
4 */
5module;
6
7export module helios.engine.state.components.StateComponent;
8
9import helios.engine.state.types.StateTransitionId;
10import helios.engine.state.types;
11
12
14
15 /**
16 * @brief Stores the current state and last transition for an entity.
17 *
18 * @details Typically attached to the session entity to track game-wide
19 * state. Updated by the StateManager during transitions.
20 *
21 * @tparam StateType The state enum type.
22 *
23 * @see StateManager
24 * @see StateTransitionContext
25 */
26 template<typename StateType>
28
30
31 /**
32 * @brief The state that was transitioned from.
33 */
34 StateType from_ = StateType::Undefined;
35
36 /**
37 * @brief The last transition that occurred.
38 */
39 StateTransitionIdType transitionId_ = StateTransitionIdType::Undefined;
40
41 /**
42 * @brief The current state.
43 */
44 StateType state_ = StateType::Undefined;
45
46 public:
47
48 /**
49 * @brief Returns the current state.
50 *
51 * @return The current state value.
52 */
53 StateType state() const noexcept {
54 return state_;
55 }
56
57 /**
58 * @brief Returns the source state of the last transition.
59 *
60 * @return The state that was transitioned from.
61 */
62 StateType from() const noexcept {
63 return from_;
64 }
65
66 /**
67 * @brief Updates state from a transition context.
68 *
69 * @param stateTransitionContext The completed transition context.
70 */
72 from_ = stateTransitionContext.from();
73 state_ = stateTransitionContext.to();
74 transitionId_ = stateTransitionContext.transitionId();
75 }
76
77 /**
78 * @brief Returns the last transition ID.
79 *
80 * @return The transition that led to the current state.
81 */
82 StateTransitionIdType transitionId() const noexcept {
83 return transitionId_;
84 }
85
86 };
87
88
89}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.