Fix for #6161 queue commands for Plane/Heli (do not ignore Order.Queued in ResolveOrder())
This commit is contained in:
@@ -84,4 +84,26 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
yield return target;
|
yield return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FlyAndContinueWithCirclesWhenIdle : Fly
|
||||||
|
{
|
||||||
|
public FlyAndContinueWithCirclesWhenIdle(Actor self, Target t)
|
||||||
|
: base(self, t) { }
|
||||||
|
|
||||||
|
public FlyAndContinueWithCirclesWhenIdle(Actor self, Target t, WDist minRange, WDist maxRange)
|
||||||
|
: base(self, t, minRange, maxRange) { }
|
||||||
|
|
||||||
|
public override Activity Tick(Actor self)
|
||||||
|
{
|
||||||
|
var activity = base.Tick(self);
|
||||||
|
|
||||||
|
if (activity == null && !IsCanceled)
|
||||||
|
{
|
||||||
|
self.QueueActivity(new FlyCircle(self));
|
||||||
|
activity = NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,30 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
yield return target;
|
yield return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class HeliFlyAndLandWhenIdle : HeliFly
|
||||||
|
{
|
||||||
|
private readonly HelicopterInfo info;
|
||||||
|
|
||||||
|
public HeliFlyAndLandWhenIdle(Actor self, Target t, HelicopterInfo info)
|
||||||
|
: base(self, t)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Activity Tick(Actor self)
|
||||||
|
{
|
||||||
|
var activity = base.Tick(self);
|
||||||
|
|
||||||
|
if (activity == null && !IsCanceled && info.LandWhenIdle)
|
||||||
|
{
|
||||||
|
if (info.TurnToLand)
|
||||||
|
self.QueueActivity(new Turn(self, info.InitialFacing));
|
||||||
|
self.QueueActivity(new HeliLand(self, true));
|
||||||
|
activity = NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (NextActivity == null)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
var reservation = aircraft.Reservation;
|
var reservation = aircraft.Reservation;
|
||||||
@@ -43,7 +44,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var destination = rp != null ? rp.Location :
|
var destination = rp != null ? rp.Location :
|
||||||
(hasHost ? self.World.Map.CellContaining(host.CenterPosition) : self.Location);
|
(hasHost ? self.World.Map.CellContaining(host.CenterPosition) : self.Location);
|
||||||
|
|
||||||
|
if (NextActivity == null)
|
||||||
return new AttackMoveActivity(self, move.MoveTo(destination, 1));
|
return new AttackMoveActivity(self, move.MoveTo(destination, 1));
|
||||||
|
else
|
||||||
|
return NextActivity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (Reservation != null)
|
|
||||||
{
|
|
||||||
Reservation.Dispose();
|
|
||||||
Reservation = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (order.OrderString == "Move")
|
if (order.OrderString == "Move")
|
||||||
{
|
{
|
||||||
var cell = self.World.Map.Clamp(order.TargetLocation);
|
var cell = self.World.Map.Clamp(order.TargetLocation);
|
||||||
@@ -64,27 +58,19 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var target = Target.FromCell(self.World, cell);
|
var target = Target.FromCell(self.World, cell);
|
||||||
|
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.SetTargetLine(target, Color.Green);
|
||||||
self.CancelActivity();
|
|
||||||
self.QueueActivity(new HeliFly(self, target));
|
|
||||||
|
|
||||||
if (Info.LandWhenIdle)
|
if (!order.Queued)
|
||||||
|
UnReserve();
|
||||||
|
|
||||||
|
self.QueueActivity(order.Queued, new HeliFlyAndLandWhenIdle(self, target, Info));
|
||||||
|
}
|
||||||
|
else if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
if (Info.TurnToLand)
|
Action enter = () =>
|
||||||
self.QueueActivity(new Turn(self, Info.InitialFacing));
|
|
||||||
|
|
||||||
self.QueueActivity(new HeliLand(self, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (order.OrderString == "Enter")
|
|
||||||
{
|
{
|
||||||
if (Reservable.IsReserved(order.TargetActor))
|
if (Reservable.IsReserved(order.TargetActor))
|
||||||
{
|
self.QueueActivity(order.Queued, new HeliReturn(self));
|
||||||
self.CancelActivity();
|
|
||||||
self.QueueActivity(new HeliReturn(self));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var res = order.TargetActor.TraitOrDefault<Reservable>();
|
var res = order.TargetActor.TraitOrDefault<Reservable>();
|
||||||
@@ -96,14 +82,21 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
|
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
|
||||||
|
|
||||||
self.CancelActivity();
|
|
||||||
self.QueueActivity(new HeliFly(self, Target.FromPos(order.TargetActor.CenterPosition + offset)));
|
self.QueueActivity(new HeliFly(self, Target.FromPos(order.TargetActor.CenterPosition + offset)));
|
||||||
self.QueueActivity(new Turn(self, Info.InitialFacing));
|
self.QueueActivity(new Turn(self, Info.InitialFacing));
|
||||||
self.QueueActivity(new HeliLand(self, false));
|
self.QueueActivity(new HeliLand(self, false));
|
||||||
self.QueueActivity(new ResupplyAircraft(self));
|
self.QueueActivity(new ResupplyAircraft(self));
|
||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.QueueActivity(order.Queued, new CallFunc(enter));
|
||||||
|
|
||||||
|
if (!order.Queued)
|
||||||
|
UnReserve();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
UnReserve();
|
||||||
|
|
||||||
if (order.OrderString == "ReturnToBase")
|
if (order.OrderString == "ReturnToBase")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,25 +83,22 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!explored && !Info.MoveIntoShroud)
|
if (!explored && !Info.MoveIntoShroud)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!order.Queued)
|
||||||
UnReserve();
|
UnReserve();
|
||||||
|
|
||||||
var target = Target.FromCell(self.World, cell);
|
var target = Target.FromCell(self.World, cell);
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.SetTargetLine(target, Color.Green);
|
||||||
self.CancelActivity();
|
self.QueueActivity(order.Queued, new FlyAndContinueWithCirclesWhenIdle(self, target));
|
||||||
self.QueueActivity(new Fly(self, target));
|
|
||||||
self.QueueActivity(new FlyCircle(self));
|
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Enter")
|
else if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
if (Reservable.IsReserved(order.TargetActor)) return;
|
if (Reservable.IsReserved(order.TargetActor)) return;
|
||||||
|
|
||||||
|
if (!order.Queued)
|
||||||
UnReserve();
|
UnReserve();
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green);
|
self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green);
|
||||||
|
self.QueueActivity(order.Queued, Util.SequenceActivities(new ReturnToBase(self, order.TargetActor), new ResupplyAircraft(self)));
|
||||||
self.CancelActivity();
|
|
||||||
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
|
||||||
self.QueueActivity(new ResupplyAircraft(self));
|
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Stop")
|
else if (order.OrderString == "Stop")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user