From 6a988fd6767909717753053449e228ded426825d Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 23 May 2016 23:22:51 +0200 Subject: [PATCH 1/4] Move WorldInteractionControllerWidget and SpriteEffect to Common --- OpenRA.Game/OpenRA.Game.csproj | 2 -- {OpenRA.Game => OpenRA.Mods.Common}/Effects/SpriteEffect.cs | 3 ++- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 ++ OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs | 2 +- OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs | 2 +- .../Widgets/WorldInteractionControllerWidget.cs | 4 +++- 6 files changed, 9 insertions(+), 6 deletions(-) rename {OpenRA.Game => OpenRA.Mods.Common}/Effects/SpriteEffect.cs (96%) rename {OpenRA.Game => OpenRA.Mods.Common}/Widgets/WorldInteractionControllerWidget.cs (99%) diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 09495ea5da..6d8eda9288 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -227,7 +227,6 @@ - @@ -241,7 +240,6 @@ - diff --git a/OpenRA.Game/Effects/SpriteEffect.cs b/OpenRA.Mods.Common/Effects/SpriteEffect.cs similarity index 96% rename from OpenRA.Game/Effects/SpriteEffect.cs rename to OpenRA.Mods.Common/Effects/SpriteEffect.cs index 1976de8012..a6022d40d2 100644 --- a/OpenRA.Game/Effects/SpriteEffect.cs +++ b/OpenRA.Mods.Common/Effects/SpriteEffect.cs @@ -10,9 +10,10 @@ #endregion using System.Collections.Generic; +using OpenRA.Effects; using OpenRA.Graphics; -namespace OpenRA.Effects +namespace OpenRA.Mods.Common.Effects { public class SpriteEffect : IEffect { diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 0f83ca0cfc..2e20f66a60 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -163,6 +163,7 @@ + @@ -646,6 +647,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs b/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs index f8f85ca5eb..c8e68afad0 100644 --- a/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs +++ b/OpenRA.Mods.Common/Traits/Render/LeavesTrails.cs @@ -10,7 +10,7 @@ #endregion using System.Collections.Generic; -using OpenRA.Effects; +using OpenRA.Mods.Common.Effects; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs index 3fc52122f3..323c950f5e 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs @@ -9,8 +9,8 @@ */ #endregion -using OpenRA.Effects; using OpenRA.Mods.Common.Activities; +using OpenRA.Mods.Common.Effects; using OpenRA.Primitives; using OpenRA.Traits; diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs similarity index 99% rename from OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs rename to OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs index 386033902e..5e4c0e913f 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs @@ -14,10 +14,12 @@ using System.Drawing; using System.Linq; using OpenRA.Effects; using OpenRA.Graphics; +using OpenRA.Mods.Common.Effects; using OpenRA.Orders; using OpenRA.Traits; +using OpenRA.Widgets; -namespace OpenRA.Widgets +namespace OpenRA.Mods.Common.Widgets { public class WorldInteractionControllerWidget : Widget { From 51b88bfbaf2520b8bc2264f99d1a2ae0157394f0 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 23 May 2016 23:06:33 +0200 Subject: [PATCH 2/4] Remove Explosion effect and use SpriteEffect instead --- OpenRA.Mods.Common/Effects/Explosion.cs | 44 ------------------- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - OpenRA.Mods.Common/Traits/Parachutable.cs | 2 +- .../Traits/Render/WithBuildingExplosion.cs | 2 +- .../Warheads/CreateEffectWarhead.cs | 2 +- 5 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 OpenRA.Mods.Common/Effects/Explosion.cs diff --git a/OpenRA.Mods.Common/Effects/Explosion.cs b/OpenRA.Mods.Common/Effects/Explosion.cs deleted file mode 100644 index a8038dc209..0000000000 --- a/OpenRA.Mods.Common/Effects/Explosion.cs +++ /dev/null @@ -1,44 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you 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. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Effects; -using OpenRA.Graphics; - -namespace OpenRA.Mods.Common.Effects -{ - public class Explosion : IEffect - { - readonly World world; - readonly string palette; - readonly Animation anim; - WPos pos; - - public Explosion(World world, WPos pos, string image, string sequence, string palette) - { - this.world = world; - this.pos = pos; - this.palette = palette; - anim = new Animation(world, image); - anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); - } - - public void Tick(World world) { anim.Tick(); } - - public IEnumerable Render(WorldRenderer wr) - { - if (world.FogObscures(pos)) - return SpriteRenderable.None; - - return anim.Render(pos, wr.Palette(palette)); - } - } -} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 2e20f66a60..31a6d70103 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -152,7 +152,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Parachutable.cs b/OpenRA.Mods.Common/Traits/Parachutable.cs index d09224c5b5..07ae17057d 100644 --- a/OpenRA.Mods.Common/Traits/Parachutable.cs +++ b/OpenRA.Mods.Common/Traits/Parachutable.cs @@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits var sequence = terrain.IsWater ? info.WaterCorpseSequence : info.GroundCorpseSequence; var palette = terrain.IsWater ? info.WaterCorpsePalette : info.GroundCorpsePalette; if (sequence != null && palette != null) - self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.OccupiesSpace.CenterPosition, info.Image, sequence, palette))); + self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(self.OccupiesSpace.CenterPosition, w, info.Image, sequence, palette))); self.Kill(self); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs index 166a41210c..b31f1a1985 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs @@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits.Render void SpawnExplosions(World world, IEnumerable cells) { foreach (var c in cells) - world.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(c), info.Image, info.Sequences.Random(w.SharedRandom), info.Palette))); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(w.Map.CenterOfCell(c), w, info.Image, info.Sequences.Random(w.SharedRandom), info.Palette))); } } } diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index b618ec4dea..62a0b76e5f 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Warheads var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom); if (Image != null && explosion != null) - world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, Image, explosion, palette))); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette))); var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom); if (impactSound != null) From 555d4f4adcaee66bce2237a2505a900a777f51f2 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 23 May 2016 23:07:34 +0200 Subject: [PATCH 3/4] Remove Corpse effect and use SpriteEffect instead --- OpenRA.Mods.Common/Effects/Corpse.cs | 44 ------------------- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - .../Traits/Render/WithDeathAnimation.cs | 2 +- 3 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 OpenRA.Mods.Common/Effects/Corpse.cs diff --git a/OpenRA.Mods.Common/Effects/Corpse.cs b/OpenRA.Mods.Common/Effects/Corpse.cs deleted file mode 100644 index 740779e751..0000000000 --- a/OpenRA.Mods.Common/Effects/Corpse.cs +++ /dev/null @@ -1,44 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you 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. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Effects; -using OpenRA.Graphics; - -namespace OpenRA.Mods.Common.Effects -{ - public class Corpse : IEffect - { - readonly World world; - readonly WPos pos; - readonly string paletteName; - readonly Animation anim; - - public Corpse(World world, WPos pos, string image, string sequence, string paletteName) - { - this.world = world; - this.pos = pos; - this.paletteName = paletteName; - anim = new Animation(world, image); - anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); - } - - public void Tick(World world) { anim.Tick(); } - - public IEnumerable Render(WorldRenderer wr) - { - if (world.FogObscures(pos)) - return SpriteRenderable.None; - - return anim.Render(pos, wr.Palette(paletteName)); - } - } -} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 31a6d70103..615fe1b703 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -150,7 +150,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs index e44ab7c130..7633d97fd9 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDeathAnimation.cs @@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits.Render public void SpawnDeathAnimation(Actor self, WPos pos, string image, string sequence, string palette) { - self.World.AddFrameEndTask(w => w.Add(new Corpse(w, pos, image, sequence, palette))); + self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, image, sequence, palette))); } void INotifyCrushed.OnCrush(Actor self, Actor crusher, HashSet crushClasses) From 122035c36c03912a154908456fe6e34ac1494a6f Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 23 May 2016 23:07:56 +0200 Subject: [PATCH 4/4] Remove Smoke effect and use SpriteEffect instead --- OpenRA.Mods.Common/Effects/Bullet.cs | 3 +- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- OpenRA.Mods.Common/Effects/Smoke.cs | 50 ------------------- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - .../Traits/SmokeTrailWhenDamaged.cs | 2 +- .../Traits/World/SmudgeLayer.cs | 2 +- 6 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 OpenRA.Mods.Common/Effects/Smoke.cs diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index 49c98d8588..0c0d72e698 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -182,7 +182,8 @@ namespace OpenRA.Mods.Common.Effects if (!string.IsNullOrEmpty(info.Trail) && --smokeTicks < 0) { var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length); - world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, GetEffectiveFacing(), info.Trail, trailPalette, info.TrailSequences.Random(world.SharedRandom)))); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, w, info.Trail, info.TrailSequences.Random(world.SharedRandom), + trailPalette, false, false, GetEffectiveFacing()))); smokeTicks = info.TrailInterval; } diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index 23e078326b..de0f81dfdb 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -820,7 +820,7 @@ namespace OpenRA.Mods.Common.Effects // Create the smoke trail effect if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated)) { - world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, renderFacing, info.TrailImage, trailPalette, info.TrailSequence))); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, w, info.TrailImage, info.TrailSequence, trailPalette, false, false, renderFacing))); ticksToNextSmoke = info.TrailInterval; } diff --git a/OpenRA.Mods.Common/Effects/Smoke.cs b/OpenRA.Mods.Common/Effects/Smoke.cs deleted file mode 100644 index e3b4068873..0000000000 --- a/OpenRA.Mods.Common/Effects/Smoke.cs +++ /dev/null @@ -1,50 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you 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. For more - * information, see COPYING. - */ -#endregion - -using System; -using System.Collections.Generic; -using OpenRA.Effects; -using OpenRA.Graphics; - -namespace OpenRA.Mods.Common.Effects -{ - public class Smoke : IEffect - { - readonly World world; - readonly WPos pos; - readonly Animation anim; - readonly string palette; - - public Smoke(World world, WPos pos, string trail, string palette, string sequence) - : this(world, pos, 0, trail, palette, sequence) { } - - public Smoke(World world, WPos pos, int facing, string trail, string palette, string sequence) - { - this.world = world; - this.pos = pos; - this.palette = palette; - - anim = new Animation(world, trail, () => facing); - anim.PlayThen(sequence, - () => world.AddFrameEndTask(w => w.Remove(this))); - } - - public void Tick(World world) { anim.Tick(); } - - public IEnumerable Render(WorldRenderer wr) - { - if (world.FogObscures(pos)) - return SpriteRenderable.None; - - return anim.Render(pos, wr.Palette(palette)); - } - } -} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 615fe1b703..4cb22e0ca3 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -160,7 +160,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs index d820f553f1..107e97fabe 100644 --- a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs +++ b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits { var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation)); var pos = position + body.LocalToWorld(offset); - self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, getFacing, info.Sprite, info.Palette, info.Sequence))); + self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, info.Sprite, info.Sequence, info.Palette, false, false, getFacing))); } ticks = info.Interval; diff --git a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs index bc15d3dfe1..e3062d2088 100644 --- a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits public void AddSmudge(CPos loc) { if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage) - world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType, Info.SmokePalette, Info.SmokeSequence))); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(world.Map.CenterOfCell(loc), w, Info.SmokeType, Info.SmokeSequence, Info.SmokePalette))); if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc)) {