.NET Format Style Fixes
This commit is contained in:
@@ -58,18 +58,16 @@ public class LootGenerator(
|
||||
{
|
||||
// Choose one at random + add to results array
|
||||
var chosenSealedContainer = _randomUtil.GetArrayValue(sealedWeaponContainerPool);
|
||||
result.Add([
|
||||
new Item
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenSealedContainer.Id,
|
||||
Upd = new Upd
|
||||
result.Add(
|
||||
[
|
||||
new Item
|
||||
{
|
||||
StackObjectsCount = 1,
|
||||
SpawnedInSession = true
|
||||
}
|
||||
}
|
||||
]);
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenSealedContainer.Id,
|
||||
Upd = new Upd { StackObjectsCount = 1, SpawnedInSession = true },
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +83,21 @@ public class LootGenerator(
|
||||
// Pool has items we could add as loot, proceed
|
||||
if (rewardPoolResults.ItemPool.Count > 0)
|
||||
{
|
||||
var randomisedItemCount = _randomUtil.GetInt(options.ItemCount.Min, options.ItemCount.Max);
|
||||
var randomisedItemCount = _randomUtil.GetInt(
|
||||
options.ItemCount.Min,
|
||||
options.ItemCount.Max
|
||||
);
|
||||
for (var index = 0; index < randomisedItemCount; index++)
|
||||
{
|
||||
if (!FindAndAddRandomItemToLoot(rewardPoolResults.ItemPool, itemTypeCounts, options, result))
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
if (
|
||||
!FindAndAddRandomItemToLoot(
|
||||
rewardPoolResults.ItemPool,
|
||||
itemTypeCounts,
|
||||
options,
|
||||
result
|
||||
)
|
||||
)
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
{
|
||||
index--;
|
||||
}
|
||||
@@ -105,9 +113,8 @@ public class LootGenerator(
|
||||
);
|
||||
if (randomisedWeaponPresetCount > 0)
|
||||
{
|
||||
var weaponDefaultPresets = globalDefaultPresets.Where(preset =>
|
||||
_itemHelper.IsOfBaseclass(preset.Encyclopedia, BaseClasses.WEAPON)
|
||||
)
|
||||
var weaponDefaultPresets = globalDefaultPresets
|
||||
.Where(preset => _itemHelper.IsOfBaseclass(preset.Encyclopedia, BaseClasses.WEAPON))
|
||||
.ToList();
|
||||
|
||||
if (weaponDefaultPresets.Any())
|
||||
@@ -115,14 +122,14 @@ public class LootGenerator(
|
||||
for (var index = 0; index < randomisedWeaponPresetCount; index++)
|
||||
{
|
||||
if (
|
||||
!FindAndAddRandomPresetToLoot(
|
||||
weaponDefaultPresets,
|
||||
itemTypeCounts,
|
||||
rewardPoolResults.Blacklist,
|
||||
result
|
||||
)
|
||||
!FindAndAddRandomPresetToLoot(
|
||||
weaponDefaultPresets,
|
||||
itemTypeCounts,
|
||||
rewardPoolResults.Blacklist,
|
||||
result
|
||||
)
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
)
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
{
|
||||
index--;
|
||||
}
|
||||
@@ -140,9 +147,8 @@ public class LootGenerator(
|
||||
var armorDefaultPresets = globalDefaultPresets.Where(preset =>
|
||||
_itemHelper.ArmorItemCanHoldMods(preset.Encyclopedia)
|
||||
);
|
||||
var levelFilteredArmorPresets = armorDefaultPresets.Where(armor =>
|
||||
IsArmorOfDesiredProtectionLevel(armor, options)
|
||||
)
|
||||
var levelFilteredArmorPresets = armorDefaultPresets
|
||||
.Where(armor => IsArmorOfDesiredProtectionLevel(armor, options))
|
||||
.ToList();
|
||||
|
||||
// Add some armors to rewards
|
||||
@@ -151,14 +157,14 @@ public class LootGenerator(
|
||||
for (var index = 0; index < randomisedArmorPresetCount; index++)
|
||||
{
|
||||
if (
|
||||
!FindAndAddRandomPresetToLoot(
|
||||
levelFilteredArmorPresets,
|
||||
itemTypeCounts,
|
||||
rewardPoolResults.Blacklist,
|
||||
result
|
||||
)
|
||||
!FindAndAddRandomPresetToLoot(
|
||||
levelFilteredArmorPresets,
|
||||
itemTypeCounts,
|
||||
rewardPoolResults.Blacklist,
|
||||
result
|
||||
)
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
)
|
||||
// Failed to add, reduce index so we get another attempt
|
||||
{
|
||||
index--;
|
||||
}
|
||||
@@ -195,7 +201,9 @@ public class LootGenerator(
|
||||
for (var i = 0; i < randomisedItemCount; i++)
|
||||
{
|
||||
// Clone preset and alter Ids to be unique
|
||||
var presetWithUniqueIds = _itemHelper.ReplaceIDs(_cloner.Clone(preset.Items));
|
||||
var presetWithUniqueIds = _itemHelper.ReplaceIDs(
|
||||
_cloner.Clone(preset.Items)
|
||||
);
|
||||
|
||||
// Add to results
|
||||
result.Add(presetWithUniqueIds);
|
||||
@@ -203,7 +211,6 @@ public class LootGenerator(
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// Non-preset item to be added
|
||||
@@ -211,11 +218,7 @@ public class LootGenerator(
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = itemTpl,
|
||||
Upd = new Upd
|
||||
{
|
||||
StackObjectsCount = randomisedItemCount,
|
||||
SpawnedInSession = true
|
||||
}
|
||||
Upd = new Upd { StackObjectsCount = randomisedItemCount, SpawnedInSession = true },
|
||||
};
|
||||
var splitResults = _itemHelper.SplitStack(newLootItem);
|
||||
foreach (var splitItem in splitResults)
|
||||
@@ -242,11 +245,12 @@ public class LootGenerator(
|
||||
List<string> itemTypeWhitelist,
|
||||
bool useRewardItemBlacklist,
|
||||
bool allowBossItems,
|
||||
bool blockSeasonalItemsOutOfSeason)
|
||||
bool blockSeasonalItemsOutOfSeason
|
||||
)
|
||||
{
|
||||
var itemsDb = _databaseService.GetItems().Values;
|
||||
var itemBlacklist = new HashSet<string>();
|
||||
itemBlacklist.UnionWith([.._itemFilterService.GetBlacklistedItems(), ..itemTplBlacklist]);
|
||||
itemBlacklist.UnionWith([.. _itemFilterService.GetBlacklistedItems(), .. itemTplBlacklist]);
|
||||
|
||||
if (useRewardItemBlacklist)
|
||||
{
|
||||
@@ -256,10 +260,12 @@ public class LootGenerator(
|
||||
var itemTypeBlacklist = _itemFilterService.GetItemRewardBaseTypeBlacklist();
|
||||
var itemsMatchingTypeBlacklist = itemsDb
|
||||
.Where(templateItem => !string.IsNullOrEmpty(templateItem.Parent)) // Ignore items without parents
|
||||
.Where(templateItem => _itemHelper.IsOfBaseclasses(templateItem.Parent, itemTypeBlacklist))
|
||||
.Where(templateItem =>
|
||||
_itemHelper.IsOfBaseclasses(templateItem.Parent, itemTypeBlacklist)
|
||||
)
|
||||
.Select(templateItem => templateItem.Id);
|
||||
|
||||
itemBlacklist.UnionWith([..rewardItemBlacklist, ..itemsMatchingTypeBlacklist]);
|
||||
itemBlacklist.UnionWith([.. rewardItemBlacklist, .. itemsMatchingTypeBlacklist]);
|
||||
}
|
||||
|
||||
if (!allowBossItems)
|
||||
@@ -272,19 +278,16 @@ public class LootGenerator(
|
||||
itemBlacklist.UnionWith(_seasonalEventService.GetInactiveSeasonalEventItems());
|
||||
}
|
||||
|
||||
var items = itemsDb.Where(item =>
|
||||
!itemBlacklist.Contains(item.Id) &&
|
||||
string.Equals(item.Type, "item", StringComparison.OrdinalIgnoreCase) &&
|
||||
!item.Properties.QuestItem.GetValueOrDefault(false) &&
|
||||
itemTypeWhitelist.Contains(item.Parent)
|
||||
var items = itemsDb
|
||||
.Where(item =>
|
||||
!itemBlacklist.Contains(item.Id)
|
||||
&& string.Equals(item.Type, "item", StringComparison.OrdinalIgnoreCase)
|
||||
&& !item.Properties.QuestItem.GetValueOrDefault(false)
|
||||
&& itemTypeWhitelist.Contains(item.Parent)
|
||||
)
|
||||
.ToList();
|
||||
|
||||
return new ItemRewardPoolResults
|
||||
{
|
||||
ItemPool = items,
|
||||
Blacklist = itemBlacklist
|
||||
};
|
||||
return new ItemRewardPoolResults { ItemPool = items, Blacklist = itemBlacklist };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -326,7 +329,7 @@ public class LootGenerator(
|
||||
itemTypeCounts[itemTypeId.Key] = new ItemLimit
|
||||
{
|
||||
Current = 0,
|
||||
Max = limits[itemTypeId.Key]
|
||||
Max = limits[itemTypeId.Key],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -341,13 +344,19 @@ public class LootGenerator(
|
||||
/// <param name="options">item filters</param>
|
||||
/// <param name="result">array to add found item to</param>
|
||||
/// <returns>true if item was valid and added to pool</returns>
|
||||
protected bool FindAndAddRandomItemToLoot(List<TemplateItem> items, Dictionary<string, ItemLimit> itemTypeCounts,
|
||||
protected bool FindAndAddRandomItemToLoot(
|
||||
List<TemplateItem> items,
|
||||
Dictionary<string, ItemLimit> itemTypeCounts,
|
||||
LootRequest options,
|
||||
List<List<Item>> result)
|
||||
List<List<Item>> result
|
||||
)
|
||||
{
|
||||
var randomItem = _randomUtil.GetArrayValue(items);
|
||||
|
||||
var itemLimitCount = itemTypeCounts.TryGetValue(randomItem.Parent, out var randomItemLimitCount);
|
||||
var itemLimitCount = itemTypeCounts.TryGetValue(
|
||||
randomItem.Parent,
|
||||
out var randomItemLimitCount
|
||||
);
|
||||
if (!itemLimitCount && randomItemLimitCount?.Current > randomItemLimitCount?.Max)
|
||||
{
|
||||
return false;
|
||||
@@ -363,11 +372,7 @@ public class LootGenerator(
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = randomItem.Id,
|
||||
Upd = new Upd
|
||||
{
|
||||
StackObjectsCount = 1,
|
||||
SpawnedInSession = true
|
||||
}
|
||||
Upd = new Upd { StackObjectsCount = 1, SpawnedInSession = true },
|
||||
};
|
||||
|
||||
// Special case - handle items that need a stackcount > 1
|
||||
@@ -380,7 +385,7 @@ public class LootGenerator(
|
||||
result.Add([newLootItem]);
|
||||
|
||||
if (randomItemLimitCount is not null)
|
||||
// Increment item count as it's in limit array
|
||||
// Increment item count as it's in limit array
|
||||
{
|
||||
randomItemLimitCount.Current++;
|
||||
}
|
||||
@@ -417,10 +422,12 @@ public class LootGenerator(
|
||||
/// <param name="itemBlacklist">Items to skip</param>
|
||||
/// <param name="result">List to add chosen preset to</param>
|
||||
/// <returns>true if preset was valid and added to pool</returns>
|
||||
protected bool FindAndAddRandomPresetToLoot(List<Preset> presetPool,
|
||||
protected bool FindAndAddRandomPresetToLoot(
|
||||
List<Preset> presetPool,
|
||||
Dictionary<string, ItemLimit> itemTypeCounts,
|
||||
HashSet<string> itemBlacklist,
|
||||
List<List<Item>> result)
|
||||
List<List<Item>> result
|
||||
)
|
||||
{
|
||||
if (presetPool.Count == 0)
|
||||
{
|
||||
@@ -437,7 +444,12 @@ public class LootGenerator(
|
||||
{
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Warning(_localisationService.GetText("loot-chosen_preset_missing_encyclopedia_value", chosenPreset?.Id));
|
||||
_logger.Warning(
|
||||
_localisationService.GetText(
|
||||
"loot-chosen_preset_missing_encyclopedia_value",
|
||||
chosenPreset?.Id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -449,7 +461,9 @@ public class LootGenerator(
|
||||
{
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"$Unable to find preset with tpl: {chosenPreset.Encyclopedia}, skipping");
|
||||
_logger.Debug(
|
||||
$"$Unable to find preset with tpl: {chosenPreset.Encyclopedia}, skipping"
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -464,13 +478,21 @@ public class LootGenerator(
|
||||
// Some custom mod items lack a parent property
|
||||
if (itemDbDetails.Value?.Parent is null)
|
||||
{
|
||||
_logger.Error(_localisationService.GetText("loot-item_missing_parentid", itemDbDetails.Value?.Name));
|
||||
_logger.Error(
|
||||
_localisationService.GetText(
|
||||
"loot-item_missing_parentid",
|
||||
itemDbDetails.Value?.Name
|
||||
)
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check chosen preset hasn't exceeded spawn limit
|
||||
var hasItemLimitCount = itemTypeCounts.TryGetValue(itemDbDetails.Value.Parent, out var itemLimitCount);
|
||||
var hasItemLimitCount = itemTypeCounts.TryGetValue(
|
||||
itemDbDetails.Value.Parent,
|
||||
out var itemLimitCount
|
||||
);
|
||||
if (!hasItemLimitCount && itemLimitCount?.Current > itemLimitCount?.Max)
|
||||
{
|
||||
return false;
|
||||
@@ -485,7 +507,7 @@ public class LootGenerator(
|
||||
result.Add(presetAndMods);
|
||||
|
||||
if (itemLimitCount is not null)
|
||||
// Increment item count as item has been chosen and its inside itemLimitCount dictionary
|
||||
// Increment item count as item has been chosen and its inside itemLimitCount dictionary
|
||||
{
|
||||
itemLimitCount.Current++;
|
||||
}
|
||||
@@ -499,7 +521,9 @@ public class LootGenerator(
|
||||
/// </summary>
|
||||
/// <param name="containerSettings">sealed weapon container settings</param>
|
||||
/// <returns>List of items with children lists</returns>
|
||||
public List<List<Item>> GetSealedWeaponCaseLoot(SealedAirdropContainerSettings containerSettings)
|
||||
public List<List<Item>> GetSealedWeaponCaseLoot(
|
||||
SealedAirdropContainerSettings containerSettings
|
||||
)
|
||||
{
|
||||
List<List<Item>> itemsToReturn = [];
|
||||
|
||||
@@ -513,7 +537,10 @@ public class LootGenerator(
|
||||
if (!weaponDetailsDb.Key)
|
||||
{
|
||||
_logger.Error(
|
||||
_localisationService.GetText("loot-non_item_picked_as_sealed_weapon_crate_reward", chosenWeaponTpl)
|
||||
_localisationService.GetText(
|
||||
"loot-non_item_picked_as_sealed_weapon_crate_reward",
|
||||
chosenWeaponTpl
|
||||
)
|
||||
);
|
||||
|
||||
return itemsToReturn;
|
||||
@@ -528,9 +555,14 @@ public class LootGenerator(
|
||||
if (chosenWeaponPreset is null)
|
||||
{
|
||||
_logger.Warning(
|
||||
_localisationService.GetText("loot-default_preset_not_found_using_random", chosenWeaponTpl)
|
||||
_localisationService.GetText(
|
||||
"loot-default_preset_not_found_using_random",
|
||||
chosenWeaponTpl
|
||||
)
|
||||
);
|
||||
chosenWeaponPreset = _randomUtil.GetArrayValue(
|
||||
_presetHelper.GetPresets(chosenWeaponTpl)
|
||||
);
|
||||
chosenWeaponPreset = _randomUtil.GetArrayValue(_presetHelper.GetPresets(chosenWeaponTpl));
|
||||
}
|
||||
|
||||
// Clean up Ids to ensure they're all unique and prevent collisions
|
||||
@@ -543,11 +575,17 @@ public class LootGenerator(
|
||||
// Get a random collection of weapon mods related to chosen weawpon and add them to result array
|
||||
var linkedItemsToWeapon = _ragfairLinkedItemService.GetLinkedDbItems(chosenWeaponTpl);
|
||||
itemsToReturn.AddRange(
|
||||
GetSealedContainerWeaponModRewards(containerSettings, linkedItemsToWeapon, chosenWeaponPreset)
|
||||
GetSealedContainerWeaponModRewards(
|
||||
containerSettings,
|
||||
linkedItemsToWeapon,
|
||||
chosenWeaponPreset
|
||||
)
|
||||
);
|
||||
|
||||
// Handle non-weapon mod reward types
|
||||
itemsToReturn.AddRange(GetSealedContainerNonWeaponModRewards(containerSettings, weaponDetailsDb.Value));
|
||||
itemsToReturn.AddRange(
|
||||
GetSealedContainerNonWeaponModRewards(containerSettings, weaponDetailsDb.Value)
|
||||
);
|
||||
|
||||
return itemsToReturn;
|
||||
}
|
||||
@@ -558,8 +596,10 @@ public class LootGenerator(
|
||||
/// <param name="containerSettings">Sealed weapon container settings</param>
|
||||
/// <param name="weaponDetailsDb">Details for the weapon to reward player</param>
|
||||
/// <returns>List of item with children lists</returns>
|
||||
protected List<List<Item>> GetSealedContainerNonWeaponModRewards(SealedAirdropContainerSettings containerSettings,
|
||||
TemplateItem weaponDetailsDb)
|
||||
protected List<List<Item>> GetSealedContainerNonWeaponModRewards(
|
||||
SealedAirdropContainerSettings containerSettings,
|
||||
TemplateItem weaponDetailsDb
|
||||
)
|
||||
{
|
||||
List<List<Item>> rewards = [];
|
||||
|
||||
@@ -576,11 +616,10 @@ public class LootGenerator(
|
||||
{
|
||||
// Get ammo boxes from db
|
||||
var ammoBoxesDetails = containerSettings.AmmoBoxWhitelist.Select(tpl =>
|
||||
{
|
||||
var itemDetails = _itemHelper.GetItem(tpl);
|
||||
return itemDetails.Value;
|
||||
}
|
||||
);
|
||||
{
|
||||
var itemDetails = _itemHelper.GetItem(tpl);
|
||||
return itemDetails.Value;
|
||||
});
|
||||
|
||||
// Need to find boxes that matches weapons caliber
|
||||
var weaponCaliber = weaponDetailsDb.Properties.AmmoCaliber;
|
||||
@@ -602,11 +641,7 @@ public class LootGenerator(
|
||||
var chosenAmmoBox = _randomUtil.GetArrayValue(ammoBoxesMatchingCaliber);
|
||||
var ammoBoxReward = new List<Item>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenAmmoBox.Id
|
||||
}
|
||||
new() { Id = _hashUtil.Generate(), Template = chosenAmmoBox.Id },
|
||||
};
|
||||
_itemHelper.AddCartridgesToAmmoBox(ammoBoxReward, chosenAmmoBox);
|
||||
rewards.Add(ammoBoxReward);
|
||||
@@ -616,13 +651,14 @@ public class LootGenerator(
|
||||
}
|
||||
|
||||
// Get all items of the desired type + not quest items + not globally blacklisted
|
||||
var rewardItemPool = _databaseService.GetItems()
|
||||
var rewardItemPool = _databaseService
|
||||
.GetItems()
|
||||
.Values.Where(item =>
|
||||
item.Parent == rewardKey &&
|
||||
string.Equals(item.Type, "item", StringComparison.OrdinalIgnoreCase) &&
|
||||
_itemFilterService.IsItemBlacklisted(item.Id) &&
|
||||
!(containerSettings.AllowBossItems || _itemFilterService.IsBossItem(item.Id)) &&
|
||||
item.Properties.QuestItem is null
|
||||
item.Parent == rewardKey
|
||||
&& string.Equals(item.Type, "item", StringComparison.OrdinalIgnoreCase)
|
||||
&& _itemFilterService.IsItemBlacklisted(item.Id)
|
||||
&& !(containerSettings.AllowBossItems || _itemFilterService.IsBossItem(item.Id))
|
||||
&& item.Properties.QuestItem is null
|
||||
);
|
||||
|
||||
if (!rewardItemPool.Any())
|
||||
@@ -641,11 +677,7 @@ public class LootGenerator(
|
||||
var chosenRewardItem = _randomUtil.GetArrayValue(rewardItemPool);
|
||||
var rewardItem = new List<Item>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenRewardItem.Id
|
||||
}
|
||||
new() { Id = _hashUtil.Generate(), Template = chosenRewardItem.Id },
|
||||
};
|
||||
|
||||
rewards.Add(rewardItem);
|
||||
@@ -662,8 +694,11 @@ public class LootGenerator(
|
||||
/// <param name="linkedItemsToWeapon">All items that can be attached/inserted into weapon</param>
|
||||
/// <param name="chosenWeaponPreset">The weapon preset given to player as reward</param>
|
||||
/// <returns>List of item with children lists</returns>
|
||||
protected List<List<Item>> GetSealedContainerWeaponModRewards(SealedAirdropContainerSettings containerSettings, List<TemplateItem> linkedItemsToWeapon,
|
||||
Preset chosenWeaponPreset)
|
||||
protected List<List<Item>> GetSealedContainerWeaponModRewards(
|
||||
SealedAirdropContainerSettings containerSettings,
|
||||
List<TemplateItem> linkedItemsToWeapon,
|
||||
Preset chosenWeaponPreset
|
||||
)
|
||||
{
|
||||
List<List<Item>> modRewards = [];
|
||||
|
||||
@@ -678,7 +713,8 @@ public class LootGenerator(
|
||||
}
|
||||
|
||||
// Get items that fulfil reward type criteria from items that fit on gun
|
||||
var relatedItems = linkedItemsToWeapon?.Where(item => item?.Parent == rewardKey && !_itemFilterService.IsItemBlacklisted(item.Id)
|
||||
var relatedItems = linkedItemsToWeapon?.Where(item =>
|
||||
item?.Parent == rewardKey && !_itemFilterService.IsItemBlacklisted(item.Id)
|
||||
);
|
||||
if (relatedItems is null || !relatedItems.Any())
|
||||
{
|
||||
@@ -698,11 +734,7 @@ public class LootGenerator(
|
||||
var chosenItem = _randomUtil.DrawRandomFromList(relatedItems.ToList());
|
||||
var reward = new List<Item>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenItem[0].Id
|
||||
}
|
||||
new() { Id = _hashUtil.Generate(), Template = chosenItem[0].Id },
|
||||
};
|
||||
|
||||
modRewards.Add(reward);
|
||||
@@ -742,11 +774,7 @@ public class LootGenerator(
|
||||
|
||||
List<Item> rewardItem =
|
||||
[
|
||||
new()
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = chosenRewardItemTpl
|
||||
}
|
||||
new() { Id = _hashUtil.Generate(), Template = chosenRewardItemTpl },
|
||||
];
|
||||
itemsToReturn.Add(rewardItem);
|
||||
}
|
||||
@@ -761,47 +789,33 @@ public class LootGenerator(
|
||||
/// <returns>Single tpl</returns>
|
||||
protected string PickRewardItem(RewardDetails rewardContainerDetails)
|
||||
{
|
||||
if (rewardContainerDetails.RewardTplPool is not null && rewardContainerDetails.RewardTplPool.Count > 0)
|
||||
if (
|
||||
rewardContainerDetails.RewardTplPool is not null
|
||||
&& rewardContainerDetails.RewardTplPool.Count > 0
|
||||
)
|
||||
{
|
||||
return _weightedRandomHelper.GetWeightedValue(rewardContainerDetails.RewardTplPool);
|
||||
}
|
||||
|
||||
return _randomUtil.GetArrayValue(
|
||||
GetItemRewardPool([], rewardContainerDetails.RewardTypePool, true, true, false)
|
||||
.ItemPool.Select(item => item.Id
|
||||
)
|
||||
.ItemPool.Select(item => item.Id)
|
||||
);
|
||||
}
|
||||
|
||||
public record ItemRewardPoolResults
|
||||
{
|
||||
public List<TemplateItem> ItemPool
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public List<TemplateItem> ItemPool { get; set; }
|
||||
|
||||
public HashSet<string> Blacklist
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public HashSet<string> Blacklist { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemLimit
|
||||
{
|
||||
[JsonPropertyName("current")]
|
||||
public int Current
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Current { get; set; }
|
||||
|
||||
[JsonPropertyName("max")]
|
||||
public int Max
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Max { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user