]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix bug with holding objects (#31009)
authorIgorAnt028 <118114530+IgorAnt028@users.noreply.github.com>
Fri, 16 Aug 2024 04:53:34 +0000 (07:53 +0300)
committerGitHub <noreply@github.com>
Fri, 16 Aug 2024 04:53:34 +0000 (00:53 -0400)
Main

Content.Shared/Movement/Pulling/Systems/PullingSystem.cs

index b5fc6948334aadab5241fc43184c77c1677678f8..dd8722607cd7840a3168f2beee840bc4d08d2854 100644 (file)
@@ -9,6 +9,8 @@ using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Input;
 using Content.Shared.Interaction;
 using Content.Shared.Item;
+using Content.Shared.Mobs;
+using Content.Shared.Mobs.Systems;
 using Content.Shared.Movement.Events;
 using Content.Shared.Movement.Pulling.Components;
 using Content.Shared.Movement.Pulling.Events;
@@ -60,6 +62,7 @@ public sealed class PullingSystem : EntitySystem
         SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
         SubscribeLocalEvent<PullableComponent, StopBeingPulledAlertEvent>(OnStopBeingPulledAlert);
 
+        SubscribeLocalEvent<PullerComponent, UpdateMobStateEvent>(OnStateChanged);
         SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
         SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
         SubscribeLocalEvent<PullerComponent, EntityUnpausedEvent>(OnPullerUnpaused);
@@ -76,6 +79,17 @@ public sealed class PullingSystem : EntitySystem
             .Register<PullingSystem>();
     }
 
+    private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args)
+    {
+        if (component.Pulling == null)
+            return;
+
+        if (TryComp<PullableComponent>(component.Pulling, out var comp) && (args.State == MobState.Critical || args.State == MobState.Dead))
+        {
+            TryStopPull(component.Pulling.Value, comp);
+        }
+    }
+
     private void OnBuckled(Entity<PullableComponent> ent, ref StrappedEvent args)
     {
         // Prevent people from pulling the entity they are buckled to