make repath much less aggressive while attacking, to fix perf

This commit is contained in:
Chris Forbes
2010-12-27 19:17:02 +13:00
parent 59fdbe8725
commit 888fe35f08
2 changed files with 26 additions and 8 deletions

View File

@@ -18,6 +18,10 @@ namespace OpenRA.Mods.RA.Activities
{
Target Target;
int Range;
int nextPathTime;
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
public Follow(Target target, int range)
{
@@ -33,8 +37,12 @@ namespace OpenRA.Mods.RA.Activities
var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range;
if( inRange ) return this;
if (--nextPathTime > 0) return this;
var mobile = self.Trait<Mobile>();
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
delayBetweenPathingAttempts + delaySpread);
var mobile = self.Trait<Mobile>();
return Util.SequenceActivities( mobile.MoveWithinRange( Target, Range ), this );
}
}