actionfilloil.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class ActionFillOilCB : ActionContinuousBaseCB
  2. {
  3. private const float TIME_TO_REPEAT = 0.05;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousFillOil( UAQuantityConsumed.POUR_LIQUID, TIME_TO_REPEAT );
  7. }
  8. };
  9. class ActionFillOil: ActionContinuousBase
  10. {
  11. void ActionFillOil()
  12. {
  13. m_CallbackClass = ActionFillOilCB;
  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.OIL ) >= 0.98 )
  36. return false;
  37. array<string> selections = new array<string>;
  38. target.GetObject().GetActionComponentNameList(target.GetComponentIndex(), selections);
  39. CarScript carS = CarScript.Cast(car);
  40. if( carS )
  41. {
  42. for (int s = 0; s < selections.Count(); s++)
  43. {
  44. if ( selections[s] == carS.GetActionCompNameOil() )
  45. {
  46. float dist = vector.Distance( carS.GetRefillPointPosWS(), player.GetPosition() );
  47. if ( dist < carS.GetActionDistanceOil() )
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. override void OnEndAnimationLoopServer( ActionData action_data )
  55. {
  56. if ( action_data.m_MainItem && action_data.m_MainItem.GetQuantity() <= 0.01 )
  57. {
  58. action_data.m_MainItem.SetQuantity(0);
  59. }
  60. }
  61. };