@etothepii/satisfactory-file-parser
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -6,7 +6,11 @@ export { Level } from './parser/satisfactory/level.class'; | ||
export { SaveComponent } from './parser/satisfactory/objects/SaveComponent'; | ||
export { SaveEntity } from './parser/satisfactory/objects/SaveEntity'; | ||
export type * from './parser/satisfactory/satisfactory-save'; | ||
export { StaticData } from './parser/satisfactory/static-data'; | ||
export { BlueprintConfigReader, BlueprintReader } from './parser/blueprint-reader'; | ||
export { BlueprintConfigWriter, BlueprintWriter } from './parser/blueprint-writer'; | ||
export type * from './parser/satisfactory/structs/util.types'; | ||
export { SaveEntity } from './parser/satisfactory/objects/SaveEntity'; | ||
export { SaveReader } from './parser/save-reader'; | ||
export { SaveWriter } from './parser/save-writer'; | ||
export { CompressionLibraryError, CorruptSaveError, ParserError, UnsupportedVersionError } from './parser/error/parser.error'; | ||
export { SaveParser } from './parser/parser'; |
@@ -0,12 +1,49 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveParser = exports.UnsupportedVersionError = exports.ParserError = exports.CorruptSaveError = exports.CompressionLibraryError = exports.SaveWriter = exports.SaveReader = exports.BlueprintWriter = exports.BlueprintConfigWriter = exports.BlueprintReader = exports.BlueprintConfigReader = exports.SaveEntity = exports.SaveComponent = exports.ObjectReference = exports.DataFields = exports.Level = void 0; | ||
// types & classes for convenience | ||
export { Level } from './parser/satisfactory/level.class'; | ||
export { DataFields } from './parser/satisfactory/objects/DataFields'; | ||
export { ObjectReference } from './parser/satisfactory/objects/ObjectReference'; | ||
export * from './parser/satisfactory/objects/Property'; | ||
export { SaveComponent } from './parser/satisfactory/objects/SaveComponent'; | ||
// should better be removed | ||
export { SaveEntity } from './parser/satisfactory/objects/SaveEntity'; | ||
var level_class_1 = require("./parser/satisfactory/level.class"); | ||
Object.defineProperty(exports, "Level", { enumerable: true, get: function () { return level_class_1.Level; } }); | ||
var DataFields_1 = require("./parser/satisfactory/objects/DataFields"); | ||
Object.defineProperty(exports, "DataFields", { enumerable: true, get: function () { return DataFields_1.DataFields; } }); | ||
var ObjectReference_1 = require("./parser/satisfactory/objects/ObjectReference"); | ||
Object.defineProperty(exports, "ObjectReference", { enumerable: true, get: function () { return ObjectReference_1.ObjectReference; } }); | ||
__exportStar(require("./parser/satisfactory/objects/Property"), exports); | ||
var SaveComponent_1 = require("./parser/satisfactory/objects/SaveComponent"); | ||
Object.defineProperty(exports, "SaveComponent", { enumerable: true, get: function () { return SaveComponent_1.SaveComponent; } }); | ||
var SaveEntity_1 = require("./parser/satisfactory/objects/SaveEntity"); | ||
Object.defineProperty(exports, "SaveEntity", { enumerable: true, get: function () { return SaveEntity_1.SaveEntity; } }); | ||
// should better be removed in a future update to prevent shenanigans. | ||
var blueprint_reader_1 = require("./parser/blueprint-reader"); | ||
Object.defineProperty(exports, "BlueprintConfigReader", { enumerable: true, get: function () { return blueprint_reader_1.BlueprintConfigReader; } }); | ||
Object.defineProperty(exports, "BlueprintReader", { enumerable: true, get: function () { return blueprint_reader_1.BlueprintReader; } }); | ||
var blueprint_writer_1 = require("./parser/blueprint-writer"); | ||
Object.defineProperty(exports, "BlueprintConfigWriter", { enumerable: true, get: function () { return blueprint_writer_1.BlueprintConfigWriter; } }); | ||
Object.defineProperty(exports, "BlueprintWriter", { enumerable: true, get: function () { return blueprint_writer_1.BlueprintWriter; } }); | ||
var save_reader_1 = require("./parser/save-reader"); | ||
Object.defineProperty(exports, "SaveReader", { enumerable: true, get: function () { return save_reader_1.SaveReader; } }); | ||
var save_writer_1 = require("./parser/save-writer"); | ||
Object.defineProperty(exports, "SaveWriter", { enumerable: true, get: function () { return save_writer_1.SaveWriter; } }); | ||
// errors | ||
export { CompressionLibraryError, CorruptSaveError, ParserError, UnsupportedVersionError } from './parser/error/parser.error'; | ||
var parser_error_1 = require("./parser/error/parser.error"); | ||
Object.defineProperty(exports, "CompressionLibraryError", { enumerable: true, get: function () { return parser_error_1.CompressionLibraryError; } }); | ||
Object.defineProperty(exports, "CorruptSaveError", { enumerable: true, get: function () { return parser_error_1.CorruptSaveError; } }); | ||
Object.defineProperty(exports, "ParserError", { enumerable: true, get: function () { return parser_error_1.ParserError; } }); | ||
Object.defineProperty(exports, "UnsupportedVersionError", { enumerable: true, get: function () { return parser_error_1.UnsupportedVersionError; } }); | ||
// facade | ||
export { SaveParser } from './parser/parser'; | ||
var parser_1 = require("./parser/parser"); | ||
Object.defineProperty(exports, "SaveParser", { enumerable: true, get: function () { return parser_1.SaveParser; } }); |
@@ -1,10 +0,16 @@ | ||
import Pako from "pako"; | ||
import { Alignment } from "./byte/alignment.enum"; | ||
import { ByteReader } from "./byte/byte-reader.class"; | ||
import { ParserError } from "./error/parser.error"; | ||
import { Level } from "./satisfactory/level.class"; | ||
import { ParseCol4RGBA, ParseVec3 } from "./satisfactory/structs/util.types"; | ||
export class BlueprintReader extends ByteReader { | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BlueprintConfigReader = exports.BlueprintReader = void 0; | ||
const pako_1 = __importDefault(require("pako")); | ||
const alignment_enum_1 = require("./byte/alignment.enum"); | ||
const byte_reader_class_1 = require("./byte/byte-reader.class"); | ||
const parser_error_1 = require("./error/parser.error"); | ||
const level_class_1 = require("./satisfactory/level.class"); | ||
const util_types_1 = require("./satisfactory/structs/util.types"); | ||
class BlueprintReader extends byte_reader_class_1.ByteReader { | ||
constructor(bluePrintBuffer) { | ||
super(bluePrintBuffer, Alignment.LITTLE_ENDIAN); | ||
super(bluePrintBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.compressionInfo = { | ||
@@ -18,3 +24,3 @@ packageFileTag: 0, | ||
const unk = reader.readBytes(3 * 4); // 02 00 00 00, 24 00 00 00, 7F 3B 03 00 - always | ||
const positionThingOrWhat = ParseVec3(reader); // 04 00 00 00, 04 00 00 00, 04 00 00 00 - always | ||
const positionThingOrWhat = (0, util_types_1.ParseVec3)(reader); // 04 00 00 00, 04 00 00 00, 04 00 00 00 - always | ||
// list of item costs. | ||
@@ -57,9 +63,9 @@ let itemTypeCount = reader.readInt32(); | ||
if (this.compressionInfo.packageFileTag <= 0) { | ||
this.compressionInfo.packageFileTag = chunkHeader.getUint32(0, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.compressionInfo.packageFileTag = chunkHeader.getUint32(0, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
if (this.compressionInfo.maxChunkContentSize <= 0) { | ||
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === Alignment.LITTLE_ENDIAN); //00 00 02 00 = 131072 | ||
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); //00 00 02 00 = 131072 | ||
} | ||
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === Alignment.LITTLE_ENDIAN); | ||
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === Alignment.LITTLE_ENDIAN); | ||
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
totalUncompressedBodySize += chunkUncompressedLength; | ||
@@ -76,7 +82,7 @@ const currentChunkSize = chunkCompressedLength; | ||
let currentInflatedChunk = null; | ||
currentInflatedChunk = Pako.inflate(currentChunk); | ||
currentInflatedChunk = pako_1.default.inflate(currentChunk); | ||
currentChunks.push(currentInflatedChunk); | ||
} | ||
catch (err) { | ||
throw new ParserError('ParserError', 'An error occurred while calling pako inflate.' + err); | ||
throw new parser_error_1.ParserError('ParserError', 'An error occurred while calling pako inflate.' + err); | ||
} | ||
@@ -108,11 +114,12 @@ } | ||
let objects = []; | ||
Level.ReadObjectHeaders(reader, objects, () => { }); | ||
level_class_1.Level.ReadObjectHeaders(reader, objects, () => { }); | ||
// objects contents | ||
Level.ReadObjectContents(reader, objects, 0, () => { }); | ||
level_class_1.Level.ReadObjectContents(reader, objects, 0, () => { }); | ||
return objects; | ||
} | ||
} | ||
export class BlueprintConfigReader extends ByteReader { | ||
exports.BlueprintReader = BlueprintReader; | ||
class BlueprintConfigReader extends byte_reader_class_1.ByteReader { | ||
constructor(bluePrintConfigBuffer) { | ||
super(bluePrintConfigBuffer, Alignment.LITTLE_ENDIAN); | ||
super(bluePrintConfigBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.bluePrintConfigBuffer = bluePrintConfigBuffer; | ||
@@ -125,3 +132,3 @@ this.parse = () => BlueprintConfigReader.ParseConfig(this); | ||
const unk3 = reader.readInt32(); // iconID. default is 0x0E03 = 782 | ||
const colorMaybe = ParseCol4RGBA(reader); // LinearColor, which is 4x float32 as RGBA | ||
const colorMaybe = (0, util_types_1.ParseCol4RGBA)(reader); // LinearColor, which is 4x float32 as RGBA | ||
return { | ||
@@ -134,1 +141,2 @@ description, | ||
} | ||
exports.BlueprintConfigReader = BlueprintConfigReader; |
@@ -1,10 +0,13 @@ | ||
import { Level } from "../parser/satisfactory/level.class"; | ||
import { SerializeCol4RGBA } from "../parser/satisfactory/structs/util.types"; | ||
import { Alignment } from "./byte/alignment.enum"; | ||
import { ByteWriter } from "./byte/byte-writer.class"; | ||
import { ParserError } from "./error/parser.error"; | ||
import { SaveWriter } from "./save-writer"; | ||
export class BlueprintWriter extends ByteWriter { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BlueprintConfigWriter = exports.BlueprintWriter = void 0; | ||
const level_class_1 = require("../parser/satisfactory/level.class"); | ||
const util_types_1 = require("../parser/satisfactory/structs/util.types"); | ||
const alignment_enum_1 = require("./byte/alignment.enum"); | ||
const byte_writer_class_1 = require("./byte/byte-writer.class"); | ||
const parser_error_1 = require("./error/parser.error"); | ||
const save_writer_1 = require("./save-writer"); | ||
class BlueprintWriter extends byte_writer_class_1.ByteWriter { | ||
constructor() { | ||
super(Alignment.LITTLE_ENDIAN); | ||
super(alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
@@ -35,3 +38,3 @@ static SerializeHeader(writer, header) { | ||
if (posAfterHeader <= 0) { | ||
throw new ParserError('ParserError', 'seems like this buffer has no header. Please write the header first before you can generate chunks.'); | ||
throw new parser_error_1.ParserError('ParserError', 'seems like this buffer has no header. Please write the header first before you can generate chunks.'); | ||
} | ||
@@ -43,3 +46,3 @@ // send plain header first. | ||
this.bufferArray = this.bufferArray.slice(posAfterHeader); | ||
SaveWriter.GenerateCompressedChunksFromData(this.bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, this.alignment); | ||
save_writer_1.SaveWriter.GenerateCompressedChunksFromData(this.bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, this.alignment); | ||
} | ||
@@ -50,11 +53,12 @@ static SerializeObjects(writer, objects) { | ||
writer.writeInt32(0); | ||
Level.SerializeObjectHeaders(writer, objects); | ||
level_class_1.Level.SerializeObjectHeaders(writer, objects); | ||
writer.writeBinarySizeFromPosition(headersLenIndicator, headersLenIndicator + 4); | ||
// objects contents | ||
Level.SerializeObjectContents(writer, objects, 0); | ||
level_class_1.Level.SerializeObjectContents(writer, objects, 0); | ||
} | ||
} | ||
export class BlueprintConfigWriter extends ByteWriter { | ||
exports.BlueprintWriter = BlueprintWriter; | ||
class BlueprintConfigWriter extends byte_writer_class_1.ByteWriter { | ||
constructor() { | ||
super(Alignment.LITTLE_ENDIAN); | ||
super(alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
@@ -65,4 +69,5 @@ static SerializeConfig(writer, config) { | ||
writer.writeInt32(config.iconID); | ||
SerializeCol4RGBA(writer, config.color); | ||
(0, util_types_1.SerializeCol4RGBA)(writer, config.color); | ||
} | ||
} | ||
exports.BlueprintConfigWriter = BlueprintConfigWriter; |
@@ -1,5 +0,8 @@ | ||
export var Alignment; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Alignment = void 0; | ||
var Alignment; | ||
(function (Alignment) { | ||
Alignment[Alignment["BIG_ENDIAN"] = 0] = "BIG_ENDIAN"; | ||
Alignment[Alignment["LITTLE_ENDIAN"] = 1] = "LITTLE_ENDIAN"; | ||
})(Alignment || (Alignment = {})); | ||
})(Alignment = exports.Alignment || (exports.Alignment = {})); |
@@ -1,3 +0,6 @@ | ||
import { Alignment } from "./alignment.enum"; | ||
export class ByteReader { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ByteReader = void 0; | ||
const alignment_enum_1 = require("./alignment.enum"); | ||
class ByteReader { | ||
constructor(fileBuffer, alignment) { | ||
@@ -57,3 +60,3 @@ this.currentByte = 0; | ||
readUint16() { | ||
let data = this.bufferView.getUint16(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getUint16(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 2; | ||
@@ -63,3 +66,3 @@ return data; | ||
readInt32() { | ||
let data = this.bufferView.getInt32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -69,3 +72,3 @@ return data; | ||
readUint32() { | ||
let data = this.bufferView.getUint32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getUint32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -75,3 +78,3 @@ return data; | ||
readLong() { | ||
let data = this.bufferView.getBigInt64(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getBigInt64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 8; | ||
@@ -81,3 +84,3 @@ return data; | ||
readFloat() { | ||
let data = this.bufferView.getFloat32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getFloat32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -87,3 +90,3 @@ return data; | ||
readDouble() { | ||
let data = this.bufferView.getFloat64(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let data = this.bufferView.getFloat64(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 8; | ||
@@ -96,3 +99,3 @@ return data; | ||
try { | ||
let strLength = this.bufferView.getInt32(this.currentByte, this.alignment === Alignment.LITTLE_ENDIAN); | ||
let strLength = this.bufferView.getInt32(this.currentByte, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
counter += 4; | ||
@@ -136,1 +139,2 @@ payload = new Array(strLength - 1).fill('').map(c => String.fromCharCode(this.bufferView.getUint8(counter++))).join(''); | ||
} | ||
exports.ByteReader = ByteReader; |
@@ -1,2 +0,5 @@ | ||
import { Alignment } from "./alignment.enum"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ByteWriter = void 0; | ||
const alignment_enum_1 = require("./alignment.enum"); | ||
class ByteWriter { | ||
@@ -44,3 +47,3 @@ constructor(alignment, bufferSize = 500) { | ||
this.extendBufferIfNeeded(2); | ||
this.bufferView.setInt16(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setInt16(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 2; | ||
@@ -50,3 +53,3 @@ } | ||
this.extendBufferIfNeeded(2); | ||
this.bufferView.setUint16(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setUint16(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 2; | ||
@@ -56,3 +59,3 @@ } | ||
this.extendBufferIfNeeded(4); | ||
this.bufferView.setInt32(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setInt32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -62,3 +65,3 @@ } | ||
this.extendBufferIfNeeded(4); | ||
this.bufferView.setUint32(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setUint32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -68,3 +71,3 @@ } | ||
this.extendBufferIfNeeded(8); | ||
this.bufferView.setBigInt64(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setBigInt64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 8; | ||
@@ -74,3 +77,3 @@ } | ||
this.extendBufferIfNeeded(8); | ||
this.bufferView.setBigUint64(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setBigUint64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 8; | ||
@@ -80,3 +83,3 @@ } | ||
this.extendBufferIfNeeded(4); | ||
this.bufferView.setFloat32(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setFloat32(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 4; | ||
@@ -86,3 +89,3 @@ } | ||
this.extendBufferIfNeeded(8); | ||
this.bufferView.setFloat64(this.currentByte, value, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.bufferView.setFloat64(this.currentByte, value, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.currentByte += 8; | ||
@@ -154,2 +157,2 @@ } | ||
ByteWriter.IsASCIICompatible = (value) => /^[\x00-\x7F]*$/.test(value); | ||
export { ByteWriter }; | ||
exports.ByteWriter = ByteWriter; |
@@ -1,2 +0,5 @@ | ||
export class ParserError extends Error { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CompressionLibraryError = exports.CorruptSaveError = exports.UnsupportedVersionError = exports.ParserError = void 0; | ||
class ParserError extends Error { | ||
constructor(name, message) { | ||
@@ -7,3 +10,4 @@ super(message); | ||
} | ||
export class UnsupportedVersionError extends ParserError { | ||
exports.ParserError = ParserError; | ||
class UnsupportedVersionError extends ParserError { | ||
constructor(message) { | ||
@@ -13,3 +17,4 @@ super('UnsupportedVersionError', message ?? 'This save version is not supported.'); | ||
} | ||
export class CorruptSaveError extends ParserError { | ||
exports.UnsupportedVersionError = UnsupportedVersionError; | ||
class CorruptSaveError extends ParserError { | ||
constructor(message) { | ||
@@ -19,3 +24,4 @@ super('CorruptSaveError', message ?? 'This save data is most likely corrupt.'); | ||
} | ||
export class CompressionLibraryError extends ParserError { | ||
exports.CorruptSaveError = CorruptSaveError; | ||
class CompressionLibraryError extends ParserError { | ||
constructor(message) { | ||
@@ -25,1 +31,2 @@ super('CompressionLibraryError', message ?? 'Failed to compress/decompress save data.'); | ||
} | ||
exports.CompressionLibraryError = CompressionLibraryError; |
@@ -1,5 +0,8 @@ | ||
import { Level } from "./satisfactory/level.class"; | ||
import { SatisfactorySave } from "./satisfactory/satisfactory-save"; | ||
import { SaveReader, projectionFilterApplies } from "./save-reader"; | ||
import { SaveWriter } from "./save-writer"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveParser = void 0; | ||
const level_class_1 = require("./satisfactory/level.class"); | ||
const satisfactory_save_1 = require("./satisfactory/satisfactory-save"); | ||
const save_reader_1 = require("./save-reader"); | ||
const save_writer_1 = require("./save-writer"); | ||
class SaveParser { | ||
@@ -15,6 +18,6 @@ /** | ||
static WriteSave(save, onBinaryBeforeCompressing, onHeader, onChunk, onFinish) { | ||
const writer = new SaveWriter(); | ||
SaveWriter.WriteHeader(writer, save.header); | ||
const writer = new save_writer_1.SaveWriter(); | ||
save_writer_1.SaveWriter.WriteHeader(writer, save.header); | ||
const posAfterHeader = writer.getBufferPosition(); | ||
SaveWriter.WriteLevels(writer, save, save.header.buildVersion); | ||
save_writer_1.SaveWriter.WriteLevels(writer, save, save.header.buildVersion); | ||
writer.endWriting(); | ||
@@ -31,6 +34,6 @@ writer.generateChunks(save.compressionInfo, posAfterHeader, onBinaryBeforeCompressing, onHeader, onChunk, onFinish); | ||
static ParseSaveFile(file, onSaveDecompressed = () => { }, onProgress = () => { }) { | ||
const reader = new SaveReader(file.buffer, onProgress); | ||
const reader = new save_reader_1.SaveReader(file.buffer, onProgress); | ||
// read header | ||
const header = reader.readHeader(); | ||
const save = new SatisfactorySave(header); | ||
const save = new satisfactory_save_1.SatisfactorySave(header); | ||
// inflate chunks | ||
@@ -58,5 +61,5 @@ const inflateResult = reader.inflateChunks(); | ||
levels: save.levels.map(level => { | ||
const lvl = new Level(level.name); | ||
const lvl = new level_class_1.Level(level.name); | ||
lvl.collectables = level.collectables; | ||
lvl.objects = level.objects.filter(obj => projectionFilterApplies(config, obj)); | ||
lvl.objects = level.objects.filter(obj => (0, save_reader_1.projectionFilterApplies)(config, obj)); | ||
return lvl; | ||
@@ -84,2 +87,2 @@ }) | ||
}, indent); | ||
export { SaveParser }; | ||
exports.SaveParser = SaveParser; |
@@ -1,1 +0,2 @@ | ||
export {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,5 +0,8 @@ | ||
import { ObjectReference } from "./objects/ObjectReference"; | ||
import { isSaveComponent, SaveComponent } from "./objects/SaveComponent"; | ||
import { isSaveEntity, SaveEntity } from "./objects/SaveEntity"; | ||
export class Level { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Level = void 0; | ||
const ObjectReference_1 = require("./objects/ObjectReference"); | ||
const SaveComponent_1 = require("./objects/SaveComponent"); | ||
const SaveEntity_1 = require("./objects/SaveEntity"); | ||
class Level { | ||
constructor(name) { | ||
@@ -15,8 +18,8 @@ this.name = name; | ||
case 'SaveEntity': | ||
writer.writeInt32(SaveEntity.TypeID); | ||
SaveEntity.SerializeHeader(writer, obj); | ||
writer.writeInt32(SaveEntity_1.SaveEntity.TypeID); | ||
SaveEntity_1.SaveEntity.SerializeHeader(writer, obj); | ||
break; | ||
case 'SaveComponent': | ||
writer.writeInt32(SaveComponent.TypeID); | ||
SaveComponent.SerializeHeader(writer, obj); | ||
writer.writeInt32(SaveComponent_1.SaveComponent.TypeID); | ||
SaveComponent_1.SaveComponent.SerializeHeader(writer, obj); | ||
break; | ||
@@ -47,7 +50,7 @@ default: | ||
writer.writeInt32(0); | ||
if (isSaveEntity(obj)) { | ||
SaveEntity.SerializeData(writer, obj, buildVersion); | ||
if ((0, SaveEntity_1.isSaveEntity)(obj)) { | ||
SaveEntity_1.SaveEntity.SerializeData(writer, obj, buildVersion); | ||
} | ||
else if (isSaveComponent(obj)) { | ||
SaveComponent.SerializeData(writer, obj, buildVersion); | ||
else if ((0, SaveComponent_1.isSaveComponent)(obj)) { | ||
SaveComponent_1.SaveComponent.SerializeData(writer, obj, buildVersion); | ||
} | ||
@@ -66,10 +69,10 @@ writer.writeBinarySizeFromPosition(lenReplacementPosition, lenReplacementPosition + 4); | ||
switch (objectType) { | ||
case SaveEntity.TypeID: | ||
let object = new SaveEntity('', '', '', ''); | ||
SaveEntity.ParseHeader(reader, object); | ||
case SaveEntity_1.SaveEntity.TypeID: | ||
let object = new SaveEntity_1.SaveEntity('', '', '', ''); | ||
SaveEntity_1.SaveEntity.ParseHeader(reader, object); | ||
objectsList.push(object); | ||
break; | ||
case SaveComponent.TypeID: | ||
let component = new SaveComponent('', '', '', ''); | ||
SaveComponent.ParseHeader(reader, component); | ||
case SaveComponent_1.SaveComponent.TypeID: | ||
let component = new SaveComponent_1.SaveComponent('', '', '', ''); | ||
SaveComponent_1.SaveComponent.ParseHeader(reader, component); | ||
objectsList.push(component); | ||
@@ -98,7 +101,7 @@ break; | ||
const obj = objectsList[i]; | ||
if (isSaveEntity(obj)) { | ||
SaveEntity.ParseData(obj, len, reader, buildVersion); | ||
if ((0, SaveEntity_1.isSaveEntity)(obj)) { | ||
SaveEntity_1.SaveEntity.ParseData(obj, len, reader, buildVersion); | ||
} | ||
else if (isSaveComponent(obj)) { | ||
SaveComponent.ParseData(obj, len, reader, buildVersion); | ||
else if ((0, SaveComponent_1.isSaveComponent)(obj)) { | ||
SaveComponent_1.SaveComponent.ParseData(obj, len, reader, buildVersion); | ||
} | ||
@@ -135,3 +138,3 @@ const after = reader.getBufferPosition(); | ||
for (const collectable of collectables) { | ||
ObjectReference.Serialize(writer, collectable); | ||
ObjectReference_1.ObjectReference.Serialize(writer, collectable); | ||
} | ||
@@ -144,3 +147,3 @@ } | ||
for (let i = 0; i < countCollected; i++) { | ||
const collectable = ObjectReference.Parse(reader); | ||
const collectable = ObjectReference_1.ObjectReference.Parse(reader); | ||
collected.push(collectable); | ||
@@ -151,1 +154,2 @@ } | ||
} | ||
exports.Level = Level; |
@@ -1,3 +0,6 @@ | ||
import { ArrayProperty, BoolProperty, ByteProperty, DoubleProperty, EnumProperty, FloatProperty, Int32Property, Int64Property, Int8Property, MapProperty, ObjectProperty, SetProperty, StrProperty, StructProperty, TextProperty, Uint32Property, Uint8Property } from "./Property"; | ||
export class DataFields { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DataFields = void 0; | ||
const Property_1 = require("./Property"); | ||
class DataFields { | ||
constructor() { | ||
@@ -55,29 +58,29 @@ this.properties = []; | ||
case 'BoolProperty': | ||
currentProperty = BoolProperty.Parse(reader, propertyType, index); | ||
overhead = BoolProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.BoolProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.BoolProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'ByteProperty': | ||
currentProperty = ByteProperty.Parse(reader, propertyType, index); | ||
overhead = ByteProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.ByteProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.ByteProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'Int8Property': | ||
currentProperty = Int8Property.Parse(reader, propertyType, index); | ||
overhead = Int8Property.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.Int8Property.Parse(reader, propertyType, index); | ||
overhead = Property_1.Int8Property.CalcOverhead(currentProperty); | ||
break; | ||
case 'UInt8Property': | ||
currentProperty = Uint8Property.Parse(reader, propertyType, index); | ||
overhead = Uint8Property.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.Uint8Property.Parse(reader, propertyType, index); | ||
overhead = Property_1.Uint8Property.CalcOverhead(currentProperty); | ||
break; | ||
case 'IntProperty': | ||
case 'Int32Property': | ||
currentProperty = Int32Property.Parse(reader, propertyType, index); | ||
overhead = Int32Property.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.Int32Property.Parse(reader, propertyType, index); | ||
overhead = Property_1.Int32Property.CalcOverhead(currentProperty); | ||
break; | ||
case 'UInt32Property': | ||
currentProperty = Uint32Property.Parse(reader, propertyType, index); | ||
overhead = Uint32Property.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.Uint32Property.Parse(reader, propertyType, index); | ||
overhead = Property_1.Uint32Property.CalcOverhead(currentProperty); | ||
break; | ||
case 'Int64Property': | ||
currentProperty = Int64Property.Parse(reader, propertyType, index); | ||
overhead = Int64Property.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.Int64Property.Parse(reader, propertyType, index); | ||
overhead = Property_1.Int64Property.CalcOverhead(currentProperty); | ||
break; | ||
@@ -92,43 +95,43 @@ // TODO | ||
case 'FloatProperty': | ||
currentProperty = FloatProperty.Parse(reader, propertyType, index); | ||
overhead = FloatProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.FloatProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.FloatProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'DoubleProperty': | ||
currentProperty = DoubleProperty.Parse(reader, propertyType, index); | ||
overhead = DoubleProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.DoubleProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.DoubleProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'StrProperty': | ||
case 'NameProperty': | ||
currentProperty = StrProperty.Parse(reader, propertyType, index); | ||
overhead = StrProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.StrProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.StrProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'ObjectProperty': | ||
case 'InterfaceProperty': | ||
currentProperty = ObjectProperty.Parse(reader, propertyType, index); | ||
overhead = ObjectProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.ObjectProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.ObjectProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'EnumProperty': | ||
currentProperty = EnumProperty.Parse(reader, propertyType, index); | ||
overhead = EnumProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.EnumProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.EnumProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'StructProperty': | ||
currentProperty = StructProperty.Parse(reader, propertyType, index, binarySize); | ||
overhead = StructProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.StructProperty.Parse(reader, propertyType, index, binarySize); | ||
overhead = Property_1.StructProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'ArrayProperty': | ||
currentProperty = ArrayProperty.Parse(reader, propertyType, index, propertyName); | ||
overhead = ArrayProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.ArrayProperty.Parse(reader, propertyType, index, propertyName); | ||
overhead = Property_1.ArrayProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'MapProperty': | ||
//currentProperty = reader.readMapProperty(currentProperty, ''); | ||
currentProperty = MapProperty.Parse(reader, propertyName, buildVersion, binarySize); | ||
overhead = MapProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.MapProperty.Parse(reader, propertyName, buildVersion, binarySize); | ||
overhead = Property_1.MapProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'TextProperty': | ||
currentProperty = TextProperty.Parse(reader, propertyType, index); | ||
overhead = TextProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.TextProperty.Parse(reader, propertyType, index); | ||
overhead = Property_1.TextProperty.CalcOverhead(currentProperty); | ||
break; | ||
case 'SetProperty': | ||
currentProperty = SetProperty.Parse(reader, propertyType, index, propertyName); | ||
overhead = SetProperty.CalcOverhead(currentProperty); | ||
currentProperty = Property_1.SetProperty.Parse(reader, propertyType, index, propertyName); | ||
overhead = Property_1.SetProperty.CalcOverhead(currentProperty); | ||
break; | ||
@@ -165,29 +168,29 @@ default: | ||
case 'BoolProperty': | ||
overhead = BoolProperty.CalcOverhead(property); | ||
BoolProperty.Serialize(writer, property); | ||
overhead = Property_1.BoolProperty.CalcOverhead(property); | ||
Property_1.BoolProperty.Serialize(writer, property); | ||
break; | ||
case 'ByteProperty': | ||
overhead = ByteProperty.CalcOverhead(property); | ||
ByteProperty.Serialize(writer, property); | ||
overhead = Property_1.ByteProperty.CalcOverhead(property); | ||
Property_1.ByteProperty.Serialize(writer, property); | ||
break; | ||
case 'Int8Property': | ||
overhead = Int8Property.CalcOverhead(property); | ||
Int8Property.Serialize(writer, property); | ||
overhead = Property_1.Int8Property.CalcOverhead(property); | ||
Property_1.Int8Property.Serialize(writer, property); | ||
break; | ||
case 'UInt8Property': | ||
overhead = Uint8Property.CalcOverhead(property); | ||
Uint8Property.Serialize(writer, property); | ||
overhead = Property_1.Uint8Property.CalcOverhead(property); | ||
Property_1.Uint8Property.Serialize(writer, property); | ||
break; | ||
case 'IntProperty': | ||
case 'Int32Property': | ||
overhead = Int32Property.CalcOverhead(property); | ||
Int32Property.Serialize(writer, property); | ||
overhead = Property_1.Int32Property.CalcOverhead(property); | ||
Property_1.Int32Property.Serialize(writer, property); | ||
break; | ||
case 'UInt32Property': | ||
overhead = Uint32Property.CalcOverhead(property); | ||
Uint32Property.Serialize(writer, property); | ||
overhead = Property_1.Uint32Property.CalcOverhead(property); | ||
Property_1.Uint32Property.Serialize(writer, property); | ||
break; | ||
case 'Int64Property': | ||
overhead = Int64Property.CalcOverhead(property); | ||
Int64Property.Serialize(writer, property); | ||
overhead = Property_1.Int64Property.CalcOverhead(property); | ||
Property_1.Int64Property.Serialize(writer, property); | ||
break; | ||
@@ -197,46 +200,46 @@ // TODO: uint64Property | ||
case 'FloatProperty': | ||
overhead = FloatProperty.CalcOverhead(property); | ||
FloatProperty.Serialize(writer, property); | ||
overhead = Property_1.FloatProperty.CalcOverhead(property); | ||
Property_1.FloatProperty.Serialize(writer, property); | ||
break; | ||
case 'DoubleProperty': | ||
overhead = DoubleProperty.CalcOverhead(property); | ||
DoubleProperty.Serialize(writer, property); | ||
overhead = Property_1.DoubleProperty.CalcOverhead(property); | ||
Property_1.DoubleProperty.Serialize(writer, property); | ||
break; | ||
case 'StrProperty': | ||
case 'NameProperty': | ||
overhead = StrProperty.CalcOverhead(property); | ||
StrProperty.Serialize(writer, property); | ||
overhead = Property_1.StrProperty.CalcOverhead(property); | ||
Property_1.StrProperty.Serialize(writer, property); | ||
break; | ||
case 'ObjectProperty': | ||
case 'InterfaceProperty': | ||
overhead = ObjectProperty.CalcOverhead(property); | ||
ObjectProperty.Serialize(writer, property); | ||
overhead = Property_1.ObjectProperty.CalcOverhead(property); | ||
Property_1.ObjectProperty.Serialize(writer, property); | ||
break; | ||
case 'EnumProperty': | ||
overhead = EnumProperty.CalcOverhead(property); | ||
EnumProperty.Serialize(writer, property); | ||
overhead = Property_1.EnumProperty.CalcOverhead(property); | ||
Property_1.EnumProperty.Serialize(writer, property); | ||
break; | ||
case 'ByteProperty': | ||
overhead = ByteProperty.CalcOverhead(property); | ||
ByteProperty.Serialize(writer, property); | ||
overhead = Property_1.ByteProperty.CalcOverhead(property); | ||
Property_1.ByteProperty.Serialize(writer, property); | ||
break; | ||
case 'StructProperty': | ||
overhead = StructProperty.CalcOverhead(property); | ||
StructProperty.Serialize(writer, property); | ||
overhead = Property_1.StructProperty.CalcOverhead(property); | ||
Property_1.StructProperty.Serialize(writer, property); | ||
break; | ||
case 'ArrayProperty': | ||
overhead = ArrayProperty.CalcOverhead(property); | ||
ArrayProperty.Serialize(writer, property, propertyName); | ||
overhead = Property_1.ArrayProperty.CalcOverhead(property); | ||
Property_1.ArrayProperty.Serialize(writer, property, propertyName); | ||
break; | ||
case 'MapProperty': | ||
overhead = MapProperty.CalcOverhead(property); | ||
MapProperty.Serialize(writer, property); | ||
overhead = Property_1.MapProperty.CalcOverhead(property); | ||
Property_1.MapProperty.Serialize(writer, property); | ||
break; | ||
case 'TextProperty': | ||
overhead = TextProperty.CalcOverhead(property); | ||
TextProperty.Serialize(writer, property); | ||
overhead = Property_1.TextProperty.CalcOverhead(property); | ||
Property_1.TextProperty.Serialize(writer, property); | ||
break; | ||
case 'SetProperty': | ||
overhead = SetProperty.CalcOverhead(property); | ||
SetProperty.Serialize(writer, property); | ||
overhead = Property_1.SetProperty.CalcOverhead(property); | ||
Property_1.SetProperty.Serialize(writer, property); | ||
break; | ||
@@ -250,1 +253,2 @@ default: | ||
} | ||
exports.DataFields = DataFields; |
@@ -1,2 +0,5 @@ | ||
export class ObjectReference { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ObjectReference = void 0; | ||
class ObjectReference { | ||
constructor(levelName, pathName) { | ||
@@ -14,1 +17,2 @@ this.levelName = levelName; | ||
} | ||
exports.ObjectReference = ObjectReference; |
@@ -1,5 +0,8 @@ | ||
import { ParseCol4BGRA, ParseCol4RGBA, ParseVec3, ParseVec4, SerializeCol4BGRA, SerializeCol4RGBA, SerializeVec3, SerializeVec4 } from "../structs/util.types"; | ||
import { DataFields } from "./DataFields"; | ||
import { ObjectReference } from "./ObjectReference"; | ||
export class AbstractProperty { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SerializeFINLuaProcessorStateStorage = exports.ReadFINLuaProcessorStateStorage = exports.SerializeFINNetworkTrace = exports.ReadFINNetworkTrace = exports.SerializeDynamicStructData = exports.ParseDynamicStructData = exports.MapProperty = exports.SetProperty = exports.ArrayProperty = exports.StructProperty = exports.TextProperty = exports.EnumProperty = exports.ObjectProperty = exports.StrProperty = exports.DoubleProperty = exports.FloatProperty = exports.Int64Property = exports.Uint32Property = exports.Int32Property = exports.Uint8Property = exports.Int8Property = exports.ByteProperty = exports.BoolProperty = exports.SerializeGUID = exports.ParseGUID = exports.BasicProperty = exports.AbstractBaseProperty = exports.AbstractProperty = void 0; | ||
const util_types_1 = require("../structs/util.types"); | ||
const DataFields_1 = require("./DataFields"); | ||
const ObjectReference_1 = require("./ObjectReference"); | ||
class AbstractProperty { | ||
constructor(type, index) { | ||
@@ -10,3 +13,4 @@ this.type = type; | ||
} | ||
export class AbstractBaseProperty extends AbstractProperty { | ||
exports.AbstractProperty = AbstractProperty; | ||
class AbstractBaseProperty extends AbstractProperty { | ||
// overhead like Guid is not calculated into property size | ||
@@ -19,3 +23,4 @@ constructor(type, ueType, index) { | ||
} | ||
export class BasicProperty extends AbstractBaseProperty { | ||
exports.AbstractBaseProperty = AbstractBaseProperty; | ||
class BasicProperty extends AbstractBaseProperty { | ||
constructor(type, ueType, guidInfo, index = 0) { | ||
@@ -26,3 +31,4 @@ super(type, ueType, index); | ||
} | ||
export const ParseGUID = (reader) => { | ||
exports.BasicProperty = BasicProperty; | ||
const ParseGUID = (reader) => { | ||
const hasGuid = reader.readByte() === 1; | ||
@@ -36,3 +42,4 @@ let guid; | ||
}; | ||
export const SerializeGUID = (writer, guid) => { | ||
exports.ParseGUID = ParseGUID; | ||
const SerializeGUID = (writer, guid) => { | ||
writer.writeByte(guid ? 1 : 0); | ||
@@ -43,3 +50,4 @@ if (guid) { | ||
}; | ||
export class BoolProperty extends BasicProperty { | ||
exports.SerializeGUID = SerializeGUID; | ||
class BoolProperty extends BasicProperty { | ||
constructor(value, ueType = 'BoolProperty', guidInfo = undefined, index = 0) { | ||
@@ -51,3 +59,3 @@ super('BoolProperty', ueType, guidInfo, index); | ||
const value = BoolProperty.ReadValue(reader); | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
return new BoolProperty(value, ueType, guidInfo, index); | ||
@@ -63,3 +71,3 @@ } | ||
BoolProperty.SerializeValue(writer, property.value); | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
} | ||
@@ -70,3 +78,4 @@ static SerializeValue(writer, value) { | ||
} | ||
export class ByteProperty extends BasicProperty { | ||
exports.BoolProperty = BoolProperty; | ||
class ByteProperty extends BasicProperty { | ||
constructor(value, ueType = 'ByteProperty', guidInfo = undefined, index = 0) { | ||
@@ -78,3 +87,3 @@ super('ByteProperty', ueType, guidInfo, index); | ||
const type = reader.readString(); | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
let value; | ||
@@ -104,3 +113,3 @@ if (type === 'None') { | ||
writer.writeString(property.value.type); | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
if (property.value.type === 'None') { | ||
@@ -117,3 +126,4 @@ ByteProperty.SerializeValue(writer, property.value.value); | ||
} | ||
export class Int8Property extends BasicProperty { | ||
exports.ByteProperty = ByteProperty; | ||
class Int8Property extends BasicProperty { | ||
constructor(value, ueType = 'Int8Property', guidInfo = undefined, index = 0) { | ||
@@ -124,3 +134,3 @@ super('Int8Property', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = Int8Property.ReadValue(reader); | ||
@@ -136,3 +146,3 @@ return new Int8Property(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
Int8Property.SerializeValue(writer, property.value); | ||
@@ -144,3 +154,4 @@ } | ||
} | ||
export class Uint8Property extends BasicProperty { | ||
exports.Int8Property = Int8Property; | ||
class Uint8Property extends BasicProperty { | ||
constructor(value, ueType = 'UInt8Property', guidInfo = undefined, index = 0) { | ||
@@ -151,3 +162,3 @@ super('UInt8Property', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = Uint8Property.ReadValue(reader); | ||
@@ -163,3 +174,3 @@ return new Uint8Property(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
Uint8Property.SerializeValue(writer, property.value); | ||
@@ -171,3 +182,4 @@ } | ||
} | ||
export class Int32Property extends BasicProperty { | ||
exports.Uint8Property = Uint8Property; | ||
class Int32Property extends BasicProperty { | ||
constructor(value, ueType = 'IntProperty', guidInfo = undefined, index = 0) { | ||
@@ -178,3 +190,3 @@ super('Int32Property', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = Int32Property.ReadValue(reader); | ||
@@ -190,3 +202,3 @@ return new Int32Property(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
Int32Property.SerializeValue(writer, property.value); | ||
@@ -198,3 +210,4 @@ } | ||
} | ||
export class Uint32Property extends BasicProperty { | ||
exports.Int32Property = Int32Property; | ||
class Uint32Property extends BasicProperty { | ||
constructor(value, ueType = 'UInt32Property', guidInfo = undefined, index = 0) { | ||
@@ -205,3 +218,3 @@ super('UInt32Property', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = Uint32Property.ReadValue(reader); | ||
@@ -217,3 +230,3 @@ return new Uint32Property(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
Uint32Property.SerializeValue(writer, property.value); | ||
@@ -225,3 +238,4 @@ } | ||
} | ||
export class Int64Property extends BasicProperty { | ||
exports.Uint32Property = Uint32Property; | ||
class Int64Property extends BasicProperty { | ||
constructor(value, ueType = 'Int64Property', guidInfo = undefined, index = 0) { | ||
@@ -232,3 +246,3 @@ super('Int64Property', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = Int64Property.ReadValue(reader); | ||
@@ -244,3 +258,3 @@ return new Int64Property(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
Int64Property.SerializeValue(writer, property.value); | ||
@@ -252,3 +266,4 @@ } | ||
} | ||
export class FloatProperty extends BasicProperty { | ||
exports.Int64Property = Int64Property; | ||
class FloatProperty extends BasicProperty { | ||
constructor(value, ueType = 'FloatProperty', guidInfo = undefined, index = 0) { | ||
@@ -259,3 +274,3 @@ super('FloatProperty', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = FloatProperty.ReadValue(reader); | ||
@@ -271,3 +286,3 @@ return new FloatProperty(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
FloatProperty.SerializeValue(writer, property.value); | ||
@@ -279,3 +294,4 @@ } | ||
} | ||
export class DoubleProperty extends BasicProperty { | ||
exports.FloatProperty = FloatProperty; | ||
class DoubleProperty extends BasicProperty { | ||
constructor(value, ueType = 'DoubleProperty', guidInfo = undefined, index = 0) { | ||
@@ -286,3 +302,3 @@ super('DoubleProperty', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = DoubleProperty.ReadValue(reader); | ||
@@ -298,3 +314,3 @@ return new DoubleProperty(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
DoubleProperty.SerializeValue(writer, property.value); | ||
@@ -306,3 +322,4 @@ } | ||
} | ||
export class StrProperty extends BasicProperty { | ||
exports.DoubleProperty = DoubleProperty; | ||
class StrProperty extends BasicProperty { | ||
constructor(value, ueType = 'StrProperty', guidInfo = undefined, index = 0) { | ||
@@ -313,3 +330,3 @@ super('StrProperty', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = StrProperty.ReadValue(reader); | ||
@@ -325,3 +342,3 @@ return new StrProperty(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
StrProperty.SerializeValue(writer, property.value); | ||
@@ -333,3 +350,4 @@ } | ||
} | ||
export class ObjectProperty extends BasicProperty { | ||
exports.StrProperty = StrProperty; | ||
class ObjectProperty extends BasicProperty { | ||
constructor(value, ueType = 'ObjectProperty', guidInfo = undefined, index = 0) { | ||
@@ -340,3 +358,3 @@ super('ObjectProperty', ueType, guidInfo, index); | ||
static Parse(reader, ueType, index = 0) { | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = ObjectProperty.ReadValue(reader); | ||
@@ -356,3 +374,3 @@ return new ObjectProperty(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
ObjectProperty.SerializeValue(writer, property.value); | ||
@@ -365,3 +383,4 @@ } | ||
} | ||
export class EnumProperty extends BasicProperty { | ||
exports.ObjectProperty = ObjectProperty; | ||
class EnumProperty extends BasicProperty { | ||
constructor(value, ueType = 'EnumProperty', guidInfo = undefined, index = 0) { | ||
@@ -373,3 +392,3 @@ super('EnumProperty', ueType, guidInfo, index); | ||
let name = reader.readString(); | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = EnumProperty.ReadValue(reader); | ||
@@ -387,3 +406,3 @@ const property = new EnumProperty({ name, value }, ueType, guidInfo, index); | ||
writer.writeString(property.value.name); | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
EnumProperty.SerializeValue(writer, property.value.value); | ||
@@ -395,3 +414,4 @@ } | ||
} | ||
export class TextProperty extends BasicProperty { | ||
exports.EnumProperty = EnumProperty; | ||
class TextProperty extends BasicProperty { | ||
constructor(value, ueType = 'TextProperty', guidInfo = undefined, index = 0) { | ||
@@ -403,3 +423,3 @@ super('TextProperty', ueType, guidInfo, index); | ||
//let name = reader.readString(); | ||
const guidInfo = ParseGUID(reader); | ||
const guidInfo = (0, exports.ParseGUID)(reader); | ||
const value = TextProperty.ParseValue(reader); | ||
@@ -467,3 +487,3 @@ return new TextProperty(value, ueType, guidInfo, index); | ||
static Serialize(writer, property) { | ||
SerializeGUID(writer, property.guidInfo); | ||
(0, exports.SerializeGUID)(writer, property.guidInfo); | ||
TextProperty.SerializeValue(writer, property.value); | ||
@@ -522,3 +542,4 @@ } | ||
} | ||
export class StructProperty extends AbstractBaseProperty { | ||
exports.TextProperty = TextProperty; | ||
class StructProperty extends AbstractBaseProperty { | ||
constructor(subtype, ueType = 'StructProperty', index = 0, guid = 0) { | ||
@@ -560,6 +581,6 @@ super('StructProperty', ueType, index); | ||
case 'Color': | ||
value = ParseCol4BGRA(reader); | ||
value = (0, util_types_1.ParseCol4BGRA)(reader); | ||
break; | ||
case 'LinearColor': | ||
value = ParseCol4RGBA(reader); | ||
value = (0, util_types_1.ParseCol4RGBA)(reader); | ||
break; | ||
@@ -569,3 +590,3 @@ case 'Vector': | ||
case 'Vector2D': | ||
value = ParseVec3(reader); | ||
value = (0, util_types_1.ParseVec3)(reader); | ||
break; | ||
@@ -575,8 +596,8 @@ case 'Quat': | ||
case 'Vector4D': | ||
value = ParseVec4(reader); | ||
value = (0, util_types_1.ParseVec4)(reader); | ||
break; | ||
case 'Box': | ||
value = { | ||
min: ParseVec3(reader), | ||
max: ParseVec3(reader), | ||
min: (0, util_types_1.ParseVec3)(reader), | ||
max: (0, util_types_1.ParseVec3)(reader), | ||
isValid: reader.readByte() >= 1 | ||
@@ -622,7 +643,7 @@ }; | ||
case 'FINNetworkTrace': | ||
value = ReadFINNetworkTrace(reader); | ||
value = (0, exports.ReadFINNetworkTrace)(reader); | ||
break; | ||
case 'FINLuaProcessorStateStorage': | ||
value = { | ||
values: ReadFINLuaProcessorStateStorage(reader, size) | ||
values: (0, exports.ReadFINLuaProcessorStateStorage)(reader, size) | ||
}; | ||
@@ -638,3 +659,3 @@ break; | ||
//TODO: use buildversion | ||
value = ParseDynamicStructData(reader, 0, subtype); | ||
value = (0, exports.ParseDynamicStructData)(reader, 0, subtype); | ||
} | ||
@@ -659,7 +680,7 @@ return value; | ||
value = value; | ||
SerializeCol4BGRA(writer, value); | ||
(0, util_types_1.SerializeCol4BGRA)(writer, value); | ||
break; | ||
case 'LinearColor': | ||
value = value; | ||
SerializeCol4RGBA(writer, value); | ||
(0, util_types_1.SerializeCol4RGBA)(writer, value); | ||
break; | ||
@@ -670,3 +691,3 @@ case 'Vector': | ||
value = value; | ||
SerializeVec3(writer, value); | ||
(0, util_types_1.SerializeVec3)(writer, value); | ||
break; | ||
@@ -677,8 +698,8 @@ case 'Quat': | ||
value = value; | ||
SerializeVec4(writer, value); | ||
(0, util_types_1.SerializeVec4)(writer, value); | ||
break; | ||
case 'Box': | ||
value = value; | ||
SerializeVec3(writer, value.min); | ||
SerializeVec3(writer, value.max); | ||
(0, util_types_1.SerializeVec3)(writer, value.min); | ||
(0, util_types_1.SerializeVec3)(writer, value.max); | ||
writer.writeByte(value.isValid ? 1 : 0); | ||
@@ -724,7 +745,7 @@ break; | ||
value = value; | ||
SerializeFINNetworkTrace(writer, value); | ||
(0, exports.SerializeFINNetworkTrace)(writer, value); | ||
break; | ||
case 'FINLuaProcessorStateStorage': | ||
value = value; | ||
SerializeFINLuaProcessorStateStorage(writer, value.values); | ||
(0, exports.SerializeFINLuaProcessorStateStorage)(writer, value.values); | ||
break; | ||
@@ -739,7 +760,8 @@ case 'FICFrameRange': // https://github.com/Panakotta00/FicsIt-Cam/blob/c55e254a84722c56e1badabcfaef1159cd7d2ef1/Source/FicsItCam/Public/Data/FICTypes.h#L34 | ||
value = value; | ||
SerializeDynamicStructData(writer, 0, value); | ||
(0, exports.SerializeDynamicStructData)(writer, 0, value); | ||
} | ||
} | ||
} | ||
export class ArrayProperty extends BasicProperty { | ||
exports.StructProperty = StructProperty; | ||
class ArrayProperty extends BasicProperty { | ||
constructor(subtype, values, ueType = 'ArrayProperty', index = 0, structValueFields) { | ||
@@ -897,3 +919,4 @@ super('ArrayProperty', ueType, undefined, index); | ||
} | ||
export class SetProperty extends BasicProperty { | ||
exports.ArrayProperty = ArrayProperty; | ||
class SetProperty extends BasicProperty { | ||
constructor(subtype, values, ueType, index) { | ||
@@ -922,3 +945,3 @@ super('SetProperty', ueType, undefined, index); | ||
if (propertyName === 'mRemovalLocations') { | ||
property = new SetProperty(subtype, new Array(elementCount).fill(0).map(e => ParseVec3(reader)), ueType, index); | ||
property = new SetProperty(subtype, new Array(elementCount).fill(0).map(e => (0, util_types_1.ParseVec3)(reader)), ueType, index); | ||
} | ||
@@ -952,3 +975,3 @@ break; | ||
//TODO: this would only work for mRemovalLocations. Get a way to check for propertyname at least. | ||
property.values.forEach(v => SerializeVec3(writer, v)); | ||
property.values.forEach(v => (0, util_types_1.SerializeVec3)(writer, v)); | ||
break; | ||
@@ -960,3 +983,4 @@ default: | ||
} | ||
export class MapProperty extends BasicProperty { | ||
exports.SetProperty = SetProperty; | ||
class MapProperty extends BasicProperty { | ||
constructor(keyType, valueType, ueType, index) { | ||
@@ -1104,3 +1128,4 @@ super('MapProperty', ueType, undefined, index); | ||
} | ||
export const ParseDynamicStructData = (reader, buildVersion, type) => { | ||
exports.MapProperty = MapProperty; | ||
const ParseDynamicStructData = (reader, buildVersion, type) => { | ||
const data = { | ||
@@ -1111,3 +1136,3 @@ type, properties: {} | ||
while (propertyName !== 'None') { | ||
const property = DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
const property = DataFields_1.DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
data.properties[propertyName] = property; | ||
@@ -1118,15 +1143,17 @@ propertyName = reader.readString(); | ||
}; | ||
export const SerializeDynamicStructData = (writer, buildVersion, data) => { | ||
exports.ParseDynamicStructData = ParseDynamicStructData; | ||
const SerializeDynamicStructData = (writer, buildVersion, data) => { | ||
for (const key in data.properties) { | ||
writer.writeString(key); | ||
DataFields.SerializeProperty(writer, data.properties[key], key, buildVersion); | ||
DataFields_1.DataFields.SerializeProperty(writer, data.properties[key], key, buildVersion); | ||
} | ||
writer.writeString('None'); | ||
}; | ||
export const ReadFINNetworkTrace = (reader) => { | ||
exports.SerializeDynamicStructData = SerializeDynamicStructData; | ||
const ReadFINNetworkTrace = (reader) => { | ||
const networkTrace = {}; | ||
networkTrace.ref = ObjectReference.Parse(reader); | ||
networkTrace.ref = ObjectReference_1.ObjectReference.Parse(reader); | ||
networkTrace.hasPrev = reader.readInt32(); | ||
if (networkTrace.hasPrev) { | ||
networkTrace.prev = ReadFINNetworkTrace(reader); | ||
networkTrace.prev = (0, exports.ReadFINNetworkTrace)(reader); | ||
} | ||
@@ -1139,8 +1166,9 @@ networkTrace.hasStep = reader.readInt32(); | ||
}; | ||
export const SerializeFINNetworkTrace = (writer, obj) => { | ||
exports.ReadFINNetworkTrace = ReadFINNetworkTrace; | ||
const SerializeFINNetworkTrace = (writer, obj) => { | ||
const networkTrace = {}; | ||
ObjectReference.Serialize(writer, obj.ref); | ||
ObjectReference_1.ObjectReference.Serialize(writer, obj.ref); | ||
writer.writeInt32(obj.hasPrev); | ||
if (obj.hasPrev) { | ||
SerializeFINNetworkTrace(writer, obj.prev); | ||
(0, exports.SerializeFINNetworkTrace)(writer, obj.prev); | ||
} | ||
@@ -1152,3 +1180,4 @@ writer.writeInt32(obj.hasStep); | ||
}; | ||
export const ReadFINLuaProcessorStateStorage = (reader, size) => { | ||
exports.SerializeFINNetworkTrace = SerializeFINNetworkTrace; | ||
const ReadFINLuaProcessorStateStorage = (reader, size) => { | ||
const stateStorage = { traces: [], references: [], thread: '', globals: '', remainingStructData: {} }; | ||
@@ -1158,7 +1187,7 @@ const start = reader.getBufferPosition(); | ||
for (let i = 0; i < traceCount; i++) { | ||
stateStorage.traces.push(ReadFINNetworkTrace(reader)); | ||
stateStorage.traces.push((0, exports.ReadFINNetworkTrace)(reader)); | ||
} | ||
const refCount = reader.readInt32(); | ||
for (let i = 0; i < refCount; i++) { | ||
stateStorage.references.push(ObjectReference.Parse(reader)); | ||
stateStorage.references.push(ObjectReference_1.ObjectReference.Parse(reader)); | ||
} | ||
@@ -1171,10 +1200,11 @@ stateStorage.thread = reader.readString(); | ||
}; | ||
export const SerializeFINLuaProcessorStateStorage = (writer, stateStorage) => { | ||
exports.ReadFINLuaProcessorStateStorage = ReadFINLuaProcessorStateStorage; | ||
const SerializeFINLuaProcessorStateStorage = (writer, stateStorage) => { | ||
writer.writeInt32(stateStorage.traces.length); | ||
for (const trace of stateStorage.traces) { | ||
SerializeFINNetworkTrace(writer, trace); | ||
(0, exports.SerializeFINNetworkTrace)(writer, trace); | ||
} | ||
writer.writeInt32(stateStorage.references.length); | ||
for (const ref of stateStorage.references) { | ||
ObjectReference.Serialize(writer, ref); | ||
ObjectReference_1.ObjectReference.Serialize(writer, ref); | ||
} | ||
@@ -1185,1 +1215,2 @@ writer.writeString(stateStorage.thread); | ||
}; | ||
exports.SerializeFINLuaProcessorStateStorage = SerializeFINLuaProcessorStateStorage; |
@@ -1,6 +0,10 @@ | ||
import { SaveObject } from "./SaveObject"; | ||
export const isSaveComponent = (obj) => { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveComponent = exports.isSaveComponent = void 0; | ||
const SaveObject_1 = require("./SaveObject"); | ||
const isSaveComponent = (obj) => { | ||
return obj.type === 'SaveComponent'; | ||
}; | ||
class SaveComponent extends SaveObject { | ||
exports.isSaveComponent = isSaveComponent; | ||
class SaveComponent extends SaveObject_1.SaveObject { | ||
constructor(typePath, rootObject, instanceName, parentEntityName = '') { | ||
@@ -15,14 +19,14 @@ super(typePath, rootObject, instanceName); | ||
static ParseHeader(reader, obj) { | ||
SaveObject.ParseHeader(reader, obj); | ||
SaveObject_1.SaveObject.ParseHeader(reader, obj); | ||
obj.parentEntityName = reader.readString(); | ||
} | ||
static SerializeHeader(writer, component) { | ||
SaveObject.SerializeHeader(writer, component); | ||
SaveObject_1.SaveObject.SerializeHeader(writer, component); | ||
writer.writeString(component.parentEntityName); | ||
} | ||
static ParseData(component, length, reader, buildVersion) { | ||
SaveObject.ParseData(component, length, reader, buildVersion); | ||
SaveObject_1.SaveObject.ParseData(component, length, reader, buildVersion); | ||
} | ||
} | ||
SaveComponent.TypeID = 0; | ||
export { SaveComponent }; | ||
exports.SaveComponent = SaveComponent; |
@@ -1,8 +0,12 @@ | ||
import { ParseTransform, SerializeTransform } from "../structs/util.types"; | ||
import { ObjectReference } from "./ObjectReference"; | ||
import { SaveObject } from "./SaveObject"; | ||
export const isSaveEntity = (obj) => { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveEntity = exports.isSaveEntity = void 0; | ||
const util_types_1 = require("../structs/util.types"); | ||
const ObjectReference_1 = require("./ObjectReference"); | ||
const SaveObject_1 = require("./SaveObject"); | ||
const isSaveEntity = (obj) => { | ||
return obj.type === 'SaveEntity'; | ||
}; | ||
class SaveEntity extends SaveObject { | ||
exports.isSaveEntity = isSaveEntity; | ||
class SaveEntity extends SaveObject_1.SaveObject { | ||
constructor(typePath, rootObject, instanceName, parentEntityName = '', needsTransform = false) { | ||
@@ -27,5 +31,5 @@ super(typePath, rootObject, instanceName); | ||
static ParseHeader(reader, obj) { | ||
SaveObject.ParseHeader(reader, obj); | ||
SaveObject_1.SaveObject.ParseHeader(reader, obj); | ||
obj.needTransform = reader.readInt32() == 1; | ||
obj.transform = ParseTransform(reader); | ||
obj.transform = (0, util_types_1.ParseTransform)(reader); | ||
obj.wasPlacedInLevel = reader.readInt32() == 1; | ||
@@ -43,12 +47,12 @@ } | ||
for (let i = 0; i < componentCount; i++) { | ||
var componentRef = ObjectReference.Parse(reader); | ||
var componentRef = ObjectReference_1.ObjectReference.Parse(reader); | ||
entity.components.push(componentRef); | ||
newLen -= 10 + componentRef.levelName.length + componentRef.pathName.length; | ||
} | ||
SaveObject.ParseData(entity, newLen, reader, buildVersion); | ||
SaveObject_1.SaveObject.ParseData(entity, newLen, reader, buildVersion); | ||
} | ||
static SerializeHeader(writer, entity) { | ||
SaveObject.SerializeHeader(writer, entity); | ||
SaveObject_1.SaveObject.SerializeHeader(writer, entity); | ||
writer.writeInt32(entity.needTransform ? 1 : 0); | ||
SerializeTransform(writer, entity.transform); | ||
(0, util_types_1.SerializeTransform)(writer, entity.transform); | ||
writer.writeInt32(entity.wasPlacedInLevel ? 1 : 0); | ||
@@ -64,6 +68,6 @@ } | ||
} | ||
SaveObject.SerializeData(writer, entity, buildVersion); | ||
SaveObject_1.SaveObject.SerializeData(writer, entity, buildVersion); | ||
} | ||
} | ||
SaveEntity.TypeID = 1; | ||
export { SaveEntity }; | ||
exports.SaveEntity = SaveEntity; |
@@ -1,3 +0,6 @@ | ||
import { DataFields } from "./DataFields"; | ||
export class SaveObject { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveObject = void 0; | ||
const DataFields_1 = require("./DataFields"); | ||
class SaveObject { | ||
constructor(typePath, rootObject, instanceName) { | ||
@@ -7,3 +10,3 @@ this.typePath = typePath; | ||
this.instanceName = instanceName; | ||
this.dataFields = new DataFields(); | ||
this.dataFields = new DataFields_1.DataFields(); | ||
} | ||
@@ -21,7 +24,8 @@ static ParseHeader(reader, obj) { | ||
static ParseData(obj, length, reader, buildVersion) { | ||
obj.dataFields = DataFields.Parse(length, reader, buildVersion); | ||
obj.dataFields = DataFields_1.DataFields.Parse(length, reader, buildVersion); | ||
} | ||
static SerializeData(writer, obj, buildVersion) { | ||
DataFields.Serialize(writer, obj.dataFields, buildVersion); | ||
DataFields_1.DataFields.Serialize(writer, obj.dataFields, buildVersion); | ||
} | ||
} | ||
exports.SaveObject = SaveObject; |
@@ -1,2 +0,5 @@ | ||
export class SatisfactorySave { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SatisfactorySave = void 0; | ||
class SatisfactorySave { | ||
constructor(header) { | ||
@@ -8,1 +11,2 @@ this.levels = []; | ||
} | ||
exports.SatisfactorySave = SatisfactorySave; |
@@ -1,1 +0,2 @@ | ||
export {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,2 +0,5 @@ | ||
export const SerializeCol4RGBA = (writer, value) => { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SerializeTransform = exports.ParseTransform = exports.SerializeVec2 = exports.ParseVec2 = exports.SerializeVec3 = exports.ParseVec3 = exports.norm = exports.mult = exports.length = exports.add = exports.sub = exports.SerializeVec4 = exports.ParseVec4 = exports.ParseCol4BGRA = exports.SerializeCol4BGRA = exports.ParseCol4RGBA = exports.SerializeCol4RGBA = void 0; | ||
const SerializeCol4RGBA = (writer, value) => { | ||
writer.writeFloat(value.r); | ||
@@ -7,3 +10,4 @@ writer.writeFloat(value.g); | ||
}; | ||
export const ParseCol4RGBA = (reader) => { | ||
exports.SerializeCol4RGBA = SerializeCol4RGBA; | ||
const ParseCol4RGBA = (reader) => { | ||
return { | ||
@@ -16,3 +20,4 @@ r: reader.readFloat(), | ||
}; | ||
export const SerializeCol4BGRA = (writer, value) => { | ||
exports.ParseCol4RGBA = ParseCol4RGBA; | ||
const SerializeCol4BGRA = (writer, value) => { | ||
writer.writeByte(value.b); | ||
@@ -23,3 +28,4 @@ writer.writeByte(value.g); | ||
}; | ||
export const ParseCol4BGRA = (reader) => { | ||
exports.SerializeCol4BGRA = SerializeCol4BGRA; | ||
const ParseCol4BGRA = (reader) => { | ||
return { | ||
@@ -32,28 +38,38 @@ b: reader.readByte(), | ||
}; | ||
export const ParseVec4 = (reader) => { | ||
exports.ParseCol4BGRA = ParseCol4BGRA; | ||
const ParseVec4 = (reader) => { | ||
return { | ||
...ParseVec3(reader), | ||
...(0, exports.ParseVec3)(reader), | ||
w: reader.readFloat() | ||
}; | ||
}; | ||
export const SerializeVec4 = (writer, vec) => { | ||
SerializeVec3(writer, vec); | ||
exports.ParseVec4 = ParseVec4; | ||
const SerializeVec4 = (writer, vec) => { | ||
(0, exports.SerializeVec3)(writer, vec); | ||
writer.writeFloat(vec.w); | ||
}; | ||
export const sub = (other, vec) => ({ x: other.x - vec.x, y: other.y - vec.y, z: other.z - vec.z }); | ||
export const add = (vec, other) => ({ x: vec.x + other.x, y: vec.y + other.y, z: vec.z + other.z }); | ||
export const length = (vec) => Math.sqrt(vec.x ** 2 + vec.y ** 2 + vec.z ** 2); | ||
export const mult = (vec, scale) => ({ x: vec.x * scale, y: vec.y * scale, z: vec.z * scale }); | ||
export const norm = (vec) => mult(vec, 1. / length(vec)); | ||
export const ParseVec3 = (reader) => { | ||
exports.SerializeVec4 = SerializeVec4; | ||
const sub = (other, vec) => ({ x: other.x - vec.x, y: other.y - vec.y, z: other.z - vec.z }); | ||
exports.sub = sub; | ||
const add = (vec, other) => ({ x: vec.x + other.x, y: vec.y + other.y, z: vec.z + other.z }); | ||
exports.add = add; | ||
const length = (vec) => Math.sqrt(vec.x ** 2 + vec.y ** 2 + vec.z ** 2); | ||
exports.length = length; | ||
const mult = (vec, scale) => ({ x: vec.x * scale, y: vec.y * scale, z: vec.z * scale }); | ||
exports.mult = mult; | ||
const norm = (vec) => (0, exports.mult)(vec, 1. / (0, exports.length)(vec)); | ||
exports.norm = norm; | ||
const ParseVec3 = (reader) => { | ||
return { | ||
...ParseVec2(reader), | ||
...(0, exports.ParseVec2)(reader), | ||
z: reader.readFloat() | ||
}; | ||
}; | ||
export const SerializeVec3 = (writer, vec) => { | ||
SerializeVec2(writer, vec); | ||
exports.ParseVec3 = ParseVec3; | ||
const SerializeVec3 = (writer, vec) => { | ||
(0, exports.SerializeVec2)(writer, vec); | ||
writer.writeFloat(vec.z); | ||
}; | ||
export const ParseVec2 = (reader) => { | ||
exports.SerializeVec3 = SerializeVec3; | ||
const ParseVec2 = (reader) => { | ||
return { | ||
@@ -64,17 +80,21 @@ x: reader.readFloat(), | ||
}; | ||
export const SerializeVec2 = (writer, vec) => { | ||
exports.ParseVec2 = ParseVec2; | ||
const SerializeVec2 = (writer, vec) => { | ||
writer.writeFloat(vec.x); | ||
writer.writeFloat(vec.y); | ||
}; | ||
export const ParseTransform = (reader) => { | ||
exports.SerializeVec2 = SerializeVec2; | ||
const ParseTransform = (reader) => { | ||
return { | ||
rotation: ParseVec4(reader), | ||
translation: ParseVec3(reader), | ||
scale3d: ParseVec3(reader), | ||
rotation: (0, exports.ParseVec4)(reader), | ||
translation: (0, exports.ParseVec3)(reader), | ||
scale3d: (0, exports.ParseVec3)(reader), | ||
}; | ||
}; | ||
export const SerializeTransform = (writer, transform) => { | ||
SerializeVec4(writer, transform.rotation); | ||
SerializeVec3(writer, transform.translation); | ||
SerializeVec3(writer, transform.scale3d); | ||
exports.ParseTransform = ParseTransform; | ||
const SerializeTransform = (writer, transform) => { | ||
(0, exports.SerializeVec4)(writer, transform.rotation); | ||
(0, exports.SerializeVec3)(writer, transform.translation); | ||
(0, exports.SerializeVec3)(writer, transform.scale3d); | ||
}; | ||
exports.SerializeTransform = SerializeTransform; |
@@ -1,15 +0,21 @@ | ||
import Pako from "pako"; | ||
import { Alignment } from "./byte/alignment.enum"; | ||
import { ByteReader } from "./byte/byte-reader.class"; | ||
import { CompressionLibraryError, CorruptSaveError, ParserError, UnsupportedVersionError } from "./error/parser.error"; | ||
import { Level } from "./satisfactory/level.class"; | ||
import { isSaveComponent } from "./satisfactory/objects/SaveComponent"; | ||
import { isSaveEntity } from "./satisfactory/objects/SaveEntity"; | ||
export const projectionFilterApplies = (config, object) => { | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Conveyor = exports.SaveReader = exports.projectionFilterApplies = void 0; | ||
const pako_1 = __importDefault(require("pako")); | ||
const alignment_enum_1 = require("./byte/alignment.enum"); | ||
const byte_reader_class_1 = require("./byte/byte-reader.class"); | ||
const parser_error_1 = require("./error/parser.error"); | ||
const level_class_1 = require("./satisfactory/level.class"); | ||
const SaveComponent_1 = require("./satisfactory/objects/SaveComponent"); | ||
const SaveEntity_1 = require("./satisfactory/objects/SaveEntity"); | ||
const projectionFilterApplies = (config, object) => { | ||
let cond1 = false; | ||
if (isSaveEntity(object) || (config.includeComponents && isSaveComponent(object))) { | ||
if ((0, SaveEntity_1.isSaveEntity)(object) || (config.includeComponents && (0, SaveComponent_1.isSaveComponent)(object))) { | ||
cond1 = true; | ||
} | ||
let cond2 = true; | ||
if (isSaveEntity(object)) { | ||
if ((0, SaveEntity_1.isSaveEntity)(object)) { | ||
cond2 = false; | ||
@@ -25,5 +31,6 @@ if (config.entityPathFilter.behavior === 'whitelist') { | ||
}; | ||
class SaveReader extends ByteReader { | ||
exports.projectionFilterApplies = projectionFilterApplies; | ||
class SaveReader extends byte_reader_class_1.ByteReader { | ||
constructor(fileBuffer, onProgressCallback = () => { }) { | ||
super(fileBuffer, Alignment.LITTLE_ENDIAN); | ||
super(fileBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
this.onProgressCallback = onProgressCallback; | ||
@@ -81,3 +88,3 @@ this.levels = []; | ||
else { | ||
throw new UnsupportedVersionError("The save version is too old to support encoding currently. Save in newer game version."); | ||
throw new parser_error_1.UnsupportedVersionError("The save version is too old to support encoding currently. Save in newer game version."); | ||
} | ||
@@ -101,9 +108,9 @@ return this.header; | ||
if (this.compressionInfo.packageFileTag <= 0) { | ||
this.compressionInfo.packageFileTag = chunkHeader.getInt32(0, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.compressionInfo.packageFileTag = chunkHeader.getInt32(0, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
if (this.compressionInfo.maxChunkContentSize <= 0) { | ||
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === Alignment.LITTLE_ENDIAN); | ||
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === Alignment.LITTLE_ENDIAN); | ||
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === Alignment.LITTLE_ENDIAN); | ||
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
totalUncompressedBodySize += chunkUncompressedLength; | ||
@@ -121,7 +128,7 @@ const currentChunkSize = chunkCompressedLength; | ||
let currentInflatedChunk = null; | ||
currentInflatedChunk = Pako.inflate(currentChunk); | ||
currentInflatedChunk = pako_1.default.inflate(currentChunk); | ||
currentChunks.push(currentInflatedChunk); | ||
} | ||
catch (err) { | ||
throw new CompressionLibraryError("Failed to inflate compressed save data. " + err); | ||
throw new parser_error_1.CompressionLibraryError("Failed to inflate compressed save data. " + err); | ||
} | ||
@@ -143,3 +150,3 @@ } | ||
if (totalUncompressedBodySize !== dataLength + 4) { | ||
throw new CorruptSaveError(`Possibly corrupt. Indicated size of total save body (${dataLength}) does not match the uncompressed real size of ${totalUncompressedBodySize}.`); | ||
throw new parser_error_1.CorruptSaveError(`Possibly corrupt. Indicated size of total save body (${dataLength}) does not match the uncompressed real size of ${totalUncompressedBodySize}.`); | ||
} | ||
@@ -153,6 +160,6 @@ return { | ||
if (!this.header) { | ||
throw new ParserError('ParserError', 'Header must be set before objects can be read.'); | ||
throw new parser_error_1.ParserError('ParserError', 'Header must be set before objects can be read.'); | ||
} | ||
if (this.header.saveVersion < 29) { | ||
throw new UnsupportedVersionError('Support for < U6 is not yet implemented.'); | ||
throw new parser_error_1.UnsupportedVersionError('Support for < U6 is not yet implemented.'); | ||
} | ||
@@ -165,7 +172,7 @@ const numSubLevels = this.readInt32(); | ||
this.onProgressCallback(this.getBufferProgress(), `reading level [${(j + 1)}/${(numSubLevels + 1)}] ${levelName}`); | ||
this.levels[j] = Level.ReadLevel(this, levelName, this.header.buildVersion); | ||
this.levels[j] = level_class_1.Level.ReadLevel(this, levelName, this.header.buildVersion); | ||
} | ||
// in U6/U7 there were more collectibles added that do not belong to a particular level | ||
if (this.getBufferPosition() < this.bufferView.byteLength) { | ||
this.trailingCollectedObjects = Level.ReadCollectablesList(this); | ||
this.trailingCollectedObjects = level_class_1.Level.ReadCollectablesList(this); | ||
} | ||
@@ -177,4 +184,4 @@ return this.levels; | ||
SaveReader.EPOCH_TICKS = 621355968000000000n; | ||
export { SaveReader }; | ||
export class Conveyor { | ||
exports.SaveReader = SaveReader; | ||
class Conveyor { | ||
static getConveyorBeltRegex() { | ||
@@ -252,1 +259,2 @@ return /\/Game\/FactoryGame\/Buildable\/Factory\/(ConveyorBeltMk[0-9]+)\/Build_(\1)\.Build_(\1)_C/g; | ||
} | ||
exports.Conveyor = Conveyor; |
@@ -1,9 +0,15 @@ | ||
import Pako from "pako"; | ||
import { Alignment } from "./byte/alignment.enum"; | ||
import { ByteWriter } from "./byte/byte-writer.class"; | ||
import { ParserError, UnsupportedVersionError } from "./error/parser.error"; | ||
import { Level } from "./satisfactory/level.class"; | ||
export class SaveWriter extends ByteWriter { | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SaveWriter = void 0; | ||
const pako_1 = __importDefault(require("pako")); | ||
const alignment_enum_1 = require("./byte/alignment.enum"); | ||
const byte_writer_class_1 = require("./byte/byte-writer.class"); | ||
const parser_error_1 = require("./error/parser.error"); | ||
const level_class_1 = require("./satisfactory/level.class"); | ||
class SaveWriter extends byte_writer_class_1.ByteWriter { | ||
constructor() { | ||
super(Alignment.LITTLE_ENDIAN); | ||
super(alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
} | ||
@@ -39,3 +45,3 @@ static WriteHeader(writer, header) { | ||
else { | ||
throw new UnsupportedVersionError("The save version is too old to be supported currently."); | ||
throw new parser_error_1.UnsupportedVersionError("The save version is too old to be supported currently."); | ||
} | ||
@@ -49,7 +55,7 @@ } | ||
} | ||
Level.WriteLevel(writer, level, buildVersion); | ||
level_class_1.Level.WriteLevel(writer, level, buildVersion); | ||
} | ||
Level.SerializeCollectablesList(writer, save.trailingCollectedObjects); | ||
level_class_1.Level.SerializeCollectablesList(writer, save.trailingCollectedObjects); | ||
} | ||
static GenerateCompressedChunksFromData(bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, alignment = Alignment.LITTLE_ENDIAN) { | ||
static GenerateCompressedChunksFromData(bufferArray, compressionInfo, onBinaryBeforeCompressing, onChunk, onFinish, alignment = alignment_enum_1.Alignment.LITTLE_ENDIAN) { | ||
const errors = []; | ||
@@ -60,3 +66,3 @@ const totalUncompressedSize = bufferArray.byteLength; | ||
const miniView = new DataView(saveBody.buffer); | ||
miniView.setInt32(0, totalUncompressedSize, alignment === Alignment.LITTLE_ENDIAN); | ||
miniView.setInt32(0, totalUncompressedSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
onBinaryBeforeCompressing(saveBody.buffer); | ||
@@ -73,3 +79,3 @@ // collect slices of chunks with help of compression info for max chunk size | ||
try { | ||
compressedChunk = Pako.deflate(uncompressedChunk); | ||
compressedChunk = pako_1.default.deflate(uncompressedChunk); | ||
} | ||
@@ -83,14 +89,14 @@ catch (err) { | ||
const view = new DataView(chunk.buffer); | ||
view.setInt32(0, compressionInfo.packageFileTag, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(4, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(8, compressionInfo.maxChunkContentSize, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(12, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(16, compressedChunk.byteLength, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(20, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(24, uncompressedContentSize, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(28, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(32, compressedChunk.byteLength, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(36, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(40, uncompressedContentSize, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(44, 0, alignment === Alignment.LITTLE_ENDIAN); | ||
view.setInt32(0, compressionInfo.packageFileTag, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(4, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(8, compressionInfo.maxChunkContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(12, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(16, compressedChunk.byteLength, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(20, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(24, uncompressedContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(28, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(32, compressedChunk.byteLength, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(36, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(40, uncompressedContentSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
view.setInt32(44, 0, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN); | ||
onChunk(chunk); | ||
@@ -110,3 +116,3 @@ chunkSummary.push({ | ||
if (posAfterHeader <= 0) { | ||
throw new ParserError('ParserError', 'Seems like this buffer has no header. Please write the header first before you can generate chunks.'); | ||
throw new parser_error_1.ParserError('ParserError', 'Seems like this buffer has no header. Please write the header first before you can generate chunks.'); | ||
} | ||
@@ -121,1 +127,2 @@ // send plain header first. | ||
} | ||
exports.SaveWriter = SaveWriter; |
{ | ||
"name": "@etothepii/satisfactory-file-parser", | ||
"author": "etothepii", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "A file parser for satisfactory files. Includes save files and blueprint files.", | ||
"main": "build/index.js", | ||
"type": "module", | ||
"keywords": [ | ||
@@ -9,0 +8,0 @@ "satisfactory", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
160050
3573
0
No