From 749cd11d330a3e3396865d00b77e777f360a8177 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sat, 21 Nov 2020 14:02:00 +0100 Subject: [PATCH] Add readonly where it is missing and fix those field names according to their modifiers (#2589) --- Content.Client/Arcade/BlockGameMenu.cs | 39 ++++++-------- .../Arcade/SpaceVillainArcadeMenu.cs | 19 ++++--- Content.Client/Eui/EuiManager.cs | 2 +- .../Cargo/CargoOrderDatabaseComponent.cs | 2 +- .../Components/CloningPod/CloningPodWindow.cs | 4 +- .../Gravity/GravityGeneratorVisualizer.cs | 2 +- .../Components/Items/ItemComponent.cs | 2 +- .../Kitchen/MicrowaveBoundUserInterface.cs | 4 +- .../Components/LightBehaviourComponent.cs | 2 +- .../Components/Mobs/AlertControl.cs | 2 +- .../Components/Mobs/ClientAlertsComponent.cs | 5 +- .../Components/PDA/PDABoundUserInterface.cs | 12 ++--- .../ParticleAcceleratorPartVisualizer.cs | 2 +- .../SolarControlConsoleBoundUserInterface.cs | 13 +++-- .../Research/LatheBoundUserInterface.cs | 2 +- .../ResearchClientServerSelectionMenu.cs | 2 +- .../Storage/ClientStorageComponent.cs | 26 +++++----- .../VendingMachineVisualizer.cs | 2 +- .../GameObjects/Components/Wires/WiresMenu.cs | 4 +- .../AI/ClientPathfindingDebugSystem.cs | 4 +- .../EntitySystems/DoAfter/DoAfterBar.cs | 10 ++-- .../EntitySystems/DoAfter/DoAfterGui.cs | 18 +++---- .../EntitySystems/DoAfter/DoAfterSystem.cs | 2 +- .../EntitySystems/DragDropSystem.cs | 8 +-- .../EntitySystems/GasTileOverlaySystem.cs | 2 +- .../Graphics/Overlays/FlashOverlay.cs | 8 +-- Content.Client/Instruments/InstrumentMenu.cs | 35 ++++++------- Content.Client/Research/LatheMenu.cs | 52 +++++++++---------- Content.Client/Research/LatheQueueMenu.cs | 40 +++++++------- .../Research/ResearchConsoleMenu.cs | 24 ++++----- Content.Client/Sandbox/SandboxManager.cs | 26 +++++----- .../AdminMenu/AdminMenuWindow.cs | 2 +- .../UserInterface/Cargo/CargoConsoleMenu.cs | 2 +- .../Cargo/GalacticBankSelectionMenu.cs | 2 +- .../UserInterface/CooldownGraphic.cs | 2 +- Content.Client/UserInterface/LateJoinGui.cs | 8 +-- .../LobbyCharacterPreviewPanel.cs | 4 +- Content.Client/UserInterface/LobbyGui.cs | 4 +- .../ParticleAcceleratorControlMenu.cs | 2 +- .../Combat/Melee/SwingMeleeWeaponOperator.cs | 2 +- .../Combat/Melee/UnarmedCombatOperator.cs | 2 +- .../Movement/MoveToEntityOperator.cs | 12 ++--- .../Actions/Clothing/Gloves/EquipGloves.cs | 4 +- .../Actions/Clothing/Head/EquipHead.cs | 2 +- .../OuterClothing/EquipOuterClothing.cs | 2 +- .../Actions/Clothing/Shoes/EquipShoes.cs | 2 +- .../Actions/Combat/Melee/EquipMelee.cs | 2 +- .../Combat/Melee/MeleeWeaponAttackEntity.cs | 4 +- .../Actions/Combat/Melee/PickUpMeleeWeapon.cs | 4 +- .../Combat/Melee/UnarmedAttackEntity.cs | 6 +-- .../Actions/Nutrition/Drink/PickUpDrink.cs | 8 +-- .../Nutrition/Drink/UseDrinkInInventory.cs | 8 +-- .../Actions/Nutrition/Food/PickUpFood.cs | 6 +-- .../Nutrition/Food/UseFoodInInventory.cs | 8 +-- .../Considerations/ConsiderationsManager.cs | 8 +-- .../AI/WorldState/BlackboardManager.cs | 6 +-- Content.Server/Administration/AdminManager.cs | 2 +- .../Atmos/HighPressureMovementController.cs | 4 +- Content.Server/Cargo/CargoOrderDatabase.cs | 6 +-- .../Arcade/BlockGameArcadeComponent.cs | 12 +++-- .../Arcade/SpaceVillainArcadeComponent.cs | 42 +++++++-------- .../DamageOnHighSpeedImpactComponent.cs | 4 +- .../Components/Doors/ServerDoorComponent.cs | 3 +- .../Storage/CursedEntityStorageComponent.cs | 3 +- .../Markers/ConditionalSpawnerComponent.cs | 3 +- .../Morgue/BodyBagEntityStorageComponent.cs | 2 +- .../NodeContainer/NodeGroups/AMENodeGroup.cs | 2 +- .../Components/Nutrition/HungerComponent.cs | 3 +- .../PoweredLightComponent.cs | 2 +- .../Components/Recycling/RecyclerComponent.cs | 5 +- .../Singularity/ContainmentFieldConnection.cs | 4 +- .../ContainmentFieldGeneratorComponent.cs | 8 +-- .../Singularity/EmitterComponent.cs | 5 +- .../Singularity/SingularityComponent.cs | 15 ++---- .../Ammunition/RangedMagazineComponent.cs | 2 +- .../EntitySystems/AI/AiFactionTagSystem.cs | 2 +- .../Accessible/AiReachableSystem.cs | 6 +-- .../Pathfinders/AStarPathfindingJob.cs | 4 +- .../Pathfinders/JpsPathfindingJob.cs | 4 +- .../AI/Pathfinding/PathfindingChunk.cs | 2 +- .../Steering/EntityTargetSteeringRequest.cs | 2 +- .../Atmos/GasTileOverlaySystem.cs | 17 +++--- .../EntitySystems/DoAfter/DoAfter.cs | 4 +- .../GameObjects/EntitySystems/DoorSystem.cs | 6 +-- .../EntitySystems/EmergencyLightSystem.cs | 4 +- .../StationEvents/StationEventSystem.cs | 2 +- Content.Server/GameTicking/GameTicker.cs | 18 +++---- .../StationEvents/PowerGridCheck.cs | 16 +++--- Content.Shared/Alert/AlertOrderPrototype.cs | 7 ++- .../ConstructionGraphPrototype.cs | 2 +- .../Body/Part/SharedBodyPartComponent.cs | 2 +- .../Research/SharedLatheDatabaseComponent.cs | 2 +- .../SharedProtolatheDatabaseComponent.cs | 2 +- Content.Shared/Physics/FrictionController.cs | 2 +- 94 files changed, 344 insertions(+), 374 deletions(-) diff --git a/Content.Client/Arcade/BlockGameMenu.cs b/Content.Client/Arcade/BlockGameMenu.cs index 7dc8776c9e..cada939096 100644 --- a/Content.Client/Arcade/BlockGameMenu.cs +++ b/Content.Client/Arcade/BlockGameMenu.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Net.Mime; using Content.Client.GameObjects.Components.Arcade; using Content.Client.Utility; using Content.Shared.Arcade; -using Content.Shared.GameObjects.Components.Arcade; using Content.Shared.Input; using Robust.Client.Graphics; using Robust.Client.Graphics.Drawing; @@ -13,7 +10,6 @@ using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; -using Robust.Shared.Input; using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Utility; @@ -22,15 +18,14 @@ namespace Content.Client.Arcade { public class BlockGameMenu : SS14Window { + private static readonly Color OverlayBackgroundColor = new Color(74,74,81,180); + private static readonly Color OverlayShadowColor = new Color(0,0,0,83); - private static Color overlayBackgroundColor = new Color(74,74,81,180); - private static Color overlayShadowColor = new Color(0,0,0,83); + private static readonly Vector2 BlockSize = new Vector2(15,15); - private static Vector2 blockSize = new Vector2(15,15); + private readonly BlockGameBoundUserInterface _owner; - private BlockGameBoundUserInterface _owner; - - private PanelContainer _mainPanel; + private readonly PanelContainer _mainPanel; private VBoxContainer _gameRootContainer; private GridContainer _gameGrid; @@ -88,7 +83,7 @@ namespace Content.Client.Arcade var rootBack = new StyleBoxTexture { Texture = backgroundTexture, - Modulate = overlayShadowColor + Modulate = OverlayShadowColor }; rootBack.SetPatchMargin(StyleBox.Margin.All, 10); _highscoresRootContainer = new PanelContainer @@ -98,7 +93,7 @@ namespace Content.Client.Arcade SizeFlagsHorizontal = SizeFlags.ShrinkCenter }; - var c = new Color(overlayBackgroundColor.R,overlayBackgroundColor.G,overlayBackgroundColor.B,220); + var c = new Color(OverlayBackgroundColor.R,OverlayBackgroundColor.G,OverlayBackgroundColor.B,220); var innerBack = new StyleBoxTexture { Texture = backgroundTexture, @@ -154,7 +149,7 @@ namespace Content.Client.Arcade var rootBack = new StyleBoxTexture { Texture = backgroundTexture, - Modulate = overlayShadowColor + Modulate = OverlayShadowColor }; rootBack.SetPatchMargin(StyleBox.Margin.All, 10); _gameOverRootContainer = new PanelContainer @@ -167,7 +162,7 @@ namespace Content.Client.Arcade var innerBack = new StyleBoxTexture { Texture = backgroundTexture, - Modulate = overlayBackgroundColor + Modulate = OverlayBackgroundColor }; innerBack.SetPatchMargin(StyleBox.Margin.All, 10); var menuInnerPanel = new PanelContainer @@ -212,7 +207,7 @@ namespace Content.Client.Arcade var rootBack = new StyleBoxTexture { Texture = backgroundTexture, - Modulate = overlayShadowColor + Modulate = OverlayShadowColor }; rootBack.SetPatchMargin(StyleBox.Margin.All, 10); _menuRootContainer = new PanelContainer @@ -225,7 +220,7 @@ namespace Content.Client.Arcade var innerBack = new StyleBoxTexture { Texture = backgroundTexture, - Modulate = overlayBackgroundColor + Modulate = OverlayBackgroundColor }; innerBack.SetPatchMargin(StyleBox.Margin.All, 10); var menuInnerPanel = new PanelContainer @@ -404,7 +399,7 @@ namespace Content.Client.Arcade var nextBlockPanel = new PanelContainer { PanelOverride = previewBack, - CustomMinimumSize = blockSize * 6.5f, + CustomMinimumSize = BlockSize * 6.5f, SizeFlagsHorizontal = SizeFlags.None, SizeFlagsVertical = SizeFlags.None }; @@ -442,7 +437,7 @@ namespace Content.Client.Arcade var holdBlockPanel = new PanelContainer { PanelOverride = previewBack, - CustomMinimumSize = blockSize * 6.5f, + CustomMinimumSize = BlockSize * 6.5f, SizeFlagsHorizontal = SizeFlags.None, SizeFlagsVertical = SizeFlags.None }; @@ -623,7 +618,7 @@ namespace Content.Client.Arcade _nextBlockGrid.AddChild(new PanelContainer { PanelOverride = new StyleBoxFlat {BackgroundColor = c}, - CustomMinimumSize = blockSize, + CustomMinimumSize = BlockSize, RectDrawClipMargin = 0 }); } @@ -645,7 +640,7 @@ namespace Content.Client.Arcade _holdBlockGrid.AddChild(new PanelContainer { PanelOverride = new StyleBoxFlat {BackgroundColor = c}, - CustomMinimumSize = blockSize, + CustomMinimumSize = BlockSize, RectDrawClipMargin = 0 }); } @@ -663,7 +658,7 @@ namespace Content.Client.Arcade _gameGrid.AddChild(new PanelContainer { PanelOverride = new StyleBoxFlat {BackgroundColor = c}, - CustomMinimumSize = blockSize, + CustomMinimumSize = BlockSize, RectDrawClipMargin = 0 }); } diff --git a/Content.Client/Arcade/SpaceVillainArcadeMenu.cs b/Content.Client/Arcade/SpaceVillainArcadeMenu.cs index 529d4b6fa7..e8897e7ebd 100644 --- a/Content.Client/Arcade/SpaceVillainArcadeMenu.cs +++ b/Content.Client/Arcade/SpaceVillainArcadeMenu.cs @@ -1,5 +1,4 @@ -using System.Linq; -using Content.Client.GameObjects.Components.Arcade; +using Content.Client.GameObjects.Components.Arcade; using Content.Shared.GameObjects.Components.Arcade; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; @@ -13,13 +12,13 @@ namespace Content.Client.Arcade protected override Vector2? CustomSize => (400, 200); public SpaceVillainArcadeBoundUserInterface Owner { get; set; } - private Label _enemyNameLabel; - private Label _playerInfoLabel; - private Label _enemyInfoLabel; - private Label _playerActionLabel; - private Label _enemyActionLabel; + private readonly Label _enemyNameLabel; + private readonly Label _playerInfoLabel; + private readonly Label _enemyInfoLabel; + private readonly Label _playerActionLabel; + private readonly Label _enemyActionLabel; - private Button[] _gameButtons = new Button[3]; //used to disable/enable all game buttons + private readonly Button[] _gameButtons = new Button[3]; //used to disable/enable all game buttons public SpaceVillainArcadeMenu(SpaceVillainArcadeBoundUserInterface owner) { Title = Loc.GetString("Space Villain"); @@ -97,8 +96,8 @@ namespace Content.Client.Arcade private class ActionButton : Button { - private SpaceVillainArcadeBoundUserInterface _owner; - private SharedSpaceVillainArcadeComponent.PlayerAction _playerAction; + private readonly SpaceVillainArcadeBoundUserInterface _owner; + private readonly SharedSpaceVillainArcadeComponent.PlayerAction _playerAction; public ActionButton(SpaceVillainArcadeBoundUserInterface owner,SharedSpaceVillainArcadeComponent.PlayerAction playerAction) { diff --git a/Content.Client/Eui/EuiManager.cs b/Content.Client/Eui/EuiManager.cs index 60e4d84047..3831f0b766 100644 --- a/Content.Client/Eui/EuiManager.cs +++ b/Content.Client/Eui/EuiManager.cs @@ -62,7 +62,7 @@ namespace Content.Client.Eui private sealed class EuiData { - public BaseEui Eui; + public readonly BaseEui Eui; public EuiData(BaseEui eui) { diff --git a/Content.Client/GameObjects/Components/Cargo/CargoOrderDatabaseComponent.cs b/Content.Client/GameObjects/Components/Cargo/CargoOrderDatabaseComponent.cs index c29e62464b..baad228915 100644 --- a/Content.Client/GameObjects/Components/Cargo/CargoOrderDatabaseComponent.cs +++ b/Content.Client/GameObjects/Components/Cargo/CargoOrderDatabaseComponent.cs @@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Cargo [RegisterComponent] public class CargoOrderDatabaseComponent : SharedCargoOrderDatabaseComponent { - private List _orders = new List(); + private readonly List _orders = new List(); public IReadOnlyList Orders => _orders; /// diff --git a/Content.Client/GameObjects/Components/CloningPod/CloningPodWindow.cs b/Content.Client/GameObjects/Components/CloningPod/CloningPodWindow.cs index accc6363c6..04e638ccc5 100644 --- a/Content.Client/GameObjects/Components/CloningPod/CloningPodWindow.cs +++ b/Content.Client/GameObjects/Components/CloningPod/CloningPodWindow.cs @@ -25,9 +25,9 @@ namespace Content.Client.GameObjects.Components.CloningPod public readonly Button EjectButton; private readonly CloningScanButton _measureButton; private CloningScanButton? _selectedButton; - private Label _progressLabel; + private readonly Label _progressLabel; private readonly ProgressBar _cloningProgressBar; - private Label _mindState; + private readonly Label _mindState; protected override Vector2 ContentsMinimumSize => _mainVBox?.CombinedMinimumSize ?? Vector2.Zero; private CloningPodBoundUserInterfaceState _lastUpdate = null!; diff --git a/Content.Client/GameObjects/Components/Gravity/GravityGeneratorVisualizer.cs b/Content.Client/GameObjects/Components/Gravity/GravityGeneratorVisualizer.cs index 0862d7725b..60eb02d45b 100644 --- a/Content.Client/GameObjects/Components/Gravity/GravityGeneratorVisualizer.cs +++ b/Content.Client/GameObjects/Components/Gravity/GravityGeneratorVisualizer.cs @@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.Components.Gravity { public class GravityGeneratorVisualizer : AppearanceVisualizer { - private Dictionary _spriteMap = new Dictionary(); + private readonly Dictionary _spriteMap = new Dictionary(); public override void InitializeEntity(IEntity entity) { diff --git a/Content.Client/GameObjects/Components/Items/ItemComponent.cs b/Content.Client/GameObjects/Components/Items/ItemComponent.cs index 42acb64a2e..07a5c33c9a 100644 --- a/Content.Client/GameObjects/Components/Items/ItemComponent.cs +++ b/Content.Client/GameObjects/Components/Items/ItemComponent.cs @@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Items [ComponentReference(typeof(IItemComponent))] public class ItemComponent : Component, IItemComponent, IDraggable { - [Dependency] private IResourceCache _resourceCache = default!; + [Dependency] private readonly IResourceCache _resourceCache = default!; public override string Name => "Item"; public override uint? NetID => ContentNetIDs.ITEM; diff --git a/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs b/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs index b838914889..802a410699 100644 --- a/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs @@ -26,8 +26,8 @@ namespace Content.Client.GameObjects.Components.Kitchen private MicrowaveMenu _menu; - private Dictionary _solids = new Dictionary(); - private Dictionary _reagents =new Dictionary(); + private readonly Dictionary _solids = new Dictionary(); + private readonly Dictionary _reagents =new Dictionary(); public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey) { diff --git a/Content.Client/GameObjects/Components/LightBehaviourComponent.cs b/Content.Client/GameObjects/Components/LightBehaviourComponent.cs index 70dc1fc695..d15ecf5bc9 100644 --- a/Content.Client/GameObjects/Components/LightBehaviourComponent.cs +++ b/Content.Client/GameObjects/Components/LightBehaviourComponent.cs @@ -361,7 +361,7 @@ namespace Content.Client.GameObjects.Components } [ViewVariables(VVAccess.ReadOnly)] - private List _animations = new List(); + private readonly List _animations = new List(); private float _originalRadius = default; private float _originalEnergy = default; diff --git a/Content.Client/GameObjects/Components/Mobs/AlertControl.cs b/Content.Client/GameObjects/Components/Mobs/AlertControl.cs index b799783594..b723550d33 100644 --- a/Content.Client/GameObjects/Components/Mobs/AlertControl.cs +++ b/Content.Client/GameObjects/Components/Mobs/AlertControl.cs @@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Mobs private short? _severity; private readonly TextureRect _icon; - private CooldownGraphic _cooldownGraphic; + private readonly CooldownGraphic _cooldownGraphic; private readonly IResourceCache _resourceCache; diff --git a/Content.Client/GameObjects/Components/Mobs/ClientAlertsComponent.cs b/Content.Client/GameObjects/Components/Mobs/ClientAlertsComponent.cs index 8dbbed08b5..15bce99a2a 100644 --- a/Content.Client/GameObjects/Components/Mobs/ClientAlertsComponent.cs +++ b/Content.Client/GameObjects/Components/Mobs/ClientAlertsComponent.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using Content.Client.UserInterface; using Content.Client.UserInterface.Stylesheets; -using Content.Client.Utility; using Content.Shared.Alert; using Content.Shared.GameObjects.Components.Mobs; using Robust.Client.GameObjects; @@ -19,11 +18,9 @@ using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Log; -using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; -using Serilog; namespace Content.Client.GameObjects.Components.Mobs { @@ -47,7 +44,7 @@ namespace Content.Client.GameObjects.Components.Mobs private bool _tooltipReady; [ViewVariables] - private Dictionary _alertControls + private readonly Dictionary _alertControls = new Dictionary(); /// diff --git a/Content.Client/GameObjects/Components/PDA/PDABoundUserInterface.cs b/Content.Client/GameObjects/Components/PDA/PDABoundUserInterface.cs index 1ba1ce1eea..1bfcee4f8e 100644 --- a/Content.Client/GameObjects/Components/PDA/PDABoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/PDA/PDABoundUserInterface.cs @@ -228,7 +228,7 @@ namespace Content.Client.GameObjects.Components.PDA public Button EjectIDButton { get; } public Button EjectPenButton { get; } - public TabContainer MasterTabContainer; + public readonly TabContainer MasterTabContainer; public RichTextLabel PDAOwnerLabel { get; } public PanelContainer IDInfoContainer { get; } @@ -236,14 +236,14 @@ namespace Content.Client.GameObjects.Components.PDA public VBoxContainer UplinkTabContainer { get; } - protected HSplitContainer CategoryAndListingsContainer; + protected readonly HSplitContainer CategoryAndListingsContainer; - private IPrototypeManager _prototypeManager; + private readonly IPrototypeManager _prototypeManager; - public VBoxContainer UplinkListingsContainer; + public readonly VBoxContainer UplinkListingsContainer; - public VBoxContainer CategoryListContainer; - public RichTextLabel BalanceInfo; + public readonly VBoxContainer CategoryListContainer; + public readonly RichTextLabel BalanceInfo; public event Action OnListingButtonPressed; public event Action OnCategoryButtonPressed; diff --git a/Content.Client/GameObjects/Components/ParticleAcceleratorPartVisualizer.cs b/Content.Client/GameObjects/Components/ParticleAcceleratorPartVisualizer.cs index 6ff0ed061a..e2e2dc8be2 100644 --- a/Content.Client/GameObjects/Components/ParticleAcceleratorPartVisualizer.cs +++ b/Content.Client/GameObjects/Components/ParticleAcceleratorPartVisualizer.cs @@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components { public class ParticleAcceleratorPartVisualizer : AppearanceVisualizer { - private Dictionary _states = new Dictionary(); + private readonly Dictionary _states = new Dictionary(); public override void LoadData(YamlMappingNode node) { diff --git a/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs b/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs index 17ce456aff..c892f1cd90 100644 --- a/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs @@ -14,8 +14,7 @@ namespace Content.Client.GameObjects.Components.Power { public class SolarControlConsoleBoundUserInterface : BoundUserInterface { - [Dependency] - private IGameTiming _gameTiming = default; + [Dependency] private readonly IGameTiming _gameTiming = default; private SolarControlWindow _window; private SolarControlConsoleBoundInterfaceState _lastState = new SolarControlConsoleBoundInterfaceState(0, 0, 0, 0); @@ -93,13 +92,13 @@ namespace Content.Client.GameObjects.Components.Power private sealed class SolarControlWindow : SS14Window { - public Label OutputPower; - public Label SunAngle; + public readonly Label OutputPower; + public readonly Label SunAngle; - public SolarControlNotARadar NotARadar; + public readonly SolarControlNotARadar NotARadar; - public LineEdit PanelRotation; - public LineEdit PanelVelocity; + public readonly LineEdit PanelRotation; + public readonly LineEdit PanelVelocity; public SolarControlWindow(IGameTiming igt) { diff --git a/Content.Client/GameObjects/Components/Research/LatheBoundUserInterface.cs b/Content.Client/GameObjects/Components/Research/LatheBoundUserInterface.cs index 923b798e39..49f7169f67 100644 --- a/Content.Client/GameObjects/Components/Research/LatheBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Research/LatheBoundUserInterface.cs @@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Research [ViewVariables] public Queue QueuedRecipes => _queuedRecipes; - private Queue _queuedRecipes = new Queue(); + private readonly Queue _queuedRecipes = new Queue(); public LatheBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { diff --git a/Content.Client/GameObjects/Components/Research/ResearchClientServerSelectionMenu.cs b/Content.Client/GameObjects/Components/Research/ResearchClientServerSelectionMenu.cs index 052f48c452..4b76477d58 100644 --- a/Content.Client/GameObjects/Components/Research/ResearchClientServerSelectionMenu.cs +++ b/Content.Client/GameObjects/Components/Research/ResearchClientServerSelectionMenu.cs @@ -8,7 +8,7 @@ namespace Content.Client.GameObjects.Components.Research { public class ResearchClientServerSelectionMenu : SS14Window { - private ItemList _servers; + private readonly ItemList _servers; private int _serverCount = 0; private string[] _serverNames = new string[]{}; private int[] _serverIds = new int[]{}; diff --git a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs index f3607ae1d2..94d8e1e8d4 100644 --- a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs +++ b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs @@ -134,12 +134,12 @@ namespace Content.Client.GameObjects.Components.Storage private class StorageWindow : SS14Window { private Control VSplitContainer; - private VBoxContainer EntityList; - private Label Information; + private readonly VBoxContainer _entityList; + private readonly Label _information; public ClientStorageComponent StorageEntity; - private StyleBoxFlat _HoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.35f) }; - private StyleBoxFlat _unHoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.0f) }; + private readonly StyleBoxFlat _hoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.35f) }; + private readonly StyleBoxFlat _unHoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.0f) }; protected override Vector2? CustomSize => (180, 320); @@ -179,12 +179,12 @@ namespace Content.Client.GameObjects.Components.Storage MouseFilter = MouseFilterMode.Ignore, }; containerButton.AddChild(VSplitContainer); - Information = new Label + _information = new Label { Text = "Items: 0 Volume: 0/0 Stuff", SizeFlagsVertical = SizeFlags.ShrinkCenter }; - VSplitContainer.AddChild(Information); + VSplitContainer.AddChild(_information); var listScrollContainer = new ScrollContainer { @@ -193,18 +193,18 @@ namespace Content.Client.GameObjects.Components.Storage HScrollEnabled = true, VScrollEnabled = true, }; - EntityList = new VBoxContainer + _entityList = new VBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand }; - listScrollContainer.AddChild(EntityList); + listScrollContainer.AddChild(_entityList); VSplitContainer.AddChild(listScrollContainer); Contents.AddChild(containerButton); listScrollContainer.OnMouseEntered += args => { - innerContainerButton.PanelOverride = _HoveredBox; + innerContainerButton.PanelOverride = _hoveredBox; }; listScrollContainer.OnMouseExited += args => @@ -224,7 +224,7 @@ namespace Content.Client.GameObjects.Components.Storage /// public void BuildEntityList() { - EntityList.DisposeAllChildren(); + _entityList.DisposeAllChildren(); var storageList = StorageEntity.StoredEntities; @@ -254,18 +254,18 @@ namespace Content.Client.GameObjects.Components.Storage button.EntitySpriteView.Sprite = sprite; } - EntityList.AddChild(button); + _entityList.AddChild(button); } //Sets information about entire storage container current capacity if (StorageEntity.StorageCapacityMax != 0) { - Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storageList.Count, + _information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storageList.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax); } else { - Information.Text = String.Format("Items: {0}", storageList.Count); + _information.Text = String.Format("Items: {0}", storageList.Count); } } diff --git a/Content.Client/GameObjects/Components/VendingMachines/VendingMachineVisualizer.cs b/Content.Client/GameObjects/Components/VendingMachines/VendingMachineVisualizer.cs index a91136b6c7..9b8f363df3 100644 --- a/Content.Client/GameObjects/Components/VendingMachines/VendingMachineVisualizer.cs +++ b/Content.Client/GameObjects/Components/VendingMachines/VendingMachineVisualizer.cs @@ -39,7 +39,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines {"broken", VendingMachineVisualLayers.Unlit}, }; - private Dictionary _animations = new Dictionary(); + private readonly Dictionary _animations = new Dictionary(); public override void LoadData(YamlMappingNode node) { diff --git a/Content.Client/GameObjects/Components/Wires/WiresMenu.cs b/Content.Client/GameObjects/Components/Wires/WiresMenu.cs index 7469f31a8d..9999f35bf2 100644 --- a/Content.Client/GameObjects/Components/Wires/WiresMenu.cs +++ b/Content.Client/GameObjects/Components/Wires/WiresMenu.cs @@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Wires { public class WiresMenu : BaseWindow { - [Dependency] private IResourceCache _resourceCache = default!; + [Dependency] private readonly IResourceCache _resourceCache = default!; public WiresBoundUserInterface Owner { get; } @@ -424,7 +424,7 @@ namespace Content.Client.GameObjects.Components.Wires "/Textures/Interface/WireHacking/wire_2_copper.svg.96dpi.png" }; - private IResourceCache _resourceCache; + private readonly IResourceCache _resourceCache; public WireRender(WireColor color, bool isCut, bool flip, bool mirror, int type, IResourceCache resourceCache) { diff --git a/Content.Client/GameObjects/EntitySystems/AI/ClientPathfindingDebugSystem.cs b/Content.Client/GameObjects/EntitySystems/AI/ClientPathfindingDebugSystem.cs index c1c0addaa8..9b80244405 100644 --- a/Content.Client/GameObjects/EntitySystems/AI/ClientPathfindingDebugSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/AI/ClientPathfindingDebugSystem.cs @@ -169,8 +169,8 @@ namespace Content.Client.GameObjects.EntitySystems.AI internal sealed class DebugPathfindingOverlay : Overlay { - private IEyeManager _eyeManager; - private IPlayerManager _playerManager; + private readonly IEyeManager _eyeManager; + private readonly IPlayerManager _playerManager; // TODO: Add a box like the debug one and show the most recent path stuff public override OverlaySpace Space => OverlaySpace.ScreenSpace; diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs index b6a1af64da..172c05d047 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs @@ -14,8 +14,8 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter public sealed class DoAfterBar : Control { private IGameTiming _gameTiming = default!; - - private ShaderInstance _shader; + + private readonly ShaderInstance _shader; /// /// Set from 0.0f to 1.0f to reflect bar progress @@ -40,13 +40,13 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter { return; } - + _cancelled = value; if (_cancelled) { _gameTiming = IoCManager.Resolve(); _lastFlash = _gameTiming.CurTime; - } + } } } @@ -87,7 +87,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter _lastFlash = _gameTiming.CurTime; _flash = !_flash; } - } + } } protected override void Draw(DrawingHandleScreen handle) diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs index 5228ab4bd1..ec87507a76 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs @@ -21,11 +21,11 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; - private Dictionary _doAfterControls = new Dictionary(); - private Dictionary _doAfterBars = new Dictionary(); + private readonly Dictionary _doAfterControls = new Dictionary(); + private readonly Dictionary _doAfterBars = new Dictionary(); // We'll store cancellations for a little bit just so we can flash the graphic to indicate it's cancelled - private Dictionary _cancelledDoAfters = new Dictionary(); + private readonly Dictionary _cancelledDoAfters = new Dictionary(); public IEntity? AttachedEntity { get; set; } private ScreenCoordinates _playerPosition; @@ -48,12 +48,12 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter base.Dispose(disposing); if (Disposed) return; - + foreach (var (_, control) in _doAfterControls) { control.Dispose(); } - + _doAfterControls.Clear(); _doAfterBars.Clear(); _cancelledDoAfters.Clear(); @@ -109,10 +109,10 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter RemoveChild(control); _doAfterControls.Remove(id); _doAfterBars.Remove(id); - + if (_cancelledDoAfters.ContainsKey(id)) _cancelledDoAfters.Remove(id); - + } /// @@ -130,7 +130,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter doAfterBar = new DoAfterBar(); _doAfterBars[id] = doAfterBar; } - + doAfterBar.Cancelled = true; _cancelledDoAfters.Add(id, _gameTiming.CurTime); } @@ -139,7 +139,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter { base.FrameUpdate(args); - if (AttachedEntity?.IsValid() != true || + if (AttachedEntity?.IsValid() != true || !AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent)) { return; diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs index 4a89a54b78..28d350b880 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs @@ -35,7 +35,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter // Each component in range will have its own vBox which we need to keep track of so if they go out of range or // come into range it needs altering - private HashSet _knownComponents = new HashSet(); + private readonly HashSet _knownComponents = new HashSet(); private IEntity? _attachedEntity; diff --git a/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs b/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs index a145bbacff..2288e33936 100644 --- a/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/DragDropSystem.cs @@ -71,7 +71,7 @@ namespace Content.Client.GameObjects.EntitySystems private SharedInteractionSystem _interactionSystem; private InputSystem _inputSystem; - private List highlightedSprites = new List(); + private readonly List _highlightedSprites = new List(); private enum DragState { @@ -298,7 +298,7 @@ namespace Content.Client.GameObjects.EntitySystems var inRange = _interactionSystem.InRangeUnobstructed(_dragger, pvsEntity); inRangeSprite.PostShader = inRange ? _dropTargetInRangeShader : _dropTargetOutOfRangeShader; inRangeSprite.RenderOrder = EntityManager.CurrentTick.Value; - highlightedSprites.Add(inRangeSprite); + _highlightedSprites.Add(inRangeSprite); } } } @@ -306,12 +306,12 @@ namespace Content.Client.GameObjects.EntitySystems private void RemoveHighlights() { - foreach (var highlightedSprite in highlightedSprites) + foreach (var highlightedSprite in _highlightedSprites) { highlightedSprite.PostShader = null; highlightedSprite.RenderOrder = 0; } - highlightedSprites.Clear(); + _highlightedSprites.Clear(); } /// diff --git a/Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs b/Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs index e235c2f06e..1c9afa5b3e 100644 --- a/Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs @@ -41,7 +41,7 @@ namespace Content.Client.GameObjects.EntitySystems private readonly int[] _fireFrameCounter = new int[FireStates]; private readonly Texture[][] _fireFrames = new Texture[FireStates][]; - private Dictionary> _tileData = + private readonly Dictionary> _tileData = new Dictionary>(); private AtmosphereSystem _atmosphereSystem = default!; diff --git a/Content.Client/Graphics/Overlays/FlashOverlay.cs b/Content.Client/Graphics/Overlays/FlashOverlay.cs index d8c37ad376..278e2c0884 100644 --- a/Content.Client/Graphics/Overlays/FlashOverlay.cs +++ b/Content.Client/Graphics/Overlays/FlashOverlay.cs @@ -22,8 +22,8 @@ namespace Content.Client.Graphics.Overlays public override OverlaySpace Space => OverlaySpace.ScreenSpace; private readonly ShaderInstance _shader; - private double _startTime; - private int lastsFor = 5000; + private readonly double _startTime; + private int _lastsFor = 5000; private Texture _screenshotTexture; public FlashOverlay() : base(nameof(SharedOverlayID.FlashOverlay)) @@ -42,7 +42,7 @@ namespace Content.Client.Graphics.Overlays protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace) { handle.UseShader(_shader); - var percentComplete = (float) ((_gameTiming.CurTime.TotalMilliseconds - _startTime) / lastsFor); + var percentComplete = (float) ((_gameTiming.CurTime.TotalMilliseconds - _startTime) / _lastsFor); _shader?.SetParameter("percentComplete", percentComplete); var screenSpaceHandle = handle as DrawingHandleScreen; @@ -63,7 +63,7 @@ namespace Content.Client.Graphics.Overlays public void Configure(TimedOverlayParameter parameters) { - lastsFor = parameters.Length; + _lastsFor = parameters.Length; } } } diff --git a/Content.Client/Instruments/InstrumentMenu.cs b/Content.Client/Instruments/InstrumentMenu.cs index 1612aec48f..9c9769f7c6 100644 --- a/Content.Client/Instruments/InstrumentMenu.cs +++ b/Content.Client/Instruments/InstrumentMenu.cs @@ -1,7 +1,6 @@ using Content.Client.GameObjects.Components.Instruments; using Content.Client.UserInterface.Stylesheets; using Content.Client.Utility; -using Content.Shared.GameObjects.EntitySystems; using Robust.Client.Audio.Midi; using Robust.Client.Graphics.Drawing; using Robust.Client.Interfaces.UserInterface; @@ -23,10 +22,10 @@ namespace Content.Client.Instruments [Dependency] private readonly IMidiManager _midiManager = default!; [Dependency] private readonly IFileDialogManager _fileDialogManager = default!; - private InstrumentBoundUserInterface _owner; - private Button midiLoopButton; - private Button midiStopButton; - private Button midiInputButton; + private readonly InstrumentBoundUserInterface _owner; + private readonly Button _midiLoopButton; + private readonly Button _midiStopButton; + private readonly Button _midiInputButton; protected override Vector2? CustomSize => (400, 150); @@ -59,7 +58,7 @@ namespace Content.Client.Instruments Align = BoxContainer.AlignMode.Center }; - midiInputButton = new Button() + _midiInputButton = new Button() { Text = Loc.GetString("MIDI Input"), TextAlign = Label.AlignMode.Center, @@ -69,7 +68,7 @@ namespace Content.Client.Instruments Pressed = _owner.Instrument.IsInputOpen, }; - midiInputButton.OnToggled += MidiInputButtonOnOnToggled; + _midiInputButton.OnToggled += MidiInputButtonOnOnToggled; var topSpacer = new Control() { @@ -95,7 +94,7 @@ namespace Content.Client.Instruments Align = BoxContainer.AlignMode.Center }; - midiLoopButton = new Button() + _midiLoopButton = new Button() { Text = Loc.GetString("Loop"), TextAlign = Label.AlignMode.Center, @@ -106,7 +105,7 @@ namespace Content.Client.Instruments Pressed = _owner.Instrument.LoopMidi, }; - midiLoopButton.OnToggled += MidiLoopButtonOnOnToggled; + _midiLoopButton.OnToggled += MidiLoopButtonOnOnToggled; var bottomSpacer = new Control() { @@ -114,7 +113,7 @@ namespace Content.Client.Instruments SizeFlagsStretchRatio = 2, }; - midiStopButton = new Button() + _midiStopButton = new Button() { Text = Loc.GetString("Stop"), TextAlign = Label.AlignMode.Center, @@ -123,13 +122,13 @@ namespace Content.Client.Instruments Disabled = !_owner.Instrument.IsMidiOpen, }; - midiStopButton.OnPressed += MidiStopButtonOnPressed; + _midiStopButton.OnPressed += MidiStopButtonOnPressed; - hBoxBottomButtons.AddChild(midiLoopButton); + hBoxBottomButtons.AddChild(_midiLoopButton); hBoxBottomButtons.AddChild(bottomSpacer); - hBoxBottomButtons.AddChild(midiStopButton); + hBoxBottomButtons.AddChild(_midiStopButton); - hBoxTopButtons.AddChild(midiInputButton); + hBoxTopButtons.AddChild(_midiInputButton); hBoxTopButtons.AddChild(topSpacer); hBoxTopButtons.AddChild(midiFileButton); @@ -168,8 +167,8 @@ namespace Content.Client.Instruments public void MidiPlaybackSetButtonsDisabled(bool disabled) { - midiLoopButton.Disabled = disabled; - midiStopButton.Disabled = disabled; + _midiLoopButton.Disabled = disabled; + _midiStopButton.Disabled = disabled; } private async void MidiFileButtonOnOnPressed(BaseButton.ButtonEventArgs obj) @@ -195,8 +194,8 @@ namespace Content.Client.Instruments await Timer.Delay(100); if (!_owner.Instrument.OpenMidi(filename)) return; MidiPlaybackSetButtonsDisabled(false); - if (midiInputButton.Pressed) - midiInputButton.Pressed = false; + if (_midiInputButton.Pressed) + _midiInputButton.Pressed = false; } private void MidiInputButtonOnOnToggled(BaseButton.ButtonToggledEventArgs obj) diff --git a/Content.Client/Research/LatheMenu.cs b/Content.Client/Research/LatheMenu.cs index c275be681b..bbb7407111 100644 --- a/Content.Client/Research/LatheMenu.cs +++ b/Content.Client/Research/LatheMenu.cs @@ -16,10 +16,10 @@ namespace Content.Client.Research { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - private ItemList Items; - private ItemList Materials; - private LineEdit AmountLineEdit; - private LineEdit SearchBar; + private readonly ItemList _items; + private readonly ItemList _materials; + private readonly LineEdit _amountLineEdit; + private readonly LineEdit _searchBar; public Button QueueButton; public Button ServerConnectButton; public Button ServerSyncButton; @@ -27,8 +27,8 @@ namespace Content.Client.Research public LatheBoundUserInterface Owner { get; set; } - private List _recipes = new List(); - private List _shownRecipes = new List(); + private readonly List _recipes = new List(); + private readonly List _shownRecipes = new List(); public LatheMenu(LatheBoundUserInterface owner = null) { @@ -94,14 +94,14 @@ namespace Content.Client.Research SizeFlagsStretchRatio = 1 }; - SearchBar = new LineEdit() + _searchBar = new LineEdit() { PlaceHolder = "Search Designs", SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 3 }; - SearchBar.OnTextChanged += Populate; + _searchBar.OnTextChanged += Populate; var filterButton = new Button() { @@ -112,25 +112,25 @@ namespace Content.Client.Research Disabled = true, }; - Items = new ItemList() + _items = new ItemList() { SizeFlagsStretchRatio = 8, SizeFlagsVertical = SizeFlags.FillExpand, SelectMode = ItemList.ItemListSelectMode.Button, }; - Items.OnItemSelected += ItemSelected; + _items.OnItemSelected += ItemSelected; - AmountLineEdit = new LineEdit() + _amountLineEdit = new LineEdit() { PlaceHolder = "Amount", Text = "1", SizeFlagsHorizontal = SizeFlags.FillExpand, }; - AmountLineEdit.OnTextChanged += PopulateDisabled; + _amountLineEdit.OnTextChanged += PopulateDisabled; - Materials = new ItemList() + _materials = new ItemList() { SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsStretchRatio = 3 @@ -145,14 +145,14 @@ namespace Content.Client.Research } hBoxButtons.AddChild(QueueButton); - hBoxFilter.AddChild(SearchBar); + hBoxFilter.AddChild(_searchBar); hBoxFilter.AddChild(filterButton); vBox.AddChild(hBoxButtons); vBox.AddChild(hBoxFilter); - vBox.AddChild(Items); - vBox.AddChild(AmountLineEdit); - vBox.AddChild(Materials); + vBox.AddChild(_items); + vBox.AddChild(_amountLineEdit); + vBox.AddChild(_materials); margin.AddChild(vBox); @@ -161,20 +161,20 @@ namespace Content.Client.Research public void ItemSelected(ItemList.ItemListSelectedEventArgs args) { - int.TryParse(AmountLineEdit.Text, out var quantity); + int.TryParse(_amountLineEdit.Text, out var quantity); if (quantity <= 0) quantity = 1; Owner.Queue(_shownRecipes[args.ItemIndex], quantity); } public void PopulateMaterials() { - Materials.Clear(); + _materials.Clear(); foreach (var (id, amount) in Owner.Storage) { if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue; var material = materialPrototype.Material; - Materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false); + _materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false); } } @@ -183,12 +183,12 @@ namespace Content.Client.Research /// public void PopulateDisabled() { - int.TryParse(AmountLineEdit.Text, out var quantity); + int.TryParse(_amountLineEdit.Text, out var quantity); if (quantity <= 0) quantity = 1; for (var i = 0; i < _shownRecipes.Count; i++) { var prototype = _shownRecipes[i]; - Items[i].Disabled = !Owner.Lathe.CanProduce(prototype, quantity); + _items[i].Disabled = !Owner.Lathe.CanProduce(prototype, quantity); } } @@ -203,10 +203,10 @@ namespace Content.Client.Research /// public void PopulateList() { - Items.Clear(); + _items.Clear(); foreach (var prototype in _shownRecipes) { - Items.AddItem(prototype.Name, prototype.Icon.Frame0()); + _items.AddItem(prototype.Name, prototype.Icon.Frame0()); } PopulateDisabled(); @@ -221,9 +221,9 @@ namespace Content.Client.Research foreach (var prototype in Owner.Database) { - if (SearchBar.Text.Trim().Length != 0) + if (_searchBar.Text.Trim().Length != 0) { - if (prototype.Name.ToLowerInvariant().Contains(SearchBar.Text.Trim().ToLowerInvariant())) + if (prototype.Name.ToLowerInvariant().Contains(_searchBar.Text.Trim().ToLowerInvariant())) _shownRecipes.Add(prototype); continue; } diff --git a/Content.Client/Research/LatheQueueMenu.cs b/Content.Client/Research/LatheQueueMenu.cs index 7c6537c5c5..1f619281d4 100644 --- a/Content.Client/Research/LatheQueueMenu.cs +++ b/Content.Client/Research/LatheQueueMenu.cs @@ -16,10 +16,10 @@ namespace Content.Client.Research public LatheBoundUserInterface Owner { get; set; } [ViewVariables] - private ItemList QueueList; - private Label NameLabel; - private Label Description; - private TextureRect Icon; + private readonly ItemList _queueList; + private readonly Label _nameLabel; + private readonly Label _description; + private readonly TextureRect _icon; public LatheQueueMenu() { @@ -54,7 +54,7 @@ namespace Content.Client.Research SizeFlagsHorizontal = SizeFlags.FillExpand, }; - Icon = new TextureRect() + _icon = new TextureRect() { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 2, @@ -66,13 +66,13 @@ namespace Content.Client.Research SizeFlagsStretchRatio = 3, }; - NameLabel = new Label() + _nameLabel = new Label() { RectClipContent = true, SizeFlagsHorizontal = SizeFlags.Fill, }; - Description = new Label() + _description = new Label() { RectClipContent = true, SizeFlagsVertical = SizeFlags.FillExpand, @@ -80,7 +80,7 @@ namespace Content.Client.Research }; - QueueList = new ItemList() + _queueList = new ItemList() { SizeFlagsHorizontal = SizeFlags.Fill, SizeFlagsVertical = SizeFlags.FillExpand, @@ -88,16 +88,16 @@ namespace Content.Client.Research SelectMode = ItemList.ItemListSelectMode.None }; - vBoxInfo.AddChild(NameLabel); - vBoxInfo.AddChild(Description); + vBoxInfo.AddChild(_nameLabel); + vBoxInfo.AddChild(_description); - hBox.AddChild(Icon); + hBox.AddChild(_icon); hBox.AddChild(vBoxInfo); descMargin.AddChild(hBox); vBox.AddChild(descMargin); - vBox.AddChild(QueueList); + vBox.AddChild(_queueList); margin.AddChild(vBox); @@ -108,27 +108,27 @@ namespace Content.Client.Research public void SetInfo(LatheRecipePrototype recipe) { - Icon.Texture = recipe.Icon.Frame0(); + _icon.Texture = recipe.Icon.Frame0(); if (recipe.Name != null) - NameLabel.Text = recipe.Name; + _nameLabel.Text = recipe.Name; if (recipe.Description != null) - Description.Text = recipe.Description; + _description.Text = recipe.Description; } public void ClearInfo() { - Icon.Texture = Texture.Transparent; - NameLabel.Text = "-------"; - Description.Text = "Not producing anything."; + _icon.Texture = Texture.Transparent; + _nameLabel.Text = "-------"; + _description.Text = "Not producing anything."; } public void PopulateList() { - QueueList.Clear(); + _queueList.Clear(); var idx = 1; foreach (var recipe in Owner.QueuedRecipes) { - QueueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0()); + _queueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0()); idx++; } } diff --git a/Content.Client/Research/ResearchConsoleMenu.cs b/Content.Client/Research/ResearchConsoleMenu.cs index 2b26fb69ac..a17a20a2a8 100644 --- a/Content.Client/Research/ResearchConsoleMenu.cs +++ b/Content.Client/Research/ResearchConsoleMenu.cs @@ -18,19 +18,19 @@ namespace Content.Client.Research protected override Vector2? CustomSize => (800, 400); - private List _unlockedTechnologyPrototypes = new List(); - private List _unlockableTechnologyPrototypes = new List(); - private List _futureTechnologyPrototypes = new List(); + private readonly List _unlockedTechnologyPrototypes = new List(); + private readonly List _unlockableTechnologyPrototypes = new List(); + private readonly List _futureTechnologyPrototypes = new List(); - private Label _pointLabel; - private Label _pointsPerSecondLabel; - private Label _technologyName; - private Label _technologyDescription; - private Label _technologyRequirements; - private TextureRect _technologyIcon; - private ItemList _unlockedTechnologies; - private ItemList _unlockableTechnologies; - private ItemList _futureTechnologies; + private readonly Label _pointLabel; + private readonly Label _pointsPerSecondLabel; + private readonly Label _technologyName; + private readonly Label _technologyDescription; + private readonly Label _technologyRequirements; + private readonly TextureRect _technologyIcon; + private readonly ItemList _unlockedTechnologies; + private readonly ItemList _unlockableTechnologies; + private readonly ItemList _futureTechnologies; public Button UnlockButton { get; private set; } public Button ServerSelectionButton { get; private set; } diff --git a/Content.Client/Sandbox/SandboxManager.cs b/Content.Client/Sandbox/SandboxManager.cs index 5faff03d31..4d432d0fa6 100644 --- a/Content.Client/Sandbox/SandboxManager.cs +++ b/Content.Client/Sandbox/SandboxManager.cs @@ -20,19 +20,19 @@ namespace Content.Client.Sandbox // Layout for the SandboxWindow public class SandboxWindow : SS14Window { - public Button RespawnButton; - public Button SpawnEntitiesButton; - public Button SpawnTilesButton; - public Button GiveFullAccessButton; //A button that just puts a captain's ID in your hands. - public Button GiveAghostButton; - public Button ToggleLightButton; - public Button ToggleFovButton; - public Button ToggleShadowsButton; - public Button SuicideButton; - public Button ToggleSubfloorButton; - public Button ShowMarkersButton; //Shows spawn points - public Button ShowBbButton; //Shows bounding boxes - public Button MachineLinkingButton; // Enables/disables machine linking mode. + public readonly Button RespawnButton; + public readonly Button SpawnEntitiesButton; + public readonly Button SpawnTilesButton; + public readonly Button GiveFullAccessButton; //A button that just puts a captain's ID in your hands. + public readonly Button GiveAghostButton; + public readonly Button ToggleLightButton; + public readonly Button ToggleFovButton; + public readonly Button ToggleShadowsButton; + public readonly Button SuicideButton; + public readonly Button ToggleSubfloorButton; + public readonly Button ShowMarkersButton; //Shows spawn points + public readonly Button ShowBbButton; //Shows bounding boxes + public readonly Button MachineLinkingButton; // Enables/disables machine linking mode. public SandboxWindow() { diff --git a/Content.Client/UserInterface/AdminMenu/AdminMenuWindow.cs b/Content.Client/UserInterface/AdminMenu/AdminMenuWindow.cs index f45ac25c88..24b39739d6 100644 --- a/Content.Client/UserInterface/AdminMenu/AdminMenuWindow.cs +++ b/Content.Client/UserInterface/AdminMenu/AdminMenuWindow.cs @@ -607,7 +607,7 @@ namespace Content.Client.UserInterface.AdminMenu GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(), }; - private CommandUISpinBox _amount = new CommandUISpinBox + private readonly CommandUISpinBox _amount = new CommandUISpinBox { Name = "Amount" }; diff --git a/Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs b/Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs index 3621ab326d..e8f41156ea 100644 --- a/Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs +++ b/Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs @@ -23,7 +23,7 @@ namespace Content.Client.UserInterface.Cargo public event Action OnOrderApproved; public event Action OnOrderCanceled; - private List _categoryStrings = new List(); + private readonly List _categoryStrings = new List(); private Label _accountNameLabel { get; set; } private Label _pointsLabel { get; set; } diff --git a/Content.Client/UserInterface/Cargo/GalacticBankSelectionMenu.cs b/Content.Client/UserInterface/Cargo/GalacticBankSelectionMenu.cs index 5727db3fce..be6a5035e1 100644 --- a/Content.Client/UserInterface/Cargo/GalacticBankSelectionMenu.cs +++ b/Content.Client/UserInterface/Cargo/GalacticBankSelectionMenu.cs @@ -10,7 +10,7 @@ namespace Content.Client.UserInterface.Cargo { public class GalacticBankSelectionMenu : SS14Window { - private ItemList _accounts; + private readonly ItemList _accounts; private int _accountCount = 0; private string[] _accountNames = new string[] { }; private int[] _accountIds = new int[] { }; diff --git a/Content.Client/UserInterface/CooldownGraphic.cs b/Content.Client/UserInterface/CooldownGraphic.cs index d281c73e99..a2da053a92 100644 --- a/Content.Client/UserInterface/CooldownGraphic.cs +++ b/Content.Client/UserInterface/CooldownGraphic.cs @@ -14,7 +14,7 @@ namespace Content.Client.UserInterface [Dependency] private readonly IPrototypeManager _protoMan = default!; - private ShaderInstance _shader; + private readonly ShaderInstance _shader; public CooldownGraphic() { diff --git a/Content.Client/UserInterface/LateJoinGui.cs b/Content.Client/UserInterface/LateJoinGui.cs index 0924a4eb94..2f6e5b29c9 100644 --- a/Content.Client/UserInterface/LateJoinGui.cs +++ b/Content.Client/UserInterface/LateJoinGui.cs @@ -26,7 +26,7 @@ namespace Content.Client.UserInterface public event Action SelectedId; - private Dictionary JobButtons = new Dictionary(); + private readonly Dictionary _jobButtons = new Dictionary(); public LateJoinGui() { @@ -95,7 +95,7 @@ namespace Content.Client.UserInterface jobButton.Disabled = true; } - JobButtons[job.ID] = jobButton; + _jobButtons[job.ID] = jobButton; } SelectedId += jobId => @@ -115,7 +115,7 @@ namespace Content.Client.UserInterface private void JobsAvailableUpdated(IReadOnlyList jobs) { - foreach (var (id, button) in JobButtons) + foreach (var (id, button) in _jobButtons) { button.Disabled = !jobs.Contains(id); } @@ -128,7 +128,7 @@ namespace Content.Client.UserInterface if (disposing) { _gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated; - JobButtons.Clear(); + _jobButtons.Clear(); } } } diff --git a/Content.Client/UserInterface/LobbyCharacterPreviewPanel.cs b/Content.Client/UserInterface/LobbyCharacterPreviewPanel.cs index 3a76eab6b8..de0af99932 100644 --- a/Content.Client/UserInterface/LobbyCharacterPreviewPanel.cs +++ b/Content.Client/UserInterface/LobbyCharacterPreviewPanel.cs @@ -23,8 +23,8 @@ namespace Content.Client.UserInterface private readonly IClientPreferencesManager _preferencesManager; private IEntity _previewDummy; private readonly Label _summaryLabel; - private VBoxContainer _loaded; - private Label _unloaded; + private readonly VBoxContainer _loaded; + private readonly Label _unloaded; public LobbyCharacterPreviewPanel(IEntityManager entityManager, IClientPreferencesManager preferencesManager) diff --git a/Content.Client/UserInterface/LobbyGui.cs b/Content.Client/UserInterface/LobbyGui.cs index 2fbc9df8f0..d445202fef 100644 --- a/Content.Client/UserInterface/LobbyGui.cs +++ b/Content.Client/UserInterface/LobbyGui.cs @@ -258,8 +258,8 @@ namespace Content.Client.UserInterface public class LobbyPlayerList : Control { - private ScrollContainer _scroll; - private VBoxContainer _vBox; + private readonly ScrollContainer _scroll; + private readonly VBoxContainer _vBox; public LobbyPlayerList() { diff --git a/Content.Client/UserInterface/ParticleAccelerator/ParticleAcceleratorControlMenu.cs b/Content.Client/UserInterface/ParticleAccelerator/ParticleAcceleratorControlMenu.cs index 2e9ab07227..1e451e9bf9 100644 --- a/Content.Client/UserInterface/ParticleAccelerator/ParticleAcceleratorControlMenu.cs +++ b/Content.Client/UserInterface/ParticleAccelerator/ParticleAcceleratorControlMenu.cs @@ -24,7 +24,7 @@ namespace Content.Client.ParticleAccelerator { public sealed class ParticleAcceleratorControlMenu : BaseWindow { - private ShaderInstance _greyScaleShader; + private readonly ShaderInstance _greyScaleShader; private readonly ParticleAcceleratorBoundUserInterface Owner; diff --git a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs index 4d57b08519..69db28af24 100644 --- a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs @@ -9,7 +9,7 @@ namespace Content.Server.AI.Operators.Combat.Melee { public class SwingMeleeWeaponOperator : AiOperator { - private float _burstTime; + private readonly float _burstTime; private float _elapsedTime; private readonly IEntity _owner; diff --git a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs index f509844fc3..3d00db189d 100644 --- a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs @@ -8,7 +8,7 @@ namespace Content.Server.AI.Operators.Combat.Melee { public sealed class UnarmedCombatOperator : AiOperator { - private float _burstTime; + private readonly float _burstTime; private float _elapsedTime; private readonly IEntity _owner; diff --git a/Content.Server/AI/Operators/Movement/MoveToEntityOperator.cs b/Content.Server/AI/Operators/Movement/MoveToEntityOperator.cs index 35a15293e7..0b84e525fa 100644 --- a/Content.Server/AI/Operators/Movement/MoveToEntityOperator.cs +++ b/Content.Server/AI/Operators/Movement/MoveToEntityOperator.cs @@ -16,12 +16,12 @@ namespace Content.Server.AI.Operators.Movement public float ArrivalDistance { get; } public float PathfindingProximity { get; } - private bool _requiresInRangeUnobstructed; + private readonly bool _requiresInRangeUnobstructed; public MoveToEntityOperator( - IEntity owner, - IEntity target, - float arrivalDistance = 1.0f, + IEntity owner, + IEntity target, + float arrivalDistance = 1.0f, float pathfindingProximity = 1.5f, bool requiresInRangeUnobstructed = false) { @@ -44,7 +44,7 @@ namespace Content.Server.AI.Operators.Movement steering.Register(_owner, _request); return true; } - + public override void Shutdown(Outcome outcome) { base.Shutdown(outcome); @@ -71,4 +71,4 @@ namespace Content.Server.AI.Operators.Movement } } } -} \ No newline at end of file +} diff --git a/Content.Server/AI/Utility/Actions/Clothing/Gloves/EquipGloves.cs b/Content.Server/AI/Utility/Actions/Clothing/Gloves/EquipGloves.cs index 1804f2e798..d3cfcd94cf 100644 --- a/Content.Server/AI/Utility/Actions/Clothing/Gloves/EquipGloves.cs +++ b/Content.Server/AI/Utility/Actions/Clothing/Gloves/EquipGloves.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Gloves { public sealed class EquipGloves : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public EquipGloves(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -35,7 +35,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Gloves base.UpdateBlackboard(context); context.GetState().SetValue(_entity); } - + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Actions/Clothing/Head/EquipHead.cs b/Content.Server/AI/Utility/Actions/Clothing/Head/EquipHead.cs index 144aa99430..c0337464cc 100644 --- a/Content.Server/AI/Utility/Actions/Clothing/Head/EquipHead.cs +++ b/Content.Server/AI/Utility/Actions/Clothing/Head/EquipHead.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Head { public sealed class EquipHead : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public EquipHead(IEntity owner, IEntity entity, float weight) : base(owner) { diff --git a/Content.Server/AI/Utility/Actions/Clothing/OuterClothing/EquipOuterClothing.cs b/Content.Server/AI/Utility/Actions/Clothing/OuterClothing/EquipOuterClothing.cs index 4a2460e63c..51982ca0e2 100644 --- a/Content.Server/AI/Utility/Actions/Clothing/OuterClothing/EquipOuterClothing.cs +++ b/Content.Server/AI/Utility/Actions/Clothing/OuterClothing/EquipOuterClothing.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.OuterClothing { public sealed class EquipOuterClothing : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public EquipOuterClothing(IEntity owner, IEntity entity, float weight) : base(owner) { diff --git a/Content.Server/AI/Utility/Actions/Clothing/Shoes/EquipShoes.cs b/Content.Server/AI/Utility/Actions/Clothing/Shoes/EquipShoes.cs index b15bb5e82b..69b5871215 100644 --- a/Content.Server/AI/Utility/Actions/Clothing/Shoes/EquipShoes.cs +++ b/Content.Server/AI/Utility/Actions/Clothing/Shoes/EquipShoes.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Shoes { public sealed class EquipShoes : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public EquipShoes(IEntity owner, IEntity entity, float weight) : base(owner) { diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/EquipMelee.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/EquipMelee.cs index ce42bfd6dd..bf823ccfb3 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/EquipMelee.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/EquipMelee.cs @@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee { public sealed class EquipMelee : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public EquipMelee(IEntity owner, IEntity entity, float weight) : base(owner) { diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs index e0df81467c..d18ce81802 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs @@ -21,7 +21,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee { public sealed class MeleeWeaponAttackEntity : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public MeleeWeaponAttackEntity(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -58,7 +58,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee var equipped = context.GetState().GetValue(); context.GetState().SetValue(equipped); } - + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/PickUpMeleeWeapon.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/PickUpMeleeWeapon.cs index fed29d402a..495e6dbbc6 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/PickUpMeleeWeapon.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/PickUpMeleeWeapon.cs @@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee { public sealed class PickUpMeleeWeapon : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public PickUpMeleeWeapon(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -34,7 +34,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee context.GetState().SetValue(_entity); context.GetState().SetValue(_entity); } - + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs index 62c15cffd7..bd64519dd7 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs @@ -19,7 +19,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee { public sealed class UnarmedAttackEntity : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public UnarmedAttackEntity(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -44,7 +44,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee ActionOperators = new Queue(new AiOperator[] { moveOperator, - new UnarmedCombatOperator(Owner, _entity), + new UnarmedCombatOperator(Owner, _entity), }); } @@ -60,7 +60,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); - + return new[] { considerationsManager.Get() diff --git a/Content.Server/AI/Utility/Actions/Nutrition/Drink/PickUpDrink.cs b/Content.Server/AI/Utility/Actions/Nutrition/Drink/PickUpDrink.cs index 3612b646ec..5adf2af6a7 100644 --- a/Content.Server/AI/Utility/Actions/Nutrition/Drink/PickUpDrink.cs +++ b/Content.Server/AI/Utility/Actions/Nutrition/Drink/PickUpDrink.cs @@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink { public sealed class PickUpDrink : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public PickUpDrink(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -26,17 +26,17 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink { ActionOperators = new GoPickupEntitySequence(Owner, _entity).Sequence; } - + protected override void UpdateBlackboard(Blackboard context) { base.UpdateBlackboard(context); context.GetState().SetValue(_entity); } - + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); - + return new[] { considerationsManager.Get() diff --git a/Content.Server/AI/Utility/Actions/Nutrition/Drink/UseDrinkInInventory.cs b/Content.Server/AI/Utility/Actions/Nutrition/Drink/UseDrinkInInventory.cs index e94cd74356..075a1f58f3 100644 --- a/Content.Server/AI/Utility/Actions/Nutrition/Drink/UseDrinkInInventory.cs +++ b/Content.Server/AI/Utility/Actions/Nutrition/Drink/UseDrinkInInventory.cs @@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink { public sealed class UseDrinkInInventory : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public UseDrinkInInventory(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -31,13 +31,13 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink new UseDrinkInInventoryOperator(Owner, _entity), }); } - + protected override void UpdateBlackboard(Blackboard context) { base.UpdateBlackboard(context); context.GetState().SetValue(_entity); - } - + } + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Actions/Nutrition/Food/PickUpFood.cs b/Content.Server/AI/Utility/Actions/Nutrition/Food/PickUpFood.cs index 4c4dd08cfa..741d611a68 100644 --- a/Content.Server/AI/Utility/Actions/Nutrition/Food/PickUpFood.cs +++ b/Content.Server/AI/Utility/Actions/Nutrition/Food/PickUpFood.cs @@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food { public sealed class PickUpFood : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public PickUpFood(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -31,8 +31,8 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food { base.UpdateBlackboard(context); context.GetState().SetValue(_entity); - } - + } + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Actions/Nutrition/Food/UseFoodInInventory.cs b/Content.Server/AI/Utility/Actions/Nutrition/Food/UseFoodInInventory.cs index b12c40dbf8..4528035a95 100644 --- a/Content.Server/AI/Utility/Actions/Nutrition/Food/UseFoodInInventory.cs +++ b/Content.Server/AI/Utility/Actions/Nutrition/Food/UseFoodInInventory.cs @@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food { public sealed class UseFoodInInventory : UtilityAction { - private IEntity _entity; + private readonly IEntity _entity; public UseFoodInInventory(IEntity owner, IEntity entity, float weight) : base(owner) { @@ -28,7 +28,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food ActionOperators = new Queue(new AiOperator[] { new EquipEntityOperator(Owner, _entity), - new UseFoodInInventoryOperator(Owner, _entity), + new UseFoodInInventoryOperator(Owner, _entity), }); } @@ -36,8 +36,8 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food { base.UpdateBlackboard(context); context.GetState().SetValue(_entity); - } - + } + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Considerations/ConsiderationsManager.cs b/Content.Server/AI/Utility/Considerations/ConsiderationsManager.cs index 1ff677f402..9de6fc5af7 100644 --- a/Content.Server/AI/Utility/Considerations/ConsiderationsManager.cs +++ b/Content.Server/AI/Utility/Considerations/ConsiderationsManager.cs @@ -7,23 +7,23 @@ namespace Content.Server.AI.Utility.Considerations { public class ConsiderationsManager { - private Dictionary _considerations = new Dictionary(); + private readonly Dictionary _considerations = new Dictionary(); public void Initialize() { var reflectionManager = IoCManager.Resolve(); var typeFactory = IoCManager.Resolve(); - + foreach (var conType in reflectionManager.GetAllChildren(typeof(Consideration))) { var con = (Consideration) typeFactory.CreateInstance(conType); _considerations.Add(conType, con); } } - + public T Get() where T : Consideration { return (T) _considerations[typeof(T)]; } } -} \ No newline at end of file +} diff --git a/Content.Server/AI/WorldState/BlackboardManager.cs b/Content.Server/AI/WorldState/BlackboardManager.cs index f0ef10f5d2..a2cd836ff2 100644 --- a/Content.Server/AI/WorldState/BlackboardManager.cs +++ b/Content.Server/AI/WorldState/BlackboardManager.cs @@ -14,7 +14,7 @@ namespace Content.Server.AI.WorldState { // Cache the known types public IReadOnlyCollection AiStates => _aiStates; - private List _aiStates = new List(); + private readonly List _aiStates = new List(); public void Initialize() { @@ -24,8 +24,8 @@ namespace Content.Server.AI.WorldState { _aiStates.Add(state); } - + DebugTools.AssertNotNull(_aiStates); } } -} \ No newline at end of file +} diff --git a/Content.Server/Administration/AdminManager.cs b/Content.Server/Administration/AdminManager.cs index 4c1b9fc4d5..0ee2b7839d 100644 --- a/Content.Server/Administration/AdminManager.cs +++ b/Content.Server/Administration/AdminManager.cs @@ -460,7 +460,7 @@ namespace Content.Server.Administration private sealed class AdminReg { - public IPlayerSession Session; + public readonly IPlayerSession Session; public AdminData Data; public int? RankId; diff --git a/Content.Server/Atmos/HighPressureMovementController.cs b/Content.Server/Atmos/HighPressureMovementController.cs index c344a25496..352a5d77f8 100644 --- a/Content.Server/Atmos/HighPressureMovementController.cs +++ b/Content.Server/Atmos/HighPressureMovementController.cs @@ -4,19 +4,17 @@ using Content.Server.GameObjects.Components.Atmos; using Content.Shared.Atmos; using Content.Shared.Physics; using Robust.Shared.GameObjects.Components; -using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; -using Robust.Shared.Physics; using Robust.Shared.Random; namespace Content.Server.Atmos { public class HighPressureMovementController : FrictionController { - [Dependency] private IRobustRandom _robustRandom = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; public override IPhysicsComponent? ControlledComponent { protected get; set; } private const float MoveForcePushRatio = 1f; diff --git a/Content.Server/Cargo/CargoOrderDatabase.cs b/Content.Server/Cargo/CargoOrderDatabase.cs index 924a424071..9c4f362273 100644 --- a/Content.Server/Cargo/CargoOrderDatabase.cs +++ b/Content.Server/Cargo/CargoOrderDatabase.cs @@ -7,7 +7,7 @@ namespace Content.Server.Cargo { public class CargoOrderDatabase { - private Dictionary _orders = new Dictionary(); + private readonly Dictionary _orders = new Dictionary(); private int _orderNumber = 0; public CargoOrderDatabase(int id) @@ -84,7 +84,7 @@ namespace Content.Server.Cargo { return _orders.Remove(orderNumber); } - + /// /// Approves an order in the database. /// @@ -96,7 +96,7 @@ namespace Content.Server.Cargo if (!_orders.TryGetValue(orderNumber, out var order)) return; else if (CurrentOrderSize + order.Amount > MaxOrderSize) - { + { AddOrder(order.Requester, Loc.GetString("{0} (Overflow)", order.Reason.Replace(" (Overflow)","")), order.ProductId, order.Amount - MaxOrderSize - CurrentOrderSize, order.PayingAccountId); order.Amount = MaxOrderSize - CurrentOrderSize; diff --git a/Content.Server/GameObjects/Components/Arcade/BlockGameArcadeComponent.cs b/Content.Server/GameObjects/Components/Arcade/BlockGameArcadeComponent.cs index b60dc31c95..681187f7c0 100644 --- a/Content.Server/GameObjects/Components/Arcade/BlockGameArcadeComponent.cs +++ b/Content.Server/GameObjects/Components/Arcade/BlockGameArcadeComponent.cs @@ -26,18 +26,20 @@ namespace Content.Server.GameObjects.Components.Arcade [ComponentReference(typeof(IActivate))] public class BlockGameArcadeComponent : Component, IActivate { - [Dependency] private IRobustRandom _random = null!; + [Dependency] private readonly IRobustRandom _random = default!; public override string Name => "BlockGameArcade"; public override uint? NetID => ContentNetIDs.BLOCKGAME_ARCADE; - [ComponentDependency] private PowerReceiverComponent? _powerReceiverComponent = default!; + + [ComponentDependency] private readonly PowerReceiverComponent? _powerReceiverComponent = default!; + private bool Powered => _powerReceiverComponent?.Powered ?? false; private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BlockGameUiKey.Key); private BlockGame? _game; private IPlayerSession? _player; - private List _spectators = new List(); + private readonly List _spectators = new List(); public void Activate(ActivateEventArgs eventArgs) { @@ -162,9 +164,9 @@ namespace Content.Server.GameObjects.Components.Arcade { //note: field is 10(0 -> 9) wide and 20(0 -> 19) high - private BlockGameArcadeComponent _component; + private readonly BlockGameArcadeComponent _component; - private List _field = new List(); + private readonly List _field = new List(); private BlockGamePiece _currentPiece; diff --git a/Content.Server/GameObjects/Components/Arcade/SpaceVillainArcadeComponent.cs b/Content.Server/GameObjects/Components/Arcade/SpaceVillainArcadeComponent.cs index 2a5a9c878c..30098ee021 100644 --- a/Content.Server/GameObjects/Components/Arcade/SpaceVillainArcadeComponent.cs +++ b/Content.Server/GameObjects/Components/Arcade/SpaceVillainArcadeComponent.cs @@ -29,10 +29,10 @@ namespace Content.Server.GameObjects.Components.Arcade [ComponentReference(typeof(IActivate))] public class SpaceVillainArcadeComponent : SharedSpaceVillainArcadeComponent, IActivate, IWires { - [Dependency] private IRobustRandom _random = null!; + [Dependency] private readonly IRobustRandom _random = null!; - [ComponentDependency] private PowerReceiverComponent? _powerReceiverComponent = default!; - [ComponentDependency] private WiresComponent? _wiresComponent = default!; + [ComponentDependency] private readonly PowerReceiverComponent? _powerReceiverComponent = default!; + [ComponentDependency] private readonly WiresComponent? _wiresComponent = default!; private bool Powered => _powerReceiverComponent != null && _powerReceiverComponent.Powered; @@ -240,7 +240,7 @@ namespace Content.Server.GameObjects.Components.Arcade { [Dependency] private readonly IRobustRandom _random = default!; - [ViewVariables] private SpaceVillainArcadeComponent Owner; + [ViewVariables] private readonly SpaceVillainArcadeComponent _owner; [ViewVariables] public string Name => $"{_fightVerb} {_enemyName}"; [ViewVariables(VVAccess.ReadWrite)] private int _playerHp = 30; @@ -253,8 +253,8 @@ namespace Content.Server.GameObjects.Components.Arcade [ViewVariables(VVAccess.ReadWrite)] private int _enemyMpMax = 20; [ViewVariables(VVAccess.ReadWrite)] private int _turtleTracker; - [ViewVariables(VVAccess.ReadWrite)] private string _fightVerb; - [ViewVariables(VVAccess.ReadWrite)] private string _enemyName; + [ViewVariables(VVAccess.ReadWrite)] private readonly string _fightVerb; + [ViewVariables(VVAccess.ReadWrite)] private readonly string _enemyName; [ViewVariables] private bool _running = true; @@ -266,7 +266,7 @@ namespace Content.Server.GameObjects.Components.Arcade public SpaceVillainGame(SpaceVillainArcadeComponent owner, string fightVerb, string enemyName) { IoCManager.InjectDependencies(this); - Owner = owner; + _owner = owner; //todo defeat the curse secret game mode _fightVerb = fightVerb; _enemyName = enemyName; @@ -278,7 +278,7 @@ namespace Content.Server.GameObjects.Components.Arcade /// private void ValidateVars() { - if(Owner._overflowFlag) return; + if(_owner._overflowFlag) return; if (_playerHp > _playerHpMax) _playerHp = _playerHpMax; if (_playerMp > _playerMpMax) _playerMp = _playerMpMax; @@ -299,23 +299,23 @@ namespace Content.Server.GameObjects.Components.Arcade case PlayerAction.Attack: var attackAmount = _random.Next(2, 6); _latestPlayerActionMessage = Loc.GetString("You attack {0} for {1}!", _enemyName, attackAmount); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_attack.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!Owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_attack.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; case PlayerAction.Heal: var pointAmount = _random.Next(1, 3); var healAmount = _random.Next(6, 8); _latestPlayerActionMessage = Loc.GetString("You use {0} magic to heal for {1} damage!", pointAmount, healAmount); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_heal.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!Owner._playerInvincibilityFlag) _playerMp -= pointAmount; + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_heal.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if(!_owner._playerInvincibilityFlag) _playerMp -= pointAmount; _playerHp += healAmount; _turtleTracker++; break; case PlayerAction.Recharge: var chargeAmount = _random.Next(4, 7); _latestPlayerActionMessage = Loc.GetString("You regain {0} points", chargeAmount); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_charge.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/player_charge.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); _playerMp += chargeAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -347,8 +347,8 @@ namespace Content.Server.GameObjects.Components.Arcade { _running = false; UpdateUi(Loc.GetString("You won!"), Loc.GetString("{0} dies.", _enemyName), true); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/win.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); - Owner.ProcessWin(); + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/win.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); + _owner.ProcessWin(); return false; } @@ -358,14 +358,14 @@ namespace Content.Server.GameObjects.Components.Arcade { _running = false; UpdateUi(Loc.GetString("You lost!"), Loc.GetString("{0} cheers.", _enemyName), true); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } if (_enemyHp <= 0 || _enemyMp <= 0) { _running = false; UpdateUi(Loc.GetString("You lost!"), Loc.GetString("{0} dies, but takes you with him.", _enemyName), true); - EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f)); + EntitySystem.Get().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } @@ -377,7 +377,7 @@ namespace Content.Server.GameObjects.Components.Arcade /// private void UpdateUi(bool metadata = false) { - Owner.UserInterface?.SendMessage(metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage()); + _owner.UserInterface?.SendMessage(metadata ? GenerateMetaDataMessage() : GenerateUpdateMessage()); } private void UpdateUi(string message1, string message2, bool metadata = false) @@ -397,14 +397,14 @@ namespace Content.Server.GameObjects.Components.Arcade { var boomAmount = _random.Next(5, 10); _latestEnemyActionMessage = Loc.GetString("{0} throws a bomb, exploding you for {1} damage!", _enemyName, boomAmount); - if (Owner._playerInvincibilityFlag) return; + if (_owner._playerInvincibilityFlag) return; _playerHp -= boomAmount; _turtleTracker--; }else if (_enemyMp <= 5 && _random.Prob(0.7f)) { var stealAmount = _random.Next(2, 3); _latestEnemyActionMessage = Loc.GetString("{0} steals {1} of your power!", _enemyName, stealAmount); - if (Owner._playerInvincibilityFlag) return; + if (_owner._playerInvincibilityFlag) return; _playerMp -= stealAmount; _enemyMp += stealAmount; }else if (_enemyHp <= 10 && _enemyMp > 4) @@ -418,7 +418,7 @@ namespace Content.Server.GameObjects.Components.Arcade var attackAmount = _random.Next(3, 6); _latestEnemyActionMessage = Loc.GetString("{0} attacks you for {1} damage!", _enemyName, attackAmount); - if (Owner._playerInvincibilityFlag) return; + if (_owner._playerInvincibilityFlag) return; _playerHp -= attackAmount; } } diff --git a/Content.Server/GameObjects/Components/Damage/DamageOnHighSpeedImpactComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageOnHighSpeedImpactComponent.cs index cb843a2c57..e8cc275d80 100644 --- a/Content.Server/GameObjects/Components/Damage/DamageOnHighSpeedImpactComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/DamageOnHighSpeedImpactComponent.cs @@ -19,8 +19,8 @@ namespace Content.Server.GameObjects.Components.Damage [RegisterComponent] public class DamageOnHighSpeedImpactComponent : Component, ICollideBehavior { - [Dependency] private IRobustRandom _robustRandom = default!; - [Dependency] private IGameTiming _gameTiming = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; public override string Name => "DamageOnHighSpeedImpact"; diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index 5033eea168..a54160d12d 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -17,7 +17,6 @@ using Content.Shared.GameObjects.Components.Doors; using Content.Shared.GameObjects.Components.Interactable; using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Interfaces.GameObjects.Components; -using Content.Shared.Physics; using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Audio; @@ -64,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Doors [ViewVariables(VVAccess.ReadWrite)] protected float CloseSpeed = AutoCloseDelay; - private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); protected virtual TimeSpan CloseTimeOne => TimeSpan.FromSeconds(0.3f); protected virtual TimeSpan CloseTimeTwo => TimeSpan.FromSeconds(0.9f); diff --git a/Content.Server/GameObjects/Components/Items/Storage/CursedEntityStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/CursedEntityStorageComponent.cs index 6018872270..a7d6b836ae 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/CursedEntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/CursedEntityStorageComponent.cs @@ -4,7 +4,6 @@ using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Random; @@ -17,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage [RegisterComponent] public class CursedEntityStorageComponent : EntityStorageComponent { - [Dependency] private IRobustRandom _robustRandom = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; public override string Name => "CursedEntityStorage"; diff --git a/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs b/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs index c0f1978962..052976632c 100644 --- a/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs @@ -4,7 +4,6 @@ using Content.Server.GameTicking; using Content.Server.Interfaces.GameTicking; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; -using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Reflection; using Robust.Shared.IoC; @@ -28,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Markers public List Prototypes { get; set; } = new List(); [ViewVariables(VVAccess.ReadWrite)] - private List _gameRules = new List(); + private readonly List _gameRules = new List(); [ViewVariables(VVAccess.ReadWrite)] public float Chance { get; set; } = 1.0f; diff --git a/Content.Server/GameObjects/Components/Morgue/BodyBagEntityStorageComponent.cs b/Content.Server/GameObjects/Components/Morgue/BodyBagEntityStorageComponent.cs index ef3e1bb8d3..3c8d91150b 100644 --- a/Content.Server/GameObjects/Components/Morgue/BodyBagEntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Morgue/BodyBagEntityStorageComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.Components.Morgue public override string Name => "BodyBagEntityStorage"; [ViewVariables] - [ComponentDependency] private AppearanceComponent? _appearance = null; + [ComponentDependency] private readonly AppearanceComponent? _appearance = null; [ViewVariables] public ContainerSlot? LabelContainer { get; private set; } diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs index 57f54a9f26..2574a294bd 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs @@ -25,7 +25,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups public AMEControllerComponent MasterController => _masterController; - private List _cores = new List(); + private readonly List _cores = new List(); public int CoreCount => _cores.Count; diff --git a/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs b/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs index 32e13a360a..d4b1daf95e 100644 --- a/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs @@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Mobs; using Content.Shared.Alert; using Content.Shared.Damage; using Content.Shared.GameObjects.Components.Damage; -using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Nutrition; using Robust.Shared.GameObjects; @@ -55,7 +54,7 @@ namespace Content.Server.GameObjects.Components.Nutrition [ViewVariables(VVAccess.ReadOnly)] public Dictionary HungerThresholds => _hungerThresholds; - private Dictionary _hungerThresholds = new Dictionary + private readonly Dictionary _hungerThresholds = new Dictionary { {HungerThreshold.Overfed, 600.0f}, {HungerThreshold.Okay, 450.0f}, diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs index 366756931a..224e288001 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece [RegisterComponent] public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit, ISignalReceiver, ISignalReceiver { - [Dependency] private IGameTiming _gameTiming = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; public override string Name => "PoweredLight"; diff --git a/Content.Server/GameObjects/Components/Recycling/RecyclerComponent.cs b/Content.Server/GameObjects/Components/Recycling/RecyclerComponent.cs index 9405fbdb4c..5236a99aac 100644 --- a/Content.Server/GameObjects/Components/Recycling/RecyclerComponent.cs +++ b/Content.Server/GameObjects/Components/Recycling/RecyclerComponent.cs @@ -3,7 +3,6 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.GameObjects.Components.Conveyor; using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Power.ApcNetComponents; -using Content.Server.GameObjects.EntitySystems; using Content.Shared.Construction; using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Recycling; @@ -13,9 +12,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components.Map; -using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -28,7 +25,7 @@ namespace Content.Server.GameObjects.Components.Recycling { public override string Name => "Recycler"; - private List _intersecting = new List(); + private readonly List _intersecting = new List(); /// /// Whether or not sentient beings will be recycled diff --git a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldConnection.cs b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldConnection.cs index 15b5b88d37..e1d0a63f18 100644 --- a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldConnection.cs +++ b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldConnection.cs @@ -15,9 +15,9 @@ namespace Content.Server.GameObjects.Components.Singularity { public readonly ContainmentFieldGeneratorComponent Generator1; public readonly ContainmentFieldGeneratorComponent Generator2; - private List _fields = new List(); + private readonly List _fields = new List(); private int _sharedEnergyPool; - private CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource(); + private readonly CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource(); public int SharedEnergyPool { get => _sharedEnergyPool; diff --git a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs index c211d464fc..62423d18bc 100644 --- a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs @@ -1,24 +1,18 @@ #nullable enable using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Server.GameObjects.Components.Projectiles; using Content.Server.Utility; -using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Physics; -using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Physics; using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Log; -using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Physics; -using Robust.Shared.Utility; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.Singularity @@ -26,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Singularity [RegisterComponent] public class ContainmentFieldGeneratorComponent : Component, ICollideBehavior { - [Dependency] private IPhysicsManager _physicsManager = null!; + [Dependency] private readonly IPhysicsManager _physicsManager = null!; public override string Name => "ContainmentFieldGenerator"; diff --git a/Content.Server/GameObjects/Components/Singularity/EmitterComponent.cs b/Content.Server/GameObjects/Components/Singularity/EmitterComponent.cs index 3a5ce91118..9968edd2e8 100644 --- a/Content.Server/GameObjects/Components/Singularity/EmitterComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/EmitterComponent.cs @@ -16,7 +16,6 @@ using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.ComponentDependencies; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -37,8 +36,8 @@ namespace Content.Server.GameObjects.Components.Singularity { [Dependency] private readonly IRobustRandom _robustRandom = default!; - [ComponentDependency] private AppearanceComponent? _appearance = default; - [ComponentDependency] private AccessReader? _accessReader = default; + [ComponentDependency] private readonly AppearanceComponent? _appearance = default; + [ComponentDependency] private readonly AccessReader? _accessReader = default; public override string Name => "Emitter"; diff --git a/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs b/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs index 3f0ab51504..e7dfb89c05 100644 --- a/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/SingularityComponent.cs @@ -1,10 +1,8 @@ #nullable enable -using System; using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.StationEvents; using Content.Shared.GameObjects; -using Content.Shared.GameObjects.EntitySystemMessages; using Content.Shared.Physics; using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; @@ -15,7 +13,6 @@ using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components.Map; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Log; @@ -29,9 +26,7 @@ namespace Content.Server.GameObjects.Components.Singularity [RegisterComponent] public class SingularityComponent : Component, ICollideBehavior { - [Dependency] private IEntityManager _entityManager = null!; - [Dependency] private IRobustRandom _random = null!; - + [Dependency] private readonly IRobustRandom _random = default!; public override uint? NetID => ContentNetIDs.SINGULARITY; @@ -163,17 +158,17 @@ namespace Content.Server.GameObjects.Components.Singularity _singularityController?.Push(pushVector.Normalized, 2); } - List _previousPulledEntites = new List(); + private readonly List _previousPulledEntities = new List(); public void PullUpdate() { - foreach (var previousPulledEntity in _previousPulledEntites) + foreach (var previousPulledEntity in _previousPulledEntities) { if(previousPulledEntity.Deleted) continue; if (!previousPulledEntity.TryGetComponent(out var collidableComponent)) continue; var controller = collidableComponent.EnsureController(); controller.StopPull(); } - _previousPulledEntites.Clear(); + _previousPulledEntities.Clear(); var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10); foreach (var entity in entitiesToPull) @@ -187,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Singularity var speed = 10 / vec.Length * Level; controller.Pull(vec.Normalized, speed); - _previousPulledEntites.Add(entity); + _previousPulledEntities.Add(entity); } } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs index 9c6d4c4d5d..7a12ce427b 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs @@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition { public override string Name => "RangedMagazine"; - private Stack _spawnedAmmo = new Stack(); + private readonly Stack _spawnedAmmo = new Stack(); private Container _ammoContainer; public int ShotsLeft => _spawnedAmmo.Count + _unspawnedCount; diff --git a/Content.Server/GameObjects/EntitySystems/AI/AiFactionTagSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/AiFactionTagSystem.cs index ea35dceb99..5801a15c46 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/AiFactionTagSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/AiFactionTagSystem.cs @@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None; - private Dictionary _hostileFactions = new Dictionary + private readonly Dictionary _hostileFactions = new Dictionary { {Faction.NanoTransen, Faction.SimpleHostile | Faction.Syndicate | Faction.Xeno}, diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index 83e3766405..af610df01d 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// /// Queued region updates /// - private HashSet _queuedUpdates = new HashSet(); + private readonly HashSet _queuedUpdates = new HashSet(); // Oh god the nesting. Shouldn't need to go beyond this /// @@ -53,7 +53,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// Regions are groups of nodes with the same profile (for pathfinding purposes) /// i.e. same collision, not-space, same access, etc. /// - private Dictionary>> _regions = + private readonly Dictionary>> _regions = new Dictionary>>(); /// @@ -70,7 +70,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible // Also, didn't use a dictionary because there didn't seem to be a clean way to do the lookup // Plus this way we can check if everything is equal except for vision so an entity with a lower vision radius can use an entity with a higher vision radius' cached result - private Dictionary Regions)>> _cachedAccessible = + private readonly Dictionary Regions)>> _cachedAccessible = new Dictionary)>>(); private readonly List _queuedCacheDeletions = new List(); diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/AStarPathfindingJob.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/AStarPathfindingJob.cs index d934f373ed..80ba5e19e3 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/AStarPathfindingJob.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/AStarPathfindingJob.cs @@ -15,9 +15,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders public static event Action DebugRoute; #endif - private PathfindingNode _startNode; + private readonly PathfindingNode _startNode; private PathfindingNode _endNode; - private PathfindingArgs _pathfindingArgs; + private readonly PathfindingArgs _pathfindingArgs; public AStarPathfindingJob( double maxTime, diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/JpsPathfindingJob.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/JpsPathfindingJob.cs index a426caeb9a..728004a829 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/JpsPathfindingJob.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Pathfinders/JpsPathfindingJob.cs @@ -19,9 +19,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders public static event Action DebugRoute; #endif - private PathfindingNode _startNode; + private readonly PathfindingNode _startNode; private PathfindingNode _endNode; - private PathfindingArgs _pathfindingArgs; + private readonly PathfindingArgs _pathfindingArgs; public JpsPathfindingJob(double maxTime, PathfindingNode startNode, diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingChunk.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingChunk.cs index 8bd0122010..50d16a4e79 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingChunk.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingChunk.cs @@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding // Nodes per chunk row public static int ChunkSize => 8; public PathfindingNode[,] Nodes => _nodes; - private PathfindingNode[,] _nodes = new PathfindingNode[ChunkSize,ChunkSize]; + private readonly PathfindingNode[,] _nodes = new PathfindingNode[ChunkSize,ChunkSize]; public PathfindingChunk(GridId gridId, Vector2i indices) { diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs index e0c8651744..ee777a175c 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs @@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering public MapCoordinates TargetMap => _target.Transform.MapPosition; public EntityCoordinates TargetGrid => _target.Transform.Coordinates; public IEntity Target => _target; - private IEntity _target; + private readonly IEntity _target; /// public float ArrivalDistance { get; } diff --git a/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs b/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs index c26bbc6320..14074c22b4 100644 --- a/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs @@ -17,32 +17,35 @@ using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Timing; +// ReSharper disable once RedundantUsingDirective +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Timing; +using Dependency = Robust.Shared.IoC.DependencyAttribute; namespace Content.Server.GameObjects.EntitySystems.Atmos { [UsedImplicitly] internal sealed class GasTileOverlaySystem : SharedGasTileOverlaySystem, IResettingEntitySystem { - [Robust.Shared.IoC.Dependency] private readonly IGameTiming _gameTiming = default!; - [Robust.Shared.IoC.Dependency] private readonly IPlayerManager _playerManager = default!; - [Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!; - [Robust.Shared.IoC.Dependency] private readonly IConfigurationManager _configManager = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IConfigurationManager _configManager = default!; /// /// The tiles that have had their atmos data updated since last tick /// - private Dictionary> _invalidTiles = new Dictionary>(); + private readonly Dictionary> _invalidTiles = new Dictionary>(); - private Dictionary _knownPlayerChunks = + private readonly Dictionary _knownPlayerChunks = new Dictionary(); /// /// Gas data stored in chunks to make PVS / bubbling easier. /// - private Dictionary> _overlay = + private readonly Dictionary> _overlay = new Dictionary>(); /// diff --git a/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs b/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs index 7a37e924ef..59b847effd 100644 --- a/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs +++ b/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs @@ -32,8 +32,8 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter public DoAfterStatus Status => AsTask.IsCompletedSuccessfully ? AsTask.Result : DoAfterStatus.Running; // NeedHand - private string? _activeHand; - private ItemComponent? _activeItem; + private readonly string? _activeHand; + private readonly ItemComponent? _activeItem; public DoAfter(DoAfterEventArgs eventArgs) { diff --git a/Content.Server/GameObjects/EntitySystems/DoorSystem.cs b/Content.Server/GameObjects/EntitySystems/DoorSystem.cs index f5c257826b..26e44f87e2 100644 --- a/Content.Server/GameObjects/EntitySystems/DoorSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/DoorSystem.cs @@ -34,8 +34,8 @@ namespace Content.Server.GameObjects.EntitySystems /// Allows everyone to open all doors. AllowAll } - - private List _activeDoors = new List(); + + private readonly List _activeDoors = new List(); public override void Initialize() { @@ -71,7 +71,7 @@ namespace Content.Server.GameObjects.EntitySystems var comp = _activeDoors[i]; if (comp.Deleted) _activeDoors.RemoveAt(i); - + comp.OnUpdate(frameTime); } } diff --git a/Content.Server/GameObjects/EntitySystems/EmergencyLightSystem.cs b/Content.Server/GameObjects/EntitySystems/EmergencyLightSystem.cs index 7cc406c8f8..ce0c0e0d3c 100644 --- a/Content.Server/GameObjects/EntitySystems/EmergencyLightSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/EmergencyLightSystem.cs @@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems [UsedImplicitly] internal sealed class EmergencyLightSystem : EntitySystem { - private List _activeLights = new List(); + private readonly List _activeLights = new List(); public override void Initialize() { @@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.EntitySystems case EmergencyLightComponent.EmergencyLightState.Charging: if (_activeLights.Contains(message.Component)) _activeLights.Add(message.Component); - + break; case EmergencyLightComponent.EmergencyLightState.Full: case EmergencyLightComponent.EmergencyLightState.Empty: diff --git a/Content.Server/GameObjects/EntitySystems/StationEvents/StationEventSystem.cs b/Content.Server/GameObjects/EntitySystems/StationEvents/StationEventSystem.cs index 6da998d840..3cf87305c4 100644 --- a/Content.Server/GameObjects/EntitySystems/StationEvents/StationEventSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StationEvents/StationEventSystem.cs @@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents public StationEvent CurrentEvent { get; private set; } public IReadOnlyCollection StationEvents => _stationEvents; - private List _stationEvents = new List(); + private readonly List _stationEvents = new List(); private const float MinimumTimeUntilFirstEvent = 300; diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 0efeed6880..0b04576b86 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -1025,15 +1025,15 @@ The current game mode is: [color=white]{0}[/color]. return preset; } - [Dependency] private IEntityManager _entityManager = default!; - [Dependency] private IMapManager _mapManager = default!; - [Dependency] private IMapLoader _mapLoader = default!; - [Dependency] private IGameTiming _gameTiming = default!; - [Dependency] private IConfigurationManager _configurationManager = default!; - [Dependency] private IChatManager _chatManager = default!; - [Dependency] private IServerNetManager _netManager = default!; - [Dependency] private IDynamicTypeFactory _dynamicTypeFactory = default!; - [Dependency] private IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IMapLoader _mapLoader = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IConfigurationManager _configurationManager = default!; + [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly IServerNetManager _netManager = default!; + [Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IServerPreferencesManager _prefsManager = default!; [Dependency] private readonly IBaseServer _baseServer = default!; diff --git a/Content.Server/StationEvents/PowerGridCheck.cs b/Content.Server/StationEvents/PowerGridCheck.cs index 8a961c2d5c..ab7e778f5c 100644 --- a/Content.Server/StationEvents/PowerGridCheck.cs +++ b/Content.Server/StationEvents/PowerGridCheck.cs @@ -29,18 +29,16 @@ namespace Content.Server.StationEvents private float _elapsedTime; private int _failDuration; - + /// /// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds. /// private bool _announced; private CancellationTokenSource _announceCancelToken; - - private List _powered = new List(); - - + private readonly List _powered = new List(); + public override void Startup() { base.Startup(); @@ -49,7 +47,7 @@ namespace Content.Server.StationEvents _elapsedTime = 0.0f; _failDuration = IoCManager.Resolve().Next(60, 120); var componentManager = IoCManager.Resolve(); - + foreach (PowerReceiverComponent component in componentManager.EntityQuery()) { component.PowerDisabled = true; @@ -64,13 +62,13 @@ namespace Content.Server.StationEvents foreach (var entity in _powered) { if (entity.Deleted) continue; - + if (entity.TryGetComponent(out PowerReceiverComponent powerReceiverComponent)) { powerReceiverComponent.PowerDisabled = false; } } - + _announceCancelToken?.Cancel(); _announceCancelToken = new CancellationTokenSource(); Timer.Spawn(3000, () => @@ -92,7 +90,7 @@ namespace Content.Server.StationEvents EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_off.ogg"); _announced = true; } - + _elapsedTime += frameTime; if (_elapsedTime < _failDuration) diff --git a/Content.Shared/Alert/AlertOrderPrototype.cs b/Content.Shared/Alert/AlertOrderPrototype.cs index 0fd5ee35c3..6bd84ed4ca 100644 --- a/Content.Shared/Alert/AlertOrderPrototype.cs +++ b/Content.Shared/Alert/AlertOrderPrototype.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Utility; @@ -13,8 +12,8 @@ namespace Content.Shared.Alert [Prototype("alertOrder")] public class AlertOrderPrototype : IPrototype, IComparer { - private Dictionary _typeToIdx = new Dictionary(); - private Dictionary _categoryToIdx = new Dictionary(); + private readonly Dictionary _typeToIdx = new Dictionary(); + private readonly Dictionary _categoryToIdx = new Dictionary(); public void LoadFrom(YamlMappingNode mapping) { diff --git a/Content.Shared/Construction/ConstructionGraphPrototype.cs b/Content.Shared/Construction/ConstructionGraphPrototype.cs index d9146745fc..5d557effd9 100644 --- a/Content.Shared/Construction/ConstructionGraphPrototype.cs +++ b/Content.Shared/Construction/ConstructionGraphPrototype.cs @@ -13,7 +13,7 @@ namespace Content.Shared.Construction public class ConstructionGraphPrototype : IPrototype, IIndexedPrototype { private readonly Dictionary _nodes = new Dictionary(); - private Dictionary, ConstructionGraphNode[]> _paths = new Dictionary, ConstructionGraphNode[]>(); + private readonly Dictionary, ConstructionGraphNode[]> _paths = new Dictionary, ConstructionGraphNode[]>(); private Dictionary _pathfinding = new Dictionary(); [ViewVariables] diff --git a/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs b/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs index a7ddb84857..148f432bb5 100644 --- a/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs +++ b/Content.Shared/GameObjects/Components/Body/Part/SharedBodyPartComponent.cs @@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part public IReadOnlyList MechanismIds => _mechanismIds; [ViewVariables] - private HashSet _mechanisms = new HashSet(); + private readonly HashSet _mechanisms = new HashSet(); [ViewVariables] public IBody? Body diff --git a/Content.Shared/GameObjects/Components/Research/SharedLatheDatabaseComponent.cs b/Content.Shared/GameObjects/Components/Research/SharedLatheDatabaseComponent.cs index 3044aeef52..14fd21a913 100644 --- a/Content.Shared/GameObjects/Components/Research/SharedLatheDatabaseComponent.cs +++ b/Content.Shared/GameObjects/Components/Research/SharedLatheDatabaseComponent.cs @@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Research public override string Name => "LatheDatabase"; public override uint? NetID => ContentNetIDs.LATHE_DATABASE; - private List _recipes = new List(); + private readonly List _recipes = new List(); /// /// Removes all recipes from the database if it's not static. diff --git a/Content.Shared/GameObjects/Components/Research/SharedProtolatheDatabaseComponent.cs b/Content.Shared/GameObjects/Components/Research/SharedProtolatheDatabaseComponent.cs index 39d5d82051..ceffd45057 100644 --- a/Content.Shared/GameObjects/Components/Research/SharedProtolatheDatabaseComponent.cs +++ b/Content.Shared/GameObjects/Components/Research/SharedProtolatheDatabaseComponent.cs @@ -15,7 +15,7 @@ namespace Content.Shared.GameObjects.Components.Research public override string Name => "ProtolatheDatabase"; public sealed override uint? NetID => ContentNetIDs.PROTOLATHE_DATABASE; - private List _protolatheRecipes = new List(); + private readonly List _protolatheRecipes = new List(); /// /// A full list of recipes this protolathe can print. diff --git a/Content.Shared/Physics/FrictionController.cs b/Content.Shared/Physics/FrictionController.cs index 92e9e17baf..0b9eb019ce 100644 --- a/Content.Shared/Physics/FrictionController.cs +++ b/Content.Shared/Physics/FrictionController.cs @@ -7,7 +7,7 @@ namespace Content.Shared.Physics { public abstract class FrictionController : VirtualController { - [Dependency] private IPhysicsManager _physicsManager = default!; + [Dependency] private readonly IPhysicsManager _physicsManager = default!; public override void UpdateAfterProcessing() {