diff --git a/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs b/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs index 2ae65f060c..7778cc0b4b 100644 --- a/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs +++ b/OpenRA.Mods.Aftermath/ChronoshiftDeploy.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -77,7 +77,7 @@ namespace OpenRA.Mods.Aftermath chargeTick = 25 * self.Info.Traits.Get().ChargeTime; foreach (var a in self.World.Queries.WithTrait()) - a.Trait.DoChronoshift(); + a.Trait.Enable(); } } diff --git a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs index d7dbaf266f..a61e1fbc9a 100644 --- a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs +++ b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA const int chronoEffectLength = 20; int remainingFrames; - public void DoChronoshift() + public void Enable() { remainingFrames = chronoEffectLength; } diff --git a/OpenRA.Mods.RA/ChronoshiftPower.cs b/OpenRA.Mods.RA/ChronoshiftPower.cs index 5efb92f319..b8c62dad16 100644 --- a/OpenRA.Mods.RA/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/ChronoshiftPower.cs @@ -183,9 +183,10 @@ namespace OpenRA.Mods.RA { Sound.Play("chrono2.aud", self.CenterLocation); Sound.Play("chrono2.aud", targetActor.CenterLocation); + // Trigger screen desaturate effect foreach (var a in self.World.Queries.WithTrait()) - a.Trait.DoChronoshift(); + a.Trait.Enable(); self.traits.Get().PlayCustomAnim(self, "active"); } diff --git a/OpenRA.Mods.RA/Effects/NukeLaunch.cs b/OpenRA.Mods.RA/Effects/NukeLaunch.cs index 96873998b4..94ff2c746a 100755 --- a/OpenRA.Mods.RA/Effects/NukeLaunch.cs +++ b/OpenRA.Mods.RA/Effects/NukeLaunch.cs @@ -80,7 +80,13 @@ namespace OpenRA.Mods.RA.Effects { altitude -= 10; if (altitude <= 0) + { + // Trigger screen desaturate effect + foreach (var a in Game.world.Queries.WithTrait()) + a.Trait.Enable(); + Explode(world); + } } } diff --git a/OpenRA.Mods.RA/NukePaletteEffect.cs b/OpenRA.Mods.RA/NukePaletteEffect.cs new file mode 100644 index 0000000000..e170fe73f1 --- /dev/null +++ b/OpenRA.Mods.RA/NukePaletteEffect.cs @@ -0,0 +1,62 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System.Drawing; +using OpenRA.Traits; +using OpenRA.Graphics; + +namespace OpenRA.Mods.RA +{ + class NukePaletteEffectInfo : TraitInfo { } + + public class NukePaletteEffect : IPaletteModifier, ITick + { + const int nukeEffectLength = 20; + int remainingFrames; + + public void Enable() + { + remainingFrames = nukeEffectLength; + } + + public void Tick(Actor self) + { + if (remainingFrames > 0) + remainingFrames--; + } + + public void AdjustPalette(Bitmap b) + { + if (remainingFrames == 0) + return; + + var frac = (float)remainingFrames / nukeEffectLength; + + // TODO: Fix me to only affect "world" palettes + for( var y = 0; y < b.Height; y++ ) + for (var x = 0; x < 256; x++) + { + var orig = b.GetPixel(x, y); + var white = Color.FromArgb(orig.A, 255, 255, 255); + b.SetPixel(x, y, OpenRA.Graphics.Util.Lerp(frac, orig, white)); + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index fb508b59f5..2f1639cffa 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -177,6 +177,7 @@ + diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index caee403254..1652d4d136 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -88,6 +88,7 @@ World: ScreenShaker: WaterPaletteRotation: ChronoshiftPaletteEffect: + NukePaletteEffect: LightPaletteRotator: BuildingInfluence: UnitInfluence: