diff --git a/Content.Server/Wires/WiresComponent.cs b/Content.Server/Wires/WiresComponent.cs index 8223ba7f52..2a96c19c1e 100644 --- a/Content.Server/Wires/WiresComponent.cs +++ b/Content.Server/Wires/WiresComponent.cs @@ -62,6 +62,13 @@ public sealed class WiresComponent : Component [DataField("alwaysRandomize")] public bool AlwaysRandomize { get; } + /// + /// Marks if maintenance panel being open/closed by someone with a screwdriver. + /// Prevents do after spam. + /// + [ViewVariables(VVAccess.ReadWrite)] + public bool IsScrewing; + /// /// Per wire status, keyed by an object. /// diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index 113ea9e48c..2d9ed56752 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -50,6 +50,7 @@ public sealed class WiresSystem : EntitySystem // this is a broadcast event SubscribeLocalEvent(OnToolFinished); + SubscribeLocalEvent(OnToolCanceled); SubscribeLocalEvent(OnWiresStartup); SubscribeLocalEvent(OnWiresActionMessage); SubscribeLocalEvent(OnInteractUsing); @@ -462,9 +463,14 @@ public sealed class WiresSystem : EntitySystem args.Handled = true; } } - else if (_toolSystem.UseTool(args.Used, args.User, uid, 0f, ScrewTime, new string[]{ "Screwing" }, doAfterCompleteEvent:new WireToolFinishedEvent(uid), toolComponent:tool)) + else if (!component.IsScrewing && _toolSystem.HasQuality(args.Used, "Screwing", tool)) { - args.Handled = true; + component.IsScrewing = _toolSystem.UseTool(args.Used, args.User, uid, + 0f, ScrewTime, new[] { "Screwing" }, + new WireToolFinishedEvent(uid), + new WireToolCanceledEvent(uid), + toolComponent: tool); + args.Handled = component.IsScrewing; } } @@ -473,6 +479,7 @@ public sealed class WiresSystem : EntitySystem if (!EntityManager.TryGetComponent(args.Target, out WiresComponent? component)) return; + component.IsScrewing = false; component.IsPanelOpen = !component.IsPanelOpen; UpdateAppearance(args.Target); @@ -491,6 +498,14 @@ public sealed class WiresSystem : EntitySystem } } + private void OnToolCanceled(WireToolCanceledEvent ev) + { + if (!TryComp(ev.Target, out WiresComponent? component)) + return; + + component.IsScrewing = false; + } + private void OnExamine(EntityUid uid, WiresComponent component, ExaminedEvent args) { args.PushMarkup(Loc.GetString(component.IsPanelOpen @@ -911,6 +926,8 @@ public sealed class WiresSystem : EntitySystem } } + public record struct WireToolCanceledEvent(EntityUid Target); + private sealed class OnWireDoAfterEvent : EntityEventArgs { public EntityUid User { get; set; }