diff --git a/Libraries/Core/Controllers/BotController.cs b/Libraries/Core/Controllers/BotController.cs index b8389cf8..dc1de088 100644 --- a/Libraries/Core/Controllers/BotController.cs +++ b/Libraries/Core/Controllers/BotController.cs @@ -238,7 +238,7 @@ public class BotController( pmcProfile, false, raidSettings, - _botConfig.PresetBatch?.Get(requestedBot?.Role ?? string.Empty), + _botConfig.PresetBatch?.GetByJsonProp(requestedBot?.Role ?? string.Empty), _botHelper.IsBotPmc(requestedBot?.Role) ); @@ -269,7 +269,7 @@ public class BotController( botGenerationDetails.Role = _botHelper.GetRandomizedPmcRole(); botGenerationDetails.Side = _botHelper.GetPmcSideByRole(botGenerationDetails.Role); botGenerationDetails.BotDifficulty = GetPmcDifficulty(requestedBot?.Difficulty); - botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.Get(botGenerationDetails.Role); + botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetByJsonProp(botGenerationDetails.Role); } } @@ -279,7 +279,7 @@ public class BotController( var bossesToConvertToWeights = _botConfig.AssaultToBossConversion.BossesToConvertToWeights; if (bossConvertEnabled && botGenerationDetails.IsPmc is not null && !botGenerationDetails.IsPmc.Value) { - var bossConvertPercent = bossConvertMinMax.Get(requestedBot?.Role?.ToLower() ?? string.Empty); + var bossConvertPercent = bossConvertMinMax.GetByJsonProp(requestedBot?.Role?.ToLower() ?? string.Empty); if (bossConvertPercent is not null) { // Roll a percentage check if we should convert scav to boss @@ -330,7 +330,7 @@ public class BotController( // Bosses are only ever 'normal' botGenerationDetails.BotDifficulty = "normal"; - botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.Get(botGenerationDetails.Role); + botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetByJsonProp(botGenerationDetails.Role); } private string? GetPmcDifficulty(string? requestedBotDifficulty) @@ -348,8 +348,8 @@ public class BotController( { var mapSpecificConversionValues = _pmcConfig.ConvertIntoPmcChance!.GetValueOrDefault(location?.ToLower(), null); return mapSpecificConversionValues is null - ? _pmcConfig.ConvertIntoPmcChance.Get>("default").Get(requestedBotRole) - : mapSpecificConversionValues.Get(requestedBotRole?.ToLower()); + ? _pmcConfig.ConvertIntoPmcChance.GetByJsonProp>("default").GetByJsonProp(requestedBotRole) + : mapSpecificConversionValues.GetByJsonProp(requestedBotRole?.ToLower()); } private GetRaidConfigurationRequestData? GetMostRecentRaidSettings() diff --git a/Libraries/Core/Generators/RepeatableQuestGenerator.cs b/Libraries/Core/Generators/RepeatableQuestGenerator.cs index 99d14478..942f31dc 100644 --- a/Libraries/Core/Generators/RepeatableQuestGenerator.cs +++ b/Libraries/Core/Generators/RepeatableQuestGenerator.cs @@ -143,7 +143,7 @@ public class RepeatableQuestGenerator( var targetKey = targetsConfig.Draw()[0]; var targetDifficulty = 1 / targetsConfig.Probability(targetKey); - var locations = questTypePool.Pool.Elimination.Targets.Get(targetKey).Locations; + var locations = questTypePool.Pool.Elimination.Targets.GetByJsonProp(targetKey).Locations; // we use any as location if "any" is in the pool and we do not hit the specific location random // we use any also if the random condition is not met in case only "any" was in the pool @@ -161,11 +161,11 @@ public class RepeatableQuestGenerator( if (locations.Count > 0) { locationKey = _randomUtil.DrawRandomFromList(locations).FirstOrDefault(); - questTypePool.Pool.Elimination.Targets.Get(targetKey).Locations = locations.Where( + questTypePool.Pool.Elimination.Targets.GetByJsonProp(targetKey).Locations = locations.Where( (l) => l != locationKey ) .ToList(); - if (questTypePool.Pool.Elimination.Targets.Get(targetKey).Locations.Count == 0) + if (questTypePool.Pool.Elimination.Targets.GetByJsonProp(targetKey).Locations.Count == 0) { questTypePool.Pool.Elimination.Targets.Remove(targetKey); } diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index c3ae5ce9..8ef74216 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -122,8 +122,8 @@ public class BotEquipmentFilterService foreach (var itemKey in generationChanges) { - baseBotGeneration.Items.Get(itemKey.Key).Weights = generationChanges.Get(itemKey.Key).Weights; - baseBotGeneration.Items.Get(itemKey.Key).Whitelist = generationChanges.Get(itemKey.Key).Whitelist; + baseBotGeneration.Items.GetByJsonProp(itemKey.Key).Weights = generationChanges.GetByJsonProp(itemKey.Key).Weights; + baseBotGeneration.Items.GetByJsonProp(itemKey.Key).Whitelist = generationChanges.GetByJsonProp(itemKey.Key).Whitelist; } } diff --git a/SptCommon/Extensions/ObjectExtensions.cs b/SptCommon/Extensions/ObjectExtensions.cs index c8e67d21..9fde7371 100644 --- a/SptCommon/Extensions/ObjectExtensions.cs +++ b/SptCommon/Extensions/ObjectExtensions.cs @@ -29,7 +29,7 @@ namespace SptCommon.Extensions /// /// /// - public static bool Contains(this object? obj, T key) + public static bool ContainsJsonProp(this object? obj, T key) { if (obj == null) { @@ -39,7 +39,7 @@ namespace SptCommon.Extensions return TryGetCachedProperty(obj.GetType(), key.ToString(), out _); } - public static T? Get(this object? obj, string? toLower) + public static T? GetByJsonProp(this object? obj, string? toLower) { ArgumentNullException.ThrowIfNull(obj); ArgumentNullException.ThrowIfNull(toLower);