Add readonly where it is missing and fix those field names according to their modifiers (#2589)

This commit is contained in:
DrSmugleaf
2020-11-21 14:02:00 +01:00
committed by GitHub
parent c7f2b67297
commit 749cd11d33
94 changed files with 344 additions and 374 deletions

View File

@@ -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
});
}

View File

@@ -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)
{

View File

@@ -62,7 +62,7 @@ namespace Content.Client.Eui
private sealed class EuiData
{
public BaseEui Eui;
public readonly BaseEui Eui;
public EuiData(BaseEui eui)
{

View File

@@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Cargo
[RegisterComponent]
public class CargoOrderDatabaseComponent : SharedCargoOrderDatabaseComponent
{
private List<CargoOrderData> _orders = new List<CargoOrderData>();
private readonly List<CargoOrderData> _orders = new List<CargoOrderData>();
public IReadOnlyList<CargoOrderData> Orders => _orders;
/// <summary>

View File

@@ -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!;

View File

@@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.Components.Gravity
{
public class GravityGeneratorVisualizer : AppearanceVisualizer
{
private Dictionary<GravityGeneratorStatus, string> _spriteMap = new Dictionary<GravityGeneratorStatus, string>();
private readonly Dictionary<GravityGeneratorStatus, string> _spriteMap = new Dictionary<GravityGeneratorStatus, string>();
public override void InitializeEntity(IEntity entity)
{

View File

@@ -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;

View File

@@ -26,8 +26,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
private MicrowaveMenu _menu;
private Dictionary<int, EntityUid> _solids = new Dictionary<int, EntityUid>();
private Dictionary<int, Solution.ReagentQuantity> _reagents =new Dictionary<int, Solution.ReagentQuantity>();
private readonly Dictionary<int, EntityUid> _solids = new Dictionary<int, EntityUid>();
private readonly Dictionary<int, Solution.ReagentQuantity> _reagents =new Dictionary<int, Solution.ReagentQuantity>();
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey)
{

View File

@@ -361,7 +361,7 @@ namespace Content.Client.GameObjects.Components
}
[ViewVariables(VVAccess.ReadOnly)]
private List<AnimationContainer> _animations = new List<AnimationContainer>();
private readonly List<AnimationContainer> _animations = new List<AnimationContainer>();
private float _originalRadius = default;
private float _originalEnergy = default;

View File

@@ -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;

View File

@@ -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<AlertKey, AlertControl> _alertControls
private readonly Dictionary<AlertKey, AlertControl> _alertControls
= new Dictionary<AlertKey, AlertControl>();
/// <summary>

View File

@@ -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<BaseButton.ButtonEventArgs, UplinkListingData> OnListingButtonPressed;
public event Action<BaseButton.ButtonEventArgs, UplinkCategory> OnCategoryButtonPressed;

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components
{
public class ParticleAcceleratorPartVisualizer : AppearanceVisualizer
{
private Dictionary<ParticleAcceleratorVisualState, string> _states = new Dictionary<ParticleAcceleratorVisualState, string>();
private readonly Dictionary<ParticleAcceleratorVisualState, string> _states = new Dictionary<ParticleAcceleratorVisualState, string>();
public override void LoadData(YamlMappingNode node)
{

View File

@@ -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)
{

View File

@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Research
[ViewVariables]
public Queue<LatheRecipePrototype> QueuedRecipes => _queuedRecipes;
private Queue<LatheRecipePrototype> _queuedRecipes = new Queue<LatheRecipePrototype>();
private readonly Queue<LatheRecipePrototype> _queuedRecipes = new Queue<LatheRecipePrototype>();
public LatheBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{

View File

@@ -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[]{};

View File

@@ -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
/// </summary>
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);
}
}

View File

@@ -39,7 +39,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
{"broken", VendingMachineVisualLayers.Unlit},
};
private Dictionary<string, Animation> _animations = new Dictionary<string, Animation>();
private readonly Dictionary<string, Animation> _animations = new Dictionary<string, Animation>();
public override void LoadData(YamlMappingNode node)
{

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -15,7 +15,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
private IGameTiming _gameTiming = default!;
private ShaderInstance _shader;
private readonly ShaderInstance _shader;
/// <summary>
/// Set from 0.0f to 1.0f to reflect bar progress

View File

@@ -21,11 +21,11 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>();
private Dictionary<byte, DoAfterBar> _doAfterBars = new Dictionary<byte, DoAfterBar>();
private readonly Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>();
private readonly Dictionary<byte, DoAfterBar> _doAfterBars = new Dictionary<byte, DoAfterBar>();
// We'll store cancellations for a little bit just so we can flash the graphic to indicate it's cancelled
private Dictionary<byte, TimeSpan> _cancelledDoAfters = new Dictionary<byte, TimeSpan>();
private readonly Dictionary<byte, TimeSpan> _cancelledDoAfters = new Dictionary<byte, TimeSpan>();
public IEntity? AttachedEntity { get; set; }
private ScreenCoordinates _playerPosition;

View File

@@ -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<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private readonly HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private IEntity? _attachedEntity;

View File

@@ -71,7 +71,7 @@ namespace Content.Client.GameObjects.EntitySystems
private SharedInteractionSystem _interactionSystem;
private InputSystem _inputSystem;
private List<SpriteComponent> highlightedSprites = new List<SpriteComponent>();
private readonly List<SpriteComponent> _highlightedSprites = new List<SpriteComponent>();
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();
}
/// <summary>

View File

@@ -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<GridId, Dictionary<Vector2i, GasOverlayChunk>> _tileData =
private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _tileData =
new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>();
private AtmosphereSystem _atmosphereSystem = default!;

View File

@@ -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;
}
}
}

View File

@@ -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)

View File

@@ -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<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
private List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
private readonly List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
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
/// </summary>
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
/// </summary>
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;
}

View File

@@ -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++;
}
}

