Changing hands unwields item (#28161)

Unhand me, fiend
This commit is contained in:
Errant
2024-05-26 03:17:01 +02:00
committed by GitHub
parent d99e73ed92
commit 6574c9b7c3

View 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) &&