Exemplo n.º 1
0
        /// <summary>
        /// Add chests to fridge
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }
            ChestController.UpdateChest();
            if (e.NewMenu == e.OldMenu || e.NewMenu == null)
            {
                return;
            }

            // If The (Cooking) Crafting page is opened
            if (!_compatibilityInfo.CookingSkillLoaded && e.NewMenu is StardewValley.Menus.CraftingPage &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "cooking", false) != null &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "cooking").GetValue())
            {
                FridgeController.InjectItems();
            }

            // If the Cooking Skill Page is opened.
            if (_compatibilityInfo.CookingSkillLoaded &&
                e.NewMenu.GetType().ToString() == "CookingSkill.NewCraftingPage")
            {
                FridgeController.InjectItems();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add chests to fridge
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }
            ChestController.UpdateChest();
            if (e.NewMenu == e.OldMenu || e.NewMenu == null)
            {
                return;
            }

            // If The (Cooking) Crafting page is opened
            if (e.NewMenu is StardewValley.Menus.CraftingPage &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "cooking", false) != null &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "cooking").GetValue())
            {
                FridgeController.InjectItems();
                return;
            }

            // If the Cooking Skill Page is opened.
            if (_compatibilityInfo.CookingSkillLoaded &&
                e.NewMenu.GetType().ToString() == "CookingSkill.NewCraftingPage")
            {
                FridgeController.InjectItems();
                return;
            }

            if (Helper.Reflection.GetField <bool>(e.NewMenu, "cooking", false) != null &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "cooking").GetValue())
            {
                Monitor.Log("Menu changed to " + e.NewMenu.GetType() + " which is a unrecognized type. Is it from an incompatible mod?", LogLevel.Warn);
            }
        }