From: Kara Date: Mon, 13 May 2024 00:34:52 +0000 (-0700) Subject: Resolve `'EntitySystem.Get()' is obsolete` in content (#27936) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=993eef1e7c22b2b79e528967ef5bb669f50236b1;p=space-station-14.git Resolve `'EntitySystem.Get()' is obsolete` in content (#27936) * PROJECT 0 WARNINGS: Resolve `'EntitySystem.Get()' is obsolete` in content * pass entman * dog ass test * webeditor --- diff --git a/Content.Client/Decals/ToggleDecalCommand.cs b/Content.Client/Decals/ToggleDecalCommand.cs index 9f0851f080..025ed1299d 100644 --- a/Content.Client/Decals/ToggleDecalCommand.cs +++ b/Content.Client/Decals/ToggleDecalCommand.cs @@ -5,11 +5,13 @@ namespace Content.Client.Decals; public sealed class ToggleDecalCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "toggledecals"; public string Description => "Toggles decaloverlay"; public string Help => $"{Command}"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - EntitySystem.Get().ToggleOverlay(); + _e.System().ToggleOverlay(); } } diff --git a/Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs b/Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs index 1be1751080..21b816515a 100644 --- a/Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs +++ b/Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs @@ -16,6 +16,7 @@ namespace Content.Client.Decals.UI; public sealed partial class DecalPlacerWindow : DefaultWindow { [Dependency] private readonly IPrototypeManager _prototype = default!; + [Dependency] private readonly IEntityManager _e = default!; private readonly DecalPlacementSystem _decalPlacementSystem; @@ -39,7 +40,7 @@ public sealed partial class DecalPlacerWindow : DefaultWindow RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - _decalPlacementSystem = EntitySystem.Get(); + _decalPlacementSystem = _e.System(); // This needs to be done in C# so we can have custom stuff passed in the constructor // and thus have a proper step size diff --git a/Content.Client/NetworkConfigurator/Systems/NetworkConfiguratorSystem.cs b/Content.Client/NetworkConfigurator/Systems/NetworkConfiguratorSystem.cs index 2fd4f29655..2d561ba5f2 100644 --- a/Content.Client/NetworkConfigurator/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Client/NetworkConfigurator/Systems/NetworkConfiguratorSystem.cs @@ -139,11 +139,13 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem public sealed class ClearAllNetworkLinkOverlays : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "clearnetworklinkoverlays"; public string Description => "Clear all network link overlays."; public string Help => Command; public void Execute(IConsoleShell shell, string argStr, string[] args) { - IoCManager.Resolve().System().ClearAllOverlays(); + _e.System().ClearAllOverlays(); } } diff --git a/Content.Client/NodeContainer/NodeVisCommand.cs b/Content.Client/NodeContainer/NodeVisCommand.cs index c6a95fce5b..249c0d9427 100644 --- a/Content.Client/NodeContainer/NodeVisCommand.cs +++ b/Content.Client/NodeContainer/NodeVisCommand.cs @@ -8,6 +8,8 @@ namespace Content.Client.NodeContainer { public sealed class NodeVisCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "nodevis"; public string Description => "Toggles node group visualization"; public string Help => ""; @@ -21,20 +23,22 @@ namespace Content.Client.NodeContainer return; } - var sys = EntitySystem.Get(); + var sys = _e.System(); sys.SetVisEnabled(!sys.VisEnabled); } } public sealed class NodeVisFilterCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "nodevisfilter"; public string Description => "Toggles showing a specific group on nodevis"; public string Help => "Usage: nodevis [filter]\nOmit filter to list currently masked-off"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var sys = EntitySystem.Get(); + var sys = _e.System(); if (args.Length == 0) { diff --git a/Content.IntegrationTests/Tests/Commands/RestartRoundTest.cs b/Content.IntegrationTests/Tests/Commands/RestartRoundTest.cs index 74d014b772..ff24ec0968 100644 --- a/Content.IntegrationTests/Tests/Commands/RestartRoundTest.cs +++ b/Content.IntegrationTests/Tests/Commands/RestartRoundTest.cs @@ -3,6 +3,7 @@ using Content.Server.GameTicking.Commands; using Content.Shared.CCVar; using Robust.Shared.Configuration; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Timing; namespace Content.IntegrationTests.Tests.Commands @@ -40,8 +41,7 @@ namespace Content.IntegrationTests.Tests.Commands tickBeforeRestart = entityManager.CurrentTick; - var command = new RestartRoundNowCommand(); - command.Execute(null, string.Empty, Array.Empty()); + gameTicker.RestartRound(); if (lobbyEnabled) { diff --git a/Content.Server/Administration/Commands/DSay.cs b/Content.Server/Administration/Commands/DSay.cs index 61b47d7856..8682614b5f 100644 --- a/Content.Server/Administration/Commands/DSay.cs +++ b/Content.Server/Administration/Commands/DSay.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] sealed class DSay : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "dsay"; public string Description => Loc.GetString("dsay-command-description"); @@ -32,7 +34,7 @@ namespace Content.Server.Administration.Commands if (string.IsNullOrEmpty(message)) return; - var chat = EntitySystem.Get(); + var chat = _e.System(); chat.TrySendInGameOOCMessage(entity, message, InGameOOCChatType.Dead, false, shell, player); } } diff --git a/Content.Server/Administration/Commands/ReadyAll.cs b/Content.Server/Administration/Commands/ReadyAll.cs index d55ef09660..530ba0e89c 100644 --- a/Content.Server/Administration/Commands/ReadyAll.cs +++ b/Content.Server/Administration/Commands/ReadyAll.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Round)] public sealed class ReadyAll : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "readyall"; public string Description => "Readies up all players in the lobby, except for observers."; public string Help => $"{Command} | ̣{Command} "; @@ -20,7 +22,7 @@ namespace Content.Server.Administration.Commands ready = bool.Parse(args[0]); } - var gameTicker = EntitySystem.Get(); + var gameTicker = _e.System(); if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby) diff --git a/Content.Server/Administration/Commands/ShuttleCommands.cs b/Content.Server/Administration/Commands/ShuttleCommands.cs index 5b0d39fd15..ea0f891360 100644 --- a/Content.Server/Administration/Commands/ShuttleCommands.cs +++ b/Content.Server/Administration/Commands/ShuttleCommands.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Round)] public sealed class CallShuttleCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "callshuttle"; public string Description => Loc.GetString("call-shuttle-command-description"); public string Help => Loc.GetString("call-shuttle-command-help-text", ("command",Command)); @@ -19,7 +21,7 @@ namespace Content.Server.Administration.Commands // ReSharper disable once ConvertIfStatementToSwitchStatement if (args.Length == 1 && TimeSpan.TryParseExact(args[0], ContentLocalizationManager.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan)) { - EntitySystem.Get().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false); + _e.System().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false); } else if (args.Length == 1) { @@ -27,7 +29,7 @@ namespace Content.Server.Administration.Commands } else { - EntitySystem.Get().RequestRoundEnd(shell.Player?.AttachedEntity, false); + _e.System().RequestRoundEnd(shell.Player?.AttachedEntity, false); } } } @@ -35,13 +37,15 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Round)] public sealed class RecallShuttleCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "recallshuttle"; public string Description => Loc.GetString("recall-shuttle-command-description"); public string Help => Loc.GetString("recall-shuttle-command-help-text", ("command",Command)); public void Execute(IConsoleShell shell, string argStr, string[] args) { - EntitySystem.Get().CancelRoundEndCountdown(shell.Player?.AttachedEntity, false); + _e.System().CancelRoundEndCountdown(shell.Player?.AttachedEntity, false); } } } diff --git a/Content.Server/Administration/Commands/ThrowScoreboardCommand.cs b/Content.Server/Administration/Commands/ThrowScoreboardCommand.cs index ed4ec5a515..e66efe809a 100644 --- a/Content.Server/Administration/Commands/ThrowScoreboardCommand.cs +++ b/Content.Server/Administration/Commands/ThrowScoreboardCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.VarEdit)] public sealed class ThrowScoreboardCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "throwscoreboard"; public string Description => Loc.GetString("throw-scoreboard-command-description"); @@ -20,6 +22,6 @@ public sealed class ThrowScoreboardCommand : IConsoleCommand shell.WriteLine(Help); return; } - EntitySystem.Get().ShowRoundEndScoreboard(); + _e.System().ShowRoundEndScoreboard(); } } diff --git a/Content.Server/Administration/Logs/AdminLogsEui.cs b/Content.Server/Administration/Logs/AdminLogsEui.cs index 8bd870b2c7..e98a3b0ff2 100644 --- a/Content.Server/Administration/Logs/AdminLogsEui.cs +++ b/Content.Server/Administration/Logs/AdminLogsEui.cs @@ -23,6 +23,7 @@ public sealed class AdminLogsEui : BaseEui [Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly IConfigurationManager _configuration = default!; + [Dependency] private readonly IEntityManager _e = default!; private readonly ISawmill _sawmill; @@ -51,7 +52,7 @@ public sealed class AdminLogsEui : BaseEui }; } - private int CurrentRoundId => EntitySystem.Get().RoundId; + private int CurrentRoundId => _e.System().RoundId; public override async void Opened() { diff --git a/Content.Server/Administration/UI/SpawnExplosionEui.cs b/Content.Server/Administration/UI/SpawnExplosionEui.cs index a3729b1454..001ce1efee 100644 --- a/Content.Server/Administration/UI/SpawnExplosionEui.cs +++ b/Content.Server/Administration/UI/SpawnExplosionEui.cs @@ -31,7 +31,7 @@ public sealed class SpawnExplosionEui : BaseEui if (request.TotalIntensity <= 0 || request.IntensitySlope <= 0) return; - var explosion = EntitySystem.Get().GenerateExplosionPreview(request); + var explosion = _explosionSystem.GenerateExplosionPreview(request); if (explosion == null) { diff --git a/Content.Server/Alert/Commands/ClearAlert.cs b/Content.Server/Alert/Commands/ClearAlert.cs index 1759612702..73a6ca52c7 100644 --- a/Content.Server/Alert/Commands/ClearAlert.cs +++ b/Content.Server/Alert/Commands/ClearAlert.cs @@ -9,6 +9,8 @@ namespace Content.Server.Alert.Commands [AdminCommand(AdminFlags.Debug)] public sealed class ClearAlert : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "clearalert"; public string Description => "Clears an alert for a player, defaulting to current player"; public string Help => "clearalert "; @@ -30,14 +32,14 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out AlertsComponent? alertsComponent)) + if (!_e.TryGetComponent(attachedEntity, out AlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; } var alertType = args[0]; - var alertsSystem = EntitySystem.Get(); + var alertsSystem = _e.System(); if (!alertsSystem.TryGet(Enum.Parse(alertType), out var alert)) { shell.WriteLine("unrecognized alertType " + alertType); diff --git a/Content.Server/Alert/Commands/ShowAlert.cs b/Content.Server/Alert/Commands/ShowAlert.cs index 11901e9af0..f37ab23f2f 100644 --- a/Content.Server/Alert/Commands/ShowAlert.cs +++ b/Content.Server/Alert/Commands/ShowAlert.cs @@ -9,6 +9,8 @@ namespace Content.Server.Alert.Commands [AdminCommand(AdminFlags.Debug)] public sealed class ShowAlert : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "showalert"; public string Description => "Shows an alert for a player, defaulting to current player"; public string Help => "showalert "; @@ -30,7 +32,7 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out AlertsComponent? alertsComponent)) + if (!_e.TryGetComponent(attachedEntity, out AlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; @@ -38,7 +40,7 @@ namespace Content.Server.Alert.Commands var alertType = args[0]; var severity = args[1]; - var alertsSystem = EntitySystem.Get(); + var alertsSystem = _e.System(); if (!alertsSystem.TryGet(Enum.Parse(alertType), out var alert)) { shell.WriteLine("unrecognized alertType " + alertType); diff --git a/Content.Server/Atmos/Commands/ListGasesCommand.cs b/Content.Server/Atmos/Commands/ListGasesCommand.cs index ab792fcf81..81acc2b3b5 100644 --- a/Content.Server/Atmos/Commands/ListGasesCommand.cs +++ b/Content.Server/Atmos/Commands/ListGasesCommand.cs @@ -8,13 +8,15 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class ListGasesCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "listgases"; public string Description => "Prints a list of gases and their indices."; public string Help => "listgases"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var atmosSystem = EntitySystem.Get(); + var atmosSystem = _e.System(); foreach (var gasPrototype in atmosSystem.Gases) { diff --git a/Content.Server/Atmos/Commands/ShowAtmosCommand.cs b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs index 263ef947d0..89b9c846ec 100644 --- a/Content.Server/Atmos/Commands/ShowAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class ShowAtmos : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "showatmos"; public string Description => "Toggles seeing atmos debug overlay."; public string Help => $"Usage: {Command}"; @@ -21,7 +23,7 @@ namespace Content.Server.Atmos.Commands return; } - var atmosDebug = EntitySystem.Get(); + var atmosDebug = _e.System(); var enabled = atmosDebug.ToggleObserver(player); shell.WriteLine(enabled diff --git a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs index d86cbe1d2f..3332d227e4 100644 --- a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs +++ b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs @@ -14,7 +14,7 @@ namespace Content.Server.Atmos.Components set { Type = value; - EntitySystem.Get().UpdateSign(Owner, this); + IoCManager.Resolve().System().UpdateSign(Owner, this); } } } diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmModes.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmModes.cs index d794be0d56..f979f4b860 100644 --- a/Content.Server/Atmos/Monitor/Systems/AirAlarmModes.cs +++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmModes.cs @@ -90,8 +90,8 @@ public abstract class AirAlarmModeExecutor : IAirAlarmMode { IoCManager.InjectDependencies(this); - DeviceNetworkSystem = EntitySystem.Get(); - AirAlarmSystem = EntitySystem.Get(); + DeviceNetworkSystem = EntityManager.System(); + AirAlarmSystem = EntityManager.System(); } } diff --git a/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs b/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs index 455d125e44..5b05668ad5 100644 --- a/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs +++ b/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs @@ -13,7 +13,7 @@ namespace Content.Server.Atmos.Piping.Components public Color ColorVV { get => Color; - set => EntitySystem.Get().SetColor(Owner, this, value); + set => IoCManager.Resolve().System().SetColor(Owner, this, value); } } } diff --git a/Content.Server/Chat/Commands/LOOCCommand.cs b/Content.Server/Chat/Commands/LOOCCommand.cs index 9e16193fc3..059d25df27 100644 --- a/Content.Server/Chat/Commands/LOOCCommand.cs +++ b/Content.Server/Chat/Commands/LOOCCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Chat.Commands [AnyCommand] internal sealed class LOOCCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "looc"; public string Description => "Send Local Out Of Character chat messages."; public string Help => "looc "; @@ -33,7 +35,7 @@ namespace Content.Server.Chat.Commands if (string.IsNullOrEmpty(message)) return; - EntitySystem.Get().TrySendInGameOOCMessage(entity, message, InGameOOCChatType.Looc, false, shell, player); + _e.System().TrySendInGameOOCMessage(entity, message, InGameOOCChatType.Looc, false, shell, player); } } } diff --git a/Content.Server/Chat/Commands/SuicideCommand.cs b/Content.Server/Chat/Commands/SuicideCommand.cs index 0c541b48b7..0db03fec79 100644 --- a/Content.Server/Chat/Commands/SuicideCommand.cs +++ b/Content.Server/Chat/Commands/SuicideCommand.cs @@ -10,6 +10,8 @@ namespace Content.Server.Chat.Commands [AnyCommand] internal sealed class SuicideCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "suicide"; public string Description => Loc.GetString("suicide-command-description"); @@ -27,8 +29,8 @@ namespace Content.Server.Chat.Commands if (player.Status != SessionStatus.InGame || player.AttachedEntity == null) return; - var entityManager = IoCManager.Resolve(); - var minds = entityManager.System(); + var minds = _e.System(); + // This check also proves mind not-null for at the end when the mob is ghosted. if (!minds.TryGetMind(player, out var mindId, out var mind) || mind.OwnedEntity is not { Valid: true } victim) @@ -37,17 +39,19 @@ namespace Content.Server.Chat.Commands return; } - if (entityManager.HasComponent(victim)) + + var gameTicker = _e.System(); + var suicideSystem = _e.System(); + + if (_e.HasComponent(victim)) { var deniedMessage = Loc.GetString("suicide-command-denied"); shell.WriteLine(deniedMessage); - entityManager.System() + _e.System() .PopupEntity(deniedMessage, victim, victim); return; } - var gameTicker = entityManager.System(); - var suicideSystem = entityManager.System(); if (suicideSystem.Suicide(victim)) { // Prevent the player from returning to the body. diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 1415b6cad3..8e12670ca6 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -122,7 +122,7 @@ namespace Content.Server.Chemistry.EntitySystems var reagent = _protoManager.Index(reagentQuantity.Reagent.Prototype); var reaction = - reagent.ReactionTile(tile, (reagentQuantity.Quantity / vapor.TransferAmount) * 0.25f); + reagent.ReactionTile(tile, (reagentQuantity.Quantity / vapor.TransferAmount) * 0.25f, EntityManager); if (reaction > reagentQuantity.Quantity) { diff --git a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs index 8a558a3ffd..2771f79c3a 100644 --- a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs @@ -61,7 +61,8 @@ namespace Content.Server.Chemistry.ReactionEffects { var intensity = MathF.Min((float) args.Quantity * IntensityPerUnit, MaxTotalIntensity); - EntitySystem.Get().QueueExplosion( + args.EntityManager.System() + .QueueExplosion( args.SolutionEntity, ExplosionType, intensity, diff --git a/Content.Server/Chemistry/ReagentEffectConditions/HasTagCondition.cs b/Content.Server/Chemistry/ReagentEffectConditions/HasTagCondition.cs index 52d4d00eb3..d185c7e0a7 100644 --- a/Content.Server/Chemistry/ReagentEffectConditions/HasTagCondition.cs +++ b/Content.Server/Chemistry/ReagentEffectConditions/HasTagCondition.cs @@ -18,7 +18,7 @@ public sealed partial class HasTag : ReagentEffectCondition public override bool Condition(ReagentEffectArgs args) { if (args.EntityManager.TryGetComponent(args.SolutionEntity, out var tag)) - return EntitySystem.Get().HasTag(tag, Tag) ^ Invert; + return args.EntityManager.System().HasTag(tag, Tag) ^ Invert; return false; } diff --git a/Content.Server/Chemistry/ReagentEffects/ChemCleanBloodstream.cs b/Content.Server/Chemistry/ReagentEffects/ChemCleanBloodstream.cs index 402b30a069..ace73c84f3 100644 --- a/Content.Server/Chemistry/ReagentEffects/ChemCleanBloodstream.cs +++ b/Content.Server/Chemistry/ReagentEffects/ChemCleanBloodstream.cs @@ -26,7 +26,7 @@ namespace Content.Server.Chemistry.ReactionEffects cleanseRate *= args.Scale; - var bloodstreamSys = EntitySystem.Get(); + var bloodstreamSys = args.EntityManager.System(); bloodstreamSys.FlushChemicals(args.SolutionEntity, args.Reagent.ID, cleanseRate); } } diff --git a/Content.Server/Chemistry/ReagentEffects/ExtinguishReaction.cs b/Content.Server/Chemistry/ReagentEffects/ExtinguishReaction.cs index e902908998..69aaf5cdcd 100644 --- a/Content.Server/Chemistry/ReagentEffects/ExtinguishReaction.cs +++ b/Content.Server/Chemistry/ReagentEffects/ExtinguishReaction.cs @@ -16,7 +16,7 @@ namespace Content.Server.Chemistry.ReagentEffects { if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out FlammableComponent? flammable)) return; - var flammableSystem = EntitySystem.Get(); + var flammableSystem = args.EntityManager.System(); flammableSystem.Extinguish(args.SolutionEntity, flammable); flammableSystem.AdjustFireStacks(args.SolutionEntity, -1.5f * (float) args.Quantity, flammable); } diff --git a/Content.Server/Chemistry/ReagentEffects/Ignite.cs b/Content.Server/Chemistry/ReagentEffects/Ignite.cs index 1fc90f63e3..6c5d47711f 100644 --- a/Content.Server/Chemistry/ReagentEffects/Ignite.cs +++ b/Content.Server/Chemistry/ReagentEffects/Ignite.cs @@ -19,7 +19,7 @@ public sealed partial class Ignite : ReagentEffect public override void Effect(ReagentEffectArgs args) { - var flamSys = EntitySystem.Get(); + var flamSys = args.EntityManager.System(); flamSys.Ignite(args.SolutionEntity, args.OrganEntity ?? args.SolutionEntity); } } diff --git a/Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs b/Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs index 7b966ea478..ecd9c86255 100644 --- a/Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs +++ b/Content.Server/Chemistry/ReagentEffects/ModifyBleedAmount.cs @@ -21,7 +21,7 @@ public sealed partial class ModifyBleedAmount : ReagentEffect { if (args.EntityManager.TryGetComponent(args.SolutionEntity, out var blood)) { - var sys = EntitySystem.Get(); + var sys = args.EntityManager.System(); var amt = Scaled ? Amount * args.Quantity.Float() : Amount; amt *= args.Scale; diff --git a/Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs b/Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs index 748aa71083..b136ff9bb8 100644 --- a/Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs +++ b/Content.Server/Chemistry/ReagentEffects/ModifyBloodLevel.cs @@ -22,7 +22,7 @@ public sealed partial class ModifyBloodLevel : ReagentEffect { if (args.EntityManager.TryGetComponent(args.SolutionEntity, out var blood)) { - var sys = EntitySystem.Get(); + var sys = args.EntityManager.System(); var amt = Scaled ? Amount * args.Quantity : Amount; amt *= args.Scale; diff --git a/Content.Server/Chemistry/ReagentEffects/MovespeedModifier.cs b/Content.Server/Chemistry/ReagentEffects/MovespeedModifier.cs index 0301742c5a..e538a011f6 100644 --- a/Content.Server/Chemistry/ReagentEffects/MovespeedModifier.cs +++ b/Content.Server/Chemistry/ReagentEffects/MovespeedModifier.cs @@ -59,7 +59,7 @@ namespace Content.Server.Chemistry.ReagentEffects IncreaseTimer(status, statusLifetime); if (modified) - EntitySystem.Get().RefreshMovementSpeedModifiers(args.SolutionEntity); + args.EntityManager.System().RefreshMovementSpeedModifiers(args.SolutionEntity); } public void IncreaseTimer(MovespeedModifierMetabolismComponent status, float time) diff --git a/Content.Server/Chemistry/ReagentEffects/Oxygenate.cs b/Content.Server/Chemistry/ReagentEffects/Oxygenate.cs index 34a2454139..6c5ab155e4 100644 --- a/Content.Server/Chemistry/ReagentEffects/Oxygenate.cs +++ b/Content.Server/Chemistry/ReagentEffects/Oxygenate.cs @@ -18,7 +18,7 @@ public sealed partial class Oxygenate : ReagentEffect { if (args.EntityManager.TryGetComponent(args.SolutionEntity, out var resp)) { - var respSys = EntitySystem.Get(); + var respSys = args.EntityManager.System(); respSys.UpdateSaturation(args.SolutionEntity, args.Quantity.Float() * Factor, resp); } } diff --git a/Content.Server/Chemistry/ReagentEffects/Paralyze.cs b/Content.Server/Chemistry/ReagentEffects/Paralyze.cs index 077d1abf2c..d5d913f37d 100644 --- a/Content.Server/Chemistry/ReagentEffects/Paralyze.cs +++ b/Content.Server/Chemistry/ReagentEffects/Paralyze.cs @@ -23,7 +23,7 @@ public sealed partial class Paralyze : ReagentEffect var paralyzeTime = ParalyzeTime; paralyzeTime *= args.Scale; - EntitySystem.Get().TryParalyze(args.SolutionEntity, TimeSpan.FromSeconds(paralyzeTime), Refresh); + args.EntityManager.System().TryParalyze(args.SolutionEntity, TimeSpan.FromSeconds(paralyzeTime), Refresh); } } diff --git a/Content.Server/Chemistry/ReagentEffects/SatiateThirst.cs b/Content.Server/Chemistry/ReagentEffects/SatiateThirst.cs index 1208e74367..8813813c24 100644 --- a/Content.Server/Chemistry/ReagentEffects/SatiateThirst.cs +++ b/Content.Server/Chemistry/ReagentEffects/SatiateThirst.cs @@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.ReagentEffects { var uid = args.SolutionEntity; if (args.EntityManager.TryGetComponent(uid, out ThirstComponent? thirst)) - EntitySystem.Get().ModifyThirst(uid, thirst, HydrationFactor); + args.EntityManager.System().ModifyThirst(uid, thirst, HydrationFactor); } protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) diff --git a/Content.Server/Chemistry/ReagentEffects/WashCreamPieReaction.cs b/Content.Server/Chemistry/ReagentEffects/WashCreamPieReaction.cs index 9bf6792eca..a71a42c25f 100644 --- a/Content.Server/Chemistry/ReagentEffects/WashCreamPieReaction.cs +++ b/Content.Server/Chemistry/ReagentEffects/WashCreamPieReaction.cs @@ -16,7 +16,7 @@ namespace Content.Server.Chemistry.ReagentEffects { if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out CreamPiedComponent? creamPied)) return; - EntitySystem.Get().SetCreamPied(args.SolutionEntity, creamPied, false); + args.EntityManager.System().SetCreamPied(args.SolutionEntity, creamPied, false); } } } diff --git a/Content.Server/Chemistry/TileReactions/CleanDecalsReaction.cs b/Content.Server/Chemistry/TileReactions/CleanDecalsReaction.cs index a20f54728e..6958dabb81 100644 --- a/Content.Server/Chemistry/TileReactions/CleanDecalsReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CleanDecalsReaction.cs @@ -21,19 +21,20 @@ public sealed partial class CleanDecalsReaction : ITileReaction [DataField] public FixedPoint2 CleanCost { get; private set; } = FixedPoint2.New(0.25f); - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { - var entMan = IoCManager.Resolve(); - if (reactVolume <= CleanCost || - !entMan.TryGetComponent(tile.GridUid, out var grid) || - !entMan.TryGetComponent(tile.GridUid, out var decalGrid)) + !entityManager.TryGetComponent(tile.GridUid, out var grid) || + !entityManager.TryGetComponent(tile.GridUid, out var decalGrid)) { return FixedPoint2.Zero; } - var lookupSystem = entMan.System(); - var decalSystem = entMan.System(); + var lookupSystem = entityManager.System(); + var decalSystem = entityManager.System(); // Very generous hitbox. var decals = decalSystem .GetDecalsIntersecting(tile.GridUid, lookupSystem.GetLocalBounds(tile, grid.TileSize).Enlarged(0.5f).Translated(new Vector2(-0.5f, -0.5f))); diff --git a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs index 3f5ae63c36..08f77de72d 100644 --- a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs @@ -31,12 +31,14 @@ public sealed partial class CleanTileReaction : ITileReaction [DataField("reagent", customTypeSerializer: typeof(PrototypeIdSerializer))] public string ReplacementReagent = "Water"; - FixedPoint2 ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + FixedPoint2 ITileReaction.TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { - var entMan = IoCManager.Resolve(); - var entities = entMan.System().GetLocalEntitiesIntersecting(tile, 0f).ToArray(); - var puddleQuery = entMan.GetEntityQuery(); - var solutionContainerSystem = entMan.System(); + var entities = entityManager.System().GetLocalEntitiesIntersecting(tile, 0f).ToArray(); + var puddleQuery = entityManager.GetEntityQuery(); + var solutionContainerSystem = entityManager.System(); // Multiply as the amount we can actually purge is higher than the react amount. var purgeAmount = reactVolume / CleanAmountMultiplier; diff --git a/Content.Server/Chemistry/TileReactions/CreateEntityTileReaction.cs b/Content.Server/Chemistry/TileReactions/CreateEntityTileReaction.cs index 9cb1ba201d..29f9275bdf 100644 --- a/Content.Server/Chemistry/TileReactions/CreateEntityTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CreateEntityTileReaction.cs @@ -35,13 +35,13 @@ public sealed partial class CreateEntityTileReaction : ITileReaction [DataField] public float RandomOffsetMax = 0.0f; - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { if (reactVolume >= Usage) { - // TODO probably pass this in args like reagenteffects do. - var entMan = IoCManager.Resolve(); - if (Whitelist != null) { int acc = 0; @@ -59,9 +59,9 @@ public sealed partial class CreateEntityTileReaction : ITileReaction var xoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax); var yoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax); - var center = entMan.System().GetTileCenter(tile); + var center = entityManager.System().GetTileCenter(tile); var pos = center.Offset(new Vector2(xoffs, yoffs)); - entMan.SpawnEntity(Entity, pos); + entityManager.SpawnEntity(Entity, pos); return Usage; } diff --git a/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs b/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs index 312b88bd34..198f650ac1 100644 --- a/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/ExtinguishTileReaction.cs @@ -14,12 +14,15 @@ namespace Content.Server.Chemistry.TileReactions { [DataField("coolingTemperature")] private float _coolingTemperature = 2f; - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { if (reactVolume <= FixedPoint2.Zero || tile.Tile.IsEmpty) return FixedPoint2.Zero; - var atmosphereSystem = EntitySystem.Get(); + var atmosphereSystem = entityManager.System(); var environment = atmosphereSystem.GetTileMixture(tile.GridUid, null, tile.GridIndices, true); diff --git a/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs b/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs index a694bf6019..b13b70d3d5 100644 --- a/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/FlammableTileReaction.cs @@ -13,12 +13,15 @@ namespace Content.Server.Chemistry.TileReactions { [DataField("temperatureMultiplier")] private float _temperatureMultiplier = 1.15f; - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { if (reactVolume <= FixedPoint2.Zero || tile.Tile.IsEmpty) return FixedPoint2.Zero; - var atmosphereSystem = EntitySystem.Get(); + var atmosphereSystem = entityManager.System(); var environment = atmosphereSystem.GetTileMixture(tile.GridUid, null, tile.GridIndices, true); if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridUid, tile.GridIndices)) diff --git a/Content.Server/Chemistry/TileReactions/PryTileReaction.cs b/Content.Server/Chemistry/TileReactions/PryTileReaction.cs index 39e95df5f7..c10b031720 100644 --- a/Content.Server/Chemistry/TileReactions/PryTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/PryTileReaction.cs @@ -12,9 +12,12 @@ namespace Content.Server.Chemistry.TileReactions; [DataDefinition] public sealed partial class PryTileReaction : ITileReaction { - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { - var sys = IoCManager.Resolve().System(); + var sys = entityManager.System(); sys.PryTile(tile); return reactVolume; } diff --git a/Content.Server/Chemistry/TileReactions/SpillIfPuddlePresentTileReaction.cs b/Content.Server/Chemistry/TileReactions/SpillIfPuddlePresentTileReaction.cs index 82ede720cd..6b46b89495 100644 --- a/Content.Server/Chemistry/TileReactions/SpillIfPuddlePresentTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/SpillIfPuddlePresentTileReaction.cs @@ -12,9 +12,12 @@ namespace Content.Server.Chemistry.TileReactions [DataDefinition] public sealed partial class SpillIfPuddlePresentTileReaction : ITileReaction { - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { - var spillSystem = EntitySystem.Get(); + var spillSystem = entityManager.System(); if (reactVolume < 5 || !spillSystem.TryGetPuddle(tile, out _)) return FixedPoint2.Zero; diff --git a/Content.Server/Chemistry/TileReactions/SpillTileReaction.cs b/Content.Server/Chemistry/TileReactions/SpillTileReaction.cs index 8f8b0626a2..fadc7147c9 100644 --- a/Content.Server/Chemistry/TileReactions/SpillTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/SpillTileReaction.cs @@ -26,13 +26,14 @@ namespace Content.Server.Chemistry.TileReactions /// [DataField("superSlippery")] private bool _superSlippery; - public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) + public FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager) { if (reactVolume < 5) return FixedPoint2.Zero; - var entityManager = IoCManager.Resolve(); - if (entityManager.EntitySysManager.GetEntitySystem() .TrySpillAt(tile, new Solution(reagent.ID, reactVolume), out var puddleUid, false, false)) { diff --git a/Content.Server/Destructible/Thresholds/Behaviors/EjectVendorItems.cs b/Content.Server/Destructible/Thresholds/Behaviors/EjectVendorItems.cs index 2ffd9a8f9f..a5212dfe85 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/EjectVendorItems.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/EjectVendorItems.cs @@ -29,7 +29,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors !system.EntityManager.TryGetComponent(owner, out var xform)) return; - var vendingMachineSystem = EntitySystem.Get(); + var vendingMachineSystem = system.EntityManager.System(); var inventory = vendingMachineSystem.GetAvailableInventory(owner, vendingcomp); if (inventory.Count <= 0) return; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs index 7ab1fe11b0..dffcac6d96 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/OpenBehavior.cs @@ -11,7 +11,7 @@ public sealed partial class OpenBehavior : IThresholdBehavior { public void Execute(EntityUid uid, DestructibleSystem system, EntityUid? cause = null) { - var openable = EntitySystem.Get(); + var openable = system.EntityManager.System(); openable.TryOpen(uid); } } diff --git a/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs index 38564380c0..5826a3871d 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs @@ -22,8 +22,8 @@ namespace Content.Server.Destructible.Thresholds.Behaviors /// public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) { - var solutionContainerSystem = EntitySystem.Get(); - var spillableSystem = EntitySystem.Get(); + var solutionContainerSystem = system.EntityManager.System(); + var spillableSystem = system.EntityManager.System(); var coordinates = system.EntityManager.GetComponent(owner).Coordinates; diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs index 923210cc73..a232ed8c0e 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs @@ -712,7 +712,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem { var (reagent, quantity) = solution.Contents[i]; var proto = _prototypeManager.Index(reagent.Prototype); - var removed = proto.ReactionTile(tileRef, quantity); + var removed = proto.ReactionTile(tileRef, quantity, EntityManager); if (removed <= FixedPoint2.Zero) continue; diff --git a/Content.Server/Fluids/EntitySystems/SmokeSystem.cs b/Content.Server/Fluids/EntitySystems/SmokeSystem.cs index ae170842a0..9638dabf28 100644 --- a/Content.Server/Fluids/EntitySystems/SmokeSystem.cs +++ b/Content.Server/Fluids/EntitySystems/SmokeSystem.cs @@ -315,7 +315,7 @@ public sealed class SmokeSystem : EntitySystem continue; var reagent = _prototype.Index(reagentQuantity.Reagent.Prototype); - reagent.ReactionTile(tile, reagentQuantity.Quantity); + reagent.ReactionTile(tile, reagentQuantity.Quantity, EntityManager); } } diff --git a/Content.Server/GameTicking/Commands/DelayStartCommand.cs b/Content.Server/GameTicking/Commands/DelayStartCommand.cs index 6f57f561d8..6e101d93a3 100644 --- a/Content.Server/GameTicking/Commands/DelayStartCommand.cs +++ b/Content.Server/GameTicking/Commands/DelayStartCommand.cs @@ -7,13 +7,15 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] sealed class DelayStartCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "delaystart"; public string Description => "Delays the round start."; public string Help => $"Usage: {Command} \nPauses/Resumes the countdown if no argument is provided."; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); diff --git a/Content.Server/GameTicking/Commands/EndRoundCommand.cs b/Content.Server/GameTicking/Commands/EndRoundCommand.cs index 972fa9561a..c6a8ddbf53 100644 --- a/Content.Server/GameTicking/Commands/EndRoundCommand.cs +++ b/Content.Server/GameTicking/Commands/EndRoundCommand.cs @@ -7,13 +7,15 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] sealed class EndRoundCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "endround"; public string Description => "Ends the round and moves the server to PostRound."; public string Help => String.Empty; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel != GameRunLevel.InRound) { diff --git a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs index 1041fed6ec..5ef72f59b3 100644 --- a/Content.Server/GameTicking/Commands/ForcePresetCommand.cs +++ b/Content.Server/GameTicking/Commands/ForcePresetCommand.cs @@ -10,13 +10,15 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] sealed class ForcePresetCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "forcepreset"; public string Description => "Forces a specific game preset to start for the current lobby."; public string Help => $"Usage: {Command} "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { shell.WriteLine("This can only be executed while the game is in the pre-round lobby."); diff --git a/Content.Server/GameTicking/Commands/GoLobbyCommand.cs b/Content.Server/GameTicking/Commands/GoLobbyCommand.cs index 4932dbe0bf..b5984d260d 100644 --- a/Content.Server/GameTicking/Commands/GoLobbyCommand.cs +++ b/Content.Server/GameTicking/Commands/GoLobbyCommand.cs @@ -10,6 +10,8 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] public sealed class GoLobbyCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "golobby"; public string Description => "Enables the lobby and restarts the round."; public string Help => $"Usage: {Command} / {Command} "; @@ -18,7 +20,7 @@ namespace Content.Server.GameTicking.Commands GamePresetPrototype? preset = null; var presetName = string.Join(" ", args); - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (args.Length > 0) { diff --git a/Content.Server/GameTicking/Commands/ObserveCommand.cs b/Content.Server/GameTicking/Commands/ObserveCommand.cs index 747e54e28b..16c2c3261d 100644 --- a/Content.Server/GameTicking/Commands/ObserveCommand.cs +++ b/Content.Server/GameTicking/Commands/ObserveCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.GameTicking.Commands [AnyCommand] sealed class ObserveCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "observe"; public string Description => ""; public string Help => ""; @@ -18,7 +20,7 @@ namespace Content.Server.GameTicking.Commands return; } - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel == GameRunLevel.PreRoundLobby) { diff --git a/Content.Server/GameTicking/Commands/RestartRoundCommand.cs b/Content.Server/GameTicking/Commands/RestartRoundCommand.cs index 36c0ba981c..e4ea3fa53c 100644 --- a/Content.Server/GameTicking/Commands/RestartRoundCommand.cs +++ b/Content.Server/GameTicking/Commands/RestartRoundCommand.cs @@ -8,13 +8,15 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] public sealed class RestartRoundCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "restartround"; public string Description => "Ends the current round and starts the countdown for the next lobby."; public string Help => string.Empty; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel != GameRunLevel.InRound) { @@ -22,20 +24,22 @@ namespace Content.Server.GameTicking.Commands return; } - EntitySystem.Get().EndRound(); + _e.System().EndRound(); } } [AdminCommand(AdminFlags.Round)] public sealed class RestartRoundNowCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "restartroundnow"; public string Description => "Moves the server from PostRound to a new PreRoundLobby."; public string Help => String.Empty; public void Execute(IConsoleShell shell, string argStr, string[] args) { - EntitySystem.Get().RestartRound(); + _e.System().RestartRound(); } } } diff --git a/Content.Server/GameTicking/Commands/StartRoundCommand.cs b/Content.Server/GameTicking/Commands/StartRoundCommand.cs index 1652a14120..432cdd23e3 100644 --- a/Content.Server/GameTicking/Commands/StartRoundCommand.cs +++ b/Content.Server/GameTicking/Commands/StartRoundCommand.cs @@ -7,13 +7,15 @@ namespace Content.Server.GameTicking.Commands [AdminCommand(AdminFlags.Round)] sealed class StartRoundCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "startround"; public string Description => "Ends PreRoundLobby state and starts the round."; public string Help => String.Empty; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var ticker = EntitySystem.Get(); + var ticker = _e.System(); if (ticker.RunLevel != GameRunLevel.PreRoundLobby) { diff --git a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs index df418c27ee..34b504acbc 100644 --- a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs +++ b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs @@ -6,6 +6,8 @@ namespace Content.Server.GameTicking.Commands [AnyCommand] sealed class ToggleReadyCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "toggleready"; public string Description => ""; public string Help => ""; @@ -23,7 +25,7 @@ namespace Content.Server.GameTicking.Commands return; } - var ticker = EntitySystem.Get(); + var ticker = _e.System(); ticker.ToggleReady(player, bool.Parse(args[0])); } } diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs index ccd460a9cf..86026b230b 100644 --- a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs +++ b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs @@ -40,7 +40,7 @@ namespace Content.Server.Ghost.Roles.Components set { _roleName = value; - EntitySystem.Get().UpdateAllEui(); + IoCManager.Resolve().System().UpdateAllEui(); } } @@ -52,7 +52,7 @@ namespace Content.Server.Ghost.Roles.Components set { _roleDescription = value; - EntitySystem.Get().UpdateAllEui(); + IoCManager.Resolve().System().UpdateAllEui(); } } @@ -64,7 +64,7 @@ namespace Content.Server.Ghost.Roles.Components set { _roleRules = value; - EntitySystem.Get().UpdateAllEui(); + IoCManager.Resolve().System().UpdateAllEui(); } } diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index c198b54b1b..b6627f1154 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -791,13 +791,15 @@ namespace Content.Server.Ghost.Roles [AnyCommand] public sealed class GhostRoles : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "ghostroles"; public string Description => "Opens the ghost role request window."; public string Help => $"{Command}"; public void Execute(IConsoleShell shell, string argStr, string[] args) { if (shell.Player != null) - EntitySystem.Get().OpenEui(shell.Player); + _e.System().OpenEui(shell.Player); else shell.WriteLine("You can only open the ghost roles UI on a client."); } diff --git a/Content.Server/Ghost/Roles/UI/GhostRolesEui.cs b/Content.Server/Ghost/Roles/UI/GhostRolesEui.cs index c1e39919a2..825691fe95 100644 --- a/Content.Server/Ghost/Roles/UI/GhostRolesEui.cs +++ b/Content.Server/Ghost/Roles/UI/GhostRolesEui.cs @@ -40,7 +40,7 @@ namespace Content.Server.Ghost.Roles.UI { base.Closed(); - EntitySystem.Get().CloseEui(Player); + _ghostRoleSystem.CloseEui(Player); } } } diff --git a/Content.Server/Maps/Conditions/HolidayMapCondition.cs b/Content.Server/Maps/Conditions/HolidayMapCondition.cs index 81ecfb356e..da971c78f3 100644 --- a/Content.Server/Maps/Conditions/HolidayMapCondition.cs +++ b/Content.Server/Maps/Conditions/HolidayMapCondition.cs @@ -10,7 +10,7 @@ public sealed partial class HolidayMapCondition : GameMapCondition public override bool Check(GameMapPrototype map) { - var holidaySystem = EntitySystem.Get(); + var holidaySystem = IoCManager.Resolve().System(); return Holidays.Any(holiday => holidaySystem.IsCurrentlyHoliday(holiday)) ^ Inverted; } diff --git a/Content.Server/NodeContainer/Nodes/PipeNode.cs b/Content.Server/NodeContainer/Nodes/PipeNode.cs index 14afa2f108..861f3eea98 100644 --- a/Content.Server/NodeContainer/Nodes/PipeNode.cs +++ b/Content.Server/NodeContainer/Nodes/PipeNode.cs @@ -37,7 +37,7 @@ namespace Content.Server.NodeContainer.Nodes _alwaysReachable.Add(pipeNode); if (NodeGroup != null) - EntitySystem.Get().QueueRemakeGroup((BaseNodeGroup) NodeGroup); + IoCManager.Resolve().System().QueueRemakeGroup((BaseNodeGroup) NodeGroup); } public void RemoveAlwaysReachable(PipeNode pipeNode) @@ -47,7 +47,7 @@ namespace Content.Server.NodeContainer.Nodes _alwaysReachable.Remove(pipeNode); if (NodeGroup != null) - EntitySystem.Get().QueueRemakeGroup((BaseNodeGroup) NodeGroup); + IoCManager.Resolve().System().QueueRemakeGroup((BaseNodeGroup) NodeGroup); } /// @@ -62,7 +62,7 @@ namespace Content.Server.NodeContainer.Nodes _connectionsEnabled = value; if (NodeGroup != null) - EntitySystem.Get().QueueRemakeGroup((BaseNodeGroup) NodeGroup); + IoCManager.Resolve().System().QueueRemakeGroup((BaseNodeGroup) NodeGroup); } } diff --git a/Content.Server/Power/Commands/PowerStatCommand.cs b/Content.Server/Power/Commands/PowerStatCommand.cs index 440e40437b..127050393a 100644 --- a/Content.Server/Power/Commands/PowerStatCommand.cs +++ b/Content.Server/Power/Commands/PowerStatCommand.cs @@ -8,13 +8,15 @@ namespace Content.Server.Power.Commands [AdminCommand(AdminFlags.Debug)] public sealed class PowerStatCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _e = default!; + public string Command => "powerstat"; public string Description => "Shows statistics for pow3r"; public string Help => "Usage: powerstat"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var stats = EntitySystem.Get().GetStatistics(); + var stats = _e.System().GetStatistics(); shell.WriteLine($"networks: {stats.CountNetworks}"); shell.WriteLine($"loads: {stats.CountLoads}"); diff --git a/Content.Server/Power/PowerWireAction.cs b/Content.Server/Power/PowerWireAction.cs index 785eac91db..ac34966036 100644 --- a/Content.Server/Power/PowerWireAction.cs +++ b/Content.Server/Power/PowerWireAction.cs @@ -159,7 +159,7 @@ public sealed partial class PowerWireAction : BaseWireAction { base.Initialize(); - _electrocutionSystem = EntitySystem.Get(); + _electrocutionSystem = EntityManager.System(); } // This should add a wire into the entity's state, whether it be diff --git a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs index 6ce8edd1d8..d5dca64eaa 100644 --- a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs +++ b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs @@ -19,7 +19,7 @@ namespace Content.Server.Sandbox.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var sandboxManager = EntitySystem.Get(); + var sandboxManager = _entManager.System(); var adminManager = IoCManager.Resolve(); if (shell.IsClient && (!sandboxManager.IsSandboxEnabled && !adminManager.HasAdminFlag(shell.Player!, AdminFlags.Mapping))) { diff --git a/Content.Shared/Chemistry/Reaction/ITileReaction.cs b/Content.Shared/Chemistry/Reaction/ITileReaction.cs index 1f6a6bf307..af6cc34f48 100644 --- a/Content.Shared/Chemistry/Reaction/ITileReaction.cs +++ b/Content.Shared/Chemistry/Reaction/ITileReaction.cs @@ -6,6 +6,9 @@ namespace Content.Shared.Chemistry.Reaction { public interface ITileReaction { - FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume); + FixedPoint2 TileReact(TileRef tile, + ReagentPrototype reagent, + FixedPoint2 reactVolume, + IEntityManager entityManager); } } diff --git a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs index df1b1aa20b..6095676b9e 100644 --- a/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs +++ b/Content.Shared/Chemistry/Reagent/ReagentPrototype.cs @@ -142,7 +142,7 @@ namespace Content.Shared.Chemistry.Reagent [DataField] public SoundSpecifier FootstepSound = new SoundCollectionSpecifier("FootstepWater", AudioParams.Default.WithVolume(6)); - public FixedPoint2 ReactionTile(TileRef tile, FixedPoint2 reactVolume) + public FixedPoint2 ReactionTile(TileRef tile, FixedPoint2 reactVolume, IEntityManager entityManager) { var removed = FixedPoint2.Zero; @@ -151,7 +151,7 @@ namespace Content.Shared.Chemistry.Reagent foreach (var reaction in TileReactions) { - removed += reaction.TileReact(tile, this, reactVolume - removed); + removed += reaction.TileReact(tile, this, reactVolume - removed, entityManager); if (removed > reactVolume) throw new Exception("Removed more than we have!"); diff --git a/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs b/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs index 405c0ec89e..47ae3ef74a 100644 --- a/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs +++ b/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs @@ -49,10 +49,10 @@ namespace Content.Tests.Shared.Alert var alertsComponent = new AlertsComponent(); alertsComponent = IoCManager.InjectDependencies(alertsComponent); - Assert.That(EntitySystem.Get().TryGet(AlertType.LowPressure, out var lowpressure)); - Assert.That(EntitySystem.Get().TryGet(AlertType.HighPressure, out var highpressure)); + Assert.That(entManager.System().TryGet(AlertType.LowPressure, out var lowpressure)); + Assert.That(entManager.System().TryGet(AlertType.HighPressure, out var highpressure)); - EntitySystem.Get().ShowAlert(alertsComponent.Owner, AlertType.LowPressure, null, null); + entManager.System().ShowAlert(alertsComponent.Owner, AlertType.LowPressure, null, null); var getty = new ComponentGetState(); entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); @@ -62,7 +62,7 @@ namespace Content.Tests.Shared.Alert Assert.That(alertState.Alerts.Count, Is.EqualTo(1)); Assert.That(alertState.Alerts.ContainsKey(lowpressure.AlertKey)); - EntitySystem.Get().ShowAlert(alertsComponent.Owner, AlertType.HighPressure, null, null); + entManager.System().ShowAlert(alertsComponent.Owner, AlertType.HighPressure, null, null); // Lazy entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); @@ -70,7 +70,7 @@ namespace Content.Tests.Shared.Alert Assert.That(alertState.Alerts.Count, Is.EqualTo(1)); Assert.That(alertState.Alerts.ContainsKey(highpressure.AlertKey)); - EntitySystem.Get().ClearAlertCategory(alertsComponent.Owner, AlertCategory.Pressure); + entManager.System().ClearAlertCategory(alertsComponent.Owner, AlertCategory.Pressure); entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!;