Merge pull request #9279 from atlimit8/SemanticallySets

More HashSet trait fields & Lint support
This commit is contained in:
Matthias Mailänder
2015-09-06 10:23:20 +02:00
57 changed files with 115 additions and 89 deletions

View File

@@ -22,8 +22,8 @@ namespace OpenRA.GameRules
public readonly Dictionary<string, string[]> Notifications = new Dictionary<string, string[]>(); public readonly Dictionary<string, string[]> Notifications = new Dictionary<string, string[]>();
public readonly string DefaultVariant = ".aud"; public readonly string DefaultVariant = ".aud";
public readonly string DefaultPrefix = ""; public readonly string DefaultPrefix = "";
public readonly string[] DisableVariants = { }; public readonly HashSet<string> DisableVariants = new HashSet<string>();
public readonly string[] DisablePrefixes = { }; public readonly HashSet<string> DisablePrefixes = new HashSet<string>();
public readonly Lazy<Dictionary<string, SoundPool>> VoicePools; public readonly Lazy<Dictionary<string, SoundPool>> VoicePools;
public readonly Lazy<Dictionary<string, SoundPool>> NotificationsPools; public readonly Lazy<Dictionary<string, SoundPool>> NotificationsPools;

View File

@@ -49,8 +49,8 @@ namespace OpenRA
static readonly TerrainTypeInfo Default = new TerrainTypeInfo(); static readonly TerrainTypeInfo Default = new TerrainTypeInfo();
public readonly string Type; public readonly string Type;
public readonly string[] TargetTypes = { }; public readonly HashSet<string> TargetTypes = new HashSet<string>();
public readonly string[] AcceptsSmudgeType = { }; public readonly HashSet<string> AcceptsSmudgeType = new HashSet<string>();
public readonly bool IsWater = false; // TODO: Remove this public readonly bool IsWater = false; // TODO: Remove this
public readonly Color Color; public readonly Color Color;
public readonly string CustomCursor; public readonly string CustomCursor;

View File

@@ -8,12 +8,14 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class EditorTilesetFilterInfo : TraitInfo<EditorTilesetFilter> public class EditorTilesetFilterInfo : TraitInfo<EditorTilesetFilter>
{ {
public readonly string[] RequireTilesets = null; public readonly HashSet<string> RequireTilesets = null;
public readonly string[] ExcludeTilesets = null; public readonly HashSet<string> ExcludeTilesets = null;
} }
public class EditorTilesetFilter { } public class EditorTilesetFilter { }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace OpenRA.Traits namespace OpenRA.Traits
@@ -16,14 +17,14 @@ namespace OpenRA.Traits
public class RejectsOrdersInfo : ITraitInfo public class RejectsOrdersInfo : ITraitInfo
{ {
[Desc("Possible values include Attack, AttackMove, Guard, Move.")] [Desc("Possible values include Attack, AttackMove, Guard, Move.")]
public readonly string[] Except = { }; public readonly HashSet<string> Except = new HashSet<string>();
public object Create(ActorInitializer init) { return new RejectsOrders(this); } public object Create(ActorInitializer init) { return new RejectsOrders(this); }
} }
public class RejectsOrders public class RejectsOrders
{ {
public string[] Except { get { return info.Except; } } public HashSet<string> Except { get { return info.Except; } }
readonly RejectsOrdersInfo info; readonly RejectsOrdersInfo info;

View File

@@ -268,7 +268,7 @@ namespace OpenRA.Traits
{ {
void OnCrush(Actor crusher); void OnCrush(Actor crusher);
void WarnCrush(Actor crusher); void WarnCrush(Actor crusher);
bool CrushableBy(string[] crushClasses, Player owner); bool CrushableBy(HashSet<string> crushClasses, Player owner);
} }
public interface ITraitInfo { object Create(ActorInitializer init); } public interface ITraitInfo { object Create(ActorInitializer init); }

View File

@@ -8,6 +8,8 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
[Desc("Attach this to the `World` actor.")] [Desc("Attach this to the `World` actor.")]
@@ -20,7 +22,7 @@ namespace OpenRA.Traits
public readonly string InternalName = null; public readonly string InternalName = null;
[Desc("Pick a random faction as the player's facton out of this list.")] [Desc("Pick a random faction as the player's facton out of this list.")]
public readonly string[] RandomFactionMembers = { }; public readonly HashSet<string> RandomFactionMembers = new HashSet<string>();
[Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")] [Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")]
public readonly string Side = null; public readonly string Side = null;

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Traits
public readonly string Name = null; public readonly string Name = null;
public readonly string TerrainType = "Ore"; public readonly string TerrainType = "Ore";
public readonly string[] AllowedTerrainTypes = { }; public readonly HashSet<string> AllowedTerrainTypes = new HashSet<string>();
public readonly bool AllowUnderActors = false; public readonly bool AllowUnderActors = false;
public readonly bool AllowUnderBuildings = false; public readonly bool AllowUnderBuildings = false;
public readonly bool AllowOnRamps = false; public readonly bool AllowOnRamps = false;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -18,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Traits
class PoisonedByTiberiumInfo : UpgradableTraitInfo class PoisonedByTiberiumInfo : UpgradableTraitInfo
{ {
[WeaponReference] public readonly string Weapon = "Tiberium"; [WeaponReference] public readonly string Weapon = "Tiberium";
public readonly string[] Resources = { "Tiberium", "BlueTiberium" }; public readonly HashSet<string> Resources = new HashSet<string> { "Tiberium", "BlueTiberium" };
public override object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } public override object Create(ActorInitializer init) { return new PoisonedByTiberium(this); }
} }

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly WVec[] LocalOffset = { WVec.Zero }; public readonly WVec[] LocalOffset = { WVec.Zero };
[Desc("Passenger CargoType to display.")] [Desc("Passenger CargoType to display.")]
public readonly string[] DisplayTypes = { }; public readonly HashSet<string> DisplayTypes = new HashSet<string>();
public object Create(ActorInitializer init) { return new WithCargo(init.Self, this); } public object Create(ActorInitializer init) { return new WithCargo(init.Self, this); }
} }

