Example #1
0
 private bool tabClick(int x, int y)
 {
     if (joinTab.visible && joinTab.containsPoint(x, y))
     {
         SetTab(Tab.JOIN_TAB);
         return(true);
     }
     if (hostTab.visible && hostTab.containsPoint(x, y))
     {
         SetTab(Tab.HOST_TAB);
         return(true);
     }
     return(false);
 }
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     base.receiveLeftClick(x, y, playSound);
     if (acceptLeftQuestButton.visible && acceptLeftQuestButton.containsPoint(x, y))
     {
         Game1.playSound("newArtifact");
         if (leftOrder != null)
         {
             Game1.player.team.acceptedSpecialOrderTypes.Add(GetOrderType());
             SpecialOrder order2 = leftOrder;
             Game1.player.team.specialOrders.Add(SpecialOrder.GetSpecialOrder(order2.questKey.Value, order2.generationSeed));
             Game1.multiplayer.globalChatInfoMessage("AcceptedSpecialOrder", Game1.player.Name, order2.GetName());
             UpdateButtons();
         }
     }
     else if (acceptRightQuestButton.visible && acceptRightQuestButton.containsPoint(x, y))
     {
         Game1.playSound("newArtifact");
         if (rightOrder != null)
         {
             Game1.player.team.acceptedSpecialOrderTypes.Add(GetOrderType());
             SpecialOrder order = rightOrder;
             Game1.player.team.specialOrders.Add(SpecialOrder.GetSpecialOrder(order.questKey.Value, order.generationSeed));
             Game1.multiplayer.globalChatInfoMessage("AcceptedSpecialOrder", Game1.player.Name, order.GetName());
             UpdateButtons();
         }
     }
 }
Example #3
0
 public void leftClick(int x, int y, ChatBox cb)
 {
     if (isWithinBounds(x, y))
     {
         int relativeX = x - xPositionOnScreen;
         int relativeY = y - yPositionOnScreen;
         if (upArrow.containsPoint(relativeX, relativeY))
         {
             upArrowPressed();
         }
         else if (downArrow.containsPoint(relativeX, relativeY))
         {
             downArrowPressed();
         }
         else if (sendArrow.containsPoint(relativeX, relativeY) && cb.chatBox.currentWidth > 0f)
         {
             cb.textBoxEnter(cb.chatBox);
             sendArrow.scale = 0.5f;
             Game1.playSound("shwip");
         }
         foreach (ClickableComponent c in emojiSelectionButtons)
         {
             if (c.containsPoint(relativeX, relativeY))
             {
                 int index = pageStartIndex + int.Parse(c.name);
                 cb.chatBox.receiveEmoji(index);
                 Game1.playSound("coin");
                 break;
             }
         }
     }
 }
Example #4
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (!Game1.conventionMode)
     {
         if (exitToTitle.containsPoint(x, y) && exitToTitle.visible)
         {
             Game1.playSound("bigDeSelect");
             Game1.ExitToTitle();
         }
         if (exitToDesktop.containsPoint(x, y) && exitToDesktop.visible)
         {
             Game1.playSound("bigDeSelect");
             Game1.quit = true;
         }
     }
 }
Example #5
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (!isSetUp)
     {
         return;
     }
     if (refreshButton.visible && refreshButton.containsPoint(x, y))
     {
         Game1.playSound("bigDeSelect");
         setMenu(new CoopMenu());
     }
     else if (!smallScreenFormat || !tabClick(x, y))
     {
         base.receiveLeftClick(x, y, playSound);
         if (!smallScreenFormat && !loading)
         {
             tabClick(x, y);
         }
     }
 }
Example #6
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     base.receiveLeftClick(x, y, playSound);
     if (acceptQuestButton.visible && acceptQuestButton.containsPoint(x, y))
     {
         Game1.playSound("newArtifact");
         Game1.questOfTheDay.dailyQuest.Value       = true;
         Game1.questOfTheDay.dayQuestAccepted.Value = Game1.Date.TotalDays;
         Game1.questOfTheDay.accepted.Value         = true;
         Game1.questOfTheDay.canBeCancelled.Value   = true;
         Game1.questOfTheDay.daysLeft.Value         = 2;
         Game1.player.questLog.Add(Game1.questOfTheDay);
         Game1.player.acceptedDailyQuest.Set(newValue: true);
         UpdateDailyQuestButton();
     }
 }
