texture discovery

This commit is contained in:
tresabhi committed 2026-06-09 12:43:14 -05:00
1 parent 62b629fe3a
commit a348e005f7
6 files changed
+117 -9

No files matched your search

+13
View File
@@ -1,6 +1,8 @@
import { assertSecret } from "@blitzkit/core";
import type { GameInterface } from "@blitzkit/game";
import { clientUnmounted } from "./unmounted";
import { api } from "../api/dynamic";
import { assertDiscoveryTag } from "./assertDiscoveryTag";
let _game: GameInterface | null = null;
@@ -12,6 +14,17 @@ if (!clientUnmounted && import.meta.env.SSR) {
assertSecret(import.meta.env.WOTB_USMAP),
"../../temp",
);
const tankTags: string[] = [];
for (const item of api.metadata.group("TankEntity")) {
const assetDiscovery = item.BlitzStaticAssetsDiscovery();
const tag = assertDiscoveryTag(assetDiscovery);
tankTags.push(tag);
}
_game.discoverTextures(tankTags);
}
export const game = _game;
@@ -0,0 +1,12 @@
import type { APIContext } from "astro";
import { mixStaticPaths } from "../../astro/mixStaticPaths";
import { game } from "../../game/game";
import { getStaticPaths as _getStaticPaths } from "./_index";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => {
return game!.textures.map((name) => ({ params: { name } }));
});
export function GET({ params }: APIContext<never, { name: string }>) {
return Response.json(params);
}
@@ -0,0 +1,7 @@
import type { GetStaticPaths } from "astro";
import { isChunkEnabled } from "../../astro/isChunkEnabled";
export const getStaticPaths = (() => {
if (!isChunkEnabled("textures")) return [];
return [{ params: { textures: "textures" } }];
}) satisfies GetStaticPaths;