BVB Source Codes

CRYENGINE Show FlowVehicleMoveActionMult.cpp Source code

Return Download CRYENGINE: download FlowVehicleMoveActionMult.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 apply multipliers to vehicle
  8.    movement actions
  9.  
  10.    -------------------------------------------------------------------------
  11.    History:
  12.    - 26:01:2006: Created by Mathieu Pinard
  13.  
  14. *************************************************************************/
  15. #include "StdAfx.h"
  16. #include "CryAction.h"
  17. #include "IVehicleSystem.h"
  18. #include "FlowVehicleMoveActionMult.h"
  19.  
  20. #include <CryFlowGraph/IFlowBaseNode.h>
  21.  
  22. //------------------------------------------------------------------------
  23. CFlowVehicleMoveActionMult::CFlowVehicleMoveActionMult(SActivationInfo* pActivationInfo)
  24.         : m_powerMult(1.0f),
  25.         m_pitchMult(1.0f),
  26.         m_yawMult(1.0f),
  27.         m_powerMustBePositive(false)
  28. {
  29.         Init(pActivationInfo);
  30. }
  31.  
  32. //------------------------------------------------------------------------
  33. IFlowNodePtr CFlowVehicleMoveActionMult::Clone(SActivationInfo* pActivationInfo)
  34. {
  35.         IFlowNode* pNode = new CFlowVehicleMoveActionMult(pActivationInfo);
  36.         return pNode;
  37. }
  38.  
  39. //------------------------------------------------------------------------
  40. void CFlowVehicleMoveActionMult::GetConfiguration(SFlowNodeConfig& nodeConfig)
  41. {
  42.         CFlowVehicleBase::GetConfiguration(nodeConfig);
  43.  
  44.         static const SInputPortConfig pInConfig[] =
  45.         {
  46.                 //InputPortConfig_AnyType("HitTrigger", _HELP("trigger which cause the vehicle to receive damages")),
  47.                 InputPortConfig_AnyType("EnableTrigger",     _HELP("")),
  48.                 InputPortConfig_AnyType("DisableTrigger",    _HELP("")),
  49.                 InputPortConfig<float>("PowerMult",          1.0f,      _HELP("")),
  50.                 InputPortConfig<float>("RotatePitch",        1.0f,      _HELP("")),
  51.                 InputPortConfig<float>("RotateYaw",          1.0f,      _HELP("")),
  52.                 InputPortConfig<bool>("PowerMustBePositive", false,     _HELP("")),
  53.                 { 0 }
  54.         };
  55.  
  56.         static const SOutputPortConfig pOutConfig[] =
  57.         {
  58.                 { 0 }
  59.         };
  60.  
  61.         nodeConfig.sDescription = _HELP("Add multipliers to vehicle movement actions");
  62.         nodeConfig.nFlags |= EFLN_TARGET_ENTITY;
  63.         nodeConfig.pInputPorts = pInConfig;
  64.         nodeConfig.pOutputPorts = pOutConfig;
  65.         nodeConfig.SetCategory(EFLN_APPROVED);
  66. }
  67.  
  68. //------------------------------------------------------------------------
  69. void CFlowVehicleMoveActionMult::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
  70. {
  71.         CFlowVehicleBase::ProcessEvent(flowEvent, pActivationInfo);
  72.  
  73.         if (flowEvent == eFE_Activate)
  74.         {
  75.                 m_powerMult = GetPortFloat(pActivationInfo, IN_POWERMULT);
  76.                 m_pitchMult = GetPortFloat(pActivationInfo, IN_ROTATEPITCHMULT);
  77.                 m_yawMult = GetPortFloat(pActivationInfo, IN_ROTATEYAWMULT);
  78.                 m_powerMustBePositive = GetPortBool(pActivationInfo, IN_POWERMUSTBEPOSITIVE);
  79.  
  80.                 if (IVehicle* pVehicle = GetVehicle())
  81.                 {
  82.                         if (IsPortActive(pActivationInfo, IN_ENABLETRIGGER))
  83.                         {
  84.                                 if (IVehicleMovement* pMovement = pVehicle->GetMovement())
  85.                                         pMovement->RegisterActionFilter(this);
  86.                         }
  87.  
  88.                         if (IsPortActive(pActivationInfo, IN_DISABLETRIGGER))
  89.                         {
  90.                                 if (IVehicleMovement* pMovement = pVehicle->GetMovement())
  91.                                         pMovement->UnregisterActionFilter(this);
  92.                         }
  93.                 }
  94.         }
  95. }
  96.  
  97. //------------------------------------------------------------------------
  98. void CFlowVehicleMoveActionMult::Serialize(SActivationInfo* pActivationInfo, TSerialize ser)
  99. {
  100. }
  101.  
  102. //------------------------------------------------------------------------
  103. void CFlowVehicleMoveActionMult::OnProcessActions(SVehicleMovementAction& movementAction)
  104. {
  105.         movementAction.power *= m_powerMult;
  106.         movementAction.rotatePitch *= m_pitchMult;
  107.         movementAction.rotateYaw *= m_yawMult;
  108.  
  109.         if (m_powerMustBePositive)
  110.                 movementAction.power = max(0.0f, movementAction.power);
  111. }
  112.  
  113. REGISTER_FLOW_NODE("Vehicle:MoveActionMult", CFlowVehicleMoveActionMult);
  114.  
downloadFlowVehicleMoveActionMult.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