diff --git a/Robust.Shared/GameObjects/Systems/EntityLookupSystem.LocalQueries.cs b/Robust.Shared/GameObjects/Systems/EntityLookupSystem.LocalQueries.cs index 6da8c386f1..c4871b0e06 100644 --- a/Robust.Shared/GameObjects/Systems/EntityLookupSystem.LocalQueries.cs +++ b/Robust.Shared/GameObjects/Systems/EntityLookupSystem.LocalQueries.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Robust.Shared.Map.Components; using Robust.Shared.Maths; namespace Robust.Shared.GameObjects; @@ -9,6 +10,25 @@ public sealed partial class EntityLookupSystem * Local AABB / Box2Rotated queries for broadphase entities. */ + /// + /// Gets the entities intersecting the specified broadphase entity using a local AABB. + /// + public void GetLocalEntitiesIntersecting(EntityUid gridUid, Vector2i localTile, HashSet intersecting, + float enlargement = TileEnlargementRadius, LookupFlags flags = DefaultFlags, MapGridComponent? gridComp = null) + { + ushort tileSize = 1; + + if (_gridQuery.Resolve(gridUid, ref gridComp)) + { + tileSize = gridComp.TileSize; + } + + var localAABB = GetLocalBounds(localTile, tileSize); + localAABB = localAABB.Enlarged(TileEnlargementRadius); + AddLocalEntitiesIntersecting(gridUid, intersecting, localAABB, flags); + AddContained(intersecting, flags); + } + /// /// Gets the entities intersecting the specified broadphase entity using a local AABB. /// diff --git a/Robust.Shared/GameObjects/Systems/EntityLookupSystem.cs b/Robust.Shared/GameObjects/Systems/EntityLookupSystem.cs index b232650c02..264ec2bf06 100644 --- a/Robust.Shared/GameObjects/Systems/EntityLookupSystem.cs +++ b/Robust.Shared/GameObjects/Systems/EntityLookupSystem.cs @@ -88,6 +88,8 @@ public sealed partial class EntityLookupSystem : EntitySystem private EntityQuery _broadQuery; private EntityQuery _containerQuery; private EntityQuery _fixturesQuery; + + private EntityQuery _gridQuery; private EntityQuery _metaQuery; private EntityQuery _physicsQuery; private EntityQuery _mapQuery; @@ -107,6 +109,7 @@ public sealed partial class EntityLookupSystem : EntitySystem _broadQuery = GetEntityQuery(); _containerQuery = GetEntityQuery(); _fixturesQuery = GetEntityQuery(); + _gridQuery = GetEntityQuery(); _metaQuery = GetEntityQuery(); _physicsQuery = GetEntityQuery(); _mapQuery = GetEntityQuery();