Fix TakeOffOnCreation
This commit is contained in:
committed by
Matthias Mailänder
parent
c009f58980
commit
60a446123b
@@ -286,6 +286,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool RequireForceMove;
|
||||
|
||||
readonly int creationActivityDelay;
|
||||
readonly CPos[] creationRallyPoint;
|
||||
|
||||
bool notify = true;
|
||||
|
||||
@@ -320,6 +321,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Facing = init.GetValue<FacingInit, WAngle>(Info.InitialFacing);
|
||||
creationActivityDelay = init.GetValue<CreationActivityDelayInit, int>(0);
|
||||
creationRallyPoint = init.GetOrDefault<RallyPointInit>()?.Value;
|
||||
}
|
||||
|
||||
public WDist LandAltitude
|
||||
@@ -1219,19 +1221,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Activity ICreationActivity.GetCreationActivity()
|
||||
{
|
||||
return new AssociateWithAirfieldActivity(self, creationActivityDelay);
|
||||
return new AssociateWithAirfieldActivity(self, creationActivityDelay, creationRallyPoint);
|
||||
}
|
||||
|
||||
sealed class AssociateWithAirfieldActivity : Activity
|
||||
{
|
||||
readonly Aircraft aircraft;
|
||||
readonly int delay;
|
||||
readonly CPos[] rallyPoint;
|
||||
|
||||
public AssociateWithAirfieldActivity(Actor self, int delay = 0)
|
||||
public AssociateWithAirfieldActivity(Actor self, int delay, CPos[] rallyPoint)
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
IsInterruptible = false;
|
||||
this.delay = delay;
|
||||
this.rallyPoint = rallyPoint;
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
@@ -1253,8 +1257,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
|
||||
QueueChild(new TakeOff(self));
|
||||
if (rallyPoint != null && aircraft.Info.TakeOffOnCreation)
|
||||
{
|
||||
foreach (var cell in rallyPoint)
|
||||
self.QueueActivity(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));
|
||||
|
||||
aircraft.UnReserve();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user