actionfillcoolant.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. class ActionFillCoolantCB : ActionContinuousBaseCB
  2. {
  3. private const float TIME_TO_REPEAT = 0.075;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousFillCoolant( UAQuantityConsumed.FUEL, TIME_TO_REPEAT );
  7. }
  8. };
  9. class ActionFillCoolant: ActionContinuousBase
  10. {
  11. const string RADIATOR_SELECTION_NAME = "radiator";
  12. void ActionFillCoolant()
  13. {
  14. m_CallbackClass = ActionFillCoolantCB;
  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 = "#refill_car";
  21. }
  22. override void CreateConditionComponents()
  23. {
  24. m_ConditionItem = new CCINonRuined;
  25. m_ConditionTarget = new CCTParent(10);
  26. }
  27. override bool IsUsingProxies()
  28. {
  29. return true;
  30. }
  31. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  32. {
  33. if (!target)
  34. return false;
  35. if (item.GetQuantity() <= 0)
  36. return false;
  37. if (item.GetLiquidType() != LIQUID_WATER)
  38. return false;
  39. if (item.GetIsFrozen())
  40. {
  41. return false;
  42. }
  43. Car car = Car.Cast( target.GetParent() );
  44. if (!car)
  45. return false;
  46. if (car.GetFluidFraction( CarFluid.COOLANT ) >= 0.95)
  47. return false;
  48. array<string> selections = new array<string>;
  49. target.GetObject().GetActionComponentNameList(target.GetComponentIndex(), selections);
  50. CarScript carS = CarScript.Cast(car);
  51. if (carS)
  52. {
  53. EntityAI radiator = null;
  54. EntityAI carAI;
  55. if (CastTo(carAI, car))
  56. {
  57. radiator = carAI.GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("CarRadiator"));
  58. if (radiator && !radiator.IsRuined())
  59. {
  60. for (int s = 0; s < selections.Count(); s++)
  61. {
  62. if (selections[s] == carS.GetActionCompNameCoolant())
  63. {
  64. float dist = vector.Distance( carS.GetCoolantPtcPosWS(), player.GetPosition() );
  65. if (dist < carS.GetActionDistanceCoolant())
  66. return true;
  67. }
  68. }
  69. }
  70. }
  71. }
  72. return false;
  73. }
  74. };