diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs index b044a3d9e1..85caf70269 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs @@ -11,6 +11,7 @@ using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Prototypes; @@ -101,6 +102,9 @@ namespace Content.Server.GameObjects.Components.Chemistry /// A user interface message from the client. private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj) { + if(!PlayerCanUseDispenser(obj.Session.AttachedEntity)) + return; + var msg = (UiButtonPressedMessage) obj.Message; switch (msg.Button) { @@ -142,6 +146,23 @@ namespace Content.Server.GameObjects.Components.Chemistry ClickSound(); } + /// + /// Checks whether the player entity is able to use the chem dispenser. + /// + /// The player entity. + /// Returns true if the entity can use the dispenser, and false if it cannot. + private bool PlayerCanUseDispenser(IEntity playerEntity) + { + //Need player entity to check if they are still able to use the dispenser + if (playerEntity == null) + return false; + //Check if player can interact in their current state + if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + return false; + + return true; + } + /// /// Gets component data to be used to update the user interface client-side. ///