diff --git a/Generator/BaseBotGenerator.cs b/Generator/BaseBotGenerator.cs index b278b2e..b069a57 100644 --- a/Generator/BaseBotGenerator.cs +++ b/Generator/BaseBotGenerator.cs @@ -73,10 +73,7 @@ namespace Generator private void AddDifficulties(Bot bot, List rawParsedBots) { - var botType = bot.botType; - var firstBotOfDesiredType = rawParsedBots.First(x => x.Info.Settings.Role == botType.ToString()); - - switch (botType) + switch (bot.botType) { case BotType.assault: DifficultyHelper.AddAssaultDifficulties(bot); @@ -92,7 +89,13 @@ namespace Generator private void UpdateBodyPartHealth(Bot botToUpdate, List rawParsedBots) { - var firstBotOfDesiredType = rawParsedBots.First(x => x.Info.Settings.Role == botToUpdate.botType.ToString()); + var firstBotOfDesiredType = rawParsedBots.FirstOrDefault(x => x.Info.Settings.Role == botToUpdate.botType.ToString()); + if (firstBotOfDesiredType == null) + { + LoggingHelpers.LogToConsole($"bottype of: {botToUpdate.botType} not found, unable to update body part health."); + return; + } + botToUpdate.health.BodyParts.Head.min = firstBotOfDesiredType.Health.BodyParts.Head.Health.Current; botToUpdate.health.BodyParts.Head.max = firstBotOfDesiredType.Health.BodyParts.Head.Health.Maximum;