Fix FlyAttack invalid target crash.

This commit is contained in:
Paul Chote
2020-02-15 23:14:52 +00:00
committed by atlimit8
parent 9a6602656b
commit 7e72cd262c

View File

@@ -222,8 +222,14 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnFirstRun(Actor self) protected override void OnFirstRun(Actor self)
{ {
QueueChild(new Fly(self, target, target.CenterPosition)); // The target may have died while this activity was queued
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); if (target.IsValidFor(self))
{
QueueChild(new Fly(self, target, target.CenterPosition));
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition));
}
else
Cancel(self);
} }
public override bool Tick(Actor self) public override bool Tick(Actor self)
@@ -261,8 +267,14 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnFirstRun(Actor self) protected override void OnFirstRun(Actor self)
{ {
QueueChild(new Fly(self, target, target.CenterPosition)); // The target may have died while this activity was queued
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); if (target.IsValidFor(self))
{
QueueChild(new Fly(self, target, target.CenterPosition));
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition));
}
else
Cancel(self);
} }
public override bool Tick(Actor self) public override bool Tick(Actor self)