//// /// <summary> /// Indicates if the given position is at a beach/ocean area. /// </summary> /// <param name="worldPos"></param> /// <returns></returns> public static bool IsBeach(Vector2 worldPos) { if (!WorldLocationLibraries.IsOverworld(worldPos)) { return(false); } return(IsBeachRegion(worldPos)); }
//////////////// /// <summary> /// Gets the identifiable region of a given point in the world. /// </summary> /// <param name="worldPos"></param> /// <returns></returns> public static WorldRegionFlags GetRegion(Vector2 worldPos) { WorldRegionFlags where = 0; if (WorldLocationLibraries.IsSky(worldPos)) { where |= WorldRegionFlags.Sky; } else if (WorldLocationLibraries.IsWithinUnderworld(worldPos)) { where |= WorldRegionFlags.Hell; } else if (WorldLocationLibraries.IsAboveWorldSurface(worldPos)) { where |= WorldRegionFlags.Overworld; if (WorldLocationLibraries.BeachEastTileX < (worldPos.X / 16)) { where |= WorldRegionFlags.OceanEast; } else if (WorldLocationLibraries.BeachWestTileX > (worldPos.X / 16)) { where |= WorldRegionFlags.OceanWest; } } else { if (WorldLocationLibraries.IsDirtLayer(worldPos)) { where |= WorldRegionFlags.CaveDirt; } else { if (WorldLocationLibraries.IsPreRockLayer(worldPos)) { where |= WorldRegionFlags.CavePreRock; } if (WorldLocationLibraries.IsRockLayer(worldPos)) { where |= WorldRegionFlags.CaveRock; if (WorldLocationLibraries.IsLavaLayer(worldPos)) { where |= WorldRegionFlags.CaveLava; } } } } return(where); }
//// /// <summary> /// Gets the first (sand) tile of the eastern beach. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <returns></returns> public static bool GetEastBeach(out int tileX, out int tileY) { int reach = 40; //340; for (int x = reach; x < Main.dungeonX; x++) { if (WorldLocationLibraries.CheckColumnForBeach(x, out tileX, out tileY)) { return(true); } } tileX = tileY = 0; return(false); }
/// <summary> /// Gets the first (sand) tile of the western beach. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <returns></returns> public static bool GetWestBeach(out int tileX, out int tileY) { int reach = 40; //340; int max = (Main.maxTilesX - reach) - Main.dungeonX; for (int x = Main.maxTilesX - reach; x > Main.dungeonX; x--) { if (WorldLocationLibraries.CheckColumnForBeach(x, out tileX, out tileY)) { return(true); } } tileX = tileY = 0; return(false); }
//////////////// /// <summary> /// Gets rectangles containing all giant trees in the world. /// </summary> /// <returns></returns> public static IList<Rectangle> GetGiantTrees() { IDictionary<int, Rectangle> trees = new Dictionary<int, Rectangle>(); int minX = 300; int maxX = Main.maxTilesX - 300; int minY = 80; int maxY = WorldLocationLibraries.SurfaceLayerBottomTileY - 50; int midX1 = ( Main.maxTilesX / 2 ) - 100; int midX2 = ( Main.maxTilesX / 2 ) + 100; Tile tile; for( int x=minX; x<maxX; x++ ) { if( x > midX1 && x < midX2 ) { x = midX2; } if( trees.ContainsKey( x ) ) { x += trees[x].Width; } for( int y=minY; y<maxY; y++ ) { tile = Main.tile[x, y]; if( tile == null || !tile.active() || (tile.type != TileID.LivingWood && tile.type != TileID.LeafBlock) ) { continue; } Rectangle tree = WorldLocationLibraries.GetGiantTreeAt( x, y ); trees[ tree.X ] = tree; x = tree.X + tree.Width + 1; break; } } return trees.Values.ToList(); }