Replace F extension with string interpolation

This commit is contained in:
teinarss
2021-04-24 17:46:24 +02:00
committed by reaperrr
parent 1385aca783
commit 10676be377
300 changed files with 752 additions and 799 deletions

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Activities
{
var max = teleporter.World.Map.Grid.MaximumTileSearchRange;
if (maximumDistance > max)
throw new InvalidOperationException("Teleport distance cannot exceed the value of MaximumTileSearchRange ({0}).".F(max));
throw new InvalidOperationException($"Teleport distance cannot exceed the value of MaximumTileSearchRange ({max}).");
this.teleporter = teleporter;
this.destination = destination;

View File

@@ -50,8 +50,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
Array.Copy(Transforms, 16 * (LimbCount * j + i), testMatrix, 0, 16);
if (OpenRA.Graphics.Util.MatrixInverse(testMatrix) == null)
throw new InvalidDataException(
"The transformation matrix for HVA file `{0}` section {1} frame {2} is invalid because it is not invertible!"
.F(fileName, i, j));
$"The transformation matrix for HVA file `{fileName}` section {i} frame {j} is invalid because it is not invertible!");
}
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
public override string ToString()
{
return "{0} - offset 0x{1:x8} - length 0x{2:x8}".F(Filename, Offset, Length);
return $"{Filename} - offset 0x{Offset:x8} - length 0x{Length:x8}";
}
}
}

View File

@@ -26,12 +26,12 @@ namespace OpenRA.Mods.Cnc.FileFormats
var id = s.ReadASCII(4);
if (id != "GABA")
throw new InvalidDataException("Unable to load Idx file, did not find magic id, found {0} instead".F(id));
throw new InvalidDataException($"Unable to load Idx file, did not find magic id, found {id} instead");
var two = s.ReadInt32();
if (two != 2)
throw new InvalidDataException("Unable to load Idx file, did not find magic number 2, found {0} instead".F(two));
throw new InvalidDataException($"Unable to load Idx file, did not find magic number 2, found {two} instead");
SoundCount = s.ReadInt32();

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
static void ReplicatePrevious(byte[] dest, int destIndex, int srcIndex, int count)
{
if (srcIndex > destIndex)
throw new NotImplementedException("srcIndex > destIndex {0} {1}".F(srcIndex, destIndex));
throw new NotImplementedException($"srcIndex > destIndex {srcIndex} {destIndex}");
for (var i = 0; i < count; i++)
{
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
var count = count3 == 0x3F ? ctx.ReadWord() : count3 + 3;
var srcIndex = reverse ? destIndex - ctx.ReadWord() : ctx.ReadWord();
if (srcIndex >= destIndex)
throw new NotImplementedException("srcIndex >= destIndex {0} {1}".F(srcIndex, destIndex));
throw new NotImplementedException($"srcIndex >= destIndex {srcIndex} {destIndex}");
for (var end = destIndex + count; destIndex < end; destIndex++)
dest[destIndex] = dest[srcIndex++];

View File

@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
type = stream.ReadASCII(4);
}
else
throw new NotSupportedException("Vqa uses unknown Subtype: {0}".F(type));
throw new NotSupportedException($"Vqa uses unknown Subtype: {type}");
}
/*var length = */stream.ReadUInt16();
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
break;
default:
if (length + stream.Position > stream.Length)
throw new NotSupportedException("Vqa uses unknown Subtype: {0}".F(type));
throw new NotSupportedException($"Vqa uses unknown Subtype: {type}");
stream.ReadBytes((int)length);
break;
}
@@ -420,7 +420,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
vtprSize = subchunkLength;
return;
default:
throw new InvalidDataException("Unknown sub-chunk {0}".F(type));
throw new InvalidDataException($"Unknown sub-chunk {type}");
}
}
}
@@ -562,7 +562,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
// Replicate previous
var srcIndex = destIndex - rpos;
if (srcIndex > destIndex)
throw new NotImplementedException("srcIndex > destIndex {0} {1}".F(srcIndex, destIndex));
throw new NotImplementedException($"srcIndex > destIndex {srcIndex} {destIndex}");
for (var j = 0; j < count; j++)
{
@@ -602,7 +602,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
var count = count3 == 0x3F ? ctx.ReadWord() : count3 + 3;
var srcIndex = reverse ? destIndex - ctx.ReadWord() : ctx.ReadWord();
if (srcIndex >= destIndex)
throw new NotImplementedException("srcIndex >= destIndex {0} {1}".F(srcIndex, destIndex));
throw new NotImplementedException($"srcIndex >= destIndex {srcIndex} {destIndex}");
for (var end = destIndex + count; destIndex < end; destIndex++)
dest[destIndex] = dest[srcIndex++];

View File

@@ -54,8 +54,8 @@ namespace OpenRA.Mods.Cnc.FileSystem
entries = ParseHeader(s, isCncMix ? 0 : 4, out dataStart);
index = ParseIndex(entries.ToDictionaryWithConflictLog(x => x.Hash,
"{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, isCncMix ? "C&C" : "RA/TS/RA2", isEncrypted, dataStart),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)), allPossibleFilenames);
$"{filename} ({(isCncMix ? "C&C" : "RA/TS/RA2")} format, Encrypted: {isEncrypted}, DataStart: {dataStart})",
null, x => $"(offs={x.Offset}, len={x.Length})"), allPossibleFilenames);
}
catch (Exception)
{
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
var unknown = entries.Count - bestIndex.Count;
if (unknown > 0)
Log.Write("debug", "{0}: failed to resolve filenames for {1} unknown hashes".F(Name, unknown));
Log.Write("debug", $"{Name}: failed to resolve filenames for {unknown} unknown hashes");
return bestIndex;
}
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
throw new ArgumentOutOfRangeException(nameof(count), "Non-negative number required.");
if (offset + (count * 2) > s.Length)
throw new ArgumentException("Bytes to read {0} and offset {1} greater than stream length {2}.".F(count * 2, offset, s.Length));
throw new ArgumentException($"Bytes to read {count * 2} and offset {offset} greater than stream length {s.Length}.");
s.Seek(offset, SeekOrigin.Begin);

