]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix pulling a new entity when already pulling an entity (#26499)
authorShadowCommander <shadowjjt@gmail.com>
Sat, 13 Apr 2024 15:36:05 +0000 (08:36 -0700)
committerGitHub <noreply@github.com>
Sat, 13 Apr 2024 15:36:05 +0000 (11:36 -0400)
Fix pulling when already pulling

The TryStopPull were failing due to wrong arguments provided.
Replacing the virtual item in hand with a different pull was failing due to the hand not being cleared.

Fix stop pulling checks that had the wrong variables provided.

VirtualItems are already queue deleted at the end of HandleEntityRemoved.

Content.Server/Hands/Systems/HandsSystem.cs
Content.Shared/Movement/Pulling/Systems/PullingSystem.cs

index bfd6393790ad203f48e32817f548bced930f64d5..e7527e2c76de63eaf72d142f47c405cbc9ea2b8d 100644 (file)
@@ -9,7 +9,6 @@ using Content.Shared.Damage.Systems;
 using Content.Shared.Explosion;
 using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
-using Content.Shared.IdentityManagement;
 using Content.Shared.Input;
 using Content.Shared.Inventory.VirtualItem;
 using Content.Shared.Movement.Pulling.Components;
@@ -17,8 +16,6 @@ using Content.Shared.Movement.Pulling.Events;
 using Content.Shared.Movement.Pulling.Systems;
 using Content.Shared.Stacks;
 using Content.Shared.Throwing;
-using Robust.Shared.Audio;
-using Robust.Shared.Audio.Systems;
 using Robust.Shared.GameStates;
 using Robust.Shared.Input.Binding;
 using Robust.Shared.Map;
@@ -160,7 +157,7 @@ namespace Content.Server.Hands.Systems
                     continue;
                 }
 
-                QueueDel(hand.HeldEntity.Value);
+                TryDrop(args.PullerUid, hand, handsComp: component);
                 break;
             }
         }
index acca7aafd0524cf4ff469360d4782b0117b5c8d1..3c265d5a027af6387bab940957db84bdb469af7e 100644 (file)
@@ -301,7 +301,9 @@ public sealed class PullingSystem : EntitySystem
             return false;
         }
 
-        if (pullerComp.NeedsHands && !_handsSystem.TryGetEmptyHand(puller, out _))
+        if (pullerComp.NeedsHands
+            && !_handsSystem.TryGetEmptyHand(puller, out _)
+            && pullerComp.Pulling == null)
         {
             return false;
         }
@@ -365,7 +367,7 @@ public sealed class PullingSystem : EntitySystem
         return TogglePull(puller.Pulling.Value, pullerUid, pullable);
     }
 
-    public bool TryStartPull(EntityUid pullerUid, EntityUid pullableUid, EntityUid? user = null,
+    public bool TryStartPull(EntityUid pullerUid, EntityUid pullableUid,
         PullerComponent? pullerComp = null, PullableComponent? pullableComp = null)
     {
         if (!Resolve(pullerUid, ref pullerComp, false) ||
@@ -387,23 +389,18 @@ public sealed class PullingSystem : EntitySystem
         }
 
         // Ensure that the puller is not currently pulling anything.
-        var oldPullable = pullerComp.Pulling;
-
-        if (oldPullable != null)
-        {
-            // Well couldn't stop the old one.
-            if (!TryStopPull(oldPullable.Value, pullableComp, user))
-                return false;
-        }
+        if (TryComp<PullableComponent>(pullerComp.Pulling, out var oldPullable)
+            && !TryStopPull(pullerComp.Pulling.Value, oldPullable, pullerUid))
+            return false;
 
-        // Is the pullable currently being pulled by something else?
+        // Stop anyone else pulling the entity we want to pull
         if (pullableComp.Puller != null)
         {
-            // Uhhh
+            // We're already pulling this item
             if (pullableComp.Puller == pullerUid)
                 return false;
 
-            if (!TryStopPull(pullableUid, pullableComp, pullerUid))
+            if (!TryStopPull(pullableUid, pullableComp, pullableComp.Puller))
                 return false;
         }
 
@@ -469,7 +466,7 @@ public sealed class PullingSystem : EntitySystem
         var pullerUidNull = pullable.Puller;
 
         if (pullerUidNull == null)
-            return false;
+            return true;
 
         var msg = new AttemptStopPullingEvent(user);
         RaiseLocalEvent(pullableUid, msg, true);