Ver Fonte

Added ability to remove AnimationClip Listeners
Added ability to check if an AnimationClip Listener has been added

Rcmaniac25 há 11 anos atrás
pai
commit
0da4af7527

+ 197 - 6
gameplay/src/AnimationClip.cpp

@@ -56,7 +56,7 @@ AnimationClip::~AnimationClip()
         {
         {
             ListenerEvent* lEvt = **_listenerItr;
             ListenerEvent* lEvt = **_listenerItr;
             SAFE_DELETE(lEvt);
             SAFE_DELETE(lEvt);
-            ++*_listenerItr;
+			++(*_listenerItr);
         }
         }
         SAFE_DELETE(_listeners);
         SAFE_DELETE(_listeners);
     }
     }
@@ -309,9 +309,11 @@ void AnimationClip::addListener(AnimationClip::Listener* listener, unsigned long
                 {
                 {
                     float currentTime = fmodf(_elapsedTime, (float)_duration);
                     float currentTime = fmodf(_elapsedTime, (float)_duration);
                     GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
                     GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
-                    if ((_speed >= 0.0f && currentTime < eventTime && (*_listenerItr == _listeners->end() || eventTime < (**_listenerItr)->_eventTime)) || 
-                        (_speed <= 0 && currentTime > eventTime && (*_listenerItr == _listeners->begin() || eventTime > (**_listenerItr)->_eventTime)))
-                        *_listenerItr = itr;
+					if ((_speed >= 0.0f && currentTime < eventTime && (*_listenerItr == _listeners->end() || eventTime < (**_listenerItr)->_eventTime)) ||
+						(_speed <= 0 && currentTime > eventTime && (*_listenerItr == _listeners->begin() || eventTime > (**_listenerItr)->_eventTime)))
+					{
+						*_listenerItr = itr;
+					}
                 }
                 }
                 return;
                 return;
             }
             }
@@ -320,6 +322,54 @@ void AnimationClip::addListener(AnimationClip::Listener* listener, unsigned long
     }
     }
 }
 }
 
 
