Пример #1
0
        public static void Before_receiveLeftClick(ShopMenu __instance, int x, int y, int ___sellPercentage)
        {
            try
            {
                if (Game1.activeClickableMenu == null)
                {
                    return;
                }

                if (__instance is ShopMenu)
                {
                    if (__instance.heldItem == null && __instance.onSell == null)
                    {
                        Item itemToSell = __instance.inventory.leftClick(x, y, null, false);

                        if (itemToSell != null)
                        {
                            int price = CalculatePrice(___sellPercentage, itemToSell);

                            QuestCheckers.CheckSellQuests(itemToSell, price);
                            __instance.inventory.leftClick(x, y, itemToSell, false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QuestEssentialsMod.ModMonitor
                .Log(
                    $"Error in {nameof(Before_receiveLeftClick)} harmony patch: {ex}",
                    LogLevel.Error
                    );
            }
        }
Пример #2
0
        public static void Before_set_Money(Farmer __instance, int value)
        {
            int oldMoney = __instance._money;

            if (value <= oldMoney)
            {
                return;
            }

            QuestCheckers.CheckEarnQuests(value - oldMoney);
        }
Пример #3
0
        public static void Before_receiveRightClick(ShopMenu __instance, int x, int y)
        {
            try
            {
                if (Game1.activeClickableMenu == null)
                {
                    return;
                }

                if (__instance is ShopMenu)
                {
                    if (__instance.heldItem == null && __instance.onSell == null)
                    {
                        Item itemToSell = __instance.inventory.rightClick(x, y, null, false, false);

                        if (itemToSell != null)
                        {
                            QuestCheckers.CheckSellQuests(itemToSell);

                            if (itemToSell.Stack == 1)
                            {
                                __instance.inventory.leftClick(x, y, itemToSell, false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QuestEssentialsMod.ModMonitor
                .Log(
                    $"Error in {nameof(Before_receiveRightClick)} harmony patch: {ex}",
                    LogLevel.Error
                    );
            }
        }