actionremoveplant.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.IsGrowing() || m_Plant.IsDry() || !m_Plant.HasCrops() || m_Plant.IsSpoiled())
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. return false;
  43. /*Object targetObject = target.GetObject();
  44. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  45. {
  46. PlantBase plant = PlantBase.Cast( targetObject );
  47. if ( plant.IsGrowing() || plant.IsDry() || !plant.HasCrops() || plant.IsSpoiled())
  48. {
  49. return true;
  50. }
  51. }
  52. return false;*/
  53. }
  54. override void OnExecuteServer( ActionData action_data )
  55. {
  56. if ( m_Plant )
  57. {
  58. //m_Plant.RemovePlant();
  59. //New method allowing us to pass player position
  60. m_Plant.RemovePlantEx( action_data.m_Player.GetPosition() );
  61. }
  62. /*Object targetObject = action_data.m_Target.GetObject();
  63. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  64. {
  65. PlantBase plant = PlantBase.Cast( targetObject );
  66. plant.RemovePlant();
  67. }*/
  68. }
  69. };