Make PKA require wielding (#16638)

This commit is contained in:
metalgearsloth
2023-06-01 12:27:19 +10:00
committed by GitHub
parent f9df5f761c
commit 6537e683b0
8 changed files with 69 additions and 4 deletions

View File

@@ -39,6 +39,8 @@ public sealed class WieldableSystem : EntitySystem
SubscribeLocalEvent<MeleeRequiresWieldComponent, AttemptMeleeEvent>(OnMeleeAttempt);
SubscribeLocalEvent<GunRequiresWieldComponent, AttemptShootEvent>(OnShootAttempt);
SubscribeLocalEvent<GunWieldBonusComponent, ItemWieldedEvent>(OnGunWielded);
SubscribeLocalEvent<GunWieldBonusComponent, ItemUnwieldedEvent>(OnGunUnwielded);
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
}
@@ -63,6 +65,26 @@ public sealed class WieldableSystem : EntitySystem
}
}
private void OnGunUnwielded(EntityUid uid, GunWieldBonusComponent component, ItemUnwieldedEvent args)
{
if (!TryComp<GunComponent>(uid, out var gun))
return;
gun.MinAngle -= component.MinAngle;
gun.MaxAngle -= component.MaxAngle;
Dirty(gun);
}
private void OnGunWielded(EntityUid uid, GunWieldBonusComponent component, ref ItemWieldedEvent args)
{
if (!TryComp<GunComponent>(uid, out var gun))
return;
gun.MinAngle += component.MinAngle;
gun.MaxAngle += component.MaxAngle;
Dirty(gun);
}
private void OnDisarmAttemptEvent(EntityUid uid, WieldableComponent component, DisarmAttemptEvent args)
{
if (component.Wielded)
@@ -197,6 +219,9 @@ public sealed class WieldableSystem : EntitySystem
_popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", uid)), args.Args.User, args.Args.User);
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", args.Args.User),("item", uid)), args.Args.User, Filter.PvsExcept(args.Args.User), true);
var ev = new ItemWieldedEvent();
RaiseLocalEvent(uid, ref ev);
Dirty(component);
args.Handled = true;
}