Removed EntityManager member variable from Components and EntitySystems (#2502)

* Removed EntityManager member variable from Components and EntitySystems

* Removed EntityManager with minor corecctions

* Update PathfindingSystem.cs

* Update InteractionSystem.cs

* Update Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>

* Update Content.Client/GameObjects/Components/Suspicion/SuspicionRoleComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Client/GameObjects/Components/Suspicion/TraitorOverlay.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/PDA/PDAComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

* Update Content.Server/GameObjects/Components/Stack/StackComponent.cs

Co-authored-by: Clyybber <darkmine956@gmail.com>

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
Co-authored-by: Clyybber <darkmine956@gmail.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
ColdAutumnRain
2020-11-18 15:45:53 +01:00
committed by GitHub
parent 87e74c4494
commit f5dc62b533
42 changed files with 66 additions and 118 deletions

View File

@@ -25,8 +25,6 @@ namespace Content.Client.GameObjects.Components.Storage
[RegisterComponent]
public class ClientStorageComponent : SharedStorageComponent, IDraggable
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private List<IEntity> _storedEntities = new List<IEntity>();
private int StorageSizeUsed;
private int StorageCapacityMax;
@@ -58,7 +56,7 @@ namespace Content.Client.GameObjects.Components.Storage
}
_storedEntities = state.StoredEntities
.Select(id => _entityManager.GetEntity(id))
.Select(id => Owner.EntityManager.GetEntity(id))
.ToList();
}
@@ -88,7 +86,7 @@ namespace Content.Client.GameObjects.Components.Storage
/// <param name="storageState"></param>
private void HandleStorageMessage(StorageHeldItemsMessage storageState)
{
_storedEntities = storageState.StoredEntities.Select(id => _entityManager.GetEntity(id)).ToList();
_storedEntities = storageState.StoredEntities.Select(id => Owner.EntityManager.GetEntity(id)).ToList();
StorageSizeUsed = storageState.StorageSizeUsed;
StorageCapacityMax = storageState.StorageSizeMax;
Window.BuildEntityList();

View File

@@ -21,7 +21,6 @@ namespace Content.Client.GameObjects.Components.Suspicion
public class SuspicionRoleComponent : SharedSuspicionRoleComponent
{
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
@@ -107,7 +106,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
return;
}
var overlay = new TraitorOverlay(Owner, _entityManager, _resourceCache, _eyeManager);
var overlay = new TraitorOverlay(Owner, Owner.EntityManager, _resourceCache, _eyeManager);
_overlayManager.AddOverlay(overlay);
}

View File

@@ -27,7 +27,6 @@ namespace Content.Client.GameObjects.EntitySystems
{
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private int _nextId;
private readonly Dictionary<int, ConstructionGhostComponent> _ghosts = new Dictionary<int, ConstructionGhostComponent>();
@@ -124,7 +123,7 @@ namespace Content.Client.GameObjects.EntitySystems
if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide())
return false;
var entity = _entityManager.GetEntity(args.EntityUid);
var entity = EntityManager.GetEntity(args.EntityUid);
if (!entity.TryGetComponent(out ConstructionGhostComponent ghostComp))
return false;
@@ -167,7 +166,7 @@ namespace Content.Client.GameObjects.EntitySystems
return;
}
var ghost = _entityManager.SpawnEntity("constructionghost", loc);
var ghost = EntityManager.SpawnEntity("constructionghost", loc);
var comp = ghost.GetComponent<ConstructionGhostComponent>();
comp.Prototype = prototype;
comp.GhostID = _nextId++;

View File

