public void tryToUpgrade(Building toUpgrade, BluePrint blueprint)
 {
     if (toUpgrade != null && blueprint.name != null && toUpgrade.buildingType.Equals(blueprint.nameOfBuildingToUpgrade))
     {
         if (toUpgrade.indoors.farmers.Count > 0)
         {
             Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\Locations:BuildableLocation_CantUpgrade_SomeoneInside"), Color.Red, 3500f));
         }
         else
         {
             toUpgrade.indoors.map                = Game1.game1.xTileContent.Load <Map>("Maps\\" + blueprint.mapToWarpTo);
             toUpgrade.indoors.name               = blueprint.mapToWarpTo;
             toUpgrade.indoors.isStructure        = true;
             toUpgrade.nameOfIndoorsWithoutUnique = blueprint.mapToWarpTo;
             toUpgrade.buildingType               = blueprint.name;
             toUpgrade.texture = blueprint.texture;
             if (toUpgrade.indoors.GetType() == typeof(AnimalHouse))
             {
                 ((AnimalHouse)toUpgrade.indoors).resetPositionsOfAllAnimals();
             }
             Game1.playSound("axe");
             blueprint.consumeResources();
             toUpgrade.performActionOnUpgrade((GameLocation)this);
             toUpgrade.color = Color.White;
             Game1.exitActiveMenu();
             if (!Game1.IsMultiplayer)
             {
                 return;
             }
             MultiplayerUtility.broadcastBuildingChange((byte)2, new Vector2((float)toUpgrade.tileX, (float)toUpgrade.tileY), blueprint.name, Game1.currentLocation.name, Game1.player.uniqueMultiplayerID);
         }
     }
     else
     {
         if (toUpgrade == null)
         {
             return;
         }
         Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\Locations:BuildableLocation_CantUpgrade_IncorrectBuildingType"), Color.Red, 3500f));
     }
 }
