Răsfoiți Sursa

Add AnimationController::IsPlaying(layer) method

1vanK 9 ani în urmă
părinte
comite
eda96cd128

+ 2 - 1
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1428,7 +1428,8 @@ static void RegisterAnimationController(asIScriptEngine* engine)
     engine->RegisterObjectMethod("AnimationController", "bool SetSpeed(const String&in, float)", asMETHOD(AnimationController, SetSpeed), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetAutoFade(const String&in, float)", asMETHOD(AnimationController, SetAutoFade), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetRemoveOnCompletion(const String&in, bool)", asMETHOD(AnimationController, SetRemoveOnCompletion), asCALL_THISCALL);
-    engine->RegisterObjectMethod("AnimationController", "bool IsPlaying(const String&in) const", asMETHOD(AnimationController, IsPlaying), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimationController", "bool IsPlaying(const String&in) const", asMETHODPR(AnimationController, IsPlaying, (const String&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimationController", "bool IsPlaying(uint8) const", asMETHODPR(AnimationController, IsPlaying, (unsigned char) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool IsFadingIn(const String&in) const", asMETHOD(AnimationController, IsFadingIn), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool IsFadingOut(const String&in) const", asMETHOD(AnimationController, IsFadingOut), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool IsAtEnd(const String&in) const", asMETHOD(AnimationController, IsAtEnd), asCALL_THISCALL);

+ 12 - 0
Source/Urho3D/Graphics/AnimationController.cpp

@@ -431,6 +431,18 @@ bool AnimationController::IsPlaying(const String& name) const
     return index != M_MAX_UNSIGNED;
 }
 
+bool AnimationController::IsPlaying(unsigned char layer) const
+{
+    for (Vector<AnimationControl>::ConstIterator i = animations_.Begin(); i != animations_.End(); ++i)
+    {
+        AnimationState* state = GetAnimationState(i->hash_);
+        if (state && state->GetLayer() == layer)
+            return true;
+    }
+
+    return false;
+}
+
 bool AnimationController::IsFadingIn(const String& name) const
 {
     unsigned index;

+ 2 - 0
Source/Urho3D/Graphics/AnimationController.h

@@ -134,6 +134,8 @@ public:
 
     /// Return whether an animation is active. Note that non-looping animations that are being clamped at the end also return true.
     bool IsPlaying(const String& name) const;
+    /// Return whether any animation is active on a specific layer.
+    bool IsPlaying(unsigned char layer) const;
     /// Return whether an animation is fading in.
     bool IsFadingIn(const String& name) const;
     /// Return whether an animation is fading out.

+ 1 - 0
Source/Urho3D/LuaScript/pkgs/Graphics/AnimationController.pkg

@@ -37,6 +37,7 @@ class AnimationController : public Component
     bool SetAutoFade(const String name, float fadeOutTime);
     bool SetRemoveOnCompletion(const String name, bool removeOnCompletion);
     bool IsPlaying(const String name) const;
+    bool IsPlaying(unsigned char layer) const;
     bool IsFadingIn(const String name) const;
     bool IsFadingOut(const String name) const;
     bool IsAtEnd(const String name) const;