Use HashSets instead of .Distinct
And don't cast to array / list where unnecessary
This commit is contained in:
@@ -96,11 +96,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||
{
|
||||
var tiles = CellsMatching(xy, footprint, info.Dimensions);
|
||||
var units = new List<Actor>();
|
||||
var units = new HashSet<Actor>();
|
||||
foreach (var t in tiles)
|
||||
units.AddRange(Self.World.ActorMap.GetActorsAt(t));
|
||||
foreach (var a in Self.World.ActorMap.GetActorsAt(t))
|
||||
units.Add(a);
|
||||
|
||||
return units.Distinct().Where(a =>
|
||||
return units.Where(a =>
|
||||
{
|
||||
if (!info.ValidRelationships.HasRelationship(Self.Owner.RelationshipWith(a.Owner)))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user