load dimension example
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
||||
"github.com/Tnze/go-mc/server"
|
||||
"github.com/Tnze/go-mc/server/ecs"
|
||||
"github.com/Tnze/go-mc/server/world"
|
||||
"log"
|
||||
)
|
||||
|
||||
type PlayerProfile struct {
|
||||
@ -31,7 +30,6 @@ func (p playerSpawnSystem) Update(w *ecs.World) {
|
||||
client.PutErr(fmt.Errorf("read player data fail: %w", err))
|
||||
return
|
||||
}
|
||||
log.Println("load player info successes", profile)
|
||||
dim, ok := dimensionRes.Find(profile.Dimension)
|
||||
if !ok {
|
||||
panic("dimension " + profile.Dimension + " not found")
|
||||
|
@ -22,6 +22,13 @@ type Dimension struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func NewDimension(name, path string) Dimension {
|
||||
return Dimension{
|
||||
Name: name,
|
||||
storage: storage{regionDir: path},
|
||||
}
|
||||
}
|
||||
|
||||
type DimensionList struct {
|
||||
Dims []ecs.Index
|
||||
DimNames []string
|
||||
@ -41,6 +48,11 @@ func (d *DimensionList) Find(dim string) (ecs.Index, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (d *DimensionList) Add(id ecs.Index, name string) {
|
||||
d.Dims = append(d.Dims, id)
|
||||
d.DimNames = append(d.DimNames, name)
|
||||
}
|
||||
|
||||
func NewDimensionManager(g *server.Game) *DimensionList {
|
||||
return ecs.SetResource(g.World, DimensionList{
|
||||
Dims: nil,
|
||||
|
Reference in New Issue
Block a user