public static bool FindNearbyRandomAirTile(int tile_x, int tile_y, int radius, out int to_x, out int to_y)
        {
            Tile tile       = null;
            int  wtf        = 0;
            bool is_blocked = false;

            to_x = 0;
            to_y = 0;

            if (tile_x + radius <= 0 || tile_x - radius >= Main.mapMaxX)
            {
                return(false);
            }
            if (tile_y + radius <= 0 || tile_y - radius >= Main.mapMaxY)
            {
                return(false);
            }

            do
            {
                do
                {
                    to_x = Main.rand.Next(-radius, radius) + tile_x;
                }while(to_x <= 0 || to_x >= Main.mapMaxX);
                do
                {
                    to_y = Main.rand.Next(-radius, radius) + tile_y;
                }while(to_y <= 0 || to_y >= Main.mapMaxY);

                //tile = Main.tile[to_x, to_y];
                tile = Framing.GetTileSafely(to_x, to_y);
                if (wtf++ > 100)
                {
                    return(false);
                }

                is_blocked = TileHelpers.IsSolid(tile, true, true) ||
                             TileWallHelpers.IsDungeon(tile) ||
                             TileHelpers.IsWire(tile) ||
                             tile.lava();
            } while(is_blocked && ((tile != null && tile.type != 0) || Lighting.Brightness(to_x, to_x) == 0));

            return(true);
        }
Exemple #2
0
 public static bool IsDungeon(Tile tile)
 {
     return(TileWallHelpers.IsDungeon(tile));
 }