start on models

This commit is contained in:
tresabhi committed 2026-06-05 11:05:19 -05:00
1 parent 85ddedd481
commit 0507f63177
5 files changed
+68 -3

No files matched your search

+14
View File
@@ -100,4 +100,18 @@ public partial class GameInterface
var icon = pda.Get<FSoftObjectPath>("Icon");
return provider.Image(icon);
}
private readonly string[] tankPartEntries = ["DT_Chassis", "DT_Hulls", "DT_Turrets", "DT_Guns"];
public byte[] TankPart(string tag, string part)
{
var pda = provider.Discovered<UPrimaryDataAsset>(tag);
foreach (var entry in tankPartEntries) {
pda.Get<FSoftObjectPath>(entry);
// var icon = pda.Get<FSoftObjectPath>("Icon");
}
return [];
}
}
@@ -5,10 +5,12 @@ import { mixStaticPaths } from "../../../../astro/mixStaticPaths";
import { assertDiscoveryTag } from "../../../../game/assertDiscoveryTag";
import { game } from "../../../../game/game";
import { clientUnmounted } from "../../../../game/unmounted";
import { getStaticPaths as _getStaticPaths } from "../../../[api]/tanks/[id].json";
import { getStaticPaths as __getStaticPaths } from "../../_index";
import { getStaticPaths as _getStaticPaths } from "../../_index";
export const getStaticPaths = mixStaticPaths(__getStaticPaths, _getStaticPaths);
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
const { list } = await api.tankList();
return list.map(({ id }) => ({ params: { id } }));
});
export async function GET({ params }: APIContext<never, { id: string }>) {
if (clientUnmounted) return clientUnmountedResponse;
@@ -0,0 +1,8 @@
import type { GetStaticPaths } from "astro";
import { isChunkEnabled } from "../../astro/isChunkEnabled";
// TODO: maybe consider abstracting this away?
export const getStaticPaths = (() => {
if (!isChunkEnabled("models")) return [];
return [{ params: { models: "models" } }];
}) satisfies GetStaticPaths;
Whitespace-only changes.
@@ -0,0 +1,41 @@
import type { APIContext, GetStaticPathsItem } from "astro";
import { api } from "../../../../api/dynamic";
import { mixStaticPaths } from "../../../../astro/mixStaticPaths";
import { getStaticPaths as _getStaticPaths } from "../../_index";
import { assertDiscoveryTag } from "../../../../game/assertDiscoveryTag";
import { game } from "../../../../game/game";
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
const tanks = await api.tanks();
const paths: GetStaticPathsItem[] = [];
for (const id in tanks.tanks) {
const tank = tanks.tanks[id];
const parts = new Set<string>(["chassis", "hull"]);
for (const line of tank.tank!.upgrade_lines) {
for (const stage of line.stages) {
for (const change of stage.visual_changes) {
parts.add(change.name);
}
}
}
for (const part of parts) {
paths.push({ params: { id, part } });
}
}
return paths;
});
export async function GET({
params,
}: APIContext<never, { id: string; part: string }>) {
const item = api.metadata.item(params.id);
const assetDiscovery = item.BlitzStaticAssetsDiscovery();
const tag = assertDiscoveryTag(assetDiscovery);
const part = game!.tankPart(tag, params.part);
return Response.json(parts.length);
}