Fix emitter lock toggle (#5066)

This commit is contained in:
Leon Friedrich
2021-10-29 00:29:19 +13:00
committed by GitHub
parent 94579d1877
commit 5dd73ff6e0
7 changed files with 11 additions and 51 deletions

View File

@@ -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);
}
}
}