From 67f9e9cb5e4b7f67de17e1ab16c09214852dcf0b Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 6 Apr 2021 13:31:07 +1000 Subject: [PATCH] Split entity lookups from entity manager (#3747) * Split entity lookups from entity manager * IoC instead * IoC refactor * Fix bad resolve * Remove EntityManager EntityLookup * Update submodule Co-authored-by: Metal Gear Sloth --- .../GameObjects/EntitySystems/DragDropSystem.cs | 2 +- Content.Client/State/GameScreenBase.cs | 2 +- .../Destructible/DestructibleDestructionTest.cs | 2 +- Content.Server/Actions/GhostBoo.cs | 5 +++-- Content.Server/Commands/Chat/SuicideCommand.cs | 2 +- .../Commands/Interactable/AnchorCommand.cs | 4 ++-- .../Commands/Interactable/UnAnchorCommand.cs | 4 ++-- .../Construction/Conditions/ComponentInTile.cs | 2 +- Content.Server/Explosions/ExplosionHelper.cs | 6 ++---- .../Components/Fluids/SpillExtensions.cs | 2 +- .../Items/Storage/ServerStorageComponent.cs | 3 ++- .../Components/Portal/TeleporterComponent.cs | 4 ++-- .../ApcNetComponents/PowerProviderComponent.cs | 3 ++- .../ApcNetComponents/PowerReceiverComponent.cs | 8 ++------ .../Components/Weapon/FlashableComponent.cs | 2 +- .../Components/Weapon/Melee/FlashComponent.cs | 3 ++- .../EntitySystems/ConstructionSystem.cs | 2 +- .../StationEvents/RadiationPulseSystem.cs | 5 ++++- .../Physics/Controllers/ConveyorController.cs | 6 ++++-- .../Physics/Controllers/SingularityController.cs | 2 +- .../Disposal/SharedDisposalUnitComponent.cs | 4 +++- .../GameObjects/Verbs/SharedVerbSystem.cs | 5 +++-- Content.Shared/Maps/TurfHelpers.cs | 14 +++++++------- RobustToolbox | 2 +- 24 files changed, 50 insertions(+), 44 deletions(-) diff --git a/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs b/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs index a707367645..e58366c41c 100644 --- a/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs @@ -372,7 +372,7 @@ namespace Content.Client.GameObjects.EntitySystems // TODO: Duplicated in SpriteSystem var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition).Position; var bounds = new Box2(mousePos - 1.5f, mousePos + 1.5f); - var pvsEntities = EntityManager.GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, true); + var pvsEntities = IoCManager.Resolve().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, true); foreach (var pvsEntity in pvsEntities) { if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) || diff --git a/Content.Client/State/GameScreenBase.cs b/Content.Client/State/GameScreenBase.cs index d9ce1acac9..448fdcc38c 100644 --- a/Content.Client/State/GameScreenBase.cs +++ b/Content.Client/State/GameScreenBase.cs @@ -127,7 +127,7 @@ namespace Content.Client.State public IList GetEntitiesUnderPosition(MapCoordinates coordinates) { // Find all the entities intersecting our click - var entities = EntityManager.GetEntitiesIntersecting(coordinates.MapId, + var entities = IoCManager.Resolve().GetEntitiesIntersecting(coordinates.MapId, Box2.CenteredAround(coordinates.Position, (1, 1))); // Check the entities against whether or not we can click them diff --git a/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs b/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs index 96dfdfe0a4..4755087bc3 100644 --- a/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs +++ b/Content.IntegrationTests/Tests/Destructible/DestructibleDestructionTest.cs @@ -68,7 +68,7 @@ namespace Content.IntegrationTests.Tests.Destructible Assert.That(spawnEntitiesBehavior.Spawn.Keys.Single(), Is.EqualTo(SpawnedEntityId)); Assert.That(spawnEntitiesBehavior.Spawn.Values.Single(), Is.EqualTo(new MinMax {Min = 1, Max = 1})); - var entitiesInRange = sEntityManager.GetEntitiesInRange(coordinates, 2); + var entitiesInRange = IoCManager.Resolve().GetEntitiesInRange(coordinates, 2); var found = false; foreach (var entity in entitiesInRange) diff --git a/Content.Server/Actions/GhostBoo.cs b/Content.Server/Actions/GhostBoo.cs index f272ad9334..6223fb3cd9 100644 --- a/Content.Server/Actions/GhostBoo.cs +++ b/Content.Server/Actions/GhostBoo.cs @@ -5,6 +5,8 @@ using Content.Shared.Actions; using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.Utility; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; @@ -26,8 +28,7 @@ namespace Content.Server.Actions if (!args.Performer.TryGetComponent(out var actions)) return; // find all IGhostBooAffected nearby and do boo on them - var entityMan = args.Performer.EntityManager; - var ents = entityMan.GetEntitiesInRange(args.Performer, _radius, false); + var ents = IoCManager.Resolve().GetEntitiesInRange(args.Performer, _radius, false); var booCounter = 0; foreach (var ent in ents) diff --git a/Content.Server/Commands/Chat/SuicideCommand.cs b/Content.Server/Commands/Chat/SuicideCommand.cs index 6c58c4ebfb..d42b73de53 100644 --- a/Content.Server/Commands/Chat/SuicideCommand.cs +++ b/Content.Server/Commands/Chat/SuicideCommand.cs @@ -95,7 +95,7 @@ namespace Content.Server.Commands.Chat } } // Get all entities in range of the suicider - var entities = owner.EntityManager.GetEntitiesInRange(owner, 1, true).ToArray(); + var entities = IoCManager.Resolve().GetEntitiesInRange(owner, 1, true).ToArray(); if (entities.Length > 0) { diff --git a/Content.Server/Commands/Interactable/AnchorCommand.cs b/Content.Server/Commands/Interactable/AnchorCommand.cs index 42c2acbf45..e67a85201e 100644 --- a/Content.Server/Commands/Interactable/AnchorCommand.cs +++ b/Content.Server/Commands/Interactable/AnchorCommand.cs @@ -6,6 +6,7 @@ using Content.Shared.Administration; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Commands.Interactable @@ -43,8 +44,7 @@ namespace Content.Server.Commands.Interactable return; } - var serverEntityManager = IoCManager.Resolve(); - var entities = serverEntityManager.GetEntitiesInRange(player.AttachedEntity, radius).ToList(); + var entities = IoCManager.Resolve().GetEntitiesInRange(player.AttachedEntity, radius).ToList(); foreach (var entity in entities) { diff --git a/Content.Server/Commands/Interactable/UnAnchorCommand.cs b/Content.Server/Commands/Interactable/UnAnchorCommand.cs index 25259366a8..b7d0f4a40e 100644 --- a/Content.Server/Commands/Interactable/UnAnchorCommand.cs +++ b/Content.Server/Commands/Interactable/UnAnchorCommand.cs @@ -6,6 +6,7 @@ using Content.Shared.Administration; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Commands.Interactable @@ -43,8 +44,7 @@ namespace Content.Server.Commands.Interactable return; } - var serverEntityManager = IoCManager.Resolve(); - var entities = serverEntityManager.GetEntitiesInRange(player.AttachedEntity, radius).ToList(); + var entities = IoCManager.Resolve().GetEntitiesInRange(player.AttachedEntity, radius).ToList(); foreach (var entity in entities) { diff --git a/Content.Server/Construction/Conditions/ComponentInTile.cs b/Content.Server/Construction/Conditions/ComponentInTile.cs index 32820744c1..196183a82e 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, entity.EntityManager); + var entities = indices.GetEntitiesInTile(entity.Transform.GridID, true, IoCManager.Resolve()); foreach (var ent in entities) { diff --git a/Content.Server/Explosions/ExplosionHelper.cs b/Content.Server/Explosions/ExplosionHelper.cs index fba68c6889..2a88ea5c5e 100644 --- a/Content.Server/Explosions/ExplosionHelper.cs +++ b/Content.Server/Explosions/ExplosionHelper.cs @@ -70,12 +70,10 @@ namespace Content.Server.Explosions MapId mapId) { var entityManager = IoCManager.Resolve(); - var serverEntityManager = IoCManager.Resolve(); - var entitySystemManager = IoCManager.Resolve(); - var exAct = entitySystemManager.GetEntitySystem(); + var exAct = EntitySystem.Get(); - var entitiesInRange = serverEntityManager.GetEntitiesInRange(mapId, boundingBox, 0).ToList(); + var entitiesInRange = IoCManager.Resolve().GetEntitiesInRange(mapId, boundingBox, 0).ToList(); var impassableEntities = new List>(); var nonImpassableEntities = new List>(); diff --git a/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs b/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs index 5576b9276a..f43e98a7c2 100644 --- a/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs +++ b/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs @@ -116,7 +116,7 @@ namespace Content.Server.GameObjects.Components.Fluids PuddleComponent? puddle = null; var spilt = false; - var spillEntities = entityManager.GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray(); + var spillEntities = IoCManager.Resolve().GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray(); foreach (var spillEntity in spillEntities) { if (spillEntity.TryGetComponent(out ISolutionInteractionsComponent? solutionContainerComponent) && diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index 25bca32aa3..55a2aaa311 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -19,6 +19,7 @@ using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Enums; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Network; @@ -498,7 +499,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage if(_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent())) { var validStorables = new List(); - foreach (var entity in Owner.EntityManager.GetEntitiesInRange(eventArgs.ClickLocation, 1)) + foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(eventArgs.ClickLocation, 1)) { if (!entity.Transform.IsMapTransform || entity == eventArgs.User diff --git a/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs b/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs index afd851bd23..1ac2fb9a1d 100644 --- a/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs +++ b/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs @@ -94,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Portal } if (_avoidCollidable) { - foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(mapCoords)) + foreach (var entity in IoCManager.Resolve().GetEntitiesIntersecting(mapCoords)) { // Added this component to avoid stacking portals and causing shenanigans // TODO: Doesn't do a great job of stopping stacking portals for directed @@ -139,7 +139,7 @@ namespace Content.Server.GameObjects.Components.Portal private bool EmptySpace(IEntity user, Vector2 target) { // TODO: Check the user's spot? Upside is no stacking TPs but downside is they can't unstuck themselves from walls. - foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(user.Transform.MapID, target)) + foreach (var entity in IoCManager.Resolve().GetEntitiesIntersecting(user.Transform.MapID, target)) { if (entity.HasComponent() || entity.HasComponent()) { diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs index b795c9231e..4933ed1d74 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -101,7 +102,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents private List FindAvailableReceivers() { - var nearbyEntities = Owner.EntityManager + var nearbyEntities = IoCManager.Resolve() .GetEntitiesInRange(Owner, PowerTransferRange); var receivers = new List(); diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs index da2c599378..a86a5a94f2 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs @@ -7,9 +7,7 @@ using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; -using Robust.Shared.Prototypes; using Robust.Shared.Physics; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -22,8 +20,6 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents [RegisterComponent] public class PowerReceiverComponent : Component, IExamine { - [Dependency] private readonly IServerEntityManager _serverEntityManager = default!; - [ViewVariables] [ComponentDependency] private readonly IPhysBody? _physicsComponent = null; public override string Name => "PowerReceiver"; @@ -131,7 +127,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents private bool TryFindAvailableProvider(out IPowerProvider foundProvider) { - var nearbyEntities = _serverEntityManager + var nearbyEntities = IoCManager.Resolve() .GetEntitiesInRange(Owner, PowerReceptionRange); foreach (var entity in nearbyEntities) @@ -140,7 +136,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents { if (provider.Connectable) { - if (provider.Owner.Transform.Coordinates.TryDistance(_serverEntityManager, Owner.Transform.Coordinates, out var distance)) + if (provider.Owner.Transform.Coordinates.TryDistance(Owner.EntityManager, Owner.Transform.Coordinates, out var distance)) { if (distance < Math.Min(PowerReceptionRange, provider.PowerTransferRange)) { diff --git a/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs b/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs index 13aa585e3c..8d95dd3fe4 100644 --- a/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs @@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Weapon public static void FlashAreaHelper(IEntity source, float range, float duration, string? sound = null) { - foreach (var entity in source.EntityManager.GetEntitiesInRange(source.Transform.Coordinates, range)) + foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(source.Transform.Coordinates, range)) { if (!entity.TryGetComponent(out FlashableComponent? flashable) || !source.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue; diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs index a5f86dade4..42e1e8d301 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; @@ -69,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee return false; } - foreach (var entity in Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, _range)) + foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(Owner.Transform.Coordinates, _range)) { Flash(entity, eventArgs.User, _aoeFlashDuration); } diff --git a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs index 261ddf8e86..12711a3305 100644 --- a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs @@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - foreach (var near in EntityManager.GetEntitiesInRange(user!, 2f, true)) + foreach (var near in IoCManager.Resolve().GetEntitiesInRange(user!, 2f, true)) { yield return near; } diff --git a/Content.Server/GameObjects/EntitySystems/StationEvents/RadiationPulseSystem.cs b/Content.Server/GameObjects/EntitySystems/StationEvents/RadiationPulseSystem.cs index b91c1aa0e7..0fff3db93d 100644 --- a/Content.Server/GameObjects/EntitySystems/StationEvents/RadiationPulseSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StationEvents/RadiationPulseSystem.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.Components.StationEvents; using Content.Shared.Interfaces.GameObjects.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; namespace Content.Server.GameObjects.EntitySystems.StationEvents @@ -40,6 +41,8 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents { base.Update(frameTime); + var lookupSystem = IoCManager.Resolve(); + foreach (var comp in ComponentManager.EntityQuery(true)) { comp.Update(frameTime); @@ -47,7 +50,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents if (ent.Deleted) continue; - foreach (var entity in EntityManager.GetEntitiesInRange(ent.Transform.Coordinates, comp.Range, true)) + foreach (var entity in lookupSystem.GetEntitiesInRange(ent.Transform.Coordinates, comp.Range, true)) { if (entity.Deleted) continue; diff --git a/Content.Server/Physics/Controllers/ConveyorController.cs b/Content.Server/Physics/Controllers/ConveyorController.cs index 88a53b6f18..1f11f270cc 100644 --- a/Content.Server/Physics/Controllers/ConveyorController.cs +++ b/Content.Server/Physics/Controllers/ConveyorController.cs @@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Conveyor; using Content.Server.GameObjects.Components.Recycling; using Content.Shared.GameObjects.Components.Movement; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Physics.Controllers; @@ -39,7 +40,7 @@ namespace Content.Server.Physics.Controllers return; } - var intersecting = EntityManager.GetEntitiesIntersecting(comp.Owner, true); + var intersecting = IoCManager.Resolve().GetEntitiesIntersecting(comp.Owner, true); var direction = comp.GetAngle().ToVec(); Vector2? ownerPos = null; @@ -99,11 +100,12 @@ namespace Content.Server.Physics.Controllers var direction = Vector2.UnitX; Vector2? ownerPos = null; + // TODO: I know it sucks but conveyors need a refactor for (var i = comp.Intersecting.Count - 1; i >= 0; i--) { var entity = comp.Intersecting[i]; - if (entity.Deleted || !comp.CanMove(entity) || !EntityManager.IsIntersecting(comp.Owner, entity)) + if (entity.Deleted || !comp.CanMove(entity) || !IoCManager.Resolve().IsIntersecting(comp.Owner, entity)) { comp.Intersecting.RemoveAt(i); continue; diff --git a/Content.Server/Physics/Controllers/SingularityController.cs b/Content.Server/Physics/Controllers/SingularityController.cs index 7702bcd04d..423116e2fd 100644 --- a/Content.Server/Physics/Controllers/SingularityController.cs +++ b/Content.Server/Physics/Controllers/SingularityController.cs @@ -74,7 +74,7 @@ namespace Content.Server.Physics.Controllers { var singularityCoords = component.Owner.Transform.Coordinates; // TODO: Maybe if we have named fixtures needs to pull out the outer circle collider (inner will be for deleting). - var entitiesToPull = EntityManager.GetEntitiesInRange(singularityCoords, component.Level * 10); + var entitiesToPull = IoCManager.Resolve().GetEntitiesInRange(singularityCoords, component.Level * 10); foreach (var entity in entitiesToPull) { if (!entity.TryGetComponent(out var collidableComponent) || collidableComponent.BodyType == BodyType.Static) continue; diff --git a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs index 95d2f0e681..d2fae33c02 100644 --- a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs +++ b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.GameObjects.Components.Storage; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Physics; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -102,11 +103,12 @@ namespace Content.Shared.GameObjects.Components.Disposal { if(_intersecting.Count == 0) return; + // TODO: Yeah look this sucks but we'll fix it someday. for (var i = _intersecting.Count - 1; i >= 0; i--) { var entity = _intersecting[i]; - if (!Owner.EntityManager.IsIntersecting(entity, Owner)) + if (IoCManager.Resolve().IsIntersecting(entity, Owner)) _intersecting.RemoveAt(i); } } diff --git a/Content.Shared/GameObjects/Verbs/SharedVerbSystem.cs b/Content.Shared/GameObjects/Verbs/SharedVerbSystem.cs index d20cbf987d..7800ff9c27 100644 --- a/Content.Shared/GameObjects/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/GameObjects/Verbs/SharedVerbSystem.cs @@ -5,6 +5,7 @@ using System.Linq; using Content.Shared.Physics; using Content.Shared.Utility; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -25,8 +26,8 @@ namespace Content.Shared.GameObjects.Verbs contextEntities = null; var length = buffer ? 1.0f: 0.5f; - var entities = EntityManager.GetEntitiesIntersecting(targetPos.MapId, - Box2.CenteredAround(targetPos.Position, (length, length))).ToList(); + var entities = IoCManager.Resolve(). + GetEntitiesIntersecting(targetPos.MapId, Box2.CenteredAround(targetPos.Position, (length, length))).ToList(); if (entities.Count == 0) { diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index aa0c19cdc8..d736eb9f86 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -149,32 +149,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, IEntityManager? entityManager = null) + public static IEnumerable GetEntitiesInTile(this TileRef turf, bool approximate = false, IEntityLookup? lookupSystem = null) { - entityManager ??= IoCManager.Resolve(); + lookupSystem ??= IoCManager.Resolve(); - return entityManager.GetEntitiesIntersecting(turf.MapIndex, GetWorldTileBox(turf), approximate); + return lookupSystem.GetEntitiesIntersecting(turf.MapIndex, GetWorldTileBox(turf), approximate); } /// /// Helper that returns all entities in a turf. /// - public static IEnumerable GetEntitiesInTile(this EntityCoordinates coordinates, bool approximate = false, IEntityManager? entityManager = null) + public static IEnumerable GetEntitiesInTile(this EntityCoordinates coordinates, bool approximate = false, IEntityLookup? lookupSystem = null) { var turf = coordinates.GetTileRef(); if (turf == null) return Enumerable.Empty(); - return GetEntitiesInTile(turf.Value, approximate, entityManager); + return GetEntitiesInTile(turf.Value, approximate, lookupSystem); } /// /// Helper that returns all entities in a turf. /// - public static IEnumerable GetEntitiesInTile(this Vector2i indices, GridId gridId, bool approximate = false, IEntityManager? entityManager = null) + public static IEnumerable GetEntitiesInTile(this Vector2i indices, GridId gridId, bool approximate = false, IEntityLookup? lookupSystem = null) { - return GetEntitiesInTile(indices.GetTileRef(gridId), approximate, entityManager); + return GetEntitiesInTile(indices.GetTileRef(gridId), approximate, lookupSystem); } /// diff --git a/RobustToolbox b/RobustToolbox index aacf6522b4..d8aad89c2f 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit aacf6522b48c4f4ccf6bfbe138154310cd9935be +Subproject commit d8aad89c2fd911431834081131a85efe9e46c2c3