]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix borg ui mispredict opening (#28305)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 26 May 2024 20:07:16 +0000 (16:07 -0400)
committerGitHub <noreply@github.com>
Sun, 26 May 2024 20:07:16 +0000 (13:07 -0700)
move borg ui junk to shared

Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs [deleted file]
Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Server/Wires/WiresSystem.cs
Content.Shared/Lock/ActivatableUIRequiresLockComponent.cs [moved from Content.Server/Lock/Components/ActivatableUIRequiresLockComponent.cs with 66% similarity]
Content.Shared/Lock/LockSystem.cs
Content.Shared/Silicons/Borgs/SharedBorgSystem.cs
Content.Shared/Wires/ActivatableUIRequiresPanelComponent.cs [moved from Content.Server/Wires/ActivatableUIRequiresPanelComponent.cs with 71% similarity]
Content.Shared/Wires/SharedWiresSystem.cs

diff --git a/Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs b/Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs
deleted file mode 100644 (file)
index 04f8e2e..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-using Content.Server.Lock.Components;
-using Content.Server.Popups;
-using Content.Shared.UserInterface;
-using Content.Shared.Lock;
-using Content.Server.UserInterface;
-using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem;
-
-namespace Content.Server.Lock.EntitySystems;
-public sealed class ActivatableUIRequiresLockSystem : EntitySystem
-{
-    [Dependency] private readonly ActivatableUISystem _activatableUI = default!;
-    [Dependency] private readonly PopupSystem _popupSystem = default!;
-
-    public override void Initialize()
-    {
-        base.Initialize();
-
-        SubscribeLocalEvent<ActivatableUIRequiresLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
-        SubscribeLocalEvent<ActivatableUIRequiresLockComponent, LockToggledEvent>(LockToggled);
-    }
-
-    private void OnUIOpenAttempt(EntityUid uid, ActivatableUIRequiresLockComponent component, ActivatableUIOpenAttemptEvent args)
-    {
-        if (args.Cancelled)
-            return;
-
-        if (TryComp<LockComponent>(uid, out var lockComp) && lockComp.Locked != component.requireLocked)
-        {
-            args.Cancel();
-            if (lockComp.Locked)
-                _popupSystem.PopupEntity(Loc.GetString("entity-storage-component-locked-message"), uid, args.User);
-        }
-    }
-
-    private void LockToggled(EntityUid uid, ActivatableUIRequiresLockComponent component, LockToggledEvent args)
-    {
-        if (!TryComp<LockComponent>(uid, out var lockComp) || lockComp.Locked == component.requireLocked)
-            return;
-
-        _activatableUI.CloseAll(uid);
-    }
-}
-
index 97adfd00eb4cd4c3d6c20cebdd4116166e541273..082e38921a2cfae69b683de70148f553368b119d 100644 (file)
@@ -5,7 +5,6 @@ using Content.Server.DeviceNetwork.Systems;
 using Content.Server.Explosion.EntitySystems;
 using Content.Server.Hands.Systems;
 using Content.Server.PowerCell;
-using Content.Shared.UserInterface;
 using Content.Shared.Access.Systems;
 using Content.Shared.Alert;
 using Content.Shared.Database;
@@ -70,7 +69,6 @@ public sealed partial class BorgSystem : SharedBorgSystem
         SubscribeLocalEvent<BorgChassisComponent, MobStateChangedEvent>(OnMobStateChanged);
         SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
         SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
-        SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
         SubscribeLocalEvent<BorgChassisComponent, GetCharactedDeadIcEvent>(OnGetDeadIC);
 
         SubscribeLocalEvent<BorgBrainComponent, MindAddedMessage>(OnBrainMindAdded);
@@ -214,13 +212,6 @@ public sealed partial class BorgSystem : SharedBorgSystem
         UpdateUI(uid, component);
     }
 
