diff --git a/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs b/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs index 3b39327e65..20b59f61e2 100644 --- a/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs +++ b/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Server.Utility; @@ -8,6 +9,8 @@ using Content.Shared.Access; using Content.Shared.GameObjects.Components.Access; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; +using Content.Shared.GameObjects.Verbs; +using Content.Shared.GameObjects.EntitySystems; using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.Interfaces.GameObjects; @@ -23,7 +26,7 @@ namespace Content.Server.GameObjects.Components.Access { [RegisterComponent] [ComponentReference(typeof(IActivate))] - public class IdCardConsoleComponent : SharedIdCardConsoleComponent, IActivate + public class IdCardConsoleComponent : SharedIdCardConsoleComponent, IActivate, IInteractUsing { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; @@ -32,6 +35,9 @@ namespace Content.Server.GameObjects.Components.Access [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(IdCardConsoleUiKey.Key); + private bool PrivilegedIDEmpty => _privilegedIdContainer.ContainedEntities.Count < 1; + private bool TargetIDEmpty => _targetIdContainer.ContainedEntities.Count < 1; + public override void Initialize() { base.Initialize(); @@ -222,5 +228,85 @@ namespace Content.Server.GameObjects.Components.Access UserInterface?.Open(actor.playerSession); } + + public async Task InteractUsing(InteractUsingEventArgs eventArgs) + { + var item = eventArgs.Using; + var user = eventArgs.User; + + if (!PrivilegedIDEmpty && !TargetIDEmpty) + { + return false; + } + + if (!item.TryGetComponent(out var idCardComponent) || !user.TryGetComponent(out IHandsComponent? hand)) + { + return false; + } + + if (PrivilegedIDEmpty) + { + InsertIdFromHand(user, _privilegedIdContainer, hand); + } + + else if (TargetIDEmpty) + { + InsertIdFromHand(user, _targetIdContainer, hand); + } + + UpdateUserInterface(); + return true; + } + + [Verb] + public sealed class EjectPrivilegedIDVerb : Verb + { + protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data) + { + if (!ActionBlockerSystem.CanInteract(user)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Eject Privileged ID"); + data.Visibility = component.PrivilegedIDEmpty ? VerbVisibility.Invisible : VerbVisibility.Visible; + } + + protected override void Activate(IEntity user, IdCardConsoleComponent component) + { + if (!user.TryGetComponent(out IHandsComponent? hand)) + { + return; + } + component.PutIdInHand(component._privilegedIdContainer, hand); + } + } + + public sealed class EjectTargetIDVerb : Verb + { + protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data) + { + if (!ActionBlockerSystem.CanInteract(user)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Eject Target ID"); + data.Visibility = component.TargetIDEmpty ? VerbVisibility.Invisible : VerbVisibility.Visible; + } + + protected override void Activate(IEntity user, IdCardConsoleComponent component) + { + if (!user.TryGetComponent(out IHandsComponent? hand)) + { + return; + } + component.PutIdInHand(component._targetIdContainer, hand); + } + } + + } } diff --git a/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs index a05d9cd351..b714c06069 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs @@ -15,6 +15,7 @@ using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Utility; +using Content.Shared.GameObjects.Verbs; using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.EntitySystems; @@ -417,5 +418,27 @@ namespace Content.Server.GameObjects.Components.Chemistry { EntitySystem.Get().PlayFromEntity("/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); } + + [Verb] + public sealed class EjectBeakerVerb : Verb + { + protected override void GetData(IEntity user, ChemMasterComponent component, VerbData data) + { + if (!ActionBlockerSystem.CanInteract(user)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Eject Beaker"); + data.Visibility = component.HasBeaker ? VerbVisibility.Visible : VerbVisibility.Invisible; + } + + protected override void Activate(IEntity user, ChemMasterComponent component) + { + component.TryEject(user); + } + } + } } diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs index f2b2cfcfca..44ea32f8b8 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs @@ -13,6 +13,7 @@ using Content.Shared.GameObjects.Components.Chemistry.ReagentDispenser; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; +using Content.Shared.GameObjects.Verbs; using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.EntitySystems; @@ -342,5 +343,26 @@ namespace Content.Server.GameObjects.Components.Chemistry EntitySystem.Get().PlayFromEntity("/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); } + + [Verb] + public sealed class EjectBeakerVerb : Verb + { + protected override void GetData(IEntity user, ReagentDispenserComponent component, VerbData data) + { + if (!ActionBlockerSystem.CanInteract(user)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Eject Beaker"); + data.Visibility = component.HasBeaker ? VerbVisibility.Visible : VerbVisibility.Invisible; + } + + protected override void Activate(IEntity user, ReagentDispenserComponent component) + { + component.TryEject(user); + } + } } }