using VOID.Generic.Objects.Item;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Objects.Unit.Actions;
using VOID.Generic.Player.Util;

namespace VOID.Generic.Player.DraggingOperation
{
    public class SceneToSceneDraggingOperation : AbstractDraggingOperation
    {
        public override bool Check(SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
        {
            return sourceSelect.slotUI?.slotType == null
                   && targetSelect.slotUI?.slotType == null;
        }

        public override void Perform(UnitObject unit, SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
        {
            if (sourceSelect.selectObject is not ItemObject item) return;
            unit.OrderStop();
            unit.Order(new MoveAction(unit, sourceSelect.position, unit.unitData.takeRange));
            unit.Order(new MoveItemAction(unit, item, targetSelect.position));
        }
    }
}