Use EntitySystem dependencies in a bunch of systems.

This commit is contained in:
Vera Aguilera Puerto
2021-07-26 12:58:17 +02:00
parent 4e93340fb0
commit 1033d8bbe5
31 changed files with 130 additions and 130 deletions

View File

@@ -19,6 +19,7 @@ namespace Content.Client.Atmos.EntitySystems
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
// Gas overlays
private readonly float[] _timer = new float[Atmospherics.TotalNumberOfGases];
@@ -38,16 +39,12 @@ namespace Content.Client.Atmos.EntitySystems
private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _tileData =
new();
private AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<GasOverlayMessage>(HandleGasOverlayMessage);
_mapManager.OnGridRemoved += OnGridRemoved;
_atmosphereSystem = Get<AtmosphereSystem>();
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
var overlay = _atmosphereSystem.GetOverlay(i);

View File

@@ -25,6 +25,7 @@ namespace Content.Client.Audio
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly ClientGameTicker _gameTicker = default!;
private SoundCollectionPrototype _ambientCollection = default!;
@@ -48,7 +49,7 @@ namespace Content.Client.Audio
_client.PlayerJoinedServer += OnJoin;
_client.PlayerLeaveServer += OnLeave;
Get<ClientGameTicker>().LobbyStatusUpdated += LobbySongReceived;
_gameTicker.LobbyStatusUpdated += LobbySongReceived;
}
public override void Shutdown()
@@ -60,7 +61,7 @@ namespace Content.Client.Audio
_client.PlayerJoinedServer -= OnJoin;
_client.PlayerLeaveServer -= OnLeave;
Get<ClientGameTicker>().LobbyStatusUpdated -= LobbySongReceived;
_gameTicker.LobbyStatusUpdated -= LobbySongReceived;
EndAmbience();
EndLobbyMusic();
@@ -165,7 +166,7 @@ namespace Content.Client.Audio
private void StartLobbyMusic()
{
EndLobbyMusic();
var file = Get<ClientGameTicker>().LobbySong;
var file = _gameTicker.LobbySong;
if (file == null) // We have not received the lobby song yet.
{
return;

View File

@@ -36,6 +36,8 @@ namespace Content.Client.DragDrop
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
// how often to recheck possible targets (prevents calling expensive
// check logic each update)
@@ -69,8 +71,6 @@ namespace Content.Client.DragDrop
private ShaderInstance? _dropTargetInRangeShader;
private ShaderInstance? _dropTargetOutOfRangeShader;
private SharedInteractionSystem _interactionSystem = default!;
private InputSystem _inputSystem = default!;
private readonly List<ISpriteComponent> _highlightedSprites = new();
@@ -80,8 +80,6 @@ namespace Content.Client.DragDrop
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
_interactionSystem = Get<SharedInteractionSystem>();
_inputSystem = Get<InputSystem>();
// needs to fire on mouseup and mousedown so we can detect a drag / drop
CommandBinds.Builder
.Bind(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false))

View File

@@ -18,6 +18,7 @@ namespace Content.Client.Weapons.Melee
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly EffectSystem _effectSystem = default!;
public override void Initialize()
{
@@ -67,7 +68,6 @@ namespace Content.Client.Weapons.Melee
source.TryGetComponent(out ISpriteComponent? sourceSprite) &&
sourceSprite.BaseRSI?.Path != null)
{
var sys = Get<EffectSystem>();
var curTime = _gameTiming.CurTime;
var effect = new EffectSystemMessage
{
@@ -81,7 +81,8 @@ namespace Content.Client.Weapons.Melee
Born = curTime,
DeathTime = curTime.Add(TimeSpan.FromMilliseconds(300f)),
};
sys.CreateEffect(effect);
_effectSystem.CreateEffect(effect);
}
}

View File

