Fix Follow formatting.
This commit is contained in:
@@ -15,8 +15,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
public class Follow : Activity
|
public class Follow : Activity
|
||||||
{
|
{
|
||||||
Target Target;
|
Target target;
|
||||||
int Range;
|
int range;
|
||||||
int nextPathTime;
|
int nextPathTime;
|
||||||
|
|
||||||
const int delayBetweenPathingAttempts = 20;
|
const int delayBetweenPathingAttempts = 20;
|
||||||
@@ -24,25 +24,25 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
public Follow(Target target, int range)
|
public Follow(Target target, int range)
|
||||||
{
|
{
|
||||||
Target = target;
|
this.target = target;
|
||||||
Range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick( Actor self )
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceled) return NextActivity;
|
if (IsCanceled || !target.IsValid)
|
||||||
if (!Target.IsValid) return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var inRange = ( Target.CenterPosition.ToCPos() - self.Location ).LengthSquared < Range * Range;
|
var inRange = (target.CenterPosition.ToCPos() - self.Location).LengthSquared < range * range;
|
||||||
|
|
||||||
if( inRange ) return this;
|
if (inRange || --nextPathTime > 0)
|
||||||
if (--nextPathTime > 0) return this;
|
return this;
|
||||||
|
|
||||||
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
|
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
|
||||||
delayBetweenPathingAttempts + delaySpread);
|
delayBetweenPathingAttempts + delaySpread);
|
||||||
|
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
return Util.SequenceActivities( mobile.MoveWithinRange( Target, new WRange(1024*Range) ), this );
|
return Util.SequenceActivities(mobile.MoveWithinRange(target, new WRange(1024*range)), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user