You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
782 B
Go

2 weeks ago
package main
import (
"fmt"
"github.com/mlange-42/ark/ecs"
"code.ndumas.com/ndumas/muddy"
)
func main() {
world := ecs.NewWorld()
locationMapper := ecs.NewMap3[muddy.ID, muddy.Location, muddy.Observable](world)
z := 0
for i := range 10 {
for j := range 10 {
_ = locationMapper.NewEntity(
&muddy.ID{ID: int64(z)},
&muddy.Location{
World: 0,
Exits: make([]int64, 0),
},
&muddy.Observable{
Name: fmt.Sprintf("Room (%d,%d)", i, j),
},
)
z++
}
}
locationFilter := ecs.NewFilter3[muddy.ID, muddy.Location, muddy.Observable](world)
query := locationFilter.Query()
for query.Next() {
id, loc, obsv := query.Get()
fmt.Println("====")
fmt.Printf("%#v\n", id)
fmt.Printf("%#v\n", loc)
fmt.Printf("%#v\n", obsv)
}
}