]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix climbing not ending when any contacts still exist (#30488)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Tue, 30 Jul 2024 08:31:59 +0000 (01:31 -0700)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2024 08:31:59 +0000 (18:31 +1000)
Content.Shared/Climbing/Systems/ClimbSystem.cs

index 726cdc24687af190bc976c9adfdbbd47a8c087a8..635bf36049bedb4da1231b517daaed637a007d9c 100644 (file)
@@ -1,5 +1,4 @@
 using Content.Shared.ActionBlocker;
-using Content.Shared.Body.Systems;
 using Content.Shared.Buckle.Components;
 using Content.Shared.Climbing.Components;
 using Content.Shared.Climbing.Events;
@@ -44,6 +43,7 @@ public sealed partial class ClimbSystem : VirtualController
     private const string ClimbingFixtureName = "climb";
     private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
 
+    private EntityQuery<ClimbableComponent> _climbableQuery;
     private EntityQuery<FixturesComponent> _fixturesQuery;
     private EntityQuery<TransformComponent> _xformQuery;
 
@@ -51,6 +51,7 @@ public sealed partial class ClimbSystem : VirtualController
     {
         base.Initialize();
 
+        _climbableQuery = GetEntityQuery<ClimbableComponent>();
         _fixturesQuery = GetEntityQuery<FixturesComponent>();
         _xformQuery = GetEntityQuery<TransformComponent>();
 
@@ -350,12 +351,39 @@ public sealed partial class ClimbSystem : VirtualController
     {
         if (args.OurFixtureId != ClimbingFixtureName
             || !component.IsClimbing
-            || component.NextTransition != null
-            || args.OurFixture.Contacts.Count > 1)
+            || component.NextTransition != null)
         {
             return;
         }
 
+        if (args.OurFixture.Contacts.Count > 1)
+        {
+            foreach (var contact in args.OurFixture.Contacts.Values)
+            {
+                if (!contact.IsTouching)
+                    continue;
+
+                var otherEnt = contact.EntityA;
+                var otherFixture = contact.FixtureA;
+                var otherFixtureId = contact.FixtureAId;
+                if (uid == contact.EntityA)
+                {
+                    otherEnt = contact.EntityB;
+                    otherFixture = contact.FixtureB;
+                    otherFixtureId = contact.FixtureBId;
+                }
+
+                if (args.OtherEntity == otherEnt && args.OtherFixtureId == otherFixtureId)
+                    continue;
+
+                if (otherFixture is { Hard: true } &&
+                    _climbableQuery.HasComp(otherEnt))
+                {
+                    return;
+                }
+            }
+        }
+
         foreach (var otherFixture in args.OurFixture.Contacts.Keys)
         {
             // If it's the other fixture then ignore em