From a5149adafb7d8fe52e4a2f867571eb96dbc23271 Mon Sep 17 00:00:00 2001 From: milerius Date: Sun, 27 Oct 2019 11:57:24 +0100 Subject: [PATCH] feat(ecs): add post_update functionality --- modules/scenes/antara/gaming/scenes/base.scene.hpp | 1 + modules/scenes/antara/gaming/scenes/scene.manager.cpp | 7 +++++++ modules/scenes/antara/gaming/scenes/scene.manager.hpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/modules/scenes/antara/gaming/scenes/base.scene.hpp b/modules/scenes/antara/gaming/scenes/base.scene.hpp index 84af3268..85076954 100644 --- a/modules/scenes/antara/gaming/scenes/base.scene.hpp +++ b/modules/scenes/antara/gaming/scenes/base.scene.hpp @@ -33,6 +33,7 @@ namespace antara::gaming::scenes base_scene(entt::registry &entity_registry) noexcept; virtual void update() noexcept = 0; + virtual void post_update() noexcept {}; virtual bool on_key_pressed(const event::key_pressed &) noexcept { return true; }; diff --git a/modules/scenes/antara/gaming/scenes/scene.manager.cpp b/modules/scenes/antara/gaming/scenes/scene.manager.cpp index 2c224a00..7ec5a876 100644 --- a/modules/scenes/antara/gaming/scenes/scene.manager.cpp +++ b/modules/scenes/antara/gaming/scenes/scene.manager.cpp @@ -113,4 +113,11 @@ namespace antara::gaming::scenes this->dispatcher_.sink().disconnect<&manager::receive_change_scene>(*this); } + void manager::post_update() noexcept + { + if (not scenes_.empty()) { + scenes_.top()->post_update(); + } + } + } diff --git a/modules/scenes/antara/gaming/scenes/scene.manager.hpp b/modules/scenes/antara/gaming/scenes/scene.manager.hpp index 2046f681..0889199e 100644 --- a/modules/scenes/antara/gaming/scenes/scene.manager.hpp +++ b/modules/scenes/antara/gaming/scenes/scene.manager.hpp @@ -44,6 +44,8 @@ namespace antara::gaming::scenes //! void update() noexcept final; + void post_update() noexcept final; + //! Public member function void change_scene(scene_ptr &&scene, bool just_push_scene = false) noexcept;