@@ -27,7 +27,6 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
* It'll also handle overall cleanup when one is removed (i.e. removing it from DoAfterGui).
*/
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
/// <summary>
/// We'll use an excess time so stuff like finishing effects can show.
@@ -39,7 +38,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
private HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private IEntity? _attachedEntity;
public override void Initialize()
{
base.Initialize();
@@ -50,14 +49,14 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
_attachedEntity = message.AttachedEntity;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var currentTime = _gameTiming.CurTime;
var foundComps = new HashSet<DoAfterComponent>();
// Can't see any I guess?
if (_attachedEntity == null || _attachedEntity.Deleted)
return;
@@ -68,7 +67,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
_knownComponents.Add(comp);
}
var doAfters = comp.DoAfters.ToList();
if (doAfters.Count == 0)
@@ -88,10 +87,10 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
if (comp.Gui != null)
comp.Gui.FirstDraw = true;
return;
}
comp.Enable();
var userGrid = comp.Owner.Transform.Coordinates;
@@ -124,7 +123,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
if (doAfter.BreakOnTargetMove)
{
if (_entityManager.TryGetEntity(doAfter.TargetUid, out var targetEntity) && targetEntity.Transform.Coordinates != doAfter.TargetGrid)
if (EntityManager.TryGetEntity(doAfter.TargetUid, out var targetEntity) && targetEntity.Transform.Coordinates != doAfter.TargetGrid)
{
comp.Cancel(id, currentTime);
continue;
@@ -142,7 +141,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
comp.Remove(cancelled.Message);
}
}
// Remove any components that we no longer need to track
foundComps.Add(comp);
}

View File

