Files
blitzkit/packages/scripts/src/buildAssets/tankArmors.ts
T

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-10-23 21:22:21 -05:00
import { toUniqueId } from "@blitzkit/core";
import { NodeIO } from "@gltf-transform/core";
import { readdir } from "fs/promises";
import { extractArmor } from "../core/blitz/extractArmor";
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
import { AssetUploader } from "../core/github/assetUploader";
import { DATA } from "./constants";
import { VehicleDefinitionList } from "./definitions";
2024-01-07 20:07:45 -06:00
2024-08-27 14:40:43 -05:00
export async function tankArmors() {
2025-10-23 21:22:21 -05:00
console.log("Building tank armors...");
2024-01-07 20:07:45 -06:00
2025-10-23 21:22:21 -05:00
using uploader = new AssetUploader("tank armors");
2024-01-08 18:34:04 -06:00
const nodeIO = new NodeIO();
2024-08-14 14:04:06 -05:00
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
2025-10-23 21:22:21 -05:00
(nations) => nations.filter((nation) => nation !== "common")
2024-01-07 20:07:45 -06:00
);
2025-10-23 21:22:21 -05:00
for (const nation of nations) {
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`
);
2024-01-07 20:07:45 -06:00
2025-10-23 21:22:21 -05:00
for (const tankKey in tanks.root) {
const tank = tanks.root[tankKey];
2024-01-20 13:43:03 -06:00
2025-10-23 21:22:21 -05:00
if (tankKey.includes("tutorial_bot")) continue;
2024-01-08 18:34:04 -06:00
2025-10-23 21:22:21 -05:00
const id = toUniqueId(nation, tank.id);
const model = await extractArmor(DATA, `${nation}-${tankKey}`);
const content = await nodeIO.writeBinary(model);
2024-01-09 13:36:33 -06:00
2025-10-23 21:22:21 -05:00
await uploader.add({ path: `3d/tanks/armor/${id}.glb`, content });
}
}
await uploader.flush();
2024-01-07 20:07:45 -06:00
}