/// <summary> /// Finds and returns all instances of Items in the Inventory with any of the designated ItemTypes. /// </summary> /// <param name="itemTypes">The ItemTypes enum values to look for.</param> /// <returns>An array of all items with any of the designated ItemTypes. If none are found, an empty array.</returns> public Item[] FindItems(Item.ItemCategories itemCategory, Item.ItemTypes itemTypes) { List <Item> itemsToFind = new List <Item>(); //If searching for Key Items, add all Key Items to the list if (itemCategory == Item.ItemCategories.KeyItem) { itemsToFind.AddRange(KeyItems); } else { //Look in the Item list for all Items with these ItemTypes and add them itemsToFind.AddRange(Items.FindAll((item) => UtilityGlobals.ItemTypesHasFlag(item.ItemType, itemTypes) == true)); } return(itemsToFind.ToArray()); }
/// <summary> /// Finds and returns the first Item in the Inventory with any of the designated ItemTypes. /// </summary> /// <param name="itemTypes">The ItemTypes enum values to look for.</param> /// <returns>An item with any of the designated ItemTypes. If not found, null.</returns> public Item FindItem(Item.ItemCategories itemCategory, Item.ItemTypes itemTypes) { return(Items.Find((item) => UtilityGlobals.ItemTypesHasFlag(item.ItemType, itemTypes) == true)); }