Reimplement sequence Defaults parsing:
The previous MiniYaml.Merge implementation interacted poorly with yaml inheritance, making it complicated (or impossible) to override certain keys from Defaults. The new implementation is simpler: If a key is defined it will be used. If it isn't, the default (if defined) will be used. Defaults can be masked by making sure the same key is defined (even with an empty value) in the sequence. This also fixes naming within the sequence code to distinguish between images (a group of sequences), sequences (defining a specific sprite/animation), and filenames for a specific sprite/animation.
This commit is contained in:
@@ -20,9 +20,9 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
public ClassicSpriteSequenceLoader(ModData modData)
|
||||
: base(modData) { }
|
||||
|
||||
public override ISpriteSequence CreateSequence(ModData modData, string tileSet, SpriteCache cache, string sequence, string animation, MiniYaml info)
|
||||
public override ISpriteSequence CreateSequence(ModData modData, string tileset, SpriteCache cache, string image, string sequence, MiniYaml data, MiniYaml defaults)
|
||||
{
|
||||
return new ClassicSpriteSequence(modData, tileSet, cache, this, sequence, animation, info);
|
||||
return new ClassicSpriteSequence(modData, tileset, cache, this, image, sequence, data, defaults);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,13 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
static readonly SpriteSequenceField<bool> UseClassicFacings = new SpriteSequenceField<bool>(nameof(UseClassicFacings), false);
|
||||
readonly bool useClassicFacings;
|
||||
|
||||
public ClassicSpriteSequence(ModData modData, string tileSet, SpriteCache cache, ISpriteSequenceLoader loader, string sequence, string animation, MiniYaml info)
|
||||
: base(modData, tileSet, cache, loader, sequence, animation, info)
|
||||
public ClassicSpriteSequence(ModData modData, string tileSet, SpriteCache cache, ISpriteSequenceLoader loader, string image, string sequence, MiniYaml data, MiniYaml defaults)
|
||||
: base(modData, tileSet, cache, loader, image, sequence, data, defaults)
|
||||
{
|
||||
var d = info.ToDictionary();
|
||||
useClassicFacings = LoadField(d, UseClassicFacings);
|
||||
useClassicFacings = LoadField(UseClassicFacings, data, defaults);
|
||||
|
||||
if (useClassicFacings && facings != 32)
|
||||
throw new InvalidOperationException(
|
||||
$"{info.Nodes[0].Location}: Sequence {sequence}.{animation}: UseClassicFacings is only valid for 32 facings");
|
||||
throw new InvalidOperationException($"Sequence {image}.{sequence}: UseClassicFacings is only valid for 32 facings");
|
||||
}
|
||||
|
||||
protected override int GetFacingFrameOffset(WAngle facing)
|
||||
|
||||
Reference in New Issue
Block a user