actionfertilizeslot.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. class ActionFertilizeSlotCB : ActionContinuousBaseCB
  2. {
  3. private const float QUANTITY_USED_PER_SEC = 150;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousFertilizeGardenSlot(QUANTITY_USED_PER_SEC);
  7. }
  8. };
  9. class ActionFertilizeSlot: ActionContinuousBase
  10. {
  11. void ActionFertilizeSlot()
  12. {
  13. m_CallbackClass = ActionFertilizeSlotCB;
  14. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
  15. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  16. m_FullBody = true;
  17. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  18. m_Text = "#fertilize_slot";
  19. }
  20. override void CreateConditionComponents()
  21. {
  22. m_ConditionTarget = new CCTDummy;
  23. m_ConditionItem = new CCINonRuined;
  24. }
  25. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  26. {
  27. if (item.GetQuantity() == 0)
  28. return false;
  29. Object targetObject = target.GetObject();
  30. if (targetObject.IsInherited(GardenBase))
  31. {
  32. GardenBase gardenBase = GardenBase.Cast(targetObject);
  33. Slot slot;
  34. array<string> selections = new array<string>;
  35. gardenBase.GetActionComponentNameList(target.GetComponentIndex(), selections);
  36. foreach(string selection: selections)
  37. {
  38. slot = gardenBase.GetSlotBySelection(selection);
  39. if (slot)
  40. break;
  41. }
  42. if (slot)
  43. {
  44. if (slot.GetPlant())
  45. return false;
  46. if (slot.GetFertilityState() == eFertlityState.NONE)
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. override void OnFinishProgressServer( ActionData action_data )
  53. {
  54. // The functionality is in the Execute event of this user action's component.
  55. }
  56. };