From e4664b3d27bb9630dddcf6b3a2902c5bb2173a21 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 29 Nov 2017 19:16:31 +0200 Subject: [PATCH] The character spawning debug command doesn't require the config file of the character to be in the default character folder (as long as the character is included in the selected content package). --- .../BarotraumaShared/Source/DebugConsole.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index 922a61d13..c40d5d776 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -4,6 +4,7 @@ using FarseerPhysics; using Microsoft.Xna.Framework; using System; using System.Collections.Generic; +using System.IO; using System.Linq; namespace Barotrauma @@ -181,10 +182,24 @@ namespace Barotrauma } else { - spawnedCharacter = Character.Create( - "Content/Characters/" + List characterFiles = GameMain.Config.SelectedContentPackage.GetFilesOfType(ContentType.Character); + + foreach (string characterFile in characterFiles) + { + if (Path.GetFileNameWithoutExtension(characterFile).ToLowerInvariant() == args[0].ToLowerInvariant()) + { + Character.Create(characterFile, spawnPosition); + return; + } + } + + ThrowError("No character matching the name \"" + args[0] + "\" found in the selected content package."); + + //attempt to open the config from the default path (the file may still be present even if it isn't included in the content package) + string configPath = "Content/Characters/" + args[0].First().ToString().ToUpper() + args[0].Substring(1) - + "/" + args[0].ToLower() + ".xml", spawnPosition); + + "/" + args[0].ToLower() + ".xml"; + Character.Create(configPath, spawnPosition); } }));