Cleanup warnings in `SharedMoverController` (#37613)

* Refactor IsAroundCollider to use EntityLookupSystem

* Formatting

* MapSystem methods

* Remove unused usings

* GrabRangeVV -> GrabRange
This commit is contained in:
Tayrtahn 2025-05-27 06:01:04 -04:00 committed by Quanteey
parent 1acdfd29e1
commit eb94fb8e8d
1 changed files with 15 additions and 15 deletions

View File

@ -1,9 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Numerics;
using Content.Shared._DV.Movement; // DeltaV
using Content.Shared.ActionBlocker;
using Content.Shared.Bed.Sleep;
using Content.Shared.CCVar;
using Content.Shared.Friction;
using Content.Shared.Gravity;
@ -23,9 +21,7 @@ using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Controllers;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Exceptions;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using PullableComponent = Content.Shared.Movement.Pulling.Components.PullableComponent;
@ -251,7 +247,7 @@ public abstract partial class SharedMoverController : VirtualController
// If we're not on a grid, and not able to move in space check if we're close enough to a grid to touch.
if (!touching && MobMoverQuery.TryComp(uid, out var mobMover))
touching |= IsAroundCollider(PhysicsSystem, xform, mobMover, uid, physicsComponent);
touching |= IsAroundCollider(_lookup, (uid, physicsComponent, mobMover, xform));
// If we're touching then use the weightless values
if (touching)
@ -275,7 +271,7 @@ public abstract partial class SharedMoverController : VirtualController
if (MapGridQuery.TryComp(xform.GridUid, out var gridComp)
&& _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile)
&& physicsComponent.BodyStatus == BodyStatus.OnGround)
tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
var walkSpeed = moveSpeedComponent?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
var sprintSpeed = moveSpeedComponent?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
@ -462,23 +458,27 @@ public abstract partial class SharedMoverController : VirtualController
}
/// <summary>
/// Used for weightlessness to determine if we are near a wall.
/// Used for weightlessness to determine if we are near a wall.
/// </summary>
private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, MobMoverComponent mover, EntityUid physicsUid, PhysicsComponent collider)
private bool IsAroundCollider(EntityLookupSystem lookupSystem, Entity<PhysicsComponent, MobMoverComponent, TransformComponent> entity)
{
var enlargedAABB = _lookup.GetWorldAABB(physicsUid, transform).Enlarged(mover.GrabRangeVV);
var (uid, collider, mover, transform) = entity;
var enlargedAABB = _lookup.GetWorldAABB(entity.Owner, transform).Enlarged(mover.GrabRange);
foreach (var otherCollider in broadPhaseSystem.GetCollidingEntities(transform.MapID, enlargedAABB))
foreach (var otherEntity in lookupSystem.GetEntitiesIntersecting(transform.MapID, enlargedAABB))
{
if (otherCollider == collider)
if (otherEntity == uid)
continue; // Don't try to push off of yourself!
if (!PhysicsQuery.TryComp(otherEntity, out var otherCollider))
continue;
// Only allow pushing off of anchored things that have collision.
if (otherCollider.BodyType != BodyType.Static ||
!otherCollider.CanCollide ||
((collider.CollisionMask & otherCollider.CollisionLayer) == 0 &&
(otherCollider.CollisionMask & collider.CollisionLayer) == 0) ||
(TryComp(otherCollider.Owner, out PullableComponent? pullable) && pullable.BeingPulled))
(TryComp(otherEntity, out PullableComponent? pullable) && pullable.BeingPulled))
{
continue;
}
@ -581,7 +581,7 @@ public abstract partial class SharedMoverController : VirtualController
return sound != null;
}
var position = grid.LocalToTile(xform.Coordinates);
var position = _mapSystem.LocalToTile(xform.GridUid.Value, grid, xform.Coordinates);
var soundEv = new GetFootstepSoundEvent(uid);
// If the coordinates have a FootstepModifier component
@ -608,9 +608,9 @@ public abstract partial class SharedMoverController : VirtualController
// Walking on a tile.
// Tile def might have been passed in already from previous methods, so use that
// if we have it
if (tileDef == null && grid.TryGetTileRef(position, out var tileRef))
if (tileDef == null && _mapSystem.TryGetTileRef(xform.GridUid.Value, grid, position, out var tileRef))
{
tileDef = (ContentTileDefinition) _tileDefinitionManager[tileRef.Tile.TypeId];
tileDef = (ContentTileDefinition)_tileDefinitionManager[tileRef.Tile.TypeId];
}
if (tileDef == null)