diff --git a/OpenRA.Mods.RA/Activities/Wait.cs b/OpenRA.Mods.RA/Activities/Wait.cs index b58fb7de63..0202057896 100644 --- a/OpenRA.Mods.RA/Activities/Wait.cs +++ b/OpenRA.Mods.RA/Activities/Wait.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using OpenRA.Traits; namespace OpenRA.Mods.RA.Activities @@ -26,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities public override Activity Tick(Actor self) { - return (remainingTicks-- == 0) ? NextActivity: this; + return (remainingTicks-- == 0) ? NextActivity : this; } public override void Cancel( Actor self ) @@ -38,4 +39,31 @@ namespace OpenRA.Mods.RA.Activities base.Cancel(self); } } + + public class WaitFor : Activity + { + Func f; + bool interruptable = true; + + public WaitFor(Func f) { this.f = f; } + public WaitFor(Func f, bool interruptable) + { + this.f = f; + this.interruptable = interruptable; + } + + public override Activity Tick(Actor self) + { + return (f != null && f()) ? NextActivity : this; + } + + public override void Cancel( Actor self ) + { + if (!interruptable) + return; + + f = null; + base.Cancel(self); + } + } }