diff --git a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs index 138d88d667..ee233271d4 100644 --- a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Content.Server.GameObjects.Components.Access; using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.Utility; using Content.Shared.GameObjects.Components.VendingMachines; @@ -16,6 +17,7 @@ using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Prototypes; @@ -146,7 +148,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines switch (message) { case VendingMachineEjectMessage msg: - TryEject(msg.ID); + TryEject(msg.ID, serverMsg.Session.AttachedEntity); break; case InventorySyncRequestMessage _: UserInterface?.SendMessage(new VendingMachineInventoryMessage(Inventory)); @@ -195,6 +197,19 @@ namespace Content.Server.GameObjects.Components.VendingMachines EntitySystem.Get().PlayFromEntity(_soundVend, Owner, AudioParams.Default.WithVolume(-2f)); } + private void TryEject(string id, IEntity? sender) + { + if (Owner.TryGetComponent(out var accessReader)) + { + if (sender == null || !accessReader.IsAllowed(sender)) + { + FlickDenyAnimation(); + return; + } + } + TryEject(id); + } + private void FlickDenyAnimation() { TrySetVisualState(VendingMachineVisualState.Deny); diff --git a/Resources/Prototypes/Entities/Constructible/Power/vending_machines.yml b/Resources/Prototypes/Entities/Constructible/Power/vending_machines.yml index 590f0b0923..5f4ccee31f 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/vending_machines.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/vending_machines.yml @@ -68,6 +68,8 @@ normalUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Bar"]] - type: entity parent: VendingMachine @@ -227,6 +229,8 @@ ejectUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Kitchen"]] - type: entity parent: VendingMachine @@ -277,6 +281,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Engineering"]] - type: entity parent: VendingMachine @@ -352,6 +358,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Medical"]] - type: entity parent: VendingMachine @@ -403,6 +411,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Hydroponics"]] - type: entity parent: VendingMachine @@ -428,6 +438,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Research"]] - type: entity parent: VendingMachine @@ -479,6 +491,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Security"]] - type: entity parent: VendingMachine @@ -505,6 +519,8 @@ ejectUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Hydroponics"]] - type: entity parent: VendingMachine @@ -749,6 +765,8 @@ denyUnshaded: true broken: true - type: WiresVisualizer + - type: AccessReader + access: [["Medical"]] - type: entity parent: VendingMachine