Replace IEntityManager resolves in systems for cached EntityManager

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 13:00:43 +01:00
parent 2699540526
commit c8b65be747
98 changed files with 338 additions and 338 deletions

View File

@@ -33,7 +33,7 @@ namespace Content.Server.Atmos.EntitySystems
foreach (var entity in _gridtileLookupSystem.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IPhysBody? physics)
if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics)
|| !entity.IsMovedByPressure(out var pressure)
|| entity.IsInContainer())
continue;

View File

@@ -75,9 +75,9 @@ namespace Content.Server.Atmos.EntitySystems
{
foreach (var exposed in EntityManager.EntityQuery<AtmosExposedComponent>())
{
var tile = GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(exposed.Owner).Coordinates);
var tile = GetTileMixture(EntityManager.GetComponent<TransformComponent>(exposed.Owner).Coordinates);
if (tile == null) continue;
var updateEvent = new AtmosExposedUpdateEvent(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(exposed.Owner).Coordinates, tile);
var updateEvent = new AtmosExposedUpdateEvent(EntityManager.GetComponent<TransformComponent>(exposed.Owner).Coordinates, tile);
RaiseLocalEvent(exposed.Owner, ref updateEvent);
}

View File

@@ -86,7 +86,7 @@ namespace Content.Server.Atmos.EntitySystems
var uid = barotrauma.Owner;
var status = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ServerAlertsComponent>(barotrauma.Owner);
var status = EntityManager.GetComponentOrNull<ServerAlertsComponent>(barotrauma.Owner);
var pressure = 1f;

View File

@@ -224,7 +224,7 @@ namespace Content.Server.Atmos.EntitySystems
flammable.FireStacks = MathF.Min(0, flammable.FireStacks + 1);
}
IoCManager.Resolve<IEntityManager>().TryGetComponent(flammable.Owner, out ServerAlertsComponent? status);
EntityManager.TryGetComponent(flammable.Owner, out ServerAlertsComponent? status);
if (!flammable.OnFire)
{

View File

@@ -24,7 +24,7 @@ namespace Content.Server.Atmos.EntitySystems
private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetActivationVerbsEvent args)
{
if (!args.CanAccess || !IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(args.User, out var actor))
if (!args.CanAccess || !EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
return;
Verb verb = new();

View File

@@ -196,17 +196,17 @@ namespace Content.Server.Atmos.EntitySystems
// This is the max in any direction that we can get a chunk (e.g. max 2 chunks away of data).
var (maxXDiff, maxYDiff) = ((int) (_updateRange / ChunkSize) + 1, (int) (_updateRange / ChunkSize) + 1);
var worldBounds = Box2.CenteredAround(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition,
var worldBounds = Box2.CenteredAround(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition,
new Vector2(_updateRange, _updateRange));
foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID, worldBounds))
foreach (var grid in _mapManager.FindGridsIntersecting(EntityManager.GetComponent<TransformComponent>(entity).MapID, worldBounds))
{
if (!_overlay.TryGetValue(grid.Index, out var chunks))
{
continue;
}
var entityTile = grid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates).GridIndices;
var entityTile = grid.GetTileRef(EntityManager.GetComponent<TransformComponent>(entity).Coordinates).GridIndices;
for (var x = -maxXDiff; x <= maxXDiff; x++)
{

View File

@@ -28,7 +28,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnGasDualPortVentPumpUpdated(EntityUid uid, GasDualPortVentPumpComponent vent, AtmosDeviceUpdateEvent args)
{
var appearance = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AppearanceComponent>(vent.Owner);
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(vent.Owner);
if (vent.Welded)
{
@@ -45,7 +45,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
return;
}
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(vent.Owner).Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(vent.Owner).Coordinates, true);
// We're in an air-blocked tile... Do nothing.
if (environment == null)

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!EntityManager.GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-pressure-pump-system-examined", out var str,
@@ -50,7 +50,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnPumpUpdated(EntityUid uid, GasPressurePumpComponent pump, AtmosDeviceUpdateEvent args)
{
var appearance = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AppearanceComponent>(pump.Owner);
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(pump.Owner);
if (!pump.Enabled
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
@@ -92,10 +92,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnPumpInteractHand(EntityUid uid, GasPressurePumpComponent component, InteractHandEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored)
if (EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);
@@ -127,7 +127,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
return;
_userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key,
new GasPressurePumpBoundUserInterfaceState(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled));
new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled));
}
}
}

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!EntityManager.GetComponent<TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-valve-system-examined", out var str,

