diff --git a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs index b8e21ee9f5..a8580f8015 100644 --- a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs +++ b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs @@ -44,21 +44,22 @@ namespace OpenRA.Mods.Cnc { dockedHarv = harv; self.traits.Get().PlayCustomAnim(self, "active"); - }) ); - harv.QueueActivity( new Drag(startDock, endDock, 11) ); - harv.QueueActivity( new CallFunc( () => - { - self.World.AddFrameEndTask( w1 => + + harv.QueueActivity( new Drag(startDock, endDock, 12) ); + harv.QueueActivity( new CallFunc( () => { - harvester.Visible = false; - harvester.Deliver(harv, self); - }); + self.World.AddFrameEndTask( w1 => + { + harvester.Visible = false; + harvester.Deliver(harv, self); + }); + }, false ) ); + harv.QueueActivity( new Wait(18, false ) ); + harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) ); + harv.QueueActivity( new Drag(endDock, startDock, 12) ); + harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) ); + harv.QueueActivity( new Harvest() ); }) ); - harv.QueueActivity( new Wait(18) ); - harv.QueueActivity( new CallFunc( () => harvester.Visible = true) ); - harv.QueueActivity( new Drag(endDock, startDock, 11) ); - harv.QueueActivity( new CallFunc( () => dockedHarv = null) ); - harv.QueueActivity( new Harvest() ); } } diff --git a/OpenRA.Mods.RA/Activities/CallFunc.cs b/OpenRA.Mods.RA/Activities/CallFunc.cs index 1ccf27786f..d79d5c3eef 100644 --- a/OpenRA.Mods.RA/Activities/CallFunc.cs +++ b/OpenRA.Mods.RA/Activities/CallFunc.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -26,8 +26,14 @@ namespace OpenRA.Mods.RA.Activities public class CallFunc : IActivity { public CallFunc(Action a) { this.a = a; } - + public CallFunc(Action a, bool interruptable) + { + this.a = a; + this.interruptable = interruptable; + } + Action a; + bool interruptable; public IActivity NextActivity { get; set; } public IActivity Tick(Actor self) @@ -36,6 +42,13 @@ namespace OpenRA.Mods.RA.Activities return NextActivity; } - public void Cancel(Actor self) { a = null; NextActivity = null; } + public void Cancel(Actor self) + { + if (!interruptable) + return; + + a = null; + NextActivity = null; + } } } diff --git a/OpenRA.Mods.RA/Activities/Wait.cs b/OpenRA.Mods.RA/Activities/Wait.cs index 8f5bd1b83e..fd3a4049cd 100644 --- a/OpenRA.Mods.RA/Activities/Wait.cs +++ b/OpenRA.Mods.RA/Activities/Wait.cs @@ -25,16 +25,29 @@ namespace OpenRA.Mods.RA.Activities public class Wait : IActivity { int remainingTicks; - + bool interruptable = true; + public Wait(int period) { remainingTicks = period; } - + public Wait(int period, bool interruptable) + { + remainingTicks = period; + this.interruptable = interruptable; + } + public IActivity Tick(Actor self) { if (remainingTicks-- == 0) return NextActivity; return this; } - public void Cancel(Actor self) { remainingTicks = 0; NextActivity = null; } + public void Cancel(Actor self) + { + if (!interruptable) + return; + + remainingTicks = 0; + NextActivity = null; + } public IActivity NextActivity { get; set; } } }