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

@@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI
public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None;
private Dictionary<Faction, Faction> _hostileFactions = new Dictionary<Faction, Faction>
private readonly Dictionary<Faction, Faction> _hostileFactions = new Dictionary<Faction, Faction>
{
{Faction.NanoTransen,
Faction.SimpleHostile | Faction.Syndicate | Faction.Xeno},

View File

@@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
/// <summary>
/// Queued region updates
/// </summary>
private HashSet<PathfindingChunk> _queuedUpdates = new HashSet<PathfindingChunk>();
private readonly HashSet<PathfindingChunk> _queuedUpdates = new HashSet<PathfindingChunk>();
// Oh god the nesting. Shouldn't need to go beyond this
/// <summary>
@@ -53,7 +53,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
/// Regions are groups of nodes with the same profile (for pathfinding purposes)
/// i.e. same collision, not-space, same access, etc.
/// </summary>
private Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>> _regions =
private readonly Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>> _regions =
new Dictionary<GridId, Dictionary<PathfindingChunk, HashSet<PathfindingRegion>>>();
/// <summary>
@@ -70,7 +70,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
// Also, didn't use a dictionary because there didn't seem to be a clean way to do the lookup
// Plus this way we can check if everything is equal except for vision so an entity with a lower vision radius can use an entity with a higher vision radius' cached result
private Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan CacheTime, HashSet<PathfindingRegion> Regions)>> _cachedAccessible =
private readonly Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan CacheTime, HashSet<PathfindingRegion> Regions)>> _cachedAccessible =
new Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan, HashSet<PathfindingRegion>)>>();
private readonly List<PathfindingRegion> _queuedCacheDeletions = new List<PathfindingRegion>();

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
// Nodes per chunk row
public static int ChunkSize => 8;
public PathfindingNode[,] Nodes => _nodes;
private PathfindingNode[,] _nodes = new PathfindingNode[ChunkSize,ChunkSize];
private readonly PathfindingNode[,] _nodes = new PathfindingNode[ChunkSize,ChunkSize];
public PathfindingChunk(GridId gridId, Vector2i indices)
{

View File

@@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
public MapCoordinates TargetMap => _target.Transform.MapPosition;
public EntityCoordinates TargetGrid => _target.Transform.Coordinates;
public IEntity Target => _target;
private IEntity _target;
private readonly IEntity _target;
/// <inheritdoc />
public float ArrivalDistance { get; }

View File

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

View File

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

View File

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

View File

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

View File

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