@@ -11,44 +11,53 @@ import { drawFrame, drawPanel } from '/src/engine/debug/index.js';
1111const theme = new Theme ( ThemeTokens ) ;
1212
1313export default class Phase18FoundationScene extends Scene {
14- constructor ( { coreServices = null } = { } ) {
14+ constructor ( { runtimeLayer = null } = { } ) {
1515 super ( ) ;
1616 this . elapsed = 0 ;
17- this . coreServices = coreServices ;
17+ this . runtimeLayer = runtimeLayer ;
1818 this . lastHeartbeatTick = 0 ;
1919 this . lastHeartbeatTime = 0 ;
20+ this . lastRuntimeTransition = 'idle' ;
2021 this . unsubscribeHeartbeat = null ;
22+ this . unsubscribeRuntimeState = null ;
2123 }
2224
2325 enter ( engine ) {
24- if ( ! this . coreServices ) return ;
25- const channel = this . coreServices . get ( 'phase18.channel' ) ;
26+ if ( ! this . runtimeLayer ) return ;
27+ const channel = this . runtimeLayer . getService ( 'phase18.channel' ) ;
2628 if ( channel && typeof channel . subscribe === 'function' ) {
2729 this . unsubscribeHeartbeat = channel . subscribe ( 'phase18.heartbeat' , ( payload ) => {
2830 this . lastHeartbeatTick = Number ( payload ?. tick ) || 0 ;
2931 this . lastHeartbeatTime = Number ( payload ?. t ) || 0 ;
3032 } ) ;
3133 }
32- this . coreServices . start ( { engine, scene : this } ) ;
34+ this . unsubscribeRuntimeState = this . runtimeLayer . onStateChange ( ( { previous, next } ) => {
35+ this . lastRuntimeTransition = `${ previous } -> ${ next } ` ;
36+ } ) ;
37+ this . runtimeLayer . start ( { engine, scene : this } ) ;
3338 }
3439
3540 update ( dtSeconds ) {
3641 this . elapsed += dtSeconds ;
37- this . coreServices ?. update ( dtSeconds , { scene : this } ) ;
42+ this . runtimeLayer ?. update ( dtSeconds , { scene : this } ) ;
3843 }
3944
4045 exit ( ) {
4146 if ( typeof this . unsubscribeHeartbeat === 'function' ) {
4247 this . unsubscribeHeartbeat ( ) ;
4348 this . unsubscribeHeartbeat = null ;
4449 }
45- this . coreServices ?. stop ( { scene : this } ) ;
50+ if ( typeof this . unsubscribeRuntimeState === 'function' ) {
51+ this . unsubscribeRuntimeState ( ) ;
52+ this . unsubscribeRuntimeState = null ;
53+ }
54+ this . runtimeLayer ?. stop ( { scene : this } ) ;
4655 }
4756
4857 render ( renderer ) {
4958 drawFrame ( renderer , theme , [
5059 'Sample 1801 - Phase 18 Foundation' ,
51- 'Minimal Phase 18 structure bootstrap and launcher wiring .' ,
60+ 'Minimal Phase 18 runtime-layer scaffolding integrated with core services .' ,
5261 'No feature implementation in this scaffold.' ,
5362 ] ) ;
5463
@@ -63,11 +72,18 @@ export default class Phase18FoundationScene extends Scene {
6372 font : '16px monospace' ,
6473 } ) ;
6574
75+ const runtimeSnapshot = this . runtimeLayer ?. getSnapshot ?. ( ) || {
76+ state : 'idle' ,
77+ tickCount : 0 ,
78+ serviceIds : [ ] ,
79+ } ;
6680 drawPanel ( renderer , 620 , 34 , 300 , 160 , 'Phase 18 Bootstrap' , [
6781 'Status: initialized' ,
6882 'Folder: samples/phase-18' ,
6983 'Entry sample: 1801' ,
70- `Services: ${ this . coreServices ?. listServiceIds ( ) . length ?? 0 } ` ,
84+ `Runtime: ${ runtimeSnapshot . state } | tick ${ runtimeSnapshot . tickCount } ` ,
85+ `Transition: ${ this . lastRuntimeTransition } ` ,
86+ `Services: ${ runtimeSnapshot . serviceIds . length } ` ,
7187 `Heartbeat tick: ${ this . lastHeartbeatTick } @ ${ this . lastHeartbeatTime . toFixed ( 2 ) } s` ,
7288 ] ) ;
7389 }
0 commit comments