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

31 lines
1.3 KiB
C#

using VOID.Generic.Dict;
using VOID.Generic.Objects.Item;
using VOID.Generic.Objects.Unit;
using VOID.Generic.Objects.Unit.Actions;
using VOID.Generic.Player.Util;
using VOID.UserInterface;
using VOID.UserInterface.Game;
namespace VOID.Generic.Player.DraggingOperation
{
public class SceneToOtherUnitBackpackDraggingOperation : AbstractDraggingOperation
{
public override bool Check(SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
{
return sourceSelect.slotUI?.slotType == null
&& targetSelect.slotUI?.slotType == SlotType.OtherUnitBackpackSlot;
}
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));
var otherUnit = GameUI.current.PickComponentUI<OtherUnitBackpackUI>().unit;
var moveAction = new MoveItemAction(unit, item, otherUnit.transform.position);
moveAction.OnAfterPerform += () => new ForcedTakeAction(otherUnit, item, targetSelect.slotUI.slotIndex).DoIt();
unit.Order(moveAction);
}
}
}