actionharvestcrops.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. class ActionHarvestCrops: ActionInteractBase
  2. {
  3. PlantBase m_Plant;
  4. void ActionHarvestCrops()
  5. {
  6. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
  7. /*m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  8. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  9. m_FullBody = true;*/
  10. }
  11. override typename GetInputType()
  12. {
  13. return ContinuousInteractActionInput;
  14. }
  15. Slot GetPlantSlot(ActionTarget target)
  16. {
  17. GardenBase garden_base;
  18. if ( Class.CastTo(garden_base, target.GetObject()))
  19. {
  20. Slot slot;
  21. array<string> selections = new array<string>;
  22. garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
  23. string selection;
  24. for (int s = 0; s < selections.Count(); s++)
  25. {
  26. selection = selections[s];
  27. slot = garden_base.GetSlotBySelection( selection );
  28. if (slot)
  29. break;
  30. }
  31. if ( slot && slot.GetPlant() )
  32. {
  33. return slot;
  34. }
  35. }
  36. return null;
  37. }
  38. override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
  39. {
  40. m_Text = "#harvest";
  41. Slot slot = GetPlantSlot(target);
  42. if (slot)
  43. {
  44. m_Plant = PlantBase.Cast(slot.GetPlant());
  45. m_Text+= " " + MiscGameplayFunctions.GetItemDisplayName(m_Plant.GetCropsType());
  46. }
  47. }
  48. override void CreateConditionComponents()
  49. {
  50. m_ConditionItem = new CCINone;
  51. m_ConditionTarget = new CCTCursor(UAMaxDistances.SMALL);
  52. }
  53. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  54. {
  55. GardenBase garden_base;
  56. if ( Class.CastTo(garden_base, target.GetObject()))
  57. {
  58. Slot slot = GetPlantSlot(target);
  59. if (slot)
  60. {
  61. m_Plant = PlantBase.Cast(slot.GetPlant());
  62. bool is_mature = m_Plant.IsMature();
  63. bool is_spoiled = m_Plant.IsSpoiled();
  64. bool has_crops = m_Plant.HasCrops();
  65. int plant_state = m_Plant.GetPlantState();
  66. if ( is_mature && has_crops )
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. return false;
  73. }
  74. override void OnExecuteServer( ActionData action_data )
  75. {
  76. if ( m_Plant )
  77. {
  78. m_Plant.Harvest( action_data.m_Player );
  79. }
  80. }
  81. };