Remove DamageWarhead.DeathType in favor of DamageWarhead.DamageTypes
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -18,17 +21,39 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Sequence to play when this actor is killed by a warhead.")]
|
||||
public readonly string DeathSequence = "die";
|
||||
|
||||
[Desc("The palette used for `DeathSequence`.")]
|
||||
public readonly string DeathSequencePalette = "player";
|
||||
|
||||
[Desc("Custom death animation palette is a player palette BaseName")]
|
||||
public readonly bool DeathPaletteIsPlayerPalette = true;
|
||||
|
||||
[Desc("Should DeathType-specific sequences be used (sequence name = DeathSequence + DeathType).")]
|
||||
public readonly bool UseDeathTypeSuffix = true;
|
||||
|
||||
[Desc("Sequence to play when this actor is crushed.")]
|
||||
public readonly string CrushedSequence = "die-crushed";
|
||||
|
||||
[Desc("The palette used for `CrushedSequence`.")]
|
||||
public readonly string CrushedSequencePalette = "effect";
|
||||
|
||||
[Desc("Custom crushed animation palette is a player palette BaseName")]
|
||||
public readonly bool CrushedPaletteIsPlayerPalette = false;
|
||||
|
||||
[FieldLoader.LoadUsing("LoadDeathTypes")]
|
||||
[Desc("Death animation to use for each damage type (defined on the warheads).",
|
||||
"Is only used if UseDeathTypeSuffix is `True`.")]
|
||||
public readonly Dictionary<string, int> DeathTypes = new Dictionary<string, int>();
|
||||
|
||||
public static object LoadDeathTypes(MiniYaml yaml)
|
||||
{
|
||||
var md = yaml.ToDictionary();
|
||||
|
||||
return md.ContainsKey("DeathTypes")
|
||||
? md["DeathTypes"].ToDictionary(my => FieldLoader.GetValue<int>("(value)", my.Value))
|
||||
: new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithDeathAnimation(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -52,7 +77,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var sequence = Info.DeathSequence;
|
||||
if (Info.UseDeathTypeSuffix)
|
||||
sequence += e.Warhead.DeathType;
|
||||
{
|
||||
var damageType = e.Warhead.DamageTypes.Intersect(Info.DeathTypes.Keys).FirstOrDefault();
|
||||
if (damageType == null)
|
||||
throw new Exception("Actor type `{0}` does not define a death animation for weapon with damage types `{1}`!"
|
||||
.F(self.Info.Name, string.Join(", ", e.Warhead.DamageTypes)));
|
||||
|
||||
sequence += Info.DeathTypes[damageType];
|
||||
}
|
||||
|
||||
var palette = Info.DeathSequencePalette;
|
||||
if (Info.DeathPaletteIsPlayerPalette)
|
||||
|
||||
Reference in New Issue
Block a user