示例#2
0
 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 index = 0; index < this.sideTabs.Count; ++index)
         {
             if (this.sideTabs[index].containsPoint(x, y) && this.currentTab != index)
             {
                 Game1.playSound("smallSelect");
                 if (index == 3)
                 {
                     this.placingStructure = true;
                     this.demolishing      = true;
                     this.parent.invisible = true;
                 }
                 else
                 {
                     this.sideTabs[this.currentTab].bounds.X -= CataloguePage.widthToMoveActiveTab;
                     this.currentTab = index;
                     this.sideTabs[index].bounds.X += CataloguePage.widthToMoveActiveTab;
                 }
             }
         }
         foreach (ClickableComponent key in this.blueprintButtons[this.currentTab].Keys)
         {
             if (key.containsPoint(x, y))
             {
                 if (this.blueprintButtons[this.currentTab][key].doesFarmerHaveEnoughResourcesToBuild())
                 {
                     this.structureForPlacement = this.blueprintButtons[this.currentTab][key];
                     this.placingStructure      = true;
                     this.parent.invisible      = true;
                     if (this.currentTab == 1)
                     {
                         this.upgrading = true;
                     }
                     Game1.playSound("smallSelect");
                     break;
                 }
                 Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10002"), Color.Red, 3500f));
                 break;
             }
         }
     }
     else if (this.demolishing)
     {
         if (!(Game1.currentLocation is Farm))
         {
             return;
         }
         if (Game1.IsClient)
         {
             Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10148"), Color.Red, 3500f));
         }
         else
         {
             Vector2  vector2    = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize));
             Building buildingAt = ((BuildableGameLocation)Game1.currentLocation).getBuildingAt(vector2);
             if (Game1.IsMultiplayer && buildingAt != null && buildingAt.indoors.farmers.Count > 0)
             {
                 Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10149"), Color.Red, 3500f));
             }
             else if (buildingAt != null && ((BuildableGameLocation)Game1.currentLocation).destroyStructure(buildingAt))
             {
                 int num = buildingAt.tileY + buildingAt.tilesHigh;
                 for (int index = 0; index < buildingAt.texture.Bounds.Height / Game1.tileSize; ++index)
                 {
                     GameLocation currentLocation             = Game1.currentLocation;
                     Texture2D    texture                     = buildingAt.texture;
                     Microsoft.Xna.Framework.Rectangle bounds = buildingAt.texture.Bounds;
                     int x1 = bounds.Center.X;
                     bounds = buildingAt.texture.Bounds;
                     int y1     = bounds.Center.Y;
                     int width  = Game1.tileSize / 16;
                     int height = Game1.tileSize / 16;
                     Microsoft.Xna.Framework.Rectangle sourcerectangle = new Microsoft.Xna.Framework.Rectangle(x1, y1, width, height);
                     int xTile           = buildingAt.tileX + Game1.random.Next(buildingAt.tilesWide);
                     int yTile           = buildingAt.tileY + buildingAt.tilesHigh - index;
                     int numberOfChunks  = Game1.random.Next(20, 45);
                     int groundLevelTile = num;
                     Game1.createRadialDebris(currentLocation, texture, sourcerectangle, xTile, yTile, numberOfChunks, groundLevelTile);
                 }
                 Game1.playSound("explosion");
                 Utility.spreadAnimalsAround(buildingAt, (Farm)Game1.currentLocation);
                 if (!Game1.IsServer)
                 {
                     return;
                 }
                 MultiplayerUtility.broadcastBuildingChange((byte)1, vector2, "", Game1.currentLocation.name, Game1.player.uniqueMultiplayerID);
             }
             else
             {
                 this.parent.invisible = false;
                 this.placingStructure = false;
                 this.demolishing      = false;
             }
         }
     }
     else if (this.upgrading && Game1.currentLocation is Farm)
     {
         (Game1.currentLocation as Farm).tryToUpgrade(((BuildableGameLocation)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))), this.structureForPlacement);
     }
     else if (!CataloguePage.canPlaceThisBuildingOnTheCurrentMap(this.structureForPlacement, Game1.currentLocation))
     {
         Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10152"), Color.Red, 3500f));
     }
     else if (!this.structureForPlacement.doesFarmerHaveEnoughResourcesToBuild())
     {
         Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10002"), Color.Red, 3500f));
     }
     else if (this.tryToBuild())
     {
         this.structureForPlacement.consumeResources();
         if (this.structureForPlacement.blueprintType.Equals("Animals"))
         {
             return;
         }
         Game1.playSound("axe");
     }
     else
     {
         if (Game1.IsClient)
         {
             return;
         }
         Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10016"), Color.Red, 3500f));
     }
 }
        public bool buildStructure(BluePrint structureForPlacement, Vector2 tileLocation, bool serverMessage, Farmer who, bool magicalConstruction = false)
        {
            if ((!serverMessage ? 0 : (Game1.IsClient ? 1 : 0)) == 0)
            {
                for (int index1 = 0; index1 < structureForPlacement.tilesHeight; ++index1)
                {
                    for (int index2 = 0; index2 < structureForPlacement.tilesWidth; ++index2)
                    {
                        if (!this.isBuildable(new Vector2(tileLocation.X + (float)index2, tileLocation.Y + (float)index1)))
                        {
                            return(false);
                        }
                        for (int index3 = 0; index3 < this.farmers.Count; ++index3)
                        {
                            if (this.farmers[index3].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(index2 * Game1.tileSize, index1 * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange((byte)0, tileLocation, structureForPlacement.name, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string name = structureForPlacement.name;
            // ISSUE: reference to a compiler-generated method
            uint     stringHash = \u003CPrivateImplementationDetails\u003E.ComputeStringHash(name);
            Building building;

            if (stringHash <= 1972213674U)
            {
                if (stringHash <= 846075854U)
                {
                    if ((int)stringHash != 45101750)
                    {
                        if ((int)stringHash != 846075854 || !(name == "Big Barn"))
                        {
                            goto label_39;
                        }
                        else
                        {
                            goto label_36;
                        }
                    }
                    else if (name == "Stable")
                    {
                        building = (Building) new Stable(structureForPlacement, tileLocation);
                        goto label_40;
                    }
                    else
                    {
                        goto label_39;
                    }
                }
                else if ((int)stringHash != 1684694008)
                {
                    if ((int)stringHash != 1972213674 || !(name == "Big Coop"))
                    {
                        goto label_39;
                    }
                }
                else if (!(name == "Coop"))
                {
                    goto label_39;
                }
            }
            else if (stringHash <= 2601855023U)
            {
                if ((int)stringHash != -1719902568)
                {
                    if ((int)stringHash != -1693112273 || !(name == "Deluxe Barn"))
                    {
                        goto label_39;
                    }
                    else
                    {
                        goto label_36;
                    }
                }
                else if (name == "Junimo Hut")
                {
                    building = (Building) new JunimoHut(structureForPlacement, tileLocation);
                    goto label_40;
                }
                else
                {
                    goto label_39;
                }
            }
            else if ((int)stringHash != -1111878468)
            {
                if ((int)stringHash != -560689829)
                {
                    if ((int)stringHash == -361784093 && name == "Mill")
                    {
                        building = (Building) new Mill(structureForPlacement, tileLocation);
                        goto label_40;
                    }
                    else
                    {
                        goto label_39;
                    }
                }
                else if (!(name == "Deluxe Coop"))
                {
                    goto label_39;
                }
            }
            else if (name == "Barn")
            {
                goto label_36;
            }
            else
            {
                goto label_39;
            }
            building = (Building) new Coop(structureForPlacement, tileLocation);
            goto label_40;
label_36:
            building = (Building) new Barn(structureForPlacement, tileLocation);
            goto label_40;
label_39:
            building = new Building(structureForPlacement, tileLocation);
label_40:
            building.owner = who.uniqueMultiplayerID;
            string message = building.isThereAnythingtoPreventConstruction((GameLocation)this);

            if (message != null)
            {
                Game1.addHUDMessage(new HUDMessage(message, Color.Red, 3500f));
                return(false);
            }
            this.buildings.Add(building);
            building.performActionOnConstruction((GameLocation)this);
            return(true);
        }
        public bool buildStructure(Building b, Vector2 tileLocation, bool serverMessage, Farmer who)
        {
            if ((!serverMessage ? 0 : (Game1.IsClient ? 1 : 0)) == 0)
            {
                for (int index1 = 0; index1 < b.tilesHigh; ++index1)
                {
                    for (int index2 = 0; index2 < b.tilesWide; ++index2)
                    {
                        if (!this.isBuildable(new Vector2(tileLocation.X + (float)index2, tileLocation.Y + (float)index1)))
                        {
                            return(false);
                        }
                        for (int index3 = 0; index3 < this.farmers.Count; ++index3)
                        {
                            if (this.farmers[index3].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(index2 * Game1.tileSize, index1 * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange((byte)0, tileLocation, b.buildingType, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string message = b.isThereAnythingtoPreventConstruction((GameLocation)this);

            if (message != null)
            {
                Game1.addHUDMessage(new HUDMessage(message, Color.Red, 3500f));
                return(false);
            }
            b.tileX = (int)tileLocation.X;
            b.tileY = (int)tileLocation.Y;
            if (b.indoors != null && b.indoors is AnimalHouse)
            {
                foreach (long index in (b.indoors as AnimalHouse).animalsThatLiveHere)
                {
                    FarmAnimal animal1 = Utility.getAnimal(index);
                    if (animal1 != null)
                    {
                        animal1.homeLocation = tileLocation;
                        animal1.home         = b;
                    }
                    else if (animal1 == null && (b.indoors as AnimalHouse).animals.ContainsKey(index))
                    {
                        FarmAnimal animal2 = (b.indoors as AnimalHouse).animals[index];
                        animal2.homeLocation = tileLocation;
                        animal2.home         = b;
                    }
                }
            }
            if (b.indoors != null)
            {
                foreach (Warp warp in b.indoors.warps)
                {
                    int num1 = b.humanDoor.X + b.tileX;
                    warp.TargetX = num1;
                    int num2 = b.humanDoor.Y + b.tileY + 1;
                    warp.TargetY = num2;
                }
            }
            this.buildings.Add(b);
            return(true);
        }
        // Token: 0x0600106B RID: 4203 RVA: 0x00152DC4 File Offset: 0x00150FC4
        public bool buildStructure(BluePrint structureForPlacement, Vector2 tileLocation, bool serverMessage, Farmer who, bool magicalConstruction = false)
        {
            if (!serverMessage || !Game1.IsClient)
            {
                for (int y = 0; y < structureForPlacement.tilesHeight; y++)
                {
                    for (int x = 0; x < structureForPlacement.tilesWidth; x++)
                    {
                        Vector2 currentGlobalTilePosition = new Vector2(tileLocation.X + (float)x, tileLocation.Y + (float)y);
                        if (!this.isBuildable(currentGlobalTilePosition))
                        {
                            return(false);
                        }
                        for (int i = 0; i < this.farmers.Count; i++)
                        {
                            if (this.farmers[i].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(x * Game1.tileSize, y * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange(0, tileLocation, structureForPlacement.name, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string   name = structureForPlacement.name;
            uint     num  = < PrivateImplementationDetails >.ComputeStringHash(name);
            Building b;

            if (num <= 1972213674u)
            {
                if (num <= 846075854u)
                {
                    if (num != 45101750u)
                    {
                        if (num != 846075854u)
                        {
                            goto IL_251;
                        }
                        if (!(name == "Big Barn"))
                        {
                            goto IL_251;
                        }
                        goto IL_233;
                    }
                    else
                    {
                        if (!(name == "Stable"))
                        {
                            goto IL_251;
                        }
                        b = new Stable(structureForPlacement, tileLocation);
                        goto IL_259;
                    }
                }
                else if (num != 1684694008u)
                {
                    if (num != 1972213674u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Big Coop"))
                    {
                        goto IL_251;
                    }
                }
                else if (!(name == "Coop"))
                {
                    goto IL_251;
                }
            }
            else if (num <= 2601855023u)
            {
                if (num != 2575064728u)
                {
                    if (num != 2601855023u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Deluxe Barn"))
                    {
                        goto IL_251;
                    }
                    goto IL_233;
                }
                else
                {
                    if (!(name == "Junimo Hut"))
                    {
                        goto IL_251;
                    }
                    b = new JunimoHut(structureForPlacement, tileLocation);
                    goto IL_259;
                }
            }
            else if (num != 3183088828u)
            {
                if (num != 3734277467u)
                {
                    if (num != 3933183203u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Mill"))
                    {
                        goto IL_251;
                    }
                    b = new Mill(structureForPlacement, tileLocation);
                    goto IL_259;
                }
                else if (!(name == "Deluxe Coop"))
                {
                    goto IL_251;
                }
            }
            else
            {
                if (!(name == "Barn"))
                {
                    goto IL_251;
                }
                goto IL_233;
            }
            b = new Coop(structureForPlacement, tileLocation);
            goto IL_259;
IL_233:
            b = new Barn(structureForPlacement, tileLocation);
            goto IL_259;
IL_251:
            b = new Building(structureForPlacement, tileLocation);
IL_259:
            b.owner = who.uniqueMultiplayerID;
            string finalCheckResult = b.isThereAnythingtoPreventConstruction(this);

            if (finalCheckResult != null)
            {
                Game1.addHUDMessage(new HUDMessage(finalCheckResult, Color.Red, 3500f));
                return(false);
            }
            this.buildings.Add(b);
            b.performActionOnConstruction(this);
            return(true);
        }
        // Token: 0x06001069 RID: 4201 RVA: 0x001529CC File Offset: 0x00150BCC
        public bool buildStructure(Building b, Vector2 tileLocation, bool serverMessage, Farmer who)
        {
            if (!serverMessage || !Game1.IsClient)
            {
                for (int y = 0; y < b.tilesHigh; y++)
                {
                    for (int x = 0; x < b.tilesWide; x++)
                    {
                        Vector2 currentGlobalTilePosition = new Vector2(tileLocation.X + (float)x, tileLocation.Y + (float)y);
                        if (!this.isBuildable(currentGlobalTilePosition))
                        {
                            return(false);
                        }
                        for (int i = 0; i < this.farmers.Count; i++)
                        {
                            if (this.farmers[i].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(x * Game1.tileSize, y * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange(0, tileLocation, b.buildingType, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string finalCheckResult = b.isThereAnythingtoPreventConstruction(this);

            if (finalCheckResult != null)
            {
                Game1.addHUDMessage(new HUDMessage(finalCheckResult, Color.Red, 3500f));
                return(false);
            }
            b.tileX = (int)tileLocation.X;
            b.tileY = (int)tileLocation.Y;
            if (b.indoors != null && b.indoors is AnimalHouse)
            {
                foreach (long a in (b.indoors as AnimalHouse).animalsThatLiveHere)
                {
                    FarmAnimal animal = Utility.getAnimal(a);
                    if (animal != null)
                    {
                        animal.homeLocation = tileLocation;
                        animal.home         = b;
                    }
                    else if (animal == null && (b.indoors as AnimalHouse).animals.ContainsKey(a))
                    {
                        animal = (b.indoors as AnimalHouse).animals[a];
                        animal.homeLocation = tileLocation;
                        animal.home         = b;
                    }
                }
            }
            if (b.indoors != null)
            {
                foreach (Warp expr_1F9 in b.indoors.warps)
                {
                    expr_1F9.TargetX = b.humanDoor.X + b.tileX;
                    expr_1F9.TargetY = b.humanDoor.Y + b.tileY + 1;
                }
            }
            this.buildings.Add(b);
            return(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));
         }
     }
 }
        public bool buildStructure(Building b, Vector2 tileLocation, bool serverMessage, Farmer who)
        {
            if (!serverMessage || !Game1.IsClient)
            {
                for (int i = 0; i < b.tilesHigh; i++)
                {
                    for (int j = 0; j < b.tilesWide; j++)
                    {
                        Vector2 tileLocation2 = new Vector2(tileLocation.X + (float)j, tileLocation.Y + (float)i);
                        if (!this.isBuildable(tileLocation2))
                        {
                            return(false);
                        }
                        for (int k = 0; k < this.farmers.Count; k++)
                        {
                            if (this.farmers[k].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(j * Game1.tileSize, i * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange(0, tileLocation, b.buildingType, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string text = b.isThereAnythingtoPreventConstruction(this);

            if (text != null)
            {
                Game1.addHUDMessage(new HUDMessage(text, Color.Red, 3500f));
                return(false);
            }
            b.tileX = (int)tileLocation.X;
            b.tileY = (int)tileLocation.Y;
            if (b.indoors != null && b.indoors is AnimalHouse)
            {
                foreach (long current in (b.indoors as AnimalHouse).animalsThatLiveHere)
                {
                    FarmAnimal farmAnimal = Utility.getAnimal(current);
                    if (farmAnimal != null)
                    {
                        farmAnimal.homeLocation = tileLocation;
                        farmAnimal.home         = b;
                    }
                    else if (farmAnimal == null && (b.indoors as AnimalHouse).animals.ContainsKey(current))
                    {
                        farmAnimal = (b.indoors as AnimalHouse).animals[current];
                        farmAnimal.homeLocation = tileLocation;
                        farmAnimal.home         = b;
                    }
                }
            }
            if (b.indoors != null)
            {
                foreach (Warp expr_1F9 in b.indoors.warps)
                {
                    expr_1F9.TargetX = b.humanDoor.X + b.tileX;
                    expr_1F9.TargetY = b.humanDoor.Y + b.tileY + 1;
                }
            }
            this.buildings.Add(b);
            return(true);
        }