Example #1
0
 public override void receiveRightClick(int x, int y, bool playSound = true)
 {
     if (!this.allowRightClick)
     {
         return;
     }
     base.receiveRightClick(x, y, playSound && this.playRightClickSound);
     if (this.heldItem == null && this.showReceivingMenu)
     {
         this.heldItem = this.ItemsToGrabMenu.rightClick(x, y, this.heldItem, false);
         if (this.heldItem != null && this.behaviorOnItemGrab != null)
         {
             this.behaviorOnItemGrab(this.heldItem, Game1.player);
         }
         if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
         {
             this.heldItem = null;
             Game1.player.canUnderstandDwarves = true;
             this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
             Game1.playSound("fireball");
             return;
         }
         if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
         {
             string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
             try {
                 if ((this.heldItem as StardewValley.Object).category == -7)
                 {
                     Game1.player.cookingRecipes.Add(key, 0);
                 }
                 else
                 {
                     Game1.player.craftingRecipes.Add(key, 0);
                 }
                 this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                 Game1.playSound("newRecipe");
             } catch (Exception) {
             }
             this.heldItem = null;
             return;
         }
         if (Game1.player.addItemToInventoryBool(this.heldItem, false))
         {
             CJB.removeLastHudMessage();
             this.heldItem = null;
             Game1.playSound("coin");
             return;
         }
     }
     else if (this.reverseGrab)
     {
         this.behaviorFunction(this.heldItem, Game1.player);
         if (this.destroyItemOnClick)
         {
             this.heldItem = null;
         }
     }
 }
Example #2
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            base.receiveLeftClick(x, y, !this.destroyItemOnClick);

            if (this.heldItem == null)
            {
                if (this.upArrow.bounds.Contains(x, y))
                {
                    if (this.ItemsToGrabMenu != null)
                    {
                        this.ItemsToGrabMenu.receiveScrollWheelAction(1);
                    }
                }

                if (this.downArrow.bounds.Contains(x, y))
                {
                    if (this.ItemsToGrabMenu != null)
                    {
                        this.ItemsToGrabMenu.receiveScrollWheelAction(-1);
                    }
                }
            }
            if (this.heldItem == null && this.showReceivingMenu)
            {
                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                if (this.heldItem != null && this.behaviorOnItemGrab != null)
                {
                    this.behaviorOnItemGrab(this.heldItem, Game1.player);
                }
                if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
                {
                    this.heldItem = null;
                    Game1.player.canUnderstandDwarves = true;
                    this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                    Game1.playSound("fireball");
                }
                else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 102)
                {
                    this.heldItem = null;
                    Game1.player.foundArtifact(102, 1);
                    this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                    Game1.playSound("fireball");
                }
                else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
                {
                    string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
                    try {
                        if ((this.heldItem as StardewValley.Object).category == -7)
                        {
                            Game1.player.cookingRecipes.Add(key, 0);
                        }
                        else
                        {
                            Game1.player.craftingRecipes.Add(key, 0);
                        }
                        this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                        Game1.playSound("newRecipe");
                    } catch (Exception) {
                    }
                    this.heldItem = null;
                }
                else if (Game1.player.addItemToInventoryBool(this.heldItem, false))
                {
                    CJB.removeLastHudMessage();
                    this.heldItem = null;
                    Game1.playSound("coin");
                }
            }
            else if ((this.reverseGrab || this.behaviorFunction != null) && this.isWithinBounds(x, y))
            {
                this.behaviorFunction(this.heldItem, Game1.player);
                if (this.destroyItemOnClick)
                {
                    this.heldItem = null;
                    return;
                }
            }
            if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed())
            {
                Game1.playSound("throwDownITem");
                Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection);
                this.heldItem = null;
            }
        }