This commit is contained in:
Schluffe
2026-03-01 23:34:45 +01:00
parent 98442cd8d1
commit c2dce421b3
3 changed files with 32 additions and 2 deletions
+17 -1
View File
@@ -1,4 +1,4 @@
import type { Box } from "#/engine/Box.ts";
import { type Box, box } from "#/engine/Box.ts";
import { type Drawable, draw, isDrawable } from "#/engine/Drawable.ts";
import {
entityMap,
@@ -8,6 +8,8 @@ import {
import { type Graph, getNeighbours } from "#/engine/Graph.ts";
import { useWithAsyncCache } from "#/engine/lib/cache.ts";
import { animateSprite, type SpriteAnimation } from "#/engine/Sprite.ts";
import { componentMap, defineComponent } from "./Component";
import { mulberry32 } from "./lib/mulberry32";
export type EntityData = {
name: string;
@@ -229,3 +231,17 @@ export async function setScene(name: string): Promise<void> {
handler(data, currentScene.data);
}
}
const next = mulberry32(54850268);
export function def(name: string): <T>(key: string, value: T) => void {
const id = next().toString(16).slice(2);
defineComponent<string>("name").set(id, name);
return (key, value) => {
const components = defineComponent(key);
components.set(id, value);
console.log(componentMap);
};
}