Fix drop/equip code (#8336)

This commit is contained in:
Leon Friedrich
2022-05-22 08:58:57 +12:00
committed by GitHub
parent 8b7b458167
commit 959c9a9615
2 changed files with 22 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.ActionBlocker;
using Content.Shared.Clothing.Components;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
@@ -144,8 +145,16 @@ public abstract partial class InventorySystem
return;
}
if (_handsSystem.CanDropHeld(actor, hands.ActiveHand!, checkActionBlocker: false))
TryEquip(actor, actor, held.Value, ev.Slot, predicted: true, inventory: inventory);
if (!_handsSystem.CanDropHeld(actor, hands.ActiveHand!, checkActionBlocker: false))
return;
var gotUnequipped = new GotUnequippedHandEvent(actor, held.Value, hands.ActiveHand!);
var didUnequip = new DidUnequipHandEvent(actor, held.Value, hands.ActiveHand!);
RaiseLocalEvent(held.Value, gotUnequipped, false);
RaiseLocalEvent(actor, didUnequip);
RaiseLocalEvent(held.Value, new HandDeselectedEvent(actor), false);
TryEquip(actor, actor, held.Value, ev.Slot, predicted: true, inventory: inventory, force: true);
}
public bool TryEquip(EntityUid uid, EntityUid itemUid, string slot, bool silent = false, bool force = false, bool predicted = false,