ImagoEngine
A C++ 2D game engine built on a sparse-set ECS, with scenes, scheduled systems, events, and action-based input
Loading...
Searching...
No Matches
Imago::Engine::Scene Class Referenceabstract

Abstract Base Class for every Scene. Users inherit from this class and override on_load() and optionally on_unload() in order to create their entites, registers systems, and subscribe to events. More...

#include <Imago/Engine/Scene.hpp>

Collaboration diagram for Imago::Engine::Scene:

Public Member Functions

 Scene (const SceneContext &gameCtx)
 Construct a new Scene object and copies the game's persistent context and fills the remaining pointers with this scene's instance of the Nexus and Broadcaster.
 Scene (const Scene &)=delete
Scene & operator= (const Scene &)=delete
 Scene (Scene &&)=delete
Scene & operator= (Scene &&)=delete
void load ()
 Loads the scene. Runs the user-defined on_load() method then flushes everything so they actually go through before the first frame of execution.
void unload ()
 Unloads the scene. Runs the user-defined on_unload() method then flushes everything.
void update (float dt)
 Runs one frame by ticking the scheduler, then flushes the Nexus.

Protected Member Functions

virtual void on_load ()=0
 Called by load(). Behavior is defined in user definitions of Scenes were the user can create entities, register systems, and subscribe to events.
virtual void on_unload ()
 Called by unload(). This is optional in user definitions of Scenes because most clean-up is handled automatically but any additional clean up that ought to happen during the termination of a Scene should go here.

Protected Attributes

ECS::Nexus _nexus
 scene's Nexus
SceneContext _ctx
 scene's own copy of the context passed into every system
Broadcaster _broadcaster
 scene's event bus
SystemScheduler _scheduler
 runs this scene's scheduled systems

Detailed Description

Abstract Base Class for every Scene. Users inherit from this class and override on_load() and optionally on_unload() in order to create their entites, registers systems, and subscribe to events.

A Scene owns everything that its systems run against. It owns its own copy of the SceneContext with nexus and broadcaster pointing at its own members so the Scene must stay self-consistent for its whole life.

Constructor & Destructor Documentation

◆ Scene()

Imago::Engine::Scene::Scene ( const SceneContext & gameCtx)
explicit

Construct a new Scene object and copies the game's persistent context and fills the remaining pointers with this scene's instance of the Nexus and Broadcaster.

Parameters
gameCtxGame's SceneContext with global Game objects filled in.

Member Function Documentation

◆ update()

void Imago::Engine::Scene::update ( float dt)

Runs one frame by ticking the scheduler, then flushes the Nexus.

Parameters
dtReal time since the last frame, in seconds.

The documentation for this class was generated from the following files:
  • engine/include/Imago/Engine/Scene.hpp
  • engine/src/Engine/Scene.cpp