From e0f9b2dd06775d2b7e2aaa084ce9cee530f17b16 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 23 Feb 2025 22:59:31 +0000 Subject: [PATCH] Refactored `PMCLootGenerator` --- Libraries/Core/Generators/PMCLootGenerator.cs | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/Libraries/Core/Generators/PMCLootGenerator.cs b/Libraries/Core/Generators/PMCLootGenerator.cs index 329e2f06..d9330fc0 100644 --- a/Libraries/Core/Generators/PMCLootGenerator.cs +++ b/Libraries/Core/Generators/PMCLootGenerator.cs @@ -75,14 +75,14 @@ public class PMCLootGenerator !blacklist.Contains(item.Value.Id) && !blacklist.Contains(item.Value.Parent) && ItemFitsInto1By2Slot(item.Value) - ); + ).Select(x => x.Key); - foreach (var (tpl, template) in itemsToAdd) + foreach (var tpl in itemsToAdd) // If pmc has price override, use that. Otherwise, use flea price { - if (pmcPriceOverrides.ContainsKey(tpl)) + if (pmcPriceOverrides.TryGetValue(tpl, out var priceOverride)) { - _pocketLootPool[tpl] = pmcPriceOverrides[tpl]; + _pocketLootPool.Add(tpl, priceOverride); } else { @@ -109,25 +109,10 @@ public class PMCLootGenerator private HashSet GetLootBlacklist() { var blacklist = new HashSet(); - foreach (var blacklistedItem in _pmcConfig.PocketLoot.Blacklist) - { - blacklist.Add(blacklistedItem); - } - - foreach (var blacklistedItem in _pmcConfig.GlobalLootBlacklist) - { - blacklist.Add(blacklistedItem); - } - - foreach (var blacklistedItem in _itemFilterService.GetBlacklistedItems()) - { - blacklist.Add(blacklistedItem); - } - - foreach (var blacklistedItem in _seasonalEventService.GetInactiveSeasonalEventItems()) - { - blacklist.Add(blacklistedItem); - } + blacklist.UnionWith(_pmcConfig.PocketLoot.Blacklist); + blacklist.UnionWith(_pmcConfig.GlobalLootBlacklist); + blacklist.UnionWith(_itemFilterService.GetBlacklistedItems()); + blacklist.UnionWith(_seasonalEventService.GetInactiveSeasonalEventItems()); return blacklist; } @@ -158,14 +143,14 @@ public class PMCLootGenerator !blacklist.Contains(item.Value.Id) && !blacklist.Contains(item.Value.Parent) && ItemFitsInto2By2Slot(item.Value) - ); + ).Select(x => x.Key); - foreach (var (tpl, template) in itemsToAdd) + foreach (var tpl in itemsToAdd) // If pmc has price override, use that. Otherwise, use flea price { - if (pmcPriceOverrides.ContainsKey(tpl)) + if (pmcPriceOverrides.TryGetValue(tpl, out var overridePrice)) { - _vestLootPool[tpl] = pmcPriceOverrides[tpl]; + _vestLootPool.Add(tpl, overridePrice); } else { @@ -240,14 +225,14 @@ public class PMCLootGenerator _itemHelper.IsValidItem(item.Value.Id) && !blacklist.Contains(item.Value.Id) && !blacklist.Contains(item.Value.Parent) - ); + ).Select(x => x.Key); - foreach (var (tpl, template) in itemsToAdd) + foreach (var tpl in itemsToAdd) // If pmc has price override, use that. Otherwise, use flea price { - if (pmcPriceOverrides.ContainsKey(tpl)) + if (pmcPriceOverrides.TryGetValue(tpl, out var priceOverride)) { - _backpackLootPool[tpl] = pmcPriceOverrides[tpl]; + _backpackLootPool.Add(tpl, priceOverride); } else {