fix crash on engineer repair if the target building goes away
This commit is contained in:
@@ -14,25 +14,25 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
class RepairBuilding : IActivity
|
class RepairBuilding : IActivity
|
||||||
{
|
{
|
||||||
Actor target;
|
Target target;
|
||||||
|
|
||||||
public RepairBuilding(Actor target) { this.target = target; }
|
public RepairBuilding(Actor target) { this.target = Target.FromActor(target); }
|
||||||
|
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (target == null || target.IsDead()) return NextActivity;
|
if (!target.IsValid) return NextActivity;
|
||||||
var health = target.Trait<Health>();
|
var health = target.Actor.Trait<Health>();
|
||||||
if (health.DamageState == DamageState.Undamaged)
|
if (health.DamageState == DamageState.Undamaged)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
target.InflictDamage(self, -health.MaxHP, null);
|
target.Actor.InflictDamage(self, -health.MaxHP, null);
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
public void Cancel(Actor self) { target = Target.None; NextActivity = null; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user