main
Nick Dumas 2 weeks ago
parent 942c249be3
commit f47273c2ed

@ -3,41 +3,13 @@ package main
import ( import (
"fmt" "fmt"
"github.com/mlange-42/ark/ecs" "github.com/EngoEngine/ecs"
"code.ndumas.com/ndumas/muddy" "code.ndumas.com/ndumas/muddy"
) )
func main() { func main() {
world := ecs.NewWorld() world := ecs.World{}
locationMapper := ecs.NewMap3[muddy.ID, muddy.Location, muddy.Observable](world) world.Update(1)
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)
}
} }

@ -5,11 +5,24 @@ type ID struct {
} }
type Location struct { type Location struct {
World int64 X, Y, Z int64
Exits []int64 World int64
Exits []int64
} }
type Observable struct { type Observable struct {
Name string Name string
Description string Description string
} }
type Inventory struct {
Items []int64
}
type HP struct {
Max, Current, Regen int64
}
type Mana struct {
Max, Current, Regen int64
}

@ -2,4 +2,9 @@ module code.ndumas.com/ndumas/muddy
go 1.24.5 go 1.24.5
require github.com/mlange-42/ark v0.7.0 require (
github.com/EngoEngine/ecs v1.0.5
github.com/mlange-42/ark v0.7.0
)
require github.com/stretchr/testify v1.10.0 // indirect

@ -1,2 +1,17 @@
github.com/EngoEngine/ecs v1.0.5 h1:S21KTClrAqC862BFR5wTkd6uEYQ0Aw/ob9RjKPt0e30=
github.com/EngoEngine/ecs v1.0.5/go.mod h1:A8AYbzKIsl+t4qafmLL3t4H6cXdfGo4CIHl7EN100iM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mlange-42/ark v0.7.0 h1:cLEqhJhZaZayi35eY/cE7VQg7GonK+s1qbsSKdtcjrs= github.com/mlange-42/ark v0.7.0 h1:cLEqhJhZaZayi35eY/cE7VQg7GonK+s1qbsSKdtcjrs=
github.com/mlange-42/ark v0.7.0/go.mod h1:gkS9cuklENPTmSjL2z4DcJgJsIVqF1yNwFlx48Hz/Sw= github.com/mlange-42/ark v0.7.0/go.mod h1:gkS9cuklENPTmSjL2z4DcJgJsIVqF1yNwFlx48Hz/Sw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

@ -0,0 +1,34 @@
package muddy
import (
"fmt"
"github.com/EngoEngine/ecs"
)
type Room struct {
ID
Location
Observable
Inventory
}
type RoomRepository interface {
Get(int64) (Room, error)
GetAll() ([]Room, error)
Delete(int64) error
}
type RoomSystem struct {
repository RoomRepository
}
func (s *RoomSystem) Initialize(w *ecs.World) {
fmt.Println("initializing room system")
// locationMapper := ecs.NewMap4[ID, Location, Observable, Inventory](w)
}
func (s *RoomSystem) Update(w *ecs.World) {}
// Finalize the system.
func (s *RoomSystem) Finalize(w *ecs.World) {}
Loading…
Cancel
Save