BVB Source Codes

CRYENGINE Show VehicleSeatActionPassiveAnimation.cpp Source code

Return Download CRYENGINE: download VehicleSeatActionPassiveAnimation.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4.  
  5. #include "IVehicleSystem.h"
  6. #include "VehicleSeatActionPassiveAnimation.h"
  7.  
  8. CVehicleSeatActionPassiveAnimation::CVehicleSeatActionPassiveAnimation()
  9.         : m_pAnimationAction(NULL)
  10.         , m_animationFragmentID(FRAGMENT_ID_INVALID)
  11.         , m_pVehicle(NULL)
  12.         , m_userId((EntityId)0)
  13. {
  14. }
  15.  
  16. CVehicleSeatActionPassiveAnimation::~CVehicleSeatActionPassiveAnimation()
  17. {
  18.         StopAnimation();
  19. }
  20.  
  21. bool CVehicleSeatActionPassiveAnimation::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table)
  22. {
  23.         m_pVehicle = pVehicle;
  24.  
  25.         const char* fragmentName = table.getAttr("FragmentID");
  26.         if (fragmentName == NULL)
  27.         {
  28.                 return false;
  29.         }
  30.         if (fragmentName[0] == '\0')
  31.         {
  32.                 return false;
  33.         }
  34.  
  35.         IActionController* pActionController = m_pVehicle->GetAnimationComponent().GetActionController();
  36.         if (pActionController == NULL)
  37.         {
  38.                 return false;
  39.         }
  40.  
  41.         m_animationFragmentID = pActionController->GetContext().controllerDef.m_fragmentIDs.Find(fragmentName);
  42.         if (m_animationFragmentID == FRAGMENT_ID_INVALID)
  43.         {
  44.                 CryLog("CVehicleSeatActionPassiveAnimation::Init(): Unable to find animation fragment ID '%s'!", fragmentName);
  45.                 return false;
  46.         }
  47.  
  48.         return true;
  49. }
  50.  
  51. void CVehicleSeatActionPassiveAnimation::Reset()
  52. {
  53.         if (m_userId != (EntityId)0)
  54.         {
  55.                 StartAnimation();
  56.         }
  57.         else
  58.         {
  59.                 StopAnimation();
  60.         }
  61. }
  62.  
  63. void CVehicleSeatActionPassiveAnimation::StartUsing(EntityId passengerId)
  64. {
  65.         m_userId = passengerId;
  66.  
  67.         if (m_animationFragmentID != FRAGMENT_ID_INVALID)
  68.         {
  69.                 StartAnimation();
  70.                 m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_PassengerUpdate);
  71.         }
  72. }
  73.  
  74. void CVehicleSeatActionPassiveAnimation::StopUsing()
  75. {
  76.         if (m_animationFragmentID != FRAGMENT_ID_INVALID)
  77.         {
  78.                 StopAnimation();
  79.                 m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_NoUpdate);
  80.         }
  81.         m_userId = (EntityId)0;
  82. }
  83.  
  84. void CVehicleSeatActionPassiveAnimation::Serialize(TSerialize ser, EEntityAspects aspects)
  85. {
  86.         if (ser.GetSerializationTarget() != eST_Network)
  87.         {
  88.         }
  89. }
  90.  
  91. void CVehicleSeatActionPassiveAnimation::StartAnimation()
  92. {
  93.         if ((m_animationFragmentID != FRAGMENT_ID_INVALID) && (m_pAnimationAction == NULL))
  94.         {
  95.                 IActionController* pActionController = m_pVehicle->GetAnimationComponent().GetActionController();
  96.                 if (pActionController != NULL)
  97.                 {
  98.                         m_pAnimationAction = new TAction<SAnimationContext>(
  99.                           IVehicleAnimationComponent::ePriority_SeatDefault,
  100.                           m_animationFragmentID,
  101.                           TAG_STATE_EMPTY);
  102.                         m_pAnimationAction->AddRef();
  103.                         pActionController->Queue(*m_pAnimationAction);
  104.                 }
  105.         }
  106. }
  107.  
  108. void CVehicleSeatActionPassiveAnimation::StopAnimation()
  109. {
  110.         if (m_pAnimationAction != NULL)
  111.         {
  112.                 m_pAnimationAction->Stop(); // Just Stop() to trigger blend-transitions.
  113.                 SAFE_RELEASE(m_pAnimationAction);
  114.         }
  115. }
  116.  
  117. DEFINE_VEHICLEOBJECT(CVehicleSeatActionPassiveAnimation);
  118.  
downloadVehicleSeatActionPassiveAnimation.cpp 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