+void AnimationClip::removeListener(AnimationClip::Listener* listener, unsigned long eventTime)
+{
+	if (_listeners)
+	{
+		GP_ASSERT(listener);
+		std::list<ListenerEvent*>::iterator iter = std::find_if(_listeners->begin(), _listeners->end(), [&](ListenerEvent* lst){ return lst->_eventTime == eventTime && lst->_listener == listener; });
+		if (iter != _listeners->end())
+		{
+			if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+			{
+				float currentTime = fmodf(_elapsedTime, (float)_duration);
+				GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
+
+				// We the listener has not been triggered yet, then check if it is next to be triggered, remove it, and update the iterator
+				if (((_speed >= 0.0f && currentTime < eventTime) || (_speed <= 0 && currentTime > eventTime)) &&
+					*iter == **_listenerItr)
+				{
+					*_listenerItr = _listeners->erase(iter);
+					return;
+				}
+			}
+			_listeners->erase(iter);
+		}
+	}
+}
+
+bool AnimationClip::hasListener(AnimationClip::Listener* listener, unsigned long eventTime, bool triggedValid) const
+{
+	if (_listeners)
+	{
+		GP_ASSERT(listener);
+		GP_ASSERT(eventTime < _activeDuration);
+		std::list<ListenerEvent*>::iterator iter = std::find_if(_listeners->begin(), _listeners->end(), [&](ListenerEvent* lst){ return lst->_eventTime == eventTime && lst->_listener == listener; });
+		if (iter != _listeners->end())
+		{
+			// If we don't care if the listener was triggered already, then we can exit.
+			// Otherwise, we need to check the time to determine if it's past the trigger time yet.
+			if (triggedValid || !isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+			{
+				return true;
+			}
+			float currentTime = fmodf(_elapsedTime, (float)_duration);
+			return (_speed >= 0.0f && currentTime < eventTime) || (_speed <= 0 && currentTime > eventTime);
+		}
+	}
+	return false;
+}
+
 void AnimationClip::addBeginListener(AnimationClip::Listener* listener)
 void AnimationClip::addBeginListener(AnimationClip::Listener* listener)
 {
 {
     if (!_beginListeners)
     if (!_beginListeners)
@@ -329,6 +379,29 @@ void AnimationClip::addBeginListener(AnimationClip::Listener* listener)
     _beginListeners->push_back(listener);
     _beginListeners->push_back(listener);
 }
 }
 
 
+void AnimationClip::removeBeginListener(AnimationClip::Listener* listener)
+{
+	if (_beginListeners)
+	{
+		GP_ASSERT(listener);
+		std::vector<Listener*>::iterator iter = std::find(_beginListeners->begin(), _beginListeners->end(), listener);
+		if (iter != _beginListeners->end())
+		{
+			_beginListeners->erase(iter);
+		}
+	}
+}
+
+bool AnimationClip::hasBeginListener(AnimationClip::Listener* listener) const
+{
+	if (_beginListeners)
+	{
+		GP_ASSERT(listener);
+		return std::find(_beginListeners->begin(), _beginListeners->end(), listener) != _beginListeners->end();
+	}
+	return false;
+}
+
 void AnimationClip::addEndListener(AnimationClip::Listener* listener)
 void AnimationClip::addEndListener(AnimationClip::Listener* listener)
 {
 {
     if (!_endListeners)
     if (!_endListeners)
@@ -338,6 +411,29 @@ void AnimationClip::addEndListener(AnimationClip::Listener* listener)
     _endListeners->push_back(listener);
     _endListeners->push_back(listener);
 }
 }
 
 
+void AnimationClip::removeEndListener(AnimationClip::Listener* listener)
+{
+	if (_endListeners)
+	{
+		GP_ASSERT(listener);
+		std::vector<Listener*>::iterator iter = std::find(_endListeners->begin(), _endListeners->end(), listener);
+		if (iter != _endListeners->end())
+		{
+			_endListeners->erase(iter);
+		}
+	}
+}
+
+bool AnimationClip::hasEndListener(AnimationClip::Listener* listener) const
+{
+	if (_endListeners)
+	{
+		GP_ASSERT(listener);
+		return std::find(_endListeners->begin(), _endListeners->end(), listener) != _endListeners->end();
+	}
+	return false;
+}
+
 void AnimationClip::addBeginListener(const char* function)
 void AnimationClip::addBeginListener(const char* function)
 {
 {
     if (!_scriptListeners)
     if (!_scriptListeners)
@@ -348,6 +444,37 @@ void AnimationClip::addBeginListener(const char* function)
     addBeginListener(listener);
     addBeginListener(listener);
 }
 }
 
 
+void AnimationClip::removeBeginListener(const char* function)
+{
+	if (_scriptListeners)
+	{
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			ScriptListener* listener = *iter;
+
+			removeBeginListener(listener);
+			_scriptListeners->erase(iter);
+			SAFE_DELETE(listener);
+		}
+	}
+}
+
+bool AnimationClip::hasBeginListener(const char* function) const
+{
+	if (_scriptListeners)
+	{
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			return hasBeginListener(*iter);
+		}
+	}
+	return false;
+}
+
 void AnimationClip::addEndListener(const char* function)
 void AnimationClip::addEndListener(const char* function)
 {
 {
     if (!_scriptListeners)
     if (!_scriptListeners)
@@ -358,6 +485,37 @@ void AnimationClip::addEndListener(const char* function)
     addEndListener(listener);
     addEndListener(listener);
 }
 }
 
 
+void AnimationClip::removeEndListener(const char* function)
+{
+	if (_scriptListeners)
+	{
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			ScriptListener* listener = *iter;
+
+			removeEndListener(listener);
+			_scriptListeners->erase(iter);
+			SAFE_DELETE(listener);
+		}
+	}
+}
+
+bool AnimationClip::hasEndListener(const char* function) const
+{
+	if (_scriptListeners)
+	{
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			return hasEndListener(*iter);
+		}
+	}
+	return false;
+}
+
 void AnimationClip::addListener(const char* function, unsigned long eventTime)
 void AnimationClip::addListener(const char* function, unsigned long eventTime)
 {
 {
     if (!_scriptListeners)
     if (!_scriptListeners)
@@ -368,6 +526,39 @@ void AnimationClip::addListener(const char* function, unsigned long eventTime)
     addListener(listener, eventTime);
     addListener(listener, eventTime);
 }
 }
 
 
