Random IoCManager.Resolve<IEntityManager> removals moment
This commit is contained in:
@@ -40,19 +40,19 @@ namespace Content.Client.AI
|
|||||||
var deletedEntities = new List<EntityUid>(0);
|
var deletedEntities = new List<EntityUid>(0);
|
||||||
foreach (var (entity, panel) in _aiBoxes)
|
foreach (var (entity, panel) in _aiBoxes)
|
||||||
{
|
{
|
||||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||||
{
|
{
|
||||||
deletedEntities.Add(entity);
|
deletedEntities.Add(entity);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_eyeManager.GetWorldViewport().Contains(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition))
|
if (!_eyeManager.GetWorldViewport().Contains(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition))
|
||||||
{
|
{
|
||||||
panel.Visible = false;
|
panel.Visible = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var (x, y) = _eyeManager.CoordinatesToScreen(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates).Position;
|
var (x, y) = _eyeManager.CoordinatesToScreen(EntityManager.GetComponent<TransformComponent>(entity).Coordinates).Position;
|
||||||
var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f);
|
var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f);
|
||||||
panel.Visible = true;
|
panel.Visible = true;
|
||||||
|
|
||||||
|
|||||||
@@ -173,14 +173,14 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
|||||||
public bool CanAccess(EntityUid entity, EntityUid target, float range = 0.0f)
|
public bool CanAccess(EntityUid entity, EntityUid target, float range = 0.0f)
|
||||||
{
|
{
|
||||||
// TODO: Handle this gracefully instead of just failing.
|
// TODO: Handle this gracefully instead of just failing.
|
||||||
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target).GridID.IsValid())
|
if (!EntityManager.GetComponent<TransformComponent>(target).GridID.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var targetTile = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target).GridID).GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target).Coordinates);
|
var targetTile = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(target).GridID).GetTileRef(EntityManager.GetComponent<TransformComponent>(target).Coordinates);
|
||||||
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||||
|
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IPhysBody? physics))
|
if (EntityManager.TryGetComponent(entity, out IPhysBody? physics))
|
||||||
{
|
{
|
||||||
collisionMask = physics.CollisionMask;
|
collisionMask = physics.CollisionMask;
|
||||||
}
|
}
|
||||||
@@ -209,12 +209,12 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
|||||||
|
|
||||||
public bool CanAccess(EntityUid entity, PathfindingNode targetNode)
|
public bool CanAccess(EntityUid entity, PathfindingNode targetNode)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).GridID != targetNode.TileRef.GridIndex)
|
if (EntityManager.GetComponent<TransformComponent>(entity).GridID != targetNode.TileRef.GridIndex)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entityTile = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).GridID).GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates);
|
var entityTile = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridID).GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates);
|
||||||
var entityNode = _pathfindingSystem.GetNode(entityTile);
|
var entityNode = _pathfindingSystem.GetNode(entityTile);
|
||||||
var entityRegion = GetRegion(entityNode);
|
var entityRegion = GetRegion(entityNode);
|
||||||
var targetRegion = GetRegion(targetNode);
|
var targetRegion = GetRegion(targetNode);
|
||||||
|
|||||||
@@ -27,15 +27,17 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args)
|
private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args)
|
||||||
{
|
{
|
||||||
|
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||||
|
|
||||||
if (airtight.FixAirBlockedDirectionInitialize)
|
if (airtight.FixAirBlockedDirectionInitialize)
|
||||||
{
|
{
|
||||||
var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).WorldRotation);
|
var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, xform.WorldRotation);
|
||||||
OnAirtightRotated(uid, airtight, ref rotateEvent);
|
OnAirtightRotated(uid, airtight, ref rotateEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding this component will immediately anchor the entity, because the atmos system
|
// Adding this component will immediately anchor the entity, because the atmos system
|
||||||
// requires airtight entities to be anchored for performance.
|
// requires airtight entities to be anchored for performance.
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).Anchored = true;
|
xform.Anchored = true;
|
||||||
|
|
||||||
UpdatePosition(airtight);
|
UpdatePosition(airtight);
|
||||||
}
|
}
|
||||||
@@ -54,8 +56,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
|
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
|
||||||
{
|
{
|
||||||
var gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).GridID;
|
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||||
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).Coordinates;
|
|
||||||
|
var gridId = xform.GridID;
|
||||||
|
var coords = xform.Coordinates;
|
||||||
|
|
||||||
var grid = _mapManager.GetGrid(gridId);
|
var grid = _mapManager.GetGrid(gridId);
|
||||||
var tilePos = grid.TileIndicesFor(coords);
|
var tilePos = grid.TileIndicesFor(coords);
|
||||||
@@ -84,11 +88,13 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
public void UpdatePosition(AirtightComponent airtight)
|
public void UpdatePosition(AirtightComponent airtight)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).Anchored || !IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).GridID.IsValid())
|
var xform = EntityManager.GetComponent<TransformComponent>(airtight.Owner);
|
||||||
|
|
||||||
|
if (!xform.Anchored || !xform.GridID.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).GridID);
|
var grid = _mapManager.GetGrid(xform.GridID);
|
||||||
airtight.LastPosition = (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).GridID, grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner).Coordinates));
|
airtight.LastPosition = (xform.GridID, grid.TileIndicesFor(xform.Coordinates));
|
||||||
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
|
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1315,7 +1315,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
public bool AddAtmosDevice(AtmosDeviceComponent atmosDevice)
|
public bool AddAtmosDevice(AtmosDeviceComponent atmosDevice)
|
||||||
{
|
{
|
||||||
var grid = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(atmosDevice.Owner).GridID;
|
var grid = EntityManager.GetComponent<TransformComponent>(atmosDevice.Owner).GridID;
|
||||||
|
|
||||||
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
|
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
|
||||||
return false;
|
return false;
|
||||||
@@ -1526,7 +1526,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
public bool TryGetMapGrid(GridAtmosphereComponent gridAtmosphere, [NotNullWhen(true)] out IMapGrid? mapGrid)
|
public bool TryGetMapGrid(GridAtmosphereComponent gridAtmosphere, [NotNullWhen(true)] out IMapGrid? mapGrid)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(gridAtmosphere.Owner, out IMapGridComponent? mapGridComponent))
|
if (EntityManager.TryGetComponent(gridAtmosphere.Owner, out IMapGridComponent? mapGridComponent))
|
||||||
{
|
{
|
||||||
mapGrid = mapGridComponent.Grid;
|
mapGrid = mapGridComponent.Grid;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ public class LungSystem : EntitySystem
|
|||||||
EntityManager.TryGetComponent((mech.Body).Owner, out InternalsComponent? internals) &&
|
EntityManager.TryGetComponent((mech.Body).Owner, out InternalsComponent? internals) &&
|
||||||
internals.BreathToolEntity != null &&
|
internals.BreathToolEntity != null &&
|
||||||
internals.GasTankEntity != null &&
|
internals.GasTankEntity != null &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(internals.BreathToolEntity, out BreathToolComponent? breathTool) &&
|
EntityManager.TryGetComponent(internals.BreathToolEntity, out BreathToolComponent? breathTool) &&
|
||||||
breathTool.IsFunctional &&
|
breathTool.IsFunctional &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(internals.GasTankEntity, out GasTankComponent? gasTank))
|
EntityManager.TryGetComponent(internals.GasTankEntity, out GasTankComponent? gasTank))
|
||||||
{
|
{
|
||||||
TakeGasFrom(uid, frameTime, gasTank.RemoveAirVolume(Atmospherics.BreathVolume), lung);
|
TakeGasFrom(uid, frameTime, gasTank.RemoveAirVolume(Atmospherics.BreathVolume), lung);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user