Converted FindAndReturnChildrenAsItems into extension method
This commit is contained in:
@@ -407,13 +407,12 @@ public class InsuranceController(
|
||||
if (itemRoll ?? false)
|
||||
{
|
||||
// Check to see if this item is a parent in the parentAttachmentsMap. If so, do a look-up for *all* of
|
||||
// its children and mark them for deletion as well. Additionally remove the parent (and its children)
|
||||
// its children and mark them for deletion as well. Also remove parent (and its children)
|
||||
// from the parentAttachmentsMap so that it's children are not rolled for later in the process.
|
||||
if (parentAttachmentsMap.ContainsKey(insuredItem.Id))
|
||||
{
|
||||
// This call will also return the parent item itself, queueing it for deletion as well.
|
||||
var itemAndChildren = _itemHelper.FindAndReturnChildrenAsItems(
|
||||
insured.Items,
|
||||
var itemAndChildren = insured.Items.FindAndReturnChildrenAsItems(
|
||||
insuredItem.Id
|
||||
);
|
||||
foreach (var item in itemAndChildren)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Generators;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
@@ -310,8 +311,7 @@ public class ProfileController(
|
||||
foreach (var rootItems in hideoutRootItems)
|
||||
{
|
||||
// Check each root items for children and add
|
||||
var itemWithChildren = _itemHelper.FindAndReturnChildrenAsItems(
|
||||
profileToViewPmc.Inventory.Items,
|
||||
var itemWithChildren = profileToViewPmc.Inventory.Items.FindAndReturnChildrenAsItems(
|
||||
rootItems.Id
|
||||
);
|
||||
itemsToReturn.AddRange(itemWithChildren);
|
||||
|
||||
@@ -335,8 +335,7 @@ public class QuestController(
|
||||
// element `location` properties of the parent so they are sequential, while retaining order
|
||||
if (removedItem.Location?.GetType() == typeof(int))
|
||||
{
|
||||
var childItems = _itemHelper.FindAndReturnChildrenAsItems(
|
||||
pmcData.Inventory.Items,
|
||||
var childItems = pmcData.Inventory.Items.FindAndReturnChildrenAsItems(
|
||||
removedItem.ParentId
|
||||
);
|
||||
childItems.RemoveAt(0); // Remove the parent
|
||||
|
||||
@@ -649,8 +649,7 @@ public class RagfairController
|
||||
|
||||
// multi-offers are all the same item,
|
||||
// Get first item and its children and use as template
|
||||
var inventoryItems = _itemHelper.FindAndReturnChildrenAsItems(
|
||||
pmcData.Inventory.Items,
|
||||
var inventoryItems = pmcData.Inventory.Items.FindAndReturnChildrenAsItems(
|
||||
firstOfferItemId // Choose first item as they're all the same item
|
||||
);
|
||||
|
||||
@@ -766,9 +765,8 @@ public class RagfairController
|
||||
|
||||
// multi-offers are all the same item,
|
||||
// Get first item and its children and use as template
|
||||
var firstInventoryItemAndChildren = _itemHelper.FindAndReturnChildrenAsItems(
|
||||
pmcData.Inventory.Items,
|
||||
offerRequest.Items[0]
|
||||
var firstInventoryItemAndChildren = pmcData.Inventory.Items.FindAndReturnChildrenAsItems(
|
||||
offerRequest.Items.FirstOrDefault()
|
||||
);
|
||||
|
||||
// Find items to be listed on flea (+ children) from player inventory
|
||||
@@ -1147,9 +1145,7 @@ public class RagfairController
|
||||
|
||||
rootItem.FixItemStackCount();
|
||||
|
||||
itemsToReturn.Add(
|
||||
_itemHelper.FindAndReturnChildrenAsItems(pmcData.Inventory.Items, itemId)
|
||||
);
|
||||
itemsToReturn.Add(pmcData.Inventory.Items.FindAndReturnChildrenAsItems(itemId));
|
||||
}
|
||||
|
||||
if (itemsToReturn?.Count == 0)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
@@ -367,7 +368,7 @@ public class TradeController(
|
||||
TraderBase traderDetails
|
||||
)
|
||||
{
|
||||
var itemWithChildren = _itemHelper.FindAndReturnChildrenAsItems(items, parentItemId);
|
||||
var itemWithChildren = items.FindAndReturnChildrenAsItems(parentItemId);
|
||||
|
||||
var totalPrice = 0;
|
||||
foreach (var itemToSell in itemWithChildren)
|
||||
|
||||
Reference in New Issue
Block a user