Fix climbing not ending when any contacts still exist (#30488)

This commit is contained in:
DrSmugleaf
2024-07-30 01:31:59 -07:00
committed by GitHub
parent fda852d2e0
commit 517598f72d

View 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