Update framework

This commit is contained in:
2022-11-26 02:22:02 +01:00
parent 9a6ce1f832
commit ae057940af
508 changed files with 26011 additions and 14248 deletions

0
framework/scene/index.d.ts vendored Normal file
View File

0
framework/scene/index.js Normal file
View File

12
framework/scene/manager.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Scene } from './scene';
export declare class SceneManager {
scenes: Map<string, Scene>;
currentScene: Scene;
defaultScene: Scene;
constructor();
init(): void;
addScene(scene: Scene): void;
removeScene(scene: Scene): void;
switchTo(scene: Scene): void;
setDefaultScene(scene: Scene): void;
}

View File

@@ -0,0 +1,33 @@
export class SceneManager {
constructor() {
this.scenes = new Map();
}
init() {
if (this.defaultScene) {
this.switchTo(this.defaultScene);
}
}
addScene(scene) {
this.scenes.set(scene.id, scene);
}
removeScene(scene) {
if (scene === this.currentScene)
this.currentScene.onDeactivate();
this.scenes.delete(scene.id);
}
switchTo(scene) {
if (scene === this.currentScene)
return;
let data;
if (this.currentScene) {
this.currentScene.onDeactivate();
data = this.currentScene.data;
}
this.currentScene = this.scenes.get(scene.id);
this.currentScene.onSwitch(data);
this.currentScene.onActivate(this);
}
setDefaultScene(scene) {
this.defaultScene = scene;
}
}

10
framework/scene/scene.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import { SceneManager } from './manager';
export interface Scene {
id: string;
data: any;
onActivate(manager: SceneManager): any;
onDeactivate(): any;
onSwitch(data: any): any;
update(dt: number): any;
updateDraw(): any;
}

1
framework/scene/scene.js Normal file
View File

@@ -0,0 +1 @@
export {};