View File

@@ -39,7 +39,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasVolumePumpComponent pump, ExaminedEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!EntityManager.GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-volume-pump-system-examined", out var str,
@@ -83,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
// Some of the gas from the mixture leaks when overclocked.
if (pump.Overclocked)
{
var tile = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner).Coordinates, true);
var tile = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(pump.Owner).Coordinates, true);
if (tile != null)
{
@@ -97,10 +97,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnPumpInteractHand(EntityUid uid, GasVolumePumpComponent component, InteractHandEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored)
if (EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);
@@ -132,7 +132,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
return;
_userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key,
new GasVolumePumpBoundUserInterfaceState(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pump.Owner).EntityName, pump.TransferRate, pump.Enabled));
new GasVolumePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(pump.Owner).EntityName, pump.TransferRate, pump.Enabled));
}
}
}

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
private bool CanJoinAtmosphere(AtmosDeviceComponent component)
{
return !component.RequireAnchored || IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored;
return !component.RequireAnchored || EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored;
}
public void JoinAtmosphere(AtmosDeviceComponent component)
@@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.RequireAnchored)
return;
if(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored)
if(EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
JoinAtmosphere(component);
else
LeaveAtmosphere(component);

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Coordinates) is not {} environment)
if (_atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates) is not {} environment)
return;
foreach (var node in nodes.Nodes.Values)
@@ -52,7 +52,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Coordinates, true) is not {} environment)
if (_atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates, true) is not {} environment)
environment = GasMixture.SpaceGas;
var lost = 0f;

View File

@@ -37,10 +37,10 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
private bool CheckMinerOperation(GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
{
environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(miner.Owner).Coordinates, true);
environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(miner.Owner).Coordinates, true);
// Space.
if (_atmosphereSystem.IsTileSpace(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(miner.Owner).Coordinates))
if (_atmosphereSystem.IsTileSpace(EntityManager.GetComponent<TransformComponent>(miner.Owner).Coordinates))
{
miner.Broken = true;
return false;

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args)
{
var appearance = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AppearanceComponent>(filter.Owner);
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(filter.Owner);
if (!filter.Enabled
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
@@ -81,10 +81,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
private void OnFilterInteractHand(EntityUid uid, GasFilterComponent component, InteractHandEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored)
if (EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);
@@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
return;
_userInterfaceSystem.TrySetUiState(uid, GasFilterUiKey.Key,
new GasFilterBoundUserInterfaceState(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(filter.Owner).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas));
new GasFilterBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(filter.Owner).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas));
}
private void OnToggleStatusMessage(EntityUid uid, GasFilterComponent filter, GasFilterToggleStatusMessage args)

View File

@@ -106,10 +106,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
private void OnMixerInteractHand(EntityUid uid, GasMixerComponent component, InteractHandEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Anchored)
if (EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);
@@ -128,7 +128,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
return;
_userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key,
new GasMixerBoundUserInterfaceState(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
}
private void OnToggleStatusMessage(EntityUid uid, GasMixerComponent mixer, GasMixerToggleStatusMessage args)

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
return;
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(injector.Owner).Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(injector.Owner).Coordinates, true);
if (environment == null)
return;

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, AtmosDeviceUpdateEvent args)
{
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(vent.Owner).Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(vent.Owner).Coordinates, true);
if (environment == null)
return;

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args)
{
var appearance = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AppearanceComponent>(thermoMachine.Owner);
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(thermoMachine.Owner);
if (!thermoMachine.Enabled
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)

View File

@@ -28,7 +28,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
{
var appearance = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<AppearanceComponent>(scrubber.Owner);
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(scrubber.Owner);
if (scrubber.Welded)
{
@@ -44,14 +44,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return;
}
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(scrubber.Owner).Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, true);
Scrub(_atmosphereSystem, scrubber, appearance, environment, outlet);
if (!scrubber.WideNet) return;
// Scrub adjacent tiles too.
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(scrubber.Owner).Coordinates, false, true))
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, false, true))
{
Scrub(_atmosphereSystem, scrubber, null, adjacent, outlet);
}