View File

@@ -50,9 +50,9 @@ namespace OpenRA.Mods.Cnc.FileSystem
public override string ToString()
{
if (names.TryGetValue(Hash, out var filename))
return "{0} - offset 0x{1:x8} - length 0x{2:x8}".F(filename, Offset, Length);
return $"{filename} - offset 0x{Offset:x8} - length 0x{Length:x8}";
else
return "0x{0:x8} - offset 0x{1:x8} - length 0x{2:x8}".F(Hash, Offset, Length);
return $"0x{Hash:x8} - offset 0x{Offset:x8} - length 0x{Length:x8}";
}
public static uint HashFilename(string name, PackageHashType type)
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
return CRC32.Calculate(Encoding.ASCII.GetBytes(name));
}
default: throw new NotImplementedException("Unknown hash type `{0}`".F(type));
default: throw new NotImplementedException($"Unknown hash type `{type}`");
}
}

View File

@@ -38,8 +38,7 @@ namespace OpenRA.Mods.Cnc.Graphics
if (useClassicFacings && Facings != 32)
throw new InvalidOperationException(
"{0}: Sequence {1}.{2}: UseClassicFacings is only valid for 32 facings"
.F(info.Nodes[0].Location, sequence, animation));
$"{info.Nodes[0].Location}: Sequence {sequence}.{animation}: UseClassicFacings is only valid for 32 facings");
}
protected override int GetFacingFrameOffset(WAngle facing)

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.Graphics
public Voxel(VoxelLoader loader, VxlReader vxl, HvaReader hva, (string Vxl, string Hva) files)
{
if (vxl.LimbCount != hva.LimbCount)
throw new InvalidOperationException("{0}.vxl and {1}.hva limb counts don't match.".F(files.Vxl, files.Hva));
throw new InvalidOperationException($"{files.Vxl}.vxl and {files.Hva}.hva limb counts don't match.");
transforms = hva.Transforms;
frames = hva.FrameCount;
@@ -60,9 +60,9 @@ namespace OpenRA.Mods.Cnc.Graphics
public float[] TransformationMatrix(uint limb, uint frame)
{
if (frame >= frames)
throw new ArgumentOutOfRangeException(nameof(frame), "Only {0} frames exist.".F(frames));
throw new ArgumentOutOfRangeException(nameof(frame), $"Only {frames} frames exist.");
if (limb >= limbs)
throw new ArgumentOutOfRangeException(nameof(limb), "Only {1} limbs exist.".F(limbs));
throw new ArgumentOutOfRangeException(nameof(limb), $"Only {limbs} limbs exist.");
var l = limbData[limb];
var t = new float[16];

View File

@@ -98,10 +98,10 @@ namespace OpenRA.Mods.Cnc.Graphics
{
if (models.ContainsKey(model))
throw new InvalidOperationException(
"Model `{0}` does not have a sequence `{1}`".F(model, sequence));
$"Model `{model}` does not have a sequence `{sequence}`");
else
throw new InvalidOperationException(
"Model `{0}` does not have any sequences defined.".F(model));
$"Model `{model}` does not have any sequences defined.");
}
}
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Cnc.Graphics
{
if (!models.ContainsKey(model))
throw new InvalidOperationException(
"Model `{0}` does not have any sequences defined.".F(model));
$"Model `{model}` does not have any sequences defined.");
return models[model].ContainsKey(sequence);
}

