public void UpdateRenderRegion(Rectangle area)
{
Task.Factory.StartNew(
() =>
{
var bounded = new Rectangle(Math.Max(area.Left, 0),
Math.Max(area.Top, 0),
Math.Min(area.Width, CurrentWorld.TilesWide - Math.Max(area.Left, 0)),
Math.Min(area.Height, CurrentWorld.TilesHigh - Math.Max(area.Top, 0)));
if (CurrentWorld != null)
{
for (int y = bounded.Top; y < bounded.Bottom; y++)
{
Color curBgColor = GetBackgroundColor(y);
OnProgressChanged(this, new ProgressChangedEventArgs(y.ProgressPercentage(CurrentWorld.TilesHigh), "Calculating Colors..."));
for (int x = bounded.Left; x < bounded.Right; x++)
{
PixelMap.SetPixelColor(x, y, Render.PixelMap.GetTileColor(CurrentWorld.Tiles[x, y], curBgColor, _showWalls, _showTiles, _showLiquid, _showRedWires, _showBlueWires, _showGreenWires, _showYellowWires));
}
}
}
OnProgressChanged(this, new ProgressChangedEventArgs(100, "Render Complete"));
});
}