View File

@@ -18,19 +18,19 @@ namespace Content.Client.Research
protected override Vector2? CustomSize => (800, 400);
private List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>();
private List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>();
private List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>();
private readonly List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>();
private readonly List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>();
private readonly List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>();
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; }

View File

@@ -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()
{

View File

@@ -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"
};

View File

@@ -23,7 +23,7 @@ namespace Content.Client.UserInterface.Cargo
public event Action<BaseButton.ButtonEventArgs> OnOrderApproved;
public event Action<BaseButton.ButtonEventArgs> OnOrderCanceled;
private List<string> _categoryStrings = new List<string>();
private readonly List<string> _categoryStrings = new List<string>();
private Label _accountNameLabel { get; set; }
private Label _pointsLabel { get; set; }

View File

@@ -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[] { };

View File

@@ -14,7 +14,7 @@ namespace Content.Client.UserInterface
[Dependency] private readonly IPrototypeManager _protoMan = default!;
private ShaderInstance _shader;
private readonly ShaderInstance _shader;
public CooldownGraphic()
{

View File

@@ -26,7 +26,7 @@ namespace Content.Client.UserInterface
public event Action<string> SelectedId;
private Dictionary<string, JobButton> JobButtons = new Dictionary<string, JobButton>();
private readonly Dictionary<string, JobButton> _jobButtons = new Dictionary<string, JobButton>();
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<string> 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();
}
}
}

View File

@@ -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)

View File

