/// <summary> /// Takes a List of part ConfigNodes and returns the ConfigNodes that are present in the inventory. /// Assumes the default strictness. /// </summary> /// <param name="sourceParts">Source list of parts</param> /// <returns>List of part ConfigNodes that are in the inventory</returns> public IList <ConfigNode> GetPartsInInventory_ConfigNodes(IEnumerable <ConfigNode> sourceParts, string strictness) { if (!ScrapYard.Instance.TheInventory.InventoryEnabled) { return(new List <ConfigNode>()); } ComparisonStrength actualStrictness = parseStrictnessString(strictness); List <ConfigNode> inInventory = new List <ConfigNode>(); PartInventory InventoryCopy = ScrapYard.Instance.TheInventory.Copy(); foreach (ConfigNode part in sourceParts) { InventoryPart inputPart = new InventoryPart(part); if (InventoryCopy.RemovePart(inputPart, actualStrictness) != null) { inInventory.Add(part); } } return(inInventory); }
/// <summary> /// Finds all parts in the inventory for the given InventoryPart and the provided strictness /// </summary> /// <param name="part">The source part to find a match for</param> /// <param name="strength">The strictness of the comparison. Defaults to MODULES.</param> /// <returns>An IEnumerable of InventoryParts that match</returns> public IEnumerable <InventoryPart> FindParts(InventoryPart part, ComparisonStrength strength = ComparisonStrength.MODULES) { if (!InventoryEnabled) { return(null); } List <InventoryPart> foundParts = new List <InventoryPart>(); PartInventory copy = Copy(); InventoryPart found = null; do { found = copy.RemovePart(part, strength); if (found != null) { foundParts.Add(found); } } while (found != null); return(foundParts); }