+void AnimationClip::removeListener(const char* function, unsigned long eventTime)
+{
+	if (_scriptListeners)
+	{
+		GP_ASSERT(eventTime < _activeDuration); // Do this check here, before we modify any state
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			ScriptListener* listener = *iter;
+
+			removeListener(listener, eventTime);
+			_scriptListeners->erase(iter);
+			SAFE_DELETE(listener);
+		}
+	}
+}
+
+bool AnimationClip::hasListener(const char* function, unsigned long eventTime, bool triggedValid) const
+{
+	if (_scriptListeners)
+	{
+		GP_ASSERT(eventTime < _activeDuration);
+		std::string functionRef = Game::getInstance()->getScriptController()->loadUrl(function);
+		std::vector<ScriptListener*>::iterator iter = std::find_if(_scriptListeners->begin(), _scriptListeners->end(), [&](ScriptListener* listener){ return listener->function == functionRef; });
+		if (iter != _scriptListeners->end())
+		{
+			return hasListener(*iter, eventTime, triggedValid);
+		}
+	}
+	return false;
+}
+
 bool AnimationClip::update(float elapsedTime)
 bool AnimationClip::update(float elapsedTime)
 {
 {
     if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
     if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
@@ -443,7 +634,7 @@ bool AnimationClip::update(float elapsedTime)
                 GP_ASSERT((**_listenerItr)->_listener);
                 GP_ASSERT((**_listenerItr)->_listener);
 
 
                 (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
                 (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
-                ++*_listenerItr;
+                ++(*_listenerItr);
             }
             }
         }
         }
         else
         else
@@ -455,7 +646,7 @@ bool AnimationClip::update(float elapsedTime)
                 GP_ASSERT((**_listenerItr)->_listener);
                 GP_ASSERT((**_listenerItr)->_listener);
 
 
                 (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
                 (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
-                --*_listenerItr;
+                --(*_listenerItr);
             }
             }
         }
         }
     }
     }

+ 102 - 0
gameplay/src/AnimationClip.h

@@ -231,6 +231,22 @@ public:
      */
      */
     void addBeginListener(AnimationClip::Listener* listener);
     void addBeginListener(AnimationClip::Listener* listener);
 
 
+	/**
+	 * Removes an animation begin listener.
+	 *
+	 * @param listener The listener to be removed.
+	 */
+	void removeBeginListener(AnimationClip::Listener* listener);
+
+	/**
+	 * Determine if a animation begin listener is registered to be called.
+	 *
+	 * @param listener The listener to lookup.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasBeginListener(AnimationClip::Listener* listener) const;
+
     /**
     /**
      * Adds an animation end listener.
      * Adds an animation end listener.
      *
      *
@@ -238,6 +254,22 @@ public:
      */
      */
     void addEndListener(AnimationClip::Listener* listener);
     void addEndListener(AnimationClip::Listener* listener);
 
 
+	/**
+	 * Removes an animation end listener.
+	 *
+	 * @param listener The listener to be removed.
+	 */
+	void removeEndListener(AnimationClip::Listener* listener);
+
+	/**
+	 * Determine if a animation end listener is registered to be called.
+	 *
+	 * @param listener The listener to lookup.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasEndListener(AnimationClip::Listener* listener) const;
+
     /**
     /**
      * Adds an animation listener to be called back at the specified eventTime during the playback 
      * Adds an animation listener to be called back at the specified eventTime during the playback 
      * of the AnimationClip.
      * of the AnimationClip.
@@ -249,6 +281,25 @@ public:
      */
      */
     void addListener(AnimationClip::Listener* listener, unsigned long eventTime);
     void addListener(AnimationClip::Listener* listener, unsigned long eventTime);
 
 
