Skip to content

Commit

Permalink
Fix quick-swap stacks of items (#32560)
Browse files Browse the repository at this point in the history
* remove picking up stack on quick swap

* better
  • Loading branch information
Plykiya authored Oct 2, 2024
1 parent cfc723e commit 2a07e46
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Content.Shared/Interaction/SmartEquipSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Input;
using Content.Shared.Inventory;
using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Whitelist;
Expand Down Expand Up @@ -151,8 +152,13 @@ private void HandleSmartEquip(ICommonSession? session, string equipmentSlot)
_hands.TryDrop(uid, hands.ActiveHand, handsComp: hands);
_storage.Insert(slotItem, handItem.Value, out var stacked, out _);

if (stacked != null)
_hands.TryPickup(uid, stacked.Value, handsComp: hands);
// if the hand item stacked with the things in inventory, but there's no more space left for the rest
// of the stack, place the stack back in hand rather than dropping it on the floor
if (stacked != null && !_storage.CanInsert(slotItem, handItem.Value, out _))
{
if (TryComp<StackComponent>(handItem.Value, out var handStack) && handStack.Count > 0)
_hands.TryPickup(uid, handItem.Value, handsComp: hands);
}

return;
}
Expand Down

0 comments on commit 2a07e46

Please sign in to comment.