Make wielding automatically drop the item on your other hand (#27975)

* Make wielding automatically drop the item on your other hand

* Fix docs

* Remove redundant parameter

* Fix not deleting virtuals on fail

* Make count freeable hands method

* Add popup when dropping item
This commit is contained in:
DrSmugleaf
2024-05-18 18:35:46 -07:00
committed by GitHub
parent 676fc22eb4
commit 3d41d5f2bc
5 changed files with 79 additions and 9 deletions

View File

@@ -161,7 +161,7 @@ public sealed class WieldableSystem : EntitySystem
return false;
}
if (hands.CountFreeHands() < component.FreeHandsRequired)
if (_handsSystem.CountFreeableHands((user, hands)) < component.FreeHandsRequired)
{
if (!quiet)
{
@@ -202,9 +202,21 @@ public sealed class WieldableSystem : EntitySystem
if (component.WieldSound != null)
_audioSystem.PlayPredicted(component.WieldSound, used, user);
var virtuals = new List<EntityUid>();
for (var i = 0; i < component.FreeHandsRequired; i++)
{
_virtualItemSystem.TrySpawnVirtualItemInHand(used, user);
if (_virtualItemSystem.TrySpawnVirtualItemInHand(used, user, out var virtualItem, true))
{
virtuals.Add(virtualItem.Value);
continue;
}
foreach (var existingVirtual in virtuals)
{
QueueDel(existingVirtual);
}
return false;
}
if (TryComp(used, out UseDelayComponent? useDelay)