Replace F extension with string interpolation
This commit is contained in:
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
var initInstance = initName.Split(ActorInfo.TraitInstanceSeparator);
|
||||
var initType = Game.ModData.ObjectCreator.FindType(initInstance[0] + "Init");
|
||||
if (initType == null)
|
||||
throw new LuaException("Unknown initializer type '{0}'".F(initInstance[0]));
|
||||
throw new LuaException($"Unknown initializer type '{initInstance[0]}'");
|
||||
|
||||
// Construct the ActorInit.
|
||||
var init = (ActorInit)FormatterServices.GetUninitializedObject(initType);
|
||||
@@ -51,14 +51,14 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
var key = kv.Key.ToString();
|
||||
if (!args.TryGetValue(key, out var type))
|
||||
throw new LuaException("Unknown initializer type '{0}.{1}'".F(initInstance[0], key));
|
||||
throw new LuaException($"Unknown initializer type '{initInstance[0]}.{key}'");
|
||||
|
||||
var isActorReference = type == typeof(ActorInitActorReference);
|
||||
if (isActorReference)
|
||||
type = kv.Value is LuaString ? typeof(string) : typeof(Actor);
|
||||
|
||||
if (!kv.Value.TryGetClrValue(type, out var clrValue))
|
||||
throw new LuaException("Invalid data type for '{0}.{1}' (expected {2}, got {3})".F(initInstance[0], key, type.Name, kv.Value.WrappedClrType()));
|
||||
throw new LuaException($"Invalid data type for '{initInstance[0]}.{key}' (expected {type.Name}, got {kv.Value.WrappedClrType()})");
|
||||
|
||||
if (isActorReference)
|
||||
clrValue = type == typeof(string) ? new ActorInitActorReference((string)clrValue) : new ActorInitActorReference((Actor)clrValue);
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
var types = initializers.Select(y => y.GetParameters()[0].ParameterType.Name).JoinWith(", ");
|
||||
throw new LuaException("Invalid data type for '{0}' (expected one of {1})".F(initInstance[0], types));
|
||||
throw new LuaException($"Invalid data type for '{initInstance[0]}' (expected one of {types})");
|
||||
}
|
||||
|
||||
[Desc("Create a new actor. initTable specifies a list of key-value pairs that defines the initial parameters for the actor's traits.")]
|
||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
|
||||
var owner = initDict.GetOrDefault<OwnerInit>();
|
||||
if (owner == null)
|
||||
throw new LuaException("Tried to create actor '{0}' with an invalid or no owner init!".F(type));
|
||||
throw new LuaException($"Tried to create actor '{type}' with an invalid or no owner init!");
|
||||
|
||||
// The actor must be added to the world at the end of the tick
|
||||
var a = Context.World.CreateActor(false, type, initDict);
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int BuildTime(string type, string queue = null)
|
||||
{
|
||||
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||
throw new LuaException($"Unknown actor type '{type}'");
|
||||
|
||||
var bi = ai.TraitInfoOrDefault<BuildableInfo>();
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
.Where(x => x.Type == queue)).FirstOrDefault();
|
||||
|
||||
if (pqueue == null)
|
||||
throw new LuaException("The specified queue '{0}' does not exist!".F(queue));
|
||||
throw new LuaException($"The specified queue '{queue}' does not exist!");
|
||||
|
||||
pbi = pqueue.BuildDurationModifier;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
.Where(x => bi.Queue.Contains(x.Type))).FirstOrDefault();
|
||||
|
||||
if (pqueue == null)
|
||||
throw new LuaException("No actors can produce actor '{0}'!".F(type));
|
||||
throw new LuaException($"No actors can produce actor '{type}'!");
|
||||
|
||||
pbi = pqueue.BuildDurationModifier;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int CruiseAltitude(string type)
|
||||
{
|
||||
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||
throw new LuaException($"Unknown actor type '{type}'");
|
||||
|
||||
var pi = ai.TraitInfoOrDefault<ICruiseAltitudeInfo>();
|
||||
return pi != null ? pi.GetCruiseAltitude().Length : 0;
|
||||
@@ -189,11 +189,11 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int Cost(string type)
|
||||
{
|
||||
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||
throw new LuaException($"Unknown actor type '{type}'");
|
||||
|
||||
var vi = ai.TraitInfoOrDefault<ValuedInfo>();
|
||||
if (vi == null)
|
||||
throw new LuaException("Actor type '{0}' does not have the Valued trait required to get the Cost.".F(type));
|
||||
throw new LuaException($"Actor type '{type}' does not have the Valued trait required to get the Cost.");
|
||||
|
||||
return vi.Cost;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user