Exemplo n.º 1
0
        private void clickCraftingRecipe(ClickableTextureComponent c, bool playSound = true)
        {
            Item obj = this.pagesOfCraftingRecipes[this.currentCraftingPage][c].createItem();
            /////
            bool    consume  = Mod.onCook(this.pagesOfCraftingRecipes[this.currentCraftingPage][c], obj);
            SObject heldObj  = this.heldItem as SObject;
            SObject itemObj  = obj as SObject;
            bool    didCraft = false;

            /////
            Game1.player.checkForQuestComplete((NPC)null, -1, -1, obj, (string)null, 2, -1);
            if (this.heldItem == null)
            {
                this.pagesOfCraftingRecipes[this.currentCraftingPage][c].consumeIngredients();
                /////
                if (consume)
                {
                    NewCraftingPage.myConsumeIngredients(this.pagesOfCraftingRecipes[this.currentCraftingPage][c]);
                }
                didCraft = true;
                /////
                this.heldItem = obj;
                if (playSound)
                {
                    Game1.playSound("coin");
                }
            }
            else if (this.heldItem.Name.Equals(obj.Name) && this.heldItem.Stack + this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft - 1 < this.heldItem.maximumStackSize())
            {
                this.heldItem.Stack += this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft;
                /////
                if (consume)
                {
                    NewCraftingPage.myConsumeIngredients(this.pagesOfCraftingRecipes[this.currentCraftingPage][c]);
                }
                didCraft = true;
                /////
                if (playSound)
                {
                    Game1.playSound("coin");
                }
            }
            if (!this.cooking && Game1.player.craftingRecipes.ContainsKey(this.pagesOfCraftingRecipes[this.currentCraftingPage][c].name))
            {
                Game1.player.craftingRecipes[this.pagesOfCraftingRecipes[this.currentCraftingPage][c].name] += this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft;
            }

            /////
            if (!didCraft)
            {
                return;
            }
            /////

            if (this.cooking)
            {
                Game1.player.cookedRecipe((int)((NetFieldBase <int, NetInt>) this.heldItem.parentSheetIndex));
                /////
                Mod.addCookingExp(itemObj.Edibility);
                /////
            }
            if (!this.cooking)
            {
                Game1.stats.checkForCraftingAchievements();
            }
            else
            {
                Game1.stats.checkForCookingAchievements();
            }
            if (!Game1.options.gamepadControls || this.heldItem == null || !Game1.player.couldInventoryAcceptThisItem(this.heldItem))
            {
                return;
            }
            Game1.player.addItemToInventoryBool(this.heldItem, false);
            this.heldItem = (Item)null;
        }
Exemplo n.º 2
0
        private void clickCraftingRecipe(ClickableTextureComponent c, bool playSound = true)
        {
            Item   item     = this.pagesOfCraftingRecipes[this.currentCraftingPage][c].createItem();
            bool   consume  = Mod.onCook(this.pagesOfCraftingRecipes[this.currentCraftingPage][c], item);
            Object heldObj  = this.heldItem as Object;
            Object itemObj  = item as Object;
            bool   didCraft = false;

            Game1.player.checkForQuestComplete(null, -1, -1, item, null, 2, -1);
            if (this.heldItem == null)
            {
                if (consume)
                {
                    NewCraftingPage.myConsumeIngredients(this.pagesOfCraftingRecipes[this.currentCraftingPage][c]);
                }
                didCraft      = true;
                this.heldItem = item;
                if (playSound)
                {
                    Game1.playSound("coin");
                }
            }
            else if (this.heldItem.Name.Equals(item.Name) && heldObj.quality == itemObj.quality && this.heldItem.Stack + this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft - 1 < this.heldItem.maximumStackSize())
            {
                this.heldItem.Stack += this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft;
                if (consume)
                {
                    NewCraftingPage.myConsumeIngredients(this.pagesOfCraftingRecipes[this.currentCraftingPage][c]);
                }
                didCraft = true;
                if (playSound)
                {
                    Game1.playSound("coin");
                }
            }
            if (!this.cooking && Game1.player.craftingRecipes.ContainsKey(this.pagesOfCraftingRecipes[this.currentCraftingPage][c].name))
            {
                string name = this.pagesOfCraftingRecipes[this.currentCraftingPage][c].name;
                Game1.player.craftingRecipes[name] += this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft;
            }
            if (!didCraft)
            {
                return;
            }

            if (this.cooking)
            {
                Game1.player.cookedRecipe(this.heldItem.parentSheetIndex);
                Mod.addCookingExp(itemObj.edibility);
            }
            if (!this.cooking)
            {
                Game1.stats.checkForCraftingAchievements();
            }
            else
            {
                Game1.stats.checkForCookingAchievements();
            }
            if (Game1.options.gamepadControls && this.heldItem != null && Game1.player.couldInventoryAcceptThisItem(this.heldItem))
            {
                Game1.player.addItemToInventoryBool(this.heldItem, false);
                this.heldItem = null;
            }
        }