From 07815143f192c666cfda52be63df88712f2979c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 5 Dec 2021 13:26:40 +0100 Subject: [PATCH] Fix CA1825 warnings on empty array initialisation. --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/GameRules/WeaponInfo.cs | 2 +- OpenRA.Game/Manifest.cs | 10 +++++----- OpenRA.Game/Map/Map.cs | 6 +++--- OpenRA.Game/Map/MapPreview.cs | 4 ++-- OpenRA.Game/Map/PlayerReference.cs | 5 +++-- OpenRA.Game/ModData.cs | 2 +- OpenRA.Game/Network/GameSave.cs | 4 ++-- OpenRA.Game/Network/GameServer.cs | 2 +- OpenRA.Game/ObjectCreator.cs | 2 +- OpenRA.Game/SelectableExts.cs | 2 +- OpenRA.Game/Settings.cs | 8 ++++---- OpenRA.Game/Traits/Target.cs | 4 ++-- .../Traits/Render/WithHarvesterSpriteBody.cs | 3 ++- OpenRA.Mods.Common/Activities/Transform.cs | 3 ++- OpenRA.Mods.Common/AssetBrowser.cs | 4 +++- OpenRA.Mods.Common/Effects/RevealShroudEffect.cs | 3 ++- OpenRA.Mods.Common/ModContent.cs | 13 +++++++------ OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs | 7 ++++--- OpenRA.Mods.Common/Traits/AffectsShroud.cs | 3 ++- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 4 ++-- OpenRA.Mods.Common/Traits/Armament.cs | 4 ++-- OpenRA.Mods.Common/Traits/Buildable.cs | 3 ++- OpenRA.Mods.Common/Traits/Buildings/BridgeHut.cs | 3 ++- .../Traits/Buildings/BridgePlaceholder.cs | 3 ++- OpenRA.Mods.Common/Traits/Buildings/Building.cs | 4 ++-- .../Traits/Buildings/GroundLevelBridge.cs | 3 ++- .../Traits/Buildings/PrimaryBuilding.cs | 3 ++- OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs | 3 ++- OpenRA.Mods.Common/Traits/Cargo.cs | 2 +- .../Traits/Conditions/GrantConditionOnBotOwner.cs | 3 ++- .../Conditions/GrantConditionOnDamageState.cs | 5 +++-- .../Traits/Conditions/GrantConditionOnHealth.cs | 5 +++-- .../Conditions/GrantConditionOnPrerequisite.cs | 3 ++- .../Traits/Conditions/GrantConditionOnTerrain.cs | 3 ++- .../Traits/Conditions/GrantConditionOnTileSet.cs | 3 ++- OpenRA.Mods.Common/Traits/Crates/CrateAction.cs | 5 +++-- .../Traits/Crates/GiveUnitCrateAction.cs | 3 ++- OpenRA.Mods.Common/Traits/DamagedByTerrain.cs | 3 ++- OpenRA.Mods.Common/Traits/DeliversCash.cs | 3 ++- .../Traits/Multipliers/ProductionCostMultiplier.cs | 3 ++- .../Traits/Multipliers/ProductionTimeMultiplier.cs | 3 ++- .../Traits/Palettes/ColorPickerPalette.cs | 3 ++- .../Traits/Palettes/FixedColorPalette.cs | 3 ++- .../Traits/Palettes/IndexedPalette.cs | 5 +++-- .../Traits/Palettes/IndexedPlayerPalette.cs | 3 ++- .../Traits/Palettes/PaletteFromFile.cs | 3 ++- .../Traits/Palettes/PaletteFromPng.cs | 2 +- .../Traits/Palettes/PlayerColorPalette.cs | 3 ++- .../Traits/Player/ClassicParallelProductionQueue.cs | 2 +- .../Traits/Player/ClassicProductionQueue.cs | 3 ++- .../Traits/Player/ProvidesPrerequisite.cs | 3 ++- .../Traits/Player/ProvidesTechPrerequisite.cs | 5 +++-- OpenRA.Mods.Common/Traits/ProducibleWithLevel.cs | 3 ++- OpenRA.Mods.Common/Traits/Production.cs | 2 +- .../Traits/Render/WithAmmoPipsDecoration.cs | 3 ++- OpenRA.Mods.Common/Traits/Render/WithCrateBody.cs | 2 +- .../Traits/Render/WithDeadBridgeSpriteBody.cs | 3 ++- .../Traits/Render/WithDecorationBase.cs | 3 ++- .../Traits/Render/WithGateSpriteBody.cs | 3 ++- .../Traits/Render/WithInfantryBody.cs | 3 ++- OpenRA.Mods.Common/Traits/Sellable.cs | 2 +- OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs | 3 ++- .../Traits/Sound/SoundOnDamageTransition.cs | 5 +++-- .../Traits/SupportPowers/NukePower.cs | 3 ++- .../Traits/SupportPowers/ParatroopersPower.cs | 2 +- .../Traits/SupportPowers/SupportPower.cs | 3 ++- .../Traits/SupportPowers/SupportPowerManager.cs | 2 +- OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs | 3 ++- OpenRA.Mods.Common/Traits/Transforms.cs | 5 +++-- .../Traits/World/ActorSpawnManager.cs | 3 ++- .../Traits/World/ColorPickerManager.cs | 4 ++-- OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs | 3 ++- OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs | 2 +- OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs | 3 ++- OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs | 5 +++-- .../Widgets/Logic/Ingame/CommandBarLogic.cs | 2 +- .../Widgets/Logic/Installation/ModContentLogic.cs | 2 +- .../Logic/Installation/ModContentPromptLogic.cs | 2 +- .../Widgets/ProductionPaletteWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs | 2 +- .../D2kActorPreviewPlaceBuildingPreview.cs | 3 ++- OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs | 3 ++- OpenRA.Server/Program.cs | 2 +- OpenRA.Utility/Program.cs | 2 +- 85 files changed, 171 insertions(+), 117 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index ffd0115004..092cb9d748 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -322,7 +322,7 @@ namespace OpenRA // Special case handling of Game.Mod argument: if it matches a real filesystem path // then we use this to override the mod search path, and replace it with the mod id var modID = args.GetValue("Game.Mod", null); - var explicitModPaths = new string[0]; + var explicitModPaths = Array.Empty(); if (modID != null && (File.Exists(modID) || Directory.Exists(modID))) { explicitModPaths = new[] { modID }; diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index 5caed8beba..e322fc86a6 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -36,7 +36,7 @@ namespace OpenRA.GameRules public class WarheadArgs { public WeaponInfo Weapon; - public int[] DamageModifiers = { }; + public int[] DamageModifiers = Array.Empty(); public WPos? Source; public WRot ImpactOrientation; public WPos ImpactPosition; diff --git a/OpenRA.Game/Manifest.cs b/OpenRA.Game/Manifest.cs index 915aa32648..e05efc9e91 100644 --- a/OpenRA.Game/Manifest.cs +++ b/OpenRA.Game/Manifest.cs @@ -80,10 +80,10 @@ namespace OpenRA public readonly IReadOnlyDictionary MapFolders; public readonly MiniYaml LoadScreen; - public readonly string[] SoundFormats = { }; - public readonly string[] SpriteFormats = { }; - public readonly string[] PackageFormats = { }; - public readonly string[] VideoFormats = { }; + public readonly string[] SoundFormats = Array.Empty(); + public readonly string[] SpriteFormats = Array.Empty(); + public readonly string[] PackageFormats = Array.Empty(); + public readonly string[] VideoFormats = Array.Empty(); readonly string[] reservedModuleNames = { @@ -208,7 +208,7 @@ namespace OpenRA static string[] YamlList(Dictionary yaml, string key, bool parsePaths = false) { if (!yaml.ContainsKey(key)) - return new string[] { }; + return Array.Empty(); return yaml[key].ToDictionary().Keys.ToArray(); } diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 4120eb2894..6a61deec2e 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -270,7 +270,7 @@ namespace OpenRA // Take the SHA1 if (streams.Count == 0) - return CryptoUtil.SHA1Hash(new byte[0]); + return CryptoUtil.SHA1Hash(Array.Empty()); var merged = streams[0]; for (var i = 1; i < streams.Count; i++) @@ -471,7 +471,7 @@ namespace OpenRA foreach (var cell in AllCells) { var uv = cell.ToMPos(Grid.Type); - cellProjection[uv] = new PPos[0]; + cellProjection[uv] = Array.Empty(); inverseCellProjection[uv] = new List(1); } @@ -973,7 +973,7 @@ namespace OpenRA return (PPos)CellContaining(projectedPos).ToMPos(Grid.Type); } - static readonly PPos[] NoProjectedCells = { }; + static readonly PPos[] NoProjectedCells = Array.Empty(); public PPos[] ProjectedCellsCovering(MPos uv) { if (!initializedCellProjection) diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index 8781fc9495..9ffc9a6dab 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -54,7 +54,7 @@ namespace OpenRA public readonly string[] categories; public readonly int players; public readonly Rectangle bounds; - public readonly short[] spawnpoints = { }; + public readonly short[] spawnpoints = Array.Empty(); public readonly MapGridType map_grid_type; public readonly string minimap; public readonly bool downloading; @@ -160,7 +160,7 @@ namespace OpenRA } } - static readonly CPos[] NoSpawns = { }; + static readonly CPos[] NoSpawns = Array.Empty(); readonly MapCache cache; readonly ModData modData; diff --git a/OpenRA.Game/Map/PlayerReference.cs b/OpenRA.Game/Map/PlayerReference.cs index c4b496bb24..bb4630ccb9 100644 --- a/OpenRA.Game/Map/PlayerReference.cs +++ b/OpenRA.Game/Map/PlayerReference.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Primitives; namespace OpenRA @@ -53,8 +54,8 @@ namespace OpenRA public bool LockHandicap = false; public int Handicap = 0; - public string[] Allies = { }; - public string[] Enemies = { }; + public string[] Allies = Array.Empty(); + public string[] Enemies = Array.Empty(); public PlayerReference() { } public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); } diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 1c1e3ee290..46f920b7bc 100644 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -52,7 +52,7 @@ namespace OpenRA public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false) { - Languages = new string[0]; + Languages = Array.Empty(); // Take a local copy of the manifest Manifest = new Manifest(mod.Id, mod.Package); diff --git a/OpenRA.Game/Network/GameSave.cs b/OpenRA.Game/Network/GameSave.cs index b25d6f3e94..e59f903d22 100644 --- a/OpenRA.Game/Network/GameSave.cs +++ b/OpenRA.Game/Network/GameSave.cs @@ -86,7 +86,7 @@ namespace OpenRA.Network // Loaded from file and updated during gameplay public int LastOrdersFrame { get; private set; } public int LastSyncFrame { get; private set; } - byte[] lastSyncPacket = new byte[0]; + byte[] lastSyncPacket = Array.Empty(); // Loaded from file or set on game start public Session.Global GlobalSettings { get; private set; } @@ -95,7 +95,7 @@ namespace OpenRA.Network public Dictionary TraitData = new Dictionary(); // Set on game start - int[] clientsBySlotIndex = { }; + int[] clientsBySlotIndex = Array.Empty(); int firstBotSlotIndex = -1; public GameSave() diff --git a/OpenRA.Game/Network/GameServer.cs b/OpenRA.Game/Network/GameServer.cs index 169c9c6d8b..cf34d0736f 100644 --- a/OpenRA.Game/Network/GameServer.cs +++ b/OpenRA.Game/Network/GameServer.cs @@ -133,7 +133,7 @@ namespace OpenRA.Network public readonly GameClient[] Clients; /// The list of spawnpoints that are disabled for this game - public readonly int[] DisabledSpawnPoints = { }; + public readonly int[] DisabledSpawnPoints = Array.Empty(); public string ModLabel => $"{ModTitle} ({Version})"; diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index 9bf432738b..ab9b3c4f23 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -141,7 +141,7 @@ namespace OpenRA public object CreateBasic(Type type) { - return type.GetConstructor(new Type[0]).Invoke(new object[0]); + return type.GetConstructor(Array.Empty()).Invoke(Array.Empty()); } public object CreateUsingArgs(ConstructorInfo ctor, Dictionary args) diff --git a/OpenRA.Game/SelectableExts.cs b/OpenRA.Game/SelectableExts.cs index 99c13f5e77..4927305284 100644 --- a/OpenRA.Game/SelectableExts.cs +++ b/OpenRA.Game/SelectableExts.cs @@ -90,7 +90,7 @@ namespace OpenRA.Traits return info.SelectionPriority(modifiers) - (long)pixelDistance << 16; } - static readonly Actor[] NoActors = { }; + static readonly Actor[] NoActors = Array.Empty(); public static IEnumerable SubsetWithHighestSelectionPriority(this IEnumerable actors, Modifiers modifiers) { diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index c7bfec7814..9f501fda47 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -66,16 +66,16 @@ namespace OpenRA public string Map = null; [Desc("Takes a comma separated list of IP addresses that are not allowed to join.")] - public string[] Ban = { }; + public string[] Ban = Array.Empty(); [Desc("For dedicated servers only, allow anonymous clients to join.")] public bool RequireAuthentication = false; [Desc("For dedicated servers only, if non-empty, only allow authenticated players with these profile IDs to join.")] - public int[] ProfileIDWhitelist = { }; + public int[] ProfileIDWhitelist = Array.Empty(); [Desc("For dedicated servers only, if non-empty, always reject players with these user IDs from joining.")] - public int[] ProfileIDBlacklist = { }; + public int[] ProfileIDBlacklist = Array.Empty(); [Desc("For dedicated servers only, controls whether a game can be started with just one human player in the lobby.")] public bool EnableSingleplayer = false; @@ -227,7 +227,7 @@ namespace OpenRA public string Name = "Commander"; public Color Color = Color.FromArgb(200, 32, 32); public string LastServer = "localhost:1234"; - public Color[] CustomColors = { }; + public Color[] CustomColors = Array.Empty(); public string Language = "en"; } diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index b912f7057d..245002eeb2 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -18,7 +18,7 @@ namespace OpenRA.Traits public enum TargetType : byte { Invalid, Actor, Terrain, FrozenActor } public readonly struct Target { - public static readonly Target[] None = { }; + public static readonly Target[] None = Array.Empty(); public static readonly Target Invalid = default(Target); readonly TargetType type; @@ -175,7 +175,7 @@ namespace OpenRA.Traits } // Positions available to target for range checks - static readonly WPos[] NoPositions = { }; + static readonly WPos[] NoPositions = Array.Empty(); public IEnumerable Positions { get diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithHarvesterSpriteBody.cs b/OpenRA.Mods.Cnc/Traits/Render/WithHarvesterSpriteBody.cs index cf58b75e22..8b9a586215 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithHarvesterSpriteBody.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithHarvesterSpriteBody.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits.Render; using OpenRA.Traits; @@ -18,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render public class WithHarvesterSpriteBodyInfo : WithFacingSpriteBodyInfo, Requires { [Desc("Images switched between depending on fullness of harvester. Overrides RenderSprites.Image.")] - public readonly string[] ImageByFullness = { }; + public readonly string[] ImageByFullness = Array.Empty(); public override object Create(ActorInitializer init) { return new WithHarvesterSpriteBody(init, this); } } diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs index 32bf0571c0..5702b858ee 100644 --- a/OpenRA.Mods.Common/Activities/Transform.cs +++ b/OpenRA.Mods.Common/Activities/Transform.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Activities; using OpenRA.Mods.Common.Traits; @@ -23,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities public readonly string ToActor; public CVec Offset = CVec.Zero; public WAngle Facing = new WAngle(384); - public string[] Sounds = { }; + public string[] Sounds = Array.Empty(); public string Notification = null; public int ForceHealthPercentage = 0; public bool SkipMakeAnims = false; diff --git a/OpenRA.Mods.Common/AssetBrowser.cs b/OpenRA.Mods.Common/AssetBrowser.cs index 6cd007a64b..38fa92f091 100644 --- a/OpenRA.Mods.Common/AssetBrowser.cs +++ b/OpenRA.Mods.Common/AssetBrowser.cs @@ -9,11 +9,13 @@ */ #endregion +using System; + namespace OpenRA { public class AssetBrowser : IGlobalModData { [FieldLoader.Require] - public readonly string[] SupportedExtensions = new string[0]; + public readonly string[] SupportedExtensions = Array.Empty(); } } diff --git a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs index 87b386474a..75ee6d4b25 100644 --- a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs +++ b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Effects; @@ -19,7 +20,7 @@ namespace OpenRA.Mods.Common.Effects { public class RevealShroudEffect : IEffect { - static readonly PPos[] NoCells = { }; + static readonly PPos[] NoCells = Array.Empty(); readonly WPos pos; readonly Player player; diff --git a/OpenRA.Mods.Common/ModContent.cs b/OpenRA.Mods.Common/ModContent.cs index f1e04fa7a0..70793a0c2b 100644 --- a/OpenRA.Mods.Common/ModContent.cs +++ b/OpenRA.Mods.Common/ModContent.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -21,8 +22,8 @@ namespace OpenRA public class ModPackage { public readonly string Title; - public readonly string[] TestFiles = { }; - public readonly string[] Sources = { }; + public readonly string[] TestFiles = Array.Empty(); + public readonly string[] Sources = Array.Empty(); public readonly bool Required; public readonly string Download; @@ -106,21 +107,21 @@ namespace OpenRA } [FieldLoader.LoadUsing(nameof(LoadDownloads))] - public readonly string[] Downloads = { }; + public readonly string[] Downloads = Array.Empty(); static object LoadDownloads(MiniYaml yaml) { var downloadNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Downloads"); - return downloadNode != null ? downloadNode.Value.Nodes.Select(n => n.Key).ToArray() : new string[0]; + return downloadNode != null ? downloadNode.Value.Nodes.Select(n => n.Key).ToArray() : Array.Empty(); } [FieldLoader.LoadUsing(nameof(LoadSources))] - public readonly string[] Sources = { }; + public readonly string[] Sources = Array.Empty(); static object LoadSources(MiniYaml yaml) { var sourceNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Sources"); - return sourceNode != null ? sourceNode.Value.Nodes.Select(n => n.Key).ToArray() : new string[0]; + return sourceNode != null ? sourceNode.Value.Nodes.Select(n => n.Key).ToArray() : Array.Empty(); } } } diff --git a/OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs b/OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs index 7bec222da4..f46fc3927a 100644 --- a/OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs +++ b/OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Traits; @@ -24,16 +25,16 @@ namespace OpenRA.Mods.Common.Traits public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally; [Desc("Play a randomly selected sound from this list when accepting cash.")] - public readonly string[] Sounds = { }; + public readonly string[] Sounds = Array.Empty(); - public override object Create(ActorInitializer init) { return new AcceptsDeliveredCash(init.Self, this); } + public override object Create(ActorInitializer init) { return new AcceptsDeliveredCash(this); } } public class AcceptsDeliveredCash : INotifyCashTransfer { readonly AcceptsDeliveredCashInfo info; - public AcceptsDeliveredCash(Actor self, AcceptsDeliveredCashInfo info) + public AcceptsDeliveredCash(AcceptsDeliveredCashInfo info) { this.info = info; } diff --git a/OpenRA.Mods.Common/Traits/AffectsShroud.cs b/OpenRA.Mods.Common/Traits/AffectsShroud.cs index abe8b70edb..e237cc13be 100644 --- a/OpenRA.Mods.Common/Traits/AffectsShroud.cs +++ b/OpenRA.Mods.Common/Traits/AffectsShroud.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Traits; @@ -35,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public abstract class AffectsShroud : ConditionalTrait, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyMoving, INotifyCenterPositionChanged, ITick { - static readonly PPos[] NoCells = { }; + static readonly PPos[] NoCells = Array.Empty(); readonly HashSet footprint; diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 9ed0985277..b58017f592 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -139,10 +139,10 @@ namespace OpenRA.Mods.Common.Traits public readonly WDist AltitudeVelocity = new WDist(43); [Desc("Sounds to play when the actor is taking off.")] - public readonly string[] TakeoffSounds = { }; + public readonly string[] TakeoffSounds = Array.Empty(); [Desc("Sounds to play when the actor is landing.")] - public readonly string[] LandingSounds = { }; + public readonly string[] LandingSounds = Array.Empty(); [Desc("The distance of the resupply base that the aircraft will wait for its turn.")] public readonly WDist WaitDistanceFromResupplyBase = new WDist(3072); diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index f8aab4d759..a4844b22e2 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -41,10 +41,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("Muzzle position relative to turret or body, (forward, right, up) triples.", "If weapon Burst = 1, it cycles through all listed offsets, otherwise the offset corresponding to current burst is used.")] - public readonly WVec[] LocalOffset = { }; + public readonly WVec[] LocalOffset = Array.Empty(); [Desc("Muzzle yaw relative to turret or body.")] - public readonly WAngle[] LocalYaw = { }; + public readonly WAngle[] LocalYaw = Array.Empty(); [Desc("Move the turret backwards when firing.")] public readonly WDist Recoil = WDist.Zero; diff --git a/OpenRA.Mods.Common/Traits/Buildable.cs b/OpenRA.Mods.Common/Traits/Buildable.cs index e100948cb2..da783f6866 100644 --- a/OpenRA.Mods.Common/Traits/Buildable.cs +++ b/OpenRA.Mods.Common/Traits/Buildable.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Traits; @@ -20,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits "This can be prefixed with ! to invert the prerequisite (disabling production if the prerequisite is available)", "and/or ~ to hide the actor from the production palette if the prerequisite is not available.", "Prerequisites are granted by actors with the ProvidesPrerequisite trait.")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); [Desc("Production queue(s) that can produce this.")] public readonly HashSet Queue = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/Buildings/BridgeHut.cs b/OpenRA.Mods.Common/Traits/Buildings/BridgeHut.cs index f1071c8bc3..d478d7bcde 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BridgeHut.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BridgeHut.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Effects; @@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string[] Types = { "GroundLevelBridge" }; [Desc("Offsets to look for adjacent bridges to act on")] - public readonly CVec[] NeighbourOffsets = { }; + public readonly CVec[] NeighbourOffsets = Array.Empty(); [Desc("Delay between each segment repair step")] public readonly int RepairPropagationDelay = 20; diff --git a/OpenRA.Mods.Common/Traits/Buildings/BridgePlaceholder.cs b/OpenRA.Mods.Common/Traits/Buildings/BridgePlaceholder.cs index 6ab21c45fb..17859aba5c 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BridgePlaceholder.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BridgePlaceholder.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Primitives; using OpenRA.Traits; @@ -25,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Actor type to replace with on repair.")] public readonly string ReplaceWithActor = null; - public readonly CVec[] NeighbourOffsets = { }; + public readonly CVec[] NeighbourOffsets = Array.Empty(); public override object Create(ActorInitializer init) { return new BridgePlaceholder(init.Self, this); } } diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 2e8ae248c3..5cf89569c8 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -56,9 +56,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Clear smudges from underneath the building footprint on transform.")] public readonly bool RemoveSmudgesOnTransform = true; - public readonly string[] BuildSounds = { }; + public readonly string[] BuildSounds = Array.Empty(); - public readonly string[] UndeploySounds = { }; + public readonly string[] UndeploySounds = Array.Empty(); public override object Create(ActorInitializer init) { return new Building(init, this); } diff --git a/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs b/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs index 1ec06dd730..f13e54b308 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.GameRules; using OpenRA.Primitives; @@ -23,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Type = "GroundLevelBridge"; - public readonly CVec[] NeighbourOffsets = { }; + public readonly CVec[] NeighbourOffsets = Array.Empty(); [WeaponReference] [Desc("The name of the weapon to use when demolishing the bridge")] diff --git a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs index cc16cb8605..5a254b3b56 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Orders; @@ -38,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("List of production queues for which the primary flag should be set.", "If empty, the list given in the `Produces` property of the `" + nameof(Production) + "` trait will be used.")] - public readonly string[] ProductionQueues = { }; + public readonly string[] ProductionQueues = Array.Empty(); [CursorReference] [Desc("Cursor to display when setting the primary building.")] diff --git a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs index 37a0abf502..c9c2fb61a6 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Effects; @@ -42,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits public readonly bool IsPlayerPalette = true; [Desc("A list of 0 or more offsets defining the initial rally point path.")] - public readonly CVec[] Path = { }; + public readonly CVec[] Path = Array.Empty(); [NotificationReference("Speech")] [Desc("The speech notification to play when setting a new rallypoint.")] diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index ee5abbfade..f23422c8cf 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits public readonly HashSet Types = new HashSet(); [Desc("A list of actor types that are initially spawned into this actor.")] - public readonly string[] InitialUnits = { }; + public readonly string[] InitialUnits = Array.Empty(); [Desc("When this actor is sold should all of its passengers be unloaded?")] public readonly bool EjectOnSell = true; diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs index 2b85f2ff91..a8ee0aa9ff 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Traits; @@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Bot types that trigger the condition.")] - public readonly string[] Bots = { }; + public readonly string[] Bots = Array.Empty(); public override object Create(ActorInitializer init) { return new GrantConditionOnBotOwner(init, this); } } diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs index 1e9ac08c3f..b20693196c 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -22,10 +23,10 @@ namespace OpenRA.Mods.Common.Traits public readonly string Condition = null; [Desc("Play a random sound from this list when enabled.")] - public readonly string[] EnabledSounds = { }; + public readonly string[] EnabledSounds = Array.Empty(); [Desc("Play a random sound from this list when disabled.")] - public readonly string[] DisabledSounds = { }; + public readonly string[] DisabledSounds = Array.Empty(); [Desc("Levels of damage at which to grant the condition.")] public readonly DamageState ValidDamageStates = DamageState.Heavy | DamageState.Critical; diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnHealth.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnHealth.cs index 1a70d48b2f..b1a9e41ce4 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnHealth.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnHealth.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -22,10 +23,10 @@ namespace OpenRA.Mods.Common.Traits public readonly string Condition = null; [Desc("Play a random sound from this list when enabled.")] - public readonly string[] EnabledSounds = { }; + public readonly string[] EnabledSounds = Array.Empty(); [Desc("Play a random sound from this list when disabled.")] - public readonly string[] DisabledSounds = { }; + public readonly string[] DisabledSounds = Array.Empty(); [Desc("Minimum level of health at which to grant the condition.")] public readonly int MinHP = 0; diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnPrerequisite.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnPrerequisite.cs index 69e740197a..75d9d55f02 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnPrerequisite.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Traits; @@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("List of required prerequisites.")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); public override object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(init.Self, this); } } diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs index 9c213d73ec..04417a9aa0 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Traits; @@ -23,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Terrain names to trigger the condition.")] - public readonly string[] TerrainTypes = { }; + public readonly string[] TerrainTypes = Array.Empty(); public override object Create(ActorInitializer init) { return new GrantConditionOnTerrain(init, this); } } diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTileSet.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTileSet.cs index 757eee4f32..e566a29d70 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTileSet.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTileSet.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Traits; @@ -23,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Tile set IDs to trigger the condition.")] - public readonly string[] TileSets = { }; + public readonly string[] TileSets = Array.Empty(); public override object Create(ActorInitializer init) { return new GrantConditionOnTileSet(this); } } diff --git a/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs index 850701e3dd..500c5e17f2 100644 --- a/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Mods.Common.Effects; using OpenRA.Traits; @@ -42,11 +43,11 @@ namespace OpenRA.Mods.Common.Traits public readonly int TimeDelay = 0; [Desc("Only allow this crate action when the collector has these prerequisites")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); [ActorReference] [Desc("Actor types that this crate action will not occur for.")] - public string[] ExcludedActorTypes = { }; + public string[] ExcludedActorTypes = Array.Empty(); public override object Create(ActorInitializer init) { return new CrateAction(init.Self, this); } } diff --git a/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs index 19a603989b..97ef8a3e52 100644 --- a/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; @@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits [ActorReference] [FieldLoader.Require] [Desc("The list of units to spawn.")] - public readonly string[] Units = { }; + public readonly string[] Units = Array.Empty(); [Desc("Factions that are allowed to trigger this action.")] public readonly HashSet ValidFactions = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs index 98128667e2..51cf7e58c9 100644 --- a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs +++ b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; @@ -30,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Terrain types where the actor will take damage.")] - public readonly string[] Terrain = { }; + public readonly string[] Terrain = Array.Empty(); public override object Create(ActorInitializer init) { return new DamagedByTerrain(this); } } diff --git a/OpenRA.Mods.Common/Traits/DeliversCash.cs b/OpenRA.Mods.Common/Traits/DeliversCash.cs index 1b73bab97a..f2ff33976a 100644 --- a/OpenRA.Mods.Common/Traits/DeliversCash.cs +++ b/OpenRA.Mods.Common/Traits/DeliversCash.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Orders; @@ -30,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Type = null; [Desc("Sound to play when delivering cash")] - public readonly string[] Sounds = { }; + public readonly string[] Sounds = Array.Empty(); [CursorReference] [Desc("Cursor to display when hovering over a valid actor to deliver cash to.")] diff --git a/OpenRA.Mods.Common/Traits/Multipliers/ProductionCostMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/ProductionCostMultiplier.cs index f29557e9cf..acddc5bfd8 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/ProductionCostMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/ProductionCostMultiplier.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Traits; @@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int Multiplier = 100; [Desc("Only apply this cost change if owner has these prerequisites.")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); [Desc("Queues that this cost will apply.")] public readonly HashSet Queue = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/Multipliers/ProductionTimeMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/ProductionTimeMultiplier.cs index 08a91eb29a..0ab3955782 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/ProductionTimeMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/ProductionTimeMultiplier.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Traits; @@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int Multiplier = 100; [Desc("Only apply this time change if owner has these prerequisites.")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); [Desc("Queues that this time will apply.")] public readonly HashSet Queue = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/Palettes/ColorPickerPalette.cs b/OpenRA.Mods.Common/Traits/Palettes/ColorPickerPalette.cs index 4b8dbcf6bb..42a5512116 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/ColorPickerPalette.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/ColorPickerPalette.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Primitives; @@ -32,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Remap these indices to player colors.")] - public readonly int[] RemapIndex = { }; + public readonly int[] RemapIndex = Array.Empty(); [Desc("Allow palette modifiers to change the palette.")] public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Palettes/FixedColorPalette.cs b/OpenRA.Mods.Common/Traits/Palettes/FixedColorPalette.cs index 8d2b3469c9..72d4258f66 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/FixedColorPalette.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/FixedColorPalette.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Graphics; using OpenRA.Primitives; using OpenRA.Traits; @@ -28,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Name = "resources"; [Desc("Remap these indices to pre-defined colors.")] - public readonly int[] RemapIndex = { }; + public readonly int[] RemapIndex = Array.Empty(); [Desc("The fixed color to remap.")] public readonly Color Color; diff --git a/OpenRA.Mods.Common/Traits/Palettes/IndexedPalette.cs b/OpenRA.Mods.Common/Traits/Palettes/IndexedPalette.cs index 2a7f103d86..88100cc0f5 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/IndexedPalette.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/IndexedPalette.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; using OpenRA.Graphics; @@ -32,11 +33,11 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Indices from BasePalette to be swapped with ReplaceIndex.")] - public readonly int[] Index = { }; + public readonly int[] Index = Array.Empty(); [FieldLoader.Require] [Desc("Indices from BasePalette to replace from Index.")] - public readonly int[] ReplaceIndex = { }; + public readonly int[] ReplaceIndex = Array.Empty(); [Desc("Allow palette modifiers to change the palette.")] public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Palettes/IndexedPlayerPalette.cs b/OpenRA.Mods.Common/Traits/Palettes/IndexedPlayerPalette.cs index 017947ea69..d843e41168 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/IndexedPlayerPalette.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/IndexedPlayerPalette.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Primitives; @@ -29,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string BaseName = "player"; [Desc("Remap these indices to player colors.")] - public readonly int[] RemapIndex = { }; + public readonly int[] RemapIndex = Array.Empty(); [Desc("Allow palette modifiers to change the palette.")] public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Palettes/PaletteFromFile.cs b/OpenRA.Mods.Common/Traits/Palettes/PaletteFromFile.cs index abd141ec92..2c17249e45 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/PaletteFromFile.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/PaletteFromFile.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.FileSystem; using OpenRA.Graphics; @@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int[] TransparentIndex = { 0 }; [Desc("Map listed indices to shadow. Ignores previous color.")] - public readonly int[] ShadowIndex = { }; + public readonly int[] ShadowIndex = Array.Empty(); public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Palettes/PaletteFromPng.cs b/OpenRA.Mods.Common/Traits/Palettes/PaletteFromPng.cs index f3e139fc33..3ed42fb8a8 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/PaletteFromPng.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/PaletteFromPng.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Filename = null; [Desc("Map listed indices to shadow. Ignores previous color.")] - public readonly int[] ShadowIndex = { }; + public readonly int[] ShadowIndex = Array.Empty(); public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Palettes/PlayerColorPalette.cs b/OpenRA.Mods.Common/Traits/Palettes/PlayerColorPalette.cs index 83166fee6e..8640b440ad 100644 --- a/OpenRA.Mods.Common/Traits/Palettes/PlayerColorPalette.cs +++ b/OpenRA.Mods.Common/Traits/Palettes/PlayerColorPalette.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Graphics; using OpenRA.Primitives; using OpenRA.Traits; @@ -28,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string BaseName = "player"; [Desc("Remap these indices to player colors.")] - public readonly int[] RemapIndex = { }; + public readonly int[] RemapIndex = Array.Empty(); [Desc("Allow palette modifiers to change the palette.")] public readonly bool AllowModifiers = true; diff --git a/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs index ba2eb85f3b..a89deadde8 100644 --- a/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ClassicParallelProductionQueue.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits public class ClassicParallelProductionQueue : ProductionQueue { - static readonly ActorInfo[] NoItems = { }; + static readonly ActorInfo[] NoItems = Array.Empty(); readonly Actor self; readonly ClassicParallelProductionQueueInfo info; diff --git a/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs index 0e68e8dafb..3c21fbcede 100644 --- a/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ClassicProductionQueue.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; @@ -35,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public class ClassicProductionQueue : ProductionQueue { - static readonly ActorInfo[] NoItems = { }; + static readonly ActorInfo[] NoItems = Array.Empty(); readonly Actor self; readonly ClassicProductionQueueInfo info; diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs index 0d82521155..da8260fd41 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Traits; @@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Prerequisite = null; [Desc("Only grant this prerequisite when you have these prerequisites.")] - public readonly string[] RequiresPrerequisites = { }; + public readonly string[] RequiresPrerequisites = Array.Empty(); [Desc("Only grant this prerequisite for certain factions.")] public readonly HashSet Factions = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs index 422553dffe..2d51fa78e3 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Traits; @@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Name; [Desc("Prerequisites to grant when this tech level is active.")] - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); IEnumerable ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; } @@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits readonly ProvidesTechPrerequisiteInfo info; bool enabled; - static readonly string[] NoPrerequisites = new string[0]; + static readonly string[] NoPrerequisites = Array.Empty(); public string Name => info.Name; diff --git a/OpenRA.Mods.Common/Traits/ProducibleWithLevel.cs b/OpenRA.Mods.Common/Traits/ProducibleWithLevel.cs index 429498a03c..587c95a15d 100644 --- a/OpenRA.Mods.Common/Traits/ProducibleWithLevel.cs +++ b/OpenRA.Mods.Common/Traits/ProducibleWithLevel.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -18,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits "trait, the production queue icon renders with an overlay defined in that trait.")] public class ProducibleWithLevelInfo : TraitInfo, Requires { - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); [Desc("Number of levels to give to the actor on creation.")] public readonly int InitialLevels = 1; diff --git a/OpenRA.Mods.Common/Traits/Production.cs b/OpenRA.Mods.Common/Traits/Production.cs index fcc872294c..66189b5b76 100644 --- a/OpenRA.Mods.Common/Traits/Production.cs +++ b/OpenRA.Mods.Common/Traits/Production.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits { [FieldLoader.Require] [Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")] - public readonly string[] Produces = { }; + public readonly string[] Produces = Array.Empty(); public override object Create(ActorInitializer init) { return new Production(init, this); } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithAmmoPipsDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithAmmoPipsDecoration.cs index 65fcd4e05d..610a50848e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithAmmoPipsDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithAmmoPipsDecoration.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -39,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits.Render public readonly string Palette = "chrome"; [Desc("Name(s) of AmmoPool(s) that use this decoration. Leave empty to include all pools.")] - public readonly string[] AmmoPools = { }; + public readonly string[] AmmoPools = Array.Empty(); public override object Create(ActorInitializer init) { return new WithAmmoPipsDecoration(init.Self, this); } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithCrateBody.cs b/OpenRA.Mods.Common/Traits/Render/WithCrateBody.cs index c2144f5412..3b92aafa9e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithCrateBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithCrateBody.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits.Render class WithCrateBodyInfo : TraitInfo, Requires, IRenderActorPreviewSpritesInfo { [Desc("Easteregg sequences to use in December.")] - public readonly string[] XmasImages = { }; + public readonly string[] XmasImages = Array.Empty(); [Desc("Terrain types on which to display WaterSequence.")] public readonly HashSet WaterTerrainTypes = new HashSet { "Water" }; diff --git a/OpenRA.Mods.Common/Traits/Render/WithDeadBridgeSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithDeadBridgeSpriteBody.cs index 819ac87513..72638a99ff 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDeadBridgeSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDeadBridgeSpriteBody.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -20,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits.Render class WithDeadBridgeSpriteBodyInfo : WithSpriteBodyInfo { [ActorReference] - public readonly string[] RampActors = { }; + public readonly string[] RampActors = Array.Empty(); [Desc("Offset to search for the 'A' neighbour")] public readonly CVec AOffset = CVec.Zero; diff --git a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs index 4bb9e54a5c..fb106ed97b 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -41,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render public readonly int BlinkInterval = 5; [Desc("A pattern of ticks (BlinkInterval long) where the decoration is visible or hidden.")] - public readonly BlinkState[] BlinkPattern = { }; + public readonly BlinkState[] BlinkPattern = Array.Empty(); [Desc("Override blink conditions to use when defined conditions are enabled.", "A dictionary of [condition string]: [pattern].")] diff --git a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs index fa59a431f2..3bcaad08ec 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -20,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits.Render class WithGateSpriteBodyInfo : WithSpriteBodyInfo, IWallConnectorInfo, Requires { [Desc("Cells (outside the gate footprint) that contain wall cells that can connect to the gate")] - public readonly CVec[] WallConnections = { }; + public readonly CVec[] WallConnections = Array.Empty(); [Desc("Wall type for connections")] public readonly string Type = "wall"; diff --git a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs index dd6973fedd..c6cab83609 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -35,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits.Render public readonly Dictionary AttackSequences = new Dictionary(); [SequenceReference] - public readonly string[] IdleSequences = { }; + public readonly string[] IdleSequences = Array.Empty(); [SequenceReference] public readonly string[] StandSequences = { "stand" }; diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index e9b1b35b13..5bac22510c 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int RefundPercent = 50; [Desc("List of audio clips to play when the actor is being sold.")] - public readonly string[] SellSounds = { }; + public readonly string[] SellSounds = Array.Empty(); [NotificationReference("Speech")] [Desc("The audio notification type to play.")] diff --git a/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs b/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs index 46660ed65c..8d5e410776 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.Traits; @@ -18,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits.Sound public class AttackSoundsInfo : ConditionalTraitInfo { [Desc("Play a randomly selected sound from this list when preparing for an attack or attacking.")] - public readonly string[] Sounds = { }; + public readonly string[] Sounds = Array.Empty(); [Desc("Delay in ticks before sound starts, either relative to attack preparation or attack.")] public readonly int Delay = 0; diff --git a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs index 06919c419a..8e9c159f05 100644 --- a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs +++ b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Primitives; using OpenRA.Traits; @@ -17,10 +18,10 @@ namespace OpenRA.Mods.Common.Traits.Sound public class SoundOnDamageTransitionInfo : TraitInfo { [Desc("Play a random sound from this list when damaged.")] - public readonly string[] DamagedSounds = { }; + public readonly string[] DamagedSounds = Array.Empty(); [Desc("Play a random sound from this list when destroyed.")] - public readonly string[] DestroyedSounds = { }; + public readonly string[] DestroyedSounds = Array.Empty(); [Desc("DamageType(s) that trigger the sounds. Leave empty to always trigger a sound.")] public readonly BitSet DamageTypes = default(BitSet); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index 9e4da97ead..d2bdecaa6b 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.GameRules; @@ -61,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits [SequenceReference(nameof(TrailImage), allowNullImage: true)] [Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")] - public readonly string[] TrailSequences = { }; + public readonly string[] TrailSequences = Array.Empty(); [Desc("Interval in ticks between each spawned Trail animation.")] public readonly int TrailInterval = 1; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs index 156b8a9bb6..709ff028f5 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits [ActorReference(typeof(PassengerInfo))] [Desc("Troops to be delivered. They will be distributed between the planes if SquadSize > 1.")] - public readonly string[] DropItems = { }; + public readonly string[] DropItems = Array.Empty(); [Desc("Risks stuck units when they don't have the Paratrooper trait.")] public readonly bool AllowImpassableCells = false; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index 89d649ab1b..392df47ea5 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Traits; @@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("If set to true, the support power will be fully charged when it becomes available. " + "Normal rules apply for subsequent charges.")] public readonly bool StartFullyCharged = false; - public readonly string[] Prerequisites = { }; + public readonly string[] Prerequisites = Array.Empty(); public readonly string DetectedSound = null; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index 0fcbcaffb8..d082c81513 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Traits Powers[order.OrderString].Activate(order); } - static readonly SupportPowerInstance[] NoInstances = { }; + static readonly SupportPowerInstance[] NoInstances = Array.Empty(); public IEnumerable GetPowersForActor(Actor a) { diff --git a/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs b/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs index bad6709753..2a64e2a565 100644 --- a/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs +++ b/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; @@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits [WeaponReference] [FieldLoader.Require] [Desc("The weapons used for shrapnel.")] - public readonly string[] Weapons = { }; + public readonly string[] Weapons = Array.Empty(); [Desc("The amount of pieces of shrapnel to expel. Two values indicate a range.")] public readonly int[] Pieces = { 3, 10 }; diff --git a/OpenRA.Mods.Common/Traits/Transforms.cs b/OpenRA.Mods.Common/Traits/Transforms.cs index 7aafb468bb..3f0fd1b672 100644 --- a/OpenRA.Mods.Common/Traits/Transforms.cs +++ b/OpenRA.Mods.Common/Traits/Transforms.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Activities; using OpenRA.Mods.Common.Activities; @@ -32,10 +33,10 @@ namespace OpenRA.Mods.Common.Traits public readonly WAngle Facing = new WAngle(384); [Desc("Sounds to play when transforming.")] - public readonly string[] TransformSounds = { }; + public readonly string[] TransformSounds = Array.Empty(); [Desc("Sounds to play when the transformation is blocked.")] - public readonly string[] NoTransformSounds = { }; + public readonly string[] NoTransformSounds = Array.Empty(); [NotificationReference("Speech")] [Desc("Notification to play when transforming.")] diff --git a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs index b81647f098..54a4b0f404 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; @@ -32,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [ActorReference] [Desc("Name of the actor that will be randomly picked to spawn.")] - public readonly string[] Actors = { }; + public readonly string[] Actors = Array.Empty(); public readonly string Owner = "Creeps"; diff --git a/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs b/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs index 308ad6f1df..988af4c670 100644 --- a/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs @@ -32,10 +32,10 @@ namespace OpenRA.Mods.Common.Traits public readonly float SimilarityThreshold = 0.314f; [Desc("List of hue components for the preset colors in the palette tab. Each entry must have a corresponding PresetSaturations definition.")] - public readonly float[] PresetHues = { }; + public readonly float[] PresetHues = Array.Empty(); [Desc("List of saturation components for the preset colors in the palette tab. Each entry must have a corresponding PresetHues definition.")] - public readonly float[] PresetSaturations = { }; + public readonly float[] PresetSaturations = Array.Empty(); [ActorReference] [Desc("Actor type to show in the color picker. This can be overridden for specific factions with FactionPreviewActors.")] diff --git a/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs b/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs index b52dca4f69..f77cc8d372 100644 --- a/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Traits; @@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("A group of units ready to defend or scout.")] [ActorReference] - public readonly string[] SupportActors = { }; + public readonly string[] SupportActors = Array.Empty(); [Desc("Inner radius for spawning support actors")] public readonly int InnerSupportRadius = 2; diff --git a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs index 315cde1488..a470beedec 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [SequenceReference(nameof(Image))] [Desc("Randomly chosen image sequences.")] - public readonly string[] Sequences = { }; + public readonly string[] Sequences = Array.Empty(); [PaletteReference] [Desc("Palette used for rendering the resource sprites.")] diff --git a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs index e56627b2db..390fc99edc 100644 --- a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -42,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits [SequenceReference(nameof(SmokeImage))] [Desc("Smoke sprite sequences randomly chosen from")] - public readonly string[] SmokeSequences = { }; + public readonly string[] SmokeSequences = Array.Empty(); [PaletteReference] public readonly string SmokePalette = "effect"; diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 659971a17d..bc433f1bef 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.GameRules; using OpenRA.Mods.Common.Effects; @@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Warheads { [SequenceReference(nameof(Image), allowNullImage: true)] [Desc("List of explosion sequences that can be used.")] - public readonly string[] Explosions = new string[0]; + public readonly string[] Explosions = Array.Empty(); [Desc("Image containing explosion effect sequence.")] public readonly string Image = "explosion"; @@ -38,7 +39,7 @@ namespace OpenRA.Mods.Common.Warheads public readonly bool ForceDisplayAtGroundLevel = false; [Desc("List of sounds that can be played on impact.")] - public readonly string[] ImpactSounds = new string[0]; + public readonly string[] ImpactSounds = Array.Empty(); [Desc("Chance of impact sound to play.")] public readonly int ImpactSoundChance = 100; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 40692bddf9..67149c4f53 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Widgets readonly World world; int selectionHash; - Actor[] selectedActors = { }; + Actor[] selectedActors = Array.Empty(); bool attackMoveDisabled = true; bool forceMoveDisabled = true; bool forceAttackDisabled = true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs index ce84f008be..96dc59d9da 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic template = scrollPanel.Get("PACKAGE_TEMPLATE"); var headerTemplate = panel.Get("HEADER_TEMPLATE"); - var headerLines = !string.IsNullOrEmpty(content.HeaderMessage) ? content.HeaderMessage.Replace("\\n", "\n").Split('\n') : new string[0]; + var headerLines = !string.IsNullOrEmpty(content.HeaderMessage) ? content.HeaderMessage.Replace("\\n", "\n").Split('\n') : Array.Empty(); var headerHeight = 0; foreach (var l in headerLines) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs index 9939de251b..4cfac3421c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var panel = widget.Get("CONTENT_PROMPT_PANEL"); var headerTemplate = panel.Get("HEADER_TEMPLATE"); - var headerLines = !string.IsNullOrEmpty(content.InstallPromptMessage) ? content.InstallPromptMessage.Replace("\\n", "\n").Split('\n') : new string[0]; + var headerLines = !string.IsNullOrEmpty(content.InstallPromptMessage) ? content.InstallPromptMessage.Replace("\\n", "\n").Split('\n') : Array.Empty(); var headerHeight = 0; foreach (var l in headerLines) { diff --git a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs index f27cf7af6d..b3006dab9c 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs @@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Widgets count = FieldLoader.GetValue("HotkeyCount", countNode.Value.Value); if (count == 0) - return new string[0]; + return Array.Empty(); if (string.IsNullOrEmpty(prefix)) emitError($"{widgetNode.Location} must define HotkeyPrefix if HotkeyCount > 0."); diff --git a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs index ef32fff7f0..b4ce68c11c 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Widgets count = FieldLoader.GetValue("HotkeyCount", countNode.Value.Value); if (count == 0) - return new string[0]; + return Array.Empty(); if (string.IsNullOrEmpty(prefix)) emitError($"{widgetNode.Location} must define HotkeyPrefix if HotkeyCount > 0."); diff --git a/OpenRA.Mods.D2k/Traits/Buildings/D2kActorPreviewPlaceBuildingPreview.cs b/OpenRA.Mods.D2k/Traits/Buildings/D2kActorPreviewPlaceBuildingPreview.cs index 2cbdfecada..9b101a156b 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/D2kActorPreviewPlaceBuildingPreview.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/D2kActorPreviewPlaceBuildingPreview.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; @@ -27,7 +28,7 @@ namespace OpenRA.Mods.D2k.Traits public readonly HashSet UnsafeTerrainTypes = new HashSet { "Rock" }; [Desc("Only check for 'unsafe' footprint tiles when you have these prerequisites.")] - public readonly string[] RequiresPrerequisites = { }; + public readonly string[] RequiresPrerequisites = Array.Empty(); [Desc("Sprite image to use for the overlay.")] public readonly string Image = "overlay"; diff --git a/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs b/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs index 25f2d48648..da0079212c 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.IO; using System.Linq; using OpenRA.Mods.Common.Terrain; @@ -43,7 +44,7 @@ namespace OpenRA.Mods.D2k.Traits.Buildings public readonly ushort ConcreteTemplate = 88; [Desc("List of required prerequisites to place a terrain template.")] - public readonly string[] ConcretePrerequisites = { }; + public readonly string[] ConcretePrerequisites = Array.Empty(); public override object Create(ActorInitializer init) { return new D2kBuilding(init, this); } } diff --git a/OpenRA.Server/Program.cs b/OpenRA.Server/Program.cs index adaa858f98..6449c1a2c7 100644 --- a/OpenRA.Server/Program.cs +++ b/OpenRA.Server/Program.cs @@ -54,7 +54,7 @@ namespace OpenRA.Server // Special case handling of Game.Mod argument: if it matches a real filesystem path // then we use this to override the mod search path, and replace it with the mod id var modID = arguments.GetValue("Game.Mod", null); - var explicitModPaths = new string[0]; + var explicitModPaths = Array.Empty(); if (modID != null && (File.Exists(modID) || Directory.Exists(modID))) { explicitModPaths = new[] { modID }; diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 74654e984d..69f4c9b215 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -73,7 +73,7 @@ namespace OpenRA } var modId = args[0]; - var explicitModPaths = new string[0]; + var explicitModPaths = Array.Empty(); if (File.Exists(modId) || Directory.Exists(modId)) { explicitModPaths = new[] { modId };