Fix IDE0028, IDE0300, IDE0301, IDE0302, IDE0303, IDE0304.

Silence IDE0305.
This commit is contained in:
RoosterDragon
2025-03-03 17:29:45 +00:00
committed by Pavel Penev
parent 0740991c12
commit 79454d8fd2
559 changed files with 1661 additions and 1751 deletions

View File

@@ -30,17 +30,17 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Every time another production building of the same queue is",
"constructed, the build times of all actors in the queue",
"modified by a percentage of the original time.")]
public readonly int[] BuildingCountBuildTimeMultipliers = { 100, 86, 75, 67, 60, 55, 50 };
public readonly int[] BuildingCountBuildTimeMultipliers = [100, 86, 75, 67, 60, 55, 50];
[Desc("Build time modifier multiplied by the number of parallel production for producing different actors at the same time.")]
public readonly int[] ParallelPenaltyBuildTimeMultipliers = { 100, 116, 133, 150, 166, 183, 200, 216, 233, 250 };
public readonly int[] ParallelPenaltyBuildTimeMultipliers = [100, 116, 133, 150, 166, 183, 200, 216, 233, 250];
public override object Create(ActorInitializer init) { return new ClassicParallelProductionQueue(init, this); }
}
public class ClassicParallelProductionQueue : ProductionQueue
{
static readonly ActorInfo[] NoItems = Array.Empty<ActorInfo>();
static readonly ActorInfo[] NoItems = [];
readonly Actor self;
readonly ClassicParallelProductionQueueInfo info;

View File

@@ -29,14 +29,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Every time another production building of the same queue is",
"constructed, the build times of all actors in the queue",
"decreased by a percentage of the original time.")]
public readonly int[] BuildTimeSpeedReduction = { 100, 86, 75, 67, 60, 55, 50 };
public readonly int[] BuildTimeSpeedReduction = [100, 86, 75, 67, 60, 55, 50];
public override object Create(ActorInitializer init) { return new ClassicProductionQueue(init, this); }
}
public class ClassicProductionQueue : ProductionQueue
{
static readonly ActorInfo[] NoItems = Array.Empty<ActorInfo>();
static readonly ActorInfo[] NoItems = [];
readonly Actor self;
readonly ClassicProductionQueueInfo info;

View File

@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits
public EnemyWatcher(EnemyWatcherInfo info)
{
lastKnownActorIds = new HashSet<uint>();
discoveredPlayers = new HashSet<Player>();
lastKnownActorIds = [];
discoveredPlayers = [];
this.info = info;
rescanInterval = 0;
ticksBeforeNextNotification = 0;
@@ -67,8 +67,8 @@ namespace OpenRA.Mods.Common.Traits
rescanInterval = info.ScanInterval;
announcedAny = false;
visibleActorIds = new HashSet<uint>();
playedNotifications = new HashSet<string>();
visibleActorIds = [];
playedNotifications = [];
foreach (var actor in self.World.ActorsWithTrait<AnnounceOnSeen>())
{

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public class GrantConditionOnPrerequisiteManager : ITechTreeElement
{
readonly Actor self;
readonly Dictionary<string, List<(Actor Actor, GrantConditionOnPrerequisite GrantConditionOnPrerequisite)>> upgradables = new();
readonly Dictionary<string, List<(Actor Actor, GrantConditionOnPrerequisite GrantConditionOnPrerequisite)>> upgradables = [];
readonly TechTree techTree;
public GrantConditionOnPrerequisiteManager(ActorInitializer init)
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
var key = MakeKey(prerequisites);
if (!upgradables.TryGetValue(key, out var list))
{
upgradables.Add(key, list = new List<(Actor, GrantConditionOnPrerequisite)>());
upgradables.Add(key, list = []);
techTree.Add(key, prerequisites, 0, this);
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
[FieldLoader.Require]
[Desc("Prerequisites to grant when this checkbox is enabled.")]
public readonly HashSet<string> Prerequisites = new();
public readonly HashSet<string> Prerequisites = [];
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; }
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
public class LobbyPrerequisiteCheckbox : INotifyCreated, ITechTreePrerequisite
{
readonly LobbyPrerequisiteCheckboxInfo info;
HashSet<string> prerequisites = new();
HashSet<string> prerequisites = [];
public LobbyPrerequisiteCheckbox(LobbyPrerequisiteCheckboxInfo info)
{

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
public class MissionObjectives : INotifyWinStateChanged, ISync, IResolveOrder, IWorldLoaded
{
public readonly MissionObjectivesInfo Info;
readonly List<MissionObjective> objectives = new();
readonly List<MissionObjective> objectives = [];
readonly Player player;
public IReadOnlyList<MissionObjective> Objectives => objectives;

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
readonly ModularBotInfo info;
readonly World world;
readonly Queue<Order> orders = new();
readonly Queue<Order> orders = [];
Player player;

View File

@@ -10,7 +10,6 @@
#endregion
using System.Linq;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -121,13 +120,13 @@ namespace OpenRA.Mods.Common.Traits
if (os == "LineBuild")
{
// Build the parent actor first
var placed = w.CreateActor(actorInfo.Name, new TypeDictionary
{
var placed = w.CreateActor(actorInfo.Name,
[
new LocationInit(targetLocation),
new OwnerInit(order.Player),
new FactionInit(faction),
new PlaceBuildingInit()
});
]);
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, placed.CenterPosition);
@@ -152,15 +151,15 @@ namespace OpenRA.Mods.Common.Traits
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableSegments)))
self.World.Remove(a);
w.CreateActor(segmentType, new TypeDictionary
{
w.CreateActor(segmentType,
[
new LocationInit(t.Cell),
new OwnerInit(order.Player),
new FactionInit(faction),
new LineBuildDirectionInit(t.Cell.X == targetLocation.X ? LineBuildDirection.Y : LineBuildDirection.X),
new LineBuildParentInit(new[] { t.Actor, placed }),
new LineBuildParentInit([t.Actor, placed]),
new PlaceBuildingInit()
});
]);
}
}
else if (os == "PlacePlug")
@@ -192,13 +191,13 @@ namespace OpenRA.Mods.Common.Traits
|| !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, actorInfo, targetLocation))
return;
var building = w.CreateActor(actorInfo.Name, new TypeDictionary
{
var building = w.CreateActor(actorInfo.Name,
[
new LocationInit(targetLocation),
new OwnerInit(order.Player),
new FactionInit(faction),
new PlaceBuildingInit()
});
]);
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, building.CenterPosition);

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string DefaultCashDropdownDescription = "The amount of cash that players start with";
[Desc("Starting cash options that are available in the lobby options.")]
public readonly int[] SelectableCash = { 2500, 5000, 10000, 20000 };
public readonly int[] SelectableCash = [2500, 5000, 10000, 20000];
[Desc("Default starting cash option: should be one of the SelectableCash options.")]
public readonly int DefaultCash = 5000;
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string CashTickDownNotification = null;
[Desc("Monetary value of each resource type.", "Dictionary of [resource type]: [value per unit].")]
public readonly Dictionary<string, int> ResourceValues = new();
public readonly Dictionary<string, int> ResourceValues = [];
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(MapPreview map)
{

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Group = null;
[Desc("Only enable this queue for certain factions.")]
public readonly HashSet<string> Factions = new();
public readonly HashSet<string> Factions = [];
[Desc("Should the prerequisite remain enabled if the owner changes?")]
public readonly bool Sticky = true;
@@ -137,8 +137,8 @@ namespace OpenRA.Mods.Common.Traits
public readonly ProductionQueueInfo Info;
// A list of things we could possibly build
protected readonly Dictionary<ActorInfo, ProductionState> Producible = new();
protected readonly List<ProductionItem> Queue = new();
protected readonly Dictionary<ActorInfo, ProductionState> Producible = [];
protected readonly List<ProductionItem> Queue = [];
readonly IEnumerable<ActorInfo> allProducibles;
readonly IEnumerable<ActorInfo> buildableProducibles;
@@ -297,7 +297,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual IEnumerable<ActorInfo> AllItems()
{
if (productionTraits.Length > 0 && productionTraits.All(p => p.IsTraitDisabled))
return Enumerable.Empty<ActorInfo>();
return [];
if (developerMode.AllTech)
return Producible.Keys;
@@ -307,9 +307,9 @@ namespace OpenRA.Mods.Common.Traits
public virtual IEnumerable<ActorInfo> BuildableItems()
{
if (productionTraits.Length > 0 && productionTraits.All(p => p.IsTraitDisabled))
return Enumerable.Empty<ActorInfo>();
return [];
if (!Enabled)
return Enumerable.Empty<ActorInfo>();
return [];
if (!Info.PayUpFront && developerMode.AllTech)
return Producible.Keys;
if (Info.PayUpFront && developerMode.AllTech)

View File

@@ -9,7 +9,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
@@ -22,17 +21,17 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Prerequisite = null;
[Desc("Only grant this prerequisite when you have these prerequisites.")]
public readonly string[] RequiresPrerequisites = Array.Empty<string>();
public readonly string[] RequiresPrerequisites = [];
[Desc("Only grant this prerequisite for certain factions.")]
public readonly HashSet<string> Factions = new();
public readonly HashSet<string> Factions = [];
[Desc("Should it recheck everything when it is captured?")]
public readonly bool ResetOnOwnerChange = false;
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info)
{
return new string[] { Prerequisite ?? info.Name };
return [Prerequisite ?? info.Name];
}
public override object Create(ActorInitializer init) { return new ProvidesPrerequisite(init, this); }
@@ -50,9 +49,9 @@ namespace OpenRA.Mods.Common.Traits
: base(info)
{
if (string.IsNullOrEmpty(info.Prerequisite))
prerequisites = new[] { init.Self.Info.Name };
prerequisites = [init.Self.Info.Name];
else
prerequisites = new[] { info.Prerequisite };
prerequisites = [info.Prerequisite];
faction = init.GetValue<FactionInit, string>(init.Self.Owner.Faction.InternalName);
}

View File

@@ -9,7 +9,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
@@ -27,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Name;
[Desc("Prerequisites to grant when this tech level is active.")]
public readonly string[] Prerequisites = Array.Empty<string>();
public readonly string[] Prerequisites = [];
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; }

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public class TechTree
{
readonly List<Watcher> watchers = new();
readonly List<Watcher> watchers = [];
public TechTree(ActorInitializer init)
{