Change prop method naming to be more consistent
This commit is contained in:
@@ -31,7 +31,7 @@ public static class ObjectExtensions
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static bool ContainsJsonProp<T>(this object? obj, T key)
|
||||
public static bool ContainsJsonProperty<T>(this object? obj, T key)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj);
|
||||
ArgumentNullException.ThrowIfNull(key);
|
||||
@@ -39,7 +39,7 @@ public static class ObjectExtensions
|
||||
return TryGetCachedProperty(obj.GetType(), key.ToString(), out _);
|
||||
}
|
||||
|
||||
public static T? GetByJsonProp<T>(this object? obj, string? toLower)
|
||||
public static T? GetByJsonProperty<T>(this object? obj, string? toLower)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj);
|
||||
ArgumentNullException.ThrowIfNull(toLower);
|
||||
@@ -52,7 +52,7 @@ public static class ObjectExtensions
|
||||
return (T?)cachedProperty.GetValue(obj);
|
||||
}
|
||||
|
||||
public static List<object> GetAllPropValuesAsList(this object? obj)
|
||||
public static List<object> GetAllPropertyValuesAsList(this object? obj)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj);
|
||||
|
||||
@@ -81,7 +81,7 @@ public static class ObjectExtensions
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Dictionary<string, object?> GetAllPropsAsDict(this object? obj)
|
||||
public static Dictionary<string, object?> GetAllPropertiesAsDictionary(this object? obj)
|
||||
{
|
||||
if (obj is null)
|
||||
{
|
||||
|
||||
@@ -465,29 +465,29 @@ public class ScavCaseRewardGenerator(
|
||||
if (id == Money.ROUBLES)
|
||||
{
|
||||
return randomUtil.GetInt(
|
||||
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax<int>>(rarity).Max
|
||||
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProperty<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProperty<MinMax<int>>(rarity).Max
|
||||
);
|
||||
}
|
||||
else if (id == Money.EUROS)
|
||||
{
|
||||
return randomUtil.GetInt(
|
||||
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax<int>>(rarity).Max
|
||||
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProperty<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProperty<MinMax<int>>(rarity).Max
|
||||
);
|
||||
}
|
||||
else if (id == Money.DOLLARS)
|
||||
{
|
||||
return randomUtil.GetInt(
|
||||
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax<int>>(rarity).Max
|
||||
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProperty<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProperty<MinMax<int>>(rarity).Max
|
||||
);
|
||||
}
|
||||
else if (id == Money.GP)
|
||||
{
|
||||
return randomUtil.GetInt(
|
||||
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax<int>>(rarity).Max
|
||||
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProperty<MinMax<int>>(rarity).Min,
|
||||
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProperty<MinMax<int>>(rarity).Max
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -243,7 +243,7 @@ public class InRaidHelper(
|
||||
if (itemToCheck.ParentId == pmcData.Inventory.Equipment)
|
||||
{
|
||||
// Check slot id against config, true = delete, false = keep, undefined = delete
|
||||
var discard = LostOnDeathConfig.Equipment.GetByJsonProp<bool>(itemToCheck.SlotId);
|
||||
var discard = LostOnDeathConfig.Equipment.GetByJsonProperty<bool>(itemToCheck.SlotId);
|
||||
if (discard)
|
||||
// Lost on death
|
||||
{
|
||||
|
||||
@@ -108,10 +108,10 @@ public class BotEquipmentFilterService(
|
||||
|
||||
foreach (var itemKey in generationChanges)
|
||||
{
|
||||
baseBotGeneration.Items.GetByJsonProp<GenerationData>(itemKey.Key).Weights = generationChanges
|
||||
baseBotGeneration.Items.GetByJsonProperty<GenerationData>(itemKey.Key).Weights = generationChanges
|
||||
.GetValueOrDefault(itemKey.Key)
|
||||
.Weights;
|
||||
baseBotGeneration.Items.GetByJsonProp<GenerationData>(itemKey.Key).Whitelist = generationChanges
|
||||
baseBotGeneration.Items.GetByJsonProperty<GenerationData>(itemKey.Key).Whitelist = generationChanges
|
||||
.GetValueOrDefault(itemKey.Key)
|
||||
.Whitelist;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ public class BotEquipmentFilterService(
|
||||
{
|
||||
foreach (var poolAdjustmentKvP in weightingAdjustments.Add)
|
||||
{
|
||||
var locationToUpdate = botItemPool.GetByJsonProp<Dictionary<MongoId, double>>(poolAdjustmentKvP.Key);
|
||||
var locationToUpdate = botItemPool.GetByJsonProperty<Dictionary<MongoId, double>>(poolAdjustmentKvP.Key);
|
||||
if (locationToUpdate is null)
|
||||
{
|
||||
continue;
|
||||
@@ -469,7 +469,7 @@ public class BotEquipmentFilterService(
|
||||
{
|
||||
foreach (var poolAdjustmentKvP in weightingAdjustments.Edit)
|
||||
{
|
||||
var locationToUpdate = botItemPool.GetByJsonProp<Dictionary<MongoId, double>>(poolAdjustmentKvP.Key);
|
||||
var locationToUpdate = botItemPool.GetByJsonProperty<Dictionary<MongoId, double>>(poolAdjustmentKvP.Key);
|
||||
if (locationToUpdate is null)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DatabaseService(
|
||||
/// <returns> assets/database/locations/ </returns>
|
||||
public Location? GetLocation(string locationId)
|
||||
{
|
||||
var desiredLocation = GetLocations().GetByJsonProp<Location>(locationId.ToLowerInvariant());
|
||||
var desiredLocation = GetLocations().GetByJsonProperty<Location>(locationId.ToLowerInvariant());
|
||||
if (desiredLocation == null)
|
||||
{
|
||||
logger.Error(serverLocalisationService.GetText("database-no_location_found_with_id", locationId));
|
||||
|
||||
@@ -528,7 +528,7 @@ public class RepairService(
|
||||
return false;
|
||||
}
|
||||
|
||||
var skillSettings = globals.Configuration.SkillsSettings.GetAllPropsAsDict();
|
||||
var skillSettings = globals.Configuration.SkillsSettings.GetAllPropertiesAsDictionary();
|
||||
BuffSettings? buffSettings = null;
|
||||
switch (itemSkillType)
|
||||
{
|
||||
|
||||
@@ -738,7 +738,7 @@ public class SeasonalEventService(
|
||||
infectionHalloween.DisplayUIEnabled = true;
|
||||
infectionHalloween.Enabled = true;
|
||||
|
||||
var globalInfectionDict = globals.LocationInfection.GetAllPropsAsDict();
|
||||
var globalInfectionDict = globals.LocationInfection.GetAllPropertiesAsDictionary();
|
||||
foreach (var (locationId, infectionPercentage) in zombieSettings.MapInfectionAmount)
|
||||
{
|
||||
// calculate a random value unless the rate is 100
|
||||
@@ -821,7 +821,7 @@ public class SeasonalEventService(
|
||||
return;
|
||||
}
|
||||
|
||||
var locations = databaseService.GetLocations().GetAllPropsAsDict();
|
||||
var locations = databaseService.GetLocations().GetAllPropertiesAsDictionary();
|
||||
foreach (var map in wavesToAddByMap)
|
||||
{
|
||||
var wavesToAdd = wavesToAddByMap[map.Key];
|
||||
@@ -849,7 +849,7 @@ public class SeasonalEventService(
|
||||
return;
|
||||
}
|
||||
|
||||
var locations = databaseService.GetLocations().GetAllPropsAsDict();
|
||||
var locations = databaseService.GetLocations().GetAllPropertiesAsDictionary();
|
||||
foreach (var (locationKey, bossesToAdd) in botsToAddPerMap)
|
||||
{
|
||||
if (bossesToAdd.Count == 0)
|
||||
@@ -1015,7 +1015,7 @@ public class SeasonalEventService(
|
||||
var itemTplsToAdd = slotKvP.Value;
|
||||
foreach (var itemKvP in itemTplsToAdd)
|
||||
{
|
||||
var dict = botToUpdate.BotInventory.Items.GetAllPropsAsDict();
|
||||
var dict = botToUpdate.BotInventory.Items.GetAllPropertiesAsDictionary();
|
||||
dict[itemKvP.Key] = itemTplsToAdd[itemKvP.Key];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user