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