Files
VOIDRPG/Assets/90 - Scripts/Generic/Player/DraggingOperation/EquipmentToOtherUnitBackpackDraggingOperation.cs
2026-07-09 21:33:33 +02:00

37 lines
1.5 KiB
C#

using System.Collections.Generic;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Objects.Unit.Actions;
using VOID.Generic.Objects.Wearable;
using VOID.Generic.Player.Util;
using VOID.UserInterface;
using VOID.UserInterface.Game;
namespace VOID.Generic.Player.DraggingOperation
{
public class EquipmentToOtherUnitBackpackDraggingOperation : AbstractDraggingOperation
{
public override bool Check(SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
{
return sourceSelect.slotUI?.slotType == SlotType.EquipmentSlot
&& targetSelect.slotUI?.slotType == SlotType.OtherUnitBackpackSlot;
}
public override void Perform(UnitObject unit, SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
{
if (sourceSelect.selectObject is not WearableObject wearable) return;
unit.OrderStop();
var otherUnit = GameUI.current.PickComponentUI<OtherUnitBackpackUI>().unit;
var orderChain = new List<AbstractAction>();
orderChain.Add(new MoveAction(unit, targetSelect.position, unit.unitData.takeRange));
var dropAction = new DropAction(unit, wearable);
dropAction.OnAfterPerform += () => new ForcedTakeAction(otherUnit, wearable, targetSelect.slotUI.slotIndex).DoIt();
orderChain.Add(dropAction);
unit.OrderChain(orderChain);
}
}
}