← API Reference Class

template<typename TStateId> asge::game::Game abstract

Base for a concrete game: owns the asset/scene/VFS stack and a state::GameStateStack<TStateId>, and wires state Update() requests into stack transitions.

#include <Game.hpp>

Inherits from asge::game::details::IGame.

Inheritance

classDiagram
    class N1["asge::game::Game"]
    class N2["asge::game::details::IGame"]
    N2 <|-- N1
    click N1 href "classasge_1_1game_1_1Game.html"
    click N2 href "classasge_1_1game_1_1details_1_1IGame.html"

Collaboration

classDiagram
    class N7["asge::audio::AudioDevice"]
    class N3["asge::filesystem::VirtualFileSystem"]
    class N1["asge::game::Game"]
    class N4["asge::game::asset::AssetManager"]
    class N2["asge::game::details::IGame"]
    class N8["asge::game::project::ProjectData"]
    class N5["asge::game::scene::SceneManager"]
    class N6["asge::video::IRenderer"]
    N2 <|-- N1
    N1 --> N3 : m_Vfs
    N1 --> N4 : m_Assets
    N1 --> N5 : m_SceneManager
    N1 --> N6 : m_Renderer
    N1 --> N7 : m_AudioDev
    N1 --> N8 : m_Project
    click N7 href "classasge_1_1audio_1_1AudioDevice.html"
    click N3 href "classasge_1_1filesystem_1_1VirtualFileSystem.html"
    click N1 href "classasge_1_1game_1_1Game.html"
    click N4 href "classasge_1_1game_1_1asset_1_1AssetManager.html"
    click N2 href "classasge_1_1game_1_1details_1_1IGame.html"
    click N8 href "structasge_1_1game_1_1project_1_1ProjectData.html"
    click N5 href "classasge_1_1game_1_1scene_1_1SceneManager.html"
    click N6 href "classasge_1_1video_1_1IRenderer.html"

A derived class implements CreateState() (one case per TStateId) and calls SetInitialState() from its own constructor to seed the stack. States are cached by id in m_StateCache the first time each is needed — CreateState() only runs once per id unless InvalidateState() evicts it — so Push/Pop between the same two states doesn't reconstruct them each time.

Public Types

#using StateType = state::IGameState< TStateId >
#using Transition = state::Transition< TStateId >

Protected Attributes

#asset::AssetManager m_Assets { m_Vfs }protected
#scene::SceneManager m_SceneManager { m_Vfs }protected
#video::IRenderer & m_Rendererprotected
#audio::AudioDevice & m_AudioDevprotected
#project::ProjectData m_Projectprotected

Private Attributes

#state::GameStateStack< TStateId > m_Statesprivate
#std::unordered_map< TStateId, std::unique_ptr< StateType > > m_StateCacheprivate
#bool m_QuitRequested {false}private
#systems::PhysicsState m_PhysicsStateprivate
#float m_LastDeltaTime {0.0f}private

Private Member Functions

#StateType & GetOrCreateState(TStateId inId)private

Returns inId's cached state, creating it via CreateState() on first use.

#void ApplyTransition(Transition const &inTransition)private

Applies one state's requested Push/Pop/Replace to m_States, or flags a Quit for QuitRequested(); TransitionKind::None is a no-op.

Protected Member Functions

#virtual std::unique_ptr< StateType > CreateState(TStateId inId)=0protected

Constructs the state for inId; called at most once per id unless InvalidateState() runs.

#void SetInitialState(TStateId inId) noexceptprotected

Seeds the stack with inId as the bottom (and initially only) state.

#void InvalidateState(TStateId inId) noexceptprotected

Evicts inId's cached state, so the next transition to it calls CreateState() again.

Public Member Functions

#explicit Game(video::IRenderer &inRenderer, audio::AudioDevice &inAudioDev) noexcept
#BoolResult LoadScene(str::String const &inPath) noexcept

Loads inPath as the active scene and resolves its Sprite/Animation assets through m_Renderer.

#BoolResult LoadProject(filesystem::Path const &inPath) noexcept

Loads a .asgeproject written by the editor: mounts its VFS entries (skipping missing directories with a warning) and loads its main scene (the first listed one if none is set) as the active one.

Fails with SceneError::EmptyProject if the project lists no scenes.

#project::ProjectData const & GetProject() const noexcept

The project last passed to LoadProject(); empty before that.

#virtual void Update(float inDeltaTime, input::InputState const &inInput) override

Runs one frame over the active scene's registry in the only valid order: UI interaction, the states' own Update() (game logic), gravity, movement, path following, UI layout, one transform propagation, collisions, triggers, audio.

States never call these systems themselves.

Overrides Update
#virtual void Render(video::IRenderer &inRenderer) override

Resolves pending assets, clears with the visible state's ClearColor(), lets states draw RenderBackground(), draws the scene through RenderPipeline, then states' Render().

Overrides Render
#virtual void OnSystemEvent(event::SystemEvent const &inSysEvent) override

Called for every system event Application's loop pumps.

Overrides OnSystemEvent
#virtual bool QuitRequested() const noexcept override

True once a state has requested a clean shutdown via TransitionKind::Quit.

Overrides QuitRequested