refactor(0.1.14-P2): Kernel 三合一 + GameEngine 引擎门面

- Kernel(engine/kernel/Kernel.ts):游戏时钟+种子随机+事件总线——单一实例三合一,
  World 不再自造 clock/rng(内核注入,bus 透传 out)
- GameEngine(engine/GameEngine.ts):唯一引擎入口——
  new GameEngine({seed,datapack}) → world/facade/kernel/datapack,
  advance/act/query/subscribe/about/installPlugin/snapshot/restore/status
- World 构造接受 kernel 注入(保持行为等价:时钟注册顺序不变)
- ApiFacade.subscribe 简化纯实现
- 验证:967 测试全绿、金钟罩三档零漂移、typecheck 0 error
This commit is contained in:
2026-08-23 13:25:42 +08:00
parent ff6df8054c
commit 8dfdaf843a
4 changed files with 206 additions and 3 deletions
@@ -115,6 +115,7 @@ export class GameFacade {
}
}
subscribe(on: (e: FacadeEvent) => void): () => void {
const bus: WorldEventBus = {
onLog: (kind: LogKind, text: string) => on({ type: 'log', kind, text, year: this.world.state.year, month: this.world.state.month }),