BVB Source Codes

CRYENGINE Show FlowVehicleBase.cpp Source code

Return Download CRYENGINE: download FlowVehicleBase.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. #include "CryAction.h"
  5. #include "IVehicleSystem.h"
  6. #include "FlowVehicleBase.h"
  7. #include <CryFlowGraph/IFlowBaseNode.h>
  8.  
  9. //------------------------------------------------------------------------
  10. void CFlowVehicleBase::Init(SActivationInfo* pActivationInfo)
  11. {
  12.         m_nodeID = pActivationInfo->myID;
  13.         m_pGraph = pActivationInfo->pGraph;
  14.  
  15.         if (IEntity* pEntity = pActivationInfo->pEntity)
  16.         {
  17.                 IVehicleSystem* pVehicleSystem = CCryAction::GetCryAction()->GetIVehicleSystem();
  18.                 CRY_ASSERT(pVehicleSystem);
  19.  
  20.                 if (pVehicleSystem->GetVehicle(pEntity->GetId()))
  21.                         m_vehicleId = pEntity->GetId();
  22.         }
  23.         else
  24.                 m_vehicleId = 0;
  25. }
  26.  
  27. //------------------------------------------------------------------------
  28. void CFlowVehicleBase::Delete()
  29. {
  30.         if (IVehicle* pVehicle = GetVehicle())
  31.                 pVehicle->UnregisterVehicleEventListener(this);
  32. }
  33.  
  34. //------------------------------------------------------------------------
  35. void CFlowVehicleBase::GetConfiguration(SFlowNodeConfig& nodeConfig)
  36. {
  37. }
  38.  
  39. //------------------------------------------------------------------------
  40. void CFlowVehicleBase::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
  41. {
  42.         if (flowEvent == eFE_SetEntityId)
  43.         {
  44.                 IEntity* pEntity = pActivationInfo->pEntity;
  45.  
  46.                 if (pEntity)
  47.                 {
  48.                         IVehicleSystem* pVehicleSystem = CCryAction::GetCryAction()->GetIVehicleSystem();
  49.                         CRY_ASSERT(pVehicleSystem);
  50.  
  51.                         if (pEntity->GetId() != m_vehicleId)
  52.                         {
  53.                                 if (IVehicle* pVehicle = GetVehicle())
  54.                                         pVehicle->UnregisterVehicleEventListener(this);
  55.  
  56.                                 m_vehicleId = 0;
  57.                         }
  58.  
  59.                         if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId()))
  60.                         {
  61.                                 pVehicle->RegisterVehicleEventListener(this, "FlowVehicleBase");
  62.                                 m_vehicleId = pEntity->GetId();
  63.                         }
  64.                 }
  65.                 else
  66.                 {
  67.                         if (IVehicle* pVehicle = GetVehicle())
  68.                                 pVehicle->UnregisterVehicleEventListener(this);
  69.                 }
  70.         }
  71. }
  72.  
  73. //------------------------------------------------------------------------
  74. void CFlowVehicleBase::Serialize(SActivationInfo* pActivationInfo, TSerialize ser)
  75. {
  76. }
  77.  
  78. //------------------------------------------------------------------------
  79. void CFlowVehicleBase::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
  80. {
  81.         if (event == eVE_VehicleDeleted)
  82.                 m_vehicleId = 0;
  83. }
  84.  
  85. //------------------------------------------------------------------------
  86. IVehicle* CFlowVehicleBase::GetVehicle()
  87. {
  88.         if (!m_vehicleId)
  89.                 return NULL;
  90.  
  91.         return CCryAction::GetCryAction()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
  92. }
  93.  
downloadFlowVehicleBase.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