コード例 #1
0
 public override void receiveGamePadButton(Buttons b)
 {
     if (b == Buttons.Back && organizeButton != null)
     {
         ItemGrabMenu.organizeItemsInList(Game1.player.items);
         Game1.playSound("Ship");
     }
 }
コード例 #2
0
 public override void receiveGamePadButton(Buttons b)
 {
     if (b != Buttons.Back || this.organizeButton == null)
     {
         return;
     }
     ItemGrabMenu.organizeItemsInList(Game1.player.items);
     Game1.playSound("Ship");
 }
コード例 #3
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     base.receiveLeftClick(x, y, !this.destroyItemOnClick);
     if (this.shippingBin && this.lastShippedHolder.containsPoint(x, y))
     {
         if (Game1.getFarm().lastItemShipped != null && Game1.player.addItemToInventoryBool(Game1.getFarm().lastItemShipped, false))
         {
             Game1.playSound("coin");
             Game1.getFarm().shippingBin.Remove(Game1.getFarm().lastItemShipped);
             Game1.getFarm().lastItemShipped = null;
             if (Game1.player.ActiveObject != null)
             {
                 Game1.player.showCarrying();
                 Game1.player.Halt();
             }
         }
         return;
     }
     if (this.chestColorPicker != null)
     {
         this.chestColorPicker.receiveLeftClick(x, y, true);
         if (this.sourceItem != null && this.sourceItem is Chest)
         {
             (this.sourceItem as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
         }
     }
     if (this.colorPickerToggleButton != null && this.colorPickerToggleButton.containsPoint(x, y))
     {
         Game1.player.showChestColorPicker = !Game1.player.showChestColorPicker;
         this.chestColorPicker.visible     = Game1.player.showChestColorPicker;
         try
         {
             Game1.playSound("drumkit6");
         }
         catch (Exception)
         {
         }
     }
     if (this.whichSpecialButton != -1 && this.specialButton != null && this.specialButton.containsPoint(x, y))
     {
         Game1.playSound("drumkit6");
         int num = this.whichSpecialButton;
         if (num == 1 && this.specialObject != null && this.specialObject is JunimoHut)
         {
             (this.specialObject as JunimoHut).noHarvest = !(this.specialObject as JunimoHut).noHarvest;
             this.specialButton.sourceRect.X             = ((this.specialObject as JunimoHut).noHarvest ? 124 : 108);
         }
     }
     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 (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
             {
                 (Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
                 if (Game1.options.SnappyMenus)
                 {
                     (Game1.activeClickableMenu as ItemGrabMenu).currentlySnappedComponent = this.currentlySnappedComponent;
                     (Game1.activeClickableMenu as ItemGrabMenu).snapCursorToCurrentSnappedComponent();
                 }
             }
         }
         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))
         {
             this.heldItem = null;
             Game1.playSound("coin");
         }
     }
     else if ((this.reverseGrab || this.behaviorFunction != null) && this.isWithinBounds(x, y))
     {
         this.behaviorFunction(this.heldItem, Game1.player);
         if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
         {
             (Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
             if (Game1.options.SnappyMenus)
             {
                 (Game1.activeClickableMenu as ItemGrabMenu).currentlySnappedComponent = this.currentlySnappedComponent;
                 (Game1.activeClickableMenu as ItemGrabMenu).snapCursorToCurrentSnappedComponent();
             }
         }
         if (this.destroyItemOnClick)
         {
             this.heldItem = null;
             return;
         }
     }
     if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
     {
         ItemGrabMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
         Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem, -1, null);
         Game1.playSound("Ship");
         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, null);
         if (this.inventory.onAddItem != null)
         {
             this.inventory.onAddItem(this.heldItem, Game1.player);
         }
         this.heldItem = null;
     }
 }
