Fix wallmount interaction (#38111)

This commit is contained in:
slarticodefast
2025-06-21 15:11:17 +02:00
committed by GitHub
parent 0d346840da
commit 686016098a

View File

@@ -747,7 +747,7 @@ namespace Content.Shared.Interaction
var inRange = true;
MapCoordinates originPos = default;
var targetPos = _transform.ToMapCoordinates(otherCoordinates);
Angle targetRot = default;
Angle targetRot = _transform.GetWorldRotation(otherCoordinates.EntityId) + otherAngle;
// So essentially:
// 1. If fixtures available check nearest point. We take in coordinates / angles because we might want to use a lag compensated position
@@ -766,8 +766,7 @@ namespace Content.Shared.Interaction
{
var (worldPosA, worldRotA) = _transform.GetWorldPositionRotation(origin.Comp);
var xfA = new Transform(worldPosA, worldRotA);
var parentRotB = _transform.GetWorldRotation(otherCoordinates.EntityId);
var xfB = new Transform(targetPos.Position, parentRotB + otherAngle);
var xfB = new Transform(targetPos.Position, targetRot);
// Different map or the likes.
if (!_broadphase.TryGetNearest(
@@ -809,8 +808,6 @@ namespace Content.Shared.Interaction
else
{
originPos = _transform.GetMapCoordinates(origin, origin);
var otherParent = (other.Comp ?? Transform(other)).ParentUid;
targetRot = otherParent.IsValid() ? Transform(otherParent).LocalRotation + otherAngle : otherAngle;
}
// Do a raycast to check if relevant
@@ -851,7 +848,7 @@ namespace Content.Shared.Interaction
/// if the target entity is a wallmount we ignore all other entities on the tile.
/// </example>
private Ignored GetPredicate(
MapCoordinates origin,
MapCoordinates originCoords,
EntityUid target,
MapCoordinates targetCoords,
Angle targetRotation,
@@ -871,7 +868,7 @@ namespace Content.Shared.Interaction
if (target == otherEnt ||
!_physicsQuery.TryComp(otherEnt, out var otherBody) ||
!otherBody.CanCollide ||
((int) collisionMask & otherBody.CollisionLayer) == 0x0)
((int)collisionMask & otherBody.CollisionLayer) == 0x0)
{
continue;
}
@@ -888,7 +885,7 @@ namespace Content.Shared.Interaction
ignoreAnchored = true;
else
{
var angle = Angle.FromWorldVec(origin.Position - targetCoords.Position);
var angle = Angle.FromWorldVec(originCoords.Position - targetCoords.Position);
var angleDelta = (wallMount.Direction + targetRotation - angle).Reduced().FlipPositive();
ignoreAnchored = angleDelta < wallMount.Arc / 2 || Math.Tau - angleDelta < wallMount.Arc / 2;
}