Fix and optimize FindTilesInCircle

This commit is contained in:
Pavlos Touboulidis
2014-06-21 02:18:55 +03:00
parent 1c511ea6eb
commit daed053a57
7 changed files with 42 additions and 50 deletions

View File

@@ -58,7 +58,9 @@ namespace OpenRA.Mods.RA
var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height;
MapControl = world.Actors
.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == player && a.HasTrait<RevealsShroud>())
.SelectMany(a => world.Map.FindTilesInCircle(a.Location, a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(50)).Range / 1024))
.SelectMany(a => world.Map.FindTilesInCircle(
a.Location,
a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(Map.MaxTilesInCircleRange)).Range / 1024))
.Distinct()
.Count() / total;
}