BVB Source Codes

CRYENGINE Show VehicleDamageBehaviorDisableSeatAction.cpp Source code

Return Download CRYENGINE: download VehicleDamageBehaviorDisableSeatAction.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 "VehicleDamageBehaviorDisableSeatAction.h"
  5.  
  6. #include "IVehicleSystem.h"
  7. #include "Vehicle.h"
  8. #include "VehicleSeat.h"
  9.  
  10. CVehicleDamageBehaviorDisableSeatAction::CVehicleDamageBehaviorDisableSeatAction()
  11.         : m_pVehicle(nullptr)
  12. {}
  13.  
  14. //------------------------------------------------------------------------
  15. bool CVehicleDamageBehaviorDisableSeatAction::Init(IVehicle* pVehicle, const CVehicleParams& table)
  16. {
  17.         m_pVehicle = (CVehicle*) pVehicle;
  18.  
  19.         CVehicleParams actionTable = table.findChild("DisableSeatAction");
  20.         if (!actionTable)
  21.                 return false;
  22.  
  23.         m_seatName = actionTable.getAttr("seat");
  24.         m_seatActionName = actionTable.getAttr("actionName");
  25.  
  26.         return true;
  27. }
  28.  
  29. //------------------------------------------------------------------------
  30. void CVehicleDamageBehaviorDisableSeatAction::Reset()
  31. {
  32. }
  33.  
  34. //------------------------------------------------------------------------
  35. void CVehicleDamageBehaviorDisableSeatAction::OnDamageEvent(EVehicleDamageBehaviorEvent event, const SVehicleDamageBehaviorEventParams& behaviorParams)
  36. {
  37.         if (event != eVDBE_Hit)
  38.                 return;
  39.  
  40.         TVehicleSeatId seatId = m_pVehicle->GetSeatId(m_seatName.c_str());
  41.  
  42.         if (seatId == InvalidVehicleSeatId)
  43.         {
  44.                 CryLog("DisableSeatAction damage behavior referencing invalid vehicle seat (%s)", m_seatName.c_str());
  45.                 return;
  46.         }
  47.  
  48.         if (CVehicleSeat* pSeat = static_cast<CVehicleSeat*>(m_pVehicle->GetSeatById(seatId)))
  49.         {
  50.                 bool all = (m_seatActionName == "all");
  51.                 TVehicleSeatActionVector& actions = pSeat->GetSeatActions();
  52.                 for (TVehicleSeatActionVector::iterator ite = actions.begin(), end = actions.end(); ite != end; ++ite)
  53.                 {
  54.                         if (all || (m_seatActionName == ite->pSeatAction->GetName()))
  55.                         {
  56.                                 ite->pSeatAction->StopUsing();
  57.  
  58.                                 ite->isEnabled = false;
  59.                         }
  60.                 }
  61.         }
  62. }
  63.  
  64. void CVehicleDamageBehaviorDisableSeatAction::GetMemoryUsage(ICrySizer* s) const
  65. {
  66.         s->AddObject(this, sizeof(*this));
  67.         s->AddObject(m_seatName);
  68.         s->AddObject(m_seatActionName);
  69. }
  70.  
  71. DEFINE_VEHICLEOBJECT(CVehicleDamageBehaviorDisableSeatAction);
  72.  
downloadVehicleDamageBehaviorDisableSeatAction.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