]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Predict pulling hands blocking (#37504)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 16 May 2025 12:44:46 +0000 (22:44 +1000)
committerGitHub <noreply@github.com>
Fri, 16 May 2025 12:44:46 +0000 (08:44 -0400)
Think I forgor to add this one when I split the 1 morbillion PRs out.

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

index ad8bf72674588251467785f7e2b1cb83715b4130..357046be56ce41d93caf7b0cc55c6114b9bf3204 100644 (file)
@@ -33,7 +33,6 @@ namespace Content.Server.Hands.Systems
         [Dependency] private readonly IGameTiming _timing = default!;
         [Dependency] private readonly IRobustRandom _random = default!;
         [Dependency] private readonly StackSystem _stackSystem = default!;
-        [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
         [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
         [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
         [Dependency] private readonly PullingSystem _pullingSystem = default!;
@@ -54,9 +53,6 @@ namespace Content.Server.Hands.Systems
 
             SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem), typeof(SharedStaminaSystem)});
 
-            SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
-            SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
-
             SubscribeLocalEvent<HandsComponent, BodyPartAddedEvent>(HandleBodyPartAdded);
             SubscribeLocalEvent<HandsComponent, BodyPartRemovedEvent>(HandleBodyPartRemoved);
 
@@ -142,45 +138,6 @@ namespace Content.Server.Hands.Systems
             RemoveHand(uid, args.Slot);
         }
 
-        #region pulling
-
-        private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
-        {
-            if (args.PullerUid != uid)
-                return;
-
-            if (TryComp<PullerComponent>(args.PullerUid, out var pullerComp) && !pullerComp.NeedsHands)
-                return;
-
-            if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.PulledUid, uid))
-            {
-                DebugTools.Assert("Unable to find available hand when starting pulling??");
-            }
-        }
-
-        private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
-        {
-            if (args.PullerUid != uid)
-                return;
-
-            // Try find hand that is doing this pull.
-            // and clear it.
-            foreach (var hand in component.Hands.Values)
-            {
-                if (hand.HeldEntity == null
-                    || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem)
-                    || virtualItem.BlockingEntity != args.PulledUid)
-                {
-                    continue;
-                }
-
-                TryDrop(args.PullerUid, hand, handsComp: component);
-                break;
-            }
-        }
-
-        #endregion
-
         #region interactions
 
         private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
index 369225df2de6fc2b1dee9afb232288f0f7897693..bc505ee98947b03ea1a7cc77930bc1edd575b646 100644 (file)
@@ -5,10 +5,12 @@ using Content.Shared.Buckle.Components;
 using Content.Shared.Cuffs.Components;
 using Content.Shared.Database;
 using Content.Shared.Hands;
+using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Input;
 using Content.Shared.Interaction;
+using Content.Shared.Inventory.VirtualItem;
 using Content.Shared.Item;
 using Content.Shared.Mobs;
 using Content.Shared.Mobs.Systems;
@@ -28,6 +30,7 @@ using Robust.Shared.Physics.Events;
 using Robust.Shared.Physics.Systems;
 using Robust.Shared.Player;
 using Robust.Shared.Timing;
+using Robust.Shared.Utility;
 
 namespace Content.Shared.Movement.Pulling.Systems;
 
@@ -48,6 +51,7 @@ public sealed class PullingSystem : EntitySystem
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] private readonly HeldSpeedModifierSystem _clothingMoveSpeed = default!;
     [Dependency] private readonly SharedPopupSystem _popup = default!;
+    [Dependency] private readonly SharedVirtualItemSystem _virtual = default!;
 
     public override void Initialize()
     {
@@ -73,6 +77,9 @@ public sealed class PullingSystem : EntitySystem
         SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
         SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
 
+        SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
+        SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
+
         SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
         SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
 
@@ -81,6 +88,41 @@ public sealed class PullingSystem : EntitySystem
             .Register<PullingSystem>();
     }
 
+    private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
+    {
+        if (args.PullerUid != uid)
+            return;
+
+        if (TryComp(args.PullerUid, out PullerComponent? pullerComp) && !pullerComp.NeedsHands)
+            return;
+
+        if (!_virtual.TrySpawnVirtualItemInHand(args.PulledUid, uid))
+        {
+            DebugTools.Assert("Unable to find available hand when starting pulling??");
+        }
+    }
+
+    private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
+    {
+        if (args.PullerUid != uid)
+            return;
+
+        // Try find hand that is doing this pull.
+        // and clear it.
+        foreach (var hand in component.Hands.Values)
+        {
+            if (hand.HeldEntity == null
+                || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem)
+                || virtualItem.BlockingEntity != args.PulledUid)
+            {
+                continue;
+            }
+
+            _handsSystem.TryDrop(args.PullerUid, hand, handsComp: component);
+            break;
+        }
+    }
+
     private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args)
     {
         if (component.Pulling == null)