Ejemplo n.º 1
0
        public static int CountTotalOfEach(Item[] collection, ISet <int> item_types)
        {
            var set   = ItemFinderHelpers.FindIndexOfEach(collection, item_types);
            int total = 0;

            foreach (int idx in set)
            {
                total += collection[idx].stack;
            }
            return(total);
        }
Ejemplo n.º 2
0
        public static Item FindFirstPlayerItemOfType(Player player, int item_type)
        {
            Item item = ItemFinderHelpers.FindFirstItemOfType(player.inventory, item_type);

            if (item != null)
            {
                return(item);
            }

            if (player.chest >= 0)                  // Player's current chest
            {
                item = ItemFinderHelpers.FindFirstItemOfType(Main.chest[player.chest].item, item_type);
                if (item != null)
                {
                    return(item);
                }
            }
            if (player.chest == -2)                 // Piggy bank
            {
                item = ItemFinderHelpers.FindFirstItemOfType(player.bank.item, item_type);
                if (item != null)
                {
                    return(item);
                }
            }
            if (player.chest == -3)                 // Safe
            {
                item = ItemFinderHelpers.FindFirstItemOfType(player.bank2.item, item_type);
                if (item != null)
                {
                    return(item);
                }
            }
            if (player.chest == -4)                 // ..whatever this is
            {
                item = ItemFinderHelpers.FindFirstItemOfType(player.bank3.item, item_type);
                if (item != null)
                {
                    return(item);
                }
            }

            return(null);
        }
 public static int FindFirstOfItemInCollection(Item[] collection, ISet <int> item_types)
 {
     return(ItemFinderHelpers.FindIndexOfFirstOfItemInCollection(collection, item_types));
 }
 public static SortedSet <int> FindIndexOfEachItemInCollection(Item[] collection, ISet <int> item_types)
 {
     return((SortedSet <int>)ItemFinderHelpers.FindIndexOfEach(collection, item_types));
 }