mapserver/server/mapobject/setup.go

35 lines
607 B
Go
Raw Normal View History

2019-01-23 15:22:47 +03:00
package mapobject
import (
"mapserver/app"
2019-01-28 15:31:48 +03:00
"mapserver/eventbus"
2019-01-23 18:06:56 +03:00
"mapserver/mapblockparser"
2019-01-23 15:22:47 +03:00
)
2019-01-23 15:41:26 +03:00
type Listener struct {
2019-01-23 18:06:56 +03:00
ctx *app.App
2019-01-23 15:41:26 +03:00
}
2019-01-28 15:31:48 +03:00
func (this *Listener) OnEvent(eventtype string, o interface{}) {
if eventtype != eventbus.MAPBLOCK_RENDERED {
return
}
block := o.(*mapblockparser.MapBlock)
2019-01-24 10:26:28 +03:00
err := this.ctx.Objectdb.RemoveMapData(&block.Pos)
2019-01-23 18:06:56 +03:00
if err != nil {
panic(err)
}
2019-01-23 15:41:26 +03:00
2019-01-23 18:06:56 +03:00
for id, name := range block.BlockMapping {
if name == "mapserver:poi" {
onPoiBlock(id, block, this.ctx.Objectdb)
}
}
2019-01-23 15:41:26 +03:00
}
2019-01-23 15:22:47 +03:00
func Setup(ctx *app.App) {
2019-01-28 15:31:48 +03:00
ctx.BlockAccessor.Eventbus.AddListener(&Listener{ctx: ctx})
2019-01-23 15:22:47 +03:00
}