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

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