mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
start on models
This commit is contained in:
1 parent
85ddedd481
commit
0507f63177
5 files changed
+68
-3
No files matched your search
@@ -100,4 +100,18 @@ public partial class GameInterface
|
|||||||
var icon = pda.Get<FSoftObjectPath>("Icon");
|
var icon = pda.Get<FSoftObjectPath>("Icon");
|
||||||
return provider.Image(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 { assertDiscoveryTag } from "../../../../game/assertDiscoveryTag";
|
||||||
import { game } from "../../../../game/game";
|
import { game } from "../../../../game/game";
|
||||||
import { clientUnmounted } from "../../../../game/unmounted";
|
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 }>) {
|
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||||
if (clientUnmounted) return clientUnmountedResponse;
|
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);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user