world 关闭方法添加对未启动过world的处理
This commit is contained in:
parent
e83feb89dd
commit
2757e2c4e0
|
@ -20,18 +20,18 @@ 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()
|
||||
// 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(2 * time.Second)
|
||||
time.Sleep(1 * time.Second)
|
||||
w.Close()
|
||||
|
||||
time.Sleep(4 * time.Second)
|
||||
// time.Sleep(3 * time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue