diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index 6e3cc6038f..16868e8e7d 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -424,8 +424,10 @@ namespace OpenRA if (!dupKeys.TryGetValue(key, out var dupKeyMessages)) { // Log the initial conflicting value already inserted: - dupKeyMessages = new List(); - dupKeyMessages.Add(logValue(d[key])); + dupKeyMessages = new List + { + logValue(d[key]) + }; dupKeys.Add(key, dupKeyMessages); } diff --git a/OpenRA.Game/MiniYaml.cs b/OpenRA.Game/MiniYaml.cs index 67df1e5c26..8186cc2d74 100644 --- a/OpenRA.Game/MiniYaml.cs +++ b/OpenRA.Game/MiniYaml.cs @@ -154,8 +154,10 @@ namespace OpenRA if (stringPool == null) stringPool = new Dictionary(); - var levels = new List>(); - levels.Add(new List()); + var levels = new List> + { + new List() + }; var lineNo = 0; foreach (var ll in lines) @@ -323,8 +325,10 @@ namespace OpenRA var resolved = new Dictionary(tree.Count); foreach (var kv in tree) { - var inherited = new Dictionary(); - inherited.Add(kv.Key, default(MiniYamlNode.SourceLocation)); + var inherited = new Dictionary + { + { kv.Key, default(MiniYamlNode.SourceLocation) } + }; var children = ResolveInherits(kv.Value, tree, inherited); resolved.Add(kv.Key, new MiniYaml(kv.Value.Value, children)); diff --git a/OpenRA.Game/Network/Handshake.cs b/OpenRA.Game/Network/Handshake.cs index 295956d680..fce45e3e2d 100644 --- a/OpenRA.Game/Network/Handshake.cs +++ b/OpenRA.Game/Network/Handshake.cs @@ -77,10 +77,12 @@ namespace OpenRA.Network public string Serialize() { - var data = new List(); - data.Add(new MiniYamlNode("Handshake", null, - new[] { "Mod", "Version", "Password", "Fingerprint", "AuthSignature", "OrdersProtocol" }.Select(p => FieldSaver.SaveField(this, p)).ToList())); - data.Add(new MiniYamlNode("Client", FieldSaver.Save(Client))); + var data = new List + { + new MiniYamlNode("Handshake", null, + new[] { "Mod", "Version", "Password", "Fingerprint", "AuthSignature", "OrdersProtocol" }.Select(p => FieldSaver.SaveField(this, p)).ToList()), + new MiniYamlNode("Client", FieldSaver.Save(Client)) + }; return data.WriteToString(); } diff --git a/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs b/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs index 7c42bdcd1b..46f7cf80c5 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/ImportTSMapCommand.cs @@ -503,9 +503,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands var dy = rx + ry - fullSize.X - 1; var cell = new MPos(dx / 2, dy).ToCPos(map); - var ar = new ActorReference((!int.TryParse(kv.Key, out var wpindex) || wpindex > 7) ? "waypoint" : "mpspawn"); - ar.Add(new LocationInit(cell)); - ar.Add(new OwnerInit("Neutral")); + var ar = new ActorReference((!int.TryParse(kv.Key, out var wpindex) || wpindex > 7) ? "waypoint" : "mpspawn") + { + new LocationInit(cell), + new OwnerInit("Neutral") + }; map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, ar.Save())); } @@ -524,9 +526,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands var cell = new MPos(dx / 2, dy).ToCPos(map); var name = kv.Value.ToLowerInvariant(); - var ar = new ActorReference(name); - ar.Add(new LocationInit(cell)); - ar.Add(new OwnerInit("Neutral")); + var ar = new ActorReference(name) + { + new LocationInit(cell), + new OwnerInit("Neutral") + }; if (!map.Rules.Actors.ContainsKey(name)) Console.WriteLine($"Ignoring unknown actor type: `{name}`"); diff --git a/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs b/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs index c26217407e..47f388f561 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/LegacyTilesetImporter.cs @@ -100,9 +100,10 @@ namespace OpenRA.Mods.Cnc.UtilityCommands data.AppendLine($"\t\tId: {templateIndex}"); - var images = new List(); - - images.Add($"{sectionFilename}{i:D2}.{extension}"); + var images = new List + { + $"{sectionFilename}{i:D2}.{extension}" + }; for (var v = 'a'; v <= 'z'; v++) { var variant = $"{sectionFilename}{i:D2}{v}.{extension}"; diff --git a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs index 27c6bb3523..63ebf343ea 100644 --- a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs @@ -35,9 +35,10 @@ namespace OpenRA.Mods.Common.Scripting if (!Context.World.Map.Rules.Actors.TryGetValue(actorType, out var ai)) throw new LuaException($"Unknown actor type '{actorType}'"); - var initDict = new TypeDictionary(); - - initDict.Add(new OwnerInit(owner)); + var initDict = new TypeDictionary + { + new OwnerInit(owner) + }; if (entryLocation.HasValue) { diff --git a/OpenRA.Mods.Common/Traits/World/EditorCursorLayer.cs b/OpenRA.Mods.Common/Traits/World/EditorCursorLayer.cs index a99190860f..787f45706a 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorCursorLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorCursorLayer.cs @@ -161,9 +161,11 @@ namespace OpenRA.Mods.Common.Traits if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName)) ownerName = specificOwnerInfo.ValidOwnerNames.First(); - var reference = new ActorReference(actor.Name); - reference.Add(new OwnerInit(ownerName)); - reference.Add(new FactionInit(owner.Faction)); + var reference = new ActorReference(actor.Name) + { + new OwnerInit(ownerName), + new FactionInit(owner.Faction) + }; var worldPx = wr.Viewport.ViewToWorldPx(Viewport.LastMousePos) - wr.ScreenPxOffset(actorCenterOffset); var cell = wr.Viewport.ViewToWorld(wr.Viewport.WorldToViewPx(worldPx)); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index 09d925a8f0..2f8e24cbb8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -181,9 +181,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic continue; var actor = a.Actor; - var td = new TypeDictionary(); - td.Add(new OwnerInit(selectedOwner.Name)); - td.Add(new FactionInit(selectedOwner.Faction)); + var td = new TypeDictionary + { + new OwnerInit(selectedOwner.Name), + new FactionInit(selectedOwner.Faction) + }; foreach (var api in actor.TraitInfos()) foreach (var o in api.ActorPreviewInits(actor, ActorPreviewType.MapEditorSidebar)) td.Add(o); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs index b01d1e216e..90ece02bbf 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs @@ -418,13 +418,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic ? new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height) : w.Parent.Bounds; - var substitutions = new Dictionary(); - substitutions.Add("WINDOW_RIGHT", Game.Renderer.Resolution.Width); - substitutions.Add("WINDOW_BOTTOM", Game.Renderer.Resolution.Height); - substitutions.Add("PARENT_RIGHT", parentBounds.Width); - substitutions.Add("PARENT_LEFT", parentBounds.Left); - substitutions.Add("PARENT_TOP", parentBounds.Top); - substitutions.Add("PARENT_BOTTOM", parentBounds.Height); + var substitutions = new Dictionary + { + { "WINDOW_RIGHT", Game.Renderer.Resolution.Width }, + { "WINDOW_BOTTOM", Game.Renderer.Resolution.Height }, + { "PARENT_RIGHT", parentBounds.Width }, + { "PARENT_LEFT", parentBounds.Left }, + { "PARENT_TOP", parentBounds.Top }, + { "PARENT_BOTTOM", parentBounds.Height } + }; var width = Evaluator.Evaluate(w.Width, substitutions); var height = Evaluator.Evaluate(w.Height, substitutions);