@@ -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()
{

View File

@@ -24,7 +24,7 @@ namespace Content.Client.ParticleAccelerator
{
public sealed class ParticleAcceleratorControlMenu : BaseWindow
{
private ShaderInstance _greyScaleShader;
private readonly ShaderInstance _greyScaleShader;
private readonly ParticleAcceleratorBoundUserInterface Owner;

View File

@@ -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;

View File

@@ -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;

View File

@@ -16,7 +16,7 @@ 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,

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -7,7 +7,7 @@ namespace Content.Server.AI.Utility.Considerations
{
public class ConsiderationsManager
{
private Dictionary<Type, Consideration> _considerations = new Dictionary<Type, Consideration>();
private readonly Dictionary<Type, Consideration> _considerations = new Dictionary<Type, Consideration>();
public void Initialize()
{

View File

@@ -14,7 +14,7 @@ namespace Content.Server.AI.WorldState
{
// Cache the known types
public IReadOnlyCollection<Type> AiStates => _aiStates;
private List<Type> _aiStates = new List<Type>();
private readonly List<Type> _aiStates = new List<Type>();
public void Initialize()
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Cargo
{
public class CargoOrderDatabase
{
private Dictionary<int, CargoOrderData> _orders = new Dictionary<int, CargoOrderData>();
private readonly Dictionary<int, CargoOrderData> _orders = new Dictionary<int, CargoOrderData>();
private int _orderNumber = 0;
public CargoOrderDatabase(int id)

View File

@@ -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<IPlayerSession> _spectators = new List<IPlayerSession>();
private readonly List<IPlayerSession> _spectators = new List<IPlayerSession>();
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<BlockGameBlock> _field = new List<BlockGameBlock>();
private readonly List<BlockGameBlock> _field = new List<BlockGameBlock>();
private BlockGamePiece _currentPiece;

View File

@@ -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
/// </summary>
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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/player_attack.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!Owner._enemyInvincibilityFlag) _enemyHp -= attackAmount;
EntitySystem.Get<AudioSystem>().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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/player_heal.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!Owner._playerInvincibilityFlag) _playerMp -= pointAmount;
EntitySystem.Get<AudioSystem>().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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/player_charge.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
EntitySystem.Get<AudioSystem>().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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/win.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
Owner.ProcessWin();
EntitySystem.Get<AudioSystem>().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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
EntitySystem.Get<AudioSystem>().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<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", Owner.Owner, AudioParams.Default.WithVolume(-4f));
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
return false;
}
@@ -377,7 +377,7 @@ namespace Content.Server.GameObjects.Components.Arcade
/// </summary>
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;
}
}

View File

@@ -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";

View File

@@ -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);

View File

@@ -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";

View File

@@ -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<string> Prototypes { get; set; } = new List<string>();
[ViewVariables(VVAccess.ReadWrite)]
private List<string> _gameRules = new List<string>();
private readonly List<string> _gameRules = new List<string>();
[ViewVariables(VVAccess.ReadWrite)]
public float Chance { get; set; } = 1.0f;

View File

@@ -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; }

View File

@@ -25,7 +25,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
public AMEControllerComponent MasterController => _masterController;
private List<AMEShieldComponent> _cores = new List<AMEShieldComponent>();
private readonly List<AMEShieldComponent> _cores = new List<AMEShieldComponent>();
public int CoreCount => _cores.Count;

View File

@@ -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<HungerThreshold, float> HungerThresholds => _hungerThresholds;
private Dictionary<HungerThreshold, float> _hungerThresholds = new Dictionary<HungerThreshold, float>
private readonly Dictionary<HungerThreshold, float> _hungerThresholds = new Dictionary<HungerThreshold, float>
{
{HungerThreshold.Overfed, 600.0f},
{HungerThreshold.Okay, 450.0f},

View File

@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
[RegisterComponent]
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit, ISignalReceiver<bool>, ISignalReceiver<ToggleSignal>
{
[Dependency] private IGameTiming _gameTiming = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "PoweredLight";

View File

@@ -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<IEntity> _intersecting = new List<IEntity>();
private readonly List<IEntity> _intersecting = new List<IEntity>();
/// <summary>
/// Whether or not sentient beings will be recycled

View File

@@ -15,9 +15,9 @@ namespace Content.Server.GameObjects.Components.Singularity
{
public readonly ContainmentFieldGeneratorComponent Generator1;
public readonly ContainmentFieldGeneratorComponent Generator2;
private List<IEntity> _fields = new List<IEntity>();
private readonly List<IEntity> _fields = new List<IEntity>();
private int _sharedEnergyPool;
private CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource();
private readonly CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource();
public int SharedEnergyPool
{
get => _sharedEnergyPool;

View File

@@ -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";

View File

@@ -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";

View File

@@ -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<IEntity> _previousPulledEntites = new List<IEntity>();
private readonly List<IEntity> _previousPulledEntities = new List<IEntity>();
public void PullUpdate()
{
foreach (var previousPulledEntity in _previousPulledEntites)
foreach (var previousPulledEntity in _previousPulledEntities)
{
if(previousPulledEntity.Deleted) continue;
if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>();
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);
}
}

View File

@@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
{
public override string Name => "RangedMagazine";
private Stack<IEntity> _spawnedAmmo = new Stack<IEntity>();
private readonly Stack<IEntity> _spawnedAmmo = new Stack<IEntity>();
private Container _ammoContainer;
public int ShotsLeft => _spawnedAmmo.Count + _unspawnedCount;

View File

@@ -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<Faction, Faction> _hostileFactions = new Dictionary<Faction, Faction>
private readonly Dictionary<Faction, Faction> _hostileFactions = new Dictionary<Faction, Faction>
{
{Faction.NanoTransen,
Faction.SimpleHostile | Faction.Syndicate | Faction.Xeno},

View File

@@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
/// <summary>
/// Queued region updates
/// </summary>
private HashSet<PathfindingChunk> _queuedUpdates = new HashSet<PathfindingChunk>();
private readonly HashSet<PathfindingChunk> _queuedUpdates = new HashSet<PathfindingChunk>();
// Oh god the nesting. Shouldn't need to go beyond this
/// <summary>
@@ -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.
/// </summary>
private Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>> _regions =
private readonly Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>> _regions =
new Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>>();
/// <summary>
@@ -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<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan CacheTime, HashSet<PathfindingRegion> Regions)>> _cachedAccessible =
private readonly Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan CacheTime, HashSet<PathfindingRegion> Regions)>> _cachedAccessible =
new Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan, HashSet<PathfindingRegion>)>>();
private readonly List<PathfindingRegion> _queuedCacheDeletions = new List<PathfindingRegion>();

View File

@@ -15,9 +15,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
public static event Action<SharedAiDebug.AStarRouteDebug> DebugRoute;
#endif
private PathfindingNode _startNode;
private readonly PathfindingNode _startNode;
private PathfindingNode _endNode;
private PathfindingArgs _pathfindingArgs;
private readonly PathfindingArgs _pathfindingArgs;
public AStarPathfindingJob(
double maxTime,

View File

@@ -19,9 +19,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
public static event Action<SharedAiDebug.JpsRouteDebug> 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,

View File

@@ -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)
{

View File

@@ -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;
/// <inheritdoc />
public float ArrivalDistance { get; }

View File

@@ -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!;
/// <summary>
/// The tiles that have had their atmos data updated since last tick
/// </summary>
private Dictionary<GridId, HashSet<Vector2i>> _invalidTiles = new Dictionary<GridId, HashSet<Vector2i>>();
private readonly Dictionary<GridId, HashSet<Vector2i>> _invalidTiles = new Dictionary<GridId, HashSet<Vector2i>>();
private Dictionary<IPlayerSession, PlayerGasOverlay> _knownPlayerChunks =
private readonly Dictionary<IPlayerSession, PlayerGasOverlay> _knownPlayerChunks =
new Dictionary<IPlayerSession, PlayerGasOverlay>();
/// <summary>
/// Gas data stored in chunks to make PVS / bubbling easier.
/// </summary>
private Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _overlay =
private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _overlay =
new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>();
/// <summary>

View File

@@ -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)
{

View File

@@ -35,7 +35,7 @@ namespace Content.Server.GameObjects.EntitySystems
AllowAll
}
private List<ServerDoorComponent> _activeDoors = new List<ServerDoorComponent>();
private readonly List<ServerDoorComponent> _activeDoors = new List<ServerDoorComponent>();
public override void Initialize()
{

View File

@@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly]
internal sealed class EmergencyLightSystem : EntitySystem
{
private List<EmergencyLightComponent> _activeLights = new List<EmergencyLightComponent>();
private readonly List<EmergencyLightComponent> _activeLights = new List<EmergencyLightComponent>();
public override void Initialize()
{

View File

@@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
public StationEvent CurrentEvent { get; private set; }
public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents;
private List<StationEvent> _stationEvents = new List<StationEvent>();
private readonly List<StationEvent> _stationEvents = new List<StationEvent>();
private const float MinimumTimeUntilFirstEvent = 300;

View File

@@ -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!;

View File

@@ -37,9 +37,7 @@ namespace Content.Server.StationEvents
private CancellationTokenSource _announceCancelToken;
private List<IEntity> _powered = new List<IEntity>();
private readonly List<IEntity> _powered = new List<IEntity>();
public override void Startup()
{

View File

@@ -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<AlertPrototype>
{
private Dictionary<AlertType, int> _typeToIdx = new Dictionary<AlertType, int>();
private Dictionary<AlertCategory, int> _categoryToIdx = new Dictionary<AlertCategory, int>();
private readonly Dictionary<AlertType, int> _typeToIdx = new Dictionary<AlertType, int>();
private readonly Dictionary<AlertCategory, int> _categoryToIdx = new Dictionary<AlertCategory, int>();
public void LoadFrom(YamlMappingNode mapping)
{

View File

@@ -13,7 +13,7 @@ namespace Content.Shared.Construction
public class ConstructionGraphPrototype : IPrototype, IIndexedPrototype
{
private readonly Dictionary<string, ConstructionGraphNode> _nodes = new Dictionary<string, ConstructionGraphNode>();
private Dictionary<ValueTuple<string, string>, ConstructionGraphNode[]> _paths = new Dictionary<ValueTuple<string, string>, ConstructionGraphNode[]>();
private readonly Dictionary<ValueTuple<string, string>, ConstructionGraphNode[]> _paths = new Dictionary<ValueTuple<string, string>, ConstructionGraphNode[]>();
private Dictionary<ConstructionGraphNode, ConstructionGraphNode> _pathfinding = new Dictionary<ConstructionGraphNode, ConstructionGraphNode>();
[ViewVariables]

View File

@@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part
public IReadOnlyList<string> MechanismIds => _mechanismIds;
[ViewVariables]
private HashSet<IMechanism> _mechanisms = new HashSet<IMechanism>();
private readonly HashSet<IMechanism> _mechanisms = new HashSet<IMechanism>();
[ViewVariables]
public IBody? Body

View File

@@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Research
public override string Name => "LatheDatabase";
public override uint? NetID => ContentNetIDs.LATHE_DATABASE;
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
/// <summary>
/// Removes all recipes from the database if it's not static.

View File

@@ -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<LatheRecipePrototype> _protolatheRecipes = new List<LatheRecipePrototype>();
private readonly List<LatheRecipePrototype> _protolatheRecipes = new List<LatheRecipePrototype>();
/// <summary>
/// A full list of recipes this protolathe can print.

View File

@@ -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()
{