UNPKG

arx-convert

Version:

Converts various Arx Fatalis formats to JSON or YAML and back

30 lines 1.14 kB
import { BinaryIO } from '../common/BinaryIO.js'; import { repeat } from '../common/helpers.js'; export class Scene { static readFrom(binary) { const levelIdx = Scene.pathToLevelIdx(binary.readString(512)); binary.readInt32Array(16); // pad - ? binary.readFloat32Array(16); // fpad - ? return { levelIdx, }; } static accumulateFrom(scene) { const buffer = new ArrayBuffer(Scene.sizeOf()); const binary = new BinaryIO(buffer); binary.writeString(Scene.levelIdxToPath(scene.levelIdx), 512); binary.writeInt32Array(repeat(0, 16)); // pad binary.writeFloat32Array(repeat(0, 16)); // fpad return buffer; } static pathToLevelIdx(path) { return Number.parseInt(path.toLowerCase().replace('graph\\levels\\level', '').replace('\\', ''), 10); } static levelIdxToPath(levelIdx) { return `Graph\\Levels\\level${levelIdx}\\`; } static sizeOf() { return BinaryIO.sizeOfString(512) + BinaryIO.sizeOfInt32Array(16) + BinaryIO.sizeOfFloat32Array(16); } } //# sourceMappingURL=Scene.js.map