From 4cb86d93143e15a10e525540a266bbecce04ab71 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 14 Feb 2023 13:50:32 +0300 Subject: [PATCH] Return finished animations from util::animation_manager --- libs/util/include/psemek/util/animation_manager.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/util/include/psemek/util/animation_manager.hpp b/libs/util/include/psemek/util/animation_manager.hpp index 16edfd85..98b01bf5 100644 --- a/libs/util/include/psemek/util/animation_manager.hpp +++ b/libs/util/include/psemek/util/animation_manager.hpp @@ -38,16 +38,19 @@ namespace psemek::util std::push_heap(animations_.begin(), animations_.end(), compare{}); } - void update(Time dt) + std::vector update(Time dt) { for (auto & animation : animations_) animation.time += dt; + std::vector finished; while (!animations_.empty() && animations_.front().finished()) { std::pop_heap(animations_.begin(), animations_.end(), compare{}); + finished.push_back(std::move(animations_.back().data)); animations_.pop_back(); } + return finished; } animation const * begin() const