From: Arendian <137322659+Arendian@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:01:38 +0000 (+0100) Subject: Fix borg becoming emag immune if emag attempted with panel closed. (#23729) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=23e714e523f18ffe5c4a2e1e2186142371dbf0bb;p=space-station-14.git Fix borg becoming emag immune if emag attempted with panel closed. (#23729) * Fix borg becoming emag immune if emag attempted with panel closed. * new event * removed code added in accessreader * fix emag 1984 --- diff --git a/Content.Shared/Emag/Systems/EmagSystem.cs b/Content.Shared/Emag/Systems/EmagSystem.cs index ebbd4c02ac..4d3bbcbb8e 100644 --- a/Content.Shared/Emag/Systems/EmagSystem.cs +++ b/Content.Shared/Emag/Systems/EmagSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Emag.Components; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Popups; +using Content.Shared.Silicons.Laws.Components; using Content.Shared.Tag; namespace Content.Shared.Emag.Systems; @@ -79,6 +80,13 @@ public sealed class EmagSystem : EntitySystem if (HasComp(target)) return false; + var onAttemptEmagEvent = new OnAttemptEmagEvent(user); + RaiseLocalEvent(target, ref onAttemptEmagEvent); + + // prevent emagging if attempt fails + if (onAttemptEmagEvent.Handled) + return false; + var emaggedEvent = new GotEmaggedEvent(user); RaiseLocalEvent(target, ref emaggedEvent); @@ -90,3 +98,6 @@ public sealed class EmagSystem : EntitySystem [ByRefEvent] public record struct GotEmaggedEvent(EntityUid UserUid, bool Handled = false, bool Repeatable = false); + +[ByRefEvent] +public record struct OnAttemptEmagEvent(EntityUid UserUid, bool Handled = false); diff --git a/Content.Shared/Silicons/Laws/SharedSiliconLawSystem.cs b/Content.Shared/Silicons/Laws/SharedSiliconLawSystem.cs index c874b56ec0..9aa0aa9a38 100644 --- a/Content.Shared/Silicons/Laws/SharedSiliconLawSystem.cs +++ b/Content.Shared/Silicons/Laws/SharedSiliconLawSystem.cs @@ -16,18 +16,23 @@ public abstract class SharedSiliconLawSystem : EntitySystem public override void Initialize() { SubscribeLocalEvent(OnGotEmagged); + SubscribeLocalEvent(OnAttemptEmag); } - protected virtual void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args) + protected virtual void OnAttemptEmag(EntityUid uid, EmagSiliconLawComponent component, ref OnAttemptEmagEvent args) { if (component.RequireOpenPanel && TryComp(uid, out var panel) && !panel.Open) { _popup.PopupClient(Loc.GetString("law-emag-require-panel"), uid, args.UserUid); - return; + args.Handled = true; } + } + + protected virtual void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args) + { component.OwnerName = Name(args.UserUid); args.Handled = true; }