Add MinRange plumbing to attack activities.

This commit is contained in:
Paul Chote
2014-01-13 21:43:26 +13:00
parent f5a44f3c41
commit 887a515e14
12 changed files with 25 additions and 26 deletions

View File

@@ -25,13 +25,10 @@ namespace OpenRA.Mods.RA.Activities
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
public Attack(Target target, WRange range)
: this(target, range, true) {}
public Attack(Target target, WRange range, bool allowMovement)
public Attack(Actor self, Target target, WRange minRange, WRange maxRange, bool allowMovement)
{
Target = target;
Range = range;
Range = maxRange;
AllowMovement = allowMovement;
}

View File

@@ -17,13 +17,15 @@ namespace OpenRA.Mods.RA.Activities
{
Target target;
Plane plane;
WRange range;
WRange minRange;
WRange maxRange;
public FlyFollow(Actor self, Target target, WRange range)
public FlyFollow(Actor self, Target target, WRange minRange, WRange maxRange)
{
this.target = target;
plane = self.Trait<Plane>();
this.range = range;
this.minRange = minRange;
this.maxRange = maxRange;
}
public override Activity Tick(Actor self)
@@ -31,13 +33,13 @@ namespace OpenRA.Mods.RA.Activities
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
if (target.IsInRange(self.CenterPosition, range))
if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange))
{
Fly.FlyToward(self, plane, plane.Facing, plane.Info.CruiseAltitude);
return this;
}
return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), this);
return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), this);
}
}
}

View File

@@ -22,11 +22,11 @@ namespace OpenRA.Mods.RA.Activities
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
public Follow(Actor self, Target target, WRange range)
public Follow(Actor self, Target target, WRange minRange, WRange maxRange)
{
this.target = target;
move = self.Trait<IMove>();
this.range = range;
this.range = maxRange;
}
public override Activity Tick(Actor self)

View File

@@ -12,11 +12,10 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
/* non-turreted attack */
public class Heal : Attack
{
public Heal(Target target, WRange range, bool allowMovement)
: base(target, range, allowMovement) { }
public Heal(Actor self, Target target, WRange minRange, WRange maxRange, bool allowMovement)
: base(self, target, minRange, maxRange, allowMovement) { }
protected override Activity InnerTick(Actor self, AttackBase attack)
{