37 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|
|
} |