-    private void OnUIOpenAttempt(EntityUid uid, BorgChassisComponent component, ActivatableUIOpenAttemptEvent args)
-    {
-        // borgs can't view their own ui
-        if (args.User == uid)
-            args.Cancel();
-    }
-
     private void OnGetDeadIC(EntityUid uid, BorgChassisComponent component, ref GetCharactedDeadIcEvent args)
     {
         args.Dead = true;
index c643759f504b358f7809ec72da5f43f199f0454a..944b0a0e2500c02ee44b76e62d3bb361e880c275 100644 (file)
@@ -4,27 +4,23 @@ using System.Threading;
 using Content.Server.Construction;
 using Content.Server.Construction.Components;
 using Content.Server.Power.Components;
-using Content.Server.UserInterface;
 using Content.Shared.DoAfter;
 using Content.Shared.GameTicking;
 using Content.Shared.Hands.Components;
 using Content.Shared.Interaction;
 using Content.Shared.Popups;
 using Content.Shared.Tools.Components;
-using Content.Shared.UserInterface;
 using Content.Shared.Wires;
 using Robust.Server.GameObjects;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
-using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem;
 
 namespace Content.Server.Wires;
 
 public sealed class WiresSystem : SharedWiresSystem
 {
     [Dependency] private readonly IPrototypeManager _protoMan = default!;
-    [Dependency] private readonly ActivatableUISystem _activatableUI = default!;
     [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
     [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
     [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
@@ -52,8 +48,6 @@ public sealed class WiresSystem : SharedWiresSystem
         SubscribeLocalEvent<WiresComponent, TimedWireEvent>(OnTimedWire);
         SubscribeLocalEvent<WiresComponent, PowerChangedEvent>(OnWiresPowered);
         SubscribeLocalEvent<WiresComponent, WireDoAfterEvent>(OnDoAfter);
-        SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
-        SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
         SubscribeLocalEvent<WiresPanelSecurityComponent, WiresPanelSecurityEvent>(SetWiresPanelSecurity);
     }
 
@@ -473,23 +467,6 @@ public sealed class WiresSystem : SharedWiresSystem
         _uiSystem.CloseUi(ent.Owner, WiresUiKey.Key);
     }
 
-    private void OnAttemptOpenActivatableUI(EntityUid uid, ActivatableUIRequiresPanelComponent component, ActivatableUIOpenAttemptEvent args)
-    {
-        if (args.Cancelled || !TryComp<WiresPanelComponent>(uid, out var wires))
-            return;
-
-        if (component.RequireOpen != wires.Open)
-            args.Cancel();
-    }
-
-    private void OnActivatableUIPanelChanged(EntityUid uid, ActivatableUIRequiresPanelComponent component, ref PanelChangedEvent args)
-    {
-        if (args.Open == component.RequireOpen)
-            return;
-
-        _activatableUI.CloseAll(uid);
-    }
-
     private void OnMapInit(EntityUid uid, WiresComponent component, MapInitEvent args)
     {
         if (!string.IsNullOrEmpty(component.LayoutId))
similarity index 66%
rename from Content.Server/Lock/Components/ActivatableUIRequiresLockComponent.cs
rename to Content.Shared/Lock/ActivatableUIRequiresLockComponent.cs
index dac677c1c276ca4272c7e0d0f359dd46ad7255fc..7d701ffd8741342ce32d702ec9cf4203102f849d 100644 (file)
@@ -1,15 +1,17 @@
-namespace Content.Server.Lock.Components;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Lock;
 
 /// <summary>
 /// This is used for activatable UIs that require the entity to have a lock in a certain state.
 /// </summary>
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, Access(typeof(LockSystem))]
 public sealed partial class ActivatableUIRequiresLockComponent : Component
 {
     /// <summary>
     /// TRUE: the lock must be locked to access the UI.
     /// FALSE: the lock must be unlocked to access the UI.
     /// </summary>
-    [DataField("requireLocked"), ViewVariables(VVAccess.ReadWrite)]
-    public bool requireLocked = false;
+    [DataField]
+    public bool RequireLocked;
 }
index 4115358d9d78198edf3bb5a370ceb9b6253ee26a..36ac5f025b1a74db203022b42c57da5b1eaf7dd0 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Interaction;
 using Content.Shared.Popups;
 using Content.Shared.Storage;
 using Content.Shared.Storage.Components;
+using Content.Shared.UserInterface;
 using Content.Shared.Verbs;
 using Content.Shared.Wires;
 using JetBrains.Annotations;
@@ -25,6 +26,7 @@ namespace Content.Shared.Lock;
 public sealed class LockSystem : EntitySystem
 {
     [Dependency] private readonly AccessReaderSystem _accessReader = default!;
+    [Dependency] private readonly ActivatableUISystem _activatableUI = default!;
     [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly SharedPopupSystem _sharedPopupSystem = default!;
@@ -48,6 +50,9 @@ public sealed class LockSystem : EntitySystem
         SubscribeLocalEvent<LockedWiresPanelComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
         SubscribeLocalEvent<LockedWiresPanelComponent, AttemptChangePanelEvent>(OnAttemptChangePanel);
         SubscribeLocalEvent<LockedAnchorableComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
+
+        SubscribeLocalEvent<ActivatableUIRequiresLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
+        SubscribeLocalEvent<ActivatableUIRequiresLockComponent, LockToggledEvent>(LockToggled);
     }
 
     private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
@@ -349,5 +354,26 @@ public sealed class LockSystem : EntitySystem
             args.User);
         args.Cancel();
     }
+
+    private void OnUIOpenAttempt(EntityUid uid, ActivatableUIRequiresLockComponent component, ActivatableUIOpenAttemptEvent args)
+    {
+        if (args.Cancelled)
+            return;
+
+        if (TryComp<LockComponent>(uid, out var lockComp) && lockComp.Locked != component.RequireLocked)
+        {
+            args.Cancel();
+            if (lockComp.Locked)
+                _sharedPopupSystem.PopupEntity(Loc.GetString("entity-storage-component-locked-message"), uid, args.User);
+        }
+    }
+
+    private void LockToggled(EntityUid uid, ActivatableUIRequiresLockComponent component, LockToggledEvent args)
+    {
+        if (!TryComp<LockComponent>(uid, out var lockComp) || lockComp.Locked == component.RequireLocked)
+            return;
+
+        _activatableUI.CloseAll(uid);
+    }
 }
 
index 0431d95a42f8dd1559bca7a9cd4a4e1e391f7f62..2983c0d642f22f11cd88ddf514b6153f6be4a792 100644 (file)
@@ -5,6 +5,7 @@ using Content.Shared.Movement.Systems;
 using Content.Shared.Popups;
 using Content.Shared.PowerCell.Components;
 using Content.Shared.Silicons.Borgs.Components;
+using Content.Shared.UserInterface;
 using Content.Shared.Wires;
 using Robust.Shared.Containers;
 
@@ -30,7 +31,8 @@ public abstract partial class SharedBorgSystem : EntitySystem
         SubscribeLocalEvent<BorgChassisComponent, EntInsertedIntoContainerMessage>(OnInserted);
         SubscribeLocalEvent<BorgChassisComponent, EntRemovedFromContainerMessage>(OnRemoved);
         SubscribeLocalEvent<BorgChassisComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
-
+        SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
+        
         InitializeRelay();
     }
 