+	/**
+	 * Removes an animation listener assigned to the specified eventTime.
+	 *
+	 * @param listener The listener to be removed with the specified time.
+	 * @param eventTime The time of the listener to be removed.
+	 */
+	void removeListener(AnimationClip::Listener* listener, unsigned long eventTime);
+
+	/**
+	 * Determine if a animation listener is registered to be called.
+	 *
+	 * @param listener The listener to lookup.
+	 * @param eventTime The time of the listener to lookup.
+	 * @param triggedValid Return true if the listener is registered, even if it has already been called.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasListener(AnimationClip::Listener* listener, unsigned long eventTime, bool triggedValid = true) const;
+
     /**
     /**
      * Adds an animation begin listener.
      * Adds an animation begin listener.
      * 
      * 
@@ -258,6 +309,22 @@ public:
      */
      */
     void addBeginListener(const char* function);
     void addBeginListener(const char* function);
 
 
+	/**
+	 * Removes an animation begin listener.
+	 *
+	 * @param function The Lua script function to remove.
+	 */
+	void removeBeginListener(const char* function);
+
+	/**
+	 * Determine if a animation begin listener is registered to be called.
+	 *
+	 * @param function The Lua script function to lookup.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasBeginListener(const char* function) const;
+
     /**
     /**
      * Adds an animation end listener.
      * Adds an animation end listener.
      * 
      * 
@@ -267,6 +334,22 @@ public:
      */
      */
     void addEndListener(const char* function);
     void addEndListener(const char* function);
 
 
+	/**
+	 * Removes an animation end listener.
+	 *
+	 * @param function The Lua script function to remove.
+	 */
+	void removeEndListener(const char* function);
+
+	/**
+	 * Determine if a animation end listener is registered to be called.
+	 *
+	 * @param function The Lua script function to lookup.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasEndListener(const char* function) const;
+
     /**
     /**
      * Adds an animation listener to be called back at the specified eventTime during the playback 
      * Adds an animation listener to be called back at the specified eventTime during the playback 
      * of the AnimationClip.
      * of the AnimationClip.
@@ -280,6 +363,25 @@ public:
      */
      */
     void addListener(const char* function, unsigned long eventTime);
     void addListener(const char* function, unsigned long eventTime);
 
 
+	/**
+	 * Removes an animation listener assigned to the specified eventTime.
+	 *
+	 * @param function The Lua script function to remove with the specified time.
+	 * @param eventTime The time of the listener to be removed.
+	 */
+	void removeListener(const char* function, unsigned long eventTime);
+
+	/**
+	 * Determine if a animation listener is registered to be called.
+	 *
+	 * @param function The Lua script function to lookup.
+	 * @param eventTime The time of the listener to lookup.
+	 * @param triggedValid Return true if the listener is registered, even if it has already been called.
+	 *
+	 * @return true if the listener is registered to be called, false if it is not registered.
+	 */
+	bool hasListener(const char* function, unsigned long eventTime, bool triggedValid = true) const;
+
 private:
 private:
     
     
     static const unsigned char CLIP_IS_PLAYING_BIT = 0x01;             // Bit representing whether AnimationClip is a running clip in AnimationController
     static const unsigned char CLIP_IS_PLAYING_BIT = 0x01;             // Bit representing whether AnimationClip is a running clip in AnimationController

+ 443 - 0
gameplay/src/lua/lua_AnimationClip.cpp

@@ -35,10 +35,16 @@ void luaRegister_AnimationClip()
         {"getRepeatCount", lua_AnimationClip_getRepeatCount},
         {"getRepeatCount", lua_AnimationClip_getRepeatCount},
         {"getSpeed", lua_AnimationClip_getSpeed},
         {"getSpeed", lua_AnimationClip_getSpeed},
         {"getStartTime", lua_AnimationClip_getStartTime},
         {"getStartTime", lua_AnimationClip_getStartTime},
+        {"hasBeginListener", lua_AnimationClip_hasBeginListener},
+        {"hasEndListener", lua_AnimationClip_hasEndListener},
+        {"hasListener", lua_AnimationClip_hasListener},
         {"isPlaying", lua_AnimationClip_isPlaying},
         {"isPlaying", lua_AnimationClip_isPlaying},
         {"pause", lua_AnimationClip_pause},
         {"pause", lua_AnimationClip_pause},
         {"play", lua_AnimationClip_play},
         {"play", lua_AnimationClip_play},
         {"release", lua_AnimationClip_release},
         {"release", lua_AnimationClip_release},
