BGE: Fix T30179 action actuator not stoped when state changed.
authorPorteries Tristan <republicthunderbolt9@gmail.com>
Fri, 23 Oct 2015 08:41:13 +0000 (10:41 +0200)
committerPorteries Tristan <republicthunderbolt9@gmail.com>
Fri, 23 Oct 2015 08:54:08 +0000 (10:54 +0200)
The function SCA_IActuator::DecLink is now under virtual : in some case the actuator have to know when is useless.

source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/GameLogic/SCA_IActuator.h

index 372be85dacd0fff9565334ce558482bb4fc651b6..d9865c1f4fbee800d59fdc0bb7b08e885326d614 100644 (file)
@@ -336,6 +336,17 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
        return m_flag & ACT_FLAG_ACTIVE;
 }
 
+void BL_ActionActuator::DecLink()
+{
+       SCA_IActuator::DecLink();
+       /* In this case no controllers use this action actuator,
+          and it should stop its action. */
+       if (m_links == 0) {
+               KX_GameObject *obj = (KX_GameObject *)GetParent();
+               obj->StopAction(m_layer);
+       }
+}
+
 #ifdef WITH_PYTHON
 
 /* ------------------------------------------------------------------------- */
index f488b0c76a6126ae536c3e885dfcbbca1cf4fd19..a43cf0f0a7bfbf45c653d3733d90130c6941cece 100644 (file)
@@ -69,6 +69,8 @@ public:
        bAction*        GetAction() { return m_action; }
        void            SetAction(bAction* act) { m_action= act; }
 
+       virtual void DecLink();
+
 #ifdef WITH_PYTHON
 
        KX_PYMETHOD_O(BL_ActionActuator,GetChannel)
index 8c22fb39c807ad94828268853ada330ddb3dae3a..b63cb633b4e03287b654a35826bd15b2a9d92861 100644 (file)
@@ -156,7 +156,7 @@ public:
 
        void ClrLink() { m_links=0; }
        void IncLink() { m_links++; }
-       void DecLink();
+       virtual void DecLink();
        bool IsNoLink() const { return !m_links; }
        bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; }