Eject verbs for chem and id console (#2098)
* chemmaster eject beaker * reagentdispencer eject beaker * idcardconsole eject ID * implementing InteractUsing for IDCardConsole * typos
This commit is contained in:
@@ -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<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
var item = eventArgs.Using;
|
||||
var user = eventArgs.User;
|
||||
|
||||
if (!PrivilegedIDEmpty && !TargetIDEmpty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.TryGetComponent<IdCardComponent>(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<IdCardConsoleComponent>
|
||||
{
|
||||
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<IdCardConsoleComponent>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AudioSystem>().PlayFromEntity("/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
|
||||
[Verb]
|
||||
public sealed class EjectBeakerVerb : Verb<ChemMasterComponent>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AudioSystem>().PlayFromEntity("/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
|
||||
|
||||
}
|
||||
|
||||
[Verb]
|
||||
public sealed class EjectBeakerVerb : Verb<ReagentDispenserComponent>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user