From 2f9ca36506c8d1933f8dafee2ea2785d41c4f103 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Thu, 27 Aug 2015 19:14:30 +0100 Subject: [PATCH] Update WeaponInfo to use HashSets for some fields directly. --- OpenRA.Game/GameRules/WeaponInfo.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index 3e5da809e0..aacdb0fea9 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -47,10 +47,10 @@ namespace OpenRA.GameRules public readonly bool Charges = false; [Desc("What types of targets are affected.")] - public readonly string[] ValidTargets = { "Ground", "Water" }; + public readonly HashSet ValidTargets = new HashSet { "Ground", "Water" }; [Desc("What types of targets are unaffected.", "Overrules ValidTargets.")] - public readonly string[] InvalidTargets = { }; + public readonly HashSet InvalidTargets = new HashSet(); [Desc("Delay in ticks between firing shots from the same ammo magazine.")] public readonly int BurstDelay = 5; @@ -64,14 +64,9 @@ namespace OpenRA.GameRules [FieldLoader.LoadUsing("LoadWarheads")] public readonly List Warheads = new List(); - readonly HashSet validTargetSet; - readonly HashSet invalidTargetSet; - public WeaponInfo(string name, MiniYaml content) { FieldLoader.Load(this, content); - validTargetSet = new HashSet(ValidTargets); - invalidTargetSet = new HashSet(InvalidTargets); } static object LoadProjectile(MiniYaml yaml) @@ -99,7 +94,7 @@ namespace OpenRA.GameRules public bool IsValidTarget(IEnumerable targetTypes) { - return validTargetSet.Overlaps(targetTypes) && !invalidTargetSet.Overlaps(targetTypes); + return ValidTargets.Overlaps(targetTypes) && !InvalidTargets.Overlaps(targetTypes); } /// Checks if the weapon is valid against (can target) the target.