ECS verbs and update context menu (#4594)
* Functioning ECS verbs Currently only ID card console works. * Changed verb types and allow ID card insertions * Verb GUI sorting and verb networking * More networking, and shared components * Clientside verbs work now. * Verb enums changed to bitmask flags * Verb Categories redo * Fix range check * GasTank Verb * Remove unnecessary bodypart verb * Buckle Verb * buckle & unbuckle verbs * Updated range checks * Item cabinet verbs * Add range user override * construction verb * Chemistry machine verbs * Climb Verb * Generalise pulled entity verbs * ViewVariables Verb * rejuvenate, delete, sentient, control verbs * Outfit verb * inrangeunoccluded and tubedirection verbs * attach-to verbs * remove unused verbs and move VV * Rename DebugVerbSystem * Ghost role and pointing verbs * Remove global verbs * Allow verbs to raise events * Changing categories and simplifying debug verbs * Add rotate and flip verbs * fix rejuvenate test * redo context menu * new Add Gas debug verb * Add Set Temperature debug verb * Uncuff verb * Disposal unit verbs * Add pickup verb * lock/unlock verb * Remove verb type, add specific verb events * rename verb messages -> events * Context menu displays verbs by interaction type * Updated context menu HandleMove previously, checked if entities moved 1 tile from click location. Now checks if entities moved out of view. Now you can actually right-click interact with yourself while walking! * Misc Verb menu GUI changes * Fix non-human/ghost verbs * Update types and categories * Allow non-ghost/human to open context menu * configuration verb * tagger verb * Morgue Verbs * Medical Scanner Verbs * Fix solution refactor merge issues * Fix context menu in-view check * Remove prepare GUI * Redo verb restrictions * Fix context menu UI * Disposal Verbs * Spill verb * Light verb * Hand Held light verb * power cell verbs * storage verbs and adding names to insert/eject * Pulling verb * Close context menu on verb execution * Strip verb * AmmoBox verb * fix pull verb * gun barrel verbs revolver verb energy weapon verbs Bolt action verb * Magazine gun barrel verbs * Add charger verbs * PDA verbs * Transfer amount verb * Add reagent verb * make alt-click use ECS verbs * Delete old verb files * Magboot verb * finalising tweaks * context menu visibility changes * code cleanup * Update AdminAddReagentUI.cs * Remove HasFlag * Consistent verb keys * Remove Linq, add comment * Fix in-inventory check * Update GUI text alignment and padding * Added close-menu option * Changed some "interaction" verbs to "activation" * Remove verb keys, use sorted sets * fix master merge * update some verb text * Undo Changes Remove some new verbs that can be added later undid some .ftl bugfixes, can and should be done separately * fix merge * Undo file rename * fix merge * Misc Cleanup * remove contraction * Fix keybinding issue * fix comment * merge fix * fix merge * fix merge * fix merge * fix merge * fix open-close verbs * adjust uncuff verb * fix merge and undo the renaming of SharedPullableComponent to PullableComponent. I'm tired of all of those merge conflicts
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Access;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -28,21 +25,21 @@ namespace Content.Server.Access.Components
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private ContainerSlot _privilegedIdContainer = default!;
|
||||
private ContainerSlot _targetIdContainer = default!;
|
||||
public ContainerSlot PrivilegedIdContainer = default!;
|
||||
public ContainerSlot TargetIdContainer = default!;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(IdCardConsoleUiKey.Key);
|
||||
[ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
|
||||
private bool PrivilegedIDEmpty => _privilegedIdContainer.ContainedEntities.Count < 1;
|
||||
private bool TargetIDEmpty => _targetIdContainer.ContainedEntities.Count < 1;
|
||||
public bool PrivilegedIDEmpty => PrivilegedIdContainer.ContainedEntities.Count < 1;
|
||||
public bool TargetIDEmpty => TargetIdContainer.ContainedEntities.Count < 1;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_privilegedIdContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-privilegedId");
|
||||
_targetIdContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-targetId");
|
||||
PrivilegedIdContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-privilegedId");
|
||||
TargetIdContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-targetId");
|
||||
|
||||
Owner.EnsureComponentWarn<AccessReader>();
|
||||
Owner.EnsureComponentWarn<ServerUserInterfaceComponent>();
|
||||
@@ -68,10 +65,10 @@ namespace Content.Server.Access.Components
|
||||
switch (msg.Button)
|
||||
{
|
||||
case UiButton.PrivilegedId:
|
||||
HandleId(obj.Session.AttachedEntity, _privilegedIdContainer);
|
||||
HandleId(obj.Session.AttachedEntity, PrivilegedIdContainer);
|
||||
break;
|
||||
case UiButton.TargetId:
|
||||
HandleId(obj.Session.AttachedEntity, _targetIdContainer);
|
||||
HandleId(obj.Session.AttachedEntity, TargetIdContainer);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -84,7 +81,7 @@ namespace Content.Server.Access.Components
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is an ID in <see cref="_privilegedIdContainer"/> and said ID satisfies the requirements of <see cref="AccessReader"/>.
|
||||
/// Returns true if there is an ID in <see cref="PrivilegedIdContainer"/> and said ID satisfies the requirements of <see cref="AccessReader"/>.
|
||||
/// </summary>
|
||||
private bool PrivilegedIdIsAuthorized()
|
||||
{
|
||||
@@ -93,22 +90,22 @@ namespace Content.Server.Access.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
var privilegedIdEntity = _privilegedIdContainer.ContainedEntity;
|
||||
var privilegedIdEntity = PrivilegedIdContainer.ContainedEntity;
|
||||
return privilegedIdEntity != null && reader.IsAllowed(privilegedIdEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the "Submit" button in the UI gets pressed.
|
||||
/// Writes data passed from the UI into the ID stored in <see cref="_targetIdContainer"/>, if present.
|
||||
/// Writes data passed from the UI into the ID stored in <see cref="TargetIdContainer"/>, if present.
|
||||
/// </summary>
|
||||
private void TryWriteToTargetId(string newFullName, string newJobTitle, List<string> newAccessList)
|
||||
{
|
||||
if (!PrivilegedIdIsAuthorized() || _targetIdContainer.ContainedEntity == null)
|
||||
if (!PrivilegedIdIsAuthorized() || TargetIdContainer.ContainedEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targetIdEntity = _targetIdContainer.ContainedEntity;
|
||||
var targetIdEntity = TargetIdContainer.ContainedEntity;
|
||||
|
||||
var targetIdComponent = targetIdEntity.GetComponent<IdCardComponent>();
|
||||
targetIdComponent.FullName = newFullName;
|
||||
@@ -128,7 +125,7 @@ namespace Content.Server.Access.Components
|
||||
/// </summary>
|
||||
private void HandleId(IEntity user, ContainerSlot container)
|
||||
{
|
||||
if (!user.TryGetComponent(out IHandsComponent? hands))
|
||||
if (!user.TryGetComponent(out SharedHandsComponent? hands))
|
||||
{
|
||||
Owner.PopupMessage(user, Loc.GetString("access-id-card-console-component-no-hands-error"));
|
||||
return;
|
||||
@@ -144,20 +141,15 @@ namespace Content.Server.Access.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void InsertIdFromHand(IEntity user, ContainerSlot container, IHandsComponent hands)
|
||||
public void InsertIdFromHand(IEntity user, ContainerSlot container, SharedHandsComponent hands)
|
||||
{
|
||||
var isId = hands.GetActiveHand?.Owner.HasComponent<IdCardComponent>();
|
||||
if (isId != true)
|
||||
{
|
||||
if (!hands.TryGetActiveHeldEntity(out var heldEntity))
|
||||
return;
|
||||
}
|
||||
|
||||
if (hands.ActiveHand == null)
|
||||
{
|
||||
if (!heldEntity.HasComponent<IdCardComponent>())
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hands.TryPutHandIntoContainer(hands.ActiveHand, container))
|
||||
if (!hands.TryPutHandIntoContainer(hands.ActiveHand!, container))
|
||||
{
|
||||
Owner.PopupMessage(user, Loc.GetString("access-id-card-console-component-cannot-let-go-error"));
|
||||
return;
|
||||
@@ -165,7 +157,7 @@ namespace Content.Server.Access.Components
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
private void PutIdInHand(ContainerSlot container, IHandsComponent hands)
|
||||
public void PutIdInHand(ContainerSlot container, SharedHandsComponent hands)
|
||||
{
|
||||
var idEntity = container.ContainedEntity;
|
||||
if (idEntity == null || !container.Remove(idEntity))
|
||||
@@ -174,13 +166,13 @@ namespace Content.Server.Access.Components
|
||||
}
|
||||
UpdateUserInterface();
|
||||
|
||||
hands.PutInHand(idEntity.GetComponent<ItemComponent>());
|
||||
hands.TryPutInActiveHandOrAny(idEntity);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface()
|
||||
{
|
||||
var isPrivilegedIdPresent = _privilegedIdContainer.ContainedEntity != null;
|
||||
var targetIdEntity = _targetIdContainer.ContainedEntity;
|
||||
var isPrivilegedIdPresent = PrivilegedIdContainer.ContainedEntity != null;
|
||||
var targetIdEntity = TargetIdContainer.ContainedEntity;
|
||||
IdCardConsoleBoundUserInterfaceState newState;
|
||||
// this could be prettier
|
||||
if (targetIdEntity == null)
|
||||
@@ -192,8 +184,8 @@ namespace Content.Server.Access.Components
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
_privilegedIdContainer.ContainedEntity?.Name ?? string.Empty,
|
||||
_targetIdContainer.ContainedEntity?.Name ?? string.Empty);
|
||||
PrivilegedIdContainer.ContainedEntity?.Name ?? string.Empty,
|
||||
TargetIdContainer.ContainedEntity?.Name ?? string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -206,8 +198,8 @@ namespace Content.Server.Access.Components
|
||||
targetIdComponent.FullName,
|
||||
targetIdComponent.JobTitle,
|
||||
targetAccessComponent.Tags.ToArray(),
|
||||
_privilegedIdContainer.ContainedEntity?.Name ?? string.Empty,
|
||||
_targetIdContainer.ContainedEntity?.Name ?? string.Empty);
|
||||
PrivilegedIdContainer.ContainedEntity?.Name ?? string.Empty,
|
||||
TargetIdContainer.ContainedEntity?.Name ?? string.Empty);
|
||||
}
|
||||
UserInterface?.SetState(newState);
|
||||
}
|
||||
@@ -233,89 +225,34 @@ namespace Content.Server.Access.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.HasComponent<IdCardComponent>() || !user.TryGetComponent(out IHandsComponent? hand))
|
||||
if (!item.HasComponent<IdCardComponent>() || !user.TryGetComponent(out SharedHandsComponent? hand))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PrivilegedIDEmpty)
|
||||
{
|
||||
InsertIdFromHand(user, _privilegedIdContainer, hand);
|
||||
InsertIdFromHand(user, PrivilegedIdContainer, hand);
|
||||
}
|
||||
|
||||
else if (TargetIDEmpty)
|
||||
{
|
||||
InsertIdFromHand(user, _targetIdContainer, hand);
|
||||
InsertIdFromHand(user, TargetIdContainer, hand);
|
||||
}
|
||||
|
||||
UpdateUserInterface();
|
||||
return true;
|
||||
}
|
||||
|
||||
[Verb]
|
||||
public sealed class EjectPrivilegedIDVerb : Verb<IdCardConsoleComponent>
|
||||
{
|
||||
public override bool AlternativeInteraction => true;
|
||||
|
||||
protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user))
|
||||
{
|
||||
data.Visibility = VerbVisibility.Invisible;
|
||||
return;
|
||||
}
|
||||
|
||||
data.Text = Loc.GetString("access-eject-privileged-id-verb-get-data-text");
|
||||
data.IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png";
|
||||
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>
|
||||
{
|
||||
public override bool AlternativeInteraction => true;
|
||||
|
||||
protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user))
|
||||
{
|
||||
data.Visibility = VerbVisibility.Invisible;
|
||||
return;
|
||||
}
|
||||
|
||||
data.Text = Loc.GetString("access-eject-target-id-verb-get-data-text");
|
||||
data.Visibility = component.TargetIDEmpty ? VerbVisibility.Invisible : VerbVisibility.Visible;
|
||||
data.IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png";
|
||||
}
|
||||
|
||||
protected override void Activate(IEntity user, IdCardConsoleComponent component)
|
||||
{
|
||||
if (!user.TryGetComponent(out IHandsComponent? hand))
|
||||
{
|
||||
return;
|
||||
}
|
||||
component.PutIdInHand(component._targetIdContainer, hand);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBreak(BreakageEventArgs eventArgs)
|
||||
{
|
||||
var privileged = _privilegedIdContainer.ContainedEntity;
|
||||
var privileged = PrivilegedIdContainer.ContainedEntity;
|
||||
if (privileged != null)
|
||||
_privilegedIdContainer.Remove(privileged);
|
||||
PrivilegedIdContainer.Remove(privileged);
|
||||
|
||||
var target = _targetIdContainer.ContainedEntity;
|
||||
var target = TargetIdContainer.ContainedEntity;
|
||||
if (target != null)
|
||||
_targetIdContainer.Remove(target);
|
||||
TargetIdContainer.Remove(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user