From cd7dff6e8cf6a7b678b359e1cf02695ad688468f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 15 Jul 2015 23:38:13 +0300 Subject: [PATCH] Provide a getter for the number of active animations --- source/animationplayer.cpp | 6 ++++++ source/animationplayer.h | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/animationplayer.cpp b/source/animationplayer.cpp index eb18f0f9..6148ed00 100644 --- a/source/animationplayer.cpp +++ b/source/animationplayer.cpp @@ -37,6 +37,12 @@ void AnimationPlayer::play_stacked(AnimatedObject &obj, const Animation &anim) obj_slot.animations.push_back(AnimationSlot(anim)); } +unsigned AnimationPlayer::get_n_active_animations(const AnimatedObject &obj) const +{ + ObjectMap::const_iterator i = objects.find(&obj); + return (i!=objects.end() ? i->second.animations.size() : 0); +} + void AnimationPlayer::stop(AnimatedObject &obj) { objects.erase(&obj); diff --git a/source/animationplayer.h b/source/animationplayer.h index cc34e16a..db338ffb 100644 --- a/source/animationplayer.h +++ b/source/animationplayer.h @@ -37,7 +37,7 @@ private: ObjectSlot(AnimatedObject &); }; - typedef std::map ObjectMap; + typedef std::map ObjectMap; ObjectMap objects; @@ -52,6 +52,9 @@ public: playing yet, the object's current matrix is used as the base. */ void play_stacked(AnimatedObject &, const Animation &); + /// Returns the number of animations currently affecting an object. + unsigned get_n_active_animations(const AnimatedObject &) const; + /// Stops any animations affecting an object. void stop(AnimatedObject &); -- 2.43.0