View File

@@ -33,8 +33,7 @@ namespace OpenRA.Mods.Cnc.Scripting
using (kv.Value)
{
if (!kv.Key.TryGetClrValue(out actor) || !kv.Value.TryGetClrValue(out cell))
throw new LuaException("Chronoshift requires a table of Actor,CPos pairs. Received {0},{1}".F(
kv.Key.WrappedClrType().Name, kv.Value.WrappedClrType().Name));
throw new LuaException($"Chronoshift requires a table of Actor,CPos pairs. Received {kv.Key.WrappedClrType().Name},{kv.Value.WrappedClrType().Name}");
}
var cs = actor.TraitsImplementing<Chronoshiftable>()

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Scripting
var infiltrates = infiltratesTraits.FirstOrDefault(x => !x.IsTraitDisabled && x.Info.Types.Overlaps(target.GetEnabledTargetTypes()));
if (infiltrates == null)
throw new LuaException("{0} tried to infiltrate invalid target {1}!".F(Self, target));
throw new LuaException($"{Self} tried to infiltrate invalid target {target}!");
// NB: Scripted actions get no visible targetlines.
Self.QueueActivity(new Infiltrate(Self, Target.FromActor(target), infiltrates, null));

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
framePrefix = prefix;
if (prefix != framePrefix)
throw new InvalidDataException("Frame prefix mismatch: `{0}` != `{1}`".F(prefix, framePrefix));
throw new InvalidDataException($"Frame prefix mismatch: `{prefix}` != `{framePrefix}`");
frameCount = Math.Max(frameCount, int.Parse(match.Groups["frame"].Value) + 1);
}
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
var frames = new ISpriteFrame[frameCount];
for (var i = 0; i < frames.Length; i++)
{
var tgaEntry = container.GetEntry("{0}{1:D4}.tga".F(framePrefix, i));
var tgaEntry = container.GetEntry($"{framePrefix}{i:D4}.tga");
// Blank frame
if (tgaEntry == null)
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
continue;
}
var metaEntry = container.GetEntry("{0}{1:D4}.meta".F(framePrefix, i));
var metaEntry = container.GetEntry($"{framePrefix}{i:D4}.meta");
using (var tgaStream = container.GetInputStream(tgaEntry))
{
var metaStream = metaEntry != null ? container.GetInputStream(metaEntry) : null;

View File

@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
if (h.Format == Format.XORPrev)
h.RefImage = headers[i - 1];
else if (h.Format == Format.XORLCW && !offsets.TryGetValue(h.RefOffset, out h.RefImage))
throw new InvalidDataException("Reference doesn't point to image data {0}->{1}".F(h.FileOffset, h.RefOffset));
throw new InvalidDataException($"Reference doesn't point to image data {h.FileOffset}->{h.RefOffset}");
}
shpBytesFileOffset = stream.Position;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
var weaponToLower = Weapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weaponInfo))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weaponInfo;
}

