Fix aircraft fly endlessly in a circle when ordered to attack inside own turning radius

This commit is contained in:
Jonathan Gustafsson
2014-12-07 13:33:31 +01:00
parent 51f874fae2
commit d7f321e04d

View File

@@ -10,6 +10,7 @@
using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Traits;
using OpenRA.Traits; using OpenRA.Traits;
using System.Linq;
namespace OpenRA.Mods.RA.Activities namespace OpenRA.Mods.RA.Activities
{ {
@@ -17,6 +18,7 @@ namespace OpenRA.Mods.RA.Activities
{ {
readonly Target target; readonly Target target;
Activity inner; Activity inner;
int ticksUntilTurn = 50;
public FlyAttack(Target target) { this.target = target; } public FlyAttack(Target target) { this.target = target; }
@@ -38,9 +40,11 @@ namespace OpenRA.Mods.RA.Activities
if (IsCanceled) if (IsCanceled)
return NextActivity; return NextActivity;
inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(50)); if (target.IsInRange(self.CenterPosition, attack.Armaments.Select(a => a.Weapon.MinRange).Min()))
inner = Util.SequenceActivities(new FlyTimed(ticksUntilTurn), new Fly(self, target), new FlyTimed(ticksUntilTurn));
else
inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn));
} }
inner = Util.RunActivity(self, inner); inner = Util.RunActivity(self, inner);
return this; return this;