コード例 #4
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     foreach (ClickableComponent equipmentIcon in this.equipmentIcons)
     {
         if (equipmentIcon.containsPoint(x, y))
         {
             bool   flag = this.heldItem == null;
             string name = equipmentIcon.name;
             if (!(name == "Hat"))
             {
                 if (!(name == "Left Ring"))
                 {
                     if (!(name == "Right Ring"))
                     {
                         if (name == "Boots" && (this.heldItem == null || this.heldItem is Boots))
                         {
                             Boots heldItem = (Boots)this.heldItem;
                             this.heldItem      = (Item)Game1.player.boots;
                             Game1.player.boots = heldItem;
                             if (this.heldItem != null)
                             {
                                 (this.heldItem as Boots).onUnequip();
                             }
                             if (Game1.player.boots != null)
                             {
                                 Game1.player.boots.onEquip();
                                 Game1.playSound("sandyStep");
                                 DelayedAction.playSoundAfterDelay("sandyStep", 150);
                             }
                             else if (this.heldItem != null)
                             {
                                 Game1.playSound("dwop");
                             }
                         }
                     }
                     else if (this.heldItem == null || this.heldItem is Ring)
                     {
                         Ring heldItem = (Ring)this.heldItem;
                         this.heldItem          = (Item)Game1.player.rightRing;
                         Game1.player.rightRing = heldItem;
                         if (this.heldItem != null)
                         {
                             (this.heldItem as Ring).onUnequip(Game1.player);
                         }
                         if (Game1.player.rightRing != null)
                         {
                             Game1.player.rightRing.onEquip(Game1.player);
                             Game1.playSound("crit");
                         }
                         else if (this.heldItem != null)
                         {
                             Game1.playSound("dwop");
                         }
                     }
                 }
                 else if (this.heldItem == null || this.heldItem is Ring)
                 {
                     Ring heldItem = (Ring)this.heldItem;
                     this.heldItem         = (Item)Game1.player.leftRing;
                     Game1.player.leftRing = heldItem;
                     if (this.heldItem != null)
                     {
                         (this.heldItem as Ring).onUnequip(Game1.player);
                     }
                     if (Game1.player.leftRing != null)
                     {
                         Game1.player.leftRing.onEquip(Game1.player);
                         Game1.playSound("crit");
                     }
                     else if (this.heldItem != null)
                     {
                         Game1.playSound("dwop");
                     }
                 }
             }
             else if (this.heldItem == null || this.heldItem is Hat)
             {
                 Hat heldItem = (Hat)this.heldItem;
                 this.heldItem    = (Item)Game1.player.hat;
                 Game1.player.hat = heldItem;
                 if (Game1.player.hat != null)
                 {
                     Game1.playSound("grassyStep");
                 }
                 else if (this.heldItem != null)
                 {
                     Game1.playSound("dwop");
                 }
             }
             if (flag && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
             {
                 for (int position = 0; position < Game1.player.items.Count; ++position)
                 {
                     if (Game1.player.items[position] == null || Game1.player.items[position].canStackWith(this.heldItem))
                     {
                         if (Game1.player.CurrentToolIndex == position && this.heldItem != null)
                         {
                             this.heldItem.actionWhenBeingHeld(Game1.player);
                         }
                         this.heldItem = Utility.addItemToInventory(this.heldItem, position, this.inventory.actualInventory, (ItemGrabMenu.behaviorOnItemSelect)null);
                         if (Game1.player.CurrentToolIndex == position && this.heldItem != null)
                         {
                             this.heldItem.actionWhenStopBeingHeld(Game1.player);
                         }
                         Game1.playSound("stoneStep");
                         return;
                     }
                 }
             }
         }
     }
     this.heldItem = this.inventory.leftClick(x, y, this.heldItem, !Game1.oldKBState.IsKeyDown(Keys.LeftShift));
     if (this.heldItem != null && this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).ParentSheetIndex == 434)
     {
         Game1.playSound("smallSelect");
         Game1.playerEatObject(this.heldItem as StardewValley.Object, true);
         this.heldItem = (Item)null;
         Game1.exitActiveMenu();
     }
     else if (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
     {
         if (this.heldItem is Ring)
         {
             if (Game1.player.leftRing == null)
             {
                 Game1.player.leftRing = this.heldItem as Ring;
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = (Item)null;
                 Game1.playSound("crit");
                 return;
             }
             if (Game1.player.rightRing == null)
             {
                 Game1.player.rightRing = this.heldItem as Ring;
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = (Item)null;
                 Game1.playSound("crit");
                 return;
             }
         }
         else if (this.heldItem is Hat)
         {
             if (Game1.player.hat == null)
             {
                 Game1.player.hat = this.heldItem as Hat;
                 Game1.playSound("grassyStep");
                 this.heldItem = (Item)null;
                 return;
             }
         }
         else if (this.heldItem is Boots && Game1.player.boots == null)
         {
             Game1.player.boots = this.heldItem as Boots;
             (this.heldItem as Boots).onEquip();
             Game1.playSound("sandyStep");
             DelayedAction.playSoundAfterDelay("sandyStep", 150);
             this.heldItem = (Item)null;
             return;
         }
         if (this.inventory.getInventoryPositionOfClick(x, y) >= 12)
         {
             for (int position = 0; position < 12; ++position)
             {
                 if (Game1.player.items[position] == null || Game1.player.items[position].canStackWith(this.heldItem))
                 {
                     if (Game1.player.CurrentToolIndex == position && this.heldItem != null)
                     {
                         this.heldItem.actionWhenBeingHeld(Game1.player);
                     }
                     this.heldItem = Utility.addItemToInventory(this.heldItem, position, this.inventory.actualInventory, (ItemGrabMenu.behaviorOnItemSelect)null);
                     if (this.heldItem != null)
                     {
                         this.heldItem.actionWhenStopBeingHeld(Game1.player);
                     }
                     Game1.playSound("stoneStep");
                     return;
                 }
             }
         }
     }
     if (this.portrait.containsPoint(x, y))
     {
         this.portrait.name = this.portrait.name.Equals("32") ? "8" : "32";
     }
     if (this.heldItem != null && this.trashCan.containsPoint(x, y) && this.heldItem.canBeTrashed())
     {
         if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex))
         {
             Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex);
         }
         this.heldItem = (Item)null;
         Game1.playSound("trashcan");
     }
     else if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed())
     {
         Game1.playSound("throwDownITem");
         Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection, (GameLocation)null);
         this.heldItem = (Item)null;
     }
     if (this.organizeButton == null || !this.organizeButton.containsPoint(x, y))
     {
         return;
     }
     ItemGrabMenu.organizeItemsInList(Game1.player.items);
     Game1.playSound("Ship");
 }