View File

@@ -32,10 +32,10 @@ namespace OpenRA.Mods.Common.AI
public readonly int SquadSizeRandomBonus = 30; public readonly int SquadSizeRandomBonus = 30;
[Desc("Production queues AI uses for buildings.")] [Desc("Production queues AI uses for buildings.")]
public readonly string[] BuildingQueues = { "Building" }; public readonly HashSet<string> BuildingQueues = new HashSet<string> { "Building" };
[Desc("Production queues AI uses for defenses.")] [Desc("Production queues AI uses for defenses.")]
public readonly string[] DefenseQueues = { "Defense" }; public readonly HashSet<string> DefenseQueues = new HashSet<string> { "Defense" };
[Desc("Delay (in ticks) between giving out orders to units.")] [Desc("Delay (in ticks) between giving out orders to units.")]
public readonly int AssignRolesInterval = 20; public readonly int AssignRolesInterval = 20;
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.AI
public readonly int CheckForWaterRadius = 8; public readonly int CheckForWaterRadius = 8;
[Desc("Production queues AI uses for producing units.")] [Desc("Production queues AI uses for producing units.")]
public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" }; public readonly HashSet<string> UnitQueues = new HashSet<string> { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" };
[Desc("Should the AI repair its buildings if damaged?")] [Desc("Should the AI repair its buildings if damaged?")]
public readonly bool ShouldRepairBuildings = true; public readonly bool ShouldRepairBuildings = true;

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common
public readonly string MenuWidget = null; public readonly string MenuWidget = null;
public readonly string MusicMenuWidget = null; public readonly string MusicMenuWidget = null;
public readonly string BackgroundWidget = null; public readonly string BackgroundWidget = null;
public readonly string[] TestFiles = { }; public readonly HashSet<string> TestFiles = new HashSet<string>();
public readonly string[] DiskTestFiles = { }; public readonly HashSet<string> DiskTestFiles = new HashSet<string>();
public readonly string PackageToExtractFromCD = null; public readonly string PackageToExtractFromCD = null;
public readonly bool OverwriteFiles = true; public readonly bool OverwriteFiles = true;
@@ -37,10 +37,10 @@ namespace OpenRA.Mods.Common
public readonly int ShippedSoundtracks = 0; public readonly int ShippedSoundtracks = 0;
/// <summary> InstallShield .cab File Ids, used to extract Mod specific files. </summary> /// <summary> InstallShield .cab File Ids, used to extract Mod specific files. </summary>
public readonly int[] InstallShieldCABFileIds = { }; public readonly HashSet<int> InstallShieldCABFileIds = new HashSet<int>();
/// <summary> InstallShield .cab File Ids, used to extract Mod specific archives and extract contents of ExtractFilesFromCD. </summary> /// <summary> InstallShield .cab File Ids, used to extract Mod specific archives and extract contents of ExtractFilesFromCD. </summary>
public readonly string[] InstallShieldCABFilePackageIds = { }; public readonly HashSet<string> InstallShieldCABFilePackageIds = new HashSet<string>();
} }
public static class InstallUtils public static class InstallUtils

View File