@@ -24,21 +24,12 @@ namespace Content.Client.Weapons.Ranged
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly CombatModeSystem _combatModeSystem = default!;
private InputSystem _inputSystem = default!;
private CombatModeSystem _combatModeSystem = default!;
private bool _blocked;
private int _shotCounter;
public override void Initialize()
{
base.Initialize();
IoCManager.InjectDependencies(this);
_inputSystem = Get<InputSystem>();
_combatModeSystem = Get<CombatModeSystem>();
}
public override void Update(float frameTime)
{
base.Update(frameTime);

View File

@@ -37,8 +37,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
*/
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private PathfindingSystem _pathfindingSystem = default!;
[Dependency] private readonly PathfindingSystem _pathfindingSystem = default!;
/// <summary>
/// Queued region updates
@@ -80,7 +79,6 @@ namespace Content.Server.AI.Pathfinding.Accessible
public override void Initialize()
{
_pathfindingSystem = Get<PathfindingSystem>();
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<PathfindingChunkUpdateMessage>(RecalculateNodeRegions);
#if DEBUG

View File

@@ -27,8 +27,7 @@ namespace Content.Server.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!;
private PathfindingSystem _pathfindingSystem = default!;
[Dependency] private readonly PathfindingSystem _pathfindingSystem = default!;
/// <summary>
/// Whether we try to avoid non-blocking physics objects
@@ -87,7 +86,6 @@ namespace Content.Server.AI.Steering
public override void Initialize()
{
base.Initialize();
_pathfindingSystem = Get<PathfindingSystem>();
for (var i = 0; i < AgentListCount; i++)
{

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Atmos.EntitySystems
public class AirtightSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
@@ -42,7 +43,7 @@ namespace Content.Server.Atmos.EntitySystems
if (airtight.FixVacuum)
{
Get<AtmosphereSystem>().FixVacuum(airtight.LastPosition.Item1, airtight.LastPosition.Item2);
_atmosphereSystem.FixVacuum(airtight.LastPosition.Item1, airtight.LastPosition.Item2);
}
}
@@ -93,9 +94,8 @@ namespace Content.Server.Atmos.EntitySystems
if (!gridId.IsValid())
return;
var atmosphereSystem = Get<AtmosphereSystem>();
atmosphereSystem.UpdateAdjacent(gridId, pos);
atmosphereSystem.InvalidateTile(gridId, pos);
_atmosphereSystem.UpdateAdjacent(gridId, pos);
_atmosphereSystem.InvalidateTile(gridId, pos);
}
private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle)

View File

@@ -21,6 +21,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
/// <summary>
/// Players allowed to see the atmos debug overlay.
@@ -127,7 +128,6 @@ namespace Content.Server.Atmos.EntitySystems
AccumulatedFrameTime -= _updateCooldown;
var currentTick = _gameTiming.CurTick;
var atmosphereSystem = Get<AtmosphereSystem>();
// Now we'll go through each player, then through each chunk in range of that player checking if the player is still in range
// If they are, check if they need the new data to send (i.e. if there's an overlay for the gas).
@@ -157,7 +157,7 @@ namespace Content.Server.Atmos.EntitySystems
for (var x = 0; x < LocalViewRange; x++)
{
var Vector2i = new Vector2i(baseTile.X + x, baseTile.Y + y);
debugOverlayContent[index++] = ConvertTileToData(atmosphereSystem.GetTileAtmosphereOrCreateSpace(grid, gam, Vector2i));
debugOverlayContent[index++] = ConvertTileToData(_atmosphereSystem.GetTileAtmosphereOrCreateSpace(grid, gam, Vector2i));
}
}

View File

