// Get all other relevant tiles.
while (tileEnumerator.MoveNext(out var tileRef))
{
- var tileBounds = _lookup.GetLocalBounds(tileRef.GridIndices, grid.Comp.TileSize).Enlarged(-0.05f);
-
- _occluders.Clear();
- _lookup.GetLocalEntitiesIntersecting(grid.Owner, tileBounds, _occluders, LookupFlags.Static);
-
- if (_occluders.Count > 0)
+ if (IsOccluded(grid, tileRef.GridIndices))
{
_opaque.Add(tileRef.GridIndices);
}
return TargetFound;
}
+ private bool IsOccluded(Entity<MapGridComponent> grid, Vector2i tile)
+ {
+ var tileBounds = _lookup.GetLocalBounds(tile, grid.Comp.TileSize).Enlarged(-0.05f);
+ _occluders.Clear();
+ _lookup.GetLocalEntitiesIntersecting(grid.Owner, tileBounds, _occluders, LookupFlags.Static);
+ var anyOccluders = false;
+
+ foreach (var occluder in _occluders)
+ {
+ if (!occluder.Comp.Enabled)
+ continue;
+
+ anyOccluders = true;
+ break;
+ }
+
+ return anyOccluders;
+ }
+
/// <summary>
/// Gets a byond-equivalent for tiles in the specified worldAABB.
/// </summary>
while (tileEnumerator.MoveNext(out var tileRef))
{
- var tileBounds = _lookup.GetLocalBounds(tileRef.GridIndices, grid.Comp.TileSize).Enlarged(-0.05f);
-
- _occluders.Clear();
- _lookup.GetLocalEntitiesIntersecting(grid.Owner, tileBounds, _occluders, LookupFlags.Static);
-
- if (_occluders.Count > 0)
+ if (IsOccluded(grid, tileRef.GridIndices))
{
_opaque.Add(tileRef.GridIndices);
}
if (_viewportTiles.Contains(tileRef.GridIndices))
continue;
- var tileBounds = _lookup.GetLocalBounds(tileRef.GridIndices, grid.Comp.TileSize).Enlarged(-0.05f);
-
- _occluders.Clear();
- _lookup.GetLocalEntitiesIntersecting(grid.Owner, tileBounds, _occluders, LookupFlags.Static);
-
- if (_occluders.Count > 0)
+ if (IsOccluded(grid, tileRef.GridIndices))
{
_opaque.Add(tileRef.GridIndices);
}