init
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Unit;
|
||||
using VOID.Generic.Player.Util;
|
||||
|
||||
namespace VOID.Generic.Player.DraggingOperation
|
||||
{
|
||||
public class BackpackToBackpackDraggingOperation : AbstractDraggingOperation
|
||||
{
|
||||
public override bool Check(SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
|
||||
{
|
||||
return sourceSelect.slotUI?.slotType == SlotType.BackpackSlot
|
||||
&& targetSelect.slotUI?.slotType == SlotType.BackpackSlot;
|
||||
}
|
||||
|
||||
public override void Perform(UnitObject unit, SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
|
||||
{
|
||||
var itemFrom = sourceSelect.slotUI.item;
|
||||
var itemTo = targetSelect.slotUI.item;
|
||||
|
||||
if (itemFrom.CanStackWith(itemTo))
|
||||
{
|
||||
itemFrom.StackWith(itemTo);
|
||||
return;
|
||||
}
|
||||
|
||||
unit.unitBackpack.Swap(
|
||||
sourceSelect.slotUI.slotIndex,
|
||||
targetSelect.slotUI.slotIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user