add more map objects

This commit is contained in:
NatureFreshMilk 2019-01-29 07:47:53 +01:00
parent 1948d87a9b
commit b42648f36e
5 changed files with 87 additions and 0 deletions

22
server/mapobject/bones.go Normal file
View File

@ -0,0 +1,22 @@
package mapobject
import (
"mapserver/mapblockparser"
"mapserver/mapobjectdb"
)
type BonesBlock struct{}
func (this *BonesBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
if md["owner"] == "" {
return nil
}
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "bones")
o.Attributes["time"] = md["time"]
o.Attributes["owner"] = md["owner"]
return o
}

View File

@ -0,0 +1,18 @@
package mapobject
import (
"mapserver/mapblockparser"
"mapserver/mapobjectdb"
)
type NuclearReactorBlock struct{}
func (this *NuclearReactorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "nuclearreactor")
o.Attributes["burn_time"] = md["burn_time"]
o.Attributes["structure_accumulated_badness"] = md["structure_accumulated_badness"]
return o
}

View File

@ -0,0 +1,23 @@
package mapobject
import (
"mapserver/mapblockparser"
"mapserver/mapobjectdb"
)
type QuarryBlock struct{}
func (this *QuarryBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
if md["owner"] == "" {
return nil
}
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "technicquarry")
o.Attributes["owner"] = md["owner"]
o.Attributes["dug"] = md["dug"]
o.Attributes["enabled"] = md["enabled"]
return o
}

View File

@ -69,6 +69,10 @@ func Setup(ctx *app.App) {
l.AddMapObject("travelnet:travelnet", &TravelnetBlock{})
l.AddMapObject("protector:protect", &ProtectorBlock{})
l.AddMapObject("protector:protect2", &ProtectorBlock{})
l.AddMapObject("bones:bones", &BonesBlock{})
l.AddMapObject("technic:quarry", &QuarryBlock{})
l.AddMapObject("technic:hv_nuclear_reactor_core_active", &NuclearReactorBlock{})
l.AddMapObject("technic:admin_anchor", &TechnicAnchorBlock{})
ctx.BlockAccessor.Eventbus.AddListener(&l)
}

View File

@ -0,0 +1,20 @@
package mapobject
import (
"mapserver/mapblockparser"
"mapserver/mapobjectdb"
)
type TechnicAnchorBlock struct{}
func (this *TechnicAnchorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "technicanchor")
o.Attributes["owner"] = md["owner"]
o.Attributes["radius"] = md["radius"]
o.Attributes["locked"] = md["locked"]
o.Attributes["enabled"] = md["enabled"]
return o
}