2025-10-23 21:22:21 -05:00
|
|
|
import { toUniqueId } from "@blitzkit/core";
|
|
|
|
|
import { NodeIO } from "@gltf-transform/core";
|
|
|
|
|
import { extractArmor } from "../core/blitz/extractArmor";
|
|
|
|
|
import { AssetUploader } from "../core/github/assetUploader";
|
2025-11-26 13:18:44 -06:00
|
|
|
import { vfs } from "./constants";
|
2025-10-23 21:22:21 -05:00
|
|
|
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();
|
2025-11-26 13:18:44 -06:00
|
|
|
const nations = vfs.dir(`Data/XML/item_defs/vehicles`).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) {
|
2025-11-26 13:18:44 -06:00
|
|
|
const tanks = await vfs.xml<{ root: VehicleDefinitionList }>(
|
|
|
|
|
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
2025-10-23 21:22:21 -05:00
|
|
|
);
|
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);
|
2025-11-26 13:18:44 -06:00
|
|
|
const model = await extractArmor(vfs, `${nation}-${tankKey}`);
|
2025-10-23 21:22:21 -05:00
|
|
|
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
|
|
|
}
|