public void FindWaterfalls(bool forced = false)
{
++this.findWaterfallCount;
if (this.findWaterfallCount < 30 && !forced)
return;
this.findWaterfallCount = 0;
this.waterfallDist = (int)(75.0 * (double)Main.gfxQuality) + 25;
this.qualityMax = (int)(175.0 * (double)Main.gfxQuality) + 25;
this.currentMax = 0;
int num1 = (int)((double)Main.screenPosition.X / 16.0 - 1.0);
int num2 = (int)(((double)Main.screenPosition.X + (double)Main.screenWidth) / 16.0) + 2;
int num3 = (int)((double)Main.screenPosition.Y / 16.0 - 1.0);
int num4 = (int)(((double)Main.screenPosition.Y + (double)Main.screenHeight) / 16.0) + 2;
int num5 = num1 - this.waterfallDist;
int num6 = num2 + this.waterfallDist;
int num7 = num3 - this.waterfallDist;
int num8 = num4 + 20;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesX)
num6 = Main.maxTilesX;
if (num7 < 0)
num7 = 0;
if (num8 > Main.maxTilesY)
num8 = Main.maxTilesY;
for (int index1 = num5; index1 < num6; ++index1)
{
for (int index2 = num7; index2 < num8; ++index2)
{
Tile tile = Main.tile[index1, index2];
if (tile == null)
{
tile = new Tile();
Main.tile[index1, index2] = tile;
}
if (tile.active())
{
if (tile.halfBrick())
{
Tile testTile1 = Main.tile[index1, index2 - 1];
if (testTile1 == null)
{
testTile1 = new Tile();
Main.tile[index1, index2 - 1] = testTile1;
}
if ((int)testTile1.liquid < 16 || WorldGen.SolidTile(testTile1))
{
Tile testTile2 = Main.tile[index1 + 1, index2];
if (testTile2 == null)
{
testTile2 = new Tile();
Main.tile[index1 - 1, index2] = testTile2;
}
Tile testTile3 = Main.tile[index1 - 1, index2];
if (testTile3 == null)
{
testTile3 = new Tile();
Main.tile[index1 + 1, index2] = testTile3;
}
if (((int)testTile2.liquid > 160 || (int)testTile3.liquid > 160) && ((int)testTile2.liquid == 0 && !WorldGen.SolidTile(testTile2) && (int)testTile2.slope() == 0 || (int)testTile3.liquid == 0 && !WorldGen.SolidTile(testTile3) && (int)testTile3.slope() == 0) && this.currentMax < this.qualityMax)
{
this.waterfalls[this.currentMax].type = 0;
this.waterfalls[this.currentMax].type = testTile1.lava() || testTile3.lava() || testTile2.lava() ? 1 : (testTile1.honey() || testTile3.honey() || testTile2.honey() ? 14 : 0);
this.waterfalls[this.currentMax].x = index1;
this.waterfalls[this.currentMax].y = index2;
++this.currentMax;
}
}
}
if ((int)tile.type == 196)
{
Tile testTile = Main.tile[index1, index2 + 1];
if (testTile == null)
{
testTile = new Tile();
Main.tile[index1, index2 + 1] = testTile;
}
if (!WorldGen.SolidTile(testTile) && (int)testTile.slope() == 0 && this.currentMax < this.qualityMax)
{
this.waterfalls[this.currentMax].type = 11;
this.waterfalls[this.currentMax].x = index1;
this.waterfalls[this.currentMax].y = index2 + 1;
++this.currentMax;
}
}
}
}
}
}