This commit is contained in:
2026-07-09 21:33:33 +02:00
commit 84a2a365f3
2364 changed files with 950134 additions and 0 deletions
@@ -0,0 +1,33 @@
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;
namespace VOID.Generic.Player.DraggingOperation
{
public class EquipmentToEquipmentDraggingOperation : AbstractDraggingOperation
{
public override bool Check(SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
{
return sourceSelect.slotUI?.slotType == SlotType.EquipmentSlot
&& targetSelect.slotUI?.slotType == SlotType.EquipmentSlot;
}
public override void Perform(UnitObject unit, SelectUtilResult sourceSelect, SelectUtilResult targetSelect)
{
if (sourceSelect.selectObject is not WearableObject wearable) return;
if (sourceSelect.slotUI.slotIndex == targetSelect.slotUI.slotIndex) return;
if (!unit.unitEquipment.CanEquipInSlot(targetSelect.slotUI.slotIndex, wearable)) return;
unit.OrderStop();
var orderChain = new List<AbstractAction>();
var otherItem = targetSelect.slotUI.item as WearableObject;
if (otherItem) orderChain.Add(new UnEquipAction(unit, otherItem));
orderChain.Add(new UnEquipAction(unit, wearable));
if (otherItem) orderChain.Add(new EquipAction(unit, otherItem, sourceSelect.slotUI.slotIndex));
orderChain.Add(new EquipAction(unit, wearable, targetSelect.slotUI.slotIndex));
unit.OrderChain(orderChain);
}
}
}