From 5e2df2c39a99bee2af56741653b11381cbc82261 Mon Sep 17 00:00:00 2001 From: David Russell Date: Tue, 16 Dec 2014 01:46:58 +0000 Subject: [PATCH] Decloak on demolish and infiltrate Per issue #7028, infiltrating or demolishing a building will now cause an infantry unit to decloak (if it has a cloak ability). This behaviour is configurable (defaults to true in both cases) using the DecloakOnInfiltrate and DecloakOnDemolish options. --- AUTHORS | 1 + OpenRA.Mods.RA/Activities/Demolish.cs | 7 +++++++ OpenRA.Mods.RA/Activities/Infiltrate.cs | 9 +++++++++ OpenRA.Mods.RA/Traits/Cloak.cs | 2 ++ 4 files changed, 19 insertions(+) diff --git a/AUTHORS b/AUTHORS index 4720f5c9a6..6add69e3e2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,6 +36,7 @@ Also thanks to: * D2k Sardaukar * Daniel Derejvanik (Harisson) * Danny Keary (Dan9550) + * David Russell (DavidARussell) * DeadlySurprise * Erasmus Schroder (rasco) * Eric Bajumpaa (SteelPhase) diff --git a/OpenRA.Mods.RA/Activities/Demolish.cs b/OpenRA.Mods.RA/Activities/Demolish.cs index 9f6c34cc54..2bcd0a461c 100644 --- a/OpenRA.Mods.RA/Activities/Demolish.cs +++ b/OpenRA.Mods.RA/Activities/Demolish.cs @@ -13,6 +13,7 @@ using System.Linq; using OpenRA.Activities; using OpenRA.Effects; using OpenRA.Traits; +using OpenRA.Mods.RA.Traits; namespace OpenRA.Mods.RA.Activities { @@ -26,6 +27,8 @@ namespace OpenRA.Mods.RA.Activities readonly int flashInterval; readonly int flashDuration; + readonly Cloak cloak; + public Demolish(Actor self, Actor target, int delay, int flashes, int flashesDelay, int flashInterval, int flashDuration) : base(self, target) { @@ -36,6 +39,7 @@ namespace OpenRA.Mods.RA.Activities this.flashesDelay = flashesDelay; this.flashInterval = flashInterval; this.flashDuration = flashDuration; + cloak = self.TraitOrDefault(); } protected override bool CanReserve(Actor self) @@ -50,6 +54,9 @@ namespace OpenRA.Mods.RA.Activities if (target.IsDead) return; + if (cloak != null && cloak.Info.UncloakOnDemolish) + cloak.Uncloak(); + for (var f = 0; f < flashes; f++) w.Add(new DelayedAction(flashesDelay + f * flashInterval, () => w.Add(new FlashTarget(target, ticks: flashDuration)))); diff --git a/OpenRA.Mods.RA/Activities/Infiltrate.cs b/OpenRA.Mods.RA/Activities/Infiltrate.cs index 4e769507ea..fd539d31b1 100644 --- a/OpenRA.Mods.RA/Activities/Infiltrate.cs +++ b/OpenRA.Mods.RA/Activities/Infiltrate.cs @@ -11,16 +11,22 @@ using OpenRA.Activities; using OpenRA.Mods.RA.Buildings; using OpenRA.Traits; +using OpenRA.Mods.RA.Traits; namespace OpenRA.Mods.RA.Activities { class Infiltrate : Enter { readonly Actor target; + + readonly Cloak cloak; + public Infiltrate(Actor self, Actor target) : base(self, target) { this.target = target; + + cloak = self.TraitOrDefault(); } protected override void OnInside(Actor self) @@ -28,6 +34,9 @@ namespace OpenRA.Mods.RA.Activities if (target.IsDead || target.Owner == self.Owner) return; + if (cloak != null && cloak.Info.UncloakOnInfiltrate) + cloak.Uncloak(); + foreach (var t in target.TraitsImplementing()) t.Infiltrated(target, self); diff --git a/OpenRA.Mods.RA/Traits/Cloak.cs b/OpenRA.Mods.RA/Traits/Cloak.cs index 4a462cd3ac..b6d5c73517 100644 --- a/OpenRA.Mods.RA/Traits/Cloak.cs +++ b/OpenRA.Mods.RA/Traits/Cloak.cs @@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA.Traits public readonly bool UncloakOnAttack = true; public readonly bool UncloakOnMove = false; public readonly bool UncloakOnUnload = true; + public readonly bool UncloakOnInfiltrate = true; + public readonly bool UncloakOnDemolish = true; public readonly string CloakSound = null; public readonly string UncloakSound = null;