actionfillbrakes.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. class ActionFillBrakesCB : ActionContinuousBaseCB
  2. {
  3. private const float TIME_TO_REPEAT = 0.05;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousFillBrakes( UAQuantityConsumed.POUR_LIQUID, TIME_TO_REPEAT );
  7. }
  8. };
  9. class ActionFillBrakes: ActionContinuousBase
  10. {
  11. void ActionFillBrakes()
  12. {
  13. m_CallbackClass = ActionFillBrakesCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_EMPTY_VESSEL;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  16. m_FullBody = true;
  17. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  18. m_LockTargetOnUse = false;
  19. m_Text = "#refill_car";
  20. }
  21. override void CreateConditionComponents()
  22. {
  23. m_ConditionItem = new CCINonRuined;
  24. m_ConditionTarget = new CCTNone;
  25. }
  26. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  27. {
  28. if( !target || !IsTransport(target) )
  29. return false;
  30. if( item.GetQuantity() <= 0 )
  31. return false;
  32. Car car = Car.Cast( target.GetObject() );
  33. if( !car )
  34. return false;
  35. if( car.GetFluidFraction( CarFluid.BRAKE ) >= 0.98 )
  36. return false;
  37. float distance = Math.AbsFloat(vector.Distance(car.GetPosition(), player.GetPosition()));
  38. CarScript carS = CarScript.Cast(car);
  39. if( distance <= carS.GetActionDistanceFuel() )
  40. {
  41. array<string> selections = new array<string>;
  42. target.GetObject().GetActionComponentNameList(target.GetComponentIndex(), selections);
  43. for (int s = 0; s < selections.Count(); s++)
  44. {
  45. if ( selections[s] == carS.GetActionCompNameBrakes() )
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. override void OnEndAnimationLoopServer( ActionData action_data )
  54. {
  55. if ( action_data.m_MainItem && action_data.m_MainItem.GetQuantity() <= 0.01 )
  56. {
  57. action_data.m_MainItem.SetQuantity(0);
  58. }
  59. }
  60. };