Fix emitter lock toggle (#5066)
This commit is contained in:
@@ -126,9 +126,12 @@ namespace Content.Server.Lock
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<EmitterComponent, PowerConsumerReceivedChanged>(ReceivedChanged);
|
||||
SubscribeLocalEvent<EmitterComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<EmitterComponent, InteractUsingEvent>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user