From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 26 May 2024 20:07:16 +0000 (-0400) Subject: fix borg ui mispredict opening (#28305) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=cba23487d3df52fbd14aec5a30d3ac90ca942f88;p=space-station-14.git fix borg ui mispredict opening (#28305) move borg ui junk to shared --- diff --git a/Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs b/Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs deleted file mode 100644 index 04f8e2eb54..0000000000 --- a/Content.Server/Lock/EntitySystems/ActivatableUIRequiresLockSystem.cs +++ /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(OnUIOpenAttempt); - SubscribeLocalEvent(LockToggled); - } - - private void OnUIOpenAttempt(EntityUid uid, ActivatableUIRequiresLockComponent component, ActivatableUIOpenAttemptEvent args) - { - if (args.Cancelled) - return; - - if (TryComp(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(uid, out var lockComp) || lockComp.Locked == component.requireLocked) - return; - - _activatableUI.CloseAll(uid); - } -} - diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 97adfd00eb..082e38921a 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -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(OnMobStateChanged); SubscribeLocalEvent(OnPowerCellChanged); SubscribeLocalEvent(OnPowerCellSlotEmpty); - SubscribeLocalEvent(OnUIOpenAttempt); SubscribeLocalEvent(OnGetDeadIC); SubscribeLocalEvent(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; diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index c643759f50..944b0a0e25 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -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(OnTimedWire); SubscribeLocalEvent(OnWiresPowered); SubscribeLocalEvent(OnDoAfter); - SubscribeLocalEvent(OnAttemptOpenActivatableUI); - SubscribeLocalEvent(OnActivatableUIPanelChanged); SubscribeLocalEvent(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(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)) diff --git a/Content.Server/Lock/Components/ActivatableUIRequiresLockComponent.cs b/Content.Shared/Lock/ActivatableUIRequiresLockComponent.cs similarity index 66% rename from Content.Server/Lock/Components/ActivatableUIRequiresLockComponent.cs rename to Content.Shared/Lock/ActivatableUIRequiresLockComponent.cs index dac677c1c2..7d701ffd87 100644 --- a/Content.Server/Lock/Components/ActivatableUIRequiresLockComponent.cs +++ b/Content.Shared/Lock/ActivatableUIRequiresLockComponent.cs @@ -1,15 +1,17 @@ -namespace Content.Server.Lock.Components; +using Robust.Shared.GameStates; + +namespace Content.Shared.Lock; /// /// This is used for activatable UIs that require the entity to have a lock in a certain state. /// -[RegisterComponent] +[RegisterComponent, NetworkedComponent, Access(typeof(LockSystem))] public sealed partial class ActivatableUIRequiresLockComponent : Component { /// /// TRUE: the lock must be locked to access the UI. /// FALSE: the lock must be unlocked to access the UI. /// - [DataField("requireLocked"), ViewVariables(VVAccess.ReadWrite)] - public bool requireLocked = false; + [DataField] + public bool RequireLocked; } diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs index 4115358d9d..36ac5f025b 100644 --- a/Content.Shared/Lock/LockSystem.cs +++ b/Content.Shared/Lock/LockSystem.cs @@ -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(OnLockToggleAttempt); SubscribeLocalEvent(OnAttemptChangePanel); SubscribeLocalEvent(OnUnanchorAttempt); + + SubscribeLocalEvent(OnUIOpenAttempt); + SubscribeLocalEvent(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(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(uid, out var lockComp) || lockComp.Locked == component.RequireLocked) + return; + + _activatableUI.CloseAll(uid); + } } diff --git a/Content.Shared/Silicons/Borgs/SharedBorgSystem.cs b/Content.Shared/Silicons/Borgs/SharedBorgSystem.cs index 0431d95a42..2983c0d642 100644 --- a/Content.Shared/Silicons/Borgs/SharedBorgSystem.cs +++ b/Content.Shared/Silicons/Borgs/SharedBorgSystem.cs @@ -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(OnInserted); SubscribeLocalEvent(OnRemoved); SubscribeLocalEvent(OnRefreshMovementSpeedModifiers); - + SubscribeLocalEvent(OnUIOpenAttempt); + InitializeRelay(); } @@ -75,6 +77,13 @@ public abstract partial class SharedBorgSystem : EntitySystem component.ModuleContainer = Container.EnsureContainer(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) { diff --git a/Content.Server/Wires/ActivatableUIRequiresPanelComponent.cs b/Content.Shared/Wires/ActivatableUIRequiresPanelComponent.cs similarity index 71% rename from Content.Server/Wires/ActivatableUIRequiresPanelComponent.cs rename to Content.Shared/Wires/ActivatableUIRequiresPanelComponent.cs index f92df3d3d5..6e8fff6e49 100644 --- a/Content.Server/Wires/ActivatableUIRequiresPanelComponent.cs +++ b/Content.Shared/Wires/ActivatableUIRequiresPanelComponent.cs @@ -1,15 +1,17 @@ -namespace Content.Server.Wires; +using Robust.Shared.GameStates; + +namespace Content.Shared.Wires; /// /// This is used for activatable UIs that require the entity to have a panel in a certain state. /// -[RegisterComponent] +[RegisterComponent, NetworkedComponent, Access(typeof(SharedWiresSystem))] public sealed partial class ActivatableUIRequiresPanelComponent : Component { /// /// TRUE: the panel must be open to access the UI. /// FALSE: the panel must be closed to access the UI. /// - [DataField("requireOpen"), ViewVariables(VVAccess.ReadWrite)] + [DataField] public bool RequireOpen = true; } diff --git a/Content.Shared/Wires/SharedWiresSystem.cs b/Content.Shared/Wires/SharedWiresSystem.cs index b4b0768e0f..d84766a5fc 100644 --- a/Content.Shared/Wires/SharedWiresSystem.cs +++ b/Content.Shared/Wires/SharedWiresSystem.cs @@ -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(OnPanelDoAfter); SubscribeLocalEvent(OnInteractUsing); SubscribeLocalEvent(OnExamine); + + SubscribeLocalEvent(OnAttemptOpenActivatableUI); + SubscribeLocalEvent(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(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); + } }