@etothepii/satisfactory-file-parser
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -8,3 +8,3 @@ import { ByteWriter } from "../../.."; | ||
import { SaveObject } from "./SaveObject"; | ||
export type SpecialAnyProperty = {} | PowerLineSpecialProperty; | ||
export type SpecialAnyProperty = {} | PowerLineSpecialProperty | PlayerSpecialProperty; | ||
export type PowerLineSpecialProperty = { | ||
@@ -35,3 +35,3 @@ num: number; | ||
static ParseAdditionalSpecialProperties(reader: BinaryReadable, typePath: string, remainingLen: number): SpecialAnyProperty; | ||
static ParseProperty(reader: BinaryReadable, buildVersion: number, propertyName: string): AbstractBaseProperty | null; | ||
static ParseProperty(reader: BinaryReadable, buildVersion: number, propertyName: string): AbstractBaseProperty; | ||
static Serialize(obj: SaveObject, writer: SaveWriter, buildVersion: number, typePath: string): void; | ||
@@ -38,0 +38,0 @@ static SerializeAdditionalSpecialProperties(writer: ByteWriter, typePath: string, property: SpecialAnyProperty): void; |
@@ -11,3 +11,3 @@ "use strict"; | ||
const start = reader.getBufferPosition(); | ||
obj.properties = []; | ||
obj.properties = {}; | ||
if (length === 0) { | ||
@@ -18,4 +18,12 @@ return; | ||
while (propertyName !== 'None') { | ||
const property = DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
obj.properties.push(property); | ||
const parsedProperty = DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
if (obj.properties[propertyName]) { | ||
if (!Array.isArray(obj.properties[propertyName])) { | ||
obj.properties[propertyName] = [obj.properties[propertyName]]; | ||
} | ||
obj.properties[propertyName].push(parsedProperty); | ||
} | ||
else { | ||
obj.properties[propertyName] = parsedProperty; | ||
} | ||
propertyName = reader.readString(); | ||
@@ -86,5 +94,2 @@ } | ||
let currentProperty = {}; | ||
if (currentProperty.name === 'None') { | ||
return null; | ||
} | ||
const propertyType = reader.readString(); | ||
@@ -180,3 +185,3 @@ const binarySize = reader.readInt32(); | ||
static Serialize(obj, writer, buildVersion, typePath) { | ||
for (const property of Object.values(obj.properties)) { | ||
for (const property of Object.values(obj.properties).flatMap(val => Array.isArray(val) ? val : [val])) { | ||
writer.writeString(property.name); | ||
@@ -183,0 +188,0 @@ DataFields.SerializeProperty(writer, property, property.name, buildVersion); |
@@ -5,4 +5,4 @@ import { ByteWriter } from "../../.."; | ||
import { ObjectReference } from "./ObjectReference"; | ||
export type Properties = { | ||
[key: string]: string | number | boolean | any; | ||
export type PropertiesMap = { | ||
[name: string]: AbstractBaseProperty | AbstractBaseProperty[]; | ||
}; | ||
@@ -205,3 +205,3 @@ export declare abstract class AbstractProperty { | ||
type: string; | ||
properties: AbstractBaseProperty[]; | ||
properties: PropertiesMap; | ||
}; | ||
@@ -208,0 +208,0 @@ export type GENERIC_STRUCT_PROPERTY_VALUE = BasicMultipleStructPropertyValue | BasicStructPropertyValue | BoxStructPropertyValue | RailroadTrackPositionStructPropertyValue | InventoryItemStructPropertyValue | FICFrameRangeStructPropertyValue | DynamicStructPropertyValue | col4 | vec3 | vec4 | string; |
@@ -931,3 +931,3 @@ "use strict"; | ||
const data = { | ||
type, properties: [] | ||
type, properties: {} | ||
}; | ||
@@ -937,4 +937,12 @@ const pos = reader.getBufferPosition(); | ||
while (propertyName !== 'None') { | ||
const property = DataFields_1.DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
data.properties.push(property); | ||
const parsedProperty = DataFields_1.DataFields.ParseProperty(reader, buildVersion, propertyName); | ||
if (data.properties[propertyName]) { | ||
if (!Array.isArray(data.properties[propertyName])) { | ||
data.properties[propertyName] = [data.properties[propertyName]]; | ||
} | ||
data.properties[propertyName].push(parsedProperty); | ||
} | ||
else { | ||
data.properties[propertyName] = parsedProperty; | ||
} | ||
propertyName = reader.readString(); | ||
@@ -948,3 +956,5 @@ } | ||
writer.writeString(key); | ||
DataFields_1.DataFields.SerializeProperty(writer, data.properties[key], key, buildVersion); | ||
for (const prop of (Array.isArray(data.properties[key]) ? data.properties[key] : [data.properties[key]])) { | ||
DataFields_1.DataFields.SerializeProperty(writer, prop, key, buildVersion); | ||
} | ||
} | ||
@@ -951,0 +961,0 @@ writer.writeString('None'); |
import { BinaryReadable } from "../../byte/binary-readable.interface"; | ||
import { ByteWriter } from "../../byte/byte-writer.class"; | ||
import { SpecialAnyProperty } from "./DataFields"; | ||
import { AbstractBaseProperty } from "./Property"; | ||
import { PropertiesMap } from "./Property"; | ||
export interface SaveObjectHeader { | ||
@@ -14,3 +14,3 @@ typePath: string; | ||
instanceName: string; | ||
properties: AbstractBaseProperty[]; | ||
properties: PropertiesMap; | ||
specialProperties: SpecialAnyProperty; | ||
@@ -17,0 +17,0 @@ trailingData: number[]; |
@@ -10,3 +10,3 @@ "use strict"; | ||
this.instanceName = instanceName; | ||
this.properties = []; | ||
this.properties = {}; | ||
this.specialProperties = {}; | ||
@@ -13,0 +13,0 @@ this.trailingData = []; |
{ | ||
"name": "@etothepii/satisfactory-file-parser", | ||
"author": "etothepii", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "A file parser for satisfactory files. Includes save files and blueprint files.", | ||
@@ -6,0 +6,0 @@ "types": "./build/index.d.ts", |
@@ -22,3 +22,3 @@ # Satisfactory File Parser | ||
| U6 + U7 | ✅ 0.0.1 - 0.0.34 | | ||
| U8 | ⚠️ >= 0.1.8 (Reading only) | | ||
| U8 | ⚠️ >= 0.1.9 (Reading only) | | ||
@@ -25,0 +25,0 @@ |
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
227734
4929