]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix borg becoming emag immune if emag attempted with panel closed. (#23729)
authorArendian <137322659+Arendian@users.noreply.github.com>
Wed, 10 Jan 2024 22:01:38 +0000 (23:01 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2024 22:01:38 +0000 (17:01 -0500)
* Fix borg becoming emag immune if emag attempted with panel closed.

* new event

* removed code added in accessreader

* fix emag 1984

Content.Shared/Emag/Systems/EmagSystem.cs
Content.Shared/Silicons/Laws/SharedSiliconLawSystem.cs

index ebbd4c02ac639e5b608e7b7f05681d973a062f2e..4d3bbcbb8e9d84586e7f934e7af9c5c5890d3419 100644 (file)
@@ -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<EmaggedComponent>(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);
index c874b56ec06c510bd2b4e77ffd18a4d76e43920f..9aa0aa9a381aebd43accb4f2a686af7a217a57a9 100644 (file)
@@ -16,18 +16,23 @@ public abstract class SharedSiliconLawSystem : EntitySystem
     public override void Initialize()
     {
         SubscribeLocalEvent<EmagSiliconLawComponent, GotEmaggedEvent>(OnGotEmagged);
+        SubscribeLocalEvent<EmagSiliconLawComponent, OnAttemptEmagEvent>(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<WiresPanelComponent>(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;
     }