diff --git a/Content.Client/Singularity/Visualizers/EmitterVisualizer.cs b/Content.Client/Singularity/Visualizers/EmitterVisualizer.cs index 74c59b3223..a9efc7abc1 100644 --- a/Content.Client/Singularity/Visualizers/EmitterVisualizer.cs +++ b/Content.Client/Singularity/Visualizers/EmitterVisualizer.cs @@ -1,5 +1,6 @@ using System; using Content.Shared.Singularity.Components; +using Content.Shared.Storage; using JetBrains.Annotations; using Robust.Client.GameObjects; @@ -20,7 +21,7 @@ namespace Content.Client.Singularity.Visualizers return; } - if (!component.TryGetData(EmitterVisuals.Locked, out bool locked)) + if (!component.TryGetData(StorageVisuals.Locked, out bool locked)) locked = false; diff --git a/Content.Server/Lock/LockSystem.cs b/Content.Server/Lock/LockSystem.cs index 0cb71d03c2..cafd9b5c30 100644 --- a/Content.Server/Lock/LockSystem.cs +++ b/Content.Server/Lock/LockSystem.cs @@ -126,9 +126,12 @@ namespace Content.Server.Lock return true; } + /// + /// Before locking the entity, check whether it's a locker. If is, prevent it from being locked from the inside or while it is open. + /// public bool CanToggleLock(EntityUid uid, IEntity user, EntityStorageComponent? storage = null, bool quiet = true) { - if (!Resolve(uid, ref storage)) + if (!Resolve(uid, ref storage, logMissing: false)) return true; // Cannot lock if the entity is currently opened. diff --git a/Content.Server/Singularity/Components/EmitterComponent.cs b/Content.Server/Singularity/Components/EmitterComponent.cs index 64cf772c77..a21401bfa5 100644 --- a/Content.Server/Singularity/Components/EmitterComponent.cs +++ b/Content.Server/Singularity/Components/EmitterComponent.cs @@ -26,7 +26,6 @@ namespace Content.Server.Singularity.Components [ViewVariables] public bool IsOn; // Whether the power switch is on AND the machine has enough power (so is actively firing) [ViewVariables] public bool IsPowered; - [ViewVariables] public bool IsLocked; // For the "emitter fired" sound public const float Variation = 0.25f; diff --git a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs index 625ad1e52b..77dd0b3d05 100644 --- a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs @@ -1,10 +1,9 @@ using System; using System.Threading; -using Content.Server.Access.Components; -using Content.Server.Access.Systems; using Content.Server.Power.EntitySystems; using Content.Server.Projectiles.Components; using Content.Server.Singularity.Components; +using Content.Server.Storage.Components; using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Popups; @@ -27,7 +26,6 @@ namespace Content.Server.Singularity.EntitySystems public class EmitterSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly AccessReaderSystem _accessReader = default!; public override void Initialize() { @@ -35,45 +33,12 @@ namespace Content.Server.Singularity.EntitySystems SubscribeLocalEvent(ReceivedChanged); SubscribeLocalEvent(OnInteractHand); - SubscribeLocalEvent(OnInteractUsing); - } - - private void OnInteractUsing(EntityUid uid, EmitterComponent component, InteractUsingEvent args) - { - if(args.Handled) return; - - if (component.AccessReader == null) - { - return; - } - - if (_accessReader.IsAllowed(component.AccessReader, args.Used.Uid)) - { - component.IsLocked ^= true; - - if (component.IsLocked) - { - component.Owner.PopupMessage(args.User, Loc.GetString("comp-emitter-lock", ("target", component.Owner))); - } - else - { - component.Owner.PopupMessage(args.User, Loc.GetString("comp-emitter-unlock", ("target", component.Owner))); - } - - UpdateAppearance(component); - } - else - { - component.Owner.PopupMessage(args.User, Loc.GetString("comp-emitter-access-denied")); - } - - args.Handled = true; } private void OnInteractHand(EntityUid uid, EmitterComponent component, InteractHandEvent args) { args.Handled = true; - if (component.IsLocked) + if (EntityManager.TryGetComponent(uid, out LockComponent? lockComp) && lockComp.Locked) { component.Owner.PopupMessage(args.User, Loc.GetString("comp-emitter-access-locked", ("target", component.Owner))); return; @@ -252,7 +217,6 @@ namespace Content.Server.Singularity.EntitySystems } component.Appearance.SetData(EmitterVisuals.VisualState, state); - component.Appearance.SetData(EmitterVisuals.Locked, component.IsLocked); } } } diff --git a/Content.Shared/Singularity/Components/SharedEmitterComponent.cs b/Content.Shared/Singularity/Components/SharedEmitterComponent.cs index d5d128bcb2..6c5a82e196 100644 --- a/Content.Shared/Singularity/Components/SharedEmitterComponent.cs +++ b/Content.Shared/Singularity/Components/SharedEmitterComponent.cs @@ -6,8 +6,7 @@ namespace Content.Shared.Singularity.Components [NetSerializable, Serializable] public enum EmitterVisuals { - VisualState, - Locked + VisualState } [NetSerializable, Serializable] diff --git a/Resources/Locale/en-US/singularity/components/emitter-component.ftl b/Resources/Locale/en-US/singularity/components/emitter-component.ftl index 55b280e133..ef17336644 100644 --- a/Resources/Locale/en-US/singularity/components/emitter-component.ftl +++ b/Resources/Locale/en-US/singularity/components/emitter-component.ftl @@ -3,14 +3,6 @@ # Shows when attempting to turn the emitter on or off without proper access comp-emitter-access-locked = The {$target} is access locked! -# Shows when attempting to lock or unlock the emitter without proper access -comp-emitter-access-denied = Access denied. - -# Shows when locking/unlocking the emitter -comp-emitter-lock = You lock the {$target}. - -comp-emitter-unlock = You unlock the {$target}. - # Shows when turning the emitter on/off comp-emitter-turned-on = The {$target} turns on. diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml index a7580c92c5..168de1ffa9 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml @@ -69,5 +69,7 @@ - type: Appearance visuals: - type: EmitterVisualizer + - type: Lock + locked: false - type: AccessReader access: [[ "Engineering" ]]