Skip to content

Commit

Permalink
feat(ecs): add post_update functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Oct 27, 2019
1 parent 5eb0676 commit a5149ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/scenes/antara/gaming/scenes/base.scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down
7 changes: 7 additions & 0 deletions modules/scenes/antara/gaming/scenes/scene.manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ namespace antara::gaming::scenes
this->dispatcher_.sink<event::change_scene>().disconnect<&manager::receive_change_scene>(*this);
}

void manager::post_update() noexcept
{
if (not scenes_.empty()) {
scenes_.top()->post_update();
}
}

}
2 changes: 2 additions & 0 deletions modules/scenes/antara/gaming/scenes/scene.manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a5149ad

Please sign in to comment.