Cuffable/Handcuff ECS (#14382)

This commit is contained in:
Nemanja
2023-03-13 19:34:26 -04:00
committed by GitHub
parent 59bf67ec8c
commit 49f7575298
25 changed files with 947 additions and 933 deletions

View File

@@ -1,4 +1,5 @@
using Content.Client.Cuffs.Components;
using System.Linq;
using Content.Client.Cuffs;
using Content.Client.Examine;
using Content.Client.Hands;
using Content.Client.Strip;
@@ -7,6 +8,8 @@ using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Hands.Controls;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Cuffs;
using Content.Shared.Cuffs.Components;
using Content.Shared.Ensnaring.Components;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
@@ -16,7 +19,6 @@ using Content.Shared.Strip.Components;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
@@ -32,12 +34,13 @@ namespace Content.Client.Inventory
public sealed class StrippableBoundUserInterface : BoundUserInterface
{
private const int ButtonSeparation = 4;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!;
private ExamineSystem _examine = default!;
private InventorySystem _inv = default!;
private readonly SharedCuffableSystem _cuffable;
[ViewVariables]
private StrippingMenu? _strippingMenu;
@@ -50,6 +53,7 @@ namespace Content.Client.Inventory
IoCManager.InjectDependencies(this);
_examine = _entMan.EntitySysManager.GetEntitySystem<ExamineSystem>();
_inv = _entMan.EntitySysManager.GetEntitySystem<InventorySystem>();
_cuffable = _entMan.System<SharedCuffableSystem>();
var title = Loc.GetString("strippable-bound-user-interface-stripping-menu-title", ("ownerName", Identity.Name(Owner.Owner, _entMan)));
_strippingMenu = new StrippingMenu(title, this);
_strippingMenu.OnClose += Close;
@@ -98,7 +102,7 @@ namespace Content.Client.Inventory
if (_entMan.TryGetComponent(Owner.Owner, out HandsComponent? handsComp))
{
// good ol hands shit code. there is a GuiHands comparer that does the same thing... but these are hands
// and not gui hands... which are different...
// and not gui hands... which are different...
foreach (var hand in handsComp.Hands.Values)
{
if (hand.Location != HandLocation.Right)
@@ -159,10 +163,10 @@ namespace Content.Client.Inventory
if (_entMan.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virt))
{
button.Blocked = true;
if (_entMan.TryGetComponent(Owner.Owner, out CuffableComponent? cuff) && cuff.Container.Contains(virt.BlockingEntity))
if (_entMan.TryGetComponent(Owner.Owner, out CuffableComponent? cuff) && _cuffable.GetAllCuffs(cuff).Contains(virt.BlockingEntity))
button.BlockedRect.MouseFilter = MouseFilterMode.Ignore;
}
UpdateEntityIcon(button, hand.HeldEntity);
_strippingMenu!.HandsContainer.AddChild(button);
}