actionwatergardenslot.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class ActionWaterGardenSlotCB : ActionContinuousBaseCB
  2. {
  3. private const float QUANTITY_USED_PER_SEC = 150;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousWaterSlot(QUANTITY_USED_PER_SEC);
  7. }
  8. };
  9. class ActionWaterGardenSlot: ActionContinuousBase
  10. {
  11. void ActionWaterGardenSlot()
  12. {
  13. m_CallbackClass = ActionWaterGardenSlotCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_EMPTY_VESSEL;
  15. m_FullBody = true;
  16. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  17. m_Text = "#water_slot";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionTarget = new CCTDummy;
  22. m_ConditionItem = new CCINonRuined;
  23. }
  24. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  25. {
  26. if (item.GetQuantity() == 0)
  27. return false;
  28. // Get the liquid
  29. int liquidType = item.GetLiquidType();
  30. if (liquidType != LIQUID_WATER)
  31. {
  32. return false; // Forbid watering of plants with gasoline and other fluids
  33. }
  34. if (item.GetIsFrozen())
  35. {
  36. return false;
  37. }
  38. Object targetObject = target.GetObject();
  39. if (targetObject && targetObject.IsInherited(GardenBase))
  40. {
  41. GardenBase gardenBase = GardenBase.Cast(targetObject);
  42. array<string> selections = new array<string>;
  43. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  44. Slot slot;
  45. for (int s = 0; s < selections.Count(); s++)
  46. {
  47. string selection = selections[s];
  48. slot = gardenBase.GetSlotBySelection(selection);
  49. if (slot)
  50. break;
  51. }
  52. if ( slot && !slot.GetPlant() && slot.GetWateredState() == eWateredState.DRY )
  53. {
  54. return true;
  55. }
  56. else
  57. {
  58. return false;
  59. }
  60. }
  61. return false;
  62. }
  63. };