Add access locks to gas canisters (#10575)

This commit is contained in:
Justin Trotter
2022-09-16 09:06:29 -05:00
committed by GitHub
parent c893653078
commit 6bf45709e9
8 changed files with 59 additions and 2 deletions

View File

@@ -4,9 +4,12 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.Unary.Components;
using Content.Server.Cargo.Systems;
using Content.Server.Lock;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Popups;
using Content.Server.Storage.Components;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Database;
@@ -15,6 +18,7 @@ using Content.Shared.Interaction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Player;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
@@ -25,6 +29,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSys = default!;
public override void Initialize()
{
@@ -43,6 +50,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
SubscribeLocalEvent<GasCanisterComponent, GasCanisterHoldingTankEjectMessage>(OnHoldingTankEjectMessage);
SubscribeLocalEvent<GasCanisterComponent, GasCanisterChangeReleasePressureMessage>(OnCanisterChangeReleasePressure);
SubscribeLocalEvent<GasCanisterComponent, GasCanisterChangeReleaseValveMessage>(OnCanisterChangeReleaseValve);
SubscribeLocalEvent<GasCanisterComponent, LockToggledEvent>(OnLockToggled);
}
@@ -73,6 +81,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
containerManager.MakeContainer<ContainerSlot>(canister.ContainerName);
}
if (TryComp<LockComponent>(uid, out var lockComponent))
_appearanceSystem.SetData(uid, GasCanisterVisuals.Locked, lockComponent.Locked);
}
private void DirtyUI(EntityUid uid,
@@ -215,6 +226,13 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
{
_popupSystem.PopupEntity(Loc.GetString("gas-canister-popup-denied"), uid, Filter.Entities(args.User));
if (component.AccessDeniedSound != null)
_audioSys.PlayPvs(component.AccessDeniedSound, uid);
return;
}
_userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
args.Handled = true;
@@ -225,6 +243,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
return;
_userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
args.Handled = true;
@@ -301,12 +321,17 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
args.Price += _atmosphereSystem.GetPrice(component.Air);
}
/// <summary>
/// <summary>
/// Returns the gas mixture for the gas analyzer
/// </summary>
private void OnAnalyzed(EntityUid uid, GasCanisterComponent component, GasAnalyzerScanEvent args)
{
args.GasMixtures = new Dictionary<string, GasMixture?> { {Name(uid), component.Air} };
}
private void OnLockToggled(EntityUid uid, GasCanisterComponent component, LockToggledEvent args)
{
_appearanceSystem.SetData(uid, GasCanisterVisuals.Locked, args.Locked);
}
}
}