Replace F extension with string interpolation
This commit is contained in:
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var weaponToLower = Explosion.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}'");
|
||||
|
||||
ExplosionWeapon = weapon;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.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;
|
||||
ModifiedRange = new WDist(Util.ApplyPercentageModifiers(
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
ai.TraitInfos<IRangeModifierInfo>().Select(m => m.GetRangeModifierDefault())));
|
||||
|
||||
if (WeaponInfo.Burst > 1 && WeaponInfo.BurstDelays.Length > 1 && (WeaponInfo.BurstDelays.Length != WeaponInfo.Burst - 1))
|
||||
throw new YamlException("Weapon '{0}' has an invalid number of BurstDelays, must be single entry or Burst - 1.".F(weaponToLower));
|
||||
throw new YamlException($"Weapon '{weaponToLower}' has an invalid number of BurstDelays, must be single entry or Burst - 1.");
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (location == null)
|
||||
{
|
||||
AIUtils.BotDebug("{0} has nowhere to place {1}".F(player, currentBuilding.Item));
|
||||
AIUtils.BotDebug($"{player} has nowhere to place {currentBuilding.Item}");
|
||||
bot.QueueOrder(Order.CancelProduction(queue.Actor, currentBuilding.Item, 1));
|
||||
failCount += failCount;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Tell the idle harvester to quit slacking:
|
||||
var newSafeResourcePatch = FindNextResource(h.Key, h.Value);
|
||||
AIUtils.BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(h.Key, newSafeResourcePatch));
|
||||
AIUtils.BotDebug($"AI: Harvester {h.Key} is idle. Ordering to {newSafeResourcePatch} in search for new resources.");
|
||||
bot.QueueOrder(new Order("Harvest", h.Key, newSafeResourcePatch, false));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var weaponToLower = DemolishWeapon.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}'");
|
||||
|
||||
DemolishWeaponInfo = weapon;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var fp = footprintYaml.Value.Value;
|
||||
var dims = dim.X + "x" + dim.Y;
|
||||
throw new YamlException("Invalid footprint: {0} does not match dimensions {1}".F(fp, dims));
|
||||
throw new YamlException($"Invalid footprint: {fp} does not match dimensions {dims}");
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var c = footprintChars[index++];
|
||||
if (!Enum.IsDefined(typeof(FootprintCellType), (FootprintCellType)c))
|
||||
throw new YamlException("Invalid footprint cell type '{0}'".F(c));
|
||||
throw new YamlException($"Invalid footprint cell type '{c}'");
|
||||
|
||||
ret[new CVec(x, y)] = (FootprintCellType)c;
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
topLeftScreenOffset = -wr.ScreenPxOffset(centerOffset);
|
||||
|
||||
var tileset = world.Map.Tileset.ToLowerInvariant();
|
||||
if (world.Map.Rules.Sequences.HasSequence("overlay", "build-valid-{0}".F(tileset)))
|
||||
if (world.Map.Rules.Sequences.HasSequence("overlay", $"build-valid-{tileset}"))
|
||||
{
|
||||
var validSequence = world.Map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset));
|
||||
var validSequence = world.Map.Rules.Sequences.GetSequence("overlay", $"build-valid-{tileset}");
|
||||
validTile = validSequence.GetSprite(0);
|
||||
validAlpha = validSequence.GetAlpha(0);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var weaponToLower = (DemolishWeapon ?? 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}'");
|
||||
|
||||
DemolishWeaponInfo = weapon;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (Game.IsCurrentWorld(self.World))
|
||||
throw new InvalidOperationException(
|
||||
"Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})".F(
|
||||
forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));
|
||||
$"Attempted to finalize an undisposed DisposableAction. {forActor.Info.Name} ({forActor.ActorID}) reserved {self.Info.Name} ({self.ActorID})");
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
|
||||
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
|
||||
if (LocomotorInfo == null)
|
||||
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
|
||||
throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist.");
|
||||
else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1)
|
||||
throw new YamlException("There is more than one locomotor named '{0}'.".F(Locomotor));
|
||||
throw new YamlException($"There is more than one locomotor named '{Locomotor}'.");
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
{
|
||||
if (ShowTicks && !info.HasTraitInfo<IOccupySpaceInfo>())
|
||||
throw new YamlException("CashTrickler is defined with ShowTicks 'true' but actor '{0}' occupies no space.".F(info.Name));
|
||||
throw new YamlException($"CashTrickler is defined with ShowTicks 'true' but actor '{info.Name}' occupies no space.");
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CashTrickler(this); }
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var maxHP = healthInfo.MaxHP > 0 ? healthInfo.MaxHP : 1;
|
||||
var damageText = "{0} ({1}%)".F(-e.Damage.Value, e.Damage.Value * 100 / maxHP);
|
||||
var damageText = $"{-e.Damage.Value} ({e.Damage.Value * 100 / maxHP}%)";
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color, damageText, 30)));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var health = ai.TraitInfo<IHealthInfo>();
|
||||
if (health.MaxHP < MinHP)
|
||||
throw new YamlException("Minimum HP ({0}) for GrantConditionOnHealth can't be more than actor's Maximum HP ({1})".F(MinHP, health.MaxHP));
|
||||
throw new YamlException($"Minimum HP ({MinHP}) for GrantConditionOnHealth can't be more than actor's Maximum HP ({health.MaxHP})");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var weaponToLower = Weapon.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;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var emptyWeaponToLower = EmptyWeapon.ToLowerInvariant();
|
||||
if (!rules.Weapons.TryGetValue(emptyWeaponToLower, out var emptyWeapon))
|
||||
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(emptyWeaponToLower));
|
||||
throw new YamlException($"Weapons Ruleset does not contain an entry '{emptyWeaponToLower}'");
|
||||
EmptyWeaponInfo = emptyWeapon;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var weaponToLower = Weapon.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;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
catch (YamlException e)
|
||||
{
|
||||
throw new YamlException("HitShape {0}: {1}".F(shape, e.Message));
|
||||
throw new YamlException($"HitShape {shape}: {e.Message}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
|
||||
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
|
||||
if (LocomotorInfo == null)
|
||||
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
|
||||
throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist.");
|
||||
else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1)
|
||||
throw new YamlException("There is more than one locomotor named '{0}'.".F(Locomotor));
|
||||
throw new YamlException($"There is more than one locomotor named '{Locomotor}'.");
|
||||
|
||||
// We need to reset the reference to the locomotor between each worlds, otherwise we are reference the previous state.
|
||||
locomotor = null;
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
|
||||
self.Trait<PlayerResources>().ChangeCash(amount);
|
||||
|
||||
debugSuffix = " ({0} credits)".F(amount);
|
||||
debugSuffix = $" ({amount} credits)";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var player in receivingPlayers)
|
||||
player.PlayerActor.Trait<PlayerResources>().ChangeCash(amount);
|
||||
|
||||
debugSuffix = " ({0} credits)".F(amount);
|
||||
debugSuffix = $" ({amount} credits)";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (c == 0)
|
||||
return "No limit";
|
||||
else
|
||||
return c.ToString() + " minute{0}".F(c > 1 ? "s" : null);
|
||||
return c.ToString() + $" minute{(c > 1 ? "s" : null)}";
|
||||
});
|
||||
|
||||
yield return new LobbyOption("timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return forPlayer == self.Owner;
|
||||
}
|
||||
|
||||
public string TooltipText => "Power Usage: {0}{1}".F(powerManager.PowerDrained, developerMode.UnlimitedPower ? "" : "/" + powerManager.PowerProvided);
|
||||
public string TooltipText => $"Power Usage: {powerManager.PowerDrained}{(developerMode.UnlimitedPower ? "" : "/" + powerManager.PowerProvided)}";
|
||||
|
||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
queue = rules.Actors[SystemActors.Player].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||
|
||||
if (queue == null)
|
||||
throw new YamlException("Can't find a queue with ProductionType '{0}'".F(ProductionType));
|
||||
throw new YamlException($"Can't find a queue with ProductionType '{ProductionType}'");
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
if (squad == null)
|
||||
yield break;
|
||||
|
||||
var aiSquadInfo = "{0}, {1}".F(squad.Type, squad.TargetActor);
|
||||
var aiSquadInfo = $"{squad.Type}, {squad.TargetActor}";
|
||||
yield return new TextAnnotationRenderable(font, self.CenterPosition + offset, 0, color, aiSquadInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
|
||||
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
|
||||
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
{
|
||||
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
|
||||
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
|
||||
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithTextControlGroupDecoration(init.Self, this); }
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
|
||||
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
|
||||
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var weaponToLower = (MissileWeapon ?? 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;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var utLower = info.UnitType.ToLowerInvariant();
|
||||
if (!self.World.Map.Rules.Actors.TryGetValue(utLower, out var unitType))
|
||||
throw new YamlException("Actors ruleset does not include the entry '{0}'".F(utLower));
|
||||
throw new YamlException($"Actors ruleset does not include the entry '{utLower}'");
|
||||
|
||||
var altitude = unitType.TraitInfo<AircraftInfo>().CruiseAltitude.Length;
|
||||
var dropRotation = WRot.FromYaw(facing.Value);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var weaponToLower = w.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}'");
|
||||
return weapon;
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
@@ -45,13 +45,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.RulesetLoaded(rules, ai);
|
||||
|
||||
if (SpawnInterval.Length == 0 || SpawnInterval.Length > 2)
|
||||
throw new YamlException("{0}.{1} must be either 1 or 2 values".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
|
||||
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)} must be either 1 or 2 values");
|
||||
|
||||
if (SpawnInterval.Length == 2 && SpawnInterval[0] >= SpawnInterval[1])
|
||||
throw new YamlException("{0}.{1}'s first value must be less than the second value".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
|
||||
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)}'s first value must be less than the second value");
|
||||
|
||||
if (SpawnInterval.Any(it => it < 0))
|
||||
throw new YamlException("{0}.{1}'s value(s) must not be less than 0".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
|
||||
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)}'s value(s) must not be less than 0");
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
if (!worldOwnerFound)
|
||||
throw new InvalidOperationException("Map {0} does not define a player actor owning the world.".F(w.Map.Title));
|
||||
throw new InvalidOperationException($"Map {w.Map.Title} does not define a player actor owning the world.");
|
||||
|
||||
Player localPlayer = null;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
domains = new CellLayer<ushort>(world.Map);
|
||||
transientConnections = new Dictionary<ushort, HashSet<ushort>>();
|
||||
|
||||
using (new PerfTimer("BuildDomains: {0} for movement class {1}".F(world.Map.Title, movementClass)))
|
||||
using (new PerfTimer($"BuildDomains: {world.Map.Title} for movement class {movementClass}"))
|
||||
BuildDomains(world);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,12 +205,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
for (var index = 0; index < newCount; index++)
|
||||
{
|
||||
if (Players.Players.ContainsKey("Multi{0}".F(index)))
|
||||
if (Players.Players.ContainsKey($"Multi{index}"))
|
||||
continue;
|
||||
|
||||
var pr = new PlayerReference
|
||||
{
|
||||
Name = "Multi{0}".F(index),
|
||||
Name = $"Multi{index}",
|
||||
Faction = "Random",
|
||||
Playable = true,
|
||||
Enemies = new[] { "Creeps" }
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var world = worldRenderer.World;
|
||||
if (!world.Map.Rules.Actors.TryGetValue(reference.Type.ToLowerInvariant(), out Info))
|
||||
throw new InvalidDataException("Actor {0} of unknown type {1}".F(id, reference.Type.ToLowerInvariant()));
|
||||
throw new InvalidDataException($"Actor {id} of unknown type {reference.Type.ToLowerInvariant()}");
|
||||
|
||||
CenterPosition = PreviewPosition(world, reference);
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return world.Map.CenterOfSubCell(cell, subCell) + offset;
|
||||
}
|
||||
else
|
||||
throw new InvalidDataException("Actor {0} must define Location or CenterPosition".F(ID));
|
||||
throw new InvalidDataException($"Actor {ID} must define Location or CenterPosition");
|
||||
}
|
||||
|
||||
void GeneratePreviews()
|
||||
@@ -259,7 +259,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{0} {1}".F(Info.Name, ID);
|
||||
return $"{Info.Name} {ID}";
|
||||
}
|
||||
|
||||
public bool Equals(EditorActorPreview other)
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info = info;
|
||||
|
||||
if (!Game.Renderer.Fonts.TryGetValue(info.Font, out Font))
|
||||
throw new YamlException("Could not find font '{0}'".F(info.Font));
|
||||
throw new YamlException($"Could not find font '{info.Font}'");
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World w, WorldRenderer wr)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
if (Index.Length != ReplaceIndex.Length)
|
||||
throw new YamlException("ReplaceIndex length does not match Index length for palette {0}".F(Name));
|
||||
throw new YamlException($"ReplaceIndex length does not match Index length for palette {Name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common
|
||||
{
|
||||
foreach (var p in PlayerIndex)
|
||||
if (p.Value.Length != RemapIndex.Length)
|
||||
throw new YamlException("PlayerIndex for player `{0}` length does not match RemapIndex!".F(p.Key));
|
||||
throw new YamlException($"PlayerIndex for player `{p.Key}` length does not match RemapIndex!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
|
||||
if (GameSpeed != null && !gameSpeeds.ContainsKey(GameSpeed))
|
||||
throw new YamlException("Invalid default game speed '{0}'.".F(GameSpeed));
|
||||
throw new YamlException($"Invalid default game speed '{GameSpeed}'.");
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new MapOptions(this); }
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
using (var lines = s.ReadAllLines().GetEnumerator())
|
||||
{
|
||||
if (!lines.MoveNext() || (lines.Current != "GIMP Palette" && lines.Current != "JASC-PAL"))
|
||||
throw new InvalidDataException("File `{0}` is not a valid GIMP or JASC palette.".F(Filename));
|
||||
throw new InvalidDataException($"File `{Filename}` is not a valid GIMP or JASC palette.");
|
||||
|
||||
byte a;
|
||||
a = 255;
|
||||
@@ -76,16 +76,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var rgba = lines.Current.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (rgba.Length < 3)
|
||||
throw new InvalidDataException("Invalid RGB(A) triplet/quartet: ({0})".F(string.Join(" ", rgba)));
|
||||
throw new InvalidDataException($"Invalid RGB(A) triplet/quartet: ({string.Join(" ", rgba)})");
|
||||
|
||||
if (!byte.TryParse(rgba[0], out var r))
|
||||
throw new InvalidDataException("Invalid R value: {0}".F(rgba[0]));
|
||||
throw new InvalidDataException($"Invalid R value: {rgba[0]}");
|
||||
|
||||
if (!byte.TryParse(rgba[1], out var g))
|
||||
throw new InvalidDataException("Invalid G value: {0}".F(rgba[1]));
|
||||
throw new InvalidDataException($"Invalid G value: {rgba[1]}");
|
||||
|
||||
if (!byte.TryParse(rgba[2], out var b))
|
||||
throw new InvalidDataException("Invalid B value: {0}".F(rgba[2]));
|
||||
throw new InvalidDataException($"Invalid B value: {rgba[2]}");
|
||||
|
||||
// Check if color has a (valid) alpha value.
|
||||
// Note: We can't throw on "rgba.Length > 3 but parse failed", because in GIMP palettes the 'invalid' value is probably a color name string.
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var png = new Png(fileSystem.Open(Filename));
|
||||
|
||||
if (png.Palette == null)
|
||||
throw new InvalidOperationException("Unable to load palette `{0}` from non-paletted png `{1}`".F(Name, Filename));
|
||||
throw new InvalidOperationException($"Unable to load palette `{Name}` from non-paletted png `{Filename}`");
|
||||
|
||||
var colors = new uint[Palette.Size];
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.RandomOrDefault(w.SharedRandom);
|
||||
|
||||
if (unitGroup == null)
|
||||
throw new InvalidOperationException("No starting units defined for faction {0} with class {1}".F(p.Faction.InternalName, spawnClass));
|
||||
throw new InvalidOperationException($"No starting units defined for faction {p.Faction.InternalName} with class {spawnClass}");
|
||||
|
||||
if (unitGroup.BaseActor != null)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (validCell == CPos.Zero)
|
||||
{
|
||||
Log.Write("debug", "No cells available to spawn starting unit {0} for player {1}".F(s, p));
|
||||
Log.Write("debug", $"No cells available to spawn starting unit {s} for player {p}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var failed = false;
|
||||
Action<uint, string> onMissingImage = (id, f) =>
|
||||
{
|
||||
onError("\tTemplate `{0}` references sprite `{1}` that does not exist.".F(id, f));
|
||||
onError($"\tTemplate `{id}` references sprite `{f}` that does not exist.");
|
||||
missingImages.Add(f);
|
||||
failed = true;
|
||||
};
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (t.Value[i] == null || tileCache.HasTileSprite(new TerrainTile(t.Key, (byte)i), v))
|
||||
continue;
|
||||
|
||||
onError("\tTemplate `{0}` references frame {1} that does not exist in sprite `{2}`.".F(t.Key, i, templateInfo.Images[v]));
|
||||
onError($"\tTemplate `{t.Key}` references frame {i} that does not exist in sprite `{templateInfo.Images[v]}`.");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user