FindAndDeliverResources, trivial optimizations.
This commit is contained in:
@@ -110,11 +110,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Correct for SubCell offset
|
||||
target -= world.Map.Grid.OffsetOfSubCell(srcSub);
|
||||
|
||||
var rangeLengthSquared = range.LengthSquared;
|
||||
var map = world.Map;
|
||||
|
||||
// Select only the tiles that are within range from the requested SubCell
|
||||
// This assumes that the SubCell does not change during the path traversal
|
||||
var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Length / 1024 + 1)
|
||||
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.LengthSquared
|
||||
&& mobile.Info.CanEnterCell(self.World, self, t));
|
||||
var tilesInRange = map.FindTilesInCircle(targetCell, range.Length / 1024 + 1)
|
||||
.Where(t => (map.CenterOfCell(t) - target).LengthSquared <= rangeLengthSquared
|
||||
&& mobile.Info.CanEnterCell(world, self, t));
|
||||
|
||||
// See if there is any cell within range that does not involve a cross-domain request
|
||||
// Really, we only need to check the circle perimeter, but it's not clear that would be a performance win
|
||||
|
||||
Reference in New Issue
Block a user