diff --git a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs index 9beb61a3c9..ee46b25881 100644 --- a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -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> _tileData = new(); - private AtmosphereSystem _atmosphereSystem = default!; - public override void Initialize() { base.Initialize(); SubscribeNetworkEvent(HandleGasOverlayMessage); _mapManager.OnGridRemoved += OnGridRemoved; - _atmosphereSystem = Get(); - for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++) { var overlay = _atmosphereSystem.GetOverlay(i); diff --git a/Content.Client/Audio/BackgroundAudioSystem.cs b/Content.Client/Audio/BackgroundAudioSystem.cs index 4d79891649..8a6f2b2607 100644 --- a/Content.Client/Audio/BackgroundAudioSystem.cs +++ b/Content.Client/Audio/BackgroundAudioSystem.cs @@ -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().LobbyStatusUpdated += LobbySongReceived; + _gameTicker.LobbyStatusUpdated += LobbySongReceived; } public override void Shutdown() @@ -60,7 +61,7 @@ namespace Content.Client.Audio _client.PlayerJoinedServer -= OnJoin; _client.PlayerLeaveServer -= OnLeave; - Get().LobbyStatusUpdated -= LobbySongReceived; + _gameTicker.LobbyStatusUpdated -= LobbySongReceived; EndAmbience(); EndLobbyMusic(); @@ -165,7 +166,7 @@ namespace Content.Client.Audio private void StartLobbyMusic() { EndLobbyMusic(); - var file = Get().LobbySong; + var file = _gameTicker.LobbySong; if (file == null) // We have not received the lobby song yet. { return; diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 7051978def..7163623a4b 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -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 _highlightedSprites = new(); @@ -80,8 +80,6 @@ namespace Content.Client.DragDrop _dropTargetInRangeShader = _prototypeManager.Index(ShaderDropTargetInRange).Instance(); _dropTargetOutOfRangeShader = _prototypeManager.Index(ShaderDropTargetOutOfRange).Instance(); - _interactionSystem = Get(); - _inputSystem = Get(); // needs to fire on mouseup and mousedown so we can detect a drag / drop CommandBinds.Builder .Bind(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false)) diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index d793e3c501..0253c71f76 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -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(); 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); } } diff --git a/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs b/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs index 85de5e4d55..38ffb63802 100644 --- a/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs +++ b/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs @@ -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(); - _combatModeSystem = Get(); - } - public override void Update(float frameTime) { base.Update(frameTime); diff --git a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs index 5f66ec5e2e..64791ce9ff 100644 --- a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -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!; /// /// Queued region updates @@ -80,7 +79,6 @@ namespace Content.Server.AI.Pathfinding.Accessible public override void Initialize() { - _pathfindingSystem = Get(); SubscribeLocalEvent(Reset); SubscribeLocalEvent(RecalculateNodeRegions); #if DEBUG diff --git a/Content.Server/AI/Steering/AiSteeringSystem.cs b/Content.Server/AI/Steering/AiSteeringSystem.cs index 7db0a97349..b7e1e468c6 100644 --- a/Content.Server/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/AI/Steering/AiSteeringSystem.cs @@ -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!; /// /// 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(); for (var i = 0; i < AgentListCount; i++) { diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index a1fea661a1..b3b0d4dd5a 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -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().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.UpdateAdjacent(gridId, pos); - atmosphereSystem.InvalidateTile(gridId, pos); + _atmosphereSystem.UpdateAdjacent(gridId, pos); + _atmosphereSystem.InvalidateTile(gridId, pos); } private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle) diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index 87a9bc0952..d28ac4324f 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -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!; /// /// 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(); // 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)); } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs index 41424c990a..661b5b169f 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs @@ -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(); - SubscribeLocalEvent(OnGridAtmosphereInit); } diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 2d3da529e9..0cebc10603 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -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(); - foreach (var gasTank in EntityManager.ComponentManager.EntityQuery()) { - atmosphereSystem.React(gasTank.Air, gasTank); + _atmosphereSystem.React(gasTank.Air, gasTank); gasTank.CheckStatus(); gasTank.UpdateUserInterface(); } diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index 3a24573cc3..ee9d880ca7 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -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!; /// /// The tiles that have had their atmos data updated since last tick @@ -58,8 +59,6 @@ namespace Content.Server.Atmos.EntitySystems /// private float _updateCooldown; - private AtmosphereSystem _atmosphereSystem = default!; - private int _thresholds; public override void Initialize() @@ -68,7 +67,6 @@ namespace Content.Server.Atmos.EntitySystems SubscribeLocalEvent(Reset); - _atmosphereSystem = Get(); _playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _mapManager.OnGridRemoved += OnGridRemoved; var configManager = IoCManager.Resolve(); diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs index 0782523559..24c03e399e 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs @@ -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(); - 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().Merge(outlet.Air, removed); + _atmosphereSystem.Merge(outlet.Air, removed); } } } diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs index ba4fd92866..555385d401 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs @@ -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(); - 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); } } diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs index 5c0d7826c6..166a4d07b8 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs @@ -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().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().RemoveAtmosDevice(component)) + if (!_atmosphereSystem.RemoveAtmosDevice(component)) return; component.LastProcess = TimeSpan.Zero; diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs index c14fc7dafa..9e8935d0d3 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs @@ -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(OnBeforeUnanchored); @@ -26,7 +29,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems if (!component.Enabled || !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodes)) return; - if (Get().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(); - - 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); } } } diff --git a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs index d1e61c7b98..0a4379d7f6 100644 --- a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs +++ b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs @@ -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(); - - 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; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index afc56ec96c..18b4c52433 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -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.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(); - 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); } } diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs index 63f9665d44..c716f72c04 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs @@ -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(); - 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); } } } diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs index 5a61cbc350..e484e80da0 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs @@ -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(); - 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 { diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs index 748700d13e..f48aa149f5 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs @@ -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().GetHeatCapacity(inlet.Air); + var airHeatCapacity = _atmosphereSystem.GetHeatCapacity(inlet.Air); var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity; var oldTemperature = inlet.Air.Temperature; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs index 5e69a4f3b4..f9af0231f6 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs @@ -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(); - 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) diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs index 399ba29a38..190fd86228 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs @@ -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(); - 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); } } diff --git a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs index b628e7f89c..5e95ace8be 100644 --- a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs +++ b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs @@ -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 _openSurgeryUIs = new(); public override void Initialize() @@ -54,7 +57,7 @@ namespace Content.Server.Body.Surgery.Components continue; } - if (!Get().CanInteract(tool.PerformerCache) || + if (!_actionBlockerSystem.CanInteract(tool.PerformerCache) || !tool.PerformerCache.InRangeUnobstructed(tool.BodyCache)) { tool.CloseAllSurgeryUIs(); diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index 11e7c41f72..f69cffd012 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -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> _beingBuilt = new(); @@ -170,7 +172,7 @@ namespace Content.Server.Construction if (!materialStep.EntityValid(entity, out var stack)) continue; - var splitStack = Get().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(); - 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; diff --git a/Content.Server/Destructible/DestructibleSystem.cs b/Content.Server/Destructible/DestructibleSystem.cs index f2ad5d4922..1be935c9f6 100644 --- a/Content.Server/Destructible/DestructibleSystem.cs +++ b/Content.Server/Destructible/DestructibleSystem.cs @@ -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(); - ActSystem = Get(); - } + [Dependency] public readonly AudioSystem AudioSystem = default!; + [Dependency] public readonly ActSystem ActSystem = default!; } } diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index fcf4bb1d85..61bfad8791 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -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(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(out var stackComp) - && component.RemoveOnInteract && !Get().Use(uid, stackComp, 1)) + && component.RemoveOnInteract && !_stackSystem.Use(uid, stackComp, 1)) { return; } diff --git a/Content.Server/Hands/HandsSystem.cs b/Content.Server/Hands/HandsSystem.cs index 712c0867a6..4a76d07101 100644 --- a/Content.Server/Hands/HandsSystem.cs +++ b/Content.Server/Hands/HandsSystem.cs @@ -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().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().Split(throwEnt.Uid, stack, 1, playerEnt.Transform.Coordinates); + var splitStack = _stackSystem.Split(throwEnt.Uid, stack, 1, playerEnt.Transform.Coordinates); if (splitStack == null) return false; diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index efb01638c4..61a5ce724e 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -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(); - - 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().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().CanChangeDirection(user)) + if (_actionBlockerSystem.CanChangeDirection(user)) { user.Transform.WorldRotation = diffAngle; } @@ -394,7 +394,7 @@ namespace Content.Server.Interaction /// public async Task InteractUsing(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation) { - if (!Get().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 /// public void InteractHand(IEntity user, IEntity target) { - if (!Get().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 /// public void TryUseInteraction(IEntity user, IEntity used) { - if (user != null && used != null && Get().CanUse(user)) + if (user != null && used != null && _actionBlockerSystem.CanUse(user)) { UseInteraction(user, used); } @@ -501,7 +501,7 @@ namespace Content.Server.Interaction /// public bool TryThrowInteraction(IEntity user, IEntity item) { - if (user == null || item == null || !Get().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 /// public bool TryDroppedInteraction(IEntity user, IEntity item, bool intentional) { - if (user == null || item == null || !Get().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().CanAttack(user)) + if (!_actionBlockerSystem.CanAttack(user)) return; IEntity? targetEnt = null; diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index f31155ff11..e855c9270c 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -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().CanChangeDirection(player)) + if (_actionBlockerSystem.CanChangeDirection(player)) { var diff = coords.ToMapPos(EntityManager) - player.Transform.MapPosition.Position; if (diff.LengthSquared > 0.01f) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 7f50cf0063..0d02792593 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -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().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().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;