actionstartengineboat.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. class ActionStartEngineBoatCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.START_ENGINE);
  6. }
  7. }
  8. class ActionStartEngineBoat : ActionContinuousBase
  9. {
  10. void ActionStartEngineBoat()
  11. {
  12. m_CallbackClass = ActionStartEngineBoatCB;
  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 = BoatScript.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. HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
  36. if (!vehCommand)
  37. return;
  38. auto vehicle = BoatScript.Cast(vehCommand.GetTransport());
  39. if (!vehicle)
  40. return;
  41. if (vehicle.GetNetworkMoveStrategy() == NetworkMoveStrategy.PHYSICS)
  42. {
  43. // Only perform on clients (or robos), validation is performed in C++ with respect to scripted 'Car.OnBeforeEngineStart'
  44. if (action_data.m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  45. {
  46. return;
  47. }
  48. }
  49. vehicle.EngineStart();
  50. }
  51. override void OnExecute(ActionData action_data)
  52. {
  53. HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
  54. if (!vehCommand)
  55. return;
  56. auto vehicle = BoatScript.Cast(vehCommand.GetTransport());
  57. if (vehicle)
  58. vehicle.OnIgnition();
  59. }
  60. override bool CanBeUsedInVehicle()
  61. {
  62. return true;
  63. }
  64. override bool HasTarget()
  65. {
  66. return false;
  67. }
  68. override bool UseMainItem()
  69. {
  70. return false;
  71. }
  72. }