OccupiedCells and TargetableCells must return arrays, not just enumerables.

This allows callers to efficiently enumerate these returned collections without the allocation and overhead imposed by the IEnumerable interface. All implementations were already returning arrays, so this only required a signature change.
This commit is contained in:
RoosterDragon
2017-11-17 21:23:17 +00:00
committed by Pavel Penev
parent da036c5728
commit 62ab6ae6f1
10 changed files with 13 additions and 15 deletions

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
self.QueueActivity(new Drag(self, CenterPosition, finalPosition, distance / dragSpeed));
}
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return new[] { Pair.New(TopLeft, SubCell.FullCell) }; }
public Pair<CPos, SubCell>[] OccupiedCells() { return new[] { Pair.New(TopLeft, SubCell.FullCell) }; }
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)