Fix harvesters teleporting when produced
And allow to interrupt actor creation child activities
This commit is contained in:
@@ -1236,7 +1236,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public AssociateWithAirfieldActivity(Actor self, int delay, CPos[] rallyPoint)
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
IsInterruptible = false;
|
||||
this.delay = delay;
|
||||
this.rallyPoint = rallyPoint;
|
||||
}
|
||||
@@ -1245,25 +1244,26 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var host = aircraft.GetActorBelow();
|
||||
if (host != null)
|
||||
{
|
||||
aircraft.MakeReservation(host);
|
||||
|
||||
// Freshly created aircraft shouldn't block the exit, so we allow them to yield their reservation.
|
||||
aircraft.AllowYieldingReservation();
|
||||
}
|
||||
|
||||
if (delay > 0)
|
||||
QueueChild(new Wait(delay));
|
||||
}
|
||||
|
||||
public override bool Tick(Actor self)
|
||||
{
|
||||
if (!aircraft.Info.TakeOffOnCreation)
|
||||
{
|
||||
// Freshly created aircraft shouldn't block the exit, so we allow them to yield their reservation
|
||||
aircraft.AllowYieldingReservation();
|
||||
if (!aircraft.Info.TakeOffOnCreation || IsCanceling)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rallyPoint != null && aircraft.Info.TakeOffOnCreation)
|
||||
if (rallyPoint != null && rallyPoint.Length > 0)
|
||||
{
|
||||
foreach (var cell in rallyPoint)
|
||||
self.QueueActivity(new AttackMoveActivity(self, () => aircraft.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
QueueChild(new AttackMoveActivity(self, () => aircraft.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
}
|
||||
else if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
|
||||
QueueChild(new TakeOff(self));
|
||||
|
||||
@@ -979,7 +979,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public LeaveProductionActivity(Actor self, int delay, CPos[] rallyPoint, ReturnToCellActivity returnToCell)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
IsInterruptible = false;
|
||||
this.delay = delay;
|
||||
this.rallyPoint = rallyPoint;
|
||||
this.returnToCell = returnToCell;
|
||||
@@ -987,14 +986,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
// It is vital that ReturnToCell is queued first as it needs the power to intercept a possible cancellation of this activity.
|
||||
if (returnToCell != null)
|
||||
self.QueueActivity(returnToCell);
|
||||
QueueChild(returnToCell);
|
||||
else if (delay > 0)
|
||||
self.QueueActivity(new Wait(delay));
|
||||
QueueChild(new Wait(delay));
|
||||
|
||||
if (rallyPoint != null)
|
||||
foreach (var cell in rallyPoint)
|
||||
self.QueueActivity(new AttackMoveActivity(self, () => mobile.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
QueueChild(new AttackMoveActivity(self, () => mobile.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user