actionremoveplant.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class ActionRemovePlant: ActionInteractBase
  2. {
  3. PlantBase m_Plant;
  4. void ActionRemovePlant()
  5. {
  6. m_Text = "#remove_plant";
  7. }
  8. override typename GetInputType()
  9. {
  10. return ContinuousInteractActionInput;
  11. }
  12. override void CreateConditionComponents()
  13. {
  14. m_ConditionItem = new CCINone;
  15. m_ConditionTarget = new CCTCursor(UAMaxDistances.SMALL);
  16. }
  17. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  18. {
  19. if (!super.ActionCondition(player, target, item))
  20. return false;
  21. GardenBase garden_base;
  22. if ( Class.CastTo(garden_base, target.GetObject()))
  23. {
  24. Slot slot;
  25. array<string> selections = new array<string>;
  26. garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
  27. string selection;
  28. for (int s = 0; s < selections.Count(); s++)
  29. {
  30. selection = selections[s];
  31. slot = garden_base.GetSlotBySelection( selection );
  32. if (slot)
  33. break;
  34. }
  35. if ( slot && slot.GetPlant() )
  36. {
  37. m_Plant = PlantBase.Cast(slot.GetPlant());
  38. if (!m_Plant.IsHarvestable())
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. override void OnExecuteServer(ActionData action_data)
  45. {
  46. super.OnExecuteServer(action_data);
  47. if (m_Plant)
  48. m_Plant.RemovePlantEx(action_data.m_Player.GetPosition());
  49. }
  50. };