actionfillfuel.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. class ActionFillFuelCB : ActionContinuousBaseCB
  2. {
  3. private const float TIME_TO_REPEAT = 0.5;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousFillFuel( UAQuantityConsumed.FUEL, TIME_TO_REPEAT );
  7. }
  8. };
  9. class ActionFillFuel: ActionContinuousBase
  10. {
  11. const string FUEL_SELECTION_NAME = "refill";
  12. void ActionFillFuel()
  13. {
  14. m_CallbackClass = ActionFillFuelCB;
  15. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_EMPTY_VESSEL;
  16. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  17. m_FullBody = true;
  18. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  19. m_LockTargetOnUse = false;
  20. m_Text = "#refuel";
  21. }
  22. override void CreateConditionComponents()
  23. {
  24. m_ConditionItem = new CCINonRuined;//CCINotRuinedAndEmpty?
  25. m_ConditionTarget = new CCTNone;
  26. }
  27. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  28. {
  29. if ( !target || !IsTransport(target) )
  30. return false;
  31. if ( item.GetQuantity() <= 0 )
  32. return false;
  33. if ( item.GetLiquidType() != LIQUID_GASOLINE )
  34. return false;
  35. if (target.GetObject().IsDamageDestroyed())
  36. return false;
  37. Car car = Car.Cast(target.GetObject());
  38. Boat boat = Boat.Cast(target.GetObject());
  39. if (car)
  40. {
  41. if (car.GetFluidFraction( CarFluid.FUEL ) >= 0.98)
  42. return false;
  43. }
  44. else if (boat)
  45. {
  46. if ( boat.GetFluidFraction( BoatFluid.FUEL ) >= 0.98 )
  47. return false;
  48. }
  49. else
  50. return false;
  51. array<string> selections = new array<string>;
  52. target.GetObject().GetActionComponentNameList(target.GetComponentIndex(), selections);
  53. Transport vehicle = Transport.Cast(target.GetObject());
  54. if ( vehicle )
  55. {
  56. for (int s = 0; s < selections.Count(); s++)
  57. {
  58. if ( selections[s] == vehicle.GetActionCompNameFuel() )
  59. {
  60. float dist = vector.DistanceSq( vehicle.GetRefillPointPosWS(), player.GetPosition() );
  61. if ( dist < vehicle.GetActionDistanceFuel() * vehicle.GetActionDistanceFuel() )
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. };