From 4bf2c72257e52f44ef19494beaa472e3ae62147a Mon Sep 17 00:00:00 2001 From: CWX Date: Thu, 16 Jan 2025 10:48:00 +0000 Subject: [PATCH] fix null guard --- Core/Generators/BotGenerator.cs | 2 +- Core/Services/BotEquipmentFilterService.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/Generators/BotGenerator.cs b/Core/Generators/BotGenerator.cs index 249fc9fb..a4462785 100644 --- a/Core/Generators/BotGenerator.cs +++ b/Core/Generators/BotGenerator.cs @@ -497,7 +497,7 @@ public class BotGenerator // Some bodies have matching hands, look up body to see if this is the case var chosenBody = bodyGlobalDictDb.FirstOrDefault(c => c.Key == chosenBodyTemplate?.Name.Trim()); - bot.Customization.Hands = chosenBody.Value.IsNotRandom ?? false + bot.Customization.Hands = chosenBody.Value?.IsNotRandom ?? false ? chosenBody.Value.Hands // Has fixed hands for chosen body, update to match : _weightedRandomHelper.GetWeightedValue(appearance.Hands); // Hands can be random, choose any from weighted dict } diff --git a/Core/Services/BotEquipmentFilterService.cs b/Core/Services/BotEquipmentFilterService.cs index 0d4543c3..42f23d97 100644 --- a/Core/Services/BotEquipmentFilterService.cs +++ b/Core/Services/BotEquipmentFilterService.cs @@ -78,7 +78,13 @@ public class BotEquipmentFilterService /// Dictionary of weapon type and their whitelisted scope types public Dictionary> GetBotWeaponSightWhitelist(string botEquipmentRole) { - throw new NotImplementedException(); + var botEquipmentSettings = _botConfig.Equipment[botEquipmentRole]; + + if (botEquipmentSettings is null) { + return null; + } + + return botEquipmentSettings.WeaponSightWhitelist; } ///