diff --git a/Content.Shared/Weapons/Ranged/Components/GunRequiresWieldComponent.cs b/Content.Shared/Weapons/Ranged/Components/GunRequiresWieldComponent.cs
index 2ae71334b4..fa3732209f 100644
--- a/Content.Shared/Weapons/Ranged/Components/GunRequiresWieldComponent.cs
+++ b/Content.Shared/Weapons/Ranged/Components/GunRequiresWieldComponent.cs
@@ -6,8 +6,13 @@ namespace Content.Shared.Weapons.Ranged.Components;
///
/// Indicates that this gun requires wielding to be useable.
///
-[RegisterComponent, NetworkedComponent, Access(typeof(WieldableSystem))]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+[Access(typeof(WieldableSystem))]
public sealed partial class GunRequiresWieldComponent : Component
{
+ [DataField, AutoNetworkedField]
+ public TimeSpan LastPopup;
+ [DataField, AutoNetworkedField]
+ public TimeSpan PopupCooldown = TimeSpan.FromSeconds(1);
}
diff --git a/Content.Shared/Weapons/Ranged/Events/ShotAttemptedEvent.cs b/Content.Shared/Weapons/Ranged/Events/ShotAttemptedEvent.cs
index 40925ad614..d61862bf1a 100644
--- a/Content.Shared/Weapons/Ranged/Events/ShotAttemptedEvent.cs
+++ b/Content.Shared/Weapons/Ranged/Events/ShotAttemptedEvent.cs
@@ -1,3 +1,5 @@
+using Content.Shared.Weapons.Ranged.Components;
+
namespace Content.Shared.Weapons.Ranged.Events;
///
@@ -15,7 +17,7 @@ public record struct ShotAttemptedEvent
///
/// The gun being shot.
///
- public EntityUid Used;
+ public Entity Used;
public bool Cancelled { get; private set; }
diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
index 4e51ca2b62..4debc289be 100644
--- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
+++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
@@ -239,7 +239,7 @@ public abstract partial class SharedGunSystem : EntitySystem
var prevention = new ShotAttemptedEvent
{
User = user,
- Used = gunUid
+ Used = (gunUid, gun)
};
RaiseLocalEvent(gunUid, ref prevention);
if (prevention.Cancelled)
diff --git a/Content.Shared/Wieldable/WieldableSystem.cs b/Content.Shared/Wieldable/WieldableSystem.cs
index 778a664e2c..b765566f44 100644
--- a/Content.Shared/Wieldable/WieldableSystem.cs
+++ b/Content.Shared/Wieldable/WieldableSystem.cs
@@ -16,7 +16,7 @@ using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Weapons.Ranged.Systems;
using Content.Shared.Wieldable.Components;
using Robust.Shared.Audio.Systems;
-using Robust.Shared.Player;
+using Robust.Shared.Timing;
namespace Content.Shared.Wieldable;
@@ -30,6 +30,7 @@ public sealed class WieldableSystem : EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly UseDelaySystem _delay = default!;
[Dependency] private readonly SharedGunSystem _gun = default!;
+ [Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
@@ -42,7 +43,7 @@ public sealed class WieldableSystem : EntitySystem
SubscribeLocalEvent>(AddToggleWieldVerb);
SubscribeLocalEvent(OnMeleeAttempt);
- SubscribeLocalEvent(OnShootAttempt);
+ SubscribeLocalEvent(OnShootAttempt);
SubscribeLocalEvent(OnGunWielded);
SubscribeLocalEvent(OnGunUnwielded);
SubscribeLocalEvent(OnGunRefreshModifiers);
@@ -61,16 +62,21 @@ public sealed class WieldableSystem : EntitySystem
}
}
- private void OnShootAttempt(EntityUid uid, GunRequiresWieldComponent component, ref AttemptShootEvent args)
+ private void OnShootAttempt(EntityUid uid, GunRequiresWieldComponent component, ref ShotAttemptedEvent args)
{
if (TryComp(uid, out var wieldable) &&
!wieldable.Wielded)
{
- args.Cancelled = true;
+ args.Cancel();
- if (!HasComp(uid) && !HasComp(uid))
+ var time = _timing.CurTime;
+ if (time > component.LastPopup + component.PopupCooldown &&
+ !HasComp(uid) &&
+ !HasComp(uid))
{
- args.Message = Loc.GetString("wieldable-component-requires", ("item", uid));
+ component.LastPopup = time;
+ var message = Loc.GetString("wieldable-component-requires", ("item", uid));
+ _popupSystem.PopupClient(message, args.Used, args.User);
}
}
}