38 lines
771 B
Go
38 lines
771 B
Go
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"time"
|
|
|
|
"joylink.club/ecs"
|
|
)
|
|
|
|
type WorldTimeSys struct {
|
|
}
|
|
|
|
func (s *WorldTimeSys) Update(w ecs.World) {
|
|
slog.Info("世界更新")
|
|
// panic("更新异常")
|
|
}
|
|
|
|
func main() {
|
|
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug})))
|
|
w := ecs.NewWorld(15)
|
|
// ecs.EventsDebugEnable()
|
|
// ecs.WorldStateChangeEvent.Subscribe(w, func(_ ecs.World, e ecs.WorldStateChange) {
|
|
// slog.Info("世界状态变更", "statechange", e)
|
|
// if e.NewState == ecs.WorldClosed {
|
|
// panic("状态变更监听处理异常")
|
|
// }
|
|
// })
|
|
// slog.Info("世界启动")
|
|
// w.AddSystem(&WorldTimeSys{})
|
|
// w.StartUp()
|
|
|
|
time.Sleep(1 * time.Second)
|
|
w.Close()
|
|
|
|
// time.Sleep(3 * time.Second)
|
|
}
|