diff --git a/Content.Server/Atmos/Piping/Unary/Components/GasCanisterComponent.cs b/Content.Server/Atmos/Piping/Unary/Components/GasCanisterComponent.cs index 9943d8b9d3..37748780a8 100644 --- a/Content.Server/Atmos/Piping/Unary/Components/GasCanisterComponent.cs +++ b/Content.Server/Atmos/Piping/Unary/Components/GasCanisterComponent.cs @@ -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"); } } diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index bfeaf1f352..ebcd4605f2 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -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(OnHoldingTankEjectMessage); SubscribeLocalEvent(OnCanisterChangeReleasePressure); SubscribeLocalEvent(OnCanisterChangeReleaseValve); + SubscribeLocalEvent(OnLockToggled); } @@ -73,6 +81,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems { containerManager.MakeContainer(canister.ContainerName); } + + if (TryComp(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(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(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); } - /// + /// /// Returns the gas mixture for the gas analyzer /// private void OnAnalyzed(EntityUid uid, GasCanisterComponent component, GasAnalyzerScanEvent args) { args.GasMixtures = new Dictionary { {Name(uid), component.Air} }; } + + private void OnLockToggled(EntityUid uid, GasCanisterComponent component, LockToggledEvent args) + { + _appearanceSystem.SetData(uid, GasCanisterVisuals.Locked, args.Locked); + } } } diff --git a/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs b/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs index a8b17fe0b1..c7694aaae7 100644 --- a/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs +++ b/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs @@ -22,6 +22,7 @@ namespace Content.Shared.Atmos.Piping.Binary.Components { PressureState, TankInserted, + Locked } #endregion diff --git a/Resources/Locale/en-US/atmos/gas-canister-component.ftl b/Resources/Locale/en-US/atmos/gas-canister-component.ftl index edc657b616..68c2c1cb07 100644 --- a/Resources/Locale/en-US/atmos/gas-canister-component.ftl +++ b/Resources/Locale/en-US/atmos/gas-canister-component.ftl @@ -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 @@ -14,4 +17,4 @@ gas-canister-window-release-pressure-label = Release pressure: gas-canister-window-valve-label = Valve: gas-canister-window-valve-closed-text = Closed gas-canister-window-valve-open-text = Open -gas-canister-window-pressure-format-text = {$pressure}kPa \ No newline at end of file +gas-canister-window-pressure-format-text = {$pressure}kPa diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index 70fdee7797..15acc6cb8c 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -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 diff --git a/Resources/Textures/Structures/Storage/canister.rsi/can-locked.png b/Resources/Textures/Structures/Storage/canister.rsi/can-locked.png new file mode 100644 index 0000000000..9edd84975f Binary files /dev/null and b/Resources/Textures/Structures/Storage/canister.rsi/can-locked.png differ diff --git a/Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png b/Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png new file mode 100644 index 0000000000..5ba12d06af Binary files /dev/null and b/Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png differ diff --git a/Resources/Textures/Structures/Storage/canister.rsi/meta.json b/Resources/Textures/Structures/Storage/canister.rsi/meta.json index a9565d3aec..431366727e 100644 --- a/Resources/Textures/Structures/Storage/canister.rsi/meta.json +++ b/Resources/Textures/Structures/Storage/canister.rsi/meta.json @@ -22,6 +22,12 @@ { "name": "can-connector" }, + { + "name": "can-locked" + }, + { + "name": "can-unlocked" + }, { "name": "can-o0", "delays": [