Cancel carryall transport request when cancelling order.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
@@ -21,12 +22,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly IMove movement;
|
||||
readonly Harvester harv;
|
||||
readonly Actor targetActor;
|
||||
readonly INotifyHarvesterAction[] notifyHarvesterActions;
|
||||
|
||||
public DeliverResources(Actor self, Actor targetActor = null)
|
||||
{
|
||||
movement = self.Trait<IMove>();
|
||||
harv = self.Trait<Harvester>();
|
||||
this.targetActor = targetActor;
|
||||
notifyHarvesterActions = self.TraitsImplementing<INotifyHarvesterAction>().ToArray();
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
@@ -57,7 +60,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
|
||||
if (self.Location != proc.Location + iao.DeliveryOffset)
|
||||
{
|
||||
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
foreach (var n in notifyHarvesterActions)
|
||||
n.MovingToRefinery(self, proc);
|
||||
|
||||
QueueChild(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0));
|
||||
@@ -68,5 +71,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
iao.OnDock(self, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Cancel(Actor self, bool keepQueue = false)
|
||||
{
|
||||
foreach (var n in notifyHarvesterActions)
|
||||
n.MovementCancelled(self);
|
||||
|
||||
base.Cancel(self, keepQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
@@ -26,6 +27,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly BodyOrientation body;
|
||||
readonly IMove move;
|
||||
readonly CPos targetCell;
|
||||
readonly INotifyHarvesterAction[] notifyHarvesterActions;
|
||||
|
||||
public HarvestResource(Actor self, CPos targetCell)
|
||||
{
|
||||
@@ -37,6 +39,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
claimLayer = self.World.WorldActor.Trait<ResourceClaimLayer>();
|
||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
this.targetCell = targetCell;
|
||||
notifyHarvesterActions = self.TraitsImplementing<INotifyHarvesterAction>().ToArray();
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
@@ -55,7 +58,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Move towards the target cell
|
||||
if (self.Location != targetCell)
|
||||
{
|
||||
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
foreach (var n in notifyHarvesterActions)
|
||||
n.MovingToResources(self, targetCell);
|
||||
|
||||
self.SetTargetLine(Target.FromCell(self.World, targetCell), Color.Red, false);
|
||||
@@ -84,7 +87,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
harv.AcceptResource(self, resource);
|
||||
|
||||
foreach (var t in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
foreach (var t in notifyHarvesterActions)
|
||||
t.Harvested(self, resource);
|
||||
|
||||
QueueChild(new Wait(harvInfo.BaleLoadDelay));
|
||||
@@ -95,5 +98,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
claimLayer.RemoveClaim(self);
|
||||
}
|
||||
|
||||
public override void Cancel(Actor self, bool keepQueue = false)
|
||||
{
|
||||
foreach (var n in notifyHarvesterActions)
|
||||
n.MovementCancelled(self);
|
||||
|
||||
base.Cancel(self, keepQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Cancel(Actor self, bool keepQueue = false)
|
||||
{
|
||||
foreach (var t in transportCallers)
|
||||
t.MovementCancelled(self);
|
||||
|
||||
base.Cancel(self, keepQueue);
|
||||
}
|
||||
|
||||
void OnResupplyEnding(Actor self)
|
||||
{
|
||||
if (aircraft != null)
|
||||
|
||||
@@ -365,11 +365,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.SetTargetLine(order.Target, Color.Green);
|
||||
self.QueueActivity(order.Queued, new FindAndDeliverResources(self, targetActor));
|
||||
}
|
||||
else if (order.OrderString == "Stop" || order.OrderString == "Move")
|
||||
{
|
||||
foreach (var n in notifyHarvesterAction)
|
||||
n.MovementCancelled(self);
|
||||
}
|
||||
}
|
||||
|
||||
PipType GetPipAt(int i)
|
||||
|
||||
Reference in New Issue
Block a user