remove some crashes
This commit is contained in:
@@ -14,34 +14,34 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
class CaptureBuilding : IActivity
|
class CaptureBuilding : IActivity
|
||||||
{
|
{
|
||||||
Actor target;
|
Target target;
|
||||||
|
|
||||||
public CaptureBuilding(Actor target) { this.target = target; }
|
public CaptureBuilding(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;
|
||||||
if ((target.Location - self.Location).Length > 1)
|
if ((target.Actor.Location - self.Location).Length > 1)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
target.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
// momentarily remove from world so the ownership queries don't get confused
|
// momentarily remove from world so the ownership queries don't get confused
|
||||||
var oldOwner = target.Owner;
|
var oldOwner = target.Actor.Owner;
|
||||||
w.Remove(target);
|
w.Remove(target.Actor);
|
||||||
target.Owner = self.Owner;
|
target.Actor.Owner = self.Owner;
|
||||||
w.Add(target);
|
w.Add(target.Actor);
|
||||||
|
|
||||||
foreach (var t in target.TraitsImplementing<INotifyCapture>())
|
foreach (var t in target.Actor.TraitsImplementing<INotifyCapture>())
|
||||||
t.OnCapture(target, self, oldOwner, self.Owner);
|
t.OnCapture(target.Actor, self, oldOwner, self.Owner);
|
||||||
|
|
||||||
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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,26 +15,23 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
class Demolish : IActivity
|
class Demolish : IActivity
|
||||||
{
|
{
|
||||||
Actor target;
|
Target target;
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
|
|
||||||
public Demolish( Actor target )
|
public Demolish( Actor target ) { this.target = Target.FromActor(target); }
|
||||||
{
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (target == null || target.IsDead()) return NextActivity;
|
if (!target.IsValid) return NextActivity;
|
||||||
if ((target.Location - self.Location).Length > 1)
|
if ((target.Actor.Location - self.Location).Length > 1)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25 * 2,
|
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25 * 2,
|
||||||
() => target.Kill(self))));
|
() => { if (target.IsValid) target.Actor.Kill(self); })));
|
||||||
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