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 }