@@ -30,7 +30,6 @@ namespace Content.Client.GameObjects.EntitySystems
public class DragDropSystem : EntitySystem
{
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -137,7 +136,7 @@ namespace Content.Client.GameObjects.EntitySystems
// possibly initiating a drag
// check if the clicked entity is draggable
if (_entityManager.TryGetEntity(args.EntityUid, out var entity))
if (EntityManager.TryGetEntity(args.EntityUid, out var entity))
{
// check if the entity is reachable
if (!_interactionSystem.InRangeUnobstructed(dragger, entity))
@@ -241,7 +240,7 @@ namespace Content.Client.GameObjects.EntitySystems
_state = DragState.Dragging;
// pop up drag shadow under mouse
var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition);
_dragShadow = _entityManager.SpawnEntity("dragshadow", mousePos);
_dragShadow = EntityManager.SpawnEntity("dragshadow", mousePos);
var dragSprite = _dragShadow.GetComponent<SpriteComponent>();
dragSprite.CopyFrom(draggedSprite);
dragSprite.RenderOrder = EntityManager.CurrentTick.Value;
@@ -328,7 +327,7 @@ namespace Content.Client.GameObjects.EntitySystems
RemoveHighlights();
if (_dragShadow != null)
{
_entityManager.DeleteEntity(_dragShadow);
EntityManager.DeleteEntity(_dragShadow);
}
_dragShadow = null;

View File

@@ -27,7 +27,6 @@ namespace Content.Client.GameObjects.EntitySystems
{
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public const string StyleClassEntityTooltip = "entity-tooltip";
@@ -52,7 +51,7 @@ namespace Content.Client.GameObjects.EntitySystems
private bool HandleExamine(ICommonSession session, EntityCoordinates coords, EntityUid uid)
{
if (!uid.IsValid() || !_entityManager.TryGetEntity(uid, out var examined))
if (!uid.IsValid() || !EntityManager.TryGetEntity(uid, out var examined))
{
return false;
}

View File

@@ -43,7 +43,6 @@ namespace Content.Client.GameObjects.EntitySystems
public sealed class VerbSystem : SharedVerbSystem, IResettingEntitySystem
{
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
@@ -148,7 +147,7 @@ namespace Content.Client.GameObjects.EntitySystems
return false;
}
var mapCoordinates = args.Coordinates.ToMap(_entityManager);
var mapCoordinates = args.Coordinates.ToMap(EntityManager);
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || !TryGetContextEntities(playerEntity, mapCoordinates, out var entities))
@@ -196,7 +195,7 @@ namespace Content.Client.GameObjects.EntitySystems
private void FillEntityPopup(VerbSystemMessages.VerbsResponseMessage msg)
{
if (_currentEntity != msg.Entity || !_entityManager.TryGetEntity(_currentEntity, out var entity))
if (_currentEntity != msg.Entity || !EntityManager.TryGetEntity(_currentEntity, out var entity))
{
return;
}

View File

@@ -31,8 +31,6 @@ namespace Content.Server.GameObjects.Components.Atmos
[RegisterComponent]
public class FlammableComponent : SharedFlammableComponent, ICollideBehavior, IFireAct, IReagentReaction
{
[Dependency] private IEntityManager _entityManager = default!;
private bool _resisting = false;
private readonly List<EntityUid> _collided = new List<EntityUid>();
@@ -137,13 +135,13 @@ namespace Content.Server.GameObjects.Components.Atmos
foreach (var uid in _collided.ToArray())
{
if (!uid.IsValid() || !_entityManager.EntityExists(uid))
if (!uid.IsValid() || !Owner.EntityManager.EntityExists(uid))
{
_collided.Remove(uid);
continue;
}
var entity = _entityManager.GetEntity(uid);
var entity = Owner.EntityManager.GetEntity(uid);
var physics = Owner.GetComponent<IPhysicsComponent>();
var otherPhysics = entity.GetComponent<IPhysicsComponent>();

View File

@@ -26,8 +26,6 @@ namespace Content.Server.GameObjects.Components.Atmos
[RegisterComponent]
public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IUse
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private GasAnalyzerDanger _pressureDanger;
private float _timeSinceSync;
private const float TimeBetweenSyncs = 2f;
@@ -183,14 +181,14 @@ namespace Content.Server.GameObjects.Components.Atmos
if (!_checkPlayer && _position.HasValue)
{
// Check if position is out of range => don't update
if (!_position.Value.InRange(_entityManager, pos, SharedInteractionSystem.InteractionRange))
if (!_position.Value.InRange(Owner.EntityManager, pos, SharedInteractionSystem.InteractionRange))
return;
pos = _position.Value;
}
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
var gam = atmosSystem.GetGridAtmosphere(pos.GetGridId(_entityManager));
var gam = atmosSystem.GetGridAtmosphere(pos.GetGridId(Owner.EntityManager));
var tile = gam?.GetTile(pos).Air;
if (tile == null)
{

View File

@@ -18,7 +18,6 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
/// </summary>
public abstract class BaseSiphonComponent : PipeNetDeviceComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private PipeNode _scrubberOutlet;
@@ -65,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
if (!SiphonEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(Owner.EntityManager);
if (tileAtmos == null)
return;
ScrubGas(tileAtmos.Air, _scrubberOutlet.Air);

View File

@@ -18,7 +18,6 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
/// </summary>
public abstract class BaseVentComponent : PipeNetDeviceComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private PipeNode _ventInlet;
@@ -65,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
if (!VentEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(Owner.EntityManager);
if (tileAtmos == null)
return;
VentGas(_ventInlet.Air, tileAtmos.Air);

View File

@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Construction
public class ConstructionComponent : Component, IExamine, IInteractUsing
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Construction";
@@ -392,7 +391,7 @@ namespace Content.Server.GameObjects.Components.Construction
{
if (node.Entity == Owner.Prototype?.ID || string.IsNullOrEmpty(node.Entity)) return false;
var entity = _entityManager.SpawnEntity(node.Entity, Owner.Transform.Coordinates);
var entity = Owner.EntityManager.SpawnEntity(node.Entity, Owner.Transform.Coordinates);
entity.Transform.LocalRotation = Owner.Transform.LocalRotation;

View File

@@ -50,8 +50,6 @@ namespace Content.Server.GameObjects.Components.Fluids
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Puddle";
private CancellationTokenSource _evaporationToken;
@@ -399,7 +397,7 @@ namespace Content.Server.GameObjects.Components.Fluids
if (puddle == default)
{
var grid = _snapGrid.DirectionToGrid(direction);
puddle = () => _entityManager.SpawnEntity(Owner.Prototype.ID, grid).GetComponent<PuddleComponent>();
puddle = () => Owner.EntityManager.SpawnEntity(Owner.Prototype.ID, grid).GetComponent<PuddleComponent>();
}
return true;

View File

@@ -17,8 +17,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
[RegisterComponent]
public class CursedEntityStorageComponent : EntityStorageComponent
{
[Dependency] private IEntityManager _entityManager = default!;
[Dependency] private IRobustRandom _robustRandom = default!;
[Dependency] private IRobustRandom _robustRandom = default!;
public override string Name => "CursedEntityStorage";
@@ -29,7 +28,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
// No contents, we do nothing
if (Contents.ContainedEntities.Count == 0) return;
var lockers = _entityManager.GetEntities(new TypeEntityQuery(typeof(EntityStorageComponent))).ToList();
var lockers = Owner.EntityManager.GetEntities(new TypeEntityQuery(typeof(EntityStorageComponent))).ToList();
if (lockers.Contains(Owner))
lockers.Remove(Owner);

View File

@@ -36,8 +36,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
[ComponentReference(typeof(IStorageComponent))]
public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private const string LoggerName = "Storage";
private Container? _storage;
@@ -361,14 +359,14 @@ namespace Content.Server.GameObjects.Components.Items.Storage
var ownerTransform = Owner.Transform;
var playerTransform = player.Transform;
if (!playerTransform.Coordinates.InRange(_entityManager, ownerTransform.Coordinates, 2) ||
if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) ||
!ownerTransform.IsMapTransform &&
!playerTransform.ContainsEntity(ownerTransform))
{
break;
}
var entity = _entityManager.GetEntity(remove.EntityUid);
var entity = Owner.EntityManager.GetEntity(remove.EntityUid);
if (entity == null || _storage?.Contains(entity) == false)
{

View File

@@ -41,7 +41,6 @@ namespace Content.Server.GameObjects.Components.Kitchen
[ComponentReference(typeof(IActivate))]
public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISolutionChange, ISuicideAct
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly RecipeManager _recipeManager = default!;
#region YAMLSERIALIZE
@@ -340,7 +339,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
if (recipeToCook != null)
{
var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName;
_entityManager.SpawnEntity(entityToSpawn, Owner.Transform.Coordinates);
Owner.EntityManager.SpawnEntity(entityToSpawn, Owner.Transform.Coordinates);
}
}
_audioSystem.PlayFromEntity(_cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
@@ -391,9 +390,9 @@ namespace Content.Server.GameObjects.Components.Kitchen
private void EjectSolid(EntityUid entityID)
{
if (_entityManager.EntityExists(entityID))
if (Owner.EntityManager.EntityExists(entityID))
{
_storage.Remove(_entityManager.GetEntity(entityID));
_storage.Remove(Owner.EntityManager.GetEntity(entityID));
}
}

View File

@@ -18,8 +18,6 @@ namespace Content.Server.GameObjects.Components.MachineLinking
[RegisterComponent]
public class SignalTransmitterComponent : Component, IInteractUsing
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "SignalTransmitter";
private List<SignalReceiverComponent> _unresolvedReceivers;
@@ -62,7 +60,7 @@ namespace Content.Server.GameObjects.Components.MachineLinking
_unresolvedReceivers = new List<SignalReceiverComponent>();
foreach (var entityUid in entityUids)
{
if (!_entityManager.TryGetEntity(entityUid, out var entity)
if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity)
|| !entity.TryGetComponent<SignalReceiverComponent>(out var receiver))
{
continue;

View File

@@ -20,7 +20,6 @@ namespace Content.Server.GameObjects.Components.Markers
{
[Dependency] private readonly IGameTicker _gameTicker = default!;
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "ConditionalSpawner";
@@ -87,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Markers
}
if(!Owner.Deleted)
_entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
Owner.EntityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
}
public virtual void MapInit()

View File

@@ -16,7 +16,6 @@ namespace Content.Server.GameObjects.Components.Markers
[RegisterComponent]
public class TimedSpawnerComponent : Component
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "TimedSpawner";
@@ -81,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Markers
for (int i = 0; i < number; i++)
{
var entity = _robustRandom.Pick(Prototypes);
_entityManager.SpawnEntity(entity, Owner.Transform.Coordinates);
Owner.EntityManager.SpawnEntity(entity, Owner.Transform.Coordinates);
}
}
}

View File

@@ -14,7 +14,6 @@ namespace Content.Server.GameObjects.Components.Markers
[RegisterComponent]
public class TrashSpawnerComponent : ConditionalSpawnerComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "TrashSpawner";
@@ -42,7 +41,7 @@ namespace Content.Server.GameObjects.Components.Markers
{
if (RarePrototypes.Count > 0 && (RareChance == 1.0f || _robustRandom.Prob(RareChance)))
{
_entityManager.SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.Coordinates);
Owner.EntityManager.SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.Coordinates);
return;
}
@@ -64,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Markers
var x_negative = random.Prob(0.5f) ? -1 : 1;
var y_negative = random.Prob(0.5f) ? -1 : 1;
var entity = _entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
var entity = Owner.EntityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
entity.Transform.LocalPosition += new Vector2(random.NextFloat() * Offset * x_negative, random.NextFloat() * Offset * y_negative);
}

View File

@@ -32,7 +32,6 @@ namespace Content.Server.GameObjects.Components.Medical
public class CloningPodComponent : SharedCloningPodComponent, IActivate
{
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
[Dependency] private readonly IEntityManager _entityManager = null!;
[Dependency] private readonly IPlayerManager _playerManager = null!;
[ViewVariables]
@@ -169,7 +168,7 @@ namespace Content.Server.GameObjects.Components.Medical
if (!dead) return;
var mob = _entityManager.SpawnEntity("HumanMob_Content", Owner.Transform.MapPosition);
var mob = Owner.EntityManager.SpawnEntity("HumanMob_Content", Owner.Transform.MapPosition);
var client = _playerManager.GetSessionByUserId(mind.UserId!.Value);
var profile = GetPlayerProfileAsync(client.UserId);
mob.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(profile);

View File

@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Metabolism
public class MetabolismComponent : Component
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[ComponentDependency] private readonly IBody? _body = default!;
@@ -294,7 +293,7 @@ namespace Content.Server.GameObjects.Components.Metabolism
}
// creadth: sweating does not help in airless environment
if (Owner.Transform.Coordinates.TryGetTileAir(out _, _entityManager))
if (Owner.Transform.Coordinates.TryGetTileAir(out _, Owner.EntityManager))
{
temperatureComponent.RemoveHeat(Math.Min(targetHeat, SweatHeatRegulation));
}

View File

@@ -24,7 +24,6 @@ namespace Content.Server.GameObjects.Components.Movement
internal class ShuttleControllerComponent : Component, IMoverComponent
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private bool _movingUp;
private bool _movingDown;
@@ -67,7 +66,7 @@ namespace Content.Server.GameObjects.Components.Movement
var gridId = Owner.Transform.GridID;
if (_mapManager.TryGetGrid(gridId, out var grid) &&
_entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
Owner.EntityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
//TODO: Switch to shuttle component
if (!gridEntity.TryGetComponent(out IPhysicsComponent? physics))

View File

@@ -23,8 +23,6 @@ namespace Content.Server.GameObjects.Components.Nutrition
public sealed class FoodContainer : SharedFoodContainerComponent, IUse
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "FoodContainer";
private AppearanceComponent _appearance;
@@ -60,7 +58,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
return false;
}
var itemToSpawn = _entityManager.SpawnEntity(GetRandomPrototype(), Owner.Transform.Coordinates);
var itemToSpawn = Owner.EntityManager.SpawnEntity(GetRandomPrototype(), Owner.Transform.Coordinates);
handsComponent.PutInHandOrDrop(itemToSpawn.GetComponent<ItemComponent>());
_count--;
if (_count < 1)

View File

@@ -11,8 +11,6 @@ namespace Content.Server.GameObjects.Components.PA
[ComponentReference(typeof(ParticleAcceleratorPartComponent))]
public class ParticleAcceleratorEmitterComponent : ParticleAcceleratorPartComponent
{
[Dependency] private IEntityManager _entityManager = null!;
public override string Name => "ParticleAcceleratorEmitter";
public ParticleAcceleratorEmitterType Type;
@@ -25,7 +23,7 @@ namespace Content.Server.GameObjects.Components.PA
public void Fire(ParticleAcceleratorPowerState strength)
{
var projectile = _entityManager.SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
var projectile = Owner.EntityManager.SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
if (!projectile.TryGetComponent<ParticleProjectileComponent>(out var particleProjectileComponent))
{

View File

@@ -14,7 +14,6 @@ namespace Content.Server.GameObjects.Components.Power
[RegisterComponent]
internal class WirePlacerComponent : Component, IAfterInteract
{
[Dependency] private readonly IServerEntityManager _entityManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
/// <inheritdoc />
@@ -37,7 +36,7 @@ namespace Content.Server.GameObjects.Components.Power
public void AfterInteract(AfterInteractEventArgs eventArgs)
{
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return;
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(_entityManager), out var grid))
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid))
return;
var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center);
var snapCell = grid.GetSnapGridCell(snapPos, SnapGridOffset.Center);
@@ -52,7 +51,7 @@ namespace Content.Server.GameObjects.Components.Power
}
if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1))
return;
_entityManager.SpawnEntity(_wirePrototypeID, grid.GridTileToLocal(snapPos));
Owner.EntityManager.SpawnEntity(_wirePrototypeID, grid.GridTileToLocal(snapPos));
}
}
}

