Support multiple death animation variants.

This commit is contained in:
Paul Chote
2016-08-06 00:36:20 +01:00
parent da3333073f
commit a9bfa553fc

View File

@@ -42,9 +42,9 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly bool CrushedPaletteIsPlayerPalette = false;
[FieldLoader.LoadUsing("LoadDeathTypes")]
[Desc("Death animation to use for each damage type (defined on the warheads).",
[Desc("Death animations to use for each damage type (defined on the warheads).",
"Is only used if UseDeathTypeSuffix is `True`.")]
public readonly Dictionary<string, string> DeathTypes = new Dictionary<string, string>();
public readonly Dictionary<string, string[]> DeathTypes = new Dictionary<string, string[]>();
[Desc("Sequence to use when the actor is killed by some non-standard means (e.g. suicide).")]
[SequenceReference] public readonly string FallbackSequence = null;
@@ -54,8 +54,8 @@ namespace OpenRA.Mods.Common.Traits.Render
var md = yaml.ToDictionary();
return md.ContainsKey("DeathTypes")
? md["DeathTypes"].ToDictionary(my => FieldLoader.GetValue<string>("(value)", my.Value))
: new Dictionary<string, string>();
? md["DeathTypes"].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
: new Dictionary<string, string[]>();
}
public object Create(ActorInitializer init) { return new WithDeathAnimation(init.Self, this); }
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits.Render
if (damageType == null)
return;
sequence += Info.DeathTypes[damageType];
sequence += Info.DeathTypes[damageType].Random(self.World.SharedRandom);
}
SpawnDeathAnimation(self, self.CenterPosition, rs.GetImage(self), sequence, palette);