From c639339a62f3585fb4f5af02078bd8969a6c6e48 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 8 Jul 2014 17:11:59 +1200 Subject: [PATCH] Remove the crumble overlay after it has completed. --- OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs b/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs index 9b4475622b..dc45b82673 100644 --- a/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs +++ b/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs @@ -34,16 +34,19 @@ namespace OpenRA.Mods.RA.Render public WithCrumbleOverlay(ActorInitializer init, WithCrumbleOverlayInfo info) { + if (init.Contains()) + return; + + var key = "make_overlay_{0}".F(info.Sequence); var rs = init.self.Trait(); - if (!init.Contains()) - { - var overlay = new Animation(init.world, rs.GetImage(init.self)); - overlay.PlayThen(info.Sequence, () => buildComplete = false); - rs.Add("make_overlay_{0}".F(info.Sequence), - new AnimationWithOffset(overlay, null, () => !buildComplete), - info.Palette, info.IsPlayerPalette); - } + var overlay = new Animation(init.world, rs.GetImage(init.self)); + + // Remove the animation once it is complete + overlay.PlayThen(info.Sequence, () => init.world.AddFrameEndTask(w => rs.Remove(key))); + + rs.Add(key, new AnimationWithOffset(overlay, null, () => !buildComplete), + info.Palette, info.IsPlayerPalette); } public void BuildingComplete(Actor self)