Make PKA require wielding (#16638)
This commit is contained in:
@@ -26,7 +26,7 @@ public sealed partial class WieldableComponent : Component
|
||||
public bool Wielded = false;
|
||||
|
||||
[DataField("wieldedInhandPrefix")]
|
||||
public string WieldedInhandPrefix = "wielded";
|
||||
public string? WieldedInhandPrefix = "wielded";
|
||||
|
||||
public string? OldInhandPrefix = null;
|
||||
|
||||
|
||||
7
Content.Shared/Wieldable/ItemWieldedEvent.cs
Normal file
7
Content.Shared/Wieldable/ItemWieldedEvent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared.Wieldable;
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on an entity when it is wielded.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct ItemWieldedEvent;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user