make attackmove on spawn work properly for things that cant attackmove

This commit is contained in:
Chris Forbes
2012-04-25 21:05:49 +12:00
parent 49f3f740e3
commit 89025a3042
2 changed files with 11 additions and 6 deletions

View File

@@ -42,11 +42,10 @@ namespace OpenRA.Mods.RA
return null;
}
void Activate(Actor self)
{
self.CancelActivity();
self.QueueActivity(new AttackMoveActivity(mobile.MoveTo(TargetLocation.Value, 1)));
self.QueueActivity(new AttackMoveActivity(self, mobile.MoveTo(TargetLocation.Value, 1)));
self.SetTargetLine(Target.FromCell(TargetLocation.Value), Color.Red);
}
@@ -75,16 +74,21 @@ namespace OpenRA.Mods.RA
{
Activity inner;
int scanTicks;
AutoTarget autoTarget;
const int ScanInterval = 7;
public AttackMoveActivity( Activity inner ) { this.inner = inner; }
public AttackMoveActivity( Actor self, Activity inner )
{
this.inner = inner;
this.autoTarget = self.TraitOrDefault<AutoTarget>();
}
public override Activity Tick( Actor self )
{
if (--scanTicks <= 0)
if (autoTarget != null && --scanTicks <= 0)
{
self.Trait<AutoTarget>().ScanAndAttack(self);
autoTarget.ScanAndAttack(self);
scanTicks = ScanInterval;
}