layered three view

game object geometries layer
This commit is contained in:
azykov@mail.ru
2026-06-19 20:54:27 +03:00
parent 076cded364
commit 579fe36e6c
31 changed files with 521 additions and 219 deletions
+5 -9
View File
@@ -1,5 +1,5 @@
import { toJS } from "mobx";
import type { Game, GameScene, RuntimeGameObjectInstance, RuntimeGameScene, RuntimeScene, ScriptAction, ScriptCoroutineContext, World } from "../types";
import type { Game, Scene, ScriptAction, ScriptCoroutineContext, World } from "../types";
import { clone } from "../utils";
import { populateRuntimeScene } from "../utils/runtime";
import { ScriptGameEventBus } from "../scripts/eventBus";
@@ -24,7 +24,7 @@ export class GameFactory {
const game = {
paused: false,
time: 0,
scene: GameFactory.initGameScene(scene),
scene,
};
return game;
}
@@ -36,17 +36,13 @@ export class GameFactory {
}
}
public static save(game: Game<GameScene>): void {
public static save(game: Game): void {
localStorage.setItem("game", JSON.stringify(game));
}
private static initGameScene(scene: RuntimeScene): RuntimeGameScene {
return scene as RuntimeGameScene;
}
public static evalGameScripts(
world: World,
scene: RuntimeGameScene,
scene: Scene,
coroutines: ScriptCoroutines,
): ScriptGameEventBus {
@@ -80,7 +76,7 @@ export class GameFactory {
Object.values(scene.objects)
.filter((o) => o.typeId == ot.id)
.map((liveObj) => {
const snapshot = toJS(liveObj) as RuntimeGameObjectInstance;
const snapshot = toJS(liveObj);
snapshot.rb = () => liveObj.rb();
return snapshot;
})