Cleanup warnings in SharedMoverController (#37613)
* Refactor IsAroundCollider to use EntityLookupSystem * Formatting * MapSystem methods * Remove unused usings * GrabRangeVV -> GrabRange
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Numerics;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Friction;
|
||||
using Content.Shared.Gravity;
|
||||
@@ -21,9 +19,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;
|
||||
@@ -240,7 +236,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)
|
||||
@@ -264,7 +260,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;
|
||||
@@ -451,23 +447,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;
|
||||
}
|
||||
@@ -562,7 +562,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
|
||||
@@ -589,9 +589,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)
|
||||
|
||||
Reference in New Issue
Block a user