コード例 #5
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            foreach (ClickableComponent c in equipmentIcons)
            {
                if (c.containsPoint(x, y))
                {
                    bool heldItemWasNull = !checkHeldItem();
                    switch (c.name)
                    {
                    case "Hat":
                        if (checkHeldItem((Item i) => i == null || i is Hat || i is Pan))
                        {
                            Hat  tmp       = (Game1.player.CursorSlotItem is Pan) ? new Hat(71) : ((Hat)takeHeldItem());
                            Item heldItem2 = (Hat)Game1.player.hat;
                            heldItem2 = Utility.PerformSpecialItemGrabReplacement(heldItem2);
                            setHeldItem(heldItem2);
                            Game1.player.hat.Value = tmp;
                            if (Game1.player.hat.Value != null)
                            {
                                Game1.playSound("grassyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Left Ring":
                        if (checkHeldItem((Item i) => i == null || i is Ring))
                        {
                            Ring tmp2 = (Ring)takeHeldItem();
                            if (Game1.player.leftRing.Value != null)
                            {
                                Game1.player.leftRing.Value.onUnequip(Game1.player, Game1.currentLocation);
                            }
                            setHeldItem((Ring)Game1.player.leftRing);
                            Game1.player.leftRing.Value = tmp2;
                            if (Game1.player.leftRing.Value != null)
                            {
                                Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation);
                                Game1.playSound("crit");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Right Ring":
                        if (checkHeldItem((Item i) => i == null || i is Ring))
                        {
                            Ring tmp3 = (Ring)takeHeldItem();
                            if (Game1.player.rightRing.Value != null)
                            {
                                Game1.player.rightRing.Value.onUnequip(Game1.player, Game1.currentLocation);
                            }
                            setHeldItem((Ring)Game1.player.rightRing);
                            Game1.player.rightRing.Value = tmp3;
                            if (Game1.player.rightRing.Value != null)
                            {
                                Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation);
                                Game1.playSound("crit");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Boots":
                        if (checkHeldItem((Item i) => i == null || i is Boots))
                        {
                            Boots tmp4 = (Boots)takeHeldItem();
                            if (Game1.player.boots.Value != null)
                            {
                                Game1.player.boots.Value.onUnequip();
                            }
                            setHeldItem((Boots)Game1.player.boots);
                            Game1.player.boots.Value = tmp4;
                            if (Game1.player.boots.Value != null)
                            {
                                Game1.player.boots.Value.onEquip();
                                Game1.playSound("sandyStep");
                                DelayedAction.playSoundAfterDelay("sandyStep", 150);
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Shirt":
                        if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 0)))
                        {
                            Clothing tmp5      = (Clothing)takeHeldItem();
                            Item     heldItem4 = (Clothing)Game1.player.shirtItem;
                            heldItem4 = Utility.PerformSpecialItemGrabReplacement(heldItem4);
                            setHeldItem(heldItem4);
                            Game1.player.shirtItem.Value = tmp5;
                            if (Game1.player.shirtItem.Value != null)
                            {
                                Game1.playSound("sandyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Pants":
                        if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 1) || (i is Object && (int)i.parentSheetIndex == 71)))
                        {
                            Clothing tmp6      = (Game1.player.CursorSlotItem is Object && (int)Game1.player.CursorSlotItem.parentSheetIndex == 71) ? new Clothing(15) : ((Clothing)takeHeldItem());
                            Item     heldItem6 = (Clothing)Game1.player.pantsItem;
                            heldItem6 = Utility.PerformSpecialItemGrabReplacement(heldItem6);
                            setHeldItem(heldItem6);
                            Game1.player.pantsItem.Value = tmp6;
                            if (Game1.player.pantsItem.Value != null)
                            {
                                Game1.playSound("sandyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;
                    }
                    if (heldItemWasNull && checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
                    {
                        int l;
                        for (l = 0; l < Game1.player.items.Count; l++)
                        {
                            if (Game1.player.items[l] == null || checkHeldItem((Item item) => Game1.player.items[l].canStackWith(item)))
                            {
                                if (Game1.player.CurrentToolIndex == l && checkHeldItem())
                                {
                                    Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                                }
                                setHeldItem(Utility.addItemToInventory(takeHeldItem(), l, inventory.actualInventory));
                                if (Game1.player.CurrentToolIndex == l && checkHeldItem())
                                {
                                    Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                                }
                                Game1.playSound("stoneStep");
                                return;
                            }
                        }
                    }
                }
            }
            setHeldItem(inventory.leftClick(x, y, takeHeldItem(), !Game1.oldKBState.IsKeyDown(Keys.LeftShift)));
            if (checkHeldItem((Item i) => i != null && Utility.IsNormalObjectAtParentSheetIndex(i, 434)))
            {
                Game1.playSound("smallSelect");
                Game1.player.eatObject(takeHeldItem() as Object, overrideFullness: true);
                Game1.exitActiveMenu();
            }
            else if (checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
            {
                if (checkHeldItem((Item i) => i is Ring))
                {
                    if (Game1.player.leftRing.Value == null)
                    {
                        Game1.player.leftRing.Value = (takeHeldItem() as Ring);
                        Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation);
                        Game1.playSound("crit");
                        return;
                    }
                    if (Game1.player.rightRing.Value == null)
                    {
                        Game1.player.rightRing.Value = (takeHeldItem() as Ring);
                        Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation);
                        Game1.playSound("crit");
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Hat))
                {
                    if (Game1.player.hat.Value == null)
                    {
                        Game1.player.hat.Value = (takeHeldItem() as Hat);
                        Game1.playSound("grassyStep");
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Boots))
                {
                    if (Game1.player.boots.Value == null)
                    {
                        Game1.player.boots.Value = (takeHeldItem() as Boots);
                        Game1.player.boots.Value.onEquip();
                        Game1.playSound("sandyStep");
                        DelayedAction.playSoundAfterDelay("sandyStep", 150);
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 0))
                {
                    if (Game1.player.shirtItem.Value == null)
                    {
                        Game1.player.shirtItem.Value = (takeHeldItem() as Clothing);
                        Game1.playSound("sandyStep");
                        DelayedAction.playSoundAfterDelay("sandyStep", 150);
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 1) && Game1.player.pantsItem.Value == null)
                {
                    Game1.player.pantsItem.Value = (takeHeldItem() as Clothing);
                    Game1.playSound("sandyStep");
                    DelayedAction.playSoundAfterDelay("sandyStep", 150);
                    return;
                }
                if (inventory.getInventoryPositionOfClick(x, y) >= 12)
                {
                    int k;
                    for (k = 0; k < 12; k++)
                    {
                        if (Game1.player.items[k] == null || checkHeldItem((Item item) => Game1.player.items[k].canStackWith(item)))
                        {
                            if (Game1.player.CurrentToolIndex == k && checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                            }
                            setHeldItem(Utility.addItemToInventory(takeHeldItem(), k, inventory.actualInventory));
                            if (checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                            }
                            Game1.playSound("stoneStep");
                            return;
                        }
                    }
                }
                else if (inventory.getInventoryPositionOfClick(x, y) < 12)
                {
                    int j;
                    for (j = 12; j < Game1.player.items.Count; j++)
                    {
                        if (Game1.player.items[j] == null || checkHeldItem((Item item) => Game1.player.items[j].canStackWith(item)))
                        {
                            if (Game1.player.CurrentToolIndex == j && checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                            }
                            setHeldItem(Utility.addItemToInventory(takeHeldItem(), j, inventory.actualInventory));
                            if (checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                            }
                            Game1.playSound("stoneStep");
                            return;
                        }
                    }
                }
            }
            if (portrait.containsPoint(x, y))
            {
                portrait.name = (portrait.name.Equals("32") ? "8" : "32");
            }
            if (trashCan.containsPoint(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false))
            {
                Utility.trashItem(takeHeldItem());
                if (Game1.options.SnappyMenus)
                {
                    snapCursorToCurrentSnappedComponent();
                }
            }
            else if (!isWithinBounds(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false))
            {
                Game1.playSound("throwDownITem");
                Game1.createItemDebris(takeHeldItem(), Game1.player.getStandingPosition(), Game1.player.FacingDirection).DroppedByPlayerID.Value = Game1.player.UniqueMultiplayerID;
            }
            if (organizeButton != null && organizeButton.containsPoint(x, y))
            {
                ItemGrabMenu.organizeItemsInList(Game1.player.items);
                Game1.playSound("Ship");
            }
            if (junimoNoteIcon != null && junimoNoteIcon.containsPoint(x, y) && readyToClose())
            {
                Game1.activeClickableMenu = new JunimoNoteMenu(fromGameMenu: true);
            }
        }
コード例 #6
0
 // Token: 0x06000EBB RID: 3771 RVA: 0x0012C350 File Offset: 0x0012A550
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     foreach (ClickableComponent c in this.equipmentIcons)
     {
         if (c.containsPoint(x, y))
         {
             bool   heldItemWasNull = this.heldItem == null;
             string name            = c.name;
             if (!(name == "Hat"))
             {
                 if (!(name == "Left Ring"))
                 {
                     if (!(name == "Right Ring"))
                     {
                         if (name == "Boots")
                         {
                             if (this.heldItem == null || this.heldItem is Boots)
                             {
                                 Boots tmp = (Boots)this.heldItem;
                                 this.heldItem      = Game1.player.boots;
                                 Game1.player.boots = tmp;
                                 if (this.heldItem != null)
                                 {
                                     (this.heldItem as Boots).onUnequip();
                                 }
                                 if (Game1.player.boots != null)
                                 {
                                     Game1.player.boots.onEquip();
                                 }
                                 if (this.heldItem == null)
                                 {
                                     Game1.playSound("sandyStep");
                                     DelayedAction.playSoundAfterDelay("sandyStep", 150);
                                 }
                                 else
                                 {
                                     Game1.playSound("dwop");
                                 }
                             }
                         }
                     }
                     else if (this.heldItem == null || this.heldItem is Ring)
                     {
                         Ring tmp2 = (Ring)this.heldItem;
                         this.heldItem          = Game1.player.rightRing;
                         Game1.player.rightRing = tmp2;
                         if (this.heldItem != null)
                         {
                             (this.heldItem as Ring).onUnequip(Game1.player);
                         }
                         if (Game1.player.rightRing != null)
                         {
                             Game1.player.rightRing.onEquip(Game1.player);
                         }
                         if (this.heldItem == null)
                         {
                             Game1.playSound("crit");
                         }
                         else
                         {
                             Game1.playSound("dwop");
                         }
                     }
                 }
                 else if (this.heldItem == null || this.heldItem is Ring)
                 {
                     Ring tmp3 = (Ring)this.heldItem;
                     this.heldItem         = Game1.player.leftRing;
                     Game1.player.leftRing = tmp3;
                     if (this.heldItem != null)
                     {
                         (this.heldItem as Ring).onUnequip(Game1.player);
                     }
                     if (Game1.player.leftRing != null)
                     {
                         Game1.player.leftRing.onEquip(Game1.player);
                     }
                     if (this.heldItem == null)
                     {
                         Game1.playSound("crit");
                     }
                     else
                     {
                         Game1.playSound("dwop");
                     }
                 }
             }
             else if (this.heldItem == null || this.heldItem is Hat)
             {
                 Hat tmp4 = (Hat)this.heldItem;
                 this.heldItem    = Game1.player.hat;
                 Game1.player.hat = tmp4;
                 if (this.heldItem == null)
                 {
                     Game1.playSound("grassyStep");
                 }
                 else
                 {
                     Game1.playSound("dwop");
                 }
             }
             if (heldItemWasNull && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
             {
                 for (int i = 0; i < Game1.player.items.Count; i++)
                 {
                     if (Game1.player.items[i] == null || Game1.player.items[i].canStackWith(this.heldItem))
                     {
                         if (Game1.player.CurrentToolIndex == i && this.heldItem != null)
                         {
                             this.heldItem.actionWhenBeingHeld(Game1.player);
                         }
                         this.heldItem = Utility.addItemToInventory(this.heldItem, i, this.inventory.actualInventory, null);
                         if (Game1.player.CurrentToolIndex == i && this.heldItem != null)
                         {
                             this.heldItem.actionWhenStopBeingHeld(Game1.player);
                         }
                         Game1.playSound("stoneStep");
                         return;
                     }
                 }
             }
         }
     }
     this.heldItem = this.inventory.leftClick(x, y, this.heldItem, !Game1.oldKBState.IsKeyDown(Keys.LeftShift));
     if (this.heldItem != null && this.heldItem is Object && (this.heldItem as Object).ParentSheetIndex == 434)
     {
         Game1.playSound("smallSelect");
         Game1.playerEatObject(this.heldItem as Object, true);
         this.heldItem = null;
         Game1.exitActiveMenu();
     }
     else if (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
     {
         if (this.heldItem is Ring)
         {
             if (Game1.player.leftRing == null)
             {
                 Game1.player.leftRing = (this.heldItem as Ring);
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = null;
                 Game1.playSound("crit");
                 return;
             }
             if (Game1.player.rightRing == null)
             {
                 Game1.player.rightRing = (this.heldItem as Ring);
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = null;
                 Game1.playSound("crit");
                 return;
             }
         }
         else if (this.heldItem is Hat)
         {
             if (Game1.player.hat == null)
             {
                 Game1.player.hat = (this.heldItem as Hat);
                 Game1.playSound("grassyStep");
                 this.heldItem = null;
                 return;
             }
         }
         else if (this.heldItem is Boots && Game1.player.boots == null)
         {
             Game1.player.boots = (this.heldItem as Boots);
             (this.heldItem as Boots).onEquip();
             Game1.playSound("sandyStep");
             DelayedAction.playSoundAfterDelay("sandyStep", 150);
             this.heldItem = null;
             return;
         }
         if (this.inventory.getInventoryPositionOfClick(x, y) >= 12)
         {
             for (int j = 0; j < 12; j++)
             {
                 if (Game1.player.items[j] == null || Game1.player.items[j].canStackWith(this.heldItem))
                 {
                     if (Game1.player.CurrentToolIndex == j && this.heldItem != null)
                     {
                         this.heldItem.actionWhenBeingHeld(Game1.player);
                     }
                     this.heldItem = Utility.addItemToInventory(this.heldItem, j, this.inventory.actualInventory, null);
                     if (this.heldItem != null)
                     {
                         this.heldItem.actionWhenStopBeingHeld(Game1.player);
                     }
                     Game1.playSound("stoneStep");
                     return;
                 }
             }
         }
     }
     if (this.portrait.containsPoint(x, y))
     {
         this.portrait.name = (this.portrait.name.Equals("32") ? "8" : "32");
     }
     if (this.heldItem != null && this.trashCan.containsPoint(x, y) && this.heldItem.canBeTrashed())
     {
         if (this.heldItem is Object && Game1.player.specialItems.Contains((this.heldItem as Object).parentSheetIndex))
         {
             Game1.player.specialItems.Remove((this.heldItem as Object).parentSheetIndex);
         }
         this.heldItem = null;
         Game1.playSound("trashcan");
     }
     else if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed())
     {
         Game1.playSound("throwDownITem");
         Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection, null);
         this.heldItem = null;
     }
     if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
     {
         ItemGrabMenu.organizeItemsInList(Game1.player.items);
         Game1.playSound("Ship");
     }
 }