Exemple #1
0
 public override void performHoverAction(int x, int y)
 {
     base.performHoverAction(x, y);
     this.hoverTitle      = "";
     this.descriptionText = "";
     this.hoverText       = "";
     this.hoverRecipe     = null;
     this.hoverItem       = this.inventory.hover(x, y, this.hoverItem);
     if (this.hoverItem != null)
     {
         this.hoverTitle = this.inventory.hoverTitle;
         this.hoverText  = this.inventory.hoverText;
     }
     foreach (ClickableTextureComponent current in this.pagesOfCraftingRecipes[this.currentCraftingPage].Keys)
     {
         if (current.containsPoint(x, y))
         {
             if (current.hoverText.Equals("ghosted"))
             {
                 this.hoverText = "???";
             }
             else
             {
                 this.hoverRecipe = this.pagesOfCraftingRecipes[this.currentCraftingPage][current];
                 if (this.lastCookingHover == null || !this.lastCookingHover.Name.Equals(this.hoverRecipe.name))
                 {
                     this.lastCookingHover = this.hoverRecipe.createItem();
                     Mod.onCook(this.hoverRecipe, this.lastCookingHover);
                 }
                 current.scale = Math.Min(current.scale + 0.02f, current.baseScale + 0.1f);
             }
         }
         else
         {
             current.scale = Math.Max(current.scale - 0.02f, current.baseScale);
         }
     }
     if (this.upButton != null)
     {
         if (this.upButton.containsPoint(x, y))
         {
             this.upButton.scale = Math.Min(this.upButton.scale + 0.02f, this.upButton.baseScale + 0.1f);
         }
         else
         {
             this.upButton.scale = Math.Max(this.upButton.scale - 0.02f, this.upButton.baseScale);
         }
     }
     if (this.downButton != null)
     {
         if (this.downButton.containsPoint(x, y))
         {
             this.downButton.scale = Math.Min(this.downButton.scale + 0.02f, this.downButton.baseScale + 0.1f);
         }
         else
         {
             this.downButton.scale = Math.Max(this.downButton.scale - 0.02f, this.downButton.baseScale);
         }
     }
     if (this.trashCan != null)
     {
         if (this.trashCan.containsPoint(x, y))
         {
             if (this.trashCanLidRotation <= 0f)
             {
                 Game1.playSound("trashcanlid");
             }
             this.trashCanLidRotation = Math.Min(this.trashCanLidRotation + 0.06544985f, 1.57079637f);
             return;
         }
         this.trashCanLidRotation = Math.Max(this.trashCanLidRotation - 0.06544985f, 0f);
     }
 }
Exemple #2
0
 public bool ModifyCookedItem(CraftingRecipe recipe, Item craftedItem, List <Chest> additionalIngredients)
 {
     return(Mod.onCook(recipe, craftedItem, additionalIngredients));
 }
Exemple #3
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;
            }
        }
Exemple #4
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, _materialContainers);
            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)
            {
                /////
                if (consume)
                {
                    NewCraftingPage.myConsumeIngredients(this.pagesOfCraftingRecipes[this.currentCraftingPage][c], this._materialContainers);
                }
                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], this._materialContainers);
                }
                didCraft = true;
                /////
                if (playSound)
                {
                    Game1.playSound("coin");
                }
            }
            /////
            if (!didCraft)
            {
                return;
            }
            /////
            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 (this.cooking)
            {
                Game1.player.cookedRecipe((int)((NetFieldBase <int, NetInt>) this.heldItem.parentSheetIndex));
                /////
                Game1.player.AddCustomSkillExperience(Mod.skill, 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;
        }