actionremoveplant.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. GardenBase garden_base;
  20. if ( Class.CastTo(garden_base, target.GetObject()))
  21. {
  22. Slot slot;
  23. array<string> selections = new array<string>;
  24. garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
  25. string selection;
  26. for (int s = 0; s < selections.Count(); s++)
  27. {
  28. selection = selections[s];
  29. slot = garden_base.GetSlotBySelection( selection );
  30. if (slot)
  31. break;
  32. }
  33. if ( slot && slot.GetPlant() )
  34. {
  35. m_Plant = PlantBase.Cast(slot.GetPlant());
  36. if (!m_Plant.IsHarvestable())
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. override void OnExecuteServer( ActionData action_data )
  43. {
  44. if ( m_Plant )
  45. m_Plant.RemovePlantEx( action_data.m_Player.GetPosition() );
  46. }
  47. };