HandsSystem Refactor (#38438)

* checkpoint

* pt 2

* pt... i forgot

* pt 4

* patch

* More test fixes

* optimization!!!

* the REAL hand system

* fix RetractableItemActionSystem.cs oversight

* the review

* test

* remove test usage of body prototype

* Update Content.IntegrationTests/Tests/Interaction/InteractionTest.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

* hellcode

* hellcode 2

* Minor cleanup

* test

* Chasing the last of the bugs

* changes

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
Nemanja
2025-06-25 09:13:03 -04:00
committed by GitHub
parent 6cffa8aabe
commit 524725d378
79 changed files with 849 additions and 897 deletions

View File

@@ -397,6 +397,10 @@ namespace Content.Shared.Cuffs
/// </summary>
private void OnHandCountChanged(Entity<CuffableComponent> ent, ref HandCountChangedEvent message)
{
// TODO: either don't store a container ref, or make it actually nullable.
if (ent.Comp.Container == default!)
return;
var dirty = false;
var handCount = CompOrNull<HandsComponent>(ent.Owner)?.Count ?? 0;
@@ -431,19 +435,19 @@ namespace Content.Shared.Cuffs
return;
var freeHands = 0;
foreach (var hand in _hands.EnumerateHands(uid, handsComponent))
foreach (var hand in _hands.EnumerateHands((uid, handsComponent)))
{
if (hand.HeldEntity == null)
if (!_hands.TryGetHeldItem((uid, handsComponent), hand, out var held))
{
freeHands++;
continue;
}
// Is this entity removable? (it might be an existing handcuff blocker)
if (HasComp<UnremoveableComponent>(hand.HeldEntity))
if (HasComp<UnremoveableComponent>(held))
continue;
_hands.DoDrop(uid, hand, true, handsComponent);
_hands.DoDrop(uid, hand, true);
freeHands++;
if (freeHands == 2)
break;