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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user