← API Reference Class

template<typename TStateId> asge::game::state::GameStateStack

A stack of non-owning IGameState pointers driving Update/Render/event dispatch.

#include <GameStateStack.hpp>

Ownership stays with the caller (typically Game<TStateId>'s state cache) — PushRaw/PopRaw/ReplaceRaw only ever store/erase raw pointers and fire OnEnter/OnExit at the right time. See IGameState's doc comment for how Update, Render, and OnSystemEvent each traverse the stack differently.

Public Types

#using StateType = IGameState< TStateId >

Private Attributes

#std::vector< StateType * > m_Statesprivate

Private Member Functions

#std::size_t VisibleStart() const noexceptprivate

Index of the lowest state Render() draws; the stack must be non-empty for it to be meaningful.

Public Member Functions

#void PushRaw(StateType *inState) noexcept

Calls inState->OnEnter() and pushes it as the new topmost state.

#void PopRaw() noexcept

Calls the topmost state's OnExit() and pops it.

No-op on an empty stack.

#void ReplaceRaw(StateType *inState) noexcept

Pops the current top (if any) and pushes inState in its place, at the same depth.

#std::optional< Transition< TStateId > > Update(float inDeltaTime, input::InputState const &inInput) noexcept

Updates states top-down, stopping after the first whose BlocksUpdateBelow() is true; the topmost requested transition wins.

#void Render(video::IRenderer &inRenderer) noexcept

Renders bottom-up over the visible range: walks down from the top while each state's RendersBelow() lets what's under it show through, then draws that range back up so layering is correct.

#void RenderBackground(video::IRenderer &inRenderer) noexcept

Same traversal as Render(), calling each visible state's RenderBackground() instead.

#void OnSystemEvent(event::SystemEvent const &inSysEvent) noexcept

Dispatches inSysEvent to the topmost state only.

No-op on an empty stack.

#graphics::RGBA_Color ClearColor() const noexcept

The bottom-most visible state's ClearColor(); black on an empty stack.

#bool Empty() const noexcept

True if the stack has no states.