From 6bf45709e9e02badf0ff7f852acac71a28ee5824 Mon Sep 17 00:00:00 2001 From: Justin Trotter Date: Fri, 16 Sep 2022 09:06:29 -0500 Subject: [PATCH] Add access locks to gas canisters (#10575) --- .../Unary/Components/GasCanisterComponent.cs | 4 +++ .../Unary/EntitySystems/GasCanisterSystem.cs | 27 +++++++++++++++++- .../Components/SharedGasCanisterComponent.cs | 1 + .../en-US/atmos/gas-canister-component.ftl | 5 +++- .../Storage/Canisters/gas_canisters.yml | 18 ++++++++++++ .../Storage/canister.rsi/can-locked.png | Bin 0 -> 4821 bytes .../Storage/canister.rsi/can-unlocked.png | Bin 0 -> 4836 bytes .../Structures/Storage/canister.rsi/meta.json | 6 ++++ 8 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Resources/Textures/Structures/Storage/canister.rsi/can-locked.png create mode 100644 Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png 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 0000000000000000000000000000000000000000..9edd84975f38e5862c0875e7427c9c95bb1d2af9 GIT binary patch literal 4821 zcmeHKX;c$g7A_iOZD?(@-9XELEvVTSk{Tic2@o-YkU_~HP)SvwG@D5Q0h^@(Jt}>0 z>uC{DaT{C^9hV-B(#q;KEm>QgflUBr2w zjT28^>K^~)#QI5lGSB&YN3c)-eVBXDMMb(Sy!HN^Z`|+n?G9?SUoCbxQnr6{)r(a* z)?pX-l94GX$VF>VTziLS z+=#v#4-Jo&b*3%#Mkj=r%17R5vWx%1$v;&%OX=g+r1w1M_u|XYnQaaKoKrITfru23u*ZCIRqRwR=Fdr&%5HTea^vQz zLUuJB*>yT5-R;TL+0&aQl&|-w+rIk1ChkG?ya4UeoWt8`0q5#Z@%>{eLe@1_jprX7 zlj$Jfm5e{%MY1opVm(FEny_`#y|MV4jT4p{l2SKb2zP5KtusxTjpvWqm)+CkmGiPd zbZst-ye=N~T9sI{Y#_b=f&@}j+Y8|A}1 zM?KASJo|ET-td~kwPVW)BFe+Iec#E__=LdTd9Dd5D-we96vygh#WWXf*?Qu2eQFer zlTN*NIrc6M{@ep+W1wka4R8M1c|BAr-M;5*e%b})+8rglofxrTWkbD+bp+GsZ>%f| zpBJU?+FXrY%#VyUpZh`Fk>INR%5U^*YjTMHpZ7M;=Qk_%WnDPJ({A}{u;`IwhUp2gNYVO?DxUso3 zHGtn+D)voXFvVJ8H|8grL;H`zlS7}V(uECYidt3aSmW;KW$UaZY0CPUEDzPD-sI8G zeXVEurs-?iJpQst*5zV6j8R7kBI2mc&myZb*B6{M#*8 zCvIJJ`R&})#<;(n$r^jpcW%S6P0A%3mvssLRk^smpe^k3)--qbvV^N$6^(xRk8*D? zPcyIFnKvb;a7GB_n#=Tketu2emg1yf;gtx8Uio_2ewYYie$gLr}M=8@-$9mmLdA|OP;`~K5HLDu-6cin*@~Fy( zpWC%}-rLbhoBW39e|UM%FG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}(o8u5WVV|3ub zYk@hE&1(>09a*jF`7w}uZUhrY%hyh zRAvZ&T^q4rUi@AD`6=#)R(h1c0l|)hWZ{(H{lQ=7F(3aV_+#l>-yrJN`2<}%V~3qn z{wecje;7R`JIqucr`9sdwaL%1iOE|nv@kiy5soB%;uJx39qL=q{=)DqE|b0o6NWEl^q`1;s+r}F`TlF(yt zx-vzj6Prn6PG@)^z1+X@5ShmXSE$ zyyVC^OcsyJLvWPALYOF*j&N}=48f#cI9JAFFbSMF3`(rh=`odzFhK!uDhY5_l%V>;BVLaPInXu?G4R4;~EV>%W- zNCps#nd%e(nB^cBexR1X^lGg{txge8Od-K0&p~whGv%BDMdn|2Bm*w-OASn}UzY z`cu$hMglj-39$NAvLsBUAi(q(DA%`g@=r)C-j&42*$t za5|5}`+JAB4Z8jJ-WPo443=A(Y3u%MHaDX!q?_c>EIE%k>3mE>e$$Rnpfvyj9 zy%z)TW&EMKKG5}E47``|hwA#j(PcOEI7O(yzo0bmu%wBd_bYhNvX+L12%$Ho_l^_0 zzX6g_8d1Csg6zkeE(@rja3T=e=*3|{Hg|0uog8M?EwNq?L=>^mUlMovaU<#oLAI8M rzI>VHJ-ciD(QyTk=0Nl)2&y?!s~9n|)MZONu!h7zbA;sq3v>PhNB9(o literal 0 HcmV?d00001 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": [