Add support for multiple impact sounds to CreateEffectWarhead

Have the engine pick one impact sound at random from the provided list.
This commit is contained in:
Pavel Penev
2016-01-02 16:48:45 +02:00
parent 7e3ec91d30
commit 489ee9fc54
31 changed files with 202 additions and 196 deletions

View File

@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Remap explosion effect to player color, if art supports it.")]
public readonly bool UsePlayerPalette = false;
[Desc("Sound to play on impact.")]
public readonly string ImpactSound = null;
[Desc("List of sounds that can be played on impact.")]
public readonly string[] ImpactSounds = new string[0];
[Desc("What impact types should this effect apply to.")]
public readonly ImpactType ValidImpactTypes = ImpactType.Ground | ImpactType.Water | ImpactType.Air | ImpactType.GroundHit | ImpactType.WaterHit | ImpactType.AirHit;
@@ -103,8 +103,9 @@ namespace OpenRA.Mods.Common.Warheads
if (explosion != null)
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosion, palette)));
if (ImpactSound != null)
Game.Sound.Play(ImpactSound, pos);
var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
if (impactSound != null)
Game.Sound.Play(impactSound, pos);
}
public bool IsValidImpact(WPos pos, Actor firedBy)