BVB Source Codes

CRYENGINE Show FlowVehicleHandbrake.cpp Source code

Return Download CRYENGINE: download FlowVehicleHandbrake.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Implements a flow node to enable/disable vehicle handbrake.
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 15:04:2010: Created by Paul Slinger
  12.  
  13. *************************************************************************/
  14.  
  15. #include "StdAfx.h"
  16. #include "CryAction.h"
  17. #include "IVehicleSystem.h"
  18. #include "VehicleSystem/Vehicle.h"
  19. #include "FlowVehicleHandbrake.h"
  20. #include <CryFlowGraph/IFlowBaseNode.h>
  21.  
  22. //------------------------------------------------------------------------
  23. CFlowVehicleHandbrake::CFlowVehicleHandbrake(SActivationInfo* pActivationInfo)
  24. {
  25.         Init(pActivationInfo);
  26. }
  27.  
  28. //------------------------------------------------------------------------
  29. CFlowVehicleHandbrake::~CFlowVehicleHandbrake()
  30. {
  31.         Delete();
  32. }
  33.  
  34. //------------------------------------------------------------------------
  35. IFlowNodePtr CFlowVehicleHandbrake::Clone(SActivationInfo* pActivationInfo)
  36. {
  37.         return new CFlowVehicleHandbrake(pActivationInfo);
  38. }
  39.  
  40. //------------------------------------------------------------------------
  41. void CFlowVehicleHandbrake::GetConfiguration(SFlowNodeConfig& nodeConfig)
  42. {
  43.         CFlowVehicleBase::GetConfiguration(nodeConfig);
  44.  
  45.         static const SInputPortConfig pInConfig[] =
  46.         {
  47.                 InputPortConfig<SFlowSystemVoid>("Activate",   _HELP("Activate handbrake")),
  48.                 InputPortConfig<SFlowSystemVoid>("Deactivate", _HELP("Deactivate handbrake")),
  49.                 InputPortConfig<float>("ResetTimer",           5.0f,                          _HELP("Time (in seconds) before handbrake is re-activated")),
  50.                 { 0 }
  51.         };
  52.  
  53.         static const SOutputPortConfig pOutConfig[] =
  54.         {
  55.                 { 0 }
  56.         };
  57.  
  58.         nodeConfig.sDescription = _HELP("Toggle vehicle handbrake");
  59.         nodeConfig.pInputPorts = pInConfig;
  60.         nodeConfig.pOutputPorts = pOutConfig;
  61.  
  62.         nodeConfig.nFlags |= EFLN_TARGET_ENTITY;
  63.  
  64.         nodeConfig.SetCategory(EFLN_APPROVED);
  65. }
  66.  
  67. //------------------------------------------------------------------------
  68. void CFlowVehicleHandbrake::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
  69. {
  70.         CFlowVehicleBase::ProcessEvent(flowEvent, pActivationInfo);
  71.  
  72.         if (flowEvent == eFE_Activate)
  73.         {
  74.                 if (IVehicle* pVehicle = GetVehicle())
  75.                 {
  76.                         bool activate = IsPortActive(pActivationInfo, eIn_Activate);
  77.  
  78.                         bool deactivate = IsPortActive(pActivationInfo, eIn_Deactivate);
  79.  
  80.                         if (activate || deactivate)
  81.                         {
  82.                                 SVehicleMovementEventParams vehicleMovementEventParams;
  83.  
  84.                                 vehicleMovementEventParams.bValue = activate;
  85.                                 vehicleMovementEventParams.fValue = GetPortFloat(pActivationInfo, eIn_ResetTimer);
  86.  
  87.                                 pVehicle->GetMovement()->OnEvent(IVehicleMovement::eVME_EnableHandbrake, vehicleMovementEventParams);
  88.                         }
  89.                 }
  90.         }
  91. }
  92.  
  93. //------------------------------------------------------------------------
  94. void CFlowVehicleHandbrake::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
  95. {
  96.         CFlowVehicleBase::OnVehicleEvent(event, params);
  97. }
  98.  
  99. //------------------------------------------------------------------------
  100. void CFlowVehicleHandbrake::GetMemoryUsage(ICrySizer* pCrySizer) const
  101. {
  102.         pCrySizer->Add(*this);
  103. }
  104.  
  105. REGISTER_FLOW_NODE("Vehicle:Handbrake", CFlowVehicleHandbrake);
  106.  
downloadFlowVehicleHandbrake.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