Removed hard-coded path to humanhusk (now the huskified human config is found based on the name), characters with severed limbs cannot turn into husks. Closes #243

This commit is contained in:
Joonas Rikkonen
2018-02-05 15:55:32 +02:00
parent 60ad5ed3fb
commit ff85400f01

View File

@@ -142,6 +142,15 @@ namespace Barotrauma
private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
{
if (GameMain.Client != null) return;
//don't turn the character into a husk if any of its limbs are severed
if (character.AnimController?.LimbJoints != null)
{
foreach (var limbJoint in character.AnimController.LimbJoints)
{
if (limbJoint.IsSevered) return;
}
}
//create the AI husk in a coroutine to ensure that we don't modify the character list while enumerating it
CoroutineManager.StartCoroutine(CreateAIHusk(character));
@@ -152,11 +161,16 @@ namespace Barotrauma
character.Enabled = false;
Entity.Spawner.AddToRemoveQueue(character);
var husk = Character.Create(
Path.Combine("Content", "Characters", "Human", "humanhusk.xml"),
character.WorldPosition,
character.Info,
false, true);
var characterFiles = GameMain.SelectedPackage.GetFilesOfType(ContentType.Character);
var configFile = characterFiles.Find(f => Path.GetFileNameWithoutExtension(f) == "humanhusk");
if (string.IsNullOrEmpty(configFile))
{
DebugConsole.ThrowError("Failed to turn character \"" + character.Name + "\" into a husk - humanhusk config file not found.");
yield return CoroutineStatus.Success;
}
var husk = Character.Create(configFile, character.WorldPosition, character.Info, false, true);
foreach (Limb limb in husk.AnimController.Limbs)
{