locator mapobject
This commit is contained in:
parent
216c1dd6fa
commit
26f54449a2
@ -61,6 +61,7 @@ type MapObjectConfig struct {
|
||||
ATM bool `json:"atm"`
|
||||
Train bool `json:"train"`
|
||||
Minecart bool `json:"minecart"`
|
||||
Locator bool `json:"locator"`
|
||||
}
|
||||
|
||||
type WebApiConfig struct {
|
||||
@ -148,6 +149,7 @@ func ParseConfig(filename string) (*Config, error) {
|
||||
ATM: true,
|
||||
Train: true,
|
||||
Minecart: false,
|
||||
Locator: false,
|
||||
}
|
||||
|
||||
mapblockaccessor := MapBlockAccessorConfig{
|
||||
|
29
server/mapobject/locator.go
Normal file
29
server/mapobject/locator.go
Normal file
@ -0,0 +1,29 @@
|
||||
package mapobject
|
||||
|
||||
import (
|
||||
"mapserver/mapblockparser"
|
||||
"mapserver/mapobjectdb"
|
||||
)
|
||||
|
||||
type Locator struct{}
|
||||
|
||||
func (this *Locator) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||
md := block.Metadata.GetMetadata(x, y, z)
|
||||
nodename := block.GetNodeName(x, y, z)
|
||||
|
||||
var level = "1"
|
||||
switch nodename {
|
||||
case "locator:beacon_2":
|
||||
level = "2"
|
||||
case "locator:beacon_3":
|
||||
level = "3"
|
||||
}
|
||||
|
||||
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "locator")
|
||||
o.Attributes["owner"] = md["owner"]
|
||||
o.Attributes["name"] = md["name"]
|
||||
o.Attributes["active"] = md["active"]
|
||||
o.Attributes["level"] = level
|
||||
|
||||
return o
|
||||
}
|
@ -150,5 +150,13 @@ func Setup(ctx *app.App) {
|
||||
l.AddMapObject("atm:atm", &ATM{})
|
||||
}
|
||||
|
||||
//locator
|
||||
if ctx.Config.MapObjects.Locator {
|
||||
loc := &Locator{}
|
||||
l.AddMapObject("locator:beacon_1", loc)
|
||||
l.AddMapObject("locator:beacon_2", loc)
|
||||
l.AddMapObject("locator:beacon_3", loc)
|
||||
}
|
||||
|
||||
ctx.BlockAccessor.Eventbus.AddListener(&l)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user