From dcc6d3d5cafe47d53d1b321476bf73bb2d65ae9b Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 8 Jun 2022 16:21:40 +0200 Subject: refactor: remove unused cursor controller dependency from scene --- src/engine/engine.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/engine/engine.cpp') 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 user_input_observer, - std::shared_ptr cursor_controller) noexcept + std::shared_ptr cursor_controller, + std::shared_ptr 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 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()) { -- cgit v1.2.3-18-g5258