Fix mapgrid rendering (#3722)

This commit is contained in:
metalgearsloth
2023-02-07 17:20:57 +11:00
committed by GitHub
parent 42c17faa98
commit dffd28a31c
2 changed files with 15 additions and 12 deletions

View File

@@ -102,7 +102,7 @@ internal partial class MapManager
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
return EntityManager.EntityQuery<MapGridComponent>(true)
.Where(c => xformQuery.GetComponent(((Component) c).Owner).MapID == mapId)
.Where(c => xformQuery.GetComponent(c.Owner).MapID == mapId)
.Select(c => c);
}

View File

@@ -26,6 +26,11 @@ internal partial class MapManager
if (!_gridTrees.TryGetValue(mapId, out var gridTree))
return;
if (EntityManager.TryGetComponent<MapGridComponent>(GetMapEntityId(mapId), out var grid))
{
callback(grid);
}
var state = (gridTree, callback);
gridTree.Query(ref state, static (ref (
@@ -37,11 +42,6 @@ internal partial class MapManager
tuple.callback(data!);
return true;
}, worldAABB);
if (EntityManager.TryGetComponent<MapGridComponent>(GetMapEntityId(mapId), out var grid))
{
callback(grid);
}
}
public void FindGridsIntersectingApprox<TState>(MapId mapId, Box2 worldAABB, ref TState state, GridCallback<TState> callback)
@@ -92,6 +92,14 @@ internal partial class MapManager
if (!_gridTrees.TryGetValue(mapId, out var gridTree)) return Enumerable.Empty<MapGridComponent>();
DebugTools.Assert(grids.Count == 0);
var offset = 0;
if (EntityManager.TryGetComponent<MapGridComponent>(GetMapEntityId(mapId), out var mapGrid))
{
grids.Add(mapGrid);
offset = 1;
}
var state = (gridTree, grids);
gridTree.Query(ref state,
@@ -104,7 +112,7 @@ internal partial class MapManager
if (!approx)
{
for (var i = grids.Count - 1; i >= 0; i--)
for (var i = grids.Count - 1; i >= offset; i--)
{
var grid = grids[i];
@@ -144,11 +152,6 @@ internal partial class MapManager
}
}
if (EntityManager.TryGetComponent<MapGridComponent>(GetMapEntityId(mapId), out var mapGrid))
{
grids.Add(mapGrid);
}
return grids;
}