remove unnecessary data structs Dict+MapArray
This commit is contained in:
+6
-7
@@ -4,9 +4,8 @@ import {
|
||||
entityProcessMap,
|
||||
} from "#/engine/Entity.ts";
|
||||
import { type Graph, getNeighbours } from "#/engine/Graph.ts";
|
||||
import { box } from "#/engine/lib/box";
|
||||
import { type Box, box } from "#/engine/lib/box";
|
||||
import { memoize } from "#/engine/lib/cache.ts";
|
||||
import MapArray from "#/engine/lib/MapArray.ts";
|
||||
|
||||
export type Process = (ctx: CanvasRenderingContext2D, delta: number) => void;
|
||||
export type PreProcess = () => void;
|
||||
@@ -24,7 +23,7 @@ export type SceneData = {
|
||||
entities: Array<EntityData<unknown>>;
|
||||
};
|
||||
|
||||
export type ComponentsMap = Map<string, MapArray<string, unknown>>;
|
||||
export type ComponentsMap = Map<string, Map<string, Box<unknown>>>;
|
||||
|
||||
export type Scene = {
|
||||
data: SceneData;
|
||||
@@ -113,7 +112,7 @@ const [loadScene, sceneCache] = memoize(async (name: string) => {
|
||||
const localEntityProcessMap = new Map<string, EntityProcess>();
|
||||
sceneEntityProcessMap.set(name, localEntityProcessMap);
|
||||
|
||||
const componentsMap = new Map<string, MapArray<string, unknown>>();
|
||||
const componentsMap: ComponentsMap = new Map();
|
||||
sceneComponentsMap.set(name, componentsMap);
|
||||
|
||||
await Promise.all(
|
||||
@@ -138,7 +137,7 @@ const [loadScene, sceneCache] = memoize(async (name: string) => {
|
||||
if (componentsMap.has(key)) {
|
||||
componentsMap.get(key)!.set(id, boxedValue);
|
||||
} else {
|
||||
componentsMap.set(key, new MapArray([[id, boxedValue]]));
|
||||
componentsMap.set(key, new Map([[id, boxedValue]]));
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -179,6 +178,6 @@ export async function setScene(name: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export default function <T>(name: string): MapArray<string, T> {
|
||||
return currentScene.components.get(name) as MapArray<string, T>;
|
||||
export default function <T>(name: string): Map<string, Box<T>> {
|
||||
return currentScene.components.get(name) as Map<string, Box<T>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user