BVB Source Codes

CRYENGINE Show FlowVehicleAttachment.cpp Source code

Return Download CRYENGINE: download FlowVehicleAttachment.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 "FlowVehicleAttachment.h"
  7. #include "VehicleSystem/VehiclePartAttachment.h"
  8.  
  9. #include <CryFlowGraph/IFlowBaseNode.h>
  10.  
  11. //------------------------------------------------------------------------
  12. void CFlowVehicleAttachment::Init(SActivationInfo* pActivationInfo)
  13. {
  14.         CFlowVehicleBase::Init(pActivationInfo);
  15.  
  16.         m_attachedId = 0;
  17. }
  18.  
  19. //------------------------------------------------------------------------
  20. IFlowNodePtr CFlowVehicleAttachment::Clone(SActivationInfo* pActivationInfo)
  21. {
  22.         IFlowNode* pNode = new CFlowVehicleAttachment(pActivationInfo);
  23.         return pNode;
  24. }
  25.  
  26. //------------------------------------------------------------------------
  27. void CFlowVehicleAttachment::GetConfiguration(SFlowNodeConfig& nodeConfig)
  28. {
  29.         CFlowVehicleBase::GetConfiguration(nodeConfig);
  30.  
  31.         static const SInputPortConfig pInConfig[] =
  32.         {
  33.                 InputPortConfig<string>("Attachment",   _HELP("Name of Attachment socket (see Vehicle Editor, listbox planned here)")),
  34.                 InputPortConfig<EntityId>("AttachedId", _HELP("Entity to attach/detach"),                                              _HELP("EntityId")),
  35.                 InputPortConfig_Void("Attach",          _HELP("Trigger to attach the entity")),
  36.                 InputPortConfig_Void("Detach",          _HELP("Trigger to detach the entity")),
  37.                 { 0 }
  38.         };
  39.  
  40.         static const SOutputPortConfig pOutConfig[] =
  41.         {
  42.                 { 0 }
  43.         };
  44.  
  45.         nodeConfig.sDescription = _HELP("Handle vehicle entity attachments");
  46.         nodeConfig.nFlags |= EFLN_TARGET_ENTITY;
  47.         nodeConfig.pInputPorts = pInConfig;
  48.         nodeConfig.pOutputPorts = pOutConfig;
  49.         nodeConfig.SetCategory(EFLN_APPROVED); // kindly approved by alex for only two paulaners in return
  50. }
  51.  
  52. //------------------------------------------------------------------------
  53. void CFlowVehicleAttachment::Attach(SActivationInfo* pActInfo, bool attach)
  54. {
  55.         IVehicle* pVehicle = GetVehicle();
  56.         if (!pVehicle)
  57.                 return;
  58.  
  59.         IVehiclePart* pPart = pVehicle->GetPart(GetPortString(pActInfo, IN_ATTACHMENT).c_str());
  60.         if (!pPart)
  61.                 return;
  62.  
  63.         CVehiclePartEntityAttachment* pAttachment = CAST_VEHICLEOBJECT(CVehiclePartEntityAttachment, pPart);
  64.         if (!pAttachment)
  65.                 return;
  66.  
  67.         if (!attach)
  68.         {
  69.                 pAttachment->SetAttachmentEntity(0);
  70.                 m_attachedId = 0;
  71.         }
  72.         else
  73.         {
  74.                 EntityId entityId = GetPortEntityId(pActInfo, IN_ENTITYID);
  75.                 pAttachment->SetAttachmentEntity(entityId);
  76.                 m_attachedId = entityId;
  77.         }
  78. }
  79.  
  80. //------------------------------------------------------------------------
  81. void CFlowVehicleAttachment::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
  82. {
  83.         CFlowVehicleBase::ProcessEvent(flowEvent, pActivationInfo);
  84.  
  85.         if (!GetVehicle())
  86.                 return;
  87.  
  88.         switch (flowEvent)
  89.         {
  90.         case eFE_Initialize:
  91.                 {
  92.                         if (m_attachedId)
  93.                         {
  94.                                 Attach(pActivationInfo, false);
  95.                         }
  96.                         break;
  97.                 }
  98.         case eFE_Activate:
  99.                 {
  100.                         if (IsPortActive(pActivationInfo, IN_DETACH))
  101.                         {
  102.                                 Attach(pActivationInfo, false);
  103.                         }
  104.                         else if (IsPortActive(pActivationInfo, IN_ATTACH))
  105.                         {
  106.                                 Attach(pActivationInfo, true);
  107.                         }
  108.                         break;
  109.                 }
  110.         }
  111. }
  112.  
  113. //------------------------------------------------------------------------
  114. void CFlowVehicleAttachment::Serialize(SActivationInfo* pActivationInfo, TSerialize ser)
  115. {
  116.         CFlowVehicleBase::Serialize(pActivationInfo, ser);
  117. }
  118.  
  119. //------------------------------------------------------------------------
  120. void CFlowVehicleAttachment::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
  121. {
  122.         CFlowVehicleBase::OnVehicleEvent(event, params);
  123. }
  124.  
  125. REGISTER_FLOW_NODE("Vehicle:Attachment", CFlowVehicleAttachment);
  126.  
downloadFlowVehicleAttachment.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