Pulling rework (#20906)

* Pulling rework

Fixing up the FOUR systems managing pulling, all the shitcode, and also making it nicer ingame.

* More pulling cleanup

* stats

* More cleanup

* First draft

* More pulling

* weh

* Fix puller

* Pulling working

* Fix merge

* Dunked

* Self-merge time
This commit is contained in:
metalgearsloth
2024-02-03 14:36:09 +11:00
committed by GitHub
parent 79e3a6630d
commit 0d8254b2a2
53 changed files with 764 additions and 1359 deletions

View File

@@ -1,6 +1,5 @@
using System.Numerics;
using Content.Server.Inventory;
using Content.Server.Pulling;
using Content.Server.Stack;
using Content.Server.Stunnable;
using Content.Shared.ActionBlocker;
@@ -11,8 +10,9 @@ using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Input;
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Stacks;
using Content.Shared.Throwing;
using Robust.Shared.GameStates;
@@ -88,9 +88,8 @@ namespace Content.Server.Hands.Systems
return;
// Break any pulls
if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled &&
TryComp(pulled, out SharedPullableComponent? pullable))
_pullingSystem.TryStopPull(pullable);
if (TryComp(uid, out PullerComponent? puller) && TryComp(puller.Pulling, out PullableComponent? pullable))
_pullingSystem.TryStopPull(puller.Pulling.Value, pullable);
if (!_handsSystem.TryDrop(uid, component.ActiveHand!, null, checkActionBlocker: false))
return;
@@ -128,13 +127,13 @@ namespace Content.Server.Hands.Systems
private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
{
if (args.Puller.Owner != uid)
if (args.PullerUid != uid)
return;
if (TryComp<SharedPullerComponent>(args.Puller.Owner, out var pullerComp) && !pullerComp.NeedsHands)
if (TryComp<PullerComponent>(args.PullerUid, out var pullerComp) && !pullerComp.NeedsHands)
return;
if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid))
if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.PulledUid, uid))
{
DebugTools.Assert("Unable to find available hand when starting pulling??");
}
@@ -142,7 +141,7 @@ namespace Content.Server.Hands.Systems
private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
{
if (args.Puller.Owner != uid)
if (args.PullerUid != uid)
return;
// Try find hand that is doing this pull.
@@ -151,8 +150,10 @@ namespace Content.Server.Hands.Systems
{
if (hand.HeldEntity == null
|| !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem)
|| virtualItem.BlockingEntity != args.Pulled.Owner)
|| virtualItem.BlockingEntity != args.PulledUid)
{
continue;
}
QueueDel(hand.HeldEntity.Value);
break;