From f8e1779f24c4df95672ebcb853011e1c0880da6e Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Sat, 5 Apr 2014 13:58:02 +1300 Subject: [PATCH] Add an option to cancel activities when captured to Capturable --- OpenRA.Mods.RA/Capturable.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Capturable.cs b/OpenRA.Mods.RA/Capturable.cs index 70f9478d65..3d8844ad43 100644 --- a/OpenRA.Mods.RA/Capturable.cs +++ b/OpenRA.Mods.RA/Capturable.cs @@ -9,8 +9,9 @@ #endregion using System.Linq; -using OpenRA.Traits; using OpenRA.FileFormats; +using OpenRA.Mods.RA.Activities; +using OpenRA.Traits; namespace OpenRA.Mods.RA { @@ -24,6 +25,7 @@ namespace OpenRA.Mods.RA public readonly bool AllowEnemies = true; [Desc("Health percentage the target must be at (or below) before it can be captured.")] public readonly float CaptureThreshold = 0.5f; + public readonly bool CancelActivity = false; public bool CanBeTargetedBy(Actor captor, Player owner) { @@ -48,5 +50,17 @@ namespace OpenRA.Mods.RA } } - class Capturable { } + class Capturable : INotifyCapture + { + public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) + { + var info = self.Info.Traits.Get(); + if (info.CancelActivity) + { + var stop = new Order("Stop", self, false); + foreach (var t in self.TraitsImplementing()) + t.ResolveOrder(self, stop); + } + } + } }