@@ -9,21 +9,24 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
namespace OpenRA.Mods.Common.Lint namespace OpenRA.Mods.Common.Lint
{ {
public class LintExts public class LintExts
{ {
public static string[] GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action<string> emitError) public static IEnumerable<string> GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action<string> emitError)
{ {
var type = fieldInfo.FieldType; var type = fieldInfo.FieldType;
if (type == typeof(string)) if (type == typeof(string))
return new[] { (string)fieldInfo.GetValue(ruleInfo) }; return new[] { (string)fieldInfo.GetValue(ruleInfo) };
if (type == typeof(string[])) if (type == typeof(string[]))
return (string[])fieldInfo.GetValue(ruleInfo); return (string[])fieldInfo.GetValue(ruleInfo);
if (type == typeof(HashSet<string>))
return (HashSet<string>)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<string>"
.F(ruleInfo.GetType().Name, fieldInfo.Name)); .F(ruleInfo.GetType().Name, fieldInfo.Name));
return new string[] { }; return new string[] { };

View File

@@ -9,6 +9,8 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Scripting; using OpenRA.Scripting;
@@ -19,7 +21,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Part of the new Lua API.")] [Desc("Part of the new Lua API.")]
public class LuaScriptInfo : ITraitInfo, Requires<SpawnMapActorsInfo> public class LuaScriptInfo : ITraitInfo, Requires<SpawnMapActorsInfo>
{ {
public readonly string[] Scripts = { }; public readonly HashSet<string> Scripts = new HashSet<string>();
public object Create(ActorInitializer init) { return new LuaScript(this); } 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) public void WorldLoaded(World world, WorldRenderer worldRenderer)
{ {
var scripts = info.Scripts ?? new string[0]; var scripts = info.Scripts ?? Enumerable.Empty<string>();
context = new ScriptContext(world, worldRenderer, scripts); context = new ScriptContext(world, worldRenderer, scripts);
context.WorldLoaded(); context.WorldLoaded();
} }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Scripting namespace OpenRA.Mods.Common.Scripting
@@ -17,7 +18,7 @@ namespace OpenRA.Mods.Common.Scripting
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference]
[Desc("Upgrades that can be granted from the scripts.")] [Desc("Upgrades that can be granted from the scripts.")]
public readonly string[] Upgrades = { }; public readonly HashSet<string> Upgrades = new HashSet<string>();
public object Create(ActorInitializer init) { return new ScriptUpgradesCache(this); } public object Create(ActorInitializer init) { return new ScriptUpgradesCache(this); }
} }

View File

