Use 'new' expression in places where the type is evident for content (#2590)

* Content.Client

* Content.Benchmarks

* Content.IntegrationTests

* Content.Server

* Content.Server.Database

* Content.Shared

* Content.Tests

* Merge fixes

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2020-11-27 11:00:49 +01:00
committed by GitHub
parent 4a56df749b
commit 5c0cf1b1a0
235 changed files with 431 additions and 433 deletions

View File

@@ -29,7 +29,7 @@ namespace Content.Client.GameObjects.Components.Access
private readonly IdCardConsoleBoundUserInterface _owner;
private readonly Dictionary<string, Button> _accessButtons = new Dictionary<string, Button>();
private readonly Dictionary<string, Button> _accessButtons = new();
private string _lastFullName;
private string _lastJobTitle;

View File

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

View File

@@ -130,7 +130,7 @@ namespace Content.Client.GameObjects.Components
[ViewVariables] public Box2 East;
[ViewVariables] public Box2 West;
public static DirBoundData Default { get; } = new DirBoundData();
public static DirBoundData Default { get; } = new();
public void ExposeData(ObjectSerializer serializer)
{

View File

@@ -33,7 +33,7 @@ namespace Content.Client.GameObjects.Components.CloningPod
private CloningPodBoundUserInterfaceState _lastUpdate = null!;
// List of scans that are visible based on current filter criteria.
private readonly Dictionary<int, string> _filteredScans = new Dictionary<int, string>();
private readonly Dictionary<int, string> _filteredScans = new();
// The indices of the visible scans last time UpdateVisibleScans was ran.
// This is inclusive, so end is the index of the last scan, not right after it.

View File

@@ -17,10 +17,9 @@ namespace Content.Client.GameObjects.Components
public override string Name => "DoAfter";
public IReadOnlyDictionary<byte, ClientDoAfter> DoAfters => _doAfters;
private readonly Dictionary<byte, ClientDoAfter> _doAfters = new Dictionary<byte, ClientDoAfter>();
public readonly List<(TimeSpan CancelTime, ClientDoAfter Message)> CancelledDoAfters =
new List<(TimeSpan CancelTime, ClientDoAfter Message)>();
private readonly Dictionary<byte, ClientDoAfter> _doAfters = new();
public readonly List<(TimeSpan CancelTime, ClientDoAfter Message)> CancelledDoAfters = new();
public DoAfterGui? Gui { get; set; }

View File

@@ -12,7 +12,7 @@ namespace Content.Client.GameObjects.Components
[UsedImplicitly]
public class FlashLightVisualizer : AppearanceVisualizer
{
private readonly Animation _radiatingLightAnimation = new Animation
private readonly Animation _radiatingLightAnimation = new()
{
Length = TimeSpan.FromSeconds(1),
AnimationTracks =
@@ -32,7 +32,7 @@ namespace Content.Client.GameObjects.Components
}
};
private readonly Animation _blinkingLightAnimation = new Animation
private readonly Animation _blinkingLightAnimation = new()
{
Length = TimeSpan.FromSeconds(1),
AnimationTracks =

View File

@@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.Components.Gravity
{
public class GravityGeneratorVisualizer : AppearanceVisualizer
{
private readonly Dictionary<GravityGeneratorStatus, string> _spriteMap = new Dictionary<GravityGeneratorStatus, string>();
private readonly Dictionary<GravityGeneratorStatus, string> _spriteMap = new();
public override void InitializeEntity(IEntity entity)
{

View File

@@ -22,7 +22,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
[RegisterComponent]
public class ClientInventoryComponent : SharedInventoryComponent
{
private readonly Dictionary<Slots, IEntity> _slots = new Dictionary<Slots, IEntity>();
private readonly Dictionary<Slots, IEntity> _slots = new();
[ViewVariables] public InventoryInterfaceController InterfaceController { get; private set; } = default!;

View File

@@ -22,7 +22,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
= new Dictionary<Slots, List<ItemSlotButton>>();
= new();
private ItemSlotButton _hudButtonPocket1;
private ItemSlotButton _hudButtonPocket2;

View File

@@ -42,12 +42,12 @@ namespace Content.Client.GameObjects.Components
private float _timer;
private static readonly StyleBoxFlat _styleBoxLit = new StyleBoxFlat
private static readonly StyleBoxFlat _styleBoxLit = new()
{
BackgroundColor = Color.Green
};
private static readonly StyleBoxFlat _styleBoxUnlit = new StyleBoxFlat
private static readonly StyleBoxFlat _styleBoxUnlit = new()
{
BackgroundColor = Color.Black
};

View File

@@ -50,7 +50,7 @@ namespace Content.Client.GameObjects.Components.Instruments
/// A queue of MidiEvents to be sent to the server.
/// </summary>
[ViewVariables]
private readonly List<MidiEvent> _midiEventBuffer = new List<MidiEvent>();
private readonly List<MidiEvent> _midiEventBuffer = new();
/// <summary>
/// Whether a midi song will loop or not.

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Items
private HandsGui? _gui;
private readonly List<Hand> _hands = new List<Hand>();
private readonly List<Hand> _hands = new();
[ViewVariables] public IReadOnlyList<Hand> Hands => _hands;

View File

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

View File

@@ -11,7 +11,7 @@ namespace Content.Client.GameObjects.Components
[UsedImplicitly]
public class LanternVisualizer : AppearanceVisualizer
{
private readonly Animation _radiatingLightAnimation = new Animation
private readonly Animation _radiatingLightAnimation = new()
{
Length = TimeSpan.FromSeconds(5),
AnimationTracks =

View File

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

View File

@@ -45,7 +45,7 @@ namespace Content.Client.GameObjects.Components.Mobs
[ViewVariables]
private readonly Dictionary<AlertKey, AlertControl> _alertControls
= new Dictionary<AlertKey, AlertControl>();
= new();
/// <summary>
/// Allows calculating if we need to act due to this component being controlled by the current mob

View File

@@ -31,7 +31,7 @@ namespace Content.Client.GameObjects.Components.Mobs
/// <summary>
/// A list of overlay containers representing the current overlays applied
/// </summary>
private List<OverlayContainer> _currentEffects = new List<OverlayContainer>();
private List<OverlayContainer> _currentEffects = new();
[ViewVariables(VVAccess.ReadOnly)]
public List<OverlayContainer> ActiveOverlays

View File

@@ -14,7 +14,7 @@ namespace Content.Client.GameObjects.Components.Mobs
public sealed class DamageStateVisualizer : AppearanceVisualizer
{
private DamageState _data = DamageState.Alive;
private readonly Dictionary<DamageState, string> _stateMap = new Dictionary<DamageState, string>();
private readonly Dictionary<DamageState, string> _stateMap = new();
private int? _originalDrawDepth;
public override void LoadData(YamlMappingNode node)

View File

@@ -10,7 +10,7 @@ namespace Content.Client.GameObjects.Components.Mobs.State
[ComponentReference(typeof(SharedMobStateManagerComponent))]
public class MobStateManagerComponent : SharedMobStateManagerComponent
{
private readonly Dictionary<DamageState, IMobState> _behavior = new Dictionary<DamageState, IMobState>
private readonly Dictionary<DamageState, IMobState> _behavior = new()
{
{DamageState.Alive, new NormalState()},
{DamageState.Critical, new CriticalState()},

View File

@@ -19,8 +19,8 @@ namespace Content.Client.GameObjects.Components.Observer
[Dependency] private readonly IGameHud _gameHud = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IComponentManager _componentManager = default!;
public List<string> WarpNames = new List<string>();
public Dictionary<EntityUid,string> PlayerNames = new Dictionary<EntityUid,string>();
public List<string> WarpNames = new();
public Dictionary<EntityUid,string> PlayerNames = new();
private GhostGui? _gui ;

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components
{
public class ParticleAcceleratorPartVisualizer : AppearanceVisualizer
{
private readonly Dictionary<ParticleAcceleratorVisualState, string> _states = new Dictionary<ParticleAcceleratorVisualState, string>();
private readonly Dictionary<ParticleAcceleratorVisualState, string> _states = new();
public override void LoadData(YamlMappingNode node)
{

View File

@@ -17,7 +17,7 @@ namespace Content.Client.GameObjects.Components.Power
[Dependency] private readonly IGameTiming _gameTiming = default;
private SolarControlWindow _window;
private SolarControlConsoleBoundInterfaceState _lastState = new SolarControlConsoleBoundInterfaceState(0, 0, 0, 0);
private SolarControlConsoleBoundInterfaceState _lastState = new(0, 0, 0, 0);
protected override void Open()
{
@@ -161,7 +161,7 @@ namespace Content.Client.GameObjects.Components.Power
// This makes the display feel a lot smoother.
private IGameTiming _gameTiming;
private SolarControlConsoleBoundInterfaceState _lastState = new SolarControlConsoleBoundInterfaceState(0, 0, 0, 0);
private SolarControlConsoleBoundInterfaceState _lastState = new(0, 0, 0, 0);
private TimeSpan _lastStateTime = TimeSpan.Zero;

View File

@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Research
[ViewVariables]
public Queue<LatheRecipePrototype> QueuedRecipes => _queuedRecipes;
private readonly Queue<LatheRecipePrototype> _queuedRecipes = new Queue<LatheRecipePrototype>();
private readonly Queue<LatheRecipePrototype> _queuedRecipes = new();
public LatheBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{

View File

@@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Research
[ComponentReference(typeof(SharedMaterialStorageComponent))]
public class MaterialStorageComponent : SharedMaterialStorageComponent
{
protected override Dictionary<string, int> Storage { get; set; } = new Dictionary<string, int>();
protected override Dictionary<string, int> Storage { get; set; } = new();
public event Action OnMaterialStorageChanged;

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Sound
{
[Dependency] private readonly IRobustRandom _random = default!;
private readonly Dictionary<ScheduledSound, IPlayingAudioStream> _audioStreams = new Dictionary<ScheduledSound, IPlayingAudioStream>();
private readonly Dictionary<ScheduledSound, IPlayingAudioStream> _audioStreams = new();
private AudioSystem _audioSystem;
public override void StopAllSounds()

View File

@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Storage
[RegisterComponent]
public class ClientStorageComponent : SharedStorageComponent, IDraggable
{
private List<IEntity> _storedEntities = new List<IEntity>();
private List<IEntity> _storedEntities = new();
private int StorageSizeUsed;
private int StorageCapacityMax;
private StorageWindow Window;
@@ -138,8 +138,8 @@ namespace Content.Client.GameObjects.Components.Storage
private readonly Label _information;
public ClientStorageComponent StorageEntity;
private readonly StyleBoxFlat _hoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.35f) };
private readonly StyleBoxFlat _unHoveredBox = new StyleBoxFlat { BackgroundColor = Color.Black.WithAlpha(0.0f) };
private readonly StyleBoxFlat _hoveredBox = new() { BackgroundColor = Color.Black.WithAlpha(0.35f) };
private readonly StyleBoxFlat _unHoveredBox = new() { BackgroundColor = Color.Black.WithAlpha(0.0f) };
protected override Vector2? CustomSize => (180, 320);

View File

@@ -67,7 +67,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
}
}
public HashSet<EntityUid> Allies { get; } = new HashSet<EntityUid>();
public HashSet<EntityUid> Allies { get; } = new();
private bool AddAlly(EntityUid ally)
{

View File

@@ -23,7 +23,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
private readonly Font _font;
private readonly IEntity _user;
private readonly HashSet<EntityUid> _allies = new HashSet<EntityUid>();
private readonly HashSet<EntityUid> _allies = new();
private readonly string _traitorText = Loc.GetString("Traitor");
public TraitorOverlay(

View File

@@ -26,7 +26,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
private Dictionary<string, bool> _baseStates;
private static readonly Dictionary<string, VendingMachineVisualLayers> LayerMap =
new Dictionary<string, VendingMachineVisualLayers>
new()
{
{"off", VendingMachineVisualLayers.Unlit},
{"screen", VendingMachineVisualLayers.Screen},
@@ -39,7 +39,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
{"broken", VendingMachineVisualLayers.Unlit},
};
private readonly Dictionary<string, Animation> _animations = new Dictionary<string, Animation>();
private readonly Dictionary<string, Animation> _animations = new();
public override void LoadData(YamlMappingNode node)
{

View File

@@ -22,7 +22,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
[RegisterComponent]
public class ClientMagazineBarrelComponent : Component, IItemStatus
{
private static readonly Animation AlarmAnimationSmg = new Animation
private static readonly Animation AlarmAnimationSmg = new()
{
Length = TimeSpan.FromSeconds(1.4),
AnimationTracks =
@@ -45,7 +45,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
}
};
private static readonly Animation AlarmAnimationLmg = new Animation
private static readonly Animation AlarmAnimationLmg = new()
{
Length = TimeSpan.FromSeconds(0.75),
AnimationTracks =

View File

@@ -481,7 +481,7 @@ namespace Content.Client.GameObjects.Components.Wires
private sealed class StatusLight : Control
{
private static readonly Animation _blinkingFast = new Animation
private static readonly Animation _blinkingFast = new()
{
Length = TimeSpan.FromSeconds(0.2),
AnimationTracks =
@@ -500,7 +500,7 @@ namespace Content.Client.GameObjects.Components.Wires
}
};
private static readonly Animation _blinkingSlow = new Animation
private static readonly Animation _blinkingSlow = new()
{
Length = TimeSpan.FromSeconds(0.8),
AnimationTracks =