Remove Explosion effect and use SpriteEffect instead

This commit is contained in:
reaperrr
2016-05-23 23:06:33 +02:00
parent 6a988fd676
commit 51b88bfbaf
5 changed files with 3 additions and 48 deletions

View File

@@ -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<IRenderable> Render(WorldRenderer wr)
{
if (world.FogObscures(pos))
return SpriteRenderable.None;
return anim.Render(pos, wr.Palette(palette));
}
}
}

View File

@@ -152,7 +152,6 @@
<Compile Include="Effects\ContrailFader.cs" />
<Compile Include="Effects\Corpse.cs" />
<Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\Explosion.cs" />
<Compile Include="Effects\FloatingText.cs" />
<Compile Include="Effects\GravityBomb.cs" />
<Compile Include="Effects\LaserZap.cs" />

View File

@@ -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);
}

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void SpawnExplosions(World world, IEnumerable<CPos> 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)));
}
}
}

View File

@@ -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)