layered three view
game object geometries layer
This commit is contained in:
@@ -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;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user