@@ -75,6 +77,13 @@ public abstract partial class SharedBorgSystem : EntitySystem
         component.ModuleContainer = Container.EnsureContainer<Container>(uid, component.ModuleContainerId, containerManager);
     }
 
+    private void OnUIOpenAttempt(EntityUid uid, BorgChassisComponent component, ActivatableUIOpenAttemptEvent args)
+    {
+        // borgs can't view their own ui
+        if (args.User == uid)
+            args.Cancel();
+    }
+
     protected virtual void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args)
     {
 
similarity index 71%
rename from Content.Server/Wires/ActivatableUIRequiresPanelComponent.cs
rename to Content.Shared/Wires/ActivatableUIRequiresPanelComponent.cs
index f92df3d3d59abadb93d9361700bb220e24d16a31..6e8fff6e49ca100b92db09afbcf621ba8cad2c6c 100644 (file)
@@ -1,15 +1,17 @@
-namespace Content.Server.Wires;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Wires;
 
 /// <summary>
 /// This is used for activatable UIs that require the entity to have a panel in a certain state.
 /// </summary>
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, Access(typeof(SharedWiresSystem))]
 public sealed partial class ActivatableUIRequiresPanelComponent : Component
 {
     /// <summary>
     /// TRUE: the panel must be open to access the UI.
     /// FALSE: the panel must be closed to access the UI.
     /// </summary>
-    [DataField("requireOpen"), ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public bool RequireOpen = true;
 }
index b4b0768e0f771f0dba9180468929446136d68da3..d84766a5fc66691a259b5749ad326c2b0a53a463 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.Database;
 using Content.Shared.Examine;
 using Content.Shared.Interaction;
 using Content.Shared.Tools.Systems;
+using Content.Shared.UserInterface;
 using Robust.Shared.Audio.Systems;
 
 namespace Content.Shared.Wires;
@@ -10,6 +11,7 @@ namespace Content.Shared.Wires;
 public abstract class SharedWiresSystem : EntitySystem
 {
     [Dependency] protected readonly ISharedAdminLogManager AdminLogger = default!;
+    [Dependency] private readonly ActivatableUISystem _activatableUI = default!;
     [Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
     [Dependency] protected readonly SharedAudioSystem Audio = default!;
     [Dependency] protected readonly SharedToolSystem Tool = default!;
@@ -21,6 +23,9 @@ public abstract class SharedWiresSystem : EntitySystem
         SubscribeLocalEvent<WiresPanelComponent, WirePanelDoAfterEvent>(OnPanelDoAfter);
         SubscribeLocalEvent<WiresPanelComponent, InteractUsingEvent>(OnInteractUsing);
         SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
+
+        SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
+        SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
     }
 
     private void OnPanelDoAfter(EntityUid uid, WiresPanelComponent panel, WirePanelDoAfterEvent args)
@@ -132,4 +137,21 @@ public abstract class SharedWiresSystem : EntitySystem
 
         return entity.Comp.Open;
     }
+
+    private void OnAttemptOpenActivatableUI(EntityUid uid, ActivatableUIRequiresPanelComponent component, ActivatableUIOpenAttemptEvent args)
+    {
+        if (args.Cancelled || !TryComp<WiresPanelComponent>(uid, out var wires))
+            return;
+
+        if (component.RequireOpen != wires.Open)
+            args.Cancel();
+    }
+
+    private void OnActivatableUIPanelChanged(EntityUid uid, ActivatableUIRequiresPanelComponent component, ref PanelChangedEvent args)
+    {
+        if (args.Open == component.RequireOpen)
+            return;
+
+        _activatableUI.CloseAll(uid);
+    }
 }