/// <summary>
/// On draw on backbuffer
/// </summary>
protected override void OnDrawOnBackbuffer(ref System.Drawing.Graphics gfx)
{
// If layer is empty or background is empty, return
if (_layer == null || App.Room.Backgrounds[0] == null || App.Room.Backgrounds[0].Image == null)
{
return;
}
// Draw layer
gfx.DrawImageUnscaled(_layer.GetLayerImage(App.Room.Backgrounds[0], App.Room.Backgrounds[0].GetCondensedTileset(), .5f), Point.Empty);
// Convert tile ids to optimized binary tiles and reset the tile count
ExportTile[] tiles = _layer.GetExportTiles(App.Room.Backgrounds[0], false, -1);
_tileCount = 0;
// If there are rectangles to draw, draw them
if (tiles != null || tiles.Length > 0)
{
// Create a list of rectangles
List <Rectangle> rects = new List <Rectangle>();
// Iterate through tiles
foreach (ExportTile tile in tiles)
{
rects.Add(tile.Rect);
}
// Draw rectangles and set tile count
gfx.DrawRectangles(Pens.Red, rects.ToArray());
_tileCount = rects.Count;
}
}