@@ -23,13 +23,10 @@ namespace Content.Server.Atmos.EntitySystems
public partial class AtmosphereSystem
{
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
private GasTileOverlaySystem _gasTileOverlaySystem = default!;
[Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
private void InitializeGrid()
{
_gasTileOverlaySystem = Get<GasTileOverlaySystem>();
SubscribeLocalEvent<GridAtmosphereComponent, ComponentInit>(OnGridAtmosphereInit);
}

View File

@@ -1,12 +1,15 @@
using Content.Server.Atmos.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.EntitySystems
{
[UsedImplicitly]
public class GasTankSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
private const float TimerDelay = 0.5f;
private float _timer = 0f;
@@ -19,11 +22,9 @@ namespace Content.Server.Atmos.EntitySystems
if (_timer < TimerDelay) return;
_timer -= TimerDelay;
var atmosphereSystem = Get<AtmosphereSystem>();
foreach (var gasTank in EntityManager.ComponentManager.EntityQuery<GasTankComponent>())
{
atmosphereSystem.React(gasTank.Air, gasTank);
_atmosphereSystem.React(gasTank.Air, gasTank);
gasTank.CheckStatus();
gasTank.UpdateUserInterface();
}

View File

@@ -29,6 +29,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
/// <summary>
/// The tiles that have had their atmos data updated since last tick
@@ -58,8 +59,6 @@ namespace Content.Server.Atmos.EntitySystems
/// </summary>
private float _updateCooldown;
private AtmosphereSystem _atmosphereSystem = default!;
private int _thresholds;
public override void Initialize()
@@ -68,7 +67,6 @@ namespace Content.Server.Atmos.EntitySystems
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
_atmosphereSystem = Get<AtmosphereSystem>();
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_mapManager.OnGridRemoved += OnGridRemoved;
var configManager = IoCManager.Resolve<IConfigurationManager>();

View File

@@ -10,12 +10,15 @@ using Content.Shared.Atmos.Visuals;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
[UsedImplicitly]
public class GasDualPortVentPumpSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -46,8 +49,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|| !nodeContainer.TryGetNode(vent.OutletName, out PipeNode? outlet))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
// We're in an air-blocked tile... Do nothing.
if (environment == null)
@@ -68,7 +70,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
var transferMoles = pressureDelta * environment.Volume / inlet.Air.Temperature * Atmospherics.R;
var removed = inlet.Air.Remove(transferMoles);
atmosphereSystem.Merge(environment, removed);
_atmosphereSystem.Merge(environment, removed);
}
}
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0f)
@@ -89,7 +91,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
var removed = environment.Remove(molesDelta);
Get<AtmosphereSystem>().Merge(outlet.Air, removed);
_atmosphereSystem.Merge(outlet.Air, removed);
}
}
}

View File

@@ -13,7 +13,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
[UsedImplicitly]
public class GasVolumePumpSystem : EntitySystem
{
[Dependency] private IGameTiming _gameTiming = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
@@ -56,13 +57,12 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
// Some of the gas from the mixture leaks when overclocked.
if (pump.Overclocked)
{
var atmosphereSystem = Get<AtmosphereSystem>();
var tile = atmosphereSystem.GetTileMixture(pump.Owner.Transform.Coordinates, true);
var tile = _atmosphereSystem.GetTileMixture(pump.Owner.Transform.Coordinates, true);
if (tile != null)
{
var leaked = removed.RemoveRatio(pump.LeakRatio);
atmosphereSystem.Merge(tile, leaked);
_atmosphereSystem.Merge(tile, leaked);
}
}

View File

@@ -13,6 +13,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
public class AtmosDeviceSystem : EntitySystem
{
[Dependency] private IGameTiming _gameTiming = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
@@ -35,7 +36,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
return;
// We try to add the device to a valid atmosphere.
if (!Get<AtmosphereSystem>().AddAtmosDevice(component))
if (!_atmosphereSystem.AddAtmosDevice(component))
return;
component.LastProcess = _gameTiming.CurTime;
@@ -45,7 +46,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
public void LeaveAtmosphere(AtmosDeviceComponent component)
{
if (!Get<AtmosphereSystem>().RemoveAtmosDevice(component))
if (!_atmosphereSystem.RemoveAtmosDevice(component))
return;
component.LastProcess = TimeSpan.Zero;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Atmos;
using Content.Shared.Notification.Managers;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Atmos.Piping.EntitySystems
@@ -15,6 +16,8 @@ namespace Content.Server.Atmos.Piping.EntitySystems
[UsedImplicitly]
public class AtmosUnsafeUnanchorSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<AtmosUnsafeUnanchorComponent, BeforeUnanchoredEvent>(OnBeforeUnanchored);
@@ -26,7 +29,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (Get<AtmosphereSystem>().GetTileMixture(component.Owner.Transform.Coordinates) is not {} environment)
if (_atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates) is not {} environment)
return;
foreach (var node in nodes.Nodes.Values)
@@ -47,9 +50,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
if (atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates, true) is not {} environment)
if (_atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates, true) is not {} environment)
environment = GasMixture.SpaceGas;
var lost = 0f;
@@ -71,10 +72,10 @@ namespace Content.Server.Atmos.Piping.EntitySystems
{
if (node is not PipeNode pipe) continue;
atmosphereSystem.Merge(buffer, pipe.Air.Remove(sharedLoss));
_atmosphereSystem.Merge(buffer, pipe.Air.Remove(sharedLoss));
}
atmosphereSystem.Merge(environment, buffer);
_atmosphereSystem.Merge(environment, buffer);
}
}
}

