@etothepii/satisfactory-file-parser 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/parser/satisfactory/objects/DataFields.d.ts +2 -2
- package/build/parser/satisfactory/objects/DataFields.js +12 -7
- package/build/parser/satisfactory/objects/Property.d.ts +3 -3
- package/build/parser/satisfactory/objects/Property.js +16 -6
- package/build/parser/satisfactory/objects/SaveObject.d.ts +2 -2
- package/build/parser/satisfactory/objects/SaveObject.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ U8 has only read support so far and only for save files, not for blueprint files
|
|
|
19
19
|
|:--------------:|:-----------------------------|
|
|
20
20
|
| <= U5 | ❌ |
|
|
21
21
|
| U6 + U7 | ✅ 0.0.1 - 0.0.34 |
|
|
22
|
-
| U8 | ⚠️ >= 0.1.
|
|
22
|
+
| U8 | ⚠️ >= 0.1.9 (Reading only) |
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
## Installation via npm
|
|
@@ -5,7 +5,7 @@ import { vec3 } from "../structs/util.types";
|
|
|
5
5
|
import { ObjectReference } from "./ObjectReference";
|
|
6
6
|
import { AbstractBaseProperty } from "./Property";
|
|
7
7
|
import { SaveObject } from "./SaveObject";
|
|
8
|
-
export type SpecialAnyProperty = {} | PowerLineSpecialProperty;
|
|
8
|
+
export type SpecialAnyProperty = {} | PowerLineSpecialProperty | PlayerSpecialProperty;
|
|
9
9
|
export type PowerLineSpecialProperty = {
|
|
10
10
|
num: number;
|
|
11
11
|
source: ObjectReference;
|
|
@@ -31,7 +31,7 @@ export declare class DataFields {
|
|
|
31
31
|
constructor();
|
|
32
32
|
static ParseProperties(obj: SaveObject, length: number, reader: BinaryReadable, buildVersion: number, typePath: string): void;
|
|
33
33
|
static ParseAdditionalSpecialProperties(reader: BinaryReadable, typePath: string, remainingLen: number): SpecialAnyProperty;
|
|
34
|
-
static ParseProperty(reader: BinaryReadable, buildVersion: number, propertyName: string): AbstractBaseProperty
|
|
34
|
+
static ParseProperty(reader: BinaryReadable, buildVersion: number, propertyName: string): AbstractBaseProperty;
|
|
35
35
|
static Serialize(obj: SaveObject, writer: SaveWriter, buildVersion: number, typePath: string): void;
|
|
36
36
|
static SerializeAdditionalSpecialProperties(writer: ByteWriter, typePath: string, property: SpecialAnyProperty): void;
|
|
37
37
|
static SerializeProperty(writer: ByteWriter, property: AbstractBaseProperty, propertyName: string, buildVersion: number): void;
|
|
@@ -8,14 +8,22 @@ class DataFields {
|
|
|
8
8
|
}
|
|
9
9
|
static ParseProperties(obj, length, reader, buildVersion, typePath) {
|
|
10
10
|
const start = reader.getBufferPosition();
|
|
11
|
-
obj.properties =
|
|
11
|
+
obj.properties = {};
|
|
12
12
|
if (length === 0) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
let propertyName = reader.readString();
|
|
16
16
|
while (propertyName !== 'None') {
|
|
17
|
-
const
|
|
18
|
-
obj.properties
|
|
17
|
+
const parsedProperty = DataFields.ParseProperty(reader, buildVersion, propertyName);
|
|
18
|
+
if (obj.properties[propertyName]) {
|
|
19
|
+
if (!Array.isArray(obj.properties[propertyName])) {
|
|
20
|
+
obj.properties[propertyName] = [obj.properties[propertyName]];
|
|
21
|
+
}
|
|
22
|
+
obj.properties[propertyName].push(parsedProperty);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
obj.properties[propertyName] = parsedProperty;
|
|
26
|
+
}
|
|
19
27
|
propertyName = reader.readString();
|
|
20
28
|
}
|
|
21
29
|
let padding = reader.readInt32();
|
|
@@ -81,9 +89,6 @@ class DataFields {
|
|
|
81
89
|
}
|
|
82
90
|
static ParseProperty(reader, buildVersion, propertyName) {
|
|
83
91
|
let currentProperty = {};
|
|
84
|
-
if (currentProperty.name === 'None') {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
92
|
const propertyType = reader.readString();
|
|
88
93
|
const binarySize = reader.readInt32();
|
|
89
94
|
const index = reader.readInt32();
|
|
@@ -174,7 +179,7 @@ class DataFields {
|
|
|
174
179
|
return currentProperty;
|
|
175
180
|
}
|
|
176
181
|
static Serialize(obj, writer, buildVersion, typePath) {
|
|
177
|
-
for (const property of Object.values(obj.properties)) {
|
|
182
|
+
for (const property of Object.values(obj.properties).flatMap(val => Array.isArray(val) ? val : [val])) {
|
|
178
183
|
writer.writeString(property.name);
|
|
179
184
|
DataFields.SerializeProperty(writer, property, property.name, buildVersion);
|
|
180
185
|
}
|
|
@@ -2,8 +2,8 @@ import { ByteWriter } from "../../..";
|
|
|
2
2
|
import { BinaryReadable } from "../../byte/binary-readable.interface";
|
|
3
3
|
import { col4, vec3, vec4 } from "../structs/util.types";
|
|
4
4
|
import { ObjectReference } from "./ObjectReference";
|
|
5
|
-
export type
|
|
6
|
-
[
|
|
5
|
+
export type PropertiesMap = {
|
|
6
|
+
[name: string]: AbstractBaseProperty | AbstractBaseProperty[];
|
|
7
7
|
};
|
|
8
8
|
export declare abstract class AbstractProperty {
|
|
9
9
|
type: string;
|
|
@@ -201,7 +201,7 @@ export type FICFrameRangeStructPropertyValue = {
|
|
|
201
201
|
};
|
|
202
202
|
export type DynamicStructPropertyValue = {
|
|
203
203
|
type: string;
|
|
204
|
-
properties:
|
|
204
|
+
properties: PropertiesMap;
|
|
205
205
|
};
|
|
206
206
|
export type GENERIC_STRUCT_PROPERTY_VALUE = BasicMultipleStructPropertyValue | BasicStructPropertyValue | BoxStructPropertyValue | RailroadTrackPositionStructPropertyValue | InventoryItemStructPropertyValue | FICFrameRangeStructPropertyValue | DynamicStructPropertyValue | col4 | vec3 | vec4 | string;
|
|
207
207
|
export declare class StructProperty extends AbstractBaseProperty {
|
|
@@ -518,14 +518,14 @@ class StructProperty extends AbstractBaseProperty {
|
|
|
518
518
|
value = (0, util_types_1.ParseCol4RGBA)(reader);
|
|
519
519
|
break;
|
|
520
520
|
case 'Vector':
|
|
521
|
-
value = (0, util_types_1.ParseVec3)(reader);
|
|
521
|
+
value = (size === 12) ? (0, util_types_1.ParseVec3f)(reader) : (0, util_types_1.ParseVec3)(reader);
|
|
522
522
|
break;
|
|
523
523
|
case 'Rotator':
|
|
524
524
|
case 'Vector2D':
|
|
525
525
|
value = (0, util_types_1.ParseVec3f)(reader);
|
|
526
526
|
break;
|
|
527
527
|
case 'Quat':
|
|
528
|
-
value = (0, util_types_1.ParseVec4)(reader);
|
|
528
|
+
value = value = (size === 16) ? (0, util_types_1.ParseVec4f)(reader) : (0, util_types_1.ParseVec4)(reader);
|
|
529
529
|
break;
|
|
530
530
|
case 'Vector4':
|
|
531
531
|
case 'Vector4D':
|
|
@@ -928,13 +928,21 @@ class MapProperty extends BasicProperty {
|
|
|
928
928
|
exports.MapProperty = MapProperty;
|
|
929
929
|
const ParseDynamicStructData = (reader, buildVersion, type) => {
|
|
930
930
|
const data = {
|
|
931
|
-
type, properties:
|
|
931
|
+
type, properties: {}
|
|
932
932
|
};
|
|
933
933
|
const pos = reader.getBufferPosition();
|
|
934
934
|
let propertyName = reader.readString();
|
|
935
935
|
while (propertyName !== 'None') {
|
|
936
|
-
const
|
|
937
|
-
data.properties
|
|
936
|
+
const parsedProperty = DataFields_1.DataFields.ParseProperty(reader, buildVersion, propertyName);
|
|
937
|
+
if (data.properties[propertyName]) {
|
|
938
|
+
if (!Array.isArray(data.properties[propertyName])) {
|
|
939
|
+
data.properties[propertyName] = [data.properties[propertyName]];
|
|
940
|
+
}
|
|
941
|
+
data.properties[propertyName].push(parsedProperty);
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
data.properties[propertyName] = parsedProperty;
|
|
945
|
+
}
|
|
938
946
|
propertyName = reader.readString();
|
|
939
947
|
}
|
|
940
948
|
return data;
|
|
@@ -943,7 +951,9 @@ exports.ParseDynamicStructData = ParseDynamicStructData;
|
|
|
943
951
|
const SerializeDynamicStructData = (writer, buildVersion, data) => {
|
|
944
952
|
for (const key in data.properties) {
|
|
945
953
|
writer.writeString(key);
|
|
946
|
-
|
|
954
|
+
for (const prop of (Array.isArray(data.properties[key]) ? data.properties[key] : [data.properties[key]])) {
|
|
955
|
+
DataFields_1.DataFields.SerializeProperty(writer, prop, key, buildVersion);
|
|
956
|
+
}
|
|
947
957
|
}
|
|
948
958
|
writer.writeString('None');
|
|
949
959
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BinaryReadable } from "../../byte/binary-readable.interface";
|
|
2
2
|
import { ByteWriter } from "../../byte/byte-writer.class";
|
|
3
3
|
import { SpecialAnyProperty } from "./DataFields";
|
|
4
|
-
import {
|
|
4
|
+
import { PropertiesMap } from "./Property";
|
|
5
5
|
export interface SaveObjectHeader {
|
|
6
6
|
typePath: string;
|
|
7
7
|
rootObject: string;
|
|
@@ -11,7 +11,7 @@ export declare abstract class SaveObject implements SaveObjectHeader {
|
|
|
11
11
|
typePath: string;
|
|
12
12
|
rootObject: string;
|
|
13
13
|
instanceName: string;
|
|
14
|
-
properties:
|
|
14
|
+
properties: PropertiesMap;
|
|
15
15
|
specialProperties: SpecialAnyProperty;
|
|
16
16
|
trailingData: number[];
|
|
17
17
|
unknownType1: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etothepii/satisfactory-file-parser",
|
|
3
3
|
"author": "etothepii",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.10",
|
|
5
5
|
"description": "A file parser for satisfactory files. Includes save files and blueprint files.",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
7
7
|
"main": "./build/index.js",
|