Refactor AutoTarget scan and GPS interaction, and cache trait lookup for a slight performance boost

This commit is contained in:
ScottNZ
2014-06-07 02:05:10 +12:00
parent 5784444720
commit 7e6f7c51e1
10 changed files with 39 additions and 60 deletions

View File

@@ -147,23 +147,12 @@ namespace OpenRA.Mods.RA
nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);
var inRange = self.World.FindActorsInCircle(self.CenterPosition, range);
if (self.Owner.HasFogVisibility())
{
return inRange
.Where(a => a.AppearsHostileTo(self))
.Where(a => !a.HasTrait<AutoTargetIgnore>())
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
.ClosestTo(self);
}
else
{
return inRange
.Where(a => a.AppearsHostileTo(self))
.Where(a => !a.HasTrait<AutoTargetIgnore>())
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
.Where(a => self.Owner.Shroud.IsTargetable(a))
.ClosestTo(self);
}
return inRange
.Where(a => a.AppearsHostileTo(self))
.Where(a => !a.HasTrait<AutoTargetIgnore>())
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
.Where(a => self.Owner.Shroud.IsTargetable(a))
.ClosestTo(self);
}
}