diff --git a/OpenRA.Mods.Common/Activities/Demolish.cs b/OpenRA.Mods.Common/Activities/Demolish.cs index 3bdee7d8d6..07e77db0ec 100644 --- a/OpenRA.Mods.Common/Activities/Demolish.cs +++ b/OpenRA.Mods.Common/Activities/Demolish.cs @@ -25,11 +25,10 @@ namespace OpenRA.Mods.Common.Activities readonly int flashes; readonly int flashesDelay; readonly int flashInterval; - readonly int flashDuration; readonly INotifyDemolition[] notifiers; public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay, - int flashes, int flashesDelay, int flashInterval, int flashDuration) + int flashes, int flashesDelay, int flashInterval) : base(self, target, enterBehaviour) { this.target = target; @@ -39,7 +38,6 @@ namespace OpenRA.Mods.Common.Activities this.flashes = flashes; this.flashesDelay = flashesDelay; this.flashInterval = flashInterval; - this.flashDuration = flashDuration; } protected override bool CanReserve(Actor self) @@ -57,9 +55,7 @@ namespace OpenRA.Mods.Common.Activities foreach (var ind in notifiers) ind.Demolishing(self); - for (var f = 0; f < flashes; f++) - w.Add(new DelayedAction(flashesDelay + f * flashInterval, () => - w.Add(new FlashTarget(target, ticks: flashDuration)))); + w.Add(new FlashTarget(target, count: flashes, delay: flashesDelay, interval: flashInterval)); w.Add(new DelayedAction(delay, () => { diff --git a/OpenRA.Mods.Common/Effects/FlashTarget.cs b/OpenRA.Mods.Common/Effects/FlashTarget.cs index bc014683af..0bf1883fb5 100644 --- a/OpenRA.Mods.Common/Effects/FlashTarget.cs +++ b/OpenRA.Mods.Common/Effects/FlashTarget.cs @@ -18,15 +18,20 @@ namespace OpenRA.Mods.Common.Effects { public class FlashTarget : IEffect { - Actor target; - Player player; - int remainingTicks; + readonly Actor target; + readonly Player player; + readonly int count; + readonly int interval; + int tick; - public FlashTarget(Actor target, Player asPlayer = null, int ticks = 4) + public FlashTarget(Actor target, Player asPlayer = null, int count = 2, int interval = 2, int delay = 0) { this.target = target; player = asPlayer; - remainingTicks = ticks; + this.count = count; + this.interval = interval; + tick = -delay; + target.World.RemoveAll(effect => { var flashTarget = effect as FlashTarget; @@ -36,13 +41,13 @@ namespace OpenRA.Mods.Common.Effects public void Tick(World world) { - if (--remainingTicks == 0 || !target.IsInWorld) + if (++tick >= count * interval || !target.IsInWorld) world.AddFrameEndTask(w => w.Remove(this)); } public IEnumerable Render(WorldRenderer wr) { - if (target.IsInWorld && remainingTicks % 2 == 0) + if (target.IsInWorld && tick >= 0 && tick % interval == 0) { var palette = wr.Palette(player == null ? "highlight" : "highlight" + player.InternalName); return target.Render(wr) diff --git a/OpenRA.Mods.Common/Scripting/Properties/DemolitionProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/DemolitionProperties.cs index ca26232511..c124ecc11b 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/DemolitionProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/DemolitionProperties.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Scripting public void Demolish(Actor target) { Self.QueueActivity(new Demolish(Self, target, info.EnterBehaviour, info.DetonationDelay, - info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration)); + info.Flashes, info.FlashesDelay, info.FlashInterval)); } } } diff --git a/OpenRA.Mods.Common/Traits/Demolition.cs b/OpenRA.Mods.Common/Traits/Demolition.cs index 7bc9a0dcd8..bc0a54ec1d 100644 --- a/OpenRA.Mods.Common/Traits/Demolition.cs +++ b/OpenRA.Mods.Common/Traits/Demolition.cs @@ -33,9 +33,6 @@ namespace OpenRA.Mods.Common.Traits [Desc("Interval between each flash.")] public readonly int FlashInterval = 4; - [Desc("Duration of each flash.")] - public readonly int FlashDuration = 3; - [Desc("Behaviour when entering the structure.", "Possible values are Exit, Suicide, Dispose.")] public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Exit; @@ -88,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits self.SetTargetLine(target, Color.Red); self.QueueActivity(new Demolish(self, target.Actor, info.EnterBehaviour, info.DetonationDelay, - info.Flashes, info.FlashesDelay, info.FlashInterval, info.FlashDuration)); + info.Flashes, info.FlashesDelay, info.FlashInterval)); } public string VoicePhraseForOrder(Actor self, Order order)