Hack around the Lua API.

This commit is contained in:
Paul Chote
2016-09-26 17:48:25 +01:00
parent 3487d6bad5
commit 34b10dcb77
7 changed files with 18 additions and 14 deletions

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Activities
// TODO: This should check whether there is ammo left that is actually suitable for the target // TODO: This should check whether there is ammo left that is actually suitable for the target
if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo())) if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo()))
return ActivityUtils.SequenceActivities(new ReturnToBase(self), this); return ActivityUtils.SequenceActivities(new ReturnToBase(self, aircraft.Info.AbortOnResupply), this);
if (attackPlane != null) if (attackPlane != null)
attackPlane.DoAttack(self, target); attackPlane.DoAttack(self, target);

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Activities
// If any AmmoPool is depleted and no weapon is valid against target, return to helipad to reload and then resume the activity // If any AmmoPool is depleted and no weapon is valid against target, return to helipad to reload and then resume the activity
if (ammoPools.Any(x => !x.Info.SelfReloads && !x.HasAmmo()) && !attackHeli.HasAnyValidWeapons(target)) if (ammoPools.Any(x => !x.Info.SelfReloads && !x.HasAmmo()) && !attackHeli.HasAnyValidWeapons(target))
return ActivityUtils.SequenceActivities(new HeliReturnToBase(self), this); return ActivityUtils.SequenceActivities(new HeliReturnToBase(self, helicopter.Info.AbortOnResupply), this);
var dist = target.CenterPosition - self.CenterPosition; var dist = target.CenterPosition - self.CenterPosition;

View File

@@ -20,11 +20,13 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Aircraft heli; readonly Aircraft heli;
readonly bool alwaysLand; readonly bool alwaysLand;
readonly bool abortOnResupply;
public HeliReturnToBase(Actor self, bool alwaysLand = true) public HeliReturnToBase(Actor self, bool abortOnResupply, bool alwaysLand = true)
{ {
heli = self.Trait<Aircraft>(); heli = self.Trait<Aircraft>();
this.alwaysLand = alwaysLand; this.alwaysLand = alwaysLand;
this.abortOnResupply = abortOnResupply;
} }
public Actor ChooseHelipad(Actor self) public Actor ChooseHelipad(Actor self)
@@ -82,7 +84,7 @@ namespace OpenRA.Mods.Common.Activities
new Turn(self, initialFacing), new Turn(self, initialFacing),
new HeliLand(self, false), new HeliLand(self, false),
new ResupplyAircraft(self), new ResupplyAircraft(self),
!heli.Info.AbortOnResupply ? NextActivity : null); !abortOnResupply ? NextActivity : null);
} }
return ActivityUtils.SequenceActivities( return ActivityUtils.SequenceActivities(

View File

@@ -23,14 +23,16 @@ namespace OpenRA.Mods.Common.Activities
readonly Aircraft plane; readonly Aircraft plane;
readonly AircraftInfo planeInfo; readonly AircraftInfo planeInfo;
readonly bool alwaysLand; readonly bool alwaysLand;
readonly bool abortOnResupply;
bool isCalculated; bool isCalculated;
Actor dest; Actor dest;
WPos w1, w2, w3; WPos w1, w2, w3;
public ReturnToBase(Actor self, Actor dest = null, bool alwaysLand = true) public ReturnToBase(Actor self, bool abortOnResupply, Actor dest = null, bool alwaysLand = true)
{ {
this.dest = dest; this.dest = dest;
this.alwaysLand = alwaysLand; this.alwaysLand = alwaysLand;
this.abortOnResupply = abortOnResupply;
plane = self.Trait<Aircraft>(); plane = self.Trait<Aircraft>();
planeInfo = self.Info.TraitInfo<AircraftInfo>(); planeInfo = self.Info.TraitInfo<AircraftInfo>();
} }
@@ -149,7 +151,7 @@ namespace OpenRA.Mods.Common.Activities
landingProcedures.Add(new ResupplyAircraft(self)); landingProcedures.Add(new ResupplyAircraft(self));
} }
if (!planeInfo.AbortOnResupply) if (!abortOnResupply)
landingProcedures.Add(NextActivity); landingProcedures.Add(NextActivity);
return ActivityUtils.SequenceActivities(landingProcedures.ToArray()); return ActivityUtils.SequenceActivities(landingProcedures.ToArray());

View File

@@ -42,9 +42,9 @@ namespace OpenRA.Mods.Common.Scripting
public void ReturnToBase(Actor airfield = null) public void ReturnToBase(Actor airfield = null)
{ {
if (isPlane) if (isPlane)
Self.QueueActivity(new ReturnToBase(Self, airfield)); Self.QueueActivity(new ReturnToBase(Self, false, airfield));
else else
Self.QueueActivity(new HeliReturnToBase(Self)); Self.QueueActivity(new HeliReturnToBase(Self, false));
} }
[ScriptActorPropertyActivity] [ScriptActorPropertyActivity]

View File

@@ -562,9 +562,9 @@ namespace OpenRA.Mods.Common.Traits
if (Reservable.IsReserved(order.TargetActor)) if (Reservable.IsReserved(order.TargetActor))
{ {
if (IsPlane) if (IsPlane)
self.QueueActivity(new ReturnToBase(self)); self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply));
else else
self.QueueActivity(new HeliReturnToBase(self)); self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply));
} }
else else
{ {
@@ -573,7 +573,7 @@ namespace OpenRA.Mods.Common.Traits
if (IsPlane) if (IsPlane)
{ {
self.QueueActivity(order.Queued, ActivityUtils.SequenceActivities( self.QueueActivity(order.Queued, ActivityUtils.SequenceActivities(
new ReturnToBase(self, order.TargetActor), new ReturnToBase(self, Info.AbortOnResupply, order.TargetActor),
new ResupplyAircraft(self))); new ResupplyAircraft(self)));
} }
else else
@@ -621,9 +621,9 @@ namespace OpenRA.Mods.Common.Traits
UnReserve(); UnReserve();
self.CancelActivity(); self.CancelActivity();
if (IsPlane) if (IsPlane)
self.QueueActivity(new ReturnToBase(self, null, false)); self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply, null, false));
else else
self.QueueActivity(new HeliReturnToBase(self, false)); self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply, false));
} }
} }

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
var airfield = ReturnToBase.ChooseAirfield(self, true); var airfield = ReturnToBase.ChooseAirfield(self, true);
if (airfield != null) if (airfield != null)
{ {
self.QueueActivity(new ReturnToBase(self, airfield)); self.QueueActivity(new ReturnToBase(self, aircraftInfo.AbortOnResupply, airfield));
self.QueueActivity(new ResupplyAircraft(self)); self.QueueActivity(new ResupplyAircraft(self));
} }
else else