public static bool CanReallyBePlacedHere( this Wallpaper wallpaper, DecoratableLocation location, Vector2 tileLocation) { int x = (int)tileLocation.X; int y = (int)tileLocation.Y; if (wallpaper.isFloor.Value) { List <Rectangle> floors = location.getFloors(); for (int i = 0; i < floors.Count; i++) { if (floors[i].Contains(x, y)) { return(true); } } } else { List <Rectangle> walls = location.getWalls(); for (int j = 0; j < walls.Count; j++) { if (walls[j].Contains(x, y)) { return(true); } } } return(false); }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (who == null) { who = Game1.player; } if (who.currentLocation is DecoratableLocation) { Point value = new Point(x / Game1.tileSize, y / Game1.tileSize); DecoratableLocation decoratableLocation = who.currentLocation as DecoratableLocation; if (this.isFloor) { List <Rectangle> floors; if (decoratableLocation is FarmHouse) { floors = FarmHouse.getFloors((decoratableLocation as FarmHouse).upgradeLevel); } else { floors = DecoratableLocation.getFloors(); } for (int i = 0; i < floors.Count; i++) { if (floors[i].Contains(value)) { decoratableLocation.setFloor(this.parentSheetIndex, i, true); Game1.playSound("coin"); return(true); } } } else { List <Rectangle> walls; if (decoratableLocation is FarmHouse) { walls = FarmHouse.getWalls((decoratableLocation as FarmHouse).upgradeLevel); } else { walls = DecoratableLocation.getWalls(); } for (int j = 0; j < walls.Count; j++) { if (walls[j].Contains(value)) { decoratableLocation.setWallpaper(this.parentSheetIndex, j, true); Game1.playSound("coin"); return(true); } } } } return(false); }
public static void setWallsTilesheet(int whichRoom, int which, TileSheet tilesheet, DecoratableLocation dec, AnimatedTile animations = null) { List <Rectangle> walls = dec.getWalls(); if (whichRoom == -1) { foreach (Rectangle rectangle in walls) { for (int x = rectangle.X; x < rectangle.Right; ++x) { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y, "Back", 0, 0, animations); setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 1, "Back", 0, 0, animations); if (rectangle.Height >= 3) { if (dec.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Equals(dec.map.TileSheets[2]) || dec.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Id.StartsWith("zCWF")) { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 2, "Buildings", 0, 0, animations); } else { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 2, "Back", 0, 0, animations); } } } } } else { if (walls.Count <= whichRoom) { return; } Rectangle rectangle = walls[whichRoom]; for (int x = rectangle.X; x < rectangle.Right; ++x) { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y, "Back", 0, 0, animations); setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 1, "Back", 0, 0, animations); if (rectangle.Height >= 3) { if (dec.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Equals(dec.map.TileSheets[2]) || dec.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Id.StartsWith("zCWF")) { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 2, "Buildings", 0, 0, animations); } else { setMapTilesheet(dec.map, tilesheet, x, rectangle.Y + 2, "Back", 0, 0, animations); } } } } PyTK.PyUtils.setDelayedAction(500, () => dec.updateMap()); }
internal static bool Prefix(GameLocation location, int x, int y, Farmer who, ref bool __result, Wallpaper __instance) { if (who == null) { who = Game1.player; } if (who.currentLocation is DecoratableLocation) { return(true); } DecoratableLocation host = OtherLocations.FakeDecor.FakeDecorHandler.getHost(who.currentLocation); if (host == null) { return(true); } //We have our host now, so we will instead be using it on that host. Point point = new Point(x / 64, y / 64); if ((bool)((NetFieldBase <bool, NetBool>)__instance.isFloor)) { List <Rectangle> floors = host.getFloors(); for (int whichRoom = 0; whichRoom < floors.Count; ++whichRoom) { if (floors[whichRoom].Contains(point)) { host.setFloor((int)((NetFieldBase <int, NetInt>)__instance.parentSheetIndex), whichRoom, true); host.setFloors(); location.playSound("coin", NetAudio.SoundContext.Default); __result = true; return(false); } } } else { List <Rectangle> walls = host.getWalls(); for (int whichRoom = 0; whichRoom < walls.Count; ++whichRoom) { if (walls[whichRoom].Contains(point)) { host.setWallpaper((int)((NetFieldBase <int, NetInt>)__instance.parentSheetIndex), whichRoom, true); host.setWallpapers(); location.playSound("coin", NetAudio.SoundContext.Default); __result = true; return(false); } } } return(true); }
public static void DoSetVisibleWallpaper(int whichRoom, int which, DecoratableLocation location) { GameLocation client = OtherLocations.FakeDecor.FakeDecorHandler.getClient(location); if (client != null) { client.updateMap(); Logger.Log("Found client map to apply wallpaper to: " + client.Name); } else { Logger.Log("No client for " + location.Name); } location.updateMap(); //Gather a list of all the walls in this map List <Rectangle> walls = location.getWalls(); int index = which % 16 + which / 16 * 48; //Report the index of the wallpaper being pasted. Logger.Log("Chosen index " + index + "."); //Get the map for this DecoratableLocation Map map = location.map; Logger.Log("Applying wall rectangle..."); //It's possible that the number of saved wallpapers is greater than the number of walls, so we'll just skip any after we reach the end. if (walls.Count <= whichRoom) { Logger.Log("Wall rectangle exceeded walls count! You can ignore this if the farmhouse just upgraded, or you installed a new farmhouse mod.", StardewModdingAPI.LogLevel.Warn); return; } //Find the region to paste in Rectangle rectangle = walls[whichRoom]; for (int x = rectangle.X; x < rectangle.Right; x++) { for (int y = rectangle.Y; y < rectangle.Bottom; y++) { setWallMapTileIndexForAnyLayer(map, x, y, index); if (client != null) { setWallMapTileIndexForAnyLayer(client.map, x, y, index); } } } return; }
public Shed(Map m, string name) : base(m, name) { List<Rectangle> list = DecoratableLocation.getWalls(); while (this.wallPaper.Count < list.Count) { this.wallPaper.Add(0); } list = DecoratableLocation.getFloors(); while (this.floor.Count < list.Count) { this.floor.Add(0); } }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (who == null) { who = Game1.player; } if (who.currentLocation is DecoratableLocation) { Point tile = new Point(x / 64, y / 64); DecoratableLocation farmHouse = who.currentLocation as DecoratableLocation; if ((bool)isFloor) { List <Rectangle> floors = farmHouse.getFloors(); for (int j = 0; j < floors.Count; j++) { if (floors[j].Contains(tile)) { farmHouse.setFloor(parentSheetIndex, j, persist: true); location.playSound("coin"); return(true); } } } else { List <Rectangle> walls = farmHouse.getWalls(); for (int i = 0; i < walls.Count; i++) { Rectangle wall = walls[i]; if (wall.Height == 2) { wall.Height = 3; } if (wall.Contains(tile)) { farmHouse.setWallpaper(parentSheetIndex, i, persist: true); location.playSound("coin"); return(true); } } } } return(false); }
public int GetModifiedWallTilePosition(GameLocation l, int tile_x, int tile_y) { if (isGroundFurniture()) { return(tile_y); } DecoratableLocation location = l as DecoratableLocation; if (location == null) { return(tile_y); } foreach (Rectangle wall in location.getWalls()) { if (wall.Contains(new Point(tile_x, tile_y))) { return(wall.Top); } } return(tile_y); }
public static bool doSetVisibleWallpaper_Prefix(DecoratableLocation __instance, int whichRoom, int which) { if (!ModEntry.config.EnableMod || !ModEntry.floorsWallsDataDict.ContainsKey(__instance.Name)) { return(true); } int idx = -1; for (int i = 0; i < __instance.map.TileSheets.Count; i++) { if (__instance.map.TileSheets[i].Id == "walls_and_floors") { idx = i; break; } } if (idx == -1) { return(true); } __instance.updateMap(); List <Rectangle> rooms = __instance.getWalls(); int tileSheetIndex = which % 16 + which / 16 * 48; if (whichRoom == -1) { using (List <Rectangle> .Enumerator enumerator = rooms.GetEnumerator()) { while (enumerator.MoveNext()) { Rectangle r = enumerator.Current; for (int x = r.X; x < r.Right; x++) { if (IsFloorableOrWallpaperableTile(x, r.Y, "Back", __instance)) { SetWallpaperTile(x, r.Y, tileSheetIndex, "Back", __instance, idx); } if (IsFloorableOrWallpaperableTile(x, r.Y + 1, "Back", __instance)) { SetWallpaperTile(x, r.Y + 1, tileSheetIndex + 16, "Back", __instance, idx); } if (r.Height >= 3) { if (IsFloorableOrWallpaperableTile(x, r.Y + 2, "Buildings", __instance)) { SetWallpaperTile(x, r.Y + 2, tileSheetIndex + 32, "Buildings", __instance, idx); } if (IsFloorableOrWallpaperableTile(x, r.Y + 2, "Back", __instance)) { SetWallpaperTile(x, r.Y + 2, tileSheetIndex + 32, "Back", __instance, idx); } } } } return(false); } } if (rooms.Count > whichRoom) { Rectangle r2 = rooms[whichRoom]; for (int x2 = r2.X; x2 < r2.Right; x2++) { if (IsFloorableOrWallpaperableTile(x2, r2.Y, "Back", __instance)) { SetWallpaperTile(x2, r2.Y, tileSheetIndex, "Back", __instance, idx); } if (IsFloorableOrWallpaperableTile(x2, r2.Y + 1, "Back", __instance)) { SetWallpaperTile(x2, r2.Y + 1, tileSheetIndex + 16, "Back", __instance, idx); } if (r2.Height >= 3) { if (IsFloorableOrWallpaperableTile(x2, r2.Y + 2, "Buildings", __instance)) { SetWallpaperTile(x2, r2.Y + 2, tileSheetIndex + 32, "Buildings", __instance, idx); } else if (IsFloorableOrWallpaperableTile(x2, r2.Y + 2, "Back", __instance)) { SetWallpaperTile(x2, r2.Y + 2, tileSheetIndex + 32, "Back", __instance, idx); } } } } return(false); }
public static void updateAsHost(DecoratableLocation location) { foreach (Rectangle wall in location.getWalls()) { } }
internal static bool Prefix(int whichRoom, int which, DecoratableLocation __instance) { if (!(__instance is FarmHouse) || __instance is Cabin) { return(true); } //Logger.Log("Setting visible walls..."); //Logger.Log("Updating map..."); __instance.updateMap(); //Logger.Log("Map updated. Getting walls..."); List <Microsoft.Xna.Framework.Rectangle> walls = __instance.getWalls(); int index = which % 16 + which / 16 * 48; Logger.Log("Chosen index " + index + "."); Map map = __instance.map; if (whichRoom == -1) { Logger.Log("Applying to all wall rectangles..."); foreach (Microsoft.Xna.Framework.Rectangle rectangle in walls) { for (int x = rectangle.X; x < rectangle.Right; x++) { for (int y = rectangle.Y; y < rectangle.Bottom; y++) { //Logger.Log("Working on tile (" + x + ", " + rectangle.Y + ")..."); setMapTileIndexForAnyLayer(map, __instance, x, y, index); } } //Logger.Log("Applying wall rectangle (" + rectangle.X + ", " + rectangle.Y + ", " + rectangle.Width + ", " + rectangle.Height + ")..."); //for (int x = rectangle.X; x < rectangle.Right; ++x) //{ // //Logger.Log("Setting tile (" + x + ", " + rectangle.Y + ") on the Back layer..."); // setMapTileIndexIfOnTileSheet(map, __instance, x, rectangle.Y, index, "Back", 0, 2); // //Logger.Log("Setting tile (" + x + ", " + (rectangle.Y + 1) + ") on the Back layer..."); // setMapTileIndexIfOnTileSheet(map, __instance, x, rectangle.Y + 1, index + 16, "Back", 0, 2); // if (rectangle.Height >= 3) // { // //Logger.Log("Rectangle was tall..."); // if (__instance.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Equals((object)__instance.map.TileSheets[2])) // { // //Logger.Log("Buildings tile (" + x + ", " + (rectangle.Y + 2) + ") was from the walls and floors sheet. Setting it to wallpapered state..."); // __instance.setMapTileIndex(x, rectangle.Y + 2, index + 32, "Buildings", 0); // } // else // { // //Logger.Log("Setting tile (" + x + ", " + (rectangle.Y + 2) + ") to index " + index + 32 + "..."); // __instance.setMapTileIndex(x, rectangle.Y + 2, index + 32, "Back", 0); // } // } //} } } else { Logger.Log("Applying wall rectangle..."); if (walls.Count <= whichRoom) { Logger.Log("Wall rectangle exceeded walls count!", StardewModdingAPI.LogLevel.Warn); return(false); } //List<Rectangle> connectedWalls = new List<Rectangle>(); //connectedWalls.Add(walls[whichRoom]); //if (FarmHouseStates.wallDictionary.ContainsKey(walls[whichRoom])) //{ // string roomString = FarmHouseStates.wallDictionary[walls[whichRoom]]; // //Logger.Log("Looking for all walls for room " + roomString + "..."); // foreach (KeyValuePair<Rectangle, string> wallDefinition in FarmHouseStates.wallDictionary) // { // if (wallDefinition.Value.Equals(roomString)) // connectedWalls.Add(wallDefinition.Key); // } // //Logger.Log("Found " + connectedWalls.Count + " walls for " + roomString); //} //foreach (Rectangle rectangle in connectedWalls) //{ //Logger.Log("Applying wall rectangle..."); Rectangle rectangle = walls[whichRoom]; for (int x = rectangle.X; x < rectangle.Right; x++) { for (int y = rectangle.Y; y < rectangle.Bottom; y++) { //Logger.Log("Working on tile (" + x + ", " + rectangle.Y + ")..."); setMapTileIndexForAnyLayer(map, __instance, x, y, index); } } //Logger.Log("Applying wall rectangle (" + rectangle.X + ", " + rectangle.Y + ", " + rectangle.Width + ", " + rectangle.Height + ")..."); //for (int x = rectangle.X; x < rectangle.Right; ++x) //{ // //Logger.Log("Setting tile (" + x + ", " + rectangle.Y + ") on the Back layer..."); // setMapTileIndexIfOnTileSheet(map, __instance, x, rectangle.Y, index, "Back", 0, 2); // //Logger.Log("Setting tile (" + x + ", " + (rectangle.Y + 1) + ") on the Back layer..."); // setMapTileIndexIfOnTileSheet(map, __instance, x, rectangle.Y + 1, index + 16, "Back", 0, 2); // if (rectangle.Height >= 3) // { // //Logger.Log("Rectangle was tall..."); // if (__instance.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2] == null) // continue; // if (__instance.map.GetLayer("Buildings").Tiles[x, rectangle.Y + 2].TileSheet.Equals((object)__instance.map.TileSheets[2])) // { // //Logger.Log("Buildings tile (" + x + ", " + (rectangle.Y + 2) + ") was from the walls and floors sheet. Setting it to wallpapered state..."); // __instance.setMapTileIndex(x, rectangle.Y + 2, index + 32, "Buildings", 0); // } // else // { // //Logger.Log("Setting tile (" + x + ", " + (rectangle.Y + 2) + ") to index " + index + 32 + "..."); // __instance.setMapTileIndex(x, rectangle.Y + 2, index + 32, "Back", 0); // } // } //} } return(false); }
internal static bool Prefix(int which, int whichRoom, bool persist, DecoratableLocation __instance) { if (!(__instance is FarmHouse) || __instance is Cabin) { return(true); } List <Microsoft.Xna.Framework.Rectangle> walls = __instance.getWalls(); if (!persist) { return(true); } Logger.Log("Checking wallpaper indexes before SetCountAtLeast..."); for (int wallIndex = 0; wallIndex < __instance.wallPaper.Count; wallIndex++) { Logger.Log("Wall " + wallIndex + " has a wallpaper index of " + __instance.wallPaper[wallIndex] + "."); } if (__instance.wallPaper.Count < walls.Count) { FarmHouseStates.setMissingWallpaperToDefault(__instance as FarmHouse); } //__instance.wallPaper.SetCountAtLeast(walls.Count); Logger.Log("Checking wallpaper indexes after SetCountAtLeast..."); for (int wallIndex = 0; wallIndex < __instance.wallPaper.Count; wallIndex++) { Logger.Log("Wall " + wallIndex + " has a wallpaper index of " + __instance.wallPaper[wallIndex] + "."); } if (whichRoom == -1) { Logger.Log("Whichroom was -1, applying to all walls..."); for (int index = 0; index < __instance.wallPaper.Count; ++index) { __instance.wallPaper[index] = which; } } else { Logger.Log("Setting wallpaper to " + which + "..."); if (whichRoom > __instance.wallPaper.Count - 1 || whichRoom >= walls.Count) { return(false); } if (FarmHouseStates.wallDictionary.ContainsKey(walls[whichRoom])) { string roomLabel = FarmHouseStates.wallDictionary[walls[whichRoom]]; Logger.Log("Finding all walls for room '" + roomLabel + "'..."); foreach (KeyValuePair <Rectangle, string> wallData in FarmHouseStates.wallDictionary) { if (walls.Contains(wallData.Key) && wallData.Value == roomLabel) { Logger.Log(walls.IndexOf(wallData.Key) + " was a part of " + roomLabel); __instance.wallPaper[walls.IndexOf(wallData.Key)] = which; } } } else { __instance.wallPaper[whichRoom] = which; } } return(false); }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (location is DecoratableLocation) { Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); List <Rectangle> walls; if (location is FarmHouse) { walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); } else { walls = DecoratableLocation.getWalls(); } this.tileLocation = new Vector2((float)point.X, (float)point.Y); bool flag = false; if (this.furniture_type == 6 || this.furniture_type == 13 || this.parentSheetIndex == 1293) { int num = (this.parentSheetIndex == 1293) ? 3 : 0; bool flag2 = false; foreach (Rectangle current in walls) { if ((this.furniture_type == 6 || this.furniture_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) { flag2 = true; break; } } if (!flag2) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12629", new object[0])); return(false); } flag = true; } for (int i = point.X; i < point.X + this.getTilesWide(); i++) { for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) { if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12632", new object[0])); return(false); } if (!flag && Utility.pointInRectangles(walls, i, j)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12633", new object[0])); return(false); } if (location.getTileIndexAt(i, j, "Buildings") != -1) { return(false); } } } this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); foreach (Furniture current2 in (location as DecoratableLocation).furniture) { if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) { current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); bool result = true; return(result); } } using (List <Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator()) { while (enumerator3.MoveNext()) { if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12636", new object[0])); bool result = false; return(result); } } } this.updateDrawPosition(); return(base.placementAction(location, x, y, who)); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12628", new object[0])); return(false); }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (location is DecoratableLocation) { Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); List <Rectangle> rectangles = !(location is FarmHouse) ? DecoratableLocation.getWalls() : FarmHouse.getWalls((location as FarmHouse).upgradeLevel); this.tileLocation = new Vector2((float)point.X, (float)point.Y); bool flag1 = false; if (this.furniture_type == 6 || this.furniture_type == 13 || this.parentSheetIndex == 1293) { int num = this.parentSheetIndex == 1293 ? 3 : 0; bool flag2 = false; foreach (Rectangle rectangle in rectangles) { if ((this.furniture_type == 6 || this.furniture_type == 13 || num != 0) && (rectangle.Y + num == point.Y && rectangle.Contains(point.X, point.Y - num))) { flag2 = true; break; } } if (!flag2) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12629")); return(false); } flag1 = true; } for (int x1 = point.X; x1 < point.X + this.getTilesWide(); ++x1) { for (int y1 = point.Y; y1 < point.Y + this.getTilesHigh(); ++y1) { if (location.doesTileHaveProperty(x1, y1, "NoFurniture", "Back") != null) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12632")); return(false); } if (!flag1 && Utility.pointInRectangles(rectangles, x1, y1)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12633")); return(false); } if (location.getTileIndexAt(x1, y1, "Buildings") != -1) { return(false); } } } this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); foreach (Furniture furniture in (location as DecoratableLocation).furniture) { if (furniture.furniture_type == 11 && furniture.heldObject == null && furniture.getBoundingBox(furniture.tileLocation).Intersects(this.boundingBox)) { furniture.performObjectDropInAction((StardewValley.Object) this, false, who == null ? Game1.player : who); return(true); } } foreach (Character farmer in location.getFarmers()) { if (farmer.GetBoundingBox().Intersects(this.boundingBox)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12636")); return(false); } } this.updateDrawPosition(); return(base.placementAction(location, x, y, who)); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Furniture.cs.12628")); return(false); }
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (who == null) { who = Game1.player; } if (who.currentLocation is DecoratableLocation) { Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); DecoratableLocation currentLocation = who.currentLocation as DecoratableLocation; if (this.isFloor) { List <Rectangle> rectangleList = !(currentLocation is FarmHouse) ? DecoratableLocation.getFloors() : FarmHouse.getFloors((currentLocation as FarmHouse).upgradeLevel); for (int whichRoom = 0; whichRoom < rectangleList.Count; ++whichRoom) { if (rectangleList[whichRoom].Contains(point)) { currentLocation.setFloor(this.parentSheetIndex, whichRoom, true); Game1.playSound("coin"); return(true); } } } else { List <Rectangle> rectangleList = !(currentLocation is FarmHouse) ? DecoratableLocation.getWalls() : FarmHouse.getWalls((currentLocation as FarmHouse).upgradeLevel); for (int whichRoom = 0; whichRoom < rectangleList.Count; ++whichRoom) { if (rectangleList[whichRoom].Contains(point)) { currentLocation.setWallpaper(this.parentSheetIndex, whichRoom, true); Game1.playSound("coin"); return(true); } } } } return(false); }
// Token: 0x06000AD0 RID: 2768 RVA: 0x000E0410 File Offset: 0x000DE610 public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (location is DecoratableLocation) { Point anchor = new Point(x / Game1.tileSize, y / Game1.tileSize); List <Rectangle> walls; if (location is FarmHouse) { walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); } else { walls = DecoratableLocation.getWalls(); } this.tileLocation = new Vector2((float)anchor.X, (float)anchor.Y); bool paintingAtRightPlace = false; if (this.furniture_type == 6 || this.furniture_type == 13 || this.parentSheetIndex == 1293) { int offset = (this.parentSheetIndex == 1293) ? 3 : 0; bool foundWall = false; foreach (Rectangle w in walls) { if ((this.furniture_type == 6 || this.furniture_type == 13 || offset != 0) && w.Y + offset == anchor.Y && w.Contains(anchor.X, anchor.Y - offset)) { foundWall = true; break; } } if (!foundWall) { Game1.showRedMessage("Must be placed on wall"); return(false); } paintingAtRightPlace = true; } for (int furnitureX = anchor.X; furnitureX < anchor.X + this.getTilesWide(); furnitureX++) { for (int furnitureY = anchor.Y; furnitureY < anchor.Y + this.getTilesHigh(); furnitureY++) { if (location.doesTileHaveProperty(furnitureX, furnitureY, "NoFurniture", "Back") != null) { Game1.showRedMessage("Furniture can't be placed here"); return(false); } if (!paintingAtRightPlace && Utility.pointInRectangles(walls, furnitureX, furnitureY)) { Game1.showRedMessage("Can't place on wall"); return(false); } if (location.getTileIndexAt(furnitureX, furnitureY, "Buildings") != -1) { return(false); } } } this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); foreach (Furniture f in (location as DecoratableLocation).furniture) { if (f.furniture_type == 11 && f.heldObject == null && f.getBoundingBox(f.tileLocation).Intersects(this.boundingBox)) { f.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); bool result = true; return(result); } } using (List <Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator()) { while (enumerator3.MoveNext()) { if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox)) { Game1.showRedMessage("Can't place on top of a person."); bool result = false; return(result); } } } this.updateDrawPosition(); return(base.placementAction(location, x, y, who)); } Game1.showRedMessage("Can only be placed in House"); return(false); }