From 175660c8006252b17b69361680606248d796d15f Mon Sep 17 00:00:00 2001
From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Sat, 12 Aug 2023 21:21:06 -0400
Subject: [PATCH] Make "no access" popups appear again. (#19034)
---
Content.Shared/Lock/LockComponent.cs | 27 ++++++++++++---------------
Content.Shared/Lock/LockSystem.cs | 24 ++----------------------
2 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/Content.Shared/Lock/LockComponent.cs b/Content.Shared/Lock/LockComponent.cs
index fae5788612..31187a96cb 100644
--- a/Content.Shared/Lock/LockComponent.cs
+++ b/Content.Shared/Lock/LockComponent.cs
@@ -9,18 +9,21 @@ namespace Content.Shared.Lock;
///
[RegisterComponent, NetworkedComponent]
[Access(typeof(LockSystem))]
-public sealed class LockComponent : Component
+[AutoGenerateComponentState]
+public sealed partial class LockComponent : Component
{
///
/// Whether or not the lock is locked.
///
[DataField("locked"), ViewVariables(VVAccess.ReadWrite)]
+ [AutoNetworkedField]
public bool Locked = true;
///
/// Whether or not the lock is toggled by simply clicking.
///
[DataField("lockOnClick"), ViewVariables(VVAccess.ReadWrite)]
+ [AutoNetworkedField]
public bool LockOnClick;
///
@@ -39,25 +42,19 @@ public sealed class LockComponent : Component
/// Whether or not an emag disables it.
///
[DataField("breakOnEmag")]
+ [AutoNetworkedField]
public bool BreakOnEmag = true;
}
-[Serializable, NetSerializable]
-public sealed class LockComponentState : ComponentState
-{
- public bool Locked;
-
- public bool LockOnClick;
-
- public LockComponentState(bool locked, bool lockOnClick)
- {
- Locked = locked;
- LockOnClick = lockOnClick;
- }
-}
-
+///
+/// Event raised on the lock when a toggle is attempted.
+/// Can be cancelled to prevent it.
+///
[ByRefEvent]
public record struct LockToggleAttemptEvent(EntityUid User, bool Silent = false, bool Cancelled = false);
+///
+/// Event raised on a lock after it has been toggled.
+///
[ByRefEvent]
public readonly record struct LockToggledEvent(bool Locked);
diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs
index 145d77c523..7b2500b1d9 100644
--- a/Content.Shared/Lock/LockSystem.cs
+++ b/Content.Shared/Lock/LockSystem.cs
@@ -11,10 +11,6 @@ using Content.Shared.Storage.Components;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Shared.Audio;
-using Robust.Shared.GameStates;
-using Robust.Shared.Network;
-using Robust.Shared.Player;
-using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.Lock;
@@ -25,7 +21,6 @@ namespace Content.Shared.Lock;
[UsedImplicitly]
public sealed class LockSystem : EntitySystem
{
- [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -36,8 +31,6 @@ public sealed class LockSystem : EntitySystem
{
base.Initialize();
- SubscribeLocalEvent(OnGetState);
- SubscribeLocalEvent(OnHandleState);
SubscribeLocalEvent(OnStartup);
SubscribeLocalEvent(OnActivated);
SubscribeLocalEvent(OnStorageOpenAttempt);
@@ -46,19 +39,6 @@ public sealed class LockSystem : EntitySystem
SubscribeLocalEvent(OnEmagged);
}
- private void OnGetState(EntityUid uid, LockComponent component, ref ComponentGetState args)
- {
- args.State = new LockComponentState(component.Locked, component.LockOnClick);
- }
-
- private void OnHandleState(EntityUid uid, LockComponent component, ref ComponentHandleState args)
- {
- if (args.Current is not LockComponentState state)
- return;
- component.Locked = state.Locked;
- component.LockOnClick = state.LockOnClick;
- }
-
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
{
_appearanceSystem.SetData(uid, StorageVisuals.CanLock, true);
@@ -206,8 +186,8 @@ public sealed class LockSystem : EntitySystem
if (_accessReader.IsAllowed(user, reader))
return true;
- if (!quiet && _timing.IsFirstTimePredicted)
- _sharedPopupSystem.PopupEntity(Loc.GetString("lock-comp-has-user-access-fail"), uid, Filter.Local(), true);
+ if (!quiet)
+ _sharedPopupSystem.PopupClient(Loc.GetString("lock-comp-has-user-access-fail"), uid, user);
return false;
}