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

@@ -1,11 +1,10 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Interaction;
using Content.Server.Hands.Systems;
using Content.Shared.Access.Systems;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using JetBrains.Annotations;
using Robust.Shared.Utility;
@@ -152,6 +151,8 @@ public sealed partial class NPCBlackboard : IEnumerable<KeyValuePair<string, obj
value = default;
EntityUid owner;
var handSys = entManager.System<HandsSystem>();
switch (key)
{
case Access:
@@ -168,25 +169,24 @@ public sealed partial class NPCBlackboard : IEnumerable<KeyValuePair<string, obj
case ActiveHand:
{
if (!TryGetValue(Owner, out owner, entManager) ||
!entManager.TryGetComponent<HandsComponent>(owner, out var hands) ||
hands.ActiveHand == null)
handSys.GetActiveHand(owner) is not { } activeHand)
{
return false;
}
value = hands.ActiveHand;
value = activeHand;
return true;
}
case ActiveHandFree:
{
if (!TryGetValue(Owner, out owner, entManager) ||
!entManager.TryGetComponent<HandsComponent>(owner, out var hands) ||
hands.ActiveHand == null)
handSys.GetActiveHand(owner) is not { } activeHand)
{
return false;
}
value = hands.ActiveHand.IsEmpty;
value = handSys.HandIsEmpty((owner, hands), activeHand);
return true;
}
case CanMove:
@@ -204,16 +204,16 @@ public sealed partial class NPCBlackboard : IEnumerable<KeyValuePair<string, obj
{
if (!TryGetValue(Owner, out owner, entManager) ||
!entManager.TryGetComponent<HandsComponent>(owner, out var hands) ||
hands.ActiveHand == null)
handSys.GetActiveHand(owner) is null)
{
return false;
}
var handos = new List<string>();
foreach (var (id, hand) in hands.Hands)
foreach (var id in hands.Hands.Keys)
{
if (!hand.IsEmpty)
if (!handSys.HandIsEmpty((owner, hands), id))
continue;
handos.Add(id);
@@ -226,16 +226,16 @@ public sealed partial class NPCBlackboard : IEnumerable<KeyValuePair<string, obj
{
if (!TryGetValue(Owner, out owner, entManager) ||
!entManager.TryGetComponent<HandsComponent>(owner, out var hands) ||
hands.ActiveHand == null)
handSys.GetActiveHand(owner) is null)
{
return false;
}
var handos = new List<string>();
foreach (var (id, hand) in hands.Hands)
foreach (var id in hands.Hands.Keys)
{
if (!hand.IsEmpty)
if (!handSys.HandIsEmpty((owner, hands), id))
continue;
handos.Add(id);