From 4e46cf7d27460920dbd07a1e8f780b19ff869791 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 29 Aug 2021 14:23:11 +1000 Subject: [PATCH] Make content use EntityLookupFlags (#4531) * Use lookup flags * Woops --- Content.Client/DragDrop/DragDropSystem.cs | 2 +- Content.Server/Actions/Actions/GhostBoo.cs | 2 +- Content.Server/Chat/Commands/SuicideCommand.cs | 2 +- .../Construction/Conditions/ComponentInTile.cs | 2 +- Content.Server/Construction/ConstructionSystem.cs | 2 +- .../Physics/Controllers/ConveyorController.cs | 2 +- .../Construction/Conditions/LowWallInTile.cs | 2 +- .../Construction/Conditions/NoWindowsInTile.cs | 2 +- Content.Shared/Maps/TurfHelpers.cs | 12 ++++++------ 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 7163623a4b..eeea12cdeb 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -370,7 +370,7 @@ namespace Content.Client.DragDrop // TODO: Duplicated in SpriteSystem var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition).Position; var bounds = new Box2(mousePos - 1.5f, mousePos + 1.5f); - var pvsEntities = IoCManager.Resolve().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, true); + var pvsEntities = IoCManager.Resolve().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored); foreach (var pvsEntity in pvsEntities) { if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) || diff --git a/Content.Server/Actions/Actions/GhostBoo.cs b/Content.Server/Actions/Actions/GhostBoo.cs index 2287f123d1..4edc86b1ce 100644 --- a/Content.Server/Actions/Actions/GhostBoo.cs +++ b/Content.Server/Actions/Actions/GhostBoo.cs @@ -26,7 +26,7 @@ namespace Content.Server.Actions.Actions if (!args.Performer.TryGetComponent(out var actions)) return; // find all IGhostBooAffected nearby and do boo on them - var ents = IoCManager.Resolve().GetEntitiesInRange(args.Performer, _radius, false); + var ents = IoCManager.Resolve().GetEntitiesInRange(args.Performer, _radius); var booCounter = 0; foreach (var ent in ents) diff --git a/Content.Server/Chat/Commands/SuicideCommand.cs b/Content.Server/Chat/Commands/SuicideCommand.cs index 6e9751f8d3..78ad9088f2 100644 --- a/Content.Server/Chat/Commands/SuicideCommand.cs +++ b/Content.Server/Chat/Commands/SuicideCommand.cs @@ -95,7 +95,7 @@ namespace Content.Server.Chat.Commands } } // Get all entities in range of the suicider - var entities = IoCManager.Resolve().GetEntitiesInRange(owner, 1, true).ToArray(); + var entities = IoCManager.Resolve().GetEntitiesInRange(owner, 1, LookupFlags.Approximate | LookupFlags.IncludeAnchored).ToArray(); if (entities.Length > 0) { diff --git a/Content.Server/Construction/Conditions/ComponentInTile.cs b/Content.Server/Construction/Conditions/ComponentInTile.cs index 196183a82e..74759635b2 100644 --- a/Content.Server/Construction/Conditions/ComponentInTile.cs +++ b/Content.Server/Construction/Conditions/ComponentInTile.cs @@ -44,7 +44,7 @@ namespace Content.Server.Construction.Conditions var type = _componentFactory.GetRegistration(Component).Type; var indices = entity.Transform.Coordinates.ToVector2i(entity.EntityManager, _mapManager); - var entities = indices.GetEntitiesInTile(entity.Transform.GridID, true, IoCManager.Resolve()); + var entities = indices.GetEntitiesInTile(entity.Transform.GridID, LookupFlags.Approximate | LookupFlags.IncludeAnchored, IoCManager.Resolve()); foreach (var ent in entities) { diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index f69cffd012..8ce2d9d247 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -86,7 +86,7 @@ namespace Content.Server.Construction } } - foreach (var near in IoCManager.Resolve().GetEntitiesInRange(user!, 2f, true)) + foreach (var near in IoCManager.Resolve().GetEntitiesInRange(user!, 2f, LookupFlags.Approximate | LookupFlags.IncludeAnchored)) { yield return near; } diff --git a/Content.Server/Physics/Controllers/ConveyorController.cs b/Content.Server/Physics/Controllers/ConveyorController.cs index 1587e2834c..bfbd261a25 100644 --- a/Content.Server/Physics/Controllers/ConveyorController.cs +++ b/Content.Server/Physics/Controllers/ConveyorController.cs @@ -39,7 +39,7 @@ namespace Content.Server.Physics.Controllers return; } - var intersecting = IoCManager.Resolve().GetEntitiesIntersecting(comp.Owner, true); + var intersecting = IoCManager.Resolve().GetEntitiesIntersecting(comp.Owner, LookupFlags.Approximate | LookupFlags.IncludeAnchored); var direction = comp.GetAngle().ToVec(); Vector2? ownerPos = null; diff --git a/Content.Shared/Construction/Conditions/LowWallInTile.cs b/Content.Shared/Construction/Conditions/LowWallInTile.cs index 62b0b8186a..d0e0180603 100644 --- a/Content.Shared/Construction/Conditions/LowWallInTile.cs +++ b/Content.Shared/Construction/Conditions/LowWallInTile.cs @@ -16,7 +16,7 @@ namespace Content.Shared.Construction.Conditions { var lowWall = false; - foreach (var entity in location.GetEntitiesInTile(true)) + foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.IncludeAnchored)) { if (entity.HasComponent()) lowWall = true; diff --git a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs index 81b3e4786c..11805d7cb5 100644 --- a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs +++ b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs @@ -14,7 +14,7 @@ namespace Content.Shared.Construction.Conditions { public bool Condition(IEntity user, EntityCoordinates location, Direction direction) { - foreach (var entity in location.GetEntitiesInTile(true)) + foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.IncludeAnchored)) { if (entity.HasComponent()) return false; diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index 6b6613b617..82cb7b698b 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -148,32 +148,32 @@ namespace Content.Shared.Maps /// Helper that returns all entities in a turf. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static IEnumerable GetEntitiesInTile(this TileRef turf, bool approximate = false, IEntityLookup? lookupSystem = null) + public static IEnumerable GetEntitiesInTile(this TileRef turf, LookupFlags flags = LookupFlags.IncludeAnchored, IEntityLookup? lookupSystem = null) { lookupSystem ??= IoCManager.Resolve(); - return lookupSystem.GetEntitiesIntersecting(turf.MapIndex, GetWorldTileBox(turf), approximate); + return lookupSystem.GetEntitiesIntersecting(turf.MapIndex, GetWorldTileBox(turf), flags); } /// /// Helper that returns all entities in a turf. /// - public static IEnumerable GetEntitiesInTile(this EntityCoordinates coordinates, bool approximate = false, IEntityLookup? lookupSystem = null) + public static IEnumerable GetEntitiesInTile(this EntityCoordinates coordinates, LookupFlags flags = LookupFlags.IncludeAnchored, IEntityLookup? lookupSystem = null) { var turf = coordinates.GetTileRef(); if (turf == null) return Enumerable.Empty(); - return GetEntitiesInTile(turf.Value, approximate, lookupSystem); + return GetEntitiesInTile(turf.Value, flags, lookupSystem); } /// /// Helper that returns all entities in a turf. /// - public static IEnumerable GetEntitiesInTile(this Vector2i indices, GridId gridId, bool approximate = false, IEntityLookup? lookupSystem = null) + public static IEnumerable GetEntitiesInTile(this Vector2i indices, GridId gridId, LookupFlags flags = LookupFlags.IncludeAnchored, IEntityLookup? lookupSystem = null) { - return GetEntitiesInTile(indices.GetTileRef(gridId), approximate, lookupSystem); + return GetEntitiesInTile(indices.GetTileRef(gridId), flags, lookupSystem); } ///