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:
@@ -18,12 +18,12 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
{
|
||||
public override string Name => "Mechanism";
|
||||
|
||||
protected readonly Dictionary<int, object> OptionsCache = new Dictionary<int, object>();
|
||||
protected readonly Dictionary<int, object> OptionsCache = new();
|
||||
protected IBody? BodyCache;
|
||||
protected int IdHash;
|
||||
protected IEntity? PerformerCache;
|
||||
private IBodyPart? _part;
|
||||
private readonly Dictionary<Type, IMechanismBehavior> _behaviors = new Dictionary<Type, IMechanismBehavior>();
|
||||
private readonly Dictionary<Type, IMechanismBehavior> _behaviors = new();
|
||||
|
||||
public IBody? Body => Part?.Body;
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace Content.Shared.GameObjects.Components.Body.Part
|
||||
private IBody? _body;
|
||||
|
||||
// TODO BODY Remove
|
||||
private List<string> _mechanismIds = new List<string>();
|
||||
private List<string> _mechanismIds = new();
|
||||
public IReadOnlyList<string> MechanismIds => _mechanismIds;
|
||||
|
||||
[ViewVariables]
|
||||
private readonly HashSet<IMechanism> _mechanisms = new HashSet<IMechanism>();
|
||||
private readonly HashSet<IMechanism> _mechanisms = new();
|
||||
|
||||
[ViewVariables]
|
||||
public IBody? Body
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Content.Shared.GameObjects.Components.Body.Preset
|
||||
|
||||
[ViewVariables] public string Name => _name;
|
||||
|
||||
[ViewVariables] public Dictionary<string, string> PartIDs => new Dictionary<string, string>(_partIDs);
|
||||
[ViewVariables] public Dictionary<string, string> PartIDs => new(_partIDs);
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
|
||||
@@ -32,19 +32,19 @@ namespace Content.Shared.GameObjects.Components.Body
|
||||
|
||||
private string? _centerSlot;
|
||||
|
||||
private Dictionary<string, string> _partIds = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> _partIds = new();
|
||||
|
||||
private readonly Dictionary<string, IBodyPart> _parts = new Dictionary<string, IBodyPart>();
|
||||
private readonly Dictionary<string, IBodyPart> _parts = new();
|
||||
|
||||
[ViewVariables] public string? TemplateName { get; private set; }
|
||||
|
||||
[ViewVariables] public string? PresetName { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, BodyPartType> Slots { get; private set; } = new Dictionary<string, BodyPartType>();
|
||||
public Dictionary<string, BodyPartType> Slots { get; private set; } = new();
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, List<string>> Connections { get; private set; } = new Dictionary<string, List<string>>();
|
||||
public Dictionary<string, List<string>> Connections { get; private set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Maps slots to the part filling each one.
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.Shared.GameObjects.Components.Body.Surgery
|
||||
{
|
||||
public override string Name => "BiologicalSurgeryData";
|
||||
|
||||
private readonly List<IMechanism> _disconnectedOrgans = new List<IMechanism>();
|
||||
private readonly List<IMechanism> _disconnectedOrgans = new();
|
||||
|
||||
private bool _skinOpened;
|
||||
private bool _skinRetracted;
|
||||
|
||||
@@ -30,15 +30,15 @@ namespace Content.Shared.GameObjects.Components.Body.Template
|
||||
|
||||
[ViewVariables] public string CenterSlot => _centerSlot;
|
||||
|
||||
[ViewVariables] public Dictionary<string, BodyPartType> Slots => new Dictionary<string, BodyPartType>(_slots);
|
||||
[ViewVariables] public Dictionary<string, BodyPartType> Slots => new(_slots);
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, List<string>> Connections =>
|
||||
_connections.ToDictionary(x => x.Key, x => x.Value.ToList());
|
||||
|
||||
[ViewVariables] public Dictionary<string, string> Layers => new Dictionary<string, string>(_layers);
|
||||
[ViewVariables] public Dictionary<string, string> Layers => new(_layers);
|
||||
|
||||
[ViewVariables] public Dictionary<string, string> MechanismLayers => new Dictionary<string, string>(_mechanismLayers);
|
||||
[ViewVariables] public Dictionary<string, string> MechanismLayers => new(_mechanismLayers);
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Cargo
|
||||
public sealed override string Name => "GalacticMarket";
|
||||
public sealed override uint? NetID => ContentNetIDs.GALACTIC_MARKET;
|
||||
|
||||
protected List<CargoProductPrototype> _products = new List<CargoProductPrototype>();
|
||||
protected List<CargoProductPrototype> _products = new();
|
||||
|
||||
/// <summary>
|
||||
/// A read-only list of products.
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry.ReagentDispenser
|
||||
/// <summary>
|
||||
/// A list of reagents which this may dispense. Defined in yaml prototype, see <see cref="ReagentDispenserInventoryPrototype"/>.
|
||||
/// </summary>
|
||||
protected readonly List<ReagentDispenserInventoryEntry> Inventory = new List<ReagentDispenserInventoryEntry>();
|
||||
protected readonly List<ReagentDispenserInventoryEntry> Inventory = new();
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
|
||||
/// <inheritdoc />
|
||||
public sealed override uint? NetID => ContentNetIDs.SOLUTION;
|
||||
|
||||
private Solution _solution = new Solution();
|
||||
private Solution _solution = new();
|
||||
private ReagentUnit _maxVolume;
|
||||
private Color _substanceColor;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Shared.GameObjects.Components.Damage
|
||||
|
||||
[ViewVariables] private DamageContainer Damage { get; set; } = default!;
|
||||
|
||||
public Dictionary<DamageState, int> Thresholds { get; set; } = new Dictionary<DamageState, int>();
|
||||
public Dictionary<DamageState, int> Thresholds { get; set; } = new();
|
||||
|
||||
public virtual List<DamageState> SupportedDamageStates
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
||||
{
|
||||
public override string Name => "DisposalRouter";
|
||||
|
||||
public static readonly Regex TagRegex = new Regex("^[a-zA-Z0-9, ]*$", RegexOptions.Compiled);
|
||||
public static readonly Regex TagRegex = new("^[a-zA-Z0-9, ]*$", RegexOptions.Compiled);
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class DisposalRouterUserInterfaceState : BoundUserInterfaceState
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
||||
{
|
||||
public override string Name => "DisposalTagger";
|
||||
|
||||
public static readonly Regex TagRegex = new Regex("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);
|
||||
public static readonly Regex TagRegex = new("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class DisposalTaggerUserInterfaceState : BoundUserInterfaceState
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
||||
{
|
||||
public override string Name => "DisposalUnit";
|
||||
|
||||
private readonly List<IEntity> _intersecting = new List<IEntity>();
|
||||
private readonly List<IEntity> _intersecting = new();
|
||||
|
||||
[ViewVariables]
|
||||
public bool Anchored =>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Content.Shared.GameObjects.Components.Inventory
|
||||
{
|
||||
public override string InterfaceControllerTypeName => "HumanInventoryInterfaceController";
|
||||
|
||||
private static readonly Dictionary<Slots, int> _slotDrawingOrder = new Dictionary<Slots, int>
|
||||
private static readonly Dictionary<Slots, int> _slotDrawingOrder = new()
|
||||
{
|
||||
{Slots.POCKET1, 13},
|
||||
{Slots.POCKET2, 12},
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
public override uint? NetID => ContentNetIDs.ALERTS;
|
||||
|
||||
[ViewVariables]
|
||||
private Dictionary<AlertKey, ClickableAlertState> _alerts = new Dictionary<AlertKey, ClickableAlertState>();
|
||||
private Dictionary<AlertKey, ClickableAlertState> _alerts = new();
|
||||
|
||||
/// <returns>true iff an alert of the indicated alert category is currently showing</returns>
|
||||
public bool IsShowingAlertCategory(AlertCategory alertCategory)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
public string ID { get; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public List<OverlayParameter> Parameters { get; } = new List<OverlayParameter>();
|
||||
public List<OverlayParameter> Parameters { get; } = new();
|
||||
|
||||
public OverlayContainer([NotNull] string id)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
|
||||
private string _stunAlertId;
|
||||
|
||||
protected CancellationTokenSource StatusRemoveCancellation = new CancellationTokenSource();
|
||||
protected CancellationTokenSource StatusRemoveCancellation = new();
|
||||
|
||||
[ViewVariables] protected float WalkModifierOverride = 0f;
|
||||
[ViewVariables] protected float RunModifierOverride = 0f;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Content.Shared.GameObjects.Components.Movement
|
||||
/// The list of entities that have been slipped by this component,
|
||||
/// and which have not stopped colliding with its owner yet.
|
||||
/// </summary>
|
||||
protected readonly List<EntityUid> _slipped = new List<EntityUid>();
|
||||
protected readonly List<EntityUid> _slipped = new();
|
||||
|
||||
/// <summary>
|
||||
/// How many seconds the mob will be paralyzed for.
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Research
|
||||
public override string Name => "LatheDatabase";
|
||||
public override uint? NetID => ContentNetIDs.LATHE_DATABASE;
|
||||
|
||||
private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
|
||||
private readonly List<LatheRecipePrototype> _recipes = new();
|
||||
|
||||
/// <summary>
|
||||
/// Removes all recipes from the database if it's not static.
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Shared.GameObjects.Components.Research
|
||||
public override string Name => "ProtolatheDatabase";
|
||||
public sealed override uint? NetID => ContentNetIDs.PROTOLATHE_DATABASE;
|
||||
|
||||
private readonly List<LatheRecipePrototype> _protolatheRecipes = new List<LatheRecipePrototype>();
|
||||
private readonly List<LatheRecipePrototype> _protolatheRecipes = new();
|
||||
|
||||
/// <summary>
|
||||
/// A full list of recipes this protolathe can print.
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Shared.GameObjects.Components.Research
|
||||
public override string Name => "TechnologyDatabase";
|
||||
public override uint? NetID => ContentNetIDs.TECHNOLOGY_DATABASE;
|
||||
|
||||
protected List<TechnologyPrototype> _technologies = new List<TechnologyPrototype>();
|
||||
protected List<TechnologyPrototype> _technologies = new();
|
||||
|
||||
/// <summary>
|
||||
/// A read-only list of unlocked technologies.
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Shared.GameObjects.Components.VendingMachines
|
||||
public override uint? NetID => ContentNetIDs.VENDING_MACHINE;
|
||||
|
||||
[ViewVariables]
|
||||
public List<VendingMachineInventoryEntry> Inventory = new List<VendingMachineInventoryEntry>();
|
||||
public List<VendingMachineInventoryEntry> Inventory = new();
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum VendingMachineVisuals
|
||||
|
||||
Reference in New Issue
Block a user