Beispiel #1
0
    /// <summary>
    /// Sets the pixels corresponding to the tile in its current surroundings. None of the parameters can be null apart from 'tile'.
    /// Caches the operation so future calls with the same BaseTile will be very quick.
    /// </summary>
    public void SetTile(BaseTile tile, TileLayer layer, int globalX, int globalY, int x, int y)
    {
        if (tile == null)
        {
            SetTile(GetTransparentTile(), x, y);
        }
        else
        {
            int index = tile.GetAutoIndex(layer, globalX, globalY);

            if (tile.RenderData.IsCached(index))
            {
                // Already cached, just paint.
                SetTile(tile.RenderData.GetCachedPixels(index), x, y);
            }
            else
            {
                // Need to grab and flip the pixels, the store them again.
                tile.RenderData.SetCachedPixels(index, GetColours(tile.RenderData.GetSprite(index), true, true));

                // Now paint the tile.
                SetTile(tile.RenderData.GetCachedPixels(index), x, y);
            }
        }
    }