View File

@@ -6,12 +6,15 @@ using Content.Server.Atmos.Piping.Other.Components;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Other.EntitySystems
{
[UsedImplicitly]
public class GasMinerSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -21,9 +24,7 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
private void OnMinerUpdated(EntityUid uid, GasMinerComponent miner, AtmosDeviceUpdateEvent args)
{
var atmosphereSystem = Get<AtmosphereSystem>();
if (!CheckMinerOperation(atmosphereSystem, miner, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
if (!CheckMinerOperation(miner, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
return;
// Time to mine some gas.
@@ -31,15 +32,15 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
var merger = new GasMixture(1) { Temperature = miner.SpawnTemperature };
merger.SetMoles(miner.SpawnGas.Value, miner.SpawnAmount);
atmosphereSystem.Merge(environment, merger);
_atmosphereSystem.Merge(environment, merger);
}
private bool CheckMinerOperation(AtmosphereSystem atmosphereSystem, GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
private bool CheckMinerOperation(GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
{
environment = atmosphereSystem.GetTileMixture(miner.Owner.Transform.Coordinates, true);
environment = _atmosphereSystem.GetTileMixture(miner.Owner.Transform.Coordinates, true);
// Space.
if (atmosphereSystem.IsTileSpace(miner.Owner.Transform.Coordinates))
if (_atmosphereSystem.IsTileSpace(miner.Owner.Transform.Coordinates))
{
miner.Broken = true;
return false;

View File

@@ -19,6 +19,7 @@ using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
@@ -26,6 +27,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[UsedImplicitly]
public class GasCanisterSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -131,23 +134,21 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(canister.PortName, out PortablePipeNode? portNode))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
atmosphereSystem.React(canister.Air, portNode);
_atmosphereSystem.React(canister.Air, portNode);
if (portNode.NodeGroup is PipeNet {NodeCount: > 1} net)
{
var buffer = new GasMixture(net.Air.Volume + canister.Air.Volume);
atmosphereSystem.Merge(buffer, net.Air);
atmosphereSystem.Merge(buffer, canister.Air);
_atmosphereSystem.Merge(buffer, net.Air);
_atmosphereSystem.Merge(buffer, canister.Air);
net.Air.Clear();
atmosphereSystem.Merge(net.Air, buffer);
_atmosphereSystem.Merge(net.Air, buffer);
net.Air.Multiply(net.Air.Volume / buffer.Volume);
canister.Air.Clear();
atmosphereSystem.Merge(canister.Air, buffer);
_atmosphereSystem.Merge(canister.Air, buffer);
canister.Air.Multiply(canister.Air.Volume / buffer.Volume);
}
@@ -161,12 +162,12 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (container.ContainedEntities.Count > 0)
{
var gasTank = container.ContainedEntities[0].GetComponent<GasTankComponent>();
atmosphereSystem.ReleaseGasTo(canister.Air, gasTank.Air, canister.ReleasePressure);
_atmosphereSystem.ReleaseGasTo(canister.Air, gasTank.Air, canister.ReleasePressure);
}
else
{
var environment = atmosphereSystem.GetTileMixture(canister.Owner.Transform.Coordinates, true);
atmosphereSystem.ReleaseGasTo(canister.Air, environment, canister.ReleasePressure);
var environment = _atmosphereSystem.GetTileMixture(canister.Owner.Transform.Coordinates, true);
_atmosphereSystem.ReleaseGasTo(canister.Air, environment, canister.ReleasePressure);
}
}

View File

@@ -6,12 +6,15 @@ using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public class GasOutletInjectorSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -32,8 +35,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(injector.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(injector.Owner.Transform.Coordinates, true);
if (environment == null)
return;
@@ -44,7 +46,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
var removed = inlet.Air.Remove(transferMoles);
atmosphereSystem.Merge(environment, removed);
_atmosphereSystem.Merge(environment, removed);
}
}
}

View File

@@ -7,12 +7,15 @@ using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public class GasPassiveVentSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -22,8 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, AtmosDeviceUpdateEvent args)
{
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
if (environment == null)
return;
@@ -44,7 +46,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
var airTemperature = environment.Temperature > 0 ? environment.Temperature : inlet.Air.Temperature;
var transferMoles = pressureDelta * environment.Volume / (airTemperature * Atmospherics.R);
var removed = inlet.Air.Remove(transferMoles);
atmosphereSystem.Merge(environment, removed);
_atmosphereSystem.Merge(environment, removed);
}
else
{

View File

@@ -7,12 +7,15 @@ using Content.Shared.Atmos.Piping;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public class GasThermoMachineSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -35,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(thermoMachine.InletName, out PipeNode? inlet))
return;
var airHeatCapacity = Get<AtmosphereSystem>().GetHeatCapacity(inlet.Air);
var airHeatCapacity = _atmosphereSystem.GetHeatCapacity(inlet.Air);
var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity;
var oldTemperature = inlet.Air.Temperature;

View File

@@ -9,12 +9,15 @@ using Content.Shared.Atmos.Visuals;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public class GasVentPumpSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -44,8 +47,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(vent.InletName, out PipeNode? pipe))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
// We're in an air-blocked tile... Do nothing.
if (environment == null)
@@ -66,7 +68,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
var transferMoles = pressureDelta * environment.Volume / (pipe.Air.Temperature * Atmospherics.R);
atmosphereSystem.Merge(environment, pipe.Air.Remove(transferMoles));
_atmosphereSystem.Merge(environment, pipe.Air.Remove(transferMoles));
}
}
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0)

