phantasmal-world/static_generation/update_generic_data.ts

38 lines
978 B
TypeScript
Raw Normal View History

import fs from "fs";
import Logger from "js-logger";
2019-07-01 14:53:16 +08:00
import { BufferCursor } from "../src/data_formats/BufferCursor";
import { parse_rlc } from "../src/data_formats/parsing/rlc";
const logger = Logger.get("static/update_generic_data");
Logger.useDefaults({ defaultLevel: Logger.TRACE });
/**
* Used by static data generation scripts.
*/
const RESOURCE_DIR = "./static/resources";
/**
* Used by production code.
*/
const PUBLIC_DIR = "./public";
update();
function update(): void {
logger.info("Updating generic static data.");
logger.info("Extracting player animations.");
const buf = fs.readFileSync(`${RESOURCE_DIR}/plymotiondata.rlc`);
let i = 0;
for (const file of parse_rlc(new BufferCursor(buf, false))) {
fs.writeFileSync(
`${PUBLIC_DIR}/player/animation/animation_${(i++).toString().padStart(3, "0")}.njm`,
file.uint8_array_view()
);
}
logger.info("Done updating generic static data.");
}