Example #7
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (waitingForServerResponse)
     {
         return;
     }
     base.receiveLeftClick(x, y, playSound: true);
     if (!geodeSpot.containsPoint(x, y))
     {
         return;
     }
     if (heldItem != null && Utility.IsGeode(heldItem) && Game1.player.Money >= 25 && geodeAnimationTimer <= 0)
     {
         if (Game1.player.freeSpotsInInventory() > 1 || (Game1.player.freeSpotsInInventory() == 1 && heldItem.Stack == 1))
         {
             if (heldItem.ParentSheetIndex == 791 && !Game1.netWorldState.Value.GoldenCoconutCracked.Value)
             {
                 waitingForServerResponse = true;
                 Game1.player.team.goldenCoconutMutex.RequestLock(delegate
                 {
                     waitingForServerResponse = false;
                     geodeTreasureOverride    = new Object(73, 1);
                     startGeodeCrack();
                 }, delegate
                 {
                     waitingForServerResponse = false;
                     startGeodeCrack();
                 });
             }
             else
             {
                 startGeodeCrack();
             }
         }
         else
         {
             descriptionText  = Game1.content.LoadString("Strings\\UI:GeodeMenu_InventoryFull");
             wiggleWordsTimer = 500;
             alertTimer       = 1500;
         }
     }
     else if (Game1.player.Money < 25)
     {
         wiggleWordsTimer = 500;
         Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
     }
 }
Example #8
0
 public override void receiveLeftClick(int x, int y, bool playSound = false)
 {
     base.receiveLeftClick(x, y, false);
     if (!geodeSpot.containsPoint(x, y))
     {
         return;
     }
     if (heldItem != null && (heldItem.Name.Contains("Geode") || heldItem.ParentSheetIndex == 275) && (geodeAnimationTimer <= 0))
     {
         if (Game1.player.freeSpotsInInventory() > 1 || Game1.player.freeSpotsInInventory() == 1 && heldItem.Stack == 1)
         {
             geodeSpot.item = heldItem.getOne();
             --heldItem.Stack;
             if (heldItem.Stack <= 0)
             {
                 heldItem = null;
             }
             geodeAnimationTimer = 800;
             Game1.playSound("stoneStep");
             clint.setCurrentAnimation(new List <FarmerSprite.AnimationFrame>()
             {
                 new FarmerSprite.AnimationFrame(8, 90),
                 new FarmerSprite.AnimationFrame(9, 60),
                 new FarmerSprite.AnimationFrame(10, 24),
                 new FarmerSprite.AnimationFrame(11, 60),
                 new FarmerSprite.AnimationFrame(12, 30),
                 new FarmerSprite.AnimationFrame(8, 90)
             });
             clint.loop = false;
         }
         else
         {
             descriptionText  = Game1.content.LoadString("Strings\\UI:GeodeMenu_InventoryFull");
             wiggleWordsTimer = 500;
             alertTimer       = 800;
         }
     }
     else
     {
         if (Game1.player.Money >= 0)
         {
             return;
         }
         wiggleWordsTimer = 500;
         Game1.dayTimeMoneyBox.moneyShakeTimer = 1000;
     }
 }
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (scale < 1f)
     {
         return;
     }
     if (upperRightCloseButton != null && readyToClose() && upperRightCloseButton.containsPoint(x, y))
     {
         if (playSound)
         {
             Game1.playSound("bigDeSelect");
         }
         if (!isFromCollection)
         {
             exitThisMenu(ShouldPlayExitSound());
         }
         else
         {
             destroy = true;
         }
     }
     if (Game1.activeClickableMenu == null && Game1.currentMinigame == null)
     {
         unload();
         return;
     }
     foreach (ClickableComponent c in itemsToGrab)
     {
         if (c.containsPoint(x, y) && c.item != null)
         {
             Game1.playSound("coin");
             Game1.player.addItemByMenuIfNecessary(c.item);
             c.item = null;
             return;
         }
     }
     if (backButton.containsPoint(x, y) && page > 0)
     {
         page--;
         Game1.playSound("shwip");
     }
     else if (forwardButton.containsPoint(x, y) && page < mailMessage.Count - 1)
     {
         page++;
         Game1.playSound("shwip");
     }
     else if (acceptQuestButton != null && acceptQuestButton.containsPoint(x, y))
     {
         AcceptQuest();
     }
     else if (isWithinBounds(x, y))
     {
         if (page < mailMessage.Count - 1)
         {
             page++;
             Game1.playSound("shwip");
         }
         else if (!isMail)
         {
             exitThisMenuNoSound();
             Game1.playSound("shwip");
         }
         else if (isFromCollection)
         {
             destroy = true;
         }
     }
     else if (!itemsLeftToGrab())
     {
         if (!isFromCollection)
         {
             exitThisMenuNoSound();
             Game1.playSound("shwip");
         }
         else
         {
             destroy = true;
         }
     }
 }
