Exemplo n.º 1
0
        private static void Display_MenuChanged(object sender, MenuChangedEventArgs e)
        {
            if (e.OldMenu is TitleMenu || e.NewMenu is TitleMenu || Game1.currentLocation == null || Game1.player == null)
            {
                return;
            }

            // Add new objects to shop menus and edit shop stock
            if (e.NewMenu is ShopMenu menu && menu != null)
            {
                if (Config.AddCookingToolProgression && Game1.currentLocation?.Name == "Blacksmith")
                {
                    // Upgrade cooking equipment at the blacksmith
                    bool canUpgrade = CanFarmerUpgradeCookingEquipment();
                    int  level      = ModEntry.Instance.States.Value.CookingToolLevel;
                    if (canUpgrade)
                    {
                        if (e.NewMenu is ShopMenu upgradeMenu && upgradeMenu.itemPriceAndStock.Keys.All(key => key.Name != "Coal"))
                        {
                            StardewValley.Tools.GenericTool cookingTool = GenerateCookingTool(level);
                            int price = Helper.Reflection.GetMethod(
                                typeof(Utility), "priceForToolUpgradeLevel").Invoke <int>(level + 1);
                            int index = Helper.Reflection.GetMethod(
                                typeof(Utility), "indexOfExtraMaterialForToolUpgrade").Invoke <int>(level + 1);
                            upgradeMenu.itemPriceAndStock.Add(cookingTool, new int[3] {
                                price / 2, 1, index
                            });
                            upgradeMenu.forSale.Add(cookingTool);
                        }
                    }
                }

                return;
            }
        }
Exemplo n.º 2
0
        public static StardewValley.Tools.GenericTool GenerateCookingTool(int level)
        {
            var name        = GetCookingToolDisplayName(level);
            var description = i18n.Get("menu.cooking_equipment.description", new { level = level + 2 }).ToString();
            var tool        = new StardewValley.Tools.GenericTool(name, description, level + 1, CookingToolSheetIndex + level, CookingToolSheetIndex + level);

            return(tool);
        }
Exemplo n.º 3
0
 public static void GenericTool_ActionWhenClaimed_Prefix(ref StardewValley.Tools.GenericTool __instance)
 {
     if (Tools.IsThisCookingTool(__instance))
     {
         Log.D($"Collected {__instance?.Name ?? "null cooking tool"} (index {__instance.IndexOfMenuItemView})",
               ModEntry.Instance.Config.DebugMode);
         ++ModEntry.Instance.States.Value.CookingToolLevel;
     }
 }