Skip to content

Commit

Permalink
Replaces anchored lookup flag with static (#13036)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored Dec 15, 2022
1 parent 0db4402 commit 6fa2391
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Content.Client/DragDrop/DragDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private void HighlightTargets()
// 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 = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Anchored);
var pvsEntities = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Static);
foreach (var pvsEntity in pvsEntities)
{
if (!EntityManager.TryGetComponent(pvsEntity, out SpriteComponent? inRangeSprite) ||
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Outline/TargetOutlineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void HighlightTargets()
// 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 / 2f, mousePos + LookupSize / 2f);
var pvsEntities = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Anchored);
var pvsEntities = _lookup.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.Static);
var spriteQuery = GetEntityQuery<SpriteComponent>();

foreach (var entity in pvsEntities)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Weapons/Ranged/Systems/TetherGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public override void Update(float frameTime)
var bodyQuery = GetEntityQuery<PhysicsComponent>();
var lowest = new List<(int DrawDepth, uint RenderOrder, EntityUid Entity)>();

foreach (var ent in _lookup.GetEntitiesIntersecting(mousePos, LookupFlags.Approximate | LookupFlags.Anchored))
foreach (var ent in _lookup.GetEntitiesIntersecting(mousePos, LookupFlags.Approximate | LookupFlags.Static))
{
if (!bodyQuery.HasComponent(ent) ||
!TryComp<ClickableComponent>(ent, out var clickable) ||
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Chat/SuicideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEve
}

// Suicide by nearby entity (ex: Microwave)
foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Anchored))
foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Static))
{
// Skip any nearby items that can be picked up, we already checked the active held item above
if (itemQuery.HasComponent(entity))
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Construction/Conditions/ComponentInTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public bool Condition(EntityUid uid, IEntityManager entityManager)

var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve<IMapManager>());
var lookup = entityManager.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, lookup);
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Static, lookup);

foreach (var ent in entities)
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Electrocution/ElectrocutionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public bool TryDoElectrifiedAct(EntityUid uid, EntityUid targetUid,
if (electrified.NoWindowInTile)
{
foreach (var entity in transform.Coordinates.GetEntitiesInTile(
LookupFlags.Approximate | LookupFlags.Anchored, _entityLookup))
LookupFlags.Approximate | LookupFlags.Static, _entityLookup))
{
if (_tagSystem.HasTag(entity, "Window"))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void OnDefileAction(EntityUid uid, RevenantComponent component, Revenant
value.PryTile();
}

var lookup = _lookup.GetEntitiesInRange(uid, component.DefileRadius, LookupFlags.Approximate | LookupFlags.Anchored);
var lookup = _lookup.GetEntitiesInRange(uid, component.DefileRadius, LookupFlags.Approximate | LookupFlags.Static);
var tags = GetEntityQuery<TagComponent>();
var entityStorage = GetEntityQuery<EntityStorageComponent>();
var items = GetEntityQuery<ItemComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public bool Condition(EntityUid user, EntityCoordinates location, Direction dire
{
var result = false;

foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Anchored))
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Static))
{
if (IoCManager.Resolve<IEntityManager>().HasComponent<SharedCanBuildWindowOnTopComponent>(entity))
result = true;
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Construction/Conditions/NoWindowsInTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public bool Condition(EntityUid user, EntityCoordinates location, Direction dire
{
var tagSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<TagSystem>();

foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Anchored))
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Static))
{
if (tagSystem.HasTag(entity, "Window"))
return false;
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Maps/TurfHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static bool DeconstructTile(this TileRef tileRef,
/// Helper that returns all entities in a turf.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<EntityUid> GetEntitiesInTile(this TileRef turf, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null)
public static IEnumerable<EntityUid> GetEntitiesInTile(this TileRef turf, LookupFlags flags = LookupFlags.Static, EntityLookupSystem? lookupSystem = null)
{
lookupSystem ??= EntitySystem.Get<EntityLookupSystem>();

Expand All @@ -188,7 +188,7 @@ public static IEnumerable<EntityUid> GetEntitiesInTile(this TileRef turf, Lookup
/// <summary>
/// Helper that returns all entities in a turf.
/// </summary>
public static IEnumerable<EntityUid> GetEntitiesInTile(this EntityCoordinates coordinates, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null)
public static IEnumerable<EntityUid> GetEntitiesInTile(this EntityCoordinates coordinates, LookupFlags flags = LookupFlags.Static, EntityLookupSystem? lookupSystem = null)
{
var turf = coordinates.GetTileRef();

Expand All @@ -201,7 +201,7 @@ public static IEnumerable<EntityUid> GetEntitiesInTile(this EntityCoordinates co
/// <summary>
/// Helper that returns all entities in a turf.
/// </summary>
public static IEnumerable<EntityUid> GetEntitiesInTile(this Vector2i indices, EntityUid gridId, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null)
public static IEnumerable<EntityUid> GetEntitiesInTile(this Vector2i indices, EntityUid gridId, LookupFlags flags = LookupFlags.Static, EntityLookupSystem? lookupSystem = null)
{
return GetEntitiesInTile(indices.GetTileRef(gridId), flags, lookupSystem);
}
Expand Down

0 comments on commit 6fa2391

Please sign in to comment.