Add support for multiple explosions to CreateEffectWarhead

Have the engine pick one explosion at random from the provided list.
This commit is contained in:
Pavel Penev
2016-01-02 16:47:56 +02:00
parent c22281876c
commit 7e3ec91d30
35 changed files with 292 additions and 279 deletions

View File

@@ -17,11 +17,11 @@ namespace OpenRA.Mods.Common.Warheads
{
public class CreateEffectWarhead : Warhead
{
[Desc("Explosion effect to use.")]
public readonly string Explosion = null;
[Desc("List of explosion effects that can be used.")]
public readonly string[] Explosions = new string[0];
[Desc("Palette to use for explosion effect.")]
[PaletteReference("UsePlayerPalette")] public readonly string ExplosionPalette = "effect";
[Desc("Palette to use for explosion effect."), PaletteReference("UsePlayerPalette")]
public readonly string ExplosionPalette = "effect";
[Desc("Remap explosion effect to player color, if art supports it.")]
public readonly bool UsePlayerPalette = false;
@@ -99,8 +99,9 @@ namespace OpenRA.Mods.Common.Warheads
if (UsePlayerPalette)
palette += firedBy.Owner.InternalName;
if (Explosion != null)
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, Explosion, palette)));
var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);
if (explosion != null)
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosion, palette)));
if (ImpactSound != null)
Game.Sound.Play(ImpactSound, pos);