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

@@ -169,8 +169,8 @@ namespace Content.Client.GameObjects.EntitySystems.AI
internal sealed class DebugPathfindingOverlay : Overlay
{
private IEyeManager _eyeManager;
private IPlayerManager _playerManager;
private readonly IEyeManager _eyeManager;
private readonly IPlayerManager _playerManager;
// TODO: Add a box like the debug one and show the most recent path stuff
public override OverlaySpace Space => OverlaySpace.ScreenSpace;

View File

@@ -14,8 +14,8 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
public sealed class DoAfterBar : Control
{
private IGameTiming _gameTiming = default!;
private ShaderInstance _shader;
private readonly ShaderInstance _shader;
/// <summary>
/// Set from 0.0f to 1.0f to reflect bar progress
@@ -40,13 +40,13 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
return;
}
_cancelled = value;
if (_cancelled)
{
_gameTiming = IoCManager.Resolve<IGameTiming>();
_lastFlash = _gameTiming.CurTime;
}
}
}
}
@@ -87,7 +87,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
_lastFlash = _gameTiming.CurTime;
_flash = !_flash;
}
}
}
}
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 IGameTiming _gameTiming = default!;
private Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>();
private Dictionary<byte, DoAfterBar> _doAfterBars = new Dictionary<byte, DoAfterBar>();
private readonly Dictionary<byte, PanelContainer> _doAfterControls = new Dictionary<byte, PanelContainer>();
private readonly Dictionary<byte, DoAfterBar> _doAfterBars = new Dictionary<byte, DoAfterBar>();
// We'll store cancellations for a little bit just so we can flash the graphic to indicate it's cancelled
private Dictionary<byte, TimeSpan> _cancelledDoAfters = new Dictionary<byte, TimeSpan>();
private readonly Dictionary<byte, TimeSpan> _cancelledDoAfters = new Dictionary<byte, TimeSpan>();
public IEntity? AttachedEntity { get; set; }
private ScreenCoordinates _playerPosition;
@@ -48,12 +48,12 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
base.Dispose(disposing);
if (Disposed)
return;
foreach (var (_, control) in _doAfterControls)
{
control.Dispose();
}
_doAfterControls.Clear();
_doAfterBars.Clear();
_cancelledDoAfters.Clear();
@@ -109,10 +109,10 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
RemoveChild(control);
_doAfterControls.Remove(id);
_doAfterBars.Remove(id);
if (_cancelledDoAfters.ContainsKey(id))
_cancelledDoAfters.Remove(id);
}
/// <summary>
@@ -130,7 +130,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
doAfterBar = new DoAfterBar();
_doAfterBars[id] = doAfterBar;
}
doAfterBar.Cancelled = true;
_cancelledDoAfters.Add(id, _gameTiming.CurTime);
}
@@ -139,7 +139,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
base.FrameUpdate(args);
if (AttachedEntity?.IsValid() != true ||
if (AttachedEntity?.IsValid() != true ||
!AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent))
{
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
// come into range it needs altering
private HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private readonly HashSet<DoAfterComponent> _knownComponents = new HashSet<DoAfterComponent>();
private IEntity? _attachedEntity;

View File

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

View File

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