BVB Source Codes

CRYENGINE Show AnimActionTriState.h Source code

Return Download CRYENGINE: download AnimActionTriState.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. //
  4. //-------------------------------------------------------------------------
  5. //
  6. // Description:
  7. //  AnimAction that can handle a typical three-fragment Intro/Middle (sometimes looping)/Outro sequence.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////
  10. #ifndef __ANIM_ACTION_TRI_STATE_H__
  11. #define __ANIM_ACTION_TRI_STATE_H__
  12. #pragma once
  13.  
  14. //---------------------------------------------------------------------------------------------------
  15.  
  16. struct IAnimActionTriStateListener
  17. {
  18.         virtual ~IAnimActionTriStateListener() {}
  19.  
  20.         // Called when the action is entered (called before Intro)
  21.         virtual void OnAnimActionTriStateEnter(class CAnimActionTriState* pAction) {}
  22.  
  23.         // Called when the Intro substate starts (also when there is no animation for it)
  24.         virtual void OnAnimActionTriStateIntro(class CAnimActionTriState* pAction) {}
  25.  
  26.         // Called when the Middle substate starts (also when there is no animation for
  27.         // it or when a call to Abort() will cause the middle part to be skipped)
  28.         // Will NOT get called when the action gets trumped by a higher prio action
  29.         // during the Intro substate, or when it gets a call to ForceFinsh()
  30.         virtual void OnAnimActionTriStateMiddle(class CAnimActionTriState* pAction) {}
  31.  
  32.         // Called when the Outro substate starts (also when there is no animation for it)
  33.         // Will NOT get called when the action gets trumped by a higher prio action
  34.         // during the Middle substate, or when it gets a call to ForceFinsh()
  35.         virtual void OnAnimActionTriStateOutro(class CAnimActionTriState* pAction) {}
  36.  
  37.         // Called when the Outro substate ends (also when there is no animation for it)
  38.         // Will NOT get called when the action gets trumped by a higher prio action
  39.         // during the Outro substate, or when it gets a call to ForceFinsh()
  40.         virtual void OnAnimActionTriStateOutroEnd(class CAnimActionTriState* pAction) {}
  41.  
  42.         // Called when the action is exited (guaranteed to be called when Enter was
  43.         // called before -- except in error cases)
  44.         virtual void OnAnimActionTriStateExit(class CAnimActionTriState* pAction) {}
  45. };
  46.  
  47. //---------------------------------------------------------------------------------------------------
  48.  
  49. class CAnimActionTriState : public TAction<SAnimationContext>
  50. {
  51. public:
  52.         typedef TAction<SAnimationContext> TBase;
  53.  
  54.         DEFINE_ACTION("TriState");
  55.  
  56.         enum ESubState
  57.         {
  58.                 eSS_None,
  59.                 eSS_Intro,
  60.                 eSS_Middle,
  61.                 eSS_Outro,
  62.                 eSS_Exit,
  63.         };
  64.  
  65.         // --------------------------------------------------------------------------
  66.  
  67.         CAnimActionTriState(int priority, FragmentID fragmentID, IAnimatedCharacter& animChar, bool oneShot, float maxMiddleDuration = -1, bool skipIntro = false, IAnimActionTriStateListener* pListener = NULL);
  68.  
  69.         // --------------------------------------------------------------------------
  70.  
  71.         // *Must* be called when the action's lifetime can be bigger than the listener's
  72.         void UnregisterListener();
  73.  
  74.         // Initialize the location that is passed as parameter "TargetPos" to CryMannequin
  75.         void InitTargetLocation(const QuatT& targetLocation);
  76.  
  77.         // Clear the location that is passed as parameter "TargetPos" to CryMannequin
  78.         void ClearTargetLocation();
  79.  
  80.         // Initialize the MovementControlMethods that will be set when this action enters
  81.         // Note: This only happens when the fragment runs on layer 0, otherwise this
  82.         // setting is ignored
  83.         void InitMovementControlMethods(EMovementControlMethod mcmHorizontal, EMovementControlMethod mcmVertical);
  84.  
  85.         // Stop the action gracefully. Intro & Outro will still play, but the middle
  86.         // part will be skipped or stopped. When the Middle part is already playing,
  87.         // it will still play fully when the action is marked as OneShot.
  88.         // Note: When in an Intro, the Middle event will still be sent and immediately
  89.         // followed by the Outro event.
  90.         // Contrast this behavior to calling ForceFinish() or when this action is
  91.         // pushed away by another, higher priority action. In that case only the Exit
  92.         // event will be sent.
  93.         void             Stop();
  94.  
  95.         inline ESubState GetSubState() const { return m_subState; }
  96.  
  97.         inline bool      IsOneShot() const   { return (m_triStateFlags & eTSF_OneShot) != 0; }
  98.  
  99. protected:
  100.         // --------------------------------------------------------------------------
  101.  
  102.         // Called when the action is entered (called before Intro)
  103.         virtual void OnEnter() {}
  104.  
  105.         // Called when the Intro substate starts (also when there is no animation for it)
  106.         virtual void OnIntro() {}
  107.  
  108.         // Called when the Middle substate starts (also when there is no animation for
  109.         // it or when a call to Abort() will cause the middle part to be skipped)
  110.         // Will NOT get called when the action gets trumped by a higher prio action
  111.         // during the Intro substate, or when it gets a call to ForceFinsh()
  112.         virtual void OnMiddle() {}
  113.  
  114.         // Called when the Outro substate starts (also when there is no animation for it)
  115.         // Will NOT get called when the action gets trumped by a higher prio action
  116.         // during the Middle substate, or when it gets a call to ForceFinsh()
  117.         virtual void OnOutro() {}
  118.  
  119.         // Called when the Outro substate ends (also when there is no animation for it)
  120.         // Will NOT get called when the action gets trumped by a higher prio action
  121.         // during the Outro substate, or when it gets a call to ForceFinsh()
  122.         virtual void OnOutroEnd() {}
  123.  
  124.         // Called when the action is exited (guaranteed to be called when Enter was
  125.         // called before -- except in error cases)
  126.         virtual void OnExit() {}
  127.  
  128.         // --------------------------------------------------------------------------
  129.  
  130.         // overrides ----------------------------------------------------------------
  131.         virtual void    OnAnimationEvent(ICharacterInstance* pCharacter, const AnimEventInstance& event) override;
  132.         virtual void    OnSequenceFinished(int layer, uint32 scopeID) override;
  133.         virtual EStatus Update(float timePassed) override;
  134.         virtual void    Enter() override;
  135.         virtual void    Exit() override;
  136.         virtual void    Install() override;
  137.         virtual void    OnRequestBlendOut(EPriorityComparison priorityComp) override;
  138.         virtual void    OnInitialise() override;
  139.         // ~overrides ----------------------------------------------------------------
  140.  
  141. protected:
  142.  
  143.         IAnimatedCharacter&          m_animChar;
  144.         IAnimActionTriStateListener* m_pListener;
  145.         ESubState                    m_subState;
  146. #ifndef _RELEASE
  147.         bool                         m_entered;
  148. #endif
  149.  
  150. private:
  151.         bool TrySetTransitionFragment(uint32 fragTagCRC);
  152.         void TransitionToNextSubState();
  153.  
  154.         enum ETriStateFlag
  155.         {
  156.                 eTSF_TargetLocation = BIT(1), // has target location
  157.                 eTSF_SkippedIntro   = BIT(2),
  158.                 eTSF_SkipMiddle     = BIT(3),
  159.                 eTSF_OneShot        = BIT(4),
  160.         };
  161.  
  162.         uint32                 m_triStateFlags;
  163.         EMovementControlMethod m_mcmHorizontal;
  164.         EMovementControlMethod m_mcmVertical;
  165.         EMovementControlMethod m_mcmHorizontalOld;
  166.         EMovementControlMethod m_mcmVerticalOld;
  167.         QuatT                  m_targetLocation;
  168.         float                  m_maxMiddleDuration;
  169.         CTimeValue             m_middleEndTime;
  170. };
  171.  
  172. #endif // __ANIM_ACTION_TRI_STATE_H__
  173.  
downloadAnimActionTriState.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top