Add GetLocalEntitiesIntersecting for griduid + tilesize (#4807)

This commit is contained in:
metalgearsloth
2024-01-04 15:05:18 +11:00
committed by GitHub
parent bb23bc6acc
commit 371db7db2f
2 changed files with 23 additions and 0 deletions
@@ -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.
*/
/// <summary>
/// Gets the entities intersecting the specified broadphase entity using a local AABB.
/// </summary>
public void GetLocalEntitiesIntersecting(EntityUid gridUid, Vector2i localTile, HashSet<EntityUid> 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);
}
/// <summary>
/// Gets the entities intersecting the specified broadphase entity using a local AABB.
/// </summary>