View File

@@ -22,8 +22,6 @@ namespace Content.Server.GameObjects.Components.Radio
public class HandheldRadioComponent : Component, IUse, IListen, IRadio, IActivate, IExamine
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Radio";
private RadioSystem _radioSystem = default!;
@@ -91,7 +89,7 @@ namespace Content.Server.GameObjects.Components.Radio
public bool CanListen(string message, IEntity source)
{
return RadioOn &&
Owner.Transform.Coordinates.TryDistance(_entityManager, source.Transform.Coordinates, out var distance) &&
Owner.Transform.Coordinates.TryDistance(Owner.EntityManager, source.Transform.Coordinates, out var distance) &&
distance <= ListenRange;
}

View File

@@ -26,8 +26,6 @@ namespace Content.Server.GameObjects.Components.Recycling
[RegisterComponent]
public class RecyclerComponent : Component, ICollideBehavior
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Recycler";
private List<IEntity> _intersecting = new List<IEntity>();
@@ -164,7 +162,7 @@ namespace Content.Server.GameObjects.Components.Recycling
{
var entity = _intersecting[i];
if (entity.Deleted || !CanMove(entity) || !_entityManager.IsIntersecting(Owner, entity))
if (entity.Deleted || !CanMove(entity) || !Owner.EntityManager.IsIntersecting(Owner, entity))
{
_intersecting.RemoveAt(i);
continue;

View File

@@ -35,7 +35,6 @@ namespace Content.Server.GameObjects.Components.Singularity
[ComponentReference(typeof(IActivate))]
public class EmitterComponent : Component, IActivate, IInteractUsing
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[ComponentDependency] private AppearanceComponent? _appearance = default;
@@ -251,7 +250,7 @@ namespace Content.Server.GameObjects.Components.Singularity
private void Fire()
{
var projectile = _entityManager.SpawnEntity(_boltType, Owner.Transform.Coordinates);
var projectile = Owner.EntityManager.SpawnEntity(_boltType, Owner.Transform.Coordinates);
if (!projectile.TryGetComponent<PhysicsComponent>(out var physicsComponent))
{

View File

@@ -175,7 +175,7 @@ namespace Content.Server.GameObjects.Components.Singularity
}
_previousPulledEntites.Clear();
var entitiesToPull = _entityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
foreach (var entity in entitiesToPull)
{
if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;

View File

@@ -24,8 +24,6 @@ namespace Content.Server.GameObjects.Components.Stack
[ComponentReference(typeof(SharedStackComponent))]
public class StackComponent : SharedStackComponent, IInteractUsing, IExamine
{
[Dependency] private IEntityManager _entityManager = default!;
private bool _throwIndividually = false;
public override int Count
@@ -78,7 +76,7 @@ namespace Content.Server.GameObjects.Components.Stack
{
Count -= amount;
stack = _entityManager.SpawnEntity(Owner.Prototype?.ID, spawnPosition);
stack = Owner.EntityManager.SpawnEntity(Owner.Prototype?.ID, spawnPosition);
if (stack.TryGetComponent(out StackComponent? stackComp))
{

View File

@@ -23,8 +23,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
[RegisterComponent]
public class FlashComponent : MeleeWeaponComponent, IUse, IExamine
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Flash";
[ViewVariables(VVAccess.ReadWrite)] private int _flashDuration = 5000;
@@ -84,7 +82,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
return false;
}
foreach (var entity in _entityManager.GetEntitiesInRange(Owner.Transform.Coordinates, _range))
foreach (var entity in Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, _range))
{
Flash(entity, eventArgs.User, _aoeFlashDuration);
}

View File

@@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public IReadOnlyDictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> Graph => _graph;
private readonly Dictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> _graph = new Dictionary<GridId, Dictionary<Vector2i, PathfindingChunk>>();
@@ -361,7 +361,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
// Also look at increasing tile cost the more physics entities are on it
public bool CanTraverse(IEntity entity, EntityCoordinates coordinates)
{
var gridId = coordinates.GetGridId(_entityManager);
var gridId = coordinates.GetGridId(EntityManager);
var tile = _mapManager.GetGrid(gridId).GetTileRef(coordinates);
var node = GetNode(tile);
return CanTraverse(entity, node);

View File

@@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
// http://www.red3d.com/cwr/papers/1999/gdc99steer.html for a steering overview
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPauseManager _pauseManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private PathfindingSystem _pathfindingSystem;
@@ -269,7 +268,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
// Validation
// Check if we can even arrive -> Currently only samegrid movement supported
if (entity.Transform.GridID != steeringRequest.TargetGrid.GetGridId(_entityManager))
if (entity.Transform.GridID != steeringRequest.TargetGrid.GetGridId(EntityManager))
{
controller.VelocityDir = Vector2.Zero;
return SteeringStatus.NoPath;

View File

@@ -11,7 +11,6 @@ namespace Content.Server.GameObjects.EntitySystems
public class AtmosExposedSystem
: EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private const float UpdateDelay = 1f;
private float _lastUpdate;
@@ -24,7 +23,7 @@ namespace Content.Server.GameObjects.EntitySystems
// creadth: everything exposable by atmos should be updated as well
foreach (var atmosExposedComponent in EntityManager.ComponentManager.EntityQuery<AtmosExposedComponent>())
{
var tile = atmosExposedComponent.Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
var tile = atmosExposedComponent.Owner.Transform.Coordinates.GetTileAtmosphere(EntityManager);
if (tile == null) continue;
atmosExposedComponent.Update(tile, _lastUpdate);
}

View File

@@ -11,8 +11,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
{
public class ExamineSystem : ExamineSystemShared
{
[Dependency] private IEntityManager _entityManager = default!;
private static readonly FormattedMessage _entityNotFoundMessage;
static ExamineSystem()
@@ -38,7 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
var channel = player.ConnectedClient;
if (playerEnt == null
|| !_entityManager.TryGetEntity(request.EntityUid, out var entity)
|| !EntityManager.TryGetEntity(request.EntityUid, out var entity)
|| !CanExamine(playerEnt, entity))
{
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(

View File

@@ -805,7 +805,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
private void DoAttack(IEntity player, EntityCoordinates coordinates, bool wideAttack, EntityUid target = default)
{
// Verify player is on the same map as the entity he clicked on
if (_mapManager.GetGrid(coordinates.GetGridId(_entityManager)).ParentMapId != player.Transform.MapID)
if (_mapManager.GetGrid(coordinates.GetGridId(EntityManager)).ParentMapId != player.Transform.MapID)
{
Logger.WarningS("system.interaction",
$"Player named {player.Name} clicked on a map he isn't located on");

View File

@@ -35,7 +35,6 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly]
internal class ConstructionSystem : SharedConstructionSystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@@ -83,7 +82,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
foreach (var near in _entityManager.GetEntitiesInRange(user!, 2f, true))
foreach (var near in EntityManager.GetEntitiesInRange(user!, 2f, true))
{
yield return near;
}
@@ -264,7 +263,7 @@ namespace Content.Server.GameObjects.EntitySystems
return null;
}
var newEntity = _entityManager.SpawnEntity(graph.Nodes[edge.Target].Entity, user.Transform.Coordinates);
var newEntity = EntityManager.SpawnEntity(graph.Nodes[edge.Target].Entity, user.Transform.Coordinates);
// Yes, this should throw if it's missing the component.
var construction = newEntity.GetComponent<ConstructionComponent>();

View File

@@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly]
internal sealed class HandsSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
@@ -122,7 +121,7 @@ namespace Content.Server.GameObjects.EntitySystems
var entCoords = ent.Transform.Coordinates.Position;
var entToDesiredDropCoords = coords.Position - entCoords;
var targetLength = Math.Min(entToDesiredDropCoords.Length, SharedInteractionSystem.InteractionRange - 0.001f); // InteractionRange is reduced due to InRange not dealing with floating point error
var newCoords = coords.WithPosition(entToDesiredDropCoords.Normalized * targetLength + entCoords).ToMap(_entityManager);
var newCoords = coords.WithPosition(entToDesiredDropCoords.Normalized * targetLength + entCoords).ToMap(EntityManager);
var rayLength = Get<SharedInteractionSystem>().UnobstructedDistance(ent.Transform.MapPosition, newCoords, ignoredEnt: ent);
handsComp.Drop(handsComp.ActiveHand, coords.WithPosition(entCoords + entToDesiredDropCoords.Normalized * rayLength));

View File

@@ -35,7 +35,6 @@ namespace Content.Server.GameObjects.EntitySystems
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private AudioSystem _audioSystem = default!;
@@ -94,7 +93,7 @@ namespace Content.Server.GameObjects.EntitySystems
if (_mapManager.GridExists(mover.LastPosition.GetGridId(EntityManager)))
{
// Can happen when teleporting between grids.
if (!transform.Coordinates.TryDistance(_entityManager, mover.LastPosition, out var distance))
if (!transform.Coordinates.TryDistance(EntityManager, mover.LastPosition, out var distance))
{
mover.LastPosition = transform.Coordinates;
return;

View File

@@ -17,7 +17,6 @@ namespace Content.Server.GameObjects.EntitySystems
{
public class VerbSystem : SharedVerbSystem, IResettingEntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly HashSet<IPlayerSession> _seesThroughContainers = new HashSet<IPlayerSession>();
@@ -76,7 +75,7 @@ namespace Content.Server.GameObjects.EntitySystems
private void UseVerb(UseVerbMessage use, EntitySessionEventArgs eventArgs)
{
if (!_entityManager.TryGetEntity(use.EntityUid, out var entity))
if (!EntityManager.TryGetEntity(use.EntityUid, out var entity))
{
return;
}
@@ -127,7 +126,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
var player = (IPlayerSession) eventArgs.SenderSession;
if (!_entityManager.TryGetEntity(req.EntityUid, out var entity))
if (!EntityManager.TryGetEntity(req.EntityUid, out var entity))
{
Logger.Warning($"{nameof(RequestVerbs)} called on a nonexistant entity with id {req.EntityUid} by player {player}.");
return;

View File

@@ -16,7 +16,6 @@ namespace Content.Shared.GameObjects.Components.Movement
{
public abstract class SharedSlipperyComponent : Component, ICollideBehavior
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public sealed override string Name => "Slippery";
@@ -110,13 +109,13 @@ namespace Content.Shared.GameObjects.Components.Movement
{
foreach (var uid in _slipped.ToArray())
{
if (!uid.IsValid() || !_entityManager.EntityExists(uid))
if (!uid.IsValid() || !Owner.EntityManager.EntityExists(uid))
{
_slipped.Remove(uid);
continue;
}
var entity = _entityManager.GetEntity(uid);
var entity = Owner.EntityManager.GetEntity(uid);
var physics = Owner.GetComponent<IPhysicsComponent>();
var otherPhysics = entity.GetComponent<IPhysicsComponent>();