init
This commit is contained in:
25
engine/core/SceneManager.ts
Normal file
25
engine/core/SceneManager.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { GameData, SceneNode } from '../types'
|
||||
|
||||
export class SceneManager {
|
||||
private scenes: Record<string, SceneNode> = {}
|
||||
private startScene: string = ''
|
||||
|
||||
load(data: GameData) {
|
||||
this.scenes = data.scenes
|
||||
this.startScene = data.startScene
|
||||
}
|
||||
|
||||
getScene(id: string): SceneNode | undefined {
|
||||
return this.scenes[id]
|
||||
}
|
||||
|
||||
getStartScene(): SceneNode {
|
||||
const scene = this.scenes[this.startScene]
|
||||
if (!scene) throw new Error(`Start scene "${this.startScene}" not found`)
|
||||
return scene
|
||||
}
|
||||
|
||||
getAllSceneIds(): string[] {
|
||||
return Object.keys(this.scenes)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user