From 0c63823eebe628256c7a7ad3c697d6bdd615e488 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Tue, 22 Jan 2019 15:25:33 +0100 Subject: [PATCH] tile rendered callback --- tilerenderer/renderer.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tilerenderer/renderer.go b/tilerenderer/renderer.go index 6e31630..2900384 100644 --- a/tilerenderer/renderer.go +++ b/tilerenderer/renderer.go @@ -22,6 +22,11 @@ type TileRenderer struct { layers []layer.Layer tdb mapobjectdb.DBAccessor dba db.DBAccessor + listeners []TileListener +} + +type TileListener interface { + OnRenderedTile(tc *coords.TileCoords) } func NewTileRenderer(mapblockrenderer *mapblockrenderer.MapBlockRenderer, @@ -41,6 +46,10 @@ const ( IMG_SIZE = 256 ) +func (tr *TileRenderer) AddListener(l TileListener) { + tr.listeners = append(tr.listeners, l) +} + func (tr *TileRenderer) Render(tc *coords.TileCoords, recursionDepth int) ([]byte, error) { //Check cache @@ -243,5 +252,11 @@ func (tr *TileRenderer) RenderImage(tc *coords.TileCoords, recursionDepth int) ( } log.WithFields(fields).Debug("Cross stitch") + + for _, listener := range tr.listeners { + listener.OnRenderedTile(tc) + } + + return img, buf.Bytes(), nil }