Fix crash in CaptureActor.Tick when trying to capture a dead actor

This commit is contained in:
Scott_NZ
2013-03-13 11:14:45 +13:00
parent e4806e4d39
commit 6bbef8d33f

View File

@@ -22,10 +22,6 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick(Actor self)
{
var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
var health = target.Trait<Health>();
int damage = (int)(0.25 * health.MaxHP);
if (IsCanceled)
return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead())
@@ -33,6 +29,10 @@ namespace OpenRA.Mods.RA.Activities
if (target.Owner == self.Owner)
return NextActivity;
var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
var health = target.Trait<Health>();
int damage = (int)(0.25 * health.MaxHP);
// Need to be next to building, TODO: stop capture when going away
var mobile = self.Trait<Mobile>();
var nearest = target.OccupiesSpace.NearestCellTo(mobile.toCell);