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
Scene.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
9
#include "
Imago/ECS/Nexus.hpp
"
10
#include "
Imago/Engine/Broadcaster.hpp
"
11
#include "
Imago/Engine/SystemScheduler.hpp
"
12
#include "
Imago/Engine/SceneContext.hpp
"
13
14
namespace
Imago::Engine
15
{
16
24
class
Scene
{
25
protected
:
26
27
// NOTE: these members are protected because they have to be defined in the children class of Scene but should not be called
28
// directly, instead load and unload should be called directly so that they can force a flush after the user-defined logic
29
33
virtual
void
on_load
() = 0;
34
39
virtual
void
on_unload
() {}
40
41
// protected members of the ECS/Engine objects that a Scene owns, can only be acccessed in children of Scene
42
ECS::Nexus
_nexus
;
43
SceneContext
_ctx
;
44
Broadcaster
_broadcaster
;
45
SystemScheduler
_scheduler
;
46
47
public
:
48
54
explicit
Scene
(
const
SceneContext
& gameCtx);
55
56
// need a default destructor because this scene is abstract
57
virtual
~Scene
() =
default
;
58
59
// explicitly dissalow copy and move behaviour because the context holds pointers into this object
60
Scene
(
const
Scene
&) =
delete
;
61
Scene
& operator=(
const
Scene
&) =
delete
;
62
Scene
(
Scene
&&) =
delete
;
63
Scene
& operator=(
Scene
&&) =
delete
;
64
68
void
load
();
69
73
void
unload
();
74
79
void
update
(
float
dt);
80
81
//TODO: render method
82
};
83
84
}
Broadcaster.hpp
Defines the Broadcaster to emit events for subscribed systems.
Nexus.hpp
Defines the Nexus, the brain of the ECS world.
SceneContext.hpp
Defines the SceneContext, how systems reach persistent engine objects.
SystemScheduler.hpp
Defines the SystemScheduler, which runs scheduled systems in order every frame.
Imago::ECS::Nexus
the Nexus is the brain of the ECS world. It is the object the user will use to interact with everythi...
Definition
Nexus.hpp:84
Imago::Engine::Broadcaster
Broadcaster acts as ImagoEngine's event system. It lets systems communicate without knowing about eac...
Definition
Broadcaster.hpp:70
Imago::Engine::Scene::on_load
virtual void on_load()=0
Called by load(). Behavior is defined in user definitions of Scenes were the user can create entities...
Imago::Engine::Scene::Scene
Scene(const SceneContext &gameCtx)
Construct a new Scene object and copies the game's persistent context and fills the remaining pointer...
Definition
Scene.cpp:5
Imago::Engine::Scene::_nexus
ECS::Nexus _nexus
scene's Nexus
Definition
Scene.hpp:42
Imago::Engine::Scene::update
void update(float dt)
Runs one frame by ticking the scheduler, then flushes the Nexus.
Definition
Scene.cpp:25
Imago::Engine::Scene::_scheduler
SystemScheduler _scheduler
runs this scene's scheduled systems
Definition
Scene.hpp:45
Imago::Engine::Scene::unload
void unload()
Unloads the scene. Runs the user-defined on_unload() method then flushes everything.
Definition
Scene.cpp:18
Imago::Engine::Scene::_broadcaster
Broadcaster _broadcaster
scene's event bus
Definition
Scene.hpp:44
Imago::Engine::Scene::on_unload
virtual void on_unload()
Called by unload(). This is optional in user definitions of Scenes because most clean-up is handled a...
Definition
Scene.hpp:39
Imago::Engine::Scene::load
void load()
Loads the scene. Runs the user-defined on_load() method then flushes everything so they actually go t...
Definition
Scene.cpp:12
Imago::Engine::Scene::_ctx
SceneContext _ctx
scene's own copy of the context passed into every system
Definition
Scene.hpp:43
Imago::Engine::SystemScheduler
Definition
SystemScheduler.hpp:22
Imago::Engine::SceneContext
Gives systems access to the persistent engine objects they could need.
Definition
SceneContext.hpp:30
engine
include
Imago
Engine
Scene.hpp
Generated by
1.15.0