using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Objects.Usable;
using VOID.Generic.Player.Util;

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

        public override void Perform(UnitObject unit, SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
        {
            unit.unitActionBar.UnSet(sourceSelect.slotUI.slotIndex);
            if (sourceSelect.selectAbility)
                unit.unitActionBar.Set(targetSelect.slotUI.slotIndex, sourceSelect.selectAbility);
            if (sourceSelect.selectObject && sourceSelect.selectObject is UsableObject usable)
                unit.unitActionBar.Set(targetSelect.slotUI.slotIndex, usable);
        }
    }
}