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.Linq;
using System.Net.Mime;
using Content.Client.GameObjects.Components.Arcade; using Content.Client.GameObjects.Components.Arcade;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.Arcade; using Content.Shared.Arcade;
using Content.Shared.GameObjects.Components.Arcade;
using Content.Shared.Input; using Content.Shared.Input;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Graphics.Drawing; using Robust.Client.Graphics.Drawing;
@@ -13,7 +10,6 @@ using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Input;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -22,15 +18,14 @@ namespace Content.Client.Arcade
{ {
public class BlockGameMenu : SS14Window 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 readonly Vector2 BlockSize = new Vector2(15,15);
private static Color overlayShadowColor = new Color(0,0,0,83);
private static Vector2 blockSize = new Vector2(15,15); private readonly BlockGameBoundUserInterface _owner;
private BlockGameBoundUserInterface _owner; private readonly PanelContainer _mainPanel;
private PanelContainer _mainPanel;
private VBoxContainer _gameRootContainer; private VBoxContainer _gameRootContainer;
private GridContainer _gameGrid; private GridContainer _gameGrid;
@@ -88,7 +83,7 @@ namespace Content.Client.Arcade
var rootBack = new StyleBoxTexture var rootBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
Modulate = overlayShadowColor Modulate = OverlayShadowColor
}; };
rootBack.SetPatchMargin(StyleBox.Margin.All, 10); rootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_highscoresRootContainer = new PanelContainer _highscoresRootContainer = new PanelContainer
@@ -98,7 +93,7 @@ namespace Content.Client.Arcade
SizeFlagsHorizontal = SizeFlags.ShrinkCenter 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 var innerBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
@@ -154,7 +149,7 @@ namespace Content.Client.Arcade
var rootBack = new StyleBoxTexture var rootBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
Modulate = overlayShadowColor Modulate = OverlayShadowColor
}; };
rootBack.SetPatchMargin(StyleBox.Margin.All, 10); rootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_gameOverRootContainer = new PanelContainer _gameOverRootContainer = new PanelContainer
@@ -167,7 +162,7 @@ namespace Content.Client.Arcade
var innerBack = new StyleBoxTexture var innerBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
Modulate = overlayBackgroundColor Modulate = OverlayBackgroundColor
}; };
innerBack.SetPatchMargin(StyleBox.Margin.All, 10); innerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var menuInnerPanel = new PanelContainer var menuInnerPanel = new PanelContainer
@@ -212,7 +207,7 @@ namespace Content.Client.Arcade
var rootBack = new StyleBoxTexture var rootBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
Modulate = overlayShadowColor Modulate = OverlayShadowColor
}; };
rootBack.SetPatchMargin(StyleBox.Margin.All, 10); rootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_menuRootContainer = new PanelContainer _menuRootContainer = new PanelContainer
@@ -225,7 +220,7 @@ namespace Content.Client.Arcade
var innerBack = new StyleBoxTexture var innerBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
Modulate = overlayBackgroundColor Modulate = OverlayBackgroundColor
}; };
innerBack.SetPatchMargin(StyleBox.Margin.All, 10); innerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var menuInnerPanel = new PanelContainer var menuInnerPanel = new PanelContainer
@@ -404,7 +399,7 @@ namespace Content.Client.Arcade
var nextBlockPanel = new PanelContainer var nextBlockPanel = new PanelContainer
{ {
PanelOverride = previewBack, PanelOverride = previewBack,
CustomMinimumSize = blockSize * 6.5f, CustomMinimumSize = BlockSize * 6.5f,
SizeFlagsHorizontal = SizeFlags.None, SizeFlagsHorizontal = SizeFlags.None,
SizeFlagsVertical = SizeFlags.None SizeFlagsVertical = SizeFlags.None
}; };
@@ -442,7 +437,7 @@ namespace Content.Client.Arcade
var holdBlockPanel = new PanelContainer var holdBlockPanel = new PanelContainer
{ {
PanelOverride = previewBack, PanelOverride = previewBack,
CustomMinimumSize = blockSize * 6.5f, CustomMinimumSize = BlockSize * 6.5f,
SizeFlagsHorizontal = SizeFlags.None, SizeFlagsHorizontal = SizeFlags.None,
SizeFlagsVertical = SizeFlags.None SizeFlagsVertical = SizeFlags.None
}; };
@@ -623,7 +618,7 @@ namespace Content.Client.Arcade
_nextBlockGrid.AddChild(new PanelContainer _nextBlockGrid.AddChild(new PanelContainer
{ {
PanelOverride = new StyleBoxFlat {BackgroundColor = c}, PanelOverride = new StyleBoxFlat {BackgroundColor = c},
CustomMinimumSize = blockSize, CustomMinimumSize = BlockSize,
RectDrawClipMargin = 0 RectDrawClipMargin = 0
}); });
} }
@@ -645,7 +640,7 @@ namespace Content.Client.Arcade
_holdBlockGrid.AddChild(new PanelContainer _holdBlockGrid.AddChild(new PanelContainer
{ {
PanelOverride = new StyleBoxFlat {BackgroundColor = c}, PanelOverride = new StyleBoxFlat {BackgroundColor = c},
CustomMinimumSize = blockSize, CustomMinimumSize = BlockSize,
RectDrawClipMargin = 0 RectDrawClipMargin = 0
}); });
} }
@@ -663,7 +658,7 @@ namespace Content.Client.Arcade
_gameGrid.AddChild(new PanelContainer _gameGrid.AddChild(new PanelContainer
{ {
PanelOverride = new StyleBoxFlat {BackgroundColor = c}, PanelOverride = new StyleBoxFlat {BackgroundColor = c},
CustomMinimumSize = blockSize, CustomMinimumSize = BlockSize,
RectDrawClipMargin = 0 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 Content.Shared.GameObjects.Components.Arcade;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
@@ -13,13 +12,13 @@ namespace Content.Client.Arcade
protected override Vector2? CustomSize => (400, 200); protected override Vector2? CustomSize => (400, 200);
public SpaceVillainArcadeBoundUserInterface Owner { get; set; } public SpaceVillainArcadeBoundUserInterface Owner { get; set; }
private Label _enemyNameLabel; private readonly Label _enemyNameLabel;
private Label _playerInfoLabel; private readonly Label _playerInfoLabel;
private Label _enemyInfoLabel; private readonly Label _enemyInfoLabel;
private Label _playerActionLabel; private readonly Label _playerActionLabel;
private Label _enemyActionLabel; 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) public SpaceVillainArcadeMenu(SpaceVillainArcadeBoundUserInterface owner)
{ {
Title = Loc.GetString("Space Villain"); Title = Loc.GetString("Space Villain");
@@ -97,8 +96,8 @@ namespace Content.Client.Arcade
private class ActionButton : Button private class ActionButton : Button
{ {
private SpaceVillainArcadeBoundUserInterface _owner; private readonly SpaceVillainArcadeBoundUserInterface _owner;
private SharedSpaceVillainArcadeComponent.PlayerAction _playerAction; private readonly SharedSpaceVillainArcadeComponent.PlayerAction _playerAction;
public ActionButton(SpaceVillainArcadeBoundUserInterface owner,SharedSpaceVillainArcadeComponent.PlayerAction playerAction) public ActionButton(SpaceVillainArcadeBoundUserInterface owner,SharedSpaceVillainArcadeComponent.PlayerAction playerAction)
{ {

View File

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

View File

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

View File

@@ -25,9 +25,9 @@ namespace Content.Client.GameObjects.Components.CloningPod
public readonly Button EjectButton; public readonly Button EjectButton;
private readonly CloningScanButton _measureButton; private readonly CloningScanButton _measureButton;
private CloningScanButton? _selectedButton; private CloningScanButton? _selectedButton;
private Label _progressLabel; private readonly Label _progressLabel;
private readonly ProgressBar _cloningProgressBar; private readonly ProgressBar _cloningProgressBar;
private Label _mindState; private readonly Label _mindState;
protected override Vector2 ContentsMinimumSize => _mainVBox?.CombinedMinimumSize ?? Vector2.Zero; protected override Vector2 ContentsMinimumSize => _mainVBox?.CombinedMinimumSize ?? Vector2.Zero;
private CloningPodBoundUserInterfaceState _lastUpdate = null!; private CloningPodBoundUserInterfaceState _lastUpdate = null!;

View File

@@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.Components.Gravity
{ {
public class GravityGeneratorVisualizer : AppearanceVisualizer 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) public override void InitializeEntity(IEntity entity)
{ {

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Items
[ComponentReference(typeof(IItemComponent))] [ComponentReference(typeof(IItemComponent))]
public class ItemComponent : Component, IItemComponent, IDraggable public class ItemComponent : Component, IItemComponent, IDraggable
{ {
[Dependency] private IResourceCache _resourceCache = default!; [Dependency] private readonly IResourceCache _resourceCache = default!;
public override string Name => "Item"; public override string Name => "Item";
public override uint? NetID => ContentNetIDs.ITEM; public override uint? NetID => ContentNetIDs.ITEM;

View File

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

View File

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

View File

@@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Mobs
private short? _severity; private short? _severity;
private readonly TextureRect _icon; private readonly TextureRect _icon;
private CooldownGraphic _cooldownGraphic; private readonly CooldownGraphic _cooldownGraphic;
private readonly IResourceCache _resourceCache; private readonly IResourceCache _resourceCache;

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.Alert; using Content.Shared.Alert;
using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
@@ -19,11 +18,9 @@ using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using Serilog;
namespace Content.Client.GameObjects.Components.Mobs namespace Content.Client.GameObjects.Components.Mobs
{ {
@@ -47,7 +44,7 @@ namespace Content.Client.GameObjects.Components.Mobs
private bool _tooltipReady; private bool _tooltipReady;
[ViewVariables] [ViewVariables]
private Dictionary<AlertKey, AlertControl> _alertControls private readonly Dictionary<AlertKey, AlertControl> _alertControls
= new Dictionary<AlertKey, AlertControl>(); = new Dictionary<AlertKey, AlertControl>();
/// <summary> /// <summary>

View File

@@ -228,7 +228,7 @@ namespace Content.Client.GameObjects.Components.PDA
public Button EjectIDButton { get; } public Button EjectIDButton { get; }
public Button EjectPenButton { get; } public Button EjectPenButton { get; }
public TabContainer MasterTabContainer; public readonly TabContainer MasterTabContainer;
public RichTextLabel PDAOwnerLabel { get; } public RichTextLabel PDAOwnerLabel { get; }
public PanelContainer IDInfoContainer { get; } public PanelContainer IDInfoContainer { get; }
@@ -236,14 +236,14 @@ namespace Content.Client.GameObjects.Components.PDA
public VBoxContainer UplinkTabContainer { get; } 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 readonly VBoxContainer CategoryListContainer;
public RichTextLabel BalanceInfo; public readonly RichTextLabel BalanceInfo;
public event Action<BaseButton.ButtonEventArgs, UplinkListingData> OnListingButtonPressed; public event Action<BaseButton.ButtonEventArgs, UplinkListingData> OnListingButtonPressed;
public event Action<BaseButton.ButtonEventArgs, UplinkCategory> OnCategoryButtonPressed; public event Action<BaseButton.ButtonEventArgs, UplinkCategory> OnCategoryButtonPressed;

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components
{ {
public class ParticleAcceleratorPartVisualizer : AppearanceVisualizer 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) public override void LoadData(YamlMappingNode node)
{ {

View File

@@ -14,8 +14,7 @@ namespace Content.Client.GameObjects.Components.Power
{ {
public class SolarControlConsoleBoundUserInterface : BoundUserInterface public class SolarControlConsoleBoundUserInterface : BoundUserInterface
{ {
[Dependency] [Dependency] private readonly IGameTiming _gameTiming = default;
private IGameTiming _gameTiming = default;
private SolarControlWindow _window; private SolarControlWindow _window;
private SolarControlConsoleBoundInterfaceState _lastState = new SolarControlConsoleBoundInterfaceState(0, 0, 0, 0); private SolarControlConsoleBoundInterfaceState _lastState = new SolarControlConsoleBoundInterfaceState(0, 0, 0, 0);
@@ -93,13 +92,13 @@ namespace Content.Client.GameObjects.Components.Power
private sealed class SolarControlWindow : SS14Window private sealed class SolarControlWindow : SS14Window
{ {
public Label OutputPower; public readonly Label OutputPower;
public Label SunAngle; public readonly Label SunAngle;
public SolarControlNotARadar NotARadar; public readonly SolarControlNotARadar NotARadar;
public LineEdit PanelRotation; public readonly LineEdit PanelRotation;
public LineEdit PanelVelocity; public readonly LineEdit PanelVelocity;
public SolarControlWindow(IGameTiming igt) public SolarControlWindow(IGameTiming igt)
{ {

View File

@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Research
[ViewVariables] [ViewVariables]
public Queue<LatheRecipePrototype> QueuedRecipes => _queuedRecipes; 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) 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 public class ResearchClientServerSelectionMenu : SS14Window
{ {
private ItemList _servers; private readonly ItemList _servers;
private int _serverCount = 0; private int _serverCount = 0;
private string[] _serverNames = new string[]{}; private string[] _serverNames = new string[]{};
private int[] _serverIds = new int[]{}; private int[] _serverIds = new int[]{};

View File

@@ -134,12 +134,12 @@ namespace Content.Client.GameObjects.Components.Storage
private class StorageWindow : SS14Window private class StorageWindow : SS14Window
{ {
private Control VSplitContainer; private Control VSplitContainer;
private VBoxContainer EntityList; private readonly VBoxContainer _entityList;
private Label Information; private readonly Label _information;
public ClientStorageComponent StorageEntity; public ClientStorageComponent StorageEntity;
private StyleBoxFlat _HoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.35f) }; private readonly StyleBoxFlat _hoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.35f) };
private StyleBoxFlat _unHoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.0f) }; private readonly StyleBoxFlat _unHoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.0f) };
protected override Vector2? CustomSize => (180, 320); protected override Vector2? CustomSize => (180, 320);
@@ -179,12 +179,12 @@ namespace Content.Client.GameObjects.Components.Storage
MouseFilter = MouseFilterMode.Ignore, MouseFilter = MouseFilterMode.Ignore,
}; };
containerButton.AddChild(VSplitContainer); containerButton.AddChild(VSplitContainer);
Information = new Label _information = new Label
{ {
Text = "Items: 0 Volume: 0/0 Stuff", Text = "Items: 0 Volume: 0/0 Stuff",
SizeFlagsVertical = SizeFlags.ShrinkCenter SizeFlagsVertical = SizeFlags.ShrinkCenter
}; };
VSplitContainer.AddChild(Information); VSplitContainer.AddChild(_information);
var listScrollContainer = new ScrollContainer var listScrollContainer = new ScrollContainer
{ {
@@ -193,18 +193,18 @@ namespace Content.Client.GameObjects.Components.Storage
HScrollEnabled = true, HScrollEnabled = true,
VScrollEnabled = true, VScrollEnabled = true,
}; };
EntityList = new VBoxContainer _entityList = new VBoxContainer
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand SizeFlagsHorizontal = SizeFlags.FillExpand
}; };
listScrollContainer.AddChild(EntityList); listScrollContainer.AddChild(_entityList);
VSplitContainer.AddChild(listScrollContainer); VSplitContainer.AddChild(listScrollContainer);
Contents.AddChild(containerButton); Contents.AddChild(containerButton);
listScrollContainer.OnMouseEntered += args => listScrollContainer.OnMouseEntered += args =>
{ {
innerContainerButton.PanelOverride = _HoveredBox; innerContainerButton.PanelOverride = _hoveredBox;
}; };
listScrollContainer.OnMouseExited += args => listScrollContainer.OnMouseExited += args =>
@@ -224,7 +224,7 @@ namespace Content.Client.GameObjects.Components.Storage
/// </summary> /// </summary>
public void BuildEntityList() public void BuildEntityList()
{ {
EntityList.DisposeAllChildren(); _entityList.DisposeAllChildren();
var storageList = StorageEntity.StoredEntities; var storageList = StorageEntity.StoredEntities;
@@ -254,18 +254,18 @@ namespace Content.Client.GameObjects.Components.Storage
button.EntitySpriteView.Sprite = sprite; button.EntitySpriteView.Sprite = sprite;
} }
EntityList.AddChild(button); _entityList.AddChild(button);
} }
//Sets information about entire storage container current capacity //Sets information about entire storage container current capacity
if (StorageEntity.StorageCapacityMax != 0) 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); StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax);
} }
else 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}, {"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) public override void LoadData(YamlMappingNode node)
{ {

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Wires
{ {
public class WiresMenu : BaseWindow public class WiresMenu : BaseWindow
{ {
[Dependency] private IResourceCache _resourceCache = default!; [Dependency] private readonly IResourceCache _resourceCache = default!;
public WiresBoundUserInterface Owner { get; } public WiresBoundUserInterface Owner { get; }
@@ -424,7 +424,7 @@ namespace Content.Client.GameObjects.Components.Wires
"/Textures/Interface/WireHacking/wire_2_copper.svg.96dpi.png" "/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) 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 internal sealed class DebugPathfindingOverlay : Overlay
{ {
private IEyeManager _eyeManager; private readonly IEyeManager _eyeManager;
private IPlayerManager _playerManager; private readonly IPlayerManager _playerManager;
// TODO: Add a box like the debug one and show the most recent path stuff // TODO: Add a box like the debug one and show the most recent path stuff
public override OverlaySpace Space => OverlaySpace.ScreenSpace; public override OverlaySpace Space => OverlaySpace.ScreenSpace;

View File

@@ -14,8 +14,8 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
public sealed class DoAfterBar : Control public sealed class DoAfterBar : Control
{ {
private IGameTiming _gameTiming = default!; private IGameTiming _gameTiming = default!;
private ShaderInstance _shader; private readonly ShaderInstance _shader;
/// <summary> /// <summary>
/// Set from 0.0f to 1.0f to reflect bar progress /// Set from 0.0f to 1.0f to reflect bar progress
@@ -40,13 +40,13 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{ {
return; return;
} }
_cancelled = value; _cancelled = value;
if (_cancelled) if (_cancelled)
{ {
_gameTiming = IoCManager.Resolve<IGameTiming>(); _gameTiming = IoCManager.Resolve<IGameTiming>();
_lastFlash = _gameTiming.CurTime; _lastFlash = _gameTiming.CurTime;
} }
} }
} }
@@ -87,7 +87,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
_lastFlash = _gameTiming.CurTime; _lastFlash = _gameTiming.CurTime;
_flash = !_flash; _flash = !_flash;
} }
} }
} }
protected override void Draw(DrawingHandleScreen handle) protected override void Draw(DrawingHandleScreen handle)

View File

@@ -21,11 +21,11 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
[Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
private Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>(); private readonly Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>();
private Dictionary<byte, DoAfterBar> _doAfterBars = new Dictionary<byte, DoAfterBar>(); 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 // 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; } public IEntity? AttachedEntity { get; set; }
private ScreenCoordinates _playerPosition; private ScreenCoordinates _playerPosition;
@@ -48,12 +48,12 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
base.Dispose(disposing); base.Dispose(disposing);
if (Disposed) if (Disposed)
return; return;
foreach (var (_, control) in _doAfterControls) foreach (var (_, control) in _doAfterControls)
{ {
control.Dispose(); control.Dispose();
} }
_doAfterControls.Clear(); _doAfterControls.Clear();
_doAfterBars.Clear(); _doAfterBars.Clear();
_cancelledDoAfters.Clear(); _cancelledDoAfters.Clear();
@@ -109,10 +109,10 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
RemoveChild(control); RemoveChild(control);
_doAfterControls.Remove(id); _doAfterControls.Remove(id);
_doAfterBars.Remove(id); _doAfterBars.Remove(id);
if (_cancelledDoAfters.ContainsKey(id)) if (_cancelledDoAfters.ContainsKey(id))
_cancelledDoAfters.Remove(id); _cancelledDoAfters.Remove(id);
} }
/// <summary> /// <summary>
@@ -130,7 +130,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
doAfterBar = new DoAfterBar(); doAfterBar = new DoAfterBar();
_doAfterBars[id] = doAfterBar; _doAfterBars[id] = doAfterBar;
} }
doAfterBar.Cancelled = true; doAfterBar.Cancelled = true;
_cancelledDoAfters.Add(id, _gameTiming.CurTime); _cancelledDoAfters.Add(id, _gameTiming.CurTime);
} }
@@ -139,7 +139,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{ {
base.FrameUpdate(args); base.FrameUpdate(args);
if (AttachedEntity?.IsValid() != true || if (AttachedEntity?.IsValid() != true ||
!AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent)) !AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent))
{ {
return; return;

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 // 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 // come into range it needs altering
private HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>(); private readonly HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private IEntity? _attachedEntity; private IEntity? _attachedEntity;

View File

@@ -71,7 +71,7 @@ namespace Content.Client.GameObjects.EntitySystems
private SharedInteractionSystem _interactionSystem; private SharedInteractionSystem _interactionSystem;
private InputSystem _inputSystem; private InputSystem _inputSystem;
private List<SpriteComponent> highlightedSprites = new List<SpriteComponent>(); private readonly List<SpriteComponent> _highlightedSprites = new List<SpriteComponent>();
private enum DragState private enum DragState
{ {
@@ -298,7 +298,7 @@ namespace Content.Client.GameObjects.EntitySystems
var inRange = _interactionSystem.InRangeUnobstructed(_dragger, pvsEntity); var inRange = _interactionSystem.InRangeUnobstructed(_dragger, pvsEntity);
inRangeSprite.PostShader = inRange ? _dropTargetInRangeShader : _dropTargetOutOfRangeShader; inRangeSprite.PostShader = inRange ? _dropTargetInRangeShader : _dropTargetOutOfRangeShader;
inRangeSprite.RenderOrder = EntityManager.CurrentTick.Value; inRangeSprite.RenderOrder = EntityManager.CurrentTick.Value;
highlightedSprites.Add(inRangeSprite); _highlightedSprites.Add(inRangeSprite);
} }
} }
} }
@@ -306,12 +306,12 @@ namespace Content.Client.GameObjects.EntitySystems
private void RemoveHighlights() private void RemoveHighlights()
{ {
foreach (var highlightedSprite in highlightedSprites) foreach (var highlightedSprite in _highlightedSprites)
{ {
highlightedSprite.PostShader = null; highlightedSprite.PostShader = null;
highlightedSprite.RenderOrder = 0; highlightedSprite.RenderOrder = 0;
} }
highlightedSprites.Clear(); _highlightedSprites.Clear();
} }
/// <summary> /// <summary>

View File

@@ -41,7 +41,7 @@ namespace Content.Client.GameObjects.EntitySystems
private readonly int[] _fireFrameCounter = new int[FireStates]; private readonly int[] _fireFrameCounter = new int[FireStates];
private readonly Texture[][] _fireFrames = new Texture[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>>(); new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>();
private AtmosphereSystem _atmosphereSystem = default!; private AtmosphereSystem _atmosphereSystem = default!;

View File

@@ -22,8 +22,8 @@ namespace Content.Client.Graphics.Overlays
public override OverlaySpace Space => OverlaySpace.ScreenSpace; public override OverlaySpace Space => OverlaySpace.ScreenSpace;
private readonly ShaderInstance _shader; private readonly ShaderInstance _shader;
private double _startTime; private readonly double _startTime;
private int lastsFor = 5000; private int _lastsFor = 5000;
private Texture _screenshotTexture; private Texture _screenshotTexture;
public FlashOverlay() : base(nameof(SharedOverlayID.FlashOverlay)) public FlashOverlay() : base(nameof(SharedOverlayID.FlashOverlay))
@@ -42,7 +42,7 @@ namespace Content.Client.Graphics.Overlays
protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace) protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace)
{ {
handle.UseShader(_shader); handle.UseShader(_shader);
var percentComplete = (float) ((_gameTiming.CurTime.TotalMilliseconds - _startTime) / lastsFor); var percentComplete = (float) ((_gameTiming.CurTime.TotalMilliseconds - _startTime) / _lastsFor);
_shader?.SetParameter("percentComplete", percentComplete); _shader?.SetParameter("percentComplete", percentComplete);
var screenSpaceHandle = handle as DrawingHandleScreen; var screenSpaceHandle = handle as DrawingHandleScreen;
@@ -63,7 +63,7 @@ namespace Content.Client.Graphics.Overlays
public void Configure(TimedOverlayParameter parameters) 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.GameObjects.Components.Instruments;
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Client.Audio.Midi; using Robust.Client.Audio.Midi;
using Robust.Client.Graphics.Drawing; using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.UserInterface; using Robust.Client.Interfaces.UserInterface;
@@ -23,10 +22,10 @@ namespace Content.Client.Instruments
[Dependency] private readonly IMidiManager _midiManager = default!; [Dependency] private readonly IMidiManager _midiManager = default!;
[Dependency] private readonly IFileDialogManager _fileDialogManager = default!; [Dependency] private readonly IFileDialogManager _fileDialogManager = default!;
private InstrumentBoundUserInterface _owner; private readonly InstrumentBoundUserInterface _owner;
private Button midiLoopButton; private readonly Button _midiLoopButton;
private Button midiStopButton; private readonly Button _midiStopButton;
private Button midiInputButton; private readonly Button _midiInputButton;
protected override Vector2? CustomSize => (400, 150); protected override Vector2? CustomSize => (400, 150);
@@ -59,7 +58,7 @@ namespace Content.Client.Instruments
Align = BoxContainer.AlignMode.Center Align = BoxContainer.AlignMode.Center
}; };
midiInputButton = new Button() _midiInputButton = new Button()
{ {
Text = Loc.GetString("MIDI Input"), Text = Loc.GetString("MIDI Input"),
TextAlign = Label.AlignMode.Center, TextAlign = Label.AlignMode.Center,
@@ -69,7 +68,7 @@ namespace Content.Client.Instruments
Pressed = _owner.Instrument.IsInputOpen, Pressed = _owner.Instrument.IsInputOpen,
}; };
midiInputButton.OnToggled += MidiInputButtonOnOnToggled; _midiInputButton.OnToggled += MidiInputButtonOnOnToggled;
var topSpacer = new Control() var topSpacer = new Control()
{ {
@@ -95,7 +94,7 @@ namespace Content.Client.Instruments
Align = BoxContainer.AlignMode.Center Align = BoxContainer.AlignMode.Center
}; };
midiLoopButton = new Button() _midiLoopButton = new Button()
{ {
Text = Loc.GetString("Loop"), Text = Loc.GetString("Loop"),
TextAlign = Label.AlignMode.Center, TextAlign = Label.AlignMode.Center,
@@ -106,7 +105,7 @@ namespace Content.Client.Instruments
Pressed = _owner.Instrument.LoopMidi, Pressed = _owner.Instrument.LoopMidi,
}; };
midiLoopButton.OnToggled += MidiLoopButtonOnOnToggled; _midiLoopButton.OnToggled += MidiLoopButtonOnOnToggled;
var bottomSpacer = new Control() var bottomSpacer = new Control()
{ {
@@ -114,7 +113,7 @@ namespace Content.Client.Instruments
SizeFlagsStretchRatio = 2, SizeFlagsStretchRatio = 2,
}; };
midiStopButton = new Button() _midiStopButton = new Button()
{ {
Text = Loc.GetString("Stop"), Text = Loc.GetString("Stop"),
TextAlign = Label.AlignMode.Center, TextAlign = Label.AlignMode.Center,
@@ -123,13 +122,13 @@ namespace Content.Client.Instruments
Disabled = !_owner.Instrument.IsMidiOpen, Disabled = !_owner.Instrument.IsMidiOpen,
}; };
midiStopButton.OnPressed += MidiStopButtonOnPressed; _midiStopButton.OnPressed += MidiStopButtonOnPressed;
hBoxBottomButtons.AddChild(midiLoopButton); hBoxBottomButtons.AddChild(_midiLoopButton);
hBoxBottomButtons.AddChild(bottomSpacer); hBoxBottomButtons.AddChild(bottomSpacer);
hBoxBottomButtons.AddChild(midiStopButton); hBoxBottomButtons.AddChild(_midiStopButton);
hBoxTopButtons.AddChild(midiInputButton); hBoxTopButtons.AddChild(_midiInputButton);
hBoxTopButtons.AddChild(topSpacer); hBoxTopButtons.AddChild(topSpacer);
hBoxTopButtons.AddChild(midiFileButton); hBoxTopButtons.AddChild(midiFileButton);
@@ -168,8 +167,8 @@ namespace Content.Client.Instruments
public void MidiPlaybackSetButtonsDisabled(bool disabled) public void MidiPlaybackSetButtonsDisabled(bool disabled)
{ {
midiLoopButton.Disabled = disabled; _midiLoopButton.Disabled = disabled;
midiStopButton.Disabled = disabled; _midiStopButton.Disabled = disabled;
} }
private async void MidiFileButtonOnOnPressed(BaseButton.ButtonEventArgs obj) private async void MidiFileButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
@@ -195,8 +194,8 @@ namespace Content.Client.Instruments
await Timer.Delay(100); await Timer.Delay(100);
if (!_owner.Instrument.OpenMidi(filename)) return; if (!_owner.Instrument.OpenMidi(filename)) return;
MidiPlaybackSetButtonsDisabled(false); MidiPlaybackSetButtonsDisabled(false);
if (midiInputButton.Pressed) if (_midiInputButton.Pressed)
midiInputButton.Pressed = false; _midiInputButton.Pressed = false;
} }
private void MidiInputButtonOnOnToggled(BaseButton.ButtonToggledEventArgs obj) private void MidiInputButtonOnOnToggled(BaseButton.ButtonToggledEventArgs obj)

View File

@@ -16,10 +16,10 @@ namespace Content.Client.Research
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private ItemList Items; private readonly ItemList _items;
private ItemList Materials; private readonly ItemList _materials;
private LineEdit AmountLineEdit; private readonly LineEdit _amountLineEdit;
private LineEdit SearchBar; private readonly LineEdit _searchBar;
public Button QueueButton; public Button QueueButton;
public Button ServerConnectButton; public Button ServerConnectButton;
public Button ServerSyncButton; public Button ServerSyncButton;
@@ -27,8 +27,8 @@ namespace Content.Client.Research
public LatheBoundUserInterface Owner { get; set; } public LatheBoundUserInterface Owner { get; set; }
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>(); private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
private List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>(); private readonly List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
public LatheMenu(LatheBoundUserInterface owner = null) public LatheMenu(LatheBoundUserInterface owner = null)
{ {
@@ -94,14 +94,14 @@ namespace Content.Client.Research
SizeFlagsStretchRatio = 1 SizeFlagsStretchRatio = 1
}; };
SearchBar = new LineEdit() _searchBar = new LineEdit()
{ {
PlaceHolder = "Search Designs", PlaceHolder = "Search Designs",
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 3 SizeFlagsStretchRatio = 3
}; };
SearchBar.OnTextChanged += Populate; _searchBar.OnTextChanged += Populate;
var filterButton = new Button() var filterButton = new Button()
{ {
@@ -112,25 +112,25 @@ namespace Content.Client.Research
Disabled = true, Disabled = true,
}; };
Items = new ItemList() _items = new ItemList()
{ {
SizeFlagsStretchRatio = 8, SizeFlagsStretchRatio = 8,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
SelectMode = ItemList.ItemListSelectMode.Button, SelectMode = ItemList.ItemListSelectMode.Button,
}; };
Items.OnItemSelected += ItemSelected; _items.OnItemSelected += ItemSelected;
AmountLineEdit = new LineEdit() _amountLineEdit = new LineEdit()
{ {
PlaceHolder = "Amount", PlaceHolder = "Amount",
Text = "1", Text = "1",
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
}; };
AmountLineEdit.OnTextChanged += PopulateDisabled; _amountLineEdit.OnTextChanged += PopulateDisabled;
Materials = new ItemList() _materials = new ItemList()
{ {
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 3 SizeFlagsStretchRatio = 3
@@ -145,14 +145,14 @@ namespace Content.Client.Research
} }
hBoxButtons.AddChild(QueueButton); hBoxButtons.AddChild(QueueButton);
hBoxFilter.AddChild(SearchBar); hBoxFilter.AddChild(_searchBar);
hBoxFilter.AddChild(filterButton); hBoxFilter.AddChild(filterButton);
vBox.AddChild(hBoxButtons); vBox.AddChild(hBoxButtons);
vBox.AddChild(hBoxFilter); vBox.AddChild(hBoxFilter);
vBox.AddChild(Items); vBox.AddChild(_items);
vBox.AddChild(AmountLineEdit); vBox.AddChild(_amountLineEdit);
vBox.AddChild(Materials); vBox.AddChild(_materials);
margin.AddChild(vBox); margin.AddChild(vBox);
@@ -161,20 +161,20 @@ namespace Content.Client.Research
public void ItemSelected(ItemList.ItemListSelectedEventArgs args) 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; if (quantity <= 0) quantity = 1;
Owner.Queue(_shownRecipes[args.ItemIndex], quantity); Owner.Queue(_shownRecipes[args.ItemIndex], quantity);
} }
public void PopulateMaterials() public void PopulateMaterials()
{ {
Materials.Clear(); _materials.Clear();
foreach (var (id, amount) in Owner.Storage) foreach (var (id, amount) in Owner.Storage)
{ {
if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue; if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
var material = materialPrototype.Material; 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> /// </summary>
public void PopulateDisabled() public void PopulateDisabled()
{ {
int.TryParse(AmountLineEdit.Text, out var quantity); int.TryParse(_amountLineEdit.Text, out var quantity);
if (quantity <= 0) quantity = 1; if (quantity <= 0) quantity = 1;
for (var i = 0; i < _shownRecipes.Count; i++) for (var i = 0; i < _shownRecipes.Count; i++)
{ {
var prototype = _shownRecipes[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> /// </summary>
public void PopulateList() public void PopulateList()
{ {
Items.Clear(); _items.Clear();
foreach (var prototype in _shownRecipes) foreach (var prototype in _shownRecipes)
{ {
Items.AddItem(prototype.Name, prototype.Icon.Frame0()); _items.AddItem(prototype.Name, prototype.Icon.Frame0());
} }
PopulateDisabled(); PopulateDisabled();
@@ -221,9 +221,9 @@ namespace Content.Client.Research
foreach (var prototype in Owner.Database) 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); _shownRecipes.Add(prototype);
continue; continue;
} }

View File

@@ -16,10 +16,10 @@ namespace Content.Client.Research
public LatheBoundUserInterface Owner { get; set; } public LatheBoundUserInterface Owner { get; set; }
[ViewVariables] [ViewVariables]
private ItemList QueueList; private readonly ItemList _queueList;
private Label NameLabel; private readonly Label _nameLabel;
private Label Description; private readonly Label _description;
private TextureRect Icon; private readonly TextureRect _icon;
public LatheQueueMenu() public LatheQueueMenu()
{ {
@@ -54,7 +54,7 @@ namespace Content.Client.Research
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
}; };
Icon = new TextureRect() _icon = new TextureRect()
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 2, SizeFlagsStretchRatio = 2,
@@ -66,13 +66,13 @@ namespace Content.Client.Research
SizeFlagsStretchRatio = 3, SizeFlagsStretchRatio = 3,
}; };
NameLabel = new Label() _nameLabel = new Label()
{ {
RectClipContent = true, RectClipContent = true,
SizeFlagsHorizontal = SizeFlags.Fill, SizeFlagsHorizontal = SizeFlags.Fill,
}; };
Description = new Label() _description = new Label()
{ {
RectClipContent = true, RectClipContent = true,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
@@ -80,7 +80,7 @@ namespace Content.Client.Research
}; };
QueueList = new ItemList() _queueList = new ItemList()
{ {
SizeFlagsHorizontal = SizeFlags.Fill, SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
@@ -88,16 +88,16 @@ namespace Content.Client.Research
SelectMode = ItemList.ItemListSelectMode.None SelectMode = ItemList.ItemListSelectMode.None
}; };
vBoxInfo.AddChild(NameLabel); vBoxInfo.AddChild(_nameLabel);
vBoxInfo.AddChild(Description); vBoxInfo.AddChild(_description);
hBox.AddChild(Icon); hBox.AddChild(_icon);
hBox.AddChild(vBoxInfo); hBox.AddChild(vBoxInfo);
descMargin.AddChild(hBox); descMargin.AddChild(hBox);
vBox.AddChild(descMargin); vBox.AddChild(descMargin);
vBox.AddChild(QueueList); vBox.AddChild(_queueList);
margin.AddChild(vBox); margin.AddChild(vBox);
@@ -108,27 +108,27 @@ namespace Content.Client.Research
public void SetInfo(LatheRecipePrototype recipe) public void SetInfo(LatheRecipePrototype recipe)
{ {
Icon.Texture = recipe.Icon.Frame0(); _icon.Texture = recipe.Icon.Frame0();
if (recipe.Name != null) if (recipe.Name != null)
NameLabel.Text = recipe.Name; _nameLabel.Text = recipe.Name;
if (recipe.Description != null) if (recipe.Description != null)
Description.Text = recipe.Description; _description.Text = recipe.Description;
} }
public void ClearInfo() public void ClearInfo()
{ {
Icon.Texture = Texture.Transparent; _icon.Texture = Texture.Transparent;
NameLabel.Text = "-------"; _nameLabel.Text = "-------";
Description.Text = "Not producing anything."; _description.Text = "Not producing anything.";
} }
public void PopulateList() public void PopulateList()
{ {
QueueList.Clear(); _queueList.Clear();
var idx = 1; var idx = 1;
foreach (var recipe in Owner.QueuedRecipes) foreach (var recipe in Owner.QueuedRecipes)
{ {
QueueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0()); _queueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0());
idx++; idx++;
} }
} }

View File

@@ -18,19 +18,19 @@ namespace Content.Client.Research
protected override Vector2? CustomSize => (800, 400); protected override Vector2? CustomSize => (800, 400);
private List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>(); private readonly List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>();
private List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>(); private readonly List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>();
private List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>(); private readonly List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>();
private Label _pointLabel; private readonly Label _pointLabel;
private Label _pointsPerSecondLabel; private readonly Label _pointsPerSecondLabel;
private Label _technologyName; private readonly Label _technologyName;
private Label _technologyDescription; private readonly Label _technologyDescription;
private Label _technologyRequirements; private readonly Label _technologyRequirements;
private TextureRect _technologyIcon; private readonly TextureRect _technologyIcon;
private ItemList _unlockedTechnologies; private readonly ItemList _unlockedTechnologies;
private ItemList _unlockableTechnologies; private readonly ItemList _unlockableTechnologies;
private ItemList _futureTechnologies; private readonly ItemList _futureTechnologies;
public Button UnlockButton { get; private set; } public Button UnlockButton { get; private set; }
public Button ServerSelectionButton { get; private set; } public Button ServerSelectionButton { get; private set; }

View File

@@ -20,19 +20,19 @@ namespace Content.Client.Sandbox
// Layout for the SandboxWindow // Layout for the SandboxWindow
public class SandboxWindow : SS14Window public class SandboxWindow : SS14Window
{ {
public Button RespawnButton; public readonly Button RespawnButton;
public Button SpawnEntitiesButton; public readonly Button SpawnEntitiesButton;
public Button SpawnTilesButton; public readonly Button SpawnTilesButton;
public Button GiveFullAccessButton; //A button that just puts a captain's ID in your hands. public readonly Button GiveFullAccessButton; //A button that just puts a captain's ID in your hands.
public Button GiveAghostButton; public readonly Button GiveAghostButton;
public Button ToggleLightButton; public readonly Button ToggleLightButton;
public Button ToggleFovButton; public readonly Button ToggleFovButton;
public Button ToggleShadowsButton; public readonly Button ToggleShadowsButton;
public Button SuicideButton; public readonly Button SuicideButton;
public Button ToggleSubfloorButton; public readonly Button ToggleSubfloorButton;
public Button ShowMarkersButton; //Shows spawn points public readonly Button ShowMarkersButton; //Shows spawn points
public Button ShowBbButton; //Shows bounding boxes public readonly Button ShowBbButton; //Shows bounding boxes
public Button MachineLinkingButton; // Enables/disables machine linking mode. public readonly Button MachineLinkingButton; // Enables/disables machine linking mode.
public SandboxWindow() public SandboxWindow()
{ {

View File

@@ -607,7 +607,7 @@ namespace Content.Client.UserInterface.AdminMenu
GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(), GetValueFromData = (obj) => ((GasPrototype) obj).ID.ToString(),
}; };
private CommandUISpinBox _amount = new CommandUISpinBox private readonly CommandUISpinBox _amount = new CommandUISpinBox
{ {
Name = "Amount" Name = "Amount"
}; };

View File

@@ -23,7 +23,7 @@ namespace Content.Client.UserInterface.Cargo
public event Action<BaseButton.ButtonEventArgs> OnOrderApproved; public event Action<BaseButton.ButtonEventArgs> OnOrderApproved;
public event Action<BaseButton.ButtonEventArgs> OnOrderCanceled; 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 _accountNameLabel { get; set; }
private Label _pointsLabel { get; set; } private Label _pointsLabel { get; set; }

View File

@@ -10,7 +10,7 @@ namespace Content.Client.UserInterface.Cargo
{ {
public class GalacticBankSelectionMenu : SS14Window public class GalacticBankSelectionMenu : SS14Window
{ {
private ItemList _accounts; private readonly ItemList _accounts;
private int _accountCount = 0; private int _accountCount = 0;
private string[] _accountNames = new string[] { }; private string[] _accountNames = new string[] { };
private int[] _accountIds = new int[] { }; private int[] _accountIds = new int[] { };

View File

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

View File

@@ -26,7 +26,7 @@ namespace Content.Client.UserInterface
public event Action<string> SelectedId; 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() public LateJoinGui()
{ {
@@ -95,7 +95,7 @@ namespace Content.Client.UserInterface
jobButton.Disabled = true; jobButton.Disabled = true;
} }
JobButtons[job.ID] = jobButton; _jobButtons[job.ID] = jobButton;
} }
SelectedId += jobId => SelectedId += jobId =>
@@ -115,7 +115,7 @@ namespace Content.Client.UserInterface
private void JobsAvailableUpdated(IReadOnlyList<string> jobs) private void JobsAvailableUpdated(IReadOnlyList<string> jobs)
{ {
foreach (var (id, button) in JobButtons) foreach (var (id, button) in _jobButtons)
{ {
button.Disabled = !jobs.Contains(id); button.Disabled = !jobs.Contains(id);
} }
@@ -128,7 +128,7 @@ namespace Content.Client.UserInterface
if (disposing) if (disposing)
{ {
_gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated; _gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
JobButtons.Clear(); _jobButtons.Clear();
} }
} }
} }

View File

@@ -23,8 +23,8 @@ namespace Content.Client.UserInterface
private readonly IClientPreferencesManager _preferencesManager; private readonly IClientPreferencesManager _preferencesManager;
private IEntity _previewDummy; private IEntity _previewDummy;
private readonly Label _summaryLabel; private readonly Label _summaryLabel;
private VBoxContainer _loaded; private readonly VBoxContainer _loaded;
private Label _unloaded; private readonly Label _unloaded;
public LobbyCharacterPreviewPanel(IEntityManager entityManager, public LobbyCharacterPreviewPanel(IEntityManager entityManager,
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)

View File

@@ -258,8 +258,8 @@ namespace Content.Client.UserInterface
public class LobbyPlayerList : Control public class LobbyPlayerList : Control
{ {
private ScrollContainer _scroll; private readonly ScrollContainer _scroll;
private VBoxContainer _vBox; private readonly VBoxContainer _vBox;
public LobbyPlayerList() public LobbyPlayerList()
{ {

View File

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

View File

@@ -9,7 +9,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
{ {
public class SwingMeleeWeaponOperator : AiOperator public class SwingMeleeWeaponOperator : AiOperator
{ {
private float _burstTime; private readonly float _burstTime;
private float _elapsedTime; private float _elapsedTime;
private readonly IEntity _owner; private readonly IEntity _owner;

View File

@@ -8,7 +8,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
{ {
public sealed class UnarmedCombatOperator : AiOperator public sealed class UnarmedCombatOperator : AiOperator
{ {
private float _burstTime; private readonly float _burstTime;
private float _elapsedTime; private float _elapsedTime;
private readonly IEntity _owner; private readonly IEntity _owner;

View File

@@ -16,12 +16,12 @@ namespace Content.Server.AI.Operators.Movement
public float ArrivalDistance { get; } public float ArrivalDistance { get; }
public float PathfindingProximity { get; } public float PathfindingProximity { get; }
private bool _requiresInRangeUnobstructed; private readonly bool _requiresInRangeUnobstructed;
public MoveToEntityOperator( public MoveToEntityOperator(
IEntity owner, IEntity owner,
IEntity target, IEntity target,
float arrivalDistance = 1.0f, float arrivalDistance = 1.0f,
float pathfindingProximity = 1.5f, float pathfindingProximity = 1.5f,
bool requiresInRangeUnobstructed = false) bool requiresInRangeUnobstructed = false)
{ {
@@ -44,7 +44,7 @@ namespace Content.Server.AI.Operators.Movement
steering.Register(_owner, _request); steering.Register(_owner, _request);
return true; return true;
} }
public override void Shutdown(Outcome outcome) public override void Shutdown(Outcome outcome)
{ {
base.Shutdown(outcome); base.Shutdown(outcome);
@@ -71,4 +71,4 @@ namespace Content.Server.AI.Operators.Movement
} }
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Gloves
{ {
public sealed class EquipGloves : UtilityAction public sealed class EquipGloves : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public EquipGloves(IEntity owner, IEntity entity, float weight) : base(owner) 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); base.UpdateBlackboard(context);
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Actions.Clothing.Head
{ {
public sealed class EquipHead : UtilityAction public sealed class EquipHead : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public EquipHead(IEntity owner, IEntity entity, float weight) : base(owner) 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 public sealed class EquipOuterClothing : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public EquipOuterClothing(IEntity owner, IEntity entity, float weight) : base(owner) 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 public sealed class EquipShoes : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public EquipShoes(IEntity owner, IEntity entity, float weight) : base(owner) 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 public sealed class EquipMelee : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public EquipMelee(IEntity owner, IEntity entity, float weight) : base(owner) 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 public sealed class MeleeWeaponAttackEntity : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public MeleeWeaponAttackEntity(IEntity owner, IEntity entity, float weight) : base(owner) 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<EquippedEntityState>().GetValue(); var equipped = context.GetState<EquippedEntityState>().GetValue();
context.GetState<WeaponEntityState>().SetValue(equipped); context.GetState<WeaponEntityState>().SetValue(equipped);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
{ {
public sealed class PickUpMeleeWeapon : UtilityAction public sealed class PickUpMeleeWeapon : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public PickUpMeleeWeapon(IEntity owner, IEntity entity, float weight) : base(owner) public PickUpMeleeWeapon(IEntity owner, IEntity entity, float weight) : base(owner)
{ {
@@ -34,7 +34,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
context.GetState<WeaponEntityState>().SetValue(_entity); context.GetState<WeaponEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -19,7 +19,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
{ {
public sealed class UnarmedAttackEntity : UtilityAction public sealed class UnarmedAttackEntity : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public UnarmedAttackEntity(IEntity owner, IEntity entity, float weight) : base(owner) 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<AiOperator>(new AiOperator[] ActionOperators = new Queue<AiOperator>(new AiOperator[]
{ {
moveOperator, moveOperator,
new UnarmedCombatOperator(Owner, _entity), new UnarmedCombatOperator(Owner, _entity),
}); });
} }
@@ -60,7 +60,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
return new[] return new[]
{ {
considerationsManager.Get<TargetIsDeadCon>() considerationsManager.Get<TargetIsDeadCon>()

View File

@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink
{ {
public sealed class PickUpDrink : UtilityAction public sealed class PickUpDrink : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public PickUpDrink(IEntity owner, IEntity entity, float weight) : base(owner) 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; ActionOperators = new GoPickupEntitySequence(Owner, _entity).Sequence;
} }
protected override void UpdateBlackboard(Blackboard context) protected override void UpdateBlackboard(Blackboard context)
{ {
base.UpdateBlackboard(context); base.UpdateBlackboard(context);
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
return new[] return new[]
{ {
considerationsManager.Get<TargetDistanceCon>() considerationsManager.Get<TargetDistanceCon>()

View File

@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Drink
{ {
public sealed class UseDrinkInInventory : UtilityAction public sealed class UseDrinkInInventory : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public UseDrinkInInventory(IEntity owner, IEntity entity, float weight) : base(owner) 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), new UseDrinkInInventoryOperator(Owner, _entity),
}); });
} }
protected override void UpdateBlackboard(Blackboard context) protected override void UpdateBlackboard(Blackboard context)
{ {
base.UpdateBlackboard(context); base.UpdateBlackboard(context);
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food
{ {
public sealed class PickUpFood : UtilityAction public sealed class PickUpFood : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public PickUpFood(IEntity owner, IEntity entity, float weight) : base(owner) 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); base.UpdateBlackboard(context);
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Actions.Nutrition.Food
{ {
public sealed class UseFoodInInventory : UtilityAction public sealed class UseFoodInInventory : UtilityAction
{ {
private IEntity _entity; private readonly IEntity _entity;
public UseFoodInInventory(IEntity owner, IEntity entity, float weight) : base(owner) 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<AiOperator>(new AiOperator[] ActionOperators = new Queue<AiOperator>(new AiOperator[]
{ {
new EquipEntityOperator(Owner, _entity), 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); base.UpdateBlackboard(context);
context.GetState<TargetEntityState>().SetValue(_entity); context.GetState<TargetEntityState>().SetValue(_entity);
} }
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context) protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
{ {
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>(); var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();

View File

@@ -7,23 +7,23 @@ namespace Content.Server.AI.Utility.Considerations
{ {
public class ConsiderationsManager 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() public void Initialize()
{ {
var reflectionManager = IoCManager.Resolve<IReflectionManager>(); var reflectionManager = IoCManager.Resolve<IReflectionManager>();
var typeFactory = IoCManager.Resolve<IDynamicTypeFactory>(); var typeFactory = IoCManager.Resolve<IDynamicTypeFactory>();
foreach (var conType in reflectionManager.GetAllChildren(typeof(Consideration))) foreach (var conType in reflectionManager.GetAllChildren(typeof(Consideration)))
{ {
var con = (Consideration) typeFactory.CreateInstance(conType); var con = (Consideration) typeFactory.CreateInstance(conType);
_considerations.Add(conType, con); _considerations.Add(conType, con);
} }
} }
public T Get<T>() where T : Consideration public T Get<T>() where T : Consideration
{ {
return (T) _considerations[typeof(T)]; return (T) _considerations[typeof(T)];
} }
} }
} }

View File

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

View File

@@ -460,7 +460,7 @@ namespace Content.Server.Administration
private sealed class AdminReg private sealed class AdminReg
{ {
public IPlayerSession Session; public readonly IPlayerSession Session;
public AdminData Data; public AdminData Data;
public int? RankId; public int? RankId;

View File

@@ -4,19 +4,17 @@ using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Atmos namespace Content.Server.Atmos
{ {
public class HighPressureMovementController : FrictionController public class HighPressureMovementController : FrictionController
{ {
[Dependency] private IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
public override IPhysicsComponent? ControlledComponent { protected get; set; } public override IPhysicsComponent? ControlledComponent { protected get; set; }
private const float MoveForcePushRatio = 1f; private const float MoveForcePushRatio = 1f;

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Cargo
{ {
public class CargoOrderDatabase 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; private int _orderNumber = 0;
public CargoOrderDatabase(int id) public CargoOrderDatabase(int id)
@@ -84,7 +84,7 @@ namespace Content.Server.Cargo
{ {
return _orders.Remove(orderNumber); return _orders.Remove(orderNumber);
} }
/// <summary> /// <summary>
/// Approves an order in the database. /// Approves an order in the database.
/// </summary> /// </summary>
@@ -96,7 +96,7 @@ namespace Content.Server.Cargo
if (!_orders.TryGetValue(orderNumber, out var order)) if (!_orders.TryGetValue(orderNumber, out var order))
return; return;
else if (CurrentOrderSize + order.Amount > MaxOrderSize) else if (CurrentOrderSize + order.Amount > MaxOrderSize)
{ {
AddOrder(order.Requester, Loc.GetString("{0} (Overflow)", order.Reason.Replace(" (Overflow)","")), order.ProductId, AddOrder(order.Requester, Loc.GetString("{0} (Overflow)", order.Reason.Replace(" (Overflow)","")), order.ProductId,
order.Amount - MaxOrderSize - CurrentOrderSize, order.PayingAccountId); order.Amount - MaxOrderSize - CurrentOrderSize, order.PayingAccountId);
order.Amount = MaxOrderSize - CurrentOrderSize; order.Amount = MaxOrderSize - CurrentOrderSize;

View File

@@ -26,18 +26,20 @@ namespace Content.Server.GameObjects.Components.Arcade
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public class BlockGameArcadeComponent : Component, IActivate public class BlockGameArcadeComponent : Component, IActivate
{ {
[Dependency] private IRobustRandom _random = null!; [Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "BlockGameArcade"; public override string Name => "BlockGameArcade";
public override uint? NetID => ContentNetIDs.BLOCKGAME_ARCADE; 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 bool Powered => _powerReceiverComponent?.Powered ?? false;
private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BlockGameUiKey.Key); private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BlockGameUiKey.Key);
private BlockGame? _game; private BlockGame? _game;
private IPlayerSession? _player; private IPlayerSession? _player;
private List<IPlayerSession> _spectators = new List<IPlayerSession>(); private readonly List<IPlayerSession> _spectators = new List<IPlayerSession>();
public void Activate(ActivateEventArgs eventArgs) 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 //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; private BlockGamePiece _currentPiece;

View File

@@ -29,10 +29,10 @@ namespace Content.Server.GameObjects.Components.Arcade
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public class SpaceVillainArcadeComponent : SharedSpaceVillainArcadeComponent, IActivate, IWires public class SpaceVillainArcadeComponent : SharedSpaceVillainArcadeComponent, IActivate, IWires
{ {
[Dependency] private IRobustRandom _random = null!; [Dependency] private readonly IRobustRandom _random = null!;
[ComponentDependency] private PowerReceiverComponent? _powerReceiverComponent = default!; [ComponentDependency] private readonly PowerReceiverComponent? _powerReceiverComponent = default!;
[ComponentDependency] private WiresComponent? _wiresComponent = default!; [ComponentDependency] private readonly WiresComponent? _wiresComponent = default!;
private bool Powered => _powerReceiverComponent != null && _powerReceiverComponent.Powered; private bool Powered => _powerReceiverComponent != null && _powerReceiverComponent.Powered;
@@ -240,7 +240,7 @@ namespace Content.Server.GameObjects.Components.Arcade
{ {
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[ViewVariables] private SpaceVillainArcadeComponent Owner; [ViewVariables] private readonly SpaceVillainArcadeComponent _owner;
[ViewVariables] public string Name => $"{_fightVerb} {_enemyName}"; [ViewVariables] public string Name => $"{_fightVerb} {_enemyName}";
[ViewVariables(VVAccess.ReadWrite)] private int _playerHp = 30; [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 _enemyMpMax = 20;
[ViewVariables(VVAccess.ReadWrite)] private int _turtleTracker; [ViewVariables(VVAccess.ReadWrite)] private int _turtleTracker;
[ViewVariables(VVAccess.ReadWrite)] private string _fightVerb; [ViewVariables(VVAccess.ReadWrite)] private readonly string _fightVerb;
[ViewVariables(VVAccess.ReadWrite)] private string _enemyName; [ViewVariables(VVAccess.ReadWrite)] private readonly string _enemyName;
[ViewVariables] private bool _running = true; [ViewVariables] private bool _running = true;
@@ -266,7 +266,7 @@ namespace Content.Server.GameObjects.Components.Arcade
public SpaceVillainGame(SpaceVillainArcadeComponent owner, string fightVerb, string enemyName) public SpaceVillainGame(SpaceVillainArcadeComponent owner, string fightVerb, string enemyName)
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
Owner = owner; _owner = owner;
//todo defeat the curse secret game mode //todo defeat the curse secret game mode
_fightVerb = fightVerb; _fightVerb = fightVerb;
_enemyName = enemyName; _enemyName = enemyName;
@@ -278,7 +278,7 @@ namespace Content.Server.GameObjects.Components.Arcade
/// </summary> /// </summary>
private void ValidateVars() private void ValidateVars()
{ {
if(Owner._overflowFlag) return; if(_owner._overflowFlag) return;
if (_playerHp > _playerHpMax) _playerHp = _playerHpMax; if (_playerHp > _playerHpMax) _playerHp = _playerHpMax;
if (_playerMp > _playerMpMax) _playerMp = _playerMpMax; if (_playerMp > _playerMpMax) _playerMp = _playerMpMax;
@@ -299,23 +299,23 @@ namespace Content.Server.GameObjects.Components.Arcade
case PlayerAction.Attack: case PlayerAction.Attack:
var attackAmount = _random.Next(2, 6); var attackAmount = _random.Next(2, 6);
_latestPlayerActionMessage = Loc.GetString("You attack {0} for {1}!", _enemyName, attackAmount); _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)); EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/player_attack.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!Owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; if(!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount;
_turtleTracker -= _turtleTracker > 0 ? 1 : 0; _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
break; break;
case PlayerAction.Heal: case PlayerAction.Heal:
var pointAmount = _random.Next(1, 3); var pointAmount = _random.Next(1, 3);
var healAmount = _random.Next(6, 8); var healAmount = _random.Next(6, 8);
_latestPlayerActionMessage = Loc.GetString("You use {0} magic to heal for {1} damage!", pointAmount, healAmount); _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)); EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/player_heal.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!Owner._playerInvincibilityFlag) _playerMp -= pointAmount; if(!_owner._playerInvincibilityFlag) _playerMp -= pointAmount;
_playerHp += healAmount; _playerHp += healAmount;
_turtleTracker++; _turtleTracker++;
break; break;
case PlayerAction.Recharge: case PlayerAction.Recharge:
var chargeAmount = _random.Next(4, 7); var chargeAmount = _random.Next(4, 7);
_latestPlayerActionMessage = Loc.GetString("You regain {0} points", chargeAmount); _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; _playerMp += chargeAmount;
_turtleTracker -= _turtleTracker > 0 ? 1 : 0; _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
break; break;
@@ -347,8 +347,8 @@ namespace Content.Server.GameObjects.Components.Arcade
{ {
_running = false; _running = false;
UpdateUi(Loc.GetString("You won!"), Loc.GetString("{0} dies.", _enemyName), true); 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)); EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Effects/Arcade/win.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
Owner.ProcessWin(); _owner.ProcessWin();
return false; return false;
} }
@@ -358,14 +358,14 @@ namespace Content.Server.GameObjects.Components.Arcade
{ {
_running = false; _running = false;
UpdateUi(Loc.GetString("You lost!"), Loc.GetString("{0} cheers.", _enemyName), true); 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; return false;
} }
if (_enemyHp <= 0 || _enemyMp <= 0) if (_enemyHp <= 0 || _enemyMp <= 0)
{ {
_running = false; _running = false;
UpdateUi(Loc.GetString("You lost!"), Loc.GetString("{0} dies, but takes you with him.", _enemyName), true); 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; return false;
} }
@@ -377,7 +377,7 @@ namespace Content.Server.GameObjects.Components.Arcade
/// </summary> /// </summary>
private void UpdateUi(bool metadata = false) 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) 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); var boomAmount = _random.Next(5, 10);
_latestEnemyActionMessage = Loc.GetString("{0} throws a bomb, exploding you for {1} damage!", _enemyName, boomAmount); _latestEnemyActionMessage = Loc.GetString("{0} throws a bomb, exploding you for {1} damage!", _enemyName, boomAmount);
if (Owner._playerInvincibilityFlag) return; if (_owner._playerInvincibilityFlag) return;
_playerHp -= boomAmount; _playerHp -= boomAmount;
_turtleTracker--; _turtleTracker--;
}else if (_enemyMp <= 5 && _random.Prob(0.7f)) }else if (_enemyMp <= 5 && _random.Prob(0.7f))
{ {
var stealAmount = _random.Next(2, 3); var stealAmount = _random.Next(2, 3);
_latestEnemyActionMessage = Loc.GetString("{0} steals {1} of your power!", _enemyName, stealAmount); _latestEnemyActionMessage = Loc.GetString("{0} steals {1} of your power!", _enemyName, stealAmount);
if (Owner._playerInvincibilityFlag) return; if (_owner._playerInvincibilityFlag) return;
_playerMp -= stealAmount; _playerMp -= stealAmount;
_enemyMp += stealAmount; _enemyMp += stealAmount;
}else if (_enemyHp <= 10 && _enemyMp > 4) }else if (_enemyHp <= 10 && _enemyMp > 4)
@@ -418,7 +418,7 @@ namespace Content.Server.GameObjects.Components.Arcade
var attackAmount = _random.Next(3, 6); var attackAmount = _random.Next(3, 6);
_latestEnemyActionMessage = _latestEnemyActionMessage =
Loc.GetString("{0} attacks you for {1} damage!", _enemyName, attackAmount); Loc.GetString("{0} attacks you for {1} damage!", _enemyName, attackAmount);
if (Owner._playerInvincibilityFlag) return; if (_owner._playerInvincibilityFlag) return;
_playerHp -= attackAmount; _playerHp -= attackAmount;
} }
} }

View File

@@ -19,8 +19,8 @@ namespace Content.Server.GameObjects.Components.Damage
[RegisterComponent] [RegisterComponent]
public class DamageOnHighSpeedImpactComponent : Component, ICollideBehavior public class DamageOnHighSpeedImpactComponent : Component, ICollideBehavior
{ {
[Dependency] private IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "DamageOnHighSpeedImpact"; 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.Interactable;
using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Physics;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -64,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Doors
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
protected float CloseSpeed = AutoCloseDelay; 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 CloseTimeOne => TimeSpan.FromSeconds(0.3f);
protected virtual TimeSpan CloseTimeTwo => TimeSpan.FromSeconds(0.9f); 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.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -17,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
[RegisterComponent] [RegisterComponent]
public class CursedEntityStorageComponent : EntityStorageComponent public class CursedEntityStorageComponent : EntityStorageComponent
{ {
[Dependency] private IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
public override string Name => "CursedEntityStorage"; public override string Name => "CursedEntityStorage";

View File

@@ -4,7 +4,6 @@ using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Reflection; using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -28,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Markers
public List<string> Prototypes { get; set; } = new List<string>(); public List<string> Prototypes { get; set; } = new List<string>();
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
private List<string> _gameRules = new List<string>(); private readonly List<string> _gameRules = new List<string>();
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public float Chance { get; set; } = 1.0f; public float Chance { get; set; } = 1.0f;

View File

@@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.Components.Morgue
public override string Name => "BodyBagEntityStorage"; public override string Name => "BodyBagEntityStorage";
[ViewVariables] [ViewVariables]
[ComponentDependency] private AppearanceComponent? _appearance = null; [ComponentDependency] private readonly AppearanceComponent? _appearance = null;
[ViewVariables] public ContainerSlot? LabelContainer { get; private set; } [ViewVariables] public ContainerSlot? LabelContainer { get; private set; }

View File

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

View File

@@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Alert; using Content.Shared.Alert;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Nutrition; using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -55,7 +54,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
[ViewVariables(VVAccess.ReadOnly)] [ViewVariables(VVAccess.ReadOnly)]
public Dictionary<HungerThreshold, float> HungerThresholds => _hungerThresholds; 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.Overfed, 600.0f},
{HungerThreshold.Okay, 450.0f}, {HungerThreshold.Okay, 450.0f},

View File

@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
[RegisterComponent] [RegisterComponent]
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing, IMapInit, ISignalReceiver<bool>, ISignalReceiver<ToggleSignal> 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"; 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.Conveyor;
using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Construction; using Content.Shared.Construction;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Recycling; using Content.Shared.GameObjects.Components.Recycling;
@@ -13,9 +12,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Map; using Robust.Shared.GameObjects.Components.Map;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -28,7 +25,7 @@ namespace Content.Server.GameObjects.Components.Recycling
{ {
public override string Name => "Recycler"; public override string Name => "Recycler";
private List<IEntity> _intersecting = new List<IEntity>(); private readonly List<IEntity> _intersecting = new List<IEntity>();
/// <summary> /// <summary>
/// Whether or not sentient beings will be recycled /// 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 Generator1;
public readonly ContainmentFieldGeneratorComponent Generator2; public readonly ContainmentFieldGeneratorComponent Generator2;
private List<IEntity> _fields = new List<IEntity>(); private readonly List<IEntity> _fields = new List<IEntity>();
private int _sharedEnergyPool; private int _sharedEnergyPool;
private CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource(); private readonly CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource();
public int SharedEnergyPool public int SharedEnergyPool
{ {
get => _sharedEnergyPool; get => _sharedEnergyPool;

View File

@@ -1,24 +1,18 @@
#nullable enable #nullable enable
using System; using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Projectiles; using Content.Server.GameObjects.Components.Projectiles;
using Content.Server.Utility; using Content.Server.Utility;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Physics; using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Singularity namespace Content.Server.GameObjects.Components.Singularity
@@ -26,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Singularity
[RegisterComponent] [RegisterComponent]
public class ContainmentFieldGeneratorComponent : Component, ICollideBehavior public class ContainmentFieldGeneratorComponent : Component, ICollideBehavior
{ {
[Dependency] private IPhysicsManager _physicsManager = null!; [Dependency] private readonly IPhysicsManager _physicsManager = null!;
public override string Name => "ContainmentFieldGenerator"; public override string Name => "ContainmentFieldGenerator";

View File

@@ -16,7 +16,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.ComponentDependencies; using Robust.Shared.GameObjects.ComponentDependencies;
using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -37,8 +36,8 @@ namespace Content.Server.GameObjects.Components.Singularity
{ {
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[ComponentDependency] private AppearanceComponent? _appearance = default; [ComponentDependency] private readonly AppearanceComponent? _appearance = default;
[ComponentDependency] private AccessReader? _accessReader = default; [ComponentDependency] private readonly AccessReader? _accessReader = default;
public override string Name => "Emitter"; public override string Name => "Emitter";

View File

@@ -1,10 +1,8 @@
#nullable enable #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.StationEvents; using Content.Server.GameObjects.Components.StationEvents;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.EntitySystemMessages;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
@@ -15,7 +13,6 @@ using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Map; using Robust.Shared.GameObjects.Components.Map;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
@@ -29,9 +26,7 @@ namespace Content.Server.GameObjects.Components.Singularity
[RegisterComponent] [RegisterComponent]
public class SingularityComponent : Component, ICollideBehavior public class SingularityComponent : Component, ICollideBehavior
{ {
[Dependency] private IEntityManager _entityManager = null!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private IRobustRandom _random = null!;
public override uint? NetID => ContentNetIDs.SINGULARITY; public override uint? NetID => ContentNetIDs.SINGULARITY;
@@ -163,17 +158,17 @@ namespace Content.Server.GameObjects.Components.Singularity
_singularityController?.Push(pushVector.Normalized, 2); _singularityController?.Push(pushVector.Normalized, 2);
} }
List<IEntity> _previousPulledEntites = new List<IEntity>(); private readonly List<IEntity> _previousPulledEntities = new List<IEntity>();
public void PullUpdate() public void PullUpdate()
{ {
foreach (var previousPulledEntity in _previousPulledEntites) foreach (var previousPulledEntity in _previousPulledEntities)
{ {
if(previousPulledEntity.Deleted) continue; if(previousPulledEntity.Deleted) continue;
if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue; if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>(); var controller = collidableComponent.EnsureController<SingularityPullController>();
controller.StopPull(); controller.StopPull();
} }
_previousPulledEntites.Clear(); _previousPulledEntities.Clear();
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10); var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
foreach (var entity in entitiesToPull) foreach (var entity in entitiesToPull)
@@ -187,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Singularity
var speed = 10 / vec.Length * Level; var speed = 10 / vec.Length * Level;
controller.Pull(vec.Normalized, speed); 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"; public override string Name => "RangedMagazine";
private Stack<IEntity> _spawnedAmmo = new Stack<IEntity>(); private readonly Stack<IEntity> _spawnedAmmo = new Stack<IEntity>();
private Container _ammoContainer; private Container _ammoContainer;
public int ShotsLeft => _spawnedAmmo.Count + _unspawnedCount; 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; 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.NanoTransen,
Faction.SimpleHostile | Faction.Syndicate | Faction.Xeno}, Faction.SimpleHostile | Faction.Syndicate | Faction.Xeno},

View File

@@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
/// <summary> /// <summary>
/// Queued region updates /// Queued region updates
/// </summary> /// </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 // Oh god the nesting. Shouldn't need to go beyond this
/// <summary> /// <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) /// Regions are groups of nodes with the same profile (for pathfinding purposes)
/// i.e. same collision, not-space, same access, etc. /// i.e. same collision, not-space, same access, etc.
/// </summary> /// </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>>>(); new Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>>();
/// <summary> /// <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 // 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 // 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>)>>(); new Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan, HashSet<PathfindingRegion>)>>();
private readonly List<PathfindingRegion> _queuedCacheDeletions = new List<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; public static event Action<SharedAiDebug.AStarRouteDebug> DebugRoute;
#endif #endif
private PathfindingNode _startNode; private readonly PathfindingNode _startNode;
private PathfindingNode _endNode; private PathfindingNode _endNode;
private PathfindingArgs _pathfindingArgs; private readonly PathfindingArgs _pathfindingArgs;
public AStarPathfindingJob( public AStarPathfindingJob(
double maxTime, double maxTime,

View File

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

View File

@@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
// Nodes per chunk row // Nodes per chunk row
public static int ChunkSize => 8; public static int ChunkSize => 8;
public PathfindingNode[,] Nodes => _nodes; 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) 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 MapCoordinates TargetMap => _target.Transform.MapPosition;
public EntityCoordinates TargetGrid => _target.Transform.Coordinates; public EntityCoordinates TargetGrid => _target.Transform.Coordinates;
public IEntity Target => _target; public IEntity Target => _target;
private IEntity _target; private readonly IEntity _target;
/// <inheritdoc /> /// <inheritdoc />
public float ArrivalDistance { get; } public float ArrivalDistance { get; }

View File

@@ -17,32 +17,35 @@ using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
// ReSharper disable once RedundantUsingDirective
using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Dependency = Robust.Shared.IoC.DependencyAttribute;
namespace Content.Server.GameObjects.EntitySystems.Atmos namespace Content.Server.GameObjects.EntitySystems.Atmos
{ {
[UsedImplicitly] [UsedImplicitly]
internal sealed class GasTileOverlaySystem : SharedGasTileOverlaySystem, IResettingEntitySystem internal sealed class GasTileOverlaySystem : SharedGasTileOverlaySystem, IResettingEntitySystem
{ {
[Robust.Shared.IoC.Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Robust.Shared.IoC.Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!;
/// <summary> /// <summary>
/// The tiles that have had their atmos data updated since last tick /// The tiles that have had their atmos data updated since last tick
/// </summary> /// </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>(); new Dictionary<IPlayerSession, PlayerGasOverlay>();
/// <summary> /// <summary>
/// Gas data stored in chunks to make PVS / bubbling easier. /// Gas data stored in chunks to make PVS / bubbling easier.
/// </summary> /// </summary>
private Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _overlay = private readonly Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _overlay =
new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>(); new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>();
/// <summary> /// <summary>

View File

@@ -32,8 +32,8 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter
public DoAfterStatus Status => AsTask.IsCompletedSuccessfully ? AsTask.Result : DoAfterStatus.Running; public DoAfterStatus Status => AsTask.IsCompletedSuccessfully ? AsTask.Result : DoAfterStatus.Running;
// NeedHand // NeedHand
private string? _activeHand; private readonly string? _activeHand;
private ItemComponent? _activeItem; private readonly ItemComponent? _activeItem;
public DoAfter(DoAfterEventArgs eventArgs) public DoAfter(DoAfterEventArgs eventArgs)
{ {

View File

@@ -34,8 +34,8 @@ namespace Content.Server.GameObjects.EntitySystems
/// <summary> Allows everyone to open all doors. </summary> /// <summary> Allows everyone to open all doors. </summary>
AllowAll AllowAll
} }
private List<ServerDoorComponent> _activeDoors = new List<ServerDoorComponent>(); private readonly List<ServerDoorComponent> _activeDoors = new List<ServerDoorComponent>();
public override void Initialize() public override void Initialize()
{ {
@@ -71,7 +71,7 @@ namespace Content.Server.GameObjects.EntitySystems
var comp = _activeDoors[i]; var comp = _activeDoors[i];
if (comp.Deleted) if (comp.Deleted)
_activeDoors.RemoveAt(i); _activeDoors.RemoveAt(i);
comp.OnUpdate(frameTime); comp.OnUpdate(frameTime);
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly] [UsedImplicitly]
internal sealed class EmergencyLightSystem : EntitySystem internal sealed class EmergencyLightSystem : EntitySystem
{ {
private List<EmergencyLightComponent> _activeLights = new List<EmergencyLightComponent>(); private readonly List<EmergencyLightComponent> _activeLights = new List<EmergencyLightComponent>();
public override void Initialize() public override void Initialize()
{ {
@@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.EntitySystems
case EmergencyLightComponent.EmergencyLightState.Charging: case EmergencyLightComponent.EmergencyLightState.Charging:
if (_activeLights.Contains(message.Component)) if (_activeLights.Contains(message.Component))
_activeLights.Add(message.Component); _activeLights.Add(message.Component);
break; break;
case EmergencyLightComponent.EmergencyLightState.Full: case EmergencyLightComponent.EmergencyLightState.Full:
case EmergencyLightComponent.EmergencyLightState.Empty: case EmergencyLightComponent.EmergencyLightState.Empty:

View File

@@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
public StationEvent CurrentEvent { get; private set; } public StationEvent CurrentEvent { get; private set; }
public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents; 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; private const float MinimumTimeUntilFirstEvent = 300;

View File

@@ -1025,15 +1025,15 @@ The current game mode is: [color=white]{0}[/color].
return preset; return preset;
} }
[Dependency] private IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private IMapLoader _mapLoader = default!; [Dependency] private readonly IMapLoader _mapLoader = default!;
[Dependency] private IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private IConfigurationManager _configurationManager = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private IServerNetManager _netManager = default!; [Dependency] private readonly IServerNetManager _netManager = default!;
[Dependency] private IDynamicTypeFactory _dynamicTypeFactory = default!; [Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!;
[Dependency] private IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IServerPreferencesManager _prefsManager = default!; [Dependency] private readonly IServerPreferencesManager _prefsManager = default!;
[Dependency] private readonly IBaseServer _baseServer = default!; [Dependency] private readonly IBaseServer _baseServer = default!;

View File

@@ -29,18 +29,16 @@ namespace Content.Server.StationEvents
private float _elapsedTime; private float _elapsedTime;
private int _failDuration; private int _failDuration;
/// <summary> /// <summary>
/// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds. /// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds.
/// </summary> /// </summary>
private bool _announced; private bool _announced;
private CancellationTokenSource _announceCancelToken; private CancellationTokenSource _announceCancelToken;
private List<IEntity> _powered = new List<IEntity>();
private readonly List<IEntity> _powered = new List<IEntity>();
public override void Startup() public override void Startup()
{ {
base.Startup(); base.Startup();
@@ -49,7 +47,7 @@ namespace Content.Server.StationEvents
_elapsedTime = 0.0f; _elapsedTime = 0.0f;
_failDuration = IoCManager.Resolve<IRobustRandom>().Next(60, 120); _failDuration = IoCManager.Resolve<IRobustRandom>().Next(60, 120);
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
foreach (PowerReceiverComponent component in componentManager.EntityQuery<PowerReceiverComponent>()) foreach (PowerReceiverComponent component in componentManager.EntityQuery<PowerReceiverComponent>())
{ {
component.PowerDisabled = true; component.PowerDisabled = true;
@@ -64,13 +62,13 @@ namespace Content.Server.StationEvents
foreach (var entity in _powered) foreach (var entity in _powered)
{ {
if (entity.Deleted) continue; if (entity.Deleted) continue;
if (entity.TryGetComponent(out PowerReceiverComponent powerReceiverComponent)) if (entity.TryGetComponent(out PowerReceiverComponent powerReceiverComponent))
{ {
powerReceiverComponent.PowerDisabled = false; powerReceiverComponent.PowerDisabled = false;
} }
} }
_announceCancelToken?.Cancel(); _announceCancelToken?.Cancel();
_announceCancelToken = new CancellationTokenSource(); _announceCancelToken = new CancellationTokenSource();
Timer.Spawn(3000, () => Timer.Spawn(3000, () =>
@@ -92,7 +90,7 @@ namespace Content.Server.StationEvents
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_off.ogg"); EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_off.ogg");
_announced = true; _announced = true;
} }
_elapsedTime += frameTime; _elapsedTime += frameTime;
if (_elapsedTime < _failDuration) if (_elapsedTime < _failDuration)

View File

@@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -13,8 +12,8 @@ namespace Content.Shared.Alert
[Prototype("alertOrder")] [Prototype("alertOrder")]
public class AlertOrderPrototype : IPrototype, IComparer<AlertPrototype> public class AlertOrderPrototype : IPrototype, IComparer<AlertPrototype>
{ {
private Dictionary<AlertType, int> _typeToIdx = new Dictionary<AlertType, int>(); private readonly Dictionary<AlertType, int> _typeToIdx = new Dictionary<AlertType, int>();
private Dictionary<AlertCategory, int> _categoryToIdx = new Dictionary<AlertCategory, int>(); private readonly Dictionary<AlertCategory, int> _categoryToIdx = new Dictionary<AlertCategory, int>();
public void LoadFrom(YamlMappingNode mapping) public void LoadFrom(YamlMappingNode mapping)
{ {

View File

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

View File

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

View File

@@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Research
public override string Name => "LatheDatabase"; public override string Name => "LatheDatabase";
public override uint? NetID => ContentNetIDs.LATHE_DATABASE; public override uint? NetID => ContentNetIDs.LATHE_DATABASE;
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>(); private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
/// <summary> /// <summary>
/// Removes all recipes from the database if it's not static. /// 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 override string Name => "ProtolatheDatabase";
public sealed override uint? NetID => ContentNetIDs.PROTOLATHE_DATABASE; public sealed override uint? NetID => ContentNetIDs.PROTOLATHE_DATABASE;
private List<LatheRecipePrototype> _protolatheRecipes = new List<LatheRecipePrototype>(); private readonly List<LatheRecipePrototype> _protolatheRecipes = new List<LatheRecipePrototype>();
/// <summary> /// <summary>
/// A full list of recipes this protolathe can print. /// A full list of recipes this protolathe can print.

View File

@@ -7,7 +7,7 @@ namespace Content.Shared.Physics
{ {
public abstract class FrictionController : VirtualController public abstract class FrictionController : VirtualController
{ {
[Dependency] private IPhysicsManager _physicsManager = default!; [Dependency] private readonly IPhysicsManager _physicsManager = default!;
public override void UpdateAfterProcessing() public override void UpdateAfterProcessing()
{ {