View File

@@ -77,10 +77,10 @@ namespace OpenRA.Mods.Cnc.Traits
var detonationWeaponToLower = (DetonationWeapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(thumpDamageWeaponToLower, out var thumpDamageWeapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(thumpDamageWeaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{thumpDamageWeaponToLower}'");
if (!rules.Weapons.TryGetValue(detonationWeaponToLower, out var detonationWeapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(detonationWeaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{detonationWeaponToLower}'");
ThumpDamageWeaponInfo = thumpDamageWeapon;
DetonationWeaponInfo = detonationWeapon;

View File

@@ -81,8 +81,8 @@ namespace OpenRA.Mods.Cnc.Traits
this.self = self;
var tileset = self.World.Map.Tileset.ToLowerInvariant();
if (self.World.Map.Rules.Sequences.HasSequence("overlay", "{0}-{1}".F(Info.TileValidName, tileset)))
Tile = self.World.Map.Rules.Sequences.GetSequence("overlay", "{0}-{1}".F(Info.TileValidName, tileset)).GetSprite(0);
if (self.World.Map.Rules.Sequences.HasSequence("overlay", $"{Info.TileValidName}-{tileset}"))
Tile = self.World.Map.Rules.Sequences.GetSequence("overlay", $"{Info.TileValidName}-{tileset}").GetSprite(0);
else
Tile = self.World.Map.Rules.Sequences.GetSequence("overlay", Info.TileValidName).GetSprite(0);
}
@@ -220,9 +220,9 @@ namespace OpenRA.Mods.Cnc.Traits
minelayer = a.Trait<Minelayer>();
var tileset = a.World.Map.Tileset.ToLowerInvariant();
if (a.World.Map.Rules.Sequences.HasSequence("overlay", "{0}-{1}".F(minelayer.Info.TileValidName, tileset)))
if (a.World.Map.Rules.Sequences.HasSequence("overlay", $"{minelayer.Info.TileValidName}-{tileset}"))
{
var validSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", "{0}-{1}".F(minelayer.Info.TileValidName, tileset));
var validSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", $"{minelayer.Info.TileValidName}-{tileset}");
validTile = validSequence.GetSprite(0);
validAlpha = validSequence.GetAlpha(0);
}
@@ -233,9 +233,9 @@ namespace OpenRA.Mods.Cnc.Traits
validAlpha = validSequence.GetAlpha(0);
}
if (a.World.Map.Rules.Sequences.HasSequence("overlay", "{0}-{1}".F(minelayer.Info.TileUnknownName, tileset)))
if (a.World.Map.Rules.Sequences.HasSequence("overlay", $"{minelayer.Info.TileUnknownName}-{tileset}"))
{
var unknownSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", "{0}-{1}".F(minelayer.Info.TileUnknownName, tileset));
var unknownSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", $"{minelayer.Info.TileUnknownName}-{tileset}");
unknownTile = unknownSequence.GetSprite(0);
unknownAlpha = unknownSequence.GetAlpha(0);
}
@@ -246,9 +246,9 @@ namespace OpenRA.Mods.Cnc.Traits
unknownAlpha = unknownSequence.GetAlpha(0);
}
if (a.World.Map.Rules.Sequences.HasSequence("overlay", "{0}-{1}".F(minelayer.Info.TileInvalidName, tileset)))
if (a.World.Map.Rules.Sequences.HasSequence("overlay", $"{minelayer.Info.TileInvalidName}-{tileset}"))
{
var blockedSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", "{0}-{1}".F(minelayer.Info.TileInvalidName, tileset));
var blockedSequence = a.World.Map.Rules.Sequences.GetSequence("overlay", $"{minelayer.Info.TileInvalidName}-{tileset}");
blockedTile = blockedSequence.GetSprite(0);
blockedAlpha = blockedSequence.GetAlpha(0);
}

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
var weaponToLower = (Weapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weapon;

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
var weaponToLower = (Weapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weapon;

View File

@@ -249,7 +249,7 @@ namespace OpenRA.Mods.Cnc.Traits
else if (BorderIndices.TryGetValue(adjacency, out var indices))
UpdateSpriteLayers(cell, indices);
else
throw new InvalidOperationException("SpriteMap does not contain an index for Adjacency type '{0}'".F(adjacency));
throw new InvalidOperationException($"SpriteMap does not contain an index for Adjacency type '{adjacency}'");
}
void UpdateSpriteLayers(CPos cell, int[] indices)

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
if (format < 2)
{
Console.WriteLine("ERROR: Detected NewINIFormat {0}. Are you trying to import a Tiberian Dawn map?".F(format));
Console.WriteLine($"ERROR: Detected NewINIFormat {format}. Are you trying to import a Tiberian Dawn map?");
return;
}
}

View File

@@ -270,7 +270,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
var size = new Size(iniSize[2], 2 * iniSize[3]);
if (!utility.ModData.DefaultTerrainInfo.TryGetValue(tileset, out var terrainInfo))
throw new InvalidDataException("Unknown tileset {0}".F(tileset));
throw new InvalidDataException($"Unknown tileset {tileset}");
var map = new Map(Game.ModData, terrainInfo, size.Width, size.Height)
{
@@ -527,7 +527,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
ar.Add(new OwnerInit("Neutral"));
if (!map.Rules.Actors.ContainsKey(name))
Console.WriteLine("Ignoring unknown actor type: `{0}`".F(name));
Console.WriteLine($"Ignoring unknown actor type: `{name}`");
else
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, ar.Save()));
}
@@ -573,7 +573,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
ar.Add(new DeployStateInit(DeployState.Deployed));
if (!map.Rules.Actors.ContainsKey(name))
Console.WriteLine("Ignoring unknown actor type: `{0}`".F(name));
Console.WriteLine($"Ignoring unknown actor type: `{name}`");
else
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, ar.Save()));
}
@@ -600,7 +600,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
if (lightingTypes.ContainsKey(kv.Key))
parsed[kv.Key] = FieldLoader.GetValue<float>(kv.Key, kv.Value);
else
Console.WriteLine("Ignoring unknown lighting type: `{0}`".F(kv.Key));
Console.WriteLine($"Ignoring unknown lighting type: `{kv.Key}`");
}
// Merge Ground into Ambient

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
if (format > 1)
{
Console.WriteLine("ERROR: Detected NewINIFormat {0}. Are you trying to import a Red Alert map?".F(format));
Console.WriteLine($"ERROR: Detected NewINIFormat {format}. Are you trying to import a Red Alert map?");
return;
}
}

