示例#1
0
        /**
         * Returns true if the given player has any of the given item types in thier inventory.
         * index : Is set to the index of the item found. If it isn't found, it is set to -1.
         * counts : the minimum stack per item needed for HasItem to return true.
         * includeAmmo : true if you wish to include the ammo slots.
         * includeCoins : true if you wish to include the coin slots.
         */
        public static bool HasItem(Player player, int[] types, ref int index, int[] counts = default(int[]), bool includeAmmo = false, bool includeCoins = false)
        {
            if (types == null || types.Length == 0)
            {
                return(false);                                               //no types to check!
            }
            if (counts == null || counts.Length == 0)
            {
                counts = BaseUtility.FillArray(new int[types.Length], 1);
            }
            int countIndex = -1;

            if (includeCoins)
            {
                for (int m = 50; m < 54; m++)
                {
                    Item item = player.inventory[m];
                    if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex])
                    {
                        index = m; return(true);
                    }
                }
            }
            if (includeAmmo)
            {
                for (int m = 54; m < 58; m++)
                {
                    Item item = player.inventory[m];
                    if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex])
                    {
                        index = m; return(true);
                    }
                }
            }
            for (int m = 0; m < 50; m++)
            {
                Item item = player.inventory[m];
                if (item != null && BaseUtility.InArray(types, item.type, ref countIndex) && item.stack >= counts[countIndex])
                {
                    index = m; return(true);
                }
            }
            return(false);
        }
示例#2
0
        /*
         * Returns the total itemstack sum of a specific item in the player's inventory.
         *
         * typeIsAmmo : If true, types are considered ammo types. Else, types are considered item types.
         */
        public static int GetItemstackSum(Player player, int[] types, bool typeIsAmmo = false, bool includeAmmo = false, bool includeCoins = false)
        {
            int stackCount = 0;

            if (includeCoins)
            {
                for (int m = 50; m < 54; m++)
                {
                    Item item = player.inventory[m];
                    if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type)))
                    {
                        stackCount += item.stack;
                    }
                }
            }
            if (includeAmmo)
            {
                for (int m = 54; m < 58; m++)
                {
                    Item item = player.inventory[m];
                    if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type)))
                    {
                        stackCount += item.stack;
                    }
                }
            }
            for (int m = 0; m < 50; m++)
            {
                Item item = player.inventory[m];
                if (item != null && (typeIsAmmo ? BaseUtility.InArray(types, item.ammo) : BaseUtility.InArray(types, item.type)))
                {
                    stackCount += item.stack;
                }
            }
            return(stackCount);
        }
示例#3
0
        /*
         * Tints the light color according to the buff color given. (prevents 'darkness' occuring if more than one is applied)
         */
        public static Color BuffColorize(Color buffColor, Color lightColor)
        {
            Color color2 = BaseUtility.ColorBrightnessClamp(buffColor, lightColor);

            return(BaseUtility.ColorClamp(BaseUtility.Colorize(buffColor, lightColor), color2));
        }
示例#4
0
 public static int GoreType(this Mod mod, string name, IDictionary <string, int> gores = null)
 {
     return(BaseUtility.CheckForGore(mod, name, gores));
 }
示例#5
0
 public static bool HasAllItems(Player player, int[] types, ref int[] indicies, int[] counts = default(int[]), bool includeAmmo = false, bool includeCoins = false)
 {
     if (types == null || types.Length == 0)
     {
         return(false);                                               //no types to check!
     }
     if (counts == null || counts.Length == 0)
     {
         counts = BaseUtility.FillArray(new int[types.Length], 1);
     }
     int[]  indexArray = new int[types.Length];
     bool[] foundItem  = new bool[types.Length];
     if (includeCoins)
     {
         for (int m = 50; m < 54; m++)
         {
             for (int m2 = 0; m2 < types.Length; m2++)
             {
                 if (foundItem[m2])
                 {
                     continue;
                 }
                 Item item = player.inventory[m];
                 if (item != null && item.type == types[m2] && item.stack >= counts[m2])
                 {
                     foundItem[m2] = true; indexArray[m2] = m;
                 }
             }
         }
     }
     if (includeAmmo)
     {
         for (int m = 54; m < 58; m++)
         {
             for (int m2 = 0; m2 < types.Length; m2++)
             {
                 if (foundItem[m2])
                 {
                     continue;
                 }
                 Item item = player.inventory[m];
                 if (item != null && item.type == types[m2] && item.stack >= counts[m2])
                 {
                     foundItem[m2] = true; indexArray[m2] = m;
                 }
             }
         }
     }
     for (int m = 0; m < 50; m++)
     {
         for (int m2 = 0; m2 < types.Length; m2++)
         {
             if (foundItem[m2])
             {
                 continue;
             }
             Item item = player.inventory[m];
             if (item != null && item.type == types[m2] && item.stack >= counts[m2])
             {
                 foundItem[m2] = true; indexArray[m2] = m;
             }
         }
     }
     foreach (bool f in foundItem)
     {
         if (!f)
         {
             return(false);
         }
     }
     return(true);
 }