Example #1
0
        /// <summary>
        /// returns a number for the amount of times this ingredient can be batched in the recipe 0 if invalid/insufficient.
        /// Used for ensuring the ingredient is valid and in proper stack size right before initializing the craft.
        /// By default only checks id and stack. override if needs stricter checking (like weapon modifier, maximums, split item stacks etc.).
        /// </summary>
        /// <param name="ingredient"></param>
        /// <returns></returns>
        public virtual int checkIngredientBatch(AlchemyIngredient ingredient)
        {
            if (requiredIngredientsMap.ContainsKey(ingredient.storedItem.type))
            {
                Item requiredItem;
                requiredIngredientsMap.TryGetValue(ingredient.storedItem.type, out requiredItem);

                return(ingredient.storedItem.stack / requiredItem.stack);
            }

            return(0);
        }
        public static void Load()
        {
            allIngredientMap = new Dictionary <int, Type>();
            recipeList       = new List <AlchemyRecipe>();
            //reflection to discover and cache AlchemyIngredient override types
            Mod mod = StarlightRiver.Instance;

            foreach (Type type in mod.Code.GetTypes().Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(AlchemyIngredient)) && t != typeof(GenericAlchemyIngredient)))
            {
                AlchemyIngredient tempIngredient = (AlchemyIngredient)Activator.CreateInstance(type);
                allIngredientMap.Add(tempIngredient.getItemId(), type);
            }
        }