Changing hands unwields item (#28161)

Unhand me, fiend
This commit is contained in:
Errant 2024-05-26 03:17:01 +02:00 committed by null
parent ed3e930117
commit 5768c2a8d4
No known key found for this signature in database
GPG Key ID: 212F05528FD678BE
1 changed files with 9 additions and 0 deletions

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