Add TakeOffOnCreation and TakeOffOnResupply to Aircraft

Before this, it was impossible to replicate the behavior of the original games (staying on pad/airfield after reload) without hacking around in Mods.Common.
This allows modders to disable these without meddling with code.
This commit is contained in:
reaperrr
2017-07-14 05:33:51 +02:00
committed by Matthias Mailänder
parent 5cfb5aaf2d
commit c9ff362ea2
5 changed files with 15 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
if (host == null)
return;
if (aircraft.IsPlane)
if (!aircraft.Info.TakeOffOnResupply)
{
ChildActivity = ActivityUtils.SequenceActivities(
aircraft.GetResupplyActivities(host)
@@ -38,12 +38,13 @@ namespace OpenRA.Mods.Common.Activities
}
else
{
// Helicopters should take off from their helipad immediately after resupplying.
// HACK: Append NextInQueue to TakeOff to avoid moving to the Rallypoint (if NextInQueue is non-null).
ChildActivity = ActivityUtils.SequenceActivities(
aircraft.GetResupplyActivities(host)
.Append(new AllowYieldingReservation(self))
.Append(new TakeOff(self)).Append(NextInQueue).ToArray());
.Append(new TakeOff(self))
.Append(NextInQueue)
.ToArray());
}
}

View File

@@ -78,6 +78,12 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Does this actor cancel its previous activity after resupplying?")]
public readonly bool AbortOnResupply = true;
[Desc("Does this actor automatically take off after resupplying?")]
public readonly bool TakeOffOnResupply = false;
[Desc("Does this actor automatically take off after creation?")]
public readonly bool TakeOffOnCreation = true;
[Desc("Altitude at which the aircraft considers itself landed.")]
public readonly WDist LandAltitude = WDist.Zero;
@@ -264,7 +270,8 @@ namespace OpenRA.Mods.Common.Traits
if (host == null)
return;
self.QueueActivity(new TakeOff(self));
if (Info.TakeOffOnCreation)
self.QueueActivity(new TakeOff(self));
}
// Add land activity if LandOnCondidion resolves to true and the actor can land at the current location.

View File

@@ -272,6 +272,7 @@
AirborneCondition: airborne
CruisingCondition: cruising
CanHover: True
TakeOffOnResupply: true
HiddenUnderFog:
Type: GroundPosition
ActorLostNotification:

View File

@@ -548,6 +548,7 @@
CanHover: True
CruisingCondition: cruising
WaitDistanceFromResupplyBase: 4c0
TakeOffOnResupply: true
GpsDot:
String: Helicopter
Hovers@CRUISING:

View File

@@ -820,6 +820,7 @@
CruiseAltitude: 2048
CanHover: True
CruisingCondition: cruising
TakeOffOnResupply: true
Hovers@CRUISING:
RequiresCondition: cruising