View File

@@ -63,8 +63,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
metadata.AppendLine("General:");
var name = args.Length > 3 ? args[3] : Path.GetFileNameWithoutExtension(args[2]);
metadata.AppendLine("\tName: {0}".F(name));
metadata.AppendLine("\tId: {0}".F(name.ToUpperInvariant()));
metadata.AppendLine($"\tName: {name}");
metadata.AppendLine($"\tId: {name.ToUpperInvariant()}");
metadata.AppendLine("\tHeightDebugColors: 00000080, 00004480, 00008880, 0000CC80, 0000FF80, 4400CC80," +
" 88008880, CC004480, FF110080, FF550080, FF990080, FFDD0080, DDFF0080, 99FF0080, 55FF0080, 11FF0080");
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
for (var tilesetGroupIndex = 0; ; tilesetGroupIndex++)
{
var section = file.GetSection("TileSet{0:D4}".F(tilesetGroupIndex));
var section = file.GetSection($"TileSet{tilesetGroupIndex:D4}");
var sectionCount = int.Parse(section.GetValue("TilesInSet", "1"));
var sectionFilename = section.GetValue("FileName", "").ToLowerInvariant();
@@ -88,29 +88,29 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
// Loop over templates
for (var i = 1; i <= sectionCount; i++, templateIndex++)
{
var templateFilename = "{0}{1:D2}.{2}".F(sectionFilename, i, extension);
var templateFilename = $"{sectionFilename}{i:D2}.{extension}";
if (!modData.DefaultFileSystem.Exists(templateFilename))
continue;
using (var s = modData.DefaultFileSystem.Open(templateFilename))
{
data.AppendLine("\tTemplate@{0}:".F(templateIndex));
data.AppendLine("\t\tCategories: {0}".F(sectionCategory));
data.AppendLine($"\tTemplate@{templateIndex}:");
data.AppendLine($"\t\tCategories: {sectionCategory}");
usedCategories.Add(sectionCategory);
data.AppendLine("\t\tId: {0}".F(templateIndex));
data.AppendLine($"\t\tId: {templateIndex}");
var images = new List<string>();
images.Add("{0}{1:D2}.{2}".F(sectionFilename, i, extension));
images.Add($"{sectionFilename}{i:D2}.{extension}");
for (var v = 'a'; v <= 'z'; v++)
{
var variant = "{0}{1:D2}{2}.{3}".F(sectionFilename, i, v, extension);
var variant = $"{sectionFilename}{i:D2}{v}.{extension}";
if (modData.DefaultFileSystem.Exists(variant))
images.Add(variant);
}
data.AppendLine("\t\tImages: {0}".F(images.JoinWith(", ")));
data.AppendLine($"\t\tImages: {images.JoinWith(", ")}");
var templateWidth = s.ReadUInt32();
var templateHeight = s.ReadUInt32();
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
for (var j = 0; j < offsets.Length; j++)
offsets[j] = s.ReadUInt32();
data.AppendLine("\t\tSize: {0}, {1}".F(templateWidth, templateHeight));
data.AppendLine($"\t\tSize: {templateWidth}, {templateHeight}");
data.AppendLine("\t\tTiles:");
for (var j = 0; j < offsets.Length; j++)
@@ -134,18 +134,18 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
var rampType = s.ReadUInt8();
if (terrainType >= terrainTypes.Length)
throw new InvalidDataException("Unknown terrain type {0} in {1}".F(terrainType, templateFilename));
throw new InvalidDataException($"Unknown terrain type {terrainType} in {templateFilename}");
data.AppendLine("\t\t\t{0}: {1}".F(j, terrainTypes[terrainType]));
data.AppendLine($"\t\t\t{j}: {terrainTypes[terrainType]}");
if (height != 0)
data.AppendLine("\t\t\t\tHeight: {0}".F(height));
data.AppendLine($"\t\t\t\tHeight: {height}");
if (rampType != 0)
data.AppendLine("\t\t\t\tRampType: {0}".F(rampType));
data.AppendLine($"\t\t\t\tRampType: {rampType}");
data.AppendLine("\t\t\t\tMinColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
data.AppendLine("\t\t\t\tMaxColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
data.AppendLine("\t\t\t\tZOffset: {0}".F(-tileSize.Height / 2.0f));
data.AppendLine($"\t\t\t\tMinColor: {s.ReadUInt8():X2}{s.ReadUInt8():X2}{s.ReadUInt8():X2}");
data.AppendLine($"\t\t\t\tMaxColor: {s.ReadUInt8():X2}{s.ReadUInt8():X2}{s.ReadUInt8():X2}");
data.AppendLine($"\t\t\t\tZOffset: {(-tileSize.Height / 2.0f)}");
data.AppendLine("\t\t\t\tZRamp: 0");
}
}
@@ -169,8 +169,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
terrainTypes = terrainTypes.Distinct().ToArray();
foreach (var terrainType in terrainTypes)
{
metadata.AppendLine("\tTerrainType@{0}:".F(terrainType));
metadata.AppendLine("\t\tType: {0}".F(terrainType));
metadata.AppendLine($"\tTerrainType@{terrainType}:");
metadata.AppendLine($"\t\tType: {terrainType}");
if (terrainType == "Water")
metadata.AppendLine("\t\tTargetTypes: Water");