Use EntityQuery for footstep modifier and map grid in SharedMoverController (#30575)
This commit is contained in:
@@ -57,6 +57,8 @@ namespace Content.Shared.Movement.Systems
|
||||
protected EntityQuery<TransformComponent> XformQuery;
|
||||
protected EntityQuery<CanMoveInAirComponent> CanMoveInAirQuery;
|
||||
protected EntityQuery<NoRotateOnMoveComponent> NoRotateQuery;
|
||||
protected EntityQuery<FootstepModifierComponent> FootstepModifierQuery;
|
||||
protected EntityQuery<MapGridComponent> MapGridQuery;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.StopSpeed"/>
|
||||
@@ -84,6 +86,8 @@ namespace Content.Shared.Movement.Systems
|
||||
XformQuery = GetEntityQuery<TransformComponent>();
|
||||
NoRotateQuery = GetEntityQuery<NoRotateOnMoveComponent>();
|
||||
CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
|
||||
FootstepModifierQuery = GetEntityQuery<FootstepModifierComponent>();
|
||||
MapGridQuery = GetEntityQuery<MapGridComponent>();
|
||||
|
||||
InitializeInput();
|
||||
InitializeRelay();
|
||||
@@ -181,7 +185,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
// Don't bother getting the tiledef here if we're weightless or in-air
|
||||
// since no tile-based modifiers should be applying in that situation
|
||||
if (TryComp(xform.GridUid, out MapGridComponent? gridComp)
|
||||
if (MapGridQuery.TryComp(xform.GridUid, out var gridComp)
|
||||
&& _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile)
|
||||
&& !(weightless || physicsComponent.BodyStatus == BodyStatus.InAir))
|
||||
{
|
||||
@@ -430,14 +434,14 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
mobMover.StepSoundDistance -= distanceNeeded;
|
||||
|
||||
if (TryComp<FootstepModifierComponent>(uid, out var moverModifier))
|
||||
if (FootstepModifierQuery.TryComp(uid, out var moverModifier))
|
||||
{
|
||||
sound = moverModifier.FootstepSoundCollection;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_inventory.TryGetSlotEntity(uid, "shoes", out var shoes) &&
|
||||
TryComp<FootstepModifierComponent>(shoes, out var modifier))
|
||||
FootstepModifierQuery.TryComp(shoes, out var modifier))
|
||||
{
|
||||
sound = modifier.FootstepSoundCollection;
|
||||
return true;
|
||||
@@ -456,9 +460,9 @@ namespace Content.Shared.Movement.Systems
|
||||
sound = null;
|
||||
|
||||
// Fallback to the map?
|
||||
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
if (!MapGridQuery.TryComp(xform.GridUid, out var grid))
|
||||
{
|
||||
if (TryComp<FootstepModifierComponent>(xform.MapUid, out var modifier))
|
||||
if (FootstepModifierQuery.TryComp(xform.MapUid, out var modifier))
|
||||
{
|
||||
sound = modifier.FootstepSoundCollection;
|
||||
return true;
|
||||
@@ -484,7 +488,7 @@ namespace Content.Shared.Movement.Systems
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TryComp<FootstepModifierComponent>(maybeFootstep, out var footstep))
|
||||
if (FootstepModifierQuery.TryComp(maybeFootstep, out var footstep))
|
||||
{
|
||||
sound = footstep.FootstepSoundCollection;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user