Update content for new lookup API (#7363)
This commit is contained in:
@@ -136,7 +136,7 @@ namespace Content.Client.Audio
|
||||
//TODO: Make this produce a hashset of nearby entities again.
|
||||
var sourceDict = new Dictionary<string, List<AmbientSoundComponent>>(16);
|
||||
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange + RangeBuffer, LookupFlags.IncludeAnchored | LookupFlags.Approximate))
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange + RangeBuffer, LookupFlags.Anchored | LookupFlags.Approximate))
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out AmbientSoundComponent? ambientComp) ||
|
||||
!ambientComp.Enabled ||
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Content.Client.DragDrop
|
||||
// TODO: Duplicated in SpriteSystem and TargetOutlineSystem. Should probably be cached somewhere for a frame?
|
||||
var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition).Position;
|
||||
var bounds = new Box2(mousePos - 1.5f, mousePos + 1.5f);
|
||||
var pvsEntities = EntitySystem.Get<EntityLookupSystem>().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored);
|
||||
var pvsEntities = EntitySystem.Get<EntityLookupSystem>().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Anchored);
|
||||
foreach (var pvsEntity in pvsEntities)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(pvsEntity, out ISpriteComponent? inRangeSprite) ||
|
||||
|
||||
@@ -108,30 +108,33 @@ namespace Content.Client.NodeContainer
|
||||
|
||||
// Group visible nodes by grid tiles.
|
||||
var worldAABB = overlayDrawArgs.WorldAABB;
|
||||
_lookup.FastEntitiesIntersecting(map, ref worldAABB, entity =>
|
||||
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(map, worldAABB))
|
||||
{
|
||||
if (!_system.Entities.TryGetValue(entity, out var nodeData))
|
||||
return;
|
||||
|
||||
var gridId = _entityManager.GetComponent<TransformComponent>(entity).GridID;
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var gridDict = _gridIndex.GetOrNew(gridId);
|
||||
var coords = _entityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
|
||||
// TODO: This probably shouldn't be capable of returning NaN...
|
||||
if (float.IsNaN(coords.Position.X) || float.IsNaN(coords.Position.Y))
|
||||
return;
|
||||
|
||||
var tile = gridDict.GetOrNew(grid.TileIndicesFor(coords));
|
||||
|
||||
foreach (var (group, nodeDatum) in nodeData)
|
||||
foreach (var entity in _lookup.GetEntitiesIntersecting(grid.Index, worldAABB))
|
||||
{
|
||||
if (!_system.Filtered.Contains(group.GroupId))
|
||||
if (!_system.Entities.TryGetValue(entity, out var nodeData))
|
||||
return;
|
||||
|
||||
var gridDict = _gridIndex.GetOrNew(grid.Index);
|
||||
var coords = xformQuery.GetComponent(entity).Coordinates;
|
||||
|
||||
// TODO: This probably shouldn't be capable of returning NaN...
|
||||
if (float.IsNaN(coords.Position.X) || float.IsNaN(coords.Position.Y))
|
||||
return;
|
||||
|
||||
var tile = gridDict.GetOrNew(grid.TileIndicesFor(coords));
|
||||
|
||||
foreach (var (group, nodeDatum) in nodeData)
|
||||
{
|
||||
tile.Add((group, nodeDatum));
|
||||
if (!_system.Filtered.Contains(group.GroupId))
|
||||
{
|
||||
tile.Add((group, nodeDatum));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var (gridId, gridDict) in _gridIndex)
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ public sealed class TargetOutlineSystem : EntitySystem
|
||||
// TODO: Duplicated in SpriteSystem and DragDropSystem. Should probably be cached somewhere for a frame?
|
||||
var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition).Position;
|
||||
var bounds = new Box2(mousePos - LookupSize, mousePos + LookupSize);
|
||||
var pvsEntities = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored);
|
||||
var pvsEntities = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Anchored);
|
||||
|
||||
foreach (var entity in pvsEntities)
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Content.Client.Verbs
|
||||
}
|
||||
|
||||
// Get entities
|
||||
var entities = _entityLookup.GetEntitiesInRange(targetPos.MapId, targetPos.Position, EntityMenuLookupSize)
|
||||
var entities = _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize)
|
||||
.ToList();
|
||||
|
||||
if (entities.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user