+        {"removeBeginListener", lua_AnimationClip_removeBeginListener},
+        {"removeEndListener", lua_AnimationClip_removeEndListener},
+        {"removeListener", lua_AnimationClip_removeListener},
         {"setActiveDuration", lua_AnimationClip_setActiveDuration},
         {"setActiveDuration", lua_AnimationClip_setActiveDuration},
         {"setBlendWeight", lua_AnimationClip_setBlendWeight},
         {"setBlendWeight", lua_AnimationClip_setBlendWeight},
         {"setLoopBlendTime", lua_AnimationClip_setLoopBlendTime},
         {"setLoopBlendTime", lua_AnimationClip_setLoopBlendTime},
@@ -788,6 +794,264 @@ int lua_AnimationClip_getStartTime(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_AnimationClip_hasBeginListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasBeginListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasBeginListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_hasBeginListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_hasEndListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasEndListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasEndListener(param1);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_hasEndListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_hasListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasListener(param1, param2);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasListener(param1, param2);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_hasListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 4:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TBOOLEAN)
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    bool param3 = gameplay::ScriptUtil::luaCheckBool(state, 4);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasListener(param1, param2, param3);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TBOOLEAN)
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    bool param3 = gameplay::ScriptUtil::luaCheckBool(state, 4);
+
+                    AnimationClip* instance = getInstance(state);
+                    bool result = instance->hasListener(param1, param2, param3);
+
+                    // Push the return value onto the stack.
+                    lua_pushboolean(state, result);
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_hasListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3 or 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_AnimationClip_isPlaying(lua_State* state)
 int lua_AnimationClip_isPlaying(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -919,6 +1183,185 @@ int lua_AnimationClip_release(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_AnimationClip_removeBeginListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeBeginListener(param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeBeginListener(param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_removeBeginListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_removeEndListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeEndListener(param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeEndListener(param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_removeEndListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AnimationClip_removeListener(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<AnimationClip::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeListener(param1, param2);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
+
+                    AnimationClip* instance = getInstance(state);
+                    instance->removeListener(param1, param2);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AnimationClip_removeListener - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_AnimationClip_setActiveDuration(lua_State* state)
 int lua_AnimationClip_setActiveDuration(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 6 - 0
gameplay/src/lua/lua_AnimationClip.h

@@ -23,10 +23,16 @@ int lua_AnimationClip_getRefCount(lua_State* state);
 int lua_AnimationClip_getRepeatCount(lua_State* state);
 int lua_AnimationClip_getRepeatCount(lua_State* state);
 int lua_AnimationClip_getSpeed(lua_State* state);
 int lua_AnimationClip_getSpeed(lua_State* state);
 int lua_AnimationClip_getStartTime(lua_State* state);
 int lua_AnimationClip_getStartTime(lua_State* state);
+int lua_AnimationClip_hasBeginListener(lua_State* state);
+int lua_AnimationClip_hasEndListener(lua_State* state);
+int lua_AnimationClip_hasListener(lua_State* state);
 int lua_AnimationClip_isPlaying(lua_State* state);
 int lua_AnimationClip_isPlaying(lua_State* state);
 int lua_AnimationClip_pause(lua_State* state);
 int lua_AnimationClip_pause(lua_State* state);
 int lua_AnimationClip_play(lua_State* state);
 int lua_AnimationClip_play(lua_State* state);
 int lua_AnimationClip_release(lua_State* state);
 int lua_AnimationClip_release(lua_State* state);
+int lua_AnimationClip_removeBeginListener(lua_State* state);
+int lua_AnimationClip_removeEndListener(lua_State* state);
+int lua_AnimationClip_removeListener(lua_State* state);
 int lua_AnimationClip_setActiveDuration(lua_State* state);
 int lua_AnimationClip_setActiveDuration(lua_State* state);
 int lua_AnimationClip_setBlendWeight(lua_State* state);
 int lua_AnimationClip_setBlendWeight(lua_State* state);
 int lua_AnimationClip_setLoopBlendTime(lua_State* state);
 int lua_AnimationClip_setLoopBlendTime(lua_State* state);