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

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