From f96fd337dab3650e669df33735fa91fcba3877b6 Mon Sep 17 00:00:00 2001 From: kolaflash Date: Fri, 9 Jan 2026 00:42:48 +0100 Subject: [PATCH] WIP --- engine/Scene.ts | 8 ++++---- scenes/testScene/index.ts | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/Scene.ts b/engine/Scene.ts index ab2cd71..d157c3e 100644 --- a/engine/Scene.ts +++ b/engine/Scene.ts @@ -33,7 +33,7 @@ export type Scene = { }; export type Process = (ctx: CanvasRenderingContext2D, delta: number) => void; -export type PreProcess = () => void; +export type PreProcess = (entities: EntityInstanceMap) => void; export type PostProcess = () => void; export type SceneChangeHandler = (to: SceneData, from: SceneData) => void; @@ -121,7 +121,7 @@ export function useScene(data: SceneData): { ) => (name: T[number]) => Promise; process: (fn: Process) => void; preProcess: (fn: PreProcess) => void; - postProcess: (fn: PreProcess) => void; + postProcess: (fn: PostProcess) => void; } { sceneDataMap.set(data.name, data); sceneEntiyMap.set(data.name, new Map()); @@ -166,12 +166,12 @@ export async function setScene(name: string): Promise { const preProcess = scenePreProcessMap.get(name); if (preProcess) { - preProcess(); + preProcess(sceneEntiyMap.get(name)!); } const postProcess = scenePostProcessMap.get(currentScene.data.name); if (postProcess) { - postProcess(); + postProcess(sceneEntiyMap.get(name)!); } currentScene.data = data; diff --git a/scenes/testScene/index.ts b/scenes/testScene/index.ts index 2595e24..7ee34d5 100644 --- a/scenes/testScene/index.ts +++ b/scenes/testScene/index.ts @@ -5,6 +5,12 @@ const { process, preProcess, linkScenes } = useScene(data); linkScenes(["fooScene", "fuzzScene"] as const); -preProcess(() => {}); +preProcess((entityInstanceMap) => { + const entity = entityInstanceMap.get(data.entities[0].name); + const instance = entity!.instances[0]; + + instance.position.x = data.width - 16; + instance.position.y = data.height - 16; +}); process((_ctx, _delta) => {});