actionwatergardenslot.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. Object targetObject = target.GetObject();
  27. if (item.GetQuantity() == 0)
  28. return false;
  29. // Get the liquid
  30. int liquid_type = item.GetLiquidType();
  31. if (liquid_type != LIQUID_WATER)
  32. {
  33. return false; // Forbid watering of plants with gasoline and other fluids
  34. }
  35. if (item.GetIsFrozen())
  36. {
  37. return false;
  38. }
  39. if ( targetObject.IsInherited(GardenBase) )
  40. {
  41. GardenBase garden_base = GardenBase.Cast( targetObject );
  42. Slot slot;
  43. array<string> selections = new array<string>;
  44. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  45. for (int s = 0; s < selections.Count(); s++)
  46. {
  47. string selection = selections[s];
  48. slot = garden_base.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. };