xcom2charpool
Version:
Library for reading, manipulating, and managing XCOM 2 character pool binary files, supporting both browser and Node.js environments.
29 lines (28 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CharacterPoolFileWithIAM = void 0;
const StructArrayElement_1 = require("../Properties/Struct/StructArrayElement");
const IAMCharacterPoolSchema_1 = require("../Schema/IAMCharacterPoolSchema");
/**
* Wrapper that augments CharacterPoolFile with IAM-specific arrays and schema checks.
*/
class CharacterPoolFileWithIAM {
constructor(file) {
this.file = file;
file.registry.registerArray('ExtraDatas', new StructArrayElement_1.StructArrayElement('ExtraData'));
file.registry.registerArray('AppearanceStore', new StructArrayElement_1.StructArrayElement('Appearance'));
}
get registry() {
return this.file.registry;
}
read(reader) {
const data = this.file.read(reader);
IAMCharacterPoolSchema_1.IAMCharacterPoolSchema.parse(data);
return data;
}
write(writer, file) {
IAMCharacterPoolSchema_1.IAMCharacterPoolSchema.parse(file);
this.file.write(writer, file);
}
}
exports.CharacterPoolFileWithIAM = CharacterPoolFileWithIAM;