Replace arrays with sets.

In places where arrays were being treated as a set, just create a set directly. This reveals the intention of such collections better, and also improves performance by allowing set based methods to be used.
This commit is contained in:
RoosterDragon
2015-09-03 20:09:16 +01:00
parent 4f4bab2cdf
commit 901e604cf3
19 changed files with 43 additions and 38 deletions

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
@@ -19,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sound to play when being crushed.")]
public readonly string CrushSound = null;
[Desc("Which crush classes does this actor belong to.")]
public readonly string[] CrushClasses = { "infantry" };
public readonly HashSet<string> CrushClasses = new HashSet<string> { "infantry" };
[Desc("Probability of mobile actors noticing and evading a crush attempt.")]
public readonly int WarnProbability = 75;
[Desc("Will friendly units just crush me instead of pathing around.")]
@@ -72,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
if (!info.CrushedByFriendlies && crushOwner.IsAlliedWith(self.Owner))
return false;
return info.CrushClasses.Intersect(crushClasses).Any();
return info.CrushClasses.Overlaps(crushClasses);
}
}
}