]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Changing hands unwields item (#28161)
authorErrant <35878406+Errant-4@users.noreply.github.com>
Sun, 26 May 2024 01:17:01 +0000 (03:17 +0200)
committerGitHub <noreply@github.com>
Sun, 26 May 2024 01:17:01 +0000 (21:17 -0400)
Unhand me, fiend

Content.Shared/Wieldable/WieldableSystem.cs

index cee6c65fa11eb91e1e6d788387bcb3c308803217..c09044f84b43aab833e05421e6d5806b64169da4 100644 (file)
@@ -41,6 +41,7 @@ public sealed class WieldableSystem : EntitySystem
         SubscribeLocalEvent<WieldableComponent, GotUnequippedHandEvent>(OnItemLeaveHand);
         SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
         SubscribeLocalEvent<WieldableComponent, GetVerbsEvent<InteractionVerb>>(AddToggleWieldVerb);
+        SubscribeLocalEvent<WieldableComponent, HandDeselectedEvent>(OnDeselectWieldable);
 
         SubscribeLocalEvent<MeleeRequiresWieldComponent, AttemptMeleeEvent>(OnMeleeAttempt);
         SubscribeLocalEvent<GunRequiresWieldComponent, ShotAttemptedEvent>(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<GunWieldBonusComponent> bonus, ref GunRefreshModifiersEvent args)
     {
         if (TryComp(bonus, out WieldableComponent? wield) &&