hands ECS (#7081)
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Server.DoAfter;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Cuffs.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
@@ -26,6 +27,7 @@ namespace Content.Server.Cuffs.Components
|
||||
public sealed class CuffableComponent : SharedCuffableComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||
|
||||
/// <summary>
|
||||
/// How many of this entity's hands are currently cuffed.
|
||||
@@ -103,15 +105,13 @@ namespace Content.Server.Cuffs.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
var sys = _sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
// Success!
|
||||
if (_entMan.TryGetComponent(user, out HandsComponent? handsComponent) && handsComponent.IsHolding(handcuff))
|
||||
{
|
||||
// Good lord handscomponent is scuffed, I hope some smug person will fix it someday
|
||||
handsComponent.Drop(handcuff);
|
||||
}
|
||||
sys.TryDrop(user, handcuff);
|
||||
|
||||
Container.Insert(handcuff);
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? ownerHands) && ownerHands.HandNames.Count() > CuffedHandCount;
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? ownerHands) && ownerHands.Hands.Count() > CuffedHandCount;
|
||||
|
||||
OnCuffedStateChanged?.Invoke();
|
||||
UpdateAlert();
|
||||
@@ -133,23 +133,22 @@ namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
if (!_entMan.TryGetComponent(Owner, out HandsComponent? handsComponent)) return;
|
||||
|
||||
var itemCount = handsComponent.GetAllHeldItems().Count();
|
||||
var freeHandCount = handsComponent.HandNames.Count() - CuffedHandCount;
|
||||
var sys = _sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
if (freeHandCount < itemCount)
|
||||
var freeHandCount = handsComponent.Hands.Count() - CuffedHandCount;
|
||||
|
||||
foreach (var hand in handsComponent.Hands.Values)
|
||||
{
|
||||
foreach (var item in handsComponent.GetAllHeldItems())
|
||||
if (hand.IsEmpty)
|
||||
continue;
|
||||
|
||||
if (freeHandCount > 0)
|
||||
{
|
||||
if (freeHandCount < itemCount)
|
||||
{
|
||||
freeHandCount++;
|
||||
handsComponent.Drop(item.Owner, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
freeHandCount--;
|
||||
continue;
|
||||
}
|
||||
|
||||
sys.TryDrop(Owner, hand, checkActionBlocker: false, handsComp: handsComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +266,7 @@ namespace Content.Server.Cuffs.Components
|
||||
}
|
||||
}
|
||||
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? handsComponent) && handsComponent.HandNames.Count() > CuffedHandCount;
|
||||
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? handsComponent) && handsComponent.SortedHands.Count() > CuffedHandCount;
|
||||
OnCuffedStateChanged?.Invoke();
|
||||
UpdateAlert();
|
||||
Dirty();
|
||||
|
||||
Reference in New Issue
Block a user