View File

@@ -9,6 +9,7 @@ using Content.Shared.Atmos.Piping.Unary.Visuals;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
@@ -16,6 +17,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[UsedImplicitly]
public class GasVentScrubberSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -45,17 +48,16 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
return;
var atmosphereSystem = Get<AtmosphereSystem>();
var environment = atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
Scrub(atmosphereSystem, scrubber, appearance, environment, outlet);
Scrub(_atmosphereSystem, scrubber, appearance, environment, outlet);
if (!scrubber.WideNet) return;
// Scrub adjacent tiles too.
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(scrubber.Owner.Transform.Coordinates, false, true))
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(scrubber.Owner.Transform.Coordinates, false, true))
{
Scrub(atmosphereSystem, scrubber, null, adjacent, outlet);
Scrub(_atmosphereSystem, scrubber, null, adjacent, outlet);
}
}

View File

@@ -6,12 +6,15 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Body.Surgery.Components
{
[UsedImplicitly]
public class SurgeryToolSystem : EntitySystem
{
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
private readonly HashSet<SurgeryToolComponent> _openSurgeryUIs = new();
public override void Initialize()
@@ -54,7 +57,7 @@ namespace Content.Server.Body.Surgery.Components
continue;
}
if (!Get<ActionBlockerSystem>().CanInteract(tool.PerformerCache) ||
if (!_actionBlockerSystem.CanInteract(tool.PerformerCache) ||
!tool.PerformerCache.InRangeUnobstructed(tool.BodyCache))
{
tool.CloseAllSurgeryUIs();

View File

@@ -39,6 +39,8 @@ namespace Content.Server.Construction
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
private readonly Dictionary<ICommonSession, HashSet<int>> _beingBuilt = new();
@@ -170,7 +172,7 @@ namespace Content.Server.Construction
if (!materialStep.EntityValid(entity, out var stack))
continue;
var splitStack = Get<StackSystem>().Split(entity.Uid, stack, materialStep.Amount, user.ToCoordinates());
var splitStack = _stackSystem.Split(entity.Uid, stack, materialStep.Amount, user.ToCoordinates());
if (splitStack == null)
continue;
@@ -226,8 +228,6 @@ namespace Content.Server.Construction
return null;
}
var doAfterSystem = Get<DoAfterSystem>();
var doAfterArgs = new DoAfterEventArgs(user, doAfterTime)
{
BreakOnDamage = true,
@@ -237,7 +237,7 @@ namespace Content.Server.Construction
NeedHand = false,
};
if (await doAfterSystem.WaitDoAfter(doAfterArgs) == DoAfterStatus.Cancelled)
if (await _doAfterSystem.WaitDoAfter(doAfterArgs) == DoAfterStatus.Cancelled)
{
FailCleanup();
return null;

View File

@@ -11,17 +11,7 @@ namespace Content.Server.Destructible
public class DestructibleSystem : EntitySystem
{
[Dependency] public readonly IRobustRandom Random = default!;
public AudioSystem AudioSystem { get; private set; } = default!;
public ActSystem ActSystem { get; private set; } = default!;
public override void Initialize()
{
base.Initialize();
AudioSystem = Get<AudioSystem>();
ActSystem = Get<ActSystem>();
}
[Dependency] public readonly AudioSystem AudioSystem = default!;
[Dependency] public readonly ActSystem ActSystem = default!;
}
}

View File

@@ -16,6 +16,8 @@ namespace Content.Server.Engineering.EntitySystems
public class SpawnAfterInteractSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
public override void Initialize()
{
@@ -41,7 +43,7 @@ namespace Content.Server.Engineering.EntitySystems
if (!IsTileClear())
return;
if (component.DoAfterTime > 0 && TryGet<DoAfterSystem>(out var doAfterSystem))
if (component.DoAfterTime > 0)
{
var doAfterArgs = new DoAfterEventArgs(args.User, component.DoAfterTime)
{
@@ -49,7 +51,7 @@ namespace Content.Server.Engineering.EntitySystems
BreakOnStun = true,
PostCheck = IsTileClear,
};
var result = await doAfterSystem.WaitDoAfter(doAfterArgs);
var result = await _doAfterSystem.WaitDoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished)
return;
@@ -59,7 +61,7 @@ namespace Content.Server.Engineering.EntitySystems
return;
if (component.Owner.TryGetComponent<SharedStackComponent>(out var stackComp)
&& component.RemoveOnInteract && !Get<StackSystem>().Use(uid, stackComp, 1))
&& component.RemoveOnInteract && !_stackSystem.Use(uid, stackComp, 1))
{
return;
}

View File

@@ -18,6 +18,7 @@ using Robust.Server.Player;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -29,6 +30,9 @@ namespace Content.Server.Hands
[UsedImplicitly]
internal sealed class HandsSystem : SharedHandsSystem
{
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -113,12 +117,12 @@ namespace Content.Server.Hands
if (!hands.TryGetActiveHeldEntity(out var throwEnt))
return false;
if (!Get<InteractionSystem>().TryThrowInteraction(hands.Owner, throwEnt))
if (!_interactionSystem.TryThrowInteraction(hands.Owner, throwEnt))
return false;
if (throwEnt.TryGetComponent(out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually)
{
var splitStack = Get<StackSystem>().Split(throwEnt.Uid, stack, 1, playerEnt.Transform.Coordinates);
var splitStack = _stackSystem.Split(throwEnt.Uid, stack, 1, playerEnt.Transform.Coordinates);
if (splitStack == null)
return false;

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Content.Server.Buckle.Components;
using Content.Server.CombatMode;
using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Server.Pulling;
@@ -46,6 +47,7 @@ namespace Content.Server.Interaction
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
public override void Initialize()
{
@@ -175,9 +177,7 @@ namespace Content.Server.Interaction
private void InteractionActivate(IEntity user, IEntity used)
{
var actionBlocker = Get<ActionBlockerSystem>();
if (!actionBlocker.CanInteract(user) || ! actionBlocker.CanUse(user))
if (!_actionBlockerSystem.CanInteract(user) || ! _actionBlockerSystem.CanUse(user))
return;
// all activates should only fire when in range / unobstructed
@@ -275,7 +275,7 @@ namespace Content.Server.Interaction
if (!ValidateInteractAndFace(user, coordinates))
return;
if (!Get<ActionBlockerSystem>().CanInteract(user))
if (!_actionBlockerSystem.CanInteract(user))
return;
// Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
@@ -344,7 +344,7 @@ namespace Content.Server.Interaction
if (diff.LengthSquared <= 0.01f)
return;
var diffAngle = Angle.FromWorldVec(diff);
if (Get<ActionBlockerSystem>().CanChangeDirection(user))
if (_actionBlockerSystem.CanChangeDirection(user))
{
user.Transform.WorldRotation = diffAngle;
}
@@ -394,7 +394,7 @@ namespace Content.Server.Interaction
/// </summary>
public async Task InteractUsing(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation)
{
if (!Get<ActionBlockerSystem>().CanInteract(user))
if (!_actionBlockerSystem.CanInteract(user))
return;
// all interactions should only happen when in range / unobstructed, so no range check is needed
@@ -424,7 +424,7 @@ namespace Content.Server.Interaction
/// </summary>
public void InteractHand(IEntity user, IEntity target)
{
if (!Get<ActionBlockerSystem>().CanInteract(user))
if (!_actionBlockerSystem.CanInteract(user))
return;
// all interactions should only happen when in range / unobstructed, so no range check is needed
@@ -457,7 +457,7 @@ namespace Content.Server.Interaction
/// <param name="used"></param>
public void TryUseInteraction(IEntity user, IEntity used)
{
if (user != null && used != null && Get<ActionBlockerSystem>().CanUse(user))
if (user != null && used != null && _actionBlockerSystem.CanUse(user))
{
UseInteraction(user, used);
}
@@ -501,7 +501,7 @@ namespace Content.Server.Interaction
/// </summary>
public bool TryThrowInteraction(IEntity user, IEntity item)
{
if (user == null || item == null || !Get<ActionBlockerSystem>().CanThrow(user)) return false;
if (user == null || item == null || !_actionBlockerSystem.CanThrow(user)) return false;
ThrownInteraction(user, item);
return true;
@@ -618,7 +618,7 @@ namespace Content.Server.Interaction
/// </summary>
public bool TryDroppedInteraction(IEntity user, IEntity item, bool intentional)
{
if (user == null || item == null || !Get<ActionBlockerSystem>().CanDrop(user)) return false;
if (user == null || item == null || !_actionBlockerSystem.CanDrop(user)) return false;
DroppedInteraction(user, item, intentional);
return true;
@@ -726,7 +726,7 @@ namespace Content.Server.Interaction
if (!ValidateInteractAndFace(user, coordinates))
return;
if (!Get<ActionBlockerSystem>().CanAttack(user))
if (!_actionBlockerSystem.CanAttack(user))
return;
IEntity? targetEnt = null;

View File

@@ -31,6 +31,7 @@ namespace Content.Server.Pointing.EntitySystems
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f);
@@ -112,7 +113,7 @@ namespace Content.Server.Pointing.EntitySystems
return false;
}
if (EntitySystem.Get<ActionBlockerSystem>().CanChangeDirection(player))
if (_actionBlockerSystem.CanChangeDirection(player))
{
var diff = coords.ToMapPos(EntityManager) - player.Transform.MapPosition.Position;
if (diff.LengthSquared > 0.01f)

View File

@@ -4,6 +4,7 @@ using Content.Shared.Notification.Managers;
using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Physics;
@@ -17,6 +18,8 @@ namespace Content.Shared.Interaction
[UsedImplicitly]
public class SharedInteractionSystem : EntitySystem
{
[Dependency] private readonly SharedBroadphaseSystem _sharedBroadphaseSystem = default!;
public const float InteractionRange = 2;
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
@@ -46,7 +49,7 @@ namespace Content.Shared.Interaction
predicate ??= _ => false;
var ray = new CollisionRay(origin.Position, dir.Normalized, collisionMask);
var rayResults = Get<SharedBroadphaseSystem>().IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
if (rayResults.Count == 0) return dir.Length;
return (rayResults[0].HitPos - origin.Position).Length;
@@ -122,7 +125,7 @@ namespace Content.Shared.Interaction
predicate ??= _ => false;
var ray = new CollisionRay(origin.Position, dir.Normalized, (int) collisionMask);
var rayResults = Get<SharedBroadphaseSystem>().IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
if (rayResults.Count == 0) return true;