diff --git a/OpenRA.Game/GameRules/SoundInfo.cs b/OpenRA.Game/GameRules/SoundInfo.cs index a4f71abff8..c8ce35bba4 100644 --- a/OpenRA.Game/GameRules/SoundInfo.cs +++ b/OpenRA.Game/GameRules/SoundInfo.cs @@ -22,8 +22,8 @@ namespace OpenRA.GameRules public readonly Dictionary Notifications = new Dictionary(); public readonly string DefaultVariant = ".aud"; public readonly string DefaultPrefix = ""; - public readonly string[] DisableVariants = { }; - public readonly string[] DisablePrefixes = { }; + public readonly HashSet DisableVariants = new HashSet(); + public readonly HashSet DisablePrefixes = new HashSet(); public readonly Lazy> VoicePools; public readonly Lazy> NotificationsPools; diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index d60075d369..35dbe6391b 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -49,8 +49,8 @@ namespace OpenRA static readonly TerrainTypeInfo Default = new TerrainTypeInfo(); public readonly string Type; - public readonly string[] TargetTypes = { }; - public readonly string[] AcceptsSmudgeType = { }; + public readonly HashSet TargetTypes = new HashSet(); + public readonly HashSet AcceptsSmudgeType = new HashSet(); public readonly bool IsWater = false; // TODO: Remove this public readonly Color Color; public readonly string CustomCursor; diff --git a/OpenRA.Game/Traits/EditorTilesetFilter.cs b/OpenRA.Game/Traits/EditorTilesetFilter.cs index bf6317394a..7b836dcb15 100644 --- a/OpenRA.Game/Traits/EditorTilesetFilter.cs +++ b/OpenRA.Game/Traits/EditorTilesetFilter.cs @@ -8,12 +8,14 @@ */ #endregion +using System.Collections.Generic; + namespace OpenRA.Traits { public class EditorTilesetFilterInfo : TraitInfo { - public readonly string[] RequireTilesets = null; - public readonly string[] ExcludeTilesets = null; + public readonly HashSet RequireTilesets = null; + public readonly HashSet ExcludeTilesets = null; } public class EditorTilesetFilter { } diff --git a/OpenRA.Game/Traits/RejectsOrders.cs b/OpenRA.Game/Traits/RejectsOrders.cs index 117dece3ca..21d680792b 100644 --- a/OpenRA.Game/Traits/RejectsOrders.cs +++ b/OpenRA.Game/Traits/RejectsOrders.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; namespace OpenRA.Traits @@ -16,14 +17,14 @@ namespace OpenRA.Traits public class RejectsOrdersInfo : ITraitInfo { [Desc("Possible values include Attack, AttackMove, Guard, Move.")] - public readonly string[] Except = { }; + public readonly HashSet Except = new HashSet(); public object Create(ActorInitializer init) { return new RejectsOrders(this); } } public class RejectsOrders { - public string[] Except { get { return info.Except; } } + public HashSet Except { get { return info.Except; } } readonly RejectsOrdersInfo info; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 6c615eeb62..01677cfd03 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -268,7 +268,7 @@ namespace OpenRA.Traits { void OnCrush(Actor crusher); void WarnCrush(Actor crusher); - bool CrushableBy(string[] crushClasses, Player owner); + bool CrushableBy(HashSet crushClasses, Player owner); } public interface ITraitInfo { object Create(ActorInitializer init); } diff --git a/OpenRA.Game/Traits/World/Faction.cs b/OpenRA.Game/Traits/World/Faction.cs index efa7935925..df7faf8b60 100644 --- a/OpenRA.Game/Traits/World/Faction.cs +++ b/OpenRA.Game/Traits/World/Faction.cs @@ -8,6 +8,8 @@ */ #endregion +using System.Collections.Generic; + namespace OpenRA.Traits { [Desc("Attach this to the `World` actor.")] @@ -20,7 +22,7 @@ namespace OpenRA.Traits public readonly string InternalName = null; [Desc("Pick a random faction as the player's facton out of this list.")] - public readonly string[] RandomFactionMembers = { }; + public readonly HashSet RandomFactionMembers = new HashSet(); [Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")] public readonly string Side = null; diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index bd7004090d..850d5645dc 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -25,7 +25,7 @@ namespace OpenRA.Traits public readonly string Name = null; public readonly string TerrainType = "Ore"; - public readonly string[] AllowedTerrainTypes = { }; + public readonly HashSet AllowedTerrainTypes = new HashSet(); public readonly bool AllowUnderActors = false; public readonly bool AllowUnderBuildings = false; public readonly bool AllowOnRamps = false; diff --git a/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs index c046a622d5..9abac098e8 100644 --- a/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.GameRules; using OpenRA.Mods.Common.Traits; @@ -18,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Traits class PoisonedByTiberiumInfo : UpgradableTraitInfo { [WeaponReference] public readonly string Weapon = "Tiberium"; - public readonly string[] Resources = { "Tiberium", "BlueTiberium" }; + public readonly HashSet Resources = new HashSet { "Tiberium", "BlueTiberium" }; public override object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } } diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithCargo.cs b/OpenRA.Mods.Cnc/Traits/Render/WithCargo.cs index 13f31b2783..a71d1a642f 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithCargo.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithCargo.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Traits public readonly WVec[] LocalOffset = { WVec.Zero }; [Desc("Passenger CargoType to display.")] - public readonly string[] DisplayTypes = { }; + public readonly HashSet DisplayTypes = new HashSet(); public object Create(ActorInitializer init) { return new WithCargo(init.Self, this); } } diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 5f478d0845..09ed8ae0cd 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -32,10 +32,10 @@ namespace OpenRA.Mods.Common.AI public readonly int SquadSizeRandomBonus = 30; [Desc("Production queues AI uses for buildings.")] - public readonly string[] BuildingQueues = { "Building" }; + public readonly HashSet BuildingQueues = new HashSet { "Building" }; [Desc("Production queues AI uses for defenses.")] - public readonly string[] DefenseQueues = { "Defense" }; + public readonly HashSet DefenseQueues = new HashSet { "Defense" }; [Desc("Delay (in ticks) between giving out orders to units.")] public readonly int AssignRolesInterval = 20; @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.AI public readonly int CheckForWaterRadius = 8; [Desc("Production queues AI uses for producing units.")] - public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" }; + public readonly HashSet UnitQueues = new HashSet { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" }; [Desc("Should the AI repair its buildings if damaged?")] public readonly bool ShouldRepairBuildings = true; diff --git a/OpenRA.Mods.Common/InstallUtils.cs b/OpenRA.Mods.Common/InstallUtils.cs index c74daa0ed1..4520561375 100644 --- a/OpenRA.Mods.Common/InstallUtils.cs +++ b/OpenRA.Mods.Common/InstallUtils.cs @@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common public readonly string MenuWidget = null; public readonly string MusicMenuWidget = null; public readonly string BackgroundWidget = null; - public readonly string[] TestFiles = { }; - public readonly string[] DiskTestFiles = { }; + public readonly HashSet TestFiles = new HashSet(); + public readonly HashSet DiskTestFiles = new HashSet(); public readonly string PackageToExtractFromCD = null; public readonly bool OverwriteFiles = true; @@ -37,10 +37,10 @@ namespace OpenRA.Mods.Common public readonly int ShippedSoundtracks = 0; /// InstallShield .cab File Ids, used to extract Mod specific files. - public readonly int[] InstallShieldCABFileIds = { }; + public readonly HashSet InstallShieldCABFileIds = new HashSet(); /// InstallShield .cab File Ids, used to extract Mod specific archives and extract contents of ExtractFilesFromCD. - public readonly string[] InstallShieldCABFilePackageIds = { }; + public readonly HashSet InstallShieldCABFilePackageIds = new HashSet(); } public static class InstallUtils diff --git a/OpenRA.Mods.Common/Lint/LintExts.cs b/OpenRA.Mods.Common/Lint/LintExts.cs index e7dcb5d5d1..de8f168789 100644 --- a/OpenRA.Mods.Common/Lint/LintExts.cs +++ b/OpenRA.Mods.Common/Lint/LintExts.cs @@ -9,21 +9,24 @@ #endregion using System; +using System.Collections.Generic; using System.Reflection; namespace OpenRA.Mods.Common.Lint { public class LintExts { - public static string[] GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action emitError) + public static IEnumerable GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action emitError) { var type = fieldInfo.FieldType; if (type == typeof(string)) return new[] { (string)fieldInfo.GetValue(ruleInfo) }; if (type == typeof(string[])) return (string[])fieldInfo.GetValue(ruleInfo); + if (type == typeof(HashSet)) + return (HashSet)fieldInfo.GetValue(ruleInfo); - emitError("Bad type for reference on {0}.{1}. Supported types: string, string[]" + emitError("Bad type for reference on {0}.{1}. Supported types: string, string[], HashSet" .F(ruleInfo.GetType().Name, fieldInfo.Name)); return new string[] { }; diff --git a/OpenRA.Mods.Common/Scripting/LuaScript.cs b/OpenRA.Mods.Common/Scripting/LuaScript.cs index fc1c8c6198..56e23c39a0 100644 --- a/OpenRA.Mods.Common/Scripting/LuaScript.cs +++ b/OpenRA.Mods.Common/Scripting/LuaScript.cs @@ -9,6 +9,8 @@ #endregion using System; +using System.Collections.Generic; +using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Traits; using OpenRA.Scripting; @@ -19,7 +21,7 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Part of the new Lua API.")] public class LuaScriptInfo : ITraitInfo, Requires { - public readonly string[] Scripts = { }; + public readonly HashSet Scripts = new HashSet(); public object Create(ActorInitializer init) { return new LuaScript(this); } } @@ -36,7 +38,7 @@ namespace OpenRA.Mods.Common.Scripting public void WorldLoaded(World world, WorldRenderer worldRenderer) { - var scripts = info.Scripts ?? new string[0]; + var scripts = info.Scripts ?? Enumerable.Empty(); context = new ScriptContext(world, worldRenderer, scripts); context.WorldLoaded(); } diff --git a/OpenRA.Mods.Common/Scripting/ScriptUpgradesCache.cs b/OpenRA.Mods.Common/Scripting/ScriptUpgradesCache.cs index 2016665991..c3a2b6537b 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptUpgradesCache.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptUpgradesCache.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.Common.Scripting @@ -17,7 +18,7 @@ namespace OpenRA.Mods.Common.Scripting { [UpgradeGrantedReference] [Desc("Upgrades that can be granted from the scripts.")] - public readonly string[] Upgrades = { }; + public readonly HashSet Upgrades = new HashSet(); public object Create(ActorInitializer init) { return new ScriptUpgradesCache(this); } } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index bf9b8a076d..c9bfd67942 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -29,16 +29,16 @@ namespace OpenRA.Mods.Common.Traits public readonly int RepulsionSpeed = -1; [ActorReference] - public readonly string[] RepairBuildings = { "fix" }; + public readonly HashSet RepairBuildings = new HashSet { "fix" }; [ActorReference] - public readonly string[] RearmBuildings = { "hpad", "afld" }; + public readonly HashSet RearmBuildings = new HashSet { "hpad", "afld" }; public readonly int InitialFacing = 0; public readonly int ROT = 255; public readonly int Speed = 1; [Desc("Minimum altitude where this aircraft is considered airborne")] public readonly int MinAirborneAltitude = 1; - public readonly string[] LandableTerrainTypes = { }; + public readonly HashSet LandableTerrainTypes = new HashSet(); [Desc("Can the actor be ordered to move in to shroud?")] public readonly bool MoveIntoShroud = true; diff --git a/OpenRA.Mods.Common/Traits/Buildable.cs b/OpenRA.Mods.Common/Traits/Buildable.cs index 47499267f9..9e09b2b703 100644 --- a/OpenRA.Mods.Common/Traits/Buildable.cs +++ b/OpenRA.Mods.Common/Traits/Buildable.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string[] Prerequisites = { }; [Desc("Production queue(s) that can produce this.")] - public readonly string[] Queue = { }; + public readonly HashSet Queue = new HashSet(); [Desc("Override the production structure type (from the Production Produces list) that this unit should be built at.")] public readonly string BuildAtProductionType = null; diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 2275addc09..cefcc8686c 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit { [Desc("Where you are allowed to place the building (Water, Clear, ...)")] - public readonly string[] TerrainTypes = { }; + public readonly HashSet TerrainTypes = new HashSet(); [Desc("The range to the next building it can be constructed. Set it higher for walls.")] public readonly int Adjacent = 2; [Desc("x means space it blocks, _ is a part that is passable by actors.")] diff --git a/OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs b/OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs index 0286c7c053..7db358576a 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -19,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int Range = 5; [Desc("LineBuildNode 'Types' to attach to.")] - public readonly string[] NodeTypes = { "wall" }; + public readonly HashSet NodeTypes = new HashSet { "wall" }; } public class LineBuild { } diff --git a/OpenRA.Mods.Common/Traits/Captures.cs b/OpenRA.Mods.Common/Traits/Captures.cs index aebdf65cff..ab14a52c27 100644 --- a/OpenRA.Mods.Common/Traits/Captures.cs +++ b/OpenRA.Mods.Common/Traits/Captures.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits public class CapturesInfo : ITraitInfo { [Desc("Types of actors that it can capture, as long as the type also exists in the Capturable Type: trait.")] - public readonly string[] CaptureTypes = { "building" }; + public readonly HashSet CaptureTypes = new HashSet { "building" }; [Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")] public readonly bool Sabotage = true; [Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")] diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 2dab3f15ad..af02efe391 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int PipCount = 0; [Desc("`Passenger.CargoType`s that can be loaded into this actor.")] - public readonly string[] Types = { }; + public readonly HashSet Types = new HashSet(); [Desc("A list of actor types that are initially spawned into this actor.")] public readonly string[] InitialUnits = { }; @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits public readonly bool EjectOnSell = true; [Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")] - public readonly string[] UnloadTerrainTypes = { }; + public readonly HashSet UnloadTerrainTypes = new HashSet(); [Desc("Voice to play when ordered to unload the passengers.")] [VoiceReference] public readonly string UnloadVoice = "Action"; @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits self = init.Self; Info = info; Unloading = false; - checkTerrainType = info.UnloadTerrainTypes.Length > 0; + checkTerrainType = info.UnloadTerrainTypes.Count > 0; if (init.Contains()) { diff --git a/OpenRA.Mods.Common/Traits/Crates/Crate.cs b/OpenRA.Mods.Common/Traits/Crates/Crate.cs index d691e57d09..813c48bb88 100644 --- a/OpenRA.Mods.Common/Traits/Crates/Crate.cs +++ b/OpenRA.Mods.Common/Traits/Crates/Crate.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int Lifetime = 0; [Desc("Allowed to land on.")] - public readonly string[] TerrainTypes = { }; + public readonly HashSet TerrainTypes = new HashSet(); [Desc("Define actors that can collect crates by setting this into the Crushes field from the Mobile trait.")] public readonly string CrushClass = "crate"; @@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Traits return GetAvailableSubCell(a, SubCell.Any, ignoreActor, checkTransientActors) != SubCell.Invalid; } - public bool CrushableBy(string[] crushClasses, Player owner) + public bool CrushableBy(HashSet crushClasses, Player owner) { // Crate can only be crushed if it is not in the air. return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass); diff --git a/OpenRA.Mods.Common/Traits/Crates/DuplicateUnitCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/DuplicateUnitCrateAction.cs index 5288b975ad..5285cc1564 100644 --- a/OpenRA.Mods.Common/Traits/Crates/DuplicateUnitCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/DuplicateUnitCrateAction.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits public readonly HashSet ValidTargets = new HashSet { "Ground", "Water" }; [Desc("Which factions this crate action can occur for.")] - public readonly string[] ValidFactions = { }; + public readonly HashSet ValidFactions = new HashSet(); [Desc("Is the new duplicates given to a specific owner, regardless of whom collected it?")] public readonly string Owner = null; diff --git a/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs index 718ce44520..a838c284ad 100644 --- a/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/GiveUnitCrateAction.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string[] Units = { }; [Desc("Factions that are allowed to trigger this action.")] - public readonly string[] ValidFactions = { }; + public readonly HashSet ValidFactions = new HashSet(); [Desc("Override the owner of the newly spawned unit: e.g. Creeps or Neutral")] public readonly string Owner = null; diff --git a/OpenRA.Mods.Common/Traits/Crushable.cs b/OpenRA.Mods.Common/Traits/Crushable.cs index 943601e22e..58e78283cd 100644 --- a/OpenRA.Mods.Common/Traits/Crushable.cs +++ b/OpenRA.Mods.Common/Traits/Crushable.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits self.Kill(crusher); } - public bool CrushableBy(string[] crushClasses, Player crushOwner) + public bool CrushableBy(HashSet crushClasses, Player crushOwner) { // Only make actor crushable if it is on the ground. if (!self.IsAtGroundLevel()) diff --git a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs b/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs index dab9f58c8b..dcb9dba8ee 100644 --- a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs +++ b/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; @@ -26,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Spawns actors only if the selling player's faction is in this list. " + "Leave empty to allow all factions by default.")] - public readonly string[] Factions = { }; + public readonly HashSet Factions = new HashSet(); public object Create(ActorInitializer init) { return new EmitInfantryOnSell(init.Self, this); } } @@ -40,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; var factionsList = info.Factions; - correctFaction = factionsList.Length == 0 || factionsList.Contains(self.Owner.Faction.InternalName); + correctFaction = factionsList.Count == 0 || factionsList.Contains(self.Owner.Faction.InternalName); } public void Selling(Actor self) { } diff --git a/OpenRA.Mods.Common/Traits/Explodes.cs b/OpenRA.Mods.Common/Traits/Explodes.cs index 55371037e7..9ae921107b 100644 --- a/OpenRA.Mods.Common/Traits/Explodes.cs +++ b/OpenRA.Mods.Common/Traits/Explodes.cs @@ -9,6 +9,7 @@ #endregion using System; +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; @@ -31,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int Chance = 100; [Desc("DeathType(s) to apply upon explosion.")] - public readonly string[] DeathType = null; + public readonly HashSet DeathType = new HashSet(); public object Create(ActorInitializer init) { return new Explodes(this); } } @@ -51,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits return; var warhead = e.Warhead as DamageWarhead; - if (info.DeathType != null && warhead != null && !warhead.DamageTypes.Overlaps(info.DeathType)) + if (warhead != null && !warhead.DamageTypes.Overlaps(info.DeathType)) return; var weaponName = ChooseWeaponForExplosion(self); diff --git a/OpenRA.Mods.Common/Traits/ExternalCaptures.cs b/OpenRA.Mods.Common/Traits/ExternalCaptures.cs index 53e2ed7313..9a3a9aa938 100644 --- a/OpenRA.Mods.Common/Traits/ExternalCaptures.cs +++ b/OpenRA.Mods.Common/Traits/ExternalCaptures.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits class ExternalCapturesInfo : ITraitInfo { [Desc("Types of actors that it can capture, as long as the type also exists in the ExternalCapturable Type: trait.")] - public readonly string[] CaptureTypes = { "building" }; + public readonly HashSet CaptureTypes = new HashSet { "building" }; [Desc("Destroy the unit after capturing.")] public readonly bool ConsumeActor = false; diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index cf5448112f..589c268708 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits { public class HarvesterInfo : ITraitInfo, Requires { - public readonly string[] DeliveryBuildings = { }; + public readonly HashSet DeliveryBuildings = new HashSet(); [Desc("How long (in ticks) to wait until (re-)checking for a nearby available DeliveryBuilding if not yet linked to one.")] public readonly int SearchForDeliveryBuildingDelay = 125; @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int HarvestFacings = 0; [Desc("Which resources it can harvest.")] - public readonly string[] Resources = { }; + public readonly HashSet Resources = new HashSet(); [Desc("Percentage of maximum speed when fully loaded.")] public readonly int FullyLoadedSpeed = 85; @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits bool IsAcceptableProcType(Actor proc) { - return info.DeliveryBuildings.Length == 0 || + return info.DeliveryBuildings.Count == 0 || info.DeliveryBuildings.Contains(proc.Info.Name); } diff --git a/OpenRA.Mods.Common/Traits/Husk.cs b/OpenRA.Mods.Common/Traits/Husk.cs index 00cfdc4d87..78da105972 100644 --- a/OpenRA.Mods.Common/Traits/Husk.cs +++ b/OpenRA.Mods.Common/Traits/Husk.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Spawns remains of a husk actor with the correct facing.")] public class HuskInfo : IOccupySpaceInfo, IFacingInfo { - public readonly string[] AllowedTerrain = { }; + public readonly HashSet AllowedTerrain = new HashSet(); public object Create(ActorInitializer init) { return new Husk(init, this); } diff --git a/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs b/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs index 9f93e34d01..16860e3b2b 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Damage types that trigger prone state. Defined on the warheads.")] - public readonly string[] DamageTriggers = null; + public readonly HashSet DamageTriggers = new HashSet(); [Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")] public readonly Dictionary DamageModifiers = new Dictionary(); @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits public void Damaged(Actor self, AttackInfo e) { var warhead = e.Warhead as DamageWarhead; - if (e.Damage <= 0 || warhead == null || !warhead.DamageTypes.Any(x => info.DamageTriggers.Contains(x))) + if (e.Damage <= 0 || warhead == null || !warhead.DamageTypes.Overlaps(info.DamageTriggers)) return; if (!IsProne) diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 07f31d9023..71ea825cd7 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits public readonly Dictionary TerrainSpeeds; [Desc("e.g. crate, wall, infantry")] - public readonly string[] Crushes = { }; + public readonly HashSet Crushes = new HashSet(); public readonly int WaitAverage = 5; @@ -237,7 +237,7 @@ namespace OpenRA.Mods.Common.Traits return false; // If we cannot crush the other actor in our way, we are blocked. - if (self == null || Crushes == null || Crushes.Length == 0) + if (self == null || Crushes == null || Crushes.Count == 0) return true; // If the other actor in our way cannot be crushed, we are blocked. diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/FlashPaletteEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/FlashPaletteEffect.cs index 0b832e74d1..7bd93abd72 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/FlashPaletteEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/FlashPaletteEffect.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Used for bursted one-colored whole screen effects. Add this to the world actor.")] public class FlashPaletteEffectInfo : ITraitInfo { - public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "fog", "shroud" }; + public readonly HashSet ExcludePalettes = new HashSet { "cursor", "chrome", "colorpicker", "fog", "shroud" }; [Desc("Measured in ticks.")] public readonly int Length = 20; diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/GlobalLightingPaletteEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/GlobalLightingPaletteEffect.cs index f48b1bd729..2a96a17492 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/GlobalLightingPaletteEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/GlobalLightingPaletteEffect.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.Graphics; @@ -19,10 +20,10 @@ namespace OpenRA.Mods.Common.Traits class GlobalLightingPaletteEffectInfo : ITraitInfo { [Desc("Do not modify graphics that use any palette in this list.")] - public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "fog", "shroud", "alpha" }; + public readonly HashSet ExcludePalettes = new HashSet { "cursor", "chrome", "colorpicker", "fog", "shroud", "alpha" }; [Desc("Do not modify graphics that start with these letters.")] - public readonly string[] ExcludePalettePrefixes = { }; + public readonly HashSet ExcludePalettePrefixes = new HashSet(); public readonly float Red = 1f; public readonly float Green = 1f; diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/WaterPaletteRotation.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/WaterPaletteRotation.cs index 16724cd42b..bb973554be 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/WaterPaletteRotation.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/WaterPaletteRotation.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Palette effect used for sprinkle \"animations\" on terrain tiles.")] class WaterPaletteRotationInfo : ITraitInfo { - public readonly string[] ExcludePalettes = { }; + public readonly HashSet ExcludePalettes = new HashSet(); public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.World, this); } } diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index f041e8ac6d..c903286bc4 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Group = null; [Desc("Only enable this queue for certain factions.")] - public readonly string[] Factions = { }; + public readonly HashSet Factions = new HashSet(); [Desc("Should the prerequisite remain enabled if the owner changes?")] public readonly bool Sticky = true; diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs index 804708bc4c..773d0353bd 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesPrerequisite.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string[] RequiresPrerequisites = { }; [Desc("Only grant this prerequisite for certain factions.")] - public readonly string[] Factions = { }; + public readonly HashSet Factions = new HashSet(); [Desc("Should it recheck everything when it is captured?")] public readonly bool ResetOnOwnerChange = false; diff --git a/OpenRA.Mods.Common/Traits/ProximityCaptor.cs b/OpenRA.Mods.Common/Traits/ProximityCaptor.cs index cb40d26829..8e8cafb294 100644 --- a/OpenRA.Mods.Common/Traits/ProximityCaptor.cs +++ b/OpenRA.Mods.Common/Traits/ProximityCaptor.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Traits; @@ -17,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits public class ProximityCaptorInfo : ITraitInfo { [FieldLoader.Require] - public readonly string[] Types = { }; + public readonly HashSet Types = new HashSet(); public object Create(ActorInitializer init) { return new ProximityCaptor(this); } } @@ -27,9 +28,9 @@ namespace OpenRA.Mods.Common.Traits public ProximityCaptor(ProximityCaptorInfo info) { Info = info; } - public bool HasAny(string[] typesList) + public bool HasAny(IEnumerable typesList) { - return typesList.Any(flag => Info.Types.Contains(flag)); + return Info.Types.Overlaps(typesList); } } } diff --git a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs index 125494a277..96ce392d61 100644 --- a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs +++ b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits public readonly bool Permanent = false; public readonly int Range = 5; public readonly bool MustBeClear = false; - public readonly string[] CaptorTypes = { "Vehicle", "Tank", "Infantry" }; + public readonly HashSet CaptorTypes = new HashSet { "Vehicle", "Tank", "Infantry" }; public object Create(ActorInitializer init) { return new ProximityCapturable(init.Self, this); } } diff --git a/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs b/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs index cdd0f751a9..cb5f87a67d 100644 --- a/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs +++ b/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Effects; using OpenRA.Traits; @@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits [PaletteReference] public readonly string Palette = "effect"; [Desc("Only do so when the terrain types match with the previous cell.")] - public readonly string[] TerrainTypes = { }; + public readonly HashSet TerrainTypes = new HashSet(); public object Create(ActorInitializer init) { return new LeavesTrails(this, init.Self); } } diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index 8210da205d..310710d444 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("This actor can be sent to a structure for repairs.")] class RepairableInfo : ITraitInfo, Requires { - public readonly string[] RepairBuildings = { "fix" }; + public readonly HashSet RepairBuildings = new HashSet { "fix" }; [VoiceReference] public readonly string Voice = "Action"; diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index cc99cf650a..ddae2b19d5 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits { class RepairableNearInfo : ITraitInfo, Requires, Requires { - [ActorReference] public readonly string[] Buildings = { "spen", "syrd" }; + [ActorReference] public readonly HashSet Buildings = new HashSet { "spen", "syrd" }; public readonly int CloseEnough = 4; /* cells */ public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); } diff --git a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs index 552d4efcd5..9d75ba2098 100644 --- a/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs +++ b/OpenRA.Mods.Common/Traits/Sound/DeathSounds.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; @@ -25,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Damage types that this should be used for (defined on the warheads).", "If empty, this will be used as the default sound for all death types.")] - public readonly string[] DeathTypes = { }; + public readonly HashSet DeathTypes = new HashSet(); public object Create(ActorInitializer init) { return new DeathSounds(this); } } diff --git a/OpenRA.Mods.Common/Traits/TransformOnPassenger.cs b/OpenRA.Mods.Common/Traits/TransformOnPassenger.cs index a9d042409d..5fb040115b 100644 --- a/OpenRA.Mods.Common/Traits/TransformOnPassenger.cs +++ b/OpenRA.Mods.Common/Traits/TransformOnPassenger.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Activities; using OpenRA.Traits; @@ -16,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits { public class TransformOnPassengerInfo : ITraitInfo { - [ActorReference, FieldLoader.Require] public readonly string[] PassengerTypes = { }; + [ActorReference, FieldLoader.Require] public readonly HashSet PassengerTypes = new HashSet(); [ActorReference] public readonly string OnEnter = null; [ActorReference] public readonly string OnExit = null; public readonly bool SkipMakeAnims = false; diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs index f9b7f23fee..ff7407829c 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("The terrain types that this actor can deploy on to receive these upgrades. " + "Leave empty to allow any.")] - public readonly string[] AllowedTerrainTypes = { }; + public readonly HashSet AllowedTerrainTypes = new HashSet(); [Desc("Cursor to display when able to (un)deploy the actor.")] public readonly string DeployCursor = "deploy"; @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits this.self = self; this.info = info; manager = self.Trait(); - checkTerrainType = info.AllowedTerrainTypes.Length > 0; + checkTerrainType = info.AllowedTerrainTypes.Count > 0; canTurn = self.Info.Traits.WithInterface().Any(); body = Exts.Lazy(self.TraitOrDefault); } diff --git a/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs b/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs index b6d99b6026..8783aae9e6 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits { [UpgradeUsedReference] [Desc("The upgrade types which can enable or disable this trait.")] - public readonly string[] UpgradeTypes = { }; + public readonly HashSet UpgradeTypes = new HashSet(); [Desc("The minimum upgrade level at which this trait is enabled.", "Defaults to 0 (enabled by default).")] public readonly int UpgradeMinEnabledLevel = 0; @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits public UpgradableTrait(InfoType info) { Info = info; - IsTraitDisabled = info.UpgradeTypes != null && info.UpgradeTypes.Length > 0 && info.UpgradeMinEnabledLevel > 0; + IsTraitDisabled = info.UpgradeTypes != null && info.UpgradeTypes.Count > 0 && info.UpgradeMinEnabledLevel > 0; } public bool AcceptsUpgradeLevel(Actor self, string type, int level) diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 6d19194d4d..175d2e43cd 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -9,6 +9,7 @@ #endregion using System; +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Activities; using OpenRA.Primitives; @@ -28,10 +29,10 @@ namespace OpenRA.Mods.Common.Traits public readonly int SpawnInterval = 180; [Desc("Which terrain types can we drop on?")] - public readonly string[] ValidGround = { "Clear", "Rough", "Road", "Ore", "Beach" }; + public readonly HashSet ValidGround = new HashSet { "Clear", "Rough", "Road", "Ore", "Beach" }; [Desc("Which terrain types count as water?")] - public readonly string[] ValidWater = { "Water" }; + public readonly HashSet ValidWater = new HashSet { "Water" }; [Desc("Chance of generating a water crate instead of a land crate")] public readonly float WaterChance = .2f; diff --git a/OpenRA.Mods.Common/Traits/World/MPStartUnits.cs b/OpenRA.Mods.Common/Traits/World/MPStartUnits.cs index 25610ed0c6..ced3497a15 100644 --- a/OpenRA.Mods.Common/Traits/World/MPStartUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/MPStartUnits.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string ClassName = "Unlabeled"; [Desc("Only available when selecting one of these factions.", "Leave empty for no restrictions.")] - public readonly string[] Factions = { }; + public readonly HashSet Factions = new HashSet(); [Desc("The mobile construction vehicle.")] public readonly string BaseActor = null; diff --git a/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs b/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs index 104fd52feb..3297c033b8 100644 --- a/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Warheads public readonly int[] Size = { 0, 0 }; [Desc("Type of smudge to apply to terrain.")] - public readonly string[] SmudgeType = { }; + public readonly HashSet SmudgeType = new HashSet(); public override void DoImpact(Target target, Actor firedBy, IEnumerable damageModifiers) { @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads // Draw the smudges: foreach (var sc in allCells) { - var smudgeType = world.Map.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => SmudgeType.Contains(t)); + var smudgeType = world.Map.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(SmudgeType.Contains); if (smudgeType == null) continue; SmudgeLayer smudgeLayer; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs index 01aa6d0745..6e4ec3f38b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs @@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (path != null) Install(path); - else if ((installData.InstallShieldCABFileIds.Length != 0 || installData.InstallShieldCABFilePackageIds.Length != 0) + else if ((installData.InstallShieldCABFileIds.Count != 0 || installData.InstallShieldCABFilePackageIds.Count != 0) && (path = InstallUtils.GetMountedDisk(IsTFD)) != null) InstallTFD(Platform.ResolvePath(path, "data1.hdr")); else @@ -91,10 +91,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { using (var cabExtractor = new InstallShieldCABExtractor(source)) { - var denom = installData.InstallShieldCABFileIds.Length; + var denom = installData.InstallShieldCABFileIds.Count; var extractFiles = installData.ExtractFilesFromCD; - if (installData.InstallShieldCABFilePackageIds.Length > 0) + if (installData.InstallShieldCABFilePackageIds.Count > 0) denom += extractFiles.SelectMany(x => x.Value).Count(); var installPercent = 100 / denom; diff --git a/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs b/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs index be04c314b9..e18482f698 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; @@ -19,7 +20,7 @@ namespace OpenRA.Mods.D2k.Traits { [WeaponReference] public readonly string Weapon = "weathering"; - public readonly string[] SafeTerrain = { "Concrete" }; + public readonly HashSet SafeTerrain = new HashSet { "Concrete" }; public readonly int DamageThreshold = 50; public object Create(ActorInitializer init) { return new DamagedWithoutFoundation(init.Self, this); } diff --git a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs index 74745ebdf5..3f766a678f 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Traits; using OpenRA.Traits; @@ -22,7 +23,7 @@ namespace OpenRA.Mods.D2k.Traits [FieldLoader.Require] [Desc("The terrain types that this template will be placed on")] - public readonly string[] TerrainTypes = { }; + public readonly HashSet TerrainTypes = new HashSet(); [Desc("Offset relative to the actor TopLeft. Not used if the template is PickAny")] public readonly CVec Offset = CVec.Zero; diff --git a/OpenRA.Mods.RA/Activities/LayMines.cs b/OpenRA.Mods.RA/Activities/LayMines.cs index be26ed2fe9..64446c68c9 100644 --- a/OpenRA.Mods.RA/Activities/LayMines.cs +++ b/OpenRA.Mods.RA/Activities/LayMines.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities readonly MinelayerInfo info; readonly AmmoPool[] ammoPools; readonly IMove movement; - readonly string[] rearmBuildings; + readonly HashSet rearmBuildings; public LayMines(Actor self) { diff --git a/OpenRA.Mods.RA/Traits/Cloneable.cs b/OpenRA.Mods.RA/Traits/Cloneable.cs index 3e4d8b04f7..ef353acb6a 100644 --- a/OpenRA.Mods.RA/Traits/Cloneable.cs +++ b/OpenRA.Mods.RA/Traits/Cloneable.cs @@ -8,7 +8,7 @@ */ #endregion -using System; +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.RA.Traits @@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits { [FieldLoader.Require] [Desc("This unit's cloneable type is:")] - public readonly string[] Types = { }; + public readonly HashSet Types = new HashSet(); } public class Cloneable { } diff --git a/OpenRA.Mods.RA/Traits/Mine.cs b/OpenRA.Mods.RA/Traits/Mine.cs index 294cba560a..9372bfc7db 100644 --- a/OpenRA.Mods.RA/Traits/Mine.cs +++ b/OpenRA.Mods.RA/Traits/Mine.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Traits self.Kill(crusher); } - public bool CrushableBy(string[] crushClasses, Player owner) + public bool CrushableBy(HashSet crushClasses, Player owner) { return info.CrushClasses.Overlaps(crushClasses); } diff --git a/OpenRA.Mods.RA/Traits/Minelayer.cs b/OpenRA.Mods.RA/Traits/Minelayer.cs index c86aaa430d..02be6e3bef 100644 --- a/OpenRA.Mods.RA/Traits/Minelayer.cs +++ b/OpenRA.Mods.RA/Traits/Minelayer.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Traits public class MinelayerInfo : ITraitInfo { [ActorReference] public readonly string Mine = "minv"; - [ActorReference] public readonly string[] RearmBuildings = { "fix" }; + [ActorReference] public readonly HashSet RearmBuildings = new HashSet { "fix" }; public readonly string AmmoPoolName = "primary"; diff --git a/OpenRA.Mods.RA/Traits/PaletteEffects/LightPaletteRotator.cs b/OpenRA.Mods.RA/Traits/PaletteEffects/LightPaletteRotator.cs index f9769c9606..d955bf4d52 100644 --- a/OpenRA.Mods.RA/Traits/PaletteEffects/LightPaletteRotator.cs +++ b/OpenRA.Mods.RA/Traits/PaletteEffects/LightPaletteRotator.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits [Desc("Palette effect used for blinking \"animations\" on actors.")] class LightPaletteRotatorInfo : ITraitInfo { - public readonly string[] ExcludePalettes = { }; + public readonly HashSet ExcludePalettes = new HashSet(); public object Create(ActorInitializer init) { return new LightPaletteRotator(this); } } diff --git a/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs index 90733370ea..143ff5ac9c 100644 --- a/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs +++ b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Traits; using OpenRA.Traits; @@ -16,7 +17,7 @@ namespace OpenRA.Mods.RA.Traits { public class WithLandingCraftAnimationInfo : ITraitInfo, Requires, Requires, Requires { - public readonly string[] OpenTerrainTypes = { "Clear" }; + public readonly HashSet OpenTerrainTypes = new HashSet { "Clear" }; [SequenceReference] public readonly string OpenSequence = "open"; [SequenceReference] public readonly string CloseSequence = "close"; [SequenceReference] public readonly string UnloadSequence = "unload";