diff --git a/cmd/cli/guest/main.go b/cmd/cli/guest/main.go index 36986d4..09712ba 100644 --- a/cmd/cli/guest/main.go +++ b/cmd/cli/guest/main.go @@ -29,7 +29,7 @@ func main() { logLevel = slog.LevelError } - l := slog.New(slog.NewJSONHandler( + l := slog.New(slog.NewTextHandler( os.Stderr, &slog.HandlerOptions{ Level: logLevel, }, @@ -40,13 +40,14 @@ func main() { rs := &systems.RoomSystem{ Rooms: make(map[uint64]*systems.Room, 0), - L: l.WithGroup("rooms"), + L: l.With(slog.String("system", "room")), } world.AddSystem(rs) - world.Update(1) l.With( slog.Int("room count", len(rs.Rooms)), ).Info("setup complete") + + world.Update(1) } diff --git a/systems/room.go b/systems/room.go index 00dabe0..0d9d6f3 100644 --- a/systems/room.go +++ b/systems/room.go @@ -1,6 +1,7 @@ package systems import ( + "fmt" "log/slog" "github.com/EngoEngine/ecs" @@ -16,7 +17,8 @@ type Room struct { } type RoomSystem struct { - L *slog.Logger + L *slog.Logger + // replace this with cache fronted db access later Rooms map[uint64]*Room } @@ -33,20 +35,26 @@ func (rs *RoomSystem) New(w *ecs.World) { X: int64(i), Y: int64(j), }, - Observable: &components.Observable{}, - Inventory: &components.Inventory{}, + 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++ } } - // locationMapper := ecs.NewMap4[ID, Location, Observable, Inventory](w) } func (rs *RoomSystem) Update(dt float32) { - rs.L.Debug("room system tick") + + // flush changes to persistent storage } func (rs *RoomSystem) Remove(e ecs.BasicEntity) {} - -// Finalize the system. -func (rs *RoomSystem) Finalize(w *ecs.World) {}