mapserver/server/mapobject/setup.go

28 lines
484 B
Go
Raw Normal View History

2019-01-23 15:22:47 +03:00
package mapobject
import (
"mapserver/app"
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
}
func (this *Listener) OnParsedMapBlock(block *mapblockparser.MapBlock) {
2019-01-23 18:06:56 +03:00
err := this.ctx.Objectdb.RemoveMapData(block.Pos)
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-23 15:41:26 +03:00
ctx.BlockAccessor.AddListener(&Listener{ctx: ctx})
2019-01-23 15:22:47 +03:00
}