소스 검색

Merge pull request #1202 from Areloch/PlayerAnimationCallbackTweaks

Tweaks to Player's animation callbacks
Brian Roberts 1 년 전
부모
커밋
a253c8b48b
2개의 변경된 파일17개의 추가작업 그리고 7개의 파일을 삭제
  1. 15 6
      Engine/source/T3D/player.cpp
  2. 2 1
      Engine/source/T3D/player.h

+ 15 - 6
Engine/source/T3D/player.cpp

@@ -264,7 +264,7 @@ IMPLEMENT_CALLBACK( PlayerData, onLeaveLiquid, void, ( Player* obj, const char*
    "@param obj The Player object\n"
    "@param type The type of liquid the player has left\n" );
 
-IMPLEMENT_CALLBACK( PlayerData, animationDone, void, ( Player* obj ), ( obj ),
+IMPLEMENT_CALLBACK( PlayerData, animationDone, void, ( Player* obj, const char * animName), ( obj, animName),
    "@brief Called on the server when a scripted animation completes.\n\n"
    "@param obj The Player object\n"
    "@see Player::setActionThread() for setting a scripted animation and its 'hold' parameter to "
@@ -1584,6 +1584,7 @@ Player::Player()
    mActionAnimation.holdAtEnd = false;
    mActionAnimation.animateOnServer = false;
    mActionAnimation.atEnd = false;
+   mActionAnimation.callbackTripped = false;
    mState = MoveState;
    mJetting = false;
    mFalling = false;
@@ -3848,7 +3849,7 @@ void Player::setActionThread(U32 action,bool forward,bool hold,bool wait,bool fs
       mActionAnimation.atEnd           = false;
       mActionAnimation.delayTicks      = (S32)sNewAnimationTickTime;
       mActionAnimation.atEnd           = false;
-
+      mActionAnimation.callbackTripped = false;
       if (sUseAnimationTransitions && (action != PlayerData::LandAnim || !(mDataBlock->landSequenceTime > 0.0f && !mDataBlock->transitionToLand)) && (isGhost()/* || mActionAnimation.animateOnServer*/))
       {
          // The transition code needs the timeScale to be set in the
@@ -4001,14 +4002,22 @@ void Player::updateActionThread()
    if (mMountPending)
       mMountPending = (isMounted() ? 0 : (mMountPending - 1));
 
+   if (isServerObject() && (mActionAnimation.action >= PlayerData::NumTableActionAnims) && mActionAnimation.atEnd)
+   {
+      //The scripting language will get a call back when a script animation has finished...
+      //  example: When the chat menu animations are done playing...
+      bool tripCallback = false;
+      if ((!mActionAnimation.holdAtEnd)||(mActionAnimation.holdAtEnd && !mActionAnimation.callbackTripped))
+         tripCallback = true;
+      if (tripCallback)
+         mDataBlock->animationDone_callback(this, mActionAnimation.thread->getSequenceName());
+      mActionAnimation.callbackTripped = true;
+   }
+
    if ((mActionAnimation.action == PlayerData::NullAnimation) ||
        ((!mActionAnimation.waitForEnd || mActionAnimation.atEnd) &&
        (!mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0)))
    {
-      //The scripting language will get a call back when a script animation has finished...
-      //  example: When the chat menu animations are done playing...
-      if ( isServerObject() && mActionAnimation.action >= PlayerData::NumTableActionAnims )
-         mDataBlock->animationDone_callback( this );
       pickActionAnimation();
    }
 

+ 2 - 1
Engine/source/T3D/player.h

@@ -376,7 +376,7 @@ struct PlayerData: public ShapeBaseData {
    DECLARE_CALLBACK( void, doDismount, ( Player* obj ) );
    DECLARE_CALLBACK( void, onEnterLiquid, ( Player* obj, F32 coverage, const char* type ) );
    DECLARE_CALLBACK( void, onLeaveLiquid, ( Player* obj, const char* type ) );
-   DECLARE_CALLBACK( void, animationDone, ( Player* obj ) );
+   DECLARE_CALLBACK( void, animationDone, ( Player* obj, const char* animName) );
    DECLARE_CALLBACK( void, onEnterMissionArea, ( Player* obj ) );
    DECLARE_CALLBACK( void, onLeaveMissionArea, ( Player* obj ) );
    /// @}
@@ -501,6 +501,7 @@ protected:
       bool holdAtEnd;
       bool animateOnServer;
       bool atEnd;
+      bool callbackTripped;
    } mActionAnimation;
 
    struct ArmAnimation {