aboutsummaryrefslogtreecommitdiff
path: root/src/engine/engine.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-08 16:21:40 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:01 +0200
commitdcc6d3d5cafe47d53d1b321476bf73bb2d65ae9b (patch)
tree8fabd71b3f71d82a63694031dda1a89c49fb4f15 /src/engine/engine.cpp
parent3f9004b598fc8006576db9b8d2ae4e080101101b (diff)
refactor: remove unused cursor controller dependency from scene
Diffstat (limited to 'src/engine/engine.cpp')
-rw-r--r--src/engine/engine.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
index f947a45..c569c69 100644
--- a/src/engine/engine.cpp
+++ b/src/engine/engine.cpp
@@ -8,36 +8,34 @@
CLIGameEngine::CLIGameEngine(
IGameFactory game_factory,
- ISceneFactory scene_factory,
IComponentRendererFactory component_renderer_factory,
std::shared_ptr<IUserInputObserver> user_input_observer,
- std::shared_ptr<ICursorController> cursor_controller) noexcept
+ std::shared_ptr<ICursorController> cursor_controller,
+ std::shared_ptr<IScene> scene) noexcept
: _game_factory(std::move(game_factory)),
- _scene_factory(std::move(scene_factory)),
_component_renderer_factory(std::move(component_renderer_factory)),
_user_input_observer(std::move(user_input_observer)),
- _cursor_controller(std::move(cursor_controller))
+ _cursor_controller(std::move(cursor_controller)),
+ _scene(std::move(scene))
{
}
void CLIGameEngine::start() noexcept
{
- std::shared_ptr<IScene> scene = _scene_factory(_cursor_controller);
-
auto component_renderer = _component_renderer_factory(_cursor_controller);
- scene->enter();
+ _scene->enter();
- _cursor_controller->set_bounds(scene->size());
+ _cursor_controller->set_bounds(_scene->size());
- auto game = _game_factory(scene, _cursor_controller, _user_input_observer);
+ auto game = _game_factory(_scene, _cursor_controller, _user_input_observer);
game->on_start();
std::atexit(normalize_lambda(
- [this, scene, &game]()
+ [this, &game]()
{
- scene->leave();
+ _scene->leave();
game->on_exit();
}));
@@ -69,7 +67,7 @@ void CLIGameEngine::start() noexcept
game->on_update();
- for (auto [component, position] : scene->get_components())
+ for (auto [component, position] : _scene->get_components())
{
if (component->get_need_render())
{