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 <metalgearsloth@gmail.com>
This commit is contained in:
@@ -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<IEntityLookup>().GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray();
|
||||
foreach (var spillEntity in spillEntities)
|
||||
{
|
||||
if (spillEntity.TryGetComponent(out ISolutionInteractionsComponent? solutionContainerComponent) &&
|
||||
|
||||
@@ -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<SharedItemComponent>()))
|
||||
{
|
||||
var validStorables = new List<IEntity>();
|
||||
foreach (var entity in Owner.EntityManager.GetEntitiesInRange(eventArgs.ClickLocation, 1))
|
||||
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, 1))
|
||||
{
|
||||
if (!entity.Transform.IsMapTransform
|
||||
|| entity == eventArgs.User
|
||||
|
||||
@@ -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<IEntityLookup>().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<IEntityLookup>().GetEntitiesIntersecting(user.Transform.MapID, target))
|
||||
{
|
||||
if (entity.HasComponent<IPhysBody>() || entity.HasComponent<PortalComponent>())
|
||||
{
|
||||
|
||||
@@ -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<PowerReceiverComponent> FindAvailableReceivers()
|
||||
{
|
||||
var nearbyEntities = Owner.EntityManager
|
||||
var nearbyEntities = IoCManager.Resolve<IEntityLookup>()
|
||||
.GetEntitiesInRange(Owner, PowerTransferRange);
|
||||
|
||||
var receivers = new List<PowerReceiverComponent>();
|
||||
|
||||
@@ -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<IEntityLookup>()
|
||||
.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))
|
||||
{
|
||||
|
||||
@@ -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<IEntityLookup>().GetEntitiesInRange(source.Transform.Coordinates, range))
|
||||
{
|
||||
if (!entity.TryGetComponent(out FlashableComponent? flashable) ||
|
||||
!source.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue;
|
||||
|
||||
@@ -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<IEntityLookup>().GetEntitiesInRange(Owner.Transform.Coordinates, _range))
|
||||
{
|
||||
Flash(entity, eventArgs.User, _aoeFlashDuration);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var near in EntityManager.GetEntitiesInRange(user!, 2f, true))
|
||||
foreach (var near in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(user!, 2f, true))
|
||||
{
|
||||
yield return near;
|
||||
}
|
||||
|
||||
@@ -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<IEntityLookup>();
|
||||
|
||||
foreach (var comp in ComponentManager.EntityQuery<RadiationPulseComponent>(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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user