UNPKG

xcom2charpool

Version:

Library for reading, manipulating, and managing XCOM 2 character pool binary files, supporting both browser and Node.js environments.

38 lines (37 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ByteProperty = void 0; const BytePropertyValue_1 = require("./BytePropertyValue"); const BaseCodec_1 = require("../../BaseCodec"); /** * Codec for UE ByteProperty values (stored as typed strings). */ class ByteProperty extends BaseCodec_1.BaseCodec { constructor() { super(...arguments); this.type = 'ByteProperty'; } read(reader, length, ctx) { const type = reader.string(); reader.padding(); return this.readSized(reader, length, ctx, (payload) => { const value = payload.string(); payload.padding(); return new BytePropertyValue_1.BytePropertyValue(type, value); }); } write(writer, value, ctx) { writer.string(value.type); writer.padding(); // Record the start position for size calculation const startPosition = writer.position; writer.string(value.value); writer.padding(); // Record the end position return writer.position - startPosition; } isSupported(value) { return value instanceof BytePropertyValue_1.BytePropertyValue; } } exports.ByteProperty = ByteProperty;