Add access locks to gas canisters (#10575)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
{
|
||||
@@ -52,5 +53,8 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("releaseValve")]
|
||||
public bool ReleaseValve { get; set; } = false;
|
||||
|
||||
[DataField("accessDeniedSound")]
|
||||
public SoundSpecifier AccessDeniedSound = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Content.Shared.Atmos.Piping.Binary.Components
|
||||
{
|
||||
PressureState,
|
||||
TankInserted,
|
||||
Locked
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
gas-canister-bound-user-interface-title = Gas Canister
|
||||
|
||||
# Popup
|
||||
gas-canister-popup-denied = Access denied
|
||||
|
||||
# window
|
||||
|
||||
gas-canister-window-ok-text = OK
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
tankInserted:
|
||||
False: { state: can-open, visible: false }
|
||||
True: { state: can-open, visible: true }
|
||||
enum.GasCanisterVisuals.Locked:
|
||||
locked:
|
||||
False: { state: can-unlocked, shader: "unshaded" }
|
||||
True: { state: can-locked, shader: "unshaded" }
|
||||
enum.GasCanisterVisuals.PressureState:
|
||||
pressureLight:
|
||||
0: { state: can-o0, shader: "unshaded" }
|
||||
@@ -81,6 +85,10 @@
|
||||
- type: GasCanister
|
||||
- type: StaticPrice
|
||||
price: 1000
|
||||
- type: AccessReader
|
||||
access: [["Atmospherics"], ["ResearchDirector"]]
|
||||
- type: Lock
|
||||
locked: false
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
@@ -242,6 +250,8 @@
|
||||
max: 1
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- type: Lock
|
||||
locked: true
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
@@ -276,6 +286,8 @@
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- !type:DumpCanisterBehavior
|
||||
- type: Lock
|
||||
locked: true
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
@@ -310,6 +322,8 @@
|
||||
max: 1
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- type: Lock
|
||||
locked: true
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
@@ -381,6 +395,8 @@
|
||||
max: 1
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- type: Lock
|
||||
locked: true
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
@@ -455,6 +471,8 @@
|
||||
max: 1
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- type: Lock
|
||||
locked: true
|
||||
|
||||
# Broke Entities
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
@@ -22,6 +22,12 @@
|
||||
{
|
||||
"name": "can-connector"
|
||||
},
|
||||
{
|
||||
"name": "can-locked"
|
||||
},
|
||||
{
|
||||
"name": "can-unlocked"
|
||||
},
|
||||
{
|
||||
"name": "can-o0",
|
||||
"delays": [
|
||||
|
||||
Reference in New Issue
Block a user