Example #10
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);
            }
        }
 // Token: 0x06000DB9 RID: 3513 RVA: 0x00116F10 File Offset: 0x00115110
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     if (!this.placingStructure)
     {
         this.heldItem = this.inventory.leftClick(x, y, this.heldItem, true);
         for (int i = 0; i < this.sideTabs.Count; i++)
         {
             if (this.sideTabs[i].containsPoint(x, y) && this.currentTab != i)
             {
                 Game1.playSound("smallSelect");
                 if (i == 3)
                 {
                     this.placingStructure = true;
                     this.demolishing      = true;
                     this.parent.invisible = true;
                 }
                 else
                 {
                     ClickableTextureComponent expr_8F_cp_0_cp_0 = this.sideTabs[this.currentTab];
                     expr_8F_cp_0_cp_0.bounds.X = expr_8F_cp_0_cp_0.bounds.X - CataloguePage.widthToMoveActiveTab;
                     this.currentTab            = i;
                     ClickableTextureComponent expr_B5_cp_0_cp_0 = this.sideTabs[i];
                     expr_B5_cp_0_cp_0.bounds.X = expr_B5_cp_0_cp_0.bounds.X + CataloguePage.widthToMoveActiveTab;
                 }
             }
         }
         using (Dictionary <ClickableComponent, BluePrint> .KeyCollection.Enumerator enumerator = this.blueprintButtons[this.currentTab].Keys.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 ClickableComponent c = enumerator.Current;
                 if (c.containsPoint(x, y))
                 {
                     if (this.blueprintButtons[this.currentTab][c].doesFarmerHaveEnoughResourcesToBuild())
                     {
                         this.structureForPlacement = this.blueprintButtons[this.currentTab][c];
                         this.placingStructure      = true;
                         this.parent.invisible      = true;
                         if (this.currentTab == 1)
                         {
                             this.upgrading = true;
                         }
                         Game1.playSound("smallSelect");
                         break;
                     }
                     Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f));
                     break;
                 }
             }
             return;
         }
     }
     if (this.demolishing)
     {
         if (!(Game1.currentLocation is Farm))
         {
             return;
         }
         if (Game1.IsClient)
         {
             Game1.addHUDMessage(new HUDMessage("Only the farm owner can demolish.", Color.Red, 3500f));
             return;
         }
         Vector2  tileLocation = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize));
         Building destroyed    = ((Farm)Game1.currentLocation).getBuildingAt(tileLocation);
         if (Game1.IsMultiplayer && destroyed != null && destroyed.indoors.farmers.Count > 0)
         {
             Game1.addHUDMessage(new HUDMessage("Someone's in there!", Color.Red, 3500f));
             return;
         }
         if (destroyed == null || !((Farm)Game1.currentLocation).destroyStructure(destroyed))
         {
             this.parent.invisible = false;
             this.placingStructure = false;
             this.demolishing      = false;
             return;
         }
         int groundYTile = destroyed.tileY + destroyed.tilesHigh;
         for (int j = 0; j < destroyed.texture.Bounds.Height / Game1.tileSize; j++)
         {
             Game1.createRadialDebris(Game1.currentLocation, destroyed.texture, new Microsoft.Xna.Framework.Rectangle(destroyed.texture.Bounds.Center.X, destroyed.texture.Bounds.Center.Y, Game1.tileSize / 16, Game1.tileSize / 16), destroyed.tileX + Game1.random.Next(destroyed.tilesWide), destroyed.tileY + destroyed.tilesHigh - j, Game1.random.Next(20, 45), groundYTile);
         }
         Game1.playSound("explosion");
         Utility.spreadAnimalsAround(destroyed, (Farm)Game1.currentLocation);
         if (Game1.IsServer)
         {
             MultiplayerUtility.broadcastBuildingChange(1, tileLocation, "", Game1.currentLocation.name, Game1.player.uniqueMultiplayerID);
             return;
         }
     }
     else
     {
         if (this.upgrading && Game1.currentLocation.GetType() == typeof(Farm))
         {
             (Game1.currentLocation as Farm).tryToUpgrade(((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))), this.structureForPlacement);
             return;
         }
         if (!CataloguePage.canPlaceThisBuildingOnTheCurrentMap(this.structureForPlacement, Game1.currentLocation))
         {
             Game1.addHUDMessage(new HUDMessage("You can't build that in this location.", Color.Red, 3500f));
             return;
         }
         if (!this.structureForPlacement.doesFarmerHaveEnoughResourcesToBuild())
         {
             Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f));
             return;
         }
         if (this.tryToBuild())
         {
             this.structureForPlacement.consumeResources();
             if (!this.structureForPlacement.blueprintType.Equals("Animals"))
             {
                 Game1.playSound("axe");
                 return;
             }
         }
         else if (!Game1.IsClient)
         {
             Game1.addHUDMessage(new HUDMessage("Can't Build There", Color.Red, 3500f));
         }
     }
 }