|
|
|
|
package systems
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log/slog"
|
|
|
|
|
|
|
|
|
|
"github.com/EngoEngine/ecs"
|
|
|
|
|
|
|
|
|
|
"code.ndumas.com/ndumas/muddy/components"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Room struct {
|
|
|
|
|
*components.ID
|
|
|
|
|
*components.Location
|
|
|
|
|
*components.Observable
|
|
|
|
|
*components.Inventory
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RoomSystem struct {
|
|
|
|
|
L *slog.Logger
|
|
|
|
|
// replace this with cache fronted db access later
|
|
|
|
|
Rooms map[uint64]*Room
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *RoomSystem) New(w *ecs.World) {
|
|
|
|
|
rs.L.Debug("initializing room system")
|
|
|
|
|
z := 0
|
|
|
|
|
for i := range 10 {
|
|
|
|
|
for j := range 10 {
|
|
|
|
|
rs.Rooms[uint64(z)] = &Room{
|
|
|
|
|
ID: &components.ID{
|
|
|
|
|
ID: uint64(z),
|
|
|
|
|
},
|
|
|
|
|
Location: &components.Location{
|
|
|
|
|
X: int64(i),
|
|
|
|
|
Y: int64(j),
|
|
|
|
|
},
|
|
|
|
|
Observable: &components.Observable{
|
|
|
|
|
Name: fmt.Sprintf("Room (%d,%d)", i, j),
|
|
|
|
|
Description: fmt.Sprintf("%s", "A non-descript room."),
|
|
|
|
|
},
|
|
|
|
|
Inventory: &components.Inventory{},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rs.L.With(
|
|
|
|
|
slog.Int("X", i),
|
|
|
|
|
slog.Int("Y", j),
|
|
|
|
|
slog.Int("ID", z),
|
|
|
|
|
).Debug("loaded room")
|
|
|
|
|
z++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *RoomSystem) Update(dt float32) {
|
|
|
|
|
|
|
|
|
|
// flush changes to persistent storage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rs *RoomSystem) Remove(e ecs.BasicEntity) {}
|