actionstartengine.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. class ActionStartCarCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.START_ENGINE);
  6. }
  7. }
  8. class ActionStartEngine : ActionContinuousBase
  9. {
  10. void ActionStartEngine()
  11. {
  12. m_CallbackClass = ActionStartCarCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_STARTENGINE;
  14. m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
  15. m_LockTargetOnUse = false;
  16. m_Text = "#start_the_car";
  17. }
  18. override void CreateConditionComponents()
  19. {
  20. m_ConditionTarget = new CCTNone();
  21. m_ConditionItem = new CCINone();
  22. }
  23. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  24. {
  25. HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
  26. if (!vehCommand)
  27. return false;
  28. auto vehicle = CarScript.Cast(vehCommand.GetTransport());
  29. if (!vehicle || vehicle.EngineIsOn())
  30. return false;
  31. return vehicle.CrewDriver() == player;
  32. }
  33. override void OnFinishProgress(ActionData action_data)
  34. {
  35. super.OnFinishProgress(action_data);
  36. HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
  37. if (!vehCommand)
  38. return;
  39. auto vehicle = CarScript.Cast(vehCommand.GetTransport());
  40. if (!vehicle)
  41. return;
  42. if (vehicle.GetNetworkMoveStrategy() == NetworkMoveStrategy.PHYSICS)
  43. {
  44. // Only perform on clients (or robos), validation is performed in C++ with respect to scripted 'Car.OnBeforeEngineStart'
  45. if (action_data.m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  46. {
  47. return;
  48. }
  49. }
  50. else
  51. {
  52. if (g_Game.IsClient())
  53. return;
  54. }
  55. vehicle.EngineStart();
  56. }
  57. override void OnExecute(ActionData action_data)
  58. {
  59. HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
  60. if (!vehCommand)
  61. return;
  62. auto vehicle = CarScript.Cast(vehCommand.GetTransport());
  63. if (vehicle)
  64. vehicle.OnIgnition();
  65. }
  66. override bool CanBeUsedInVehicle()
  67. {
  68. return true;
  69. }
  70. override bool HasTarget()
  71. {
  72. return false;
  73. }
  74. override bool UseMainItem()
  75. {
  76. return false;
  77. }
  78. //! DEPRECATED
  79. private const int SOUND_IGNITION_DELAY = 700; // ms, delay for ignition sound to match animation of hand touching the key
  80. private const float ROUGH_SPECIALTY_WEIGHT = 0.5;
  81. static const float MINIMUM_BATTERY_ENERGY = 5.0;
  82. bool m_BatteryCon = false;
  83. bool m_SparkCon = false;
  84. bool m_BeltCon = false;
  85. bool m_FuelCon = false;
  86. }