WIP
This commit is contained in:
+4
-4
@@ -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<void>;
|
||||
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<void> {
|
||||
|
||||
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;
|
||||
|
||||
@@ -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) => {});
|
||||
|
||||
Reference in New Issue
Block a user