Remove LoadUsing where FieldLoader.GetValue works for the dictionaries

This commit is contained in:
atlimit8
2017-04-19 09:51:06 -05:00
parent 843ac85c92
commit 4767b91037
3 changed files with 1 additions and 30 deletions

View File

@@ -41,7 +41,6 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Custom crushed animation palette is a player palette BaseName")] [Desc("Custom crushed animation palette is a player palette BaseName")]
public readonly bool CrushedPaletteIsPlayerPalette = false; public readonly bool CrushedPaletteIsPlayerPalette = false;
[FieldLoader.LoadUsing("LoadDeathTypes")]
[Desc("Death animations 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`.")] "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[]>();
@@ -49,15 +48,6 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Sequence to use when the actor is killed by some non-standard means (e.g. suicide).")] [Desc("Sequence to use when the actor is killed by some non-standard means (e.g. suicide).")]
[SequenceReference] public readonly string FallbackSequence = null; [SequenceReference] public readonly string FallbackSequence = null;
public static object LoadDeathTypes(MiniYaml yaml)
{
var md = yaml.ToDictionary();
return md.ContainsKey("DeathTypes")
? md["DeathTypes"].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
: new Dictionary<string, string[]>();
}
public override object Create(ActorInitializer init) { return new WithDeathAnimation(init.Self, this); } public override object Create(ActorInitializer init) { return new WithDeathAnimation(init.Self, this); }
} }

View File

@@ -28,20 +28,10 @@ namespace OpenRA.Mods.Common.Traits.Render
// TODO: [SequenceReference] isn't smart enough to use Dictionaries. // TODO: [SequenceReference] isn't smart enough to use Dictionaries.
[Desc("Attack sequence to use for each armament.")] [Desc("Attack sequence to use for each armament.")]
[FieldLoader.LoadUsing("LoadWeaponSequences")]
public readonly Dictionary<string, string> AttackSequences = new Dictionary<string, string>(); public readonly Dictionary<string, string> AttackSequences = new Dictionary<string, string>();
[SequenceReference] public readonly string[] IdleSequences = { }; [SequenceReference] public readonly string[] IdleSequences = { };
[SequenceReference] public readonly string[] StandSequences = { "stand" }; [SequenceReference] public readonly string[] StandSequences = { "stand" };
public static object LoadWeaponSequences(MiniYaml yaml)
{
var md = yaml.ToDictionary();
return md.ContainsKey("AttackSequences")
? md["AttackSequences"].ToDictionary(my => FieldLoader.GetValue<string>("(value)", my.Value))
: new Dictionary<string, string>();
}
public override object Create(ActorInitializer init) { return new WithInfantryBody(init, this); } public override object Create(ActorInitializer init) { return new WithInfantryBody(init, this); }
public IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) public IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)

View File

@@ -24,9 +24,8 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Types of damage that this warhead causes. Leave empty for no damage.")] [Desc("Types of damage that this warhead causes. Leave empty for no damage.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>(); public readonly HashSet<string> DamageTypes = new HashSet<string>();
[FieldLoader.LoadUsing("LoadVersus")]
[Desc("Damage percentage versus each armortype.")] [Desc("Damage percentage versus each armortype.")]
public readonly Dictionary<string, int> Versus; public readonly Dictionary<string, int> Versus = new Dictionary<string, int>();
public override bool IsValidAgainst(Actor victim, Actor firedBy) public override bool IsValidAgainst(Actor victim, Actor firedBy)
{ {
@@ -36,14 +35,6 @@ namespace OpenRA.Mods.Common.Warheads
return base.IsValidAgainst(victim, firedBy); return base.IsValidAgainst(victim, firedBy);
} }
public static object LoadVersus(MiniYaml yaml)
{
var nd = yaml.ToDictionary();
return nd.ContainsKey("Versus")
? nd["Versus"].ToDictionary(my => FieldLoader.GetValue<int>("(value)", my.Value))
: new Dictionary<string, int>();
}
public int DamageVersus(Actor victim) public int DamageVersus(Actor victim)
{ {
var armor = victim.TraitsImplementing<Armor>() var armor = victim.TraitsImplementing<Armor>()