BVB Source Codes

CRYENGINE Show FlowVehicleLights.cpp Source code

Return Download CRYENGINE: download FlowVehicleLights.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 toggel vehicle lights
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 03:03:2007: Created by MichaelR
  12.  
  13. *************************************************************************/
  14. #include "StdAfx.h"
  15. #include "CryAction.h"
  16. #include "IVehicleSystem.h"
  17. #include "FlowVehicleLights.h"
  18. #include "VehicleSystem/Vehicle.h"
  19. #include "VehicleSystem/VehiclePartLight.h"
  20.  
  21. #include <CryFlowGraph/IFlowBaseNode.h>
  22.  
  23. //------------------------------------------------------------------------
  24. IFlowNodePtr CFlowVehicleLights::Clone(SActivationInfo* pActivationInfo)
  25. {
  26.         IFlowNode* pNode = new CFlowVehicleLights(pActivationInfo);
  27.         return pNode;
  28. }
  29.  
  30. //------------------------------------------------------------------------
  31. void CFlowVehicleLights::GetConfiguration(SFlowNodeConfig& nodeConfig)
  32. {
  33.         CFlowVehicleBase::GetConfiguration(nodeConfig);
  34.  
  35.         static const SInputPortConfig pInConfig[] =
  36.         {
  37.                 InputPortConfig<string>("LightType",           _HELP("Type of light to toggle"), _HELP("LightType"), _UICONFIG("enum_global:vehicleLightTypes")),
  38.                 InputPortConfig<SFlowSystemVoid>("Activate",   _HELP("Activate lights")),
  39.                 InputPortConfig<SFlowSystemVoid>("Deactivate", _HELP("Deactivate lights")),
  40.                 { 0 }
  41.         };
  42.  
  43.         static const SOutputPortConfig pOutConfig[] =
  44.         {
  45.                 { 0 }
  46.         };
  47.  
  48.         nodeConfig.sDescription = _HELP("Toggle vehicle lights");
  49.         nodeConfig.nFlags |= EFLN_TARGET_ENTITY;
  50.         nodeConfig.pInputPorts = pInConfig;
  51.         nodeConfig.pOutputPorts = pOutConfig;
  52.         nodeConfig.SetCategory(EFLN_APPROVED);
  53. }
  54.  
  55. //------------------------------------------------------------------------
  56. void CFlowVehicleLights::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
  57. {
  58.         CFlowVehicleBase::ProcessEvent(flowEvent, pActivationInfo);
  59.  
  60.         if (flowEvent == eFE_Activate)
  61.         {
  62.                 if (IVehicle* pVehicle = GetVehicle())
  63.                 {
  64.                         bool activate = IsPortActive(pActivationInfo, eIn_Activate);
  65.                         bool deactivate = IsPortActive(pActivationInfo, eIn_Deactivate);
  66.  
  67.                         if (activate || deactivate)
  68.                         {
  69.                                 const string& type = GetPortString(pActivationInfo, eIn_LightType);
  70.  
  71.                                 int partCount = pVehicle->GetPartCount();
  72.                                 for (int i = 0; i < partCount; ++i)
  73.                                 {
  74.                                         IVehiclePart* pPart = pVehicle->GetPart(i);
  75.  
  76.                                         if (!pPart)
  77.                                                 continue;
  78.  
  79.                                         if (CVehiclePartLight* pLightPart = CAST_VEHICLEOBJECT(CVehiclePartLight, pPart))
  80.                                         {
  81.                                                 if (pLightPart->GetLightType() == type || type == "All")
  82.                                                 {
  83.                                                         pLightPart->ToggleLight(activate);
  84.                                                 }
  85.                                         }
  86.                                 }
  87.                         }
  88.                 }
  89.         }
  90. }
  91.  
  92. REGISTER_FLOW_NODE("Vehicle:Lights", CFlowVehicleLights);
  93.  
downloadFlowVehicleLights.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