Use out var syntax
This commit is contained in:
@@ -53,10 +53,9 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var sequences = new Dictionary<string, ISpriteSequence>();
|
||||
var nodes = node.Value.ToDictionary();
|
||||
|
||||
MiniYaml defaults;
|
||||
try
|
||||
{
|
||||
if (nodes.TryGetValue("Defaults", out defaults))
|
||||
if (nodes.TryGetValue("Defaults", out var defaults))
|
||||
{
|
||||
nodes.Remove("Defaults");
|
||||
foreach (var n in nodes)
|
||||
@@ -123,8 +122,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
protected static T LoadField<T>(Dictionary<string, MiniYaml> d, string key, T fallback)
|
||||
{
|
||||
MiniYaml value;
|
||||
if (d.TryGetValue(key, out value))
|
||||
if (d.TryGetValue(key, out var value))
|
||||
return FieldLoader.GetValue<T>(key, value.Value);
|
||||
|
||||
return fallback;
|
||||
@@ -174,8 +172,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
Func<int, IEnumerable<int>> getUsedFrames = frameCount =>
|
||||
{
|
||||
MiniYaml length;
|
||||
if (d.TryGetValue("Length", out length) && length.Value == "*")
|
||||
if (d.TryGetValue("Length", out var length) && length.Value == "*")
|
||||
Length = Frames != null ? Frames.Length : frameCount - Start;
|
||||
else
|
||||
Length = LoadField(d, "Length", 1);
|
||||
@@ -244,8 +241,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
return usedFrames;
|
||||
};
|
||||
|
||||
MiniYaml combine;
|
||||
if (d.TryGetValue("Combine", out combine))
|
||||
if (d.TryGetValue("Combine", out var combine))
|
||||
{
|
||||
var combined = Enumerable.Empty<Sprite>();
|
||||
foreach (var sub in combine.Nodes)
|
||||
@@ -262,8 +258,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
Func<int, IEnumerable<int>> subGetUsedFrames = subFrameCount =>
|
||||
{
|
||||
MiniYaml subLengthYaml;
|
||||
if (sd.TryGetValue("Length", out subLengthYaml) && subLengthYaml.Value == "*")
|
||||
if (sd.TryGetValue("Length", out var subLengthYaml) && subLengthYaml.Value == "*")
|
||||
subLength = subFrames != null ? subFrames.Length : subFrameCount - subStart;
|
||||
else
|
||||
subLength = LoadField(sd, "Length", 1);
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
: base(modData)
|
||||
{
|
||||
var metadata = modData.Manifest.Get<SpriteSequenceFormat>().Metadata;
|
||||
MiniYaml yaml;
|
||||
if (metadata.TryGetValue("DefaultSpriteExtension", out yaml))
|
||||
if (metadata.TryGetValue("DefaultSpriteExtension", out var yaml))
|
||||
DefaultSpriteExtension = yaml.Value;
|
||||
|
||||
if (metadata.TryGetValue("TilesetExtensions", out yaml))
|
||||
@@ -51,8 +50,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
var tsId = tileSet.Id;
|
||||
|
||||
MiniYaml yaml;
|
||||
if (d.TryGetValue("TilesetOverrides", out yaml))
|
||||
if (d.TryGetValue("TilesetOverrides", out var yaml))
|
||||
{
|
||||
var tsNode = yaml.Nodes.FirstOrDefault(n => n.Key == tsId);
|
||||
if (tsNode != null)
|
||||
@@ -70,8 +68,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
if (LoadField(d, "UseTilesetCode", false))
|
||||
{
|
||||
string code;
|
||||
if (loader.TilesetCodes.TryGetValue(ResolveTilesetId(tileSet, d), out code))
|
||||
if (loader.TilesetCodes.TryGetValue(ResolveTilesetId(tileSet, d), out var code))
|
||||
spriteName = spriteName.Substring(0, 1) + code + spriteName.Substring(2, spriteName.Length - 2);
|
||||
}
|
||||
|
||||
@@ -79,8 +76,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
var useTilesetExtension = LoadField(d, "UseTilesetExtension", false);
|
||||
|
||||
string tilesetExtension;
|
||||
if (useTilesetExtension && loader.TilesetExtensions.TryGetValue(ResolveTilesetId(tileSet, d), out tilesetExtension))
|
||||
if (useTilesetExtension && loader.TilesetExtensions.TryGetValue(ResolveTilesetId(tileSet, d), out var tilesetExtension))
|
||||
return spriteName + tilesetExtension;
|
||||
|
||||
return spriteName + loader.DefaultSpriteExtension;
|
||||
|
||||
Reference in New Issue
Block a user