From af7b5cdb340f24f544c5ee0d51505bdb01809e90 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sun, 4 Feb 2024 00:03:35 -0600 Subject: [PATCH] * Improved logic to better handle the callback kickoff for actionAnimations happening * Also adds animation name to callback so you can work off which animation triggered it --- Engine/source/T3D/player.cpp | 21 +++++++++++++++------ Engine/source/T3D/player.h | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index c1990cc70..f2e54900a 100644 --- a/Engine/source/T3D/player.cpp +++ b/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(); } diff --git a/Engine/source/T3D/player.h b/Engine/source/T3D/player.h index b4fe44b40..6a2bb0248 100644 --- a/Engine/source/T3D/player.h +++ b/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 {