@@ -29,16 +29,16 @@ namespace OpenRA.Mods.Common.Traits
public readonly int RepulsionSpeed = -1; public readonly int RepulsionSpeed = -1;
[ActorReference] [ActorReference]
public readonly string[] RepairBuildings = { "fix" }; public readonly HashSet<string> RepairBuildings = new HashSet<string> { "fix" };
[ActorReference] [ActorReference]
public readonly string[] RearmBuildings = { "hpad", "afld" }; public readonly HashSet<string> RearmBuildings = new HashSet<string> { "hpad", "afld" };
public readonly int InitialFacing = 0; public readonly int InitialFacing = 0;
public readonly int ROT = 255; public readonly int ROT = 255;
public readonly int Speed = 1; public readonly int Speed = 1;
[Desc("Minimum altitude where this aircraft is considered airborne")] [Desc("Minimum altitude where this aircraft is considered airborne")]
public readonly int MinAirborneAltitude = 1; public readonly int MinAirborneAltitude = 1;
public readonly string[] LandableTerrainTypes = { }; public readonly HashSet<string> LandableTerrainTypes = new HashSet<string>();
[Desc("Can the actor be ordered to move in to shroud?")] [Desc("Can the actor be ordered to move in to shroud?")]
public readonly bool MoveIntoShroud = true; public readonly bool MoveIntoShroud = true;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
@@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string[] Prerequisites = { }; public readonly string[] Prerequisites = { };
[Desc("Production queue(s) that can produce this.")] [Desc("Production queue(s) that can produce this.")]
public readonly string[] Queue = { }; public readonly HashSet<string> Queue = new HashSet<string>();
[Desc("Override the production structure type (from the Production Produces list) that this unit should be built at.")] [Desc("Override the production structure type (from the Production Produces list) that this unit should be built at.")]
public readonly string BuildAtProductionType = null; public readonly string BuildAtProductionType = null;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit<LocationInit> public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit<LocationInit>
{ {
[Desc("Where you are allowed to place the building (Water, Clear, ...)")] [Desc("Where you are allowed to place the building (Water, Clear, ...)")]
public readonly string[] TerrainTypes = { }; public readonly HashSet<string> TerrainTypes = new HashSet<string>();
[Desc("The range to the next building it can be constructed. Set it higher for walls.")] [Desc("The range to the next building it can be constructed. Set it higher for walls.")]
public readonly int Adjacent = 2; public readonly int Adjacent = 2;
[Desc("x means space it blocks, _ is a part that is passable by actors.")] [Desc("x means space it blocks, _ is a part that is passable by actors.")]

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
@@ -19,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Range = 5; public readonly int Range = 5;
[Desc("LineBuildNode 'Types' to attach to.")] [Desc("LineBuildNode 'Types' to attach to.")]
public readonly string[] NodeTypes = { "wall" }; public readonly HashSet<string> NodeTypes = new HashSet<string> { "wall" };
} }
public class LineBuild { } public class LineBuild { }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
public class CapturesInfo : ITraitInfo public class CapturesInfo : ITraitInfo
{ {
[Desc("Types of actors that it can capture, as long as the type also exists in the Capturable Type: trait.")] [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<string> CaptureTypes = new HashSet<string> { "building" };
[Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")] [Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")]
public readonly bool Sabotage = true; public readonly bool Sabotage = true;
[Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")] [Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")]

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int PipCount = 0; public readonly int PipCount = 0;
[Desc("`Passenger.CargoType`s that can be loaded into this actor.")] [Desc("`Passenger.CargoType`s that can be loaded into this actor.")]
public readonly string[] Types = { }; public readonly HashSet<string> Types = new HashSet<string>();
[Desc("A list of actor types that are initially spawned into this actor.")] [Desc("A list of actor types that are initially spawned into this actor.")]
public readonly string[] InitialUnits = { }; public readonly string[] InitialUnits = { };
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool EjectOnSell = true; public readonly bool EjectOnSell = true;
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")] [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<string> UnloadTerrainTypes = new HashSet<string>();
[Desc("Voice to play when ordered to unload the passengers.")] [Desc("Voice to play when ordered to unload the passengers.")]
[VoiceReference] public readonly string UnloadVoice = "Action"; [VoiceReference] public readonly string UnloadVoice = "Action";
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
self = init.Self; self = init.Self;
Info = info; Info = info;
Unloading = false; Unloading = false;
checkTerrainType = info.UnloadTerrainTypes.Length > 0; checkTerrainType = info.UnloadTerrainTypes.Count > 0;
if (init.Contains<RuntimeCargoInit>()) if (init.Contains<RuntimeCargoInit>())
{ {

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Lifetime = 0; public readonly int Lifetime = 0;
[Desc("Allowed to land on.")] [Desc("Allowed to land on.")]
public readonly string[] TerrainTypes = { }; public readonly HashSet<string> TerrainTypes = new HashSet<string>();
[Desc("Define actors that can collect crates by setting this into the Crushes field from the Mobile trait.")] [Desc("Define actors that can collect crates by setting this into the Crushes field from the Mobile trait.")]
public readonly string CrushClass = "crate"; public readonly string CrushClass = "crate";
@@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Traits
return GetAvailableSubCell(a, SubCell.Any, ignoreActor, checkTransientActors) != SubCell.Invalid; return GetAvailableSubCell(a, SubCell.Any, ignoreActor, checkTransientActors) != SubCell.Invalid;
} }
public bool CrushableBy(string[] crushClasses, Player owner) public bool CrushableBy(HashSet<string> crushClasses, Player owner)
{ {
// Crate can only be crushed if it is not in the air. // Crate can only be crushed if it is not in the air.
return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass); return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass);

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly HashSet<string> ValidTargets = new HashSet<string> { "Ground", "Water" }; public readonly HashSet<string> ValidTargets = new HashSet<string> { "Ground", "Water" };
[Desc("Which factions this crate action can occur for.")] [Desc("Which factions this crate action can occur for.")]
public readonly string[] ValidFactions = { }; public readonly HashSet<string> ValidFactions = new HashSet<string>();
[Desc("Is the new duplicates given to a specific owner, regardless of whom collected it?")] [Desc("Is the new duplicates given to a specific owner, regardless of whom collected it?")]
public readonly string Owner = null; public readonly string Owner = null;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string[] Units = { }; public readonly string[] Units = { };
[Desc("Factions that are allowed to trigger this action.")] [Desc("Factions that are allowed to trigger this action.")]
public readonly string[] ValidFactions = { }; public readonly HashSet<string> ValidFactions = new HashSet<string>();
[Desc("Override the owner of the newly spawned unit: e.g. Creeps or Neutral")] [Desc("Override the owner of the newly spawned unit: e.g. Creeps or Neutral")]
public readonly string Owner = null; public readonly string Owner = null;

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
self.Kill(crusher); self.Kill(crusher);
} }
public bool CrushableBy(string[] crushClasses, Player crushOwner) public bool CrushableBy(HashSet<string> crushClasses, Player crushOwner)
{ {
// Only make actor crushable if it is on the ground. // Only make actor crushable if it is on the ground.
if (!self.IsAtGroundLevel()) if (!self.IsAtGroundLevel())

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits; 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. " + [Desc("Spawns actors only if the selling player's faction is in this list. " +
"Leave empty to allow all factions by default.")] "Leave empty to allow all factions by default.")]
public readonly string[] Factions = { }; public readonly HashSet<string> Factions = new HashSet<string>();
public object Create(ActorInitializer init) { return new EmitInfantryOnSell(init.Self, this); } public object Create(ActorInitializer init) { return new EmitInfantryOnSell(init.Self, this); }
} }
@@ -40,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
this.info = info; this.info = info;
var factionsList = info.Factions; 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) { } public void Selling(Actor self) { }

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Warheads; using OpenRA.Mods.Common.Warheads;
using OpenRA.Traits; using OpenRA.Traits;
@@ -31,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Chance = 100; public readonly int Chance = 100;
[Desc("DeathType(s) to apply upon explosion.")] [Desc("DeathType(s) to apply upon explosion.")]
public readonly string[] DeathType = null; public readonly HashSet<string> DeathType = new HashSet<string>();
public object Create(ActorInitializer init) { return new Explodes(this); } public object Create(ActorInitializer init) { return new Explodes(this); }
} }
@@ -51,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
var warhead = e.Warhead as DamageWarhead; 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; return;
var weaponName = ChooseWeaponForExplosion(self); var weaponName = ChooseWeaponForExplosion(self);

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
class ExternalCapturesInfo : ITraitInfo class ExternalCapturesInfo : ITraitInfo
{ {
[Desc("Types of actors that it can capture, as long as the type also exists in the ExternalCapturable Type: trait.")] [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<string> CaptureTypes = new HashSet<string> { "building" };
[Desc("Destroy the unit after capturing.")] [Desc("Destroy the unit after capturing.")]
public readonly bool ConsumeActor = false; public readonly bool ConsumeActor = false;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class HarvesterInfo : ITraitInfo, Requires<MobileInfo> public class HarvesterInfo : ITraitInfo, Requires<MobileInfo>
{ {
public readonly string[] DeliveryBuildings = { }; public readonly HashSet<string> DeliveryBuildings = new HashSet<string>();
[Desc("How long (in ticks) to wait until (re-)checking for a nearby available DeliveryBuilding if not yet linked to one.")] [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; public readonly int SearchForDeliveryBuildingDelay = 125;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int HarvestFacings = 0; public readonly int HarvestFacings = 0;
[Desc("Which resources it can harvest.")] [Desc("Which resources it can harvest.")]
public readonly string[] Resources = { }; public readonly HashSet<string> Resources = new HashSet<string>();
[Desc("Percentage of maximum speed when fully loaded.")] [Desc("Percentage of maximum speed when fully loaded.")]
public readonly int FullyLoadedSpeed = 85; public readonly int FullyLoadedSpeed = 85;
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits
bool IsAcceptableProcType(Actor proc) bool IsAcceptableProcType(Actor proc)
{ {
return info.DeliveryBuildings.Length == 0 || return info.DeliveryBuildings.Count == 0 ||
info.DeliveryBuildings.Contains(proc.Info.Name); info.DeliveryBuildings.Contains(proc.Info.Name);
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Spawns remains of a husk actor with the correct facing.")] [Desc("Spawns remains of a husk actor with the correct facing.")]
public class HuskInfo : IOccupySpaceInfo, IFacingInfo public class HuskInfo : IOccupySpaceInfo, IFacingInfo
{ {
public readonly string[] AllowedTerrain = { }; public readonly HashSet<string> AllowedTerrain = new HashSet<string>();
public object Create(ActorInitializer init) { return new Husk(init, this); } public object Create(ActorInitializer init) { return new Husk(init, this); }

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Damage types that trigger prone state. Defined on the warheads.")] [Desc("Damage types that trigger prone state. Defined on the warheads.")]
public readonly string[] DamageTriggers = null; public readonly HashSet<string> DamageTriggers = new HashSet<string>();
[Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")] [Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")]
public readonly Dictionary<string, int> DamageModifiers = new Dictionary<string, int>(); public readonly Dictionary<string, int> DamageModifiers = new Dictionary<string, int>();
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {
var warhead = e.Warhead as DamageWarhead; 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; return;
if (!IsProne) if (!IsProne)

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds; public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
[Desc("e.g. crate, wall, infantry")] [Desc("e.g. crate, wall, infantry")]
public readonly string[] Crushes = { }; public readonly HashSet<string> Crushes = new HashSet<string>();
public readonly int WaitAverage = 5; public readonly int WaitAverage = 5;
@@ -237,7 +237,7 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
// If we cannot crush the other actor in our way, we are blocked. // 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; return true;
// If the other actor in our way cannot be crushed, we are blocked. // If the other actor in our way cannot be crushed, we are blocked.

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Used for bursted one-colored whole screen effects. Add this to the world actor.")] [Desc("Used for bursted one-colored whole screen effects. Add this to the world actor.")]
public class FlashPaletteEffectInfo : ITraitInfo public class FlashPaletteEffectInfo : ITraitInfo
{ {
public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "fog", "shroud" }; public readonly HashSet<string> ExcludePalettes = new HashSet<string> { "cursor", "chrome", "colorpicker", "fog", "shroud" };
[Desc("Measured in ticks.")] [Desc("Measured in ticks.")]
public readonly int Length = 20; public readonly int Length = 20;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
@@ -19,10 +20,10 @@ namespace OpenRA.Mods.Common.Traits
class GlobalLightingPaletteEffectInfo : ITraitInfo class GlobalLightingPaletteEffectInfo : ITraitInfo
{ {
[Desc("Do not modify graphics that use any palette in this list.")] [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<string> ExcludePalettes = new HashSet<string> { "cursor", "chrome", "colorpicker", "fog", "shroud", "alpha" };
[Desc("Do not modify graphics that start with these letters.")] [Desc("Do not modify graphics that start with these letters.")]
public readonly string[] ExcludePalettePrefixes = { }; public readonly HashSet<string> ExcludePalettePrefixes = new HashSet<string>();
public readonly float Red = 1f; public readonly float Red = 1f;
public readonly float Green = 1f; public readonly float Green = 1f;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Palette effect used for sprinkle \"animations\" on terrain tiles.")] [Desc("Palette effect used for sprinkle \"animations\" on terrain tiles.")]
class WaterPaletteRotationInfo : ITraitInfo class WaterPaletteRotationInfo : ITraitInfo
{ {
public readonly string[] ExcludePalettes = { }; public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.World, this); } public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.World, this); }
} }

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Group = null; public readonly string Group = null;
[Desc("Only enable this queue for certain factions.")] [Desc("Only enable this queue for certain factions.")]
public readonly string[] Factions = { }; public readonly HashSet<string> Factions = new HashSet<string>();
[Desc("Should the prerequisite remain enabled if the owner changes?")] [Desc("Should the prerequisite remain enabled if the owner changes?")]
public readonly bool Sticky = true; public readonly bool Sticky = true;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string[] RequiresPrerequisites = { }; public readonly string[] RequiresPrerequisites = { };
[Desc("Only grant this prerequisite for certain factions.")] [Desc("Only grant this prerequisite for certain factions.")]
public readonly string[] Factions = { }; public readonly HashSet<string> Factions = new HashSet<string>();
[Desc("Should it recheck everything when it is captured?")] [Desc("Should it recheck everything when it is captured?")]
public readonly bool ResetOnOwnerChange = false; public readonly bool ResetOnOwnerChange = false;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
@@ -17,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
public class ProximityCaptorInfo : ITraitInfo public class ProximityCaptorInfo : ITraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
public readonly string[] Types = { }; public readonly HashSet<string> Types = new HashSet<string>();
public object Create(ActorInitializer init) { return new ProximityCaptor(this); } 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 ProximityCaptor(ProximityCaptorInfo info) { Info = info; }
public bool HasAny(string[] typesList) public bool HasAny(IEnumerable<string> typesList)
{ {
return typesList.Any(flag => Info.Types.Contains(flag)); return Info.Types.Overlaps(typesList);
} }
} }
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool Permanent = false; public readonly bool Permanent = false;
public readonly int Range = 5; public readonly int Range = 5;
public readonly bool MustBeClear = false; public readonly bool MustBeClear = false;
public readonly string[] CaptorTypes = { "Vehicle", "Tank", "Infantry" }; public readonly HashSet<string> CaptorTypes = new HashSet<string> { "Vehicle", "Tank", "Infantry" };
public object Create(ActorInitializer init) { return new ProximityCapturable(init.Self, this); } public object Create(ActorInitializer init) { return new ProximityCapturable(init.Self, this); }
} }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
[PaletteReference] public readonly string Palette = "effect"; [PaletteReference] public readonly string Palette = "effect";
[Desc("Only do so when the terrain types match with the previous cell.")] [Desc("Only do so when the terrain types match with the previous cell.")]
public readonly string[] TerrainTypes = { }; public readonly HashSet<string> TerrainTypes = new HashSet<string>();
public object Create(ActorInitializer init) { return new LeavesTrails(this, init.Self); } public object Create(ActorInitializer init) { return new LeavesTrails(this, init.Self); }
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor can be sent to a structure for repairs.")] [Desc("This actor can be sent to a structure for repairs.")]
class RepairableInfo : ITraitInfo, Requires<HealthInfo> class RepairableInfo : ITraitInfo, Requires<HealthInfo>
{ {
public readonly string[] RepairBuildings = { "fix" }; public readonly HashSet<string> RepairBuildings = new HashSet<string> { "fix" };
[VoiceReference] public readonly string Voice = "Action"; [VoiceReference] public readonly string Voice = "Action";

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo> class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo>
{ {
[ActorReference] public readonly string[] Buildings = { "spen", "syrd" }; [ActorReference] public readonly HashSet<string> Buildings = new HashSet<string> { "spen", "syrd" };
public readonly int CloseEnough = 4; /* cells */ public readonly int CloseEnough = 4; /* cells */
public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); } public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Warheads; using OpenRA.Mods.Common.Warheads;
using OpenRA.Traits; 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).", [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.")] "If empty, this will be used as the default sound for all death types.")]
public readonly string[] DeathTypes = { }; public readonly HashSet<string> DeathTypes = new HashSet<string>();
public object Create(ActorInitializer init) { return new DeathSounds(this); } public object Create(ActorInitializer init) { return new DeathSounds(this); }
} }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Traits; using OpenRA.Traits;
@@ -16,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class TransformOnPassengerInfo : ITraitInfo public class TransformOnPassengerInfo : ITraitInfo
{ {
[ActorReference, FieldLoader.Require] public readonly string[] PassengerTypes = { }; [ActorReference, FieldLoader.Require] public readonly HashSet<string> PassengerTypes = new HashSet<string>();
[ActorReference] public readonly string OnEnter = null; [ActorReference] public readonly string OnEnter = null;
[ActorReference] public readonly string OnExit = null; [ActorReference] public readonly string OnExit = null;
public readonly bool SkipMakeAnims = false; public readonly bool SkipMakeAnims = false;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The terrain types that this actor can deploy on to receive these upgrades. " + [Desc("The terrain types that this actor can deploy on to receive these upgrades. " +
"Leave empty to allow any.")] "Leave empty to allow any.")]
public readonly string[] AllowedTerrainTypes = { }; public readonly HashSet<string> AllowedTerrainTypes = new HashSet<string>();
[Desc("Cursor to display when able to (un)deploy the actor.")] [Desc("Cursor to display when able to (un)deploy the actor.")]
public readonly string DeployCursor = "deploy"; public readonly string DeployCursor = "deploy";
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
this.self = self; this.self = self;
this.info = info; this.info = info;
manager = self.Trait<UpgradeManager>(); manager = self.Trait<UpgradeManager>();
checkTerrainType = info.AllowedTerrainTypes.Length > 0; checkTerrainType = info.AllowedTerrainTypes.Count > 0;
canTurn = self.Info.Traits.WithInterface<IFacingInfo>().Any(); canTurn = self.Info.Traits.WithInterface<IFacingInfo>().Any();
body = Exts.Lazy(self.TraitOrDefault<ISpriteBody>); body = Exts.Lazy(self.TraitOrDefault<ISpriteBody>);
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
[UpgradeUsedReference] [UpgradeUsedReference]
[Desc("The upgrade types which can enable or disable this trait.")] [Desc("The upgrade types which can enable or disable this trait.")]
public readonly string[] UpgradeTypes = { }; public readonly HashSet<string> UpgradeTypes = new HashSet<string>();
[Desc("The minimum upgrade level at which this trait is enabled.", "Defaults to 0 (enabled by default).")] [Desc("The minimum upgrade level at which this trait is enabled.", "Defaults to 0 (enabled by default).")]
public readonly int UpgradeMinEnabledLevel = 0; public readonly int UpgradeMinEnabledLevel = 0;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
public UpgradableTrait(InfoType info) public UpgradableTrait(InfoType info)
{ {
Info = 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) public bool AcceptsUpgradeLevel(Actor self, string type, int level)

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Primitives; using OpenRA.Primitives;
@@ -28,10 +29,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly int SpawnInterval = 180; public readonly int SpawnInterval = 180;
[Desc("Which terrain types can we drop on?")] [Desc("Which terrain types can we drop on?")]
public readonly string[] ValidGround = { "Clear", "Rough", "Road", "Ore", "Beach" }; public readonly HashSet<string> ValidGround = new HashSet<string> { "Clear", "Rough", "Road", "Ore", "Beach" };
[Desc("Which terrain types count as water?")] [Desc("Which terrain types count as water?")]
public readonly string[] ValidWater = { "Water" }; public readonly HashSet<string> ValidWater = new HashSet<string> { "Water" };
[Desc("Chance of generating a water crate instead of a land crate")] [Desc("Chance of generating a water crate instead of a land crate")]
public readonly float WaterChance = .2f; public readonly float WaterChance = .2f;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string ClassName = "Unlabeled"; public readonly string ClassName = "Unlabeled";
[Desc("Only available when selecting one of these factions.", "Leave empty for no restrictions.")] [Desc("Only available when selecting one of these factions.", "Leave empty for no restrictions.")]
public readonly string[] Factions = { }; public readonly HashSet<string> Factions = new HashSet<string>();
[Desc("The mobile construction vehicle.")] [Desc("The mobile construction vehicle.")]
public readonly string BaseActor = null; public readonly string BaseActor = null;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly int[] Size = { 0, 0 }; public readonly int[] Size = { 0, 0 };
[Desc("Type of smudge to apply to terrain.")] [Desc("Type of smudge to apply to terrain.")]
public readonly string[] SmudgeType = { }; public readonly HashSet<string> SmudgeType = new HashSet<string>();
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads
// Draw the smudges: // Draw the smudges:
foreach (var sc in allCells) 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; if (smudgeType == null) continue;
SmudgeLayer smudgeLayer; SmudgeLayer smudgeLayer;

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (path != null) if (path != null)
Install(path); 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) && (path = InstallUtils.GetMountedDisk(IsTFD)) != null)
InstallTFD(Platform.ResolvePath(path, "data1.hdr")); InstallTFD(Platform.ResolvePath(path, "data1.hdr"));
else else
@@ -91,10 +91,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
using (var cabExtractor = new InstallShieldCABExtractor(source)) using (var cabExtractor = new InstallShieldCABExtractor(source))
{ {
var denom = installData.InstallShieldCABFileIds.Length; var denom = installData.InstallShieldCABFileIds.Count;
var extractFiles = installData.ExtractFilesFromCD; var extractFiles = installData.ExtractFilesFromCD;
if (installData.InstallShieldCABFilePackageIds.Length > 0) if (installData.InstallShieldCABFilePackageIds.Count > 0)
denom += extractFiles.SelectMany(x => x.Value).Count(); denom += extractFiles.SelectMany(x => x.Value).Count();
var installPercent = 100 / denom; var installPercent = 100 / denom;

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
@@ -19,7 +20,7 @@ namespace OpenRA.Mods.D2k.Traits
{ {
[WeaponReference] [WeaponReference]
public readonly string Weapon = "weathering"; public readonly string Weapon = "weathering";
public readonly string[] SafeTerrain = { "Concrete" }; public readonly HashSet<string> SafeTerrain = new HashSet<string> { "Concrete" };
public readonly int DamageThreshold = 50; public readonly int DamageThreshold = 50;
public object Create(ActorInitializer init) { return new DamagedWithoutFoundation(init.Self, this); } public object Create(ActorInitializer init) { return new DamagedWithoutFoundation(init.Self, this); }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.D2k.Traits
[FieldLoader.Require] [FieldLoader.Require]
[Desc("The terrain types that this template will be placed on")] [Desc("The terrain types that this template will be placed on")]
public readonly string[] TerrainTypes = { }; public readonly HashSet<string> TerrainTypes = new HashSet<string>();
[Desc("Offset relative to the actor TopLeft. Not used if the template is PickAny")] [Desc("Offset relative to the actor TopLeft. Not used if the template is PickAny")]
public readonly CVec Offset = CVec.Zero; public readonly CVec Offset = CVec.Zero;

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
readonly MinelayerInfo info; readonly MinelayerInfo info;
readonly AmmoPool[] ammoPools; readonly AmmoPool[] ammoPools;
readonly IMove movement; readonly IMove movement;
readonly string[] rearmBuildings; readonly HashSet<string> rearmBuildings;
public LayMines(Actor self) public LayMines(Actor self)
{ {

View File

@@ -8,7 +8,7 @@
*/ */
#endregion #endregion
using System; using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("This unit's cloneable type is:")] [Desc("This unit's cloneable type is:")]
public readonly string[] Types = { }; public readonly HashSet<string> Types = new HashSet<string>();
} }
public class Cloneable { } public class Cloneable { }

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Traits
self.Kill(crusher); self.Kill(crusher);
} }
public bool CrushableBy(string[] crushClasses, Player owner) public bool CrushableBy(HashSet<string> crushClasses, Player owner)
{ {
return info.CrushClasses.Overlaps(crushClasses); return info.CrushClasses.Overlaps(crushClasses);
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Traits
public class MinelayerInfo : ITraitInfo public class MinelayerInfo : ITraitInfo
{ {
[ActorReference] public readonly string Mine = "minv"; [ActorReference] public readonly string Mine = "minv";
[ActorReference] public readonly string[] RearmBuildings = { "fix" }; [ActorReference] public readonly HashSet<string> RearmBuildings = new HashSet<string> { "fix" };
public readonly string AmmoPoolName = "primary"; public readonly string AmmoPoolName = "primary";

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Palette effect used for blinking \"animations\" on actors.")] [Desc("Palette effect used for blinking \"animations\" on actors.")]
class LightPaletteRotatorInfo : ITraitInfo class LightPaletteRotatorInfo : ITraitInfo
{ {
public readonly string[] ExcludePalettes = { }; public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
public object Create(ActorInitializer init) { return new LightPaletteRotator(this); } public object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
} }

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -16,7 +17,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
public class WithLandingCraftAnimationInfo : ITraitInfo, Requires<IMoveInfo>, Requires<WithSpriteBodyInfo>, Requires<CargoInfo> public class WithLandingCraftAnimationInfo : ITraitInfo, Requires<IMoveInfo>, Requires<WithSpriteBodyInfo>, Requires<CargoInfo>
{ {
public readonly string[] OpenTerrainTypes = { "Clear" }; public readonly HashSet<string> OpenTerrainTypes = new HashSet<string> { "Clear" };
[SequenceReference] public readonly string OpenSequence = "open"; [SequenceReference] public readonly string OpenSequence = "open";
[SequenceReference] public readonly string CloseSequence = "close"; [SequenceReference] public readonly string CloseSequence = "close";
[SequenceReference] public readonly string UnloadSequence = "unload"; [SequenceReference] public readonly string UnloadSequence = "unload";