From f47273c2edea52506ae5d69f376244d4da52fc8c Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Tue, 20 Jan 2026 17:09:36 -0500 Subject: [PATCH] blarp --- cmd/cli/guest/main.go | 34 +++------------------------------- components.go | 17 +++++++++++++++-- go.mod | 7 ++++++- go.sum | 15 +++++++++++++++ systems.go | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 systems.go diff --git a/cmd/cli/guest/main.go b/cmd/cli/guest/main.go index fe3c42c..ff4432b 100644 --- a/cmd/cli/guest/main.go +++ b/cmd/cli/guest/main.go @@ -3,41 +3,13 @@ package main import ( "fmt" - "github.com/mlange-42/ark/ecs" + "github.com/EngoEngine/ecs" "code.ndumas.com/ndumas/muddy" ) func main() { - world := ecs.NewWorld() + world := ecs.World{} - 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) - } + world.Update(1) } diff --git a/components.go b/components.go index 0af35dc..9c77b83 100644 --- a/components.go +++ b/components.go @@ -5,11 +5,24 @@ type ID struct { } type Location struct { - World int64 - Exits []int64 + X, Y, Z int64 + World int64 + Exits []int64 } type Observable struct { Name string Description string } + +type Inventory struct { + Items []int64 +} + +type HP struct { + Max, Current, Regen int64 +} + +type Mana struct { + Max, Current, Regen int64 +} diff --git a/go.mod b/go.mod index 9324db1..5cb0391 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,9 @@ module code.ndumas.com/ndumas/muddy 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 diff --git a/go.sum b/go.sum index 914e546..9608f85 100644 --- a/go.sum +++ b/go.sum @@ -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/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= diff --git a/systems.go b/systems.go new file mode 100644 index 0000000..7bbf128 --- /dev/null +++ b/systems.go @@ -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) {}