123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- class ActionRemovePlant: ActionInteractBase
- {
- PlantBase m_Plant;
-
- void ActionRemovePlant()
- {
- m_Text = "#remove_plant";
- }
-
- override typename GetInputType()
- {
- return ContinuousInteractActionInput;
- }
-
- override void CreateConditionComponents()
- {
- m_ConditionItem = new CCINone;
- m_ConditionTarget = new CCTCursor(UAMaxDistances.SMALL);
- }
- override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
- {
- if (!super.ActionCondition(player, target, item))
- return false;
-
- GardenBase garden_base;
- if ( Class.CastTo(garden_base, target.GetObject()))
- {
- Slot slot;
-
- array<string> selections = new array<string>;
- garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
- string selection;
- for (int s = 0; s < selections.Count(); s++)
- {
- selection = selections[s];
- slot = garden_base.GetSlotBySelection( selection );
- if (slot)
- break;
- }
-
- if ( slot && slot.GetPlant() )
- {
- m_Plant = PlantBase.Cast(slot.GetPlant());
- if (!m_Plant.IsHarvestable())
- return true;
- }
- }
- return false;
- }
- override void OnExecuteServer(ActionData action_data)
- {
- super.OnExecuteServer(action_data);
-
- if (m_Plant)
- m_Plant.RemovePlantEx(action_data.m_Player.GetPosition());
- }
- };
|