From 6574c9b7c31dc05831a95ddf121f2c29d9479fa4 Mon Sep 17 00:00:00 2001 From: Errant <35878406+Errant-4@users.noreply.github.com> Date: Sun, 26 May 2024 03:17:01 +0200 Subject: [PATCH] Changing hands unwields item (#28161) Unhand me, fiend --- Content.Shared/Wieldable/WieldableSystem.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Content.Shared/Wieldable/WieldableSystem.cs b/Content.Shared/Wieldable/WieldableSystem.cs index cee6c65fa1..c09044f84b 100644 --- a/Content.Shared/Wieldable/WieldableSystem.cs +++ b/Content.Shared/Wieldable/WieldableSystem.cs @@ -41,6 +41,7 @@ public sealed class WieldableSystem : EntitySystem SubscribeLocalEvent(OnItemLeaveHand); SubscribeLocalEvent(OnVirtualItemDeleted); SubscribeLocalEvent>(AddToggleWieldVerb); + SubscribeLocalEvent(OnDeselectWieldable); SubscribeLocalEvent(OnMeleeAttempt); SubscribeLocalEvent(OnShootAttempt); @@ -91,6 +92,14 @@ public sealed class WieldableSystem : EntitySystem _gun.RefreshModifiers(uid); } + private void OnDeselectWieldable(EntityUid uid, WieldableComponent component, HandDeselectedEvent args) + { + if (!component.Wielded) + return; + + TryUnwield(uid, component, args.User); + } + private void OnGunRefreshModifiers(Entity bonus, ref GunRefreshModifiersEvent args) { if (TryComp(bonus, out WieldableComponent? wield) && -- 2.51.2