BVB Source Codes

CRYENGINE Show FlowVehicleTurret.cpp Source code

Return Download CRYENGINE: download FlowVehicleTurret.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 "FlowVehicleTurret.h"
  5.  
  6. #include "IVehicleSystem.h"
  7. #include "VehicleSystem/VehicleSeatActionRotateTurret.h"
  8. #include "VehicleSystem/Vehicle.h"
  9. #include "VehicleSystem/VehicleSeat.h"
  10.  
  11. IFlowNodePtr CFlowVehicleTurret::Clone(SActivationInfo* pActivationInfo)
  12. {
  13.         IFlowNode* pNode = new CFlowVehicleTurret(pActivationInfo);
  14.         return pNode;
  15. }
  16.  
  17. void CFlowVehicleTurret::GetConfiguration(SFlowNodeConfig& nodeConfig)
  18. {
  19.         CFlowVehicleBase::GetConfiguration(nodeConfig);
  20.  
  21.         static const SInputPortConfig pInConfig[] =
  22.         {
  23.                 InputPortConfig_AnyType("Trigger", _HELP("Triggers the turret to be rotated")),
  24.                 InputPortConfig<string>("seatId",  _HELP("Seat which can rotate the turret"),              _HELP("Seat"),_UICONFIG("dt=vehicleSeats, ref_entity=entityId")),
  25.                 InputPortConfig<Vec3>("aimPos",    _HELP("World position at which the turret should aim")),
  26.                 { 0 }
  27.         };
  28.  
  29.         static const SOutputPortConfig pOutConfig[] =
  30.         {
  31.                 OutputPortConfig<bool>("Success", _HELP("Triggers when the node is processed, outputing 0 or 1 representing fail or success")),
  32.                 { 0 }
  33.         };
  34.  
  35.         nodeConfig.sDescription = _HELP("Control the aim of the vehicle's turret or mounted weapon");
  36.         nodeConfig.nFlags |= EFLN_TARGET_ENTITY;
  37.         nodeConfig.pInputPorts = pInConfig;
  38.         nodeConfig.pOutputPorts = pOutConfig;
  39.         nodeConfig.SetCategory(EFLN_APPROVED);
  40. }
  41.  
  42. void CFlowVehicleTurret::ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
  43. {
  44.         CFlowVehicleBase::ProcessEvent(event, pActInfo); // handles eFE_SetEntityId
  45.  
  46.         if (event == eFE_Activate)
  47.         {
  48.                 if (IsPortActive(pActInfo, eIn_Trigger))
  49.                 {
  50.                         bool bSuccess = false;
  51.  
  52.                         const string seatName = GetPortString(pActInfo, eIn_Seat);
  53.                         Vec3 aimPos = GetPortVec3(pActInfo, eIn_AimPos);
  54.  
  55.                         CVehicle* pVehicle = static_cast<CVehicle*>(GetVehicle());
  56.                         if (pVehicle)
  57.                         {
  58.                                 CVehicleSeat* pSeat = static_cast<CVehicleSeat*>(pVehicle->GetSeatById(pVehicle->GetSeatId(seatName)));
  59.                                 if (pSeat)
  60.                                 {
  61.                                         TVehicleSeatActionVector& seatActions = pSeat->GetSeatActions();
  62.                                         for (TVehicleSeatActionVector::iterator ite = seatActions.begin(); ite != seatActions.end(); ++ite)
  63.                                         {
  64.                                                 IVehicleSeatAction* pSeatAction = ite->pSeatAction;
  65.                                                 CVehicleSeatActionRotateTurret* pActionRotateTurret = CAST_VEHICLEOBJECT(CVehicleSeatActionRotateTurret, pSeatAction);
  66.                                                 if (pActionRotateTurret)
  67.                                                 {
  68.                                                         if (!aimPos.IsZero())
  69.                                                         {
  70.                                                                 pActionRotateTurret->SetAimGoal(aimPos);
  71.                                                         }
  72.                                                         bSuccess = true;
  73.                                                         break;
  74.                                                 }
  75.                                         }
  76.                                 }
  77.                         }
  78.                         ActivateOutput(pActInfo, eOut_Success, bSuccess);
  79.                 }
  80.         }
  81. }
  82.  
  83. void CFlowVehicleTurret::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
  84. {
  85.         CFlowVehicleBase::OnVehicleEvent(event, params);
  86. }
  87.  
  88. void CFlowVehicleTurret::Serialize(SActivationInfo* pActivationInfo, TSerialize ser)
  89. {
  90.         CFlowVehicleBase::Serialize(pActivationInfo, ser);
  91. }
  92.  
  93. REGISTER_FLOW_NODE("Vehicle:Turret", CFlowVehicleTurret);
  94.  
downloadFlowVehicleTurret.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