]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Use EntityQuery for footstep modifier and map grid in SharedMoverController (#30575)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Fri, 2 Aug 2024 14:08:46 +0000 (07:08 -0700)
committerGitHub <noreply@github.com>
Fri, 2 Aug 2024 14:08:46 +0000 (10:08 -0400)
Content.Shared/Movement/Systems/SharedMoverController.cs

index 68e384a1b420692e3de2844abbfb252d882132e2..1f647178239880235539ef9c1a1305993c835402 100644 (file)
@@ -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;