// Structs that don't use binary serialization // https://github.com/EpicGames/UnrealEngine/blob/7d9919ac7bfd80b7483012eab342cb427d60e8c9/Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp#L2197 internal UObject(PackageReader reader, long maxSize, bool structFallback) { var props = new Dictionary <string, object>(); int i = 1; while (true) { var Tag = new FPropertyTag(reader); if (Tag.Name.IsNone) { break; } var pos = reader.Position; if (props.ContainsKey(Tag.Name.String)) // FortniteGame/Content/Balance/RarityData.uasset i really need this { props[$"{Tag.Name.String}_NK{i++}"] = BaseProperty.ReadProperty(reader, Tag, Tag.Type, ReadType.NORMAL) ?? null; // NK = NewKey } else { props[Tag.Name.String] = BaseProperty.ReadProperty(reader, Tag, Tag.Type, ReadType.NORMAL) ?? null; } if (props[Tag.Name.String] is null) { break; } if (Tag.Size + pos != reader.Position) { System.Diagnostics.Debug.WriteLine($"Didn't read {Tag.Type.String} correctly (at {reader.Position}, should be {Tag.Size + pos}, {Tag.Size + pos - reader.Position} behind)"); reader.Position = Tag.Size + pos; } } Dict = props; if (!structFallback && reader.ReadInt32() != 0 && reader.Position + 16 <= maxSize) { GUID = new FGuid(reader); } }
public static ARKDinoDataObject[] ReadData(byte[] content) { //Open stream IOMemoryStream stream = new IOMemoryStream(new System.IO.MemoryStream(content), true); //Read number of values int objectCount = stream.ReadInt(); //Read object headers ARKDinoDataObject[] objects = new ARKDinoDataObject[objectCount]; for (int i = 0; i < objectCount; i++) { objects[i] = ARKDinoDataObject.ReadFromFile(stream); } //Now, read payloads for all of these objects foreach (ARKDinoDataObject o in objects) { stream.position = o.payloadStart; o.properties = new List <BaseProperty>(); BaseProperty prop = BaseProperty.ReadProperty(stream); while (prop != null) { o.properties.Add(prop); prop = BaseProperty.ReadProperty(stream); } } //Now, link all of the properties foreach (ARKDinoDataObject o in objects) { foreach (BaseProperty prop in o.properties) { prop.Link(objects); } } return(objects); }