public byte byteValue; //Use ONLY if the above boolean is true public ByteProperty(DotArkDeserializer d, int index, int length) { var ms = d.ms; //Read in the enum name enumName = ms.ReadArkClassname(d); //That can be None, but cannot be null. if (enumName == null) { throw new Exception("Tried to read enum type, but got null!"); } isNormalByte = enumName.IsNone(); //If that type is a None, this is not an enum. If it is, this is an enum. Read the name. dataFilePosition = ms.position; if (isNormalByte) { byteValue = ms.ReadByte(); } else { enumValue = ms.ReadArkClassname(d); } }
public ArkStructQuat(IOMemoryStream ms, ArkClassName structType) { x = ms.ReadFloat(); y = ms.ReadFloat(); z = ms.ReadFloat(); w = ms.ReadFloat(); }
public ArkStructColor(IOMemoryStream ms, ArkClassName structType) { b = ms.ReadByte(); g = ms.ReadByte(); r = ms.ReadByte(); a = ms.ReadByte(); }
public ArkStructLinearColor(IOMemoryStream ms, ArkClassName structType) { r = ms.ReadFloat(); g = ms.ReadFloat(); b = ms.ReadFloat(); a = ms.ReadFloat(); }
public InlineProperty(IOMemoryStream ms) { startPos = ms.position; name = ms.ReadInlineArkClassname(); type = ms.ReadInlineArkClassname(); length = ms.ReadInt(); index = ms.ReadInt(); }
public StructProperty(DotArkDeserializer d, int index, int length) { var ms = d.ms; //Read the struct type structType = ms.ReadArkClassname(d); //Read in the struct dataFilePosition = ms.position; structData = DotArkStruct.ReadFromFile(d, structType); data = structData; }
public static DotArkStruct ReadFromFile(DotArkDeserializer d, ArkClassName structType) { //Based on the type, open it. string typeName = structType.classname; DotArkStruct st; //First, we check known types for the struct property list. There could be other data, but it could fail. if (typeName == "ItemNetID" || typeName == "ItemNetInfo" || typeName == "Transform" || typeName == "PrimalPlayerDataStruct" || typeName == "PrimalPlayerCharacterConfigStruct" || typeName == "PrimalPersistentCharacterStatsStruct" || typeName == "TribeData" || typeName == "TribeGovernment" || typeName == "TerrainInfo" || typeName == "ArkInventoryData" || typeName == "DinoOrderGroup" || typeName == "ARKDinoData") { //Open this as a struct property list. st = new ArkStructProps(d, structType); } else if (typeName == "Vector" || typeName == "Rotator") { //3d vector or rotor st = new ArkStructVector3(d.ms, structType); } else if (typeName == "Vector2D") { //2d vector st = new ArkStructVector2(d.ms, structType); } else if (typeName == "Quat") { //Quat st = new ArkStructQuat(d.ms, structType); } else if (typeName == "Color") { //Color st = new ArkStructColor(d.ms, structType); } else if (typeName == "LinearColor") { //Linear color st = new ArkStructLinearColor(d.ms, structType); } else if (typeName == "UniqueNetIdRepl") { //Some net stuff st = new ArkStructUniqueNetId(d.ms, structType); } else { //Interpet this as a struct property list. Maybe raise a warning later? //Console.WriteLine($"Unknown struct type '{typeName}'. Interpeting as struct property list."); st = new ArkStructProps(d, structType); } return(st); }
private static DotArkProperty ReadStructProperty(DotArkDeserializer d, int index, int length, ArkClassName type) { //Open List <DotArkStruct> data = new List <DotArkStruct>(); int arraySize = d.ms.ReadInt(); //Determine the type ArkClassName structType; if (arraySize * 4 + 4 == length) { structType = ArkClassName.Create("Color"); } else if (arraySize * 12 + 4 == length) { structType = ArkClassName.Create("Vector"); } else if (arraySize * 16 + 4 == length) { structType = ArkClassName.Create("LinearColor"); } else { structType = null; } //Read if (structType != null) { for (int i = 0; i < arraySize; i++) { data.Add(DotArkStruct.ReadFromFile(d, structType)); } } else { for (int i = 0; i < arraySize; i++) { data.Add(new ArkStructProps(d, structType)); } } //Create return(new ArrayProperty <DotArkStruct> { arrayType = type, index = index, items = data, size = length }); }
public static DotArkProperty ReadArray(DotArkDeserializer d, int index, int length) { var ms = d.ms; //First, read the type of the array. ArkClassName arrayType = ms.ReadArkClassname(d); //Read through each of the values in the array. //ms.ms.Position += length; //Switch depending on the type DotArkProperty r; switch (arrayType.classname) { case "ObjectProperty": r = ReadObjectProperty(d, index, length, arrayType); break; case "StructProperty": r = ReadStructProperty(d, index, length, arrayType); break; case "UInt32Property": r = ReadUInt32Property(d, index, length, arrayType); break; case "IntProperty": r = ReadIntProperty(d, index, length, arrayType); break; case "UInt16Property": r = ReadUInt16Property(d, index, length, arrayType); break; case "Int16Property": r = ReadInt16Property(d, index, length, arrayType); break; case "ByteProperty": r = ReadByteProperty(d, index, length, arrayType); break; case "Int8Property": r = ReadInt8Property(d, index, length, arrayType); break; case "StrProperty": r = ReadStrProperty(d, index, length, arrayType); break; case "UInt64Property": r = ReadUInt64Property(d, index, length, arrayType); break; case "BoolProperty": r = ReadBoolProperty(d, index, length, arrayType); break; case "FloatProperty": r = ReadFloatProperty(d, index, length, arrayType); break; case "DoubleProperty": r = ReadDoubleProperty(d, index, length, arrayType); break; case "NameProperty": r = ReadNameProperty(d, index, length, arrayType); break; default: throw new Exception($"Unknown ARK array type '{arrayType.classname}'."); } return(r); }
public InlineStructProperty(IOMemoryStream ms) : base(ms) { //Determine the type. structType = ms.ReadInlineArkClassname(); //First, we check known types for the struct property list. There could be other data, but it could fail. if (structType.classname == "ItemNetID" || structType.classname == "ItemNetInfo" || structType.classname == "Transform" || structType.classname == "PrimalPlayerDataStruct" || structType.classname == "PrimalPlayerCharacterConfigStruct" || structType.classname == "PrimalPersistentCharacterStatsStruct" || structType.classname == "TribeData" || structType.classname == "TribeGovernment" || structType.classname == "TerrainInfo" || structType.classname == "ArkInventoryData" || structType.classname == "DinoOrderGroup" || structType.classname == "ARKDinoData") { //Open this as a struct property list. data = new ArkStructInlineProps(ms); } else if (structType.classname == "Vector" || structType.classname == "Rotator") { //3d vector or rotor data = new ArkStructVector3(ms, structType); } else if (structType.classname == "Vector2D") { //2d vector data = new ArkStructVector2(ms, structType); } else if (structType.classname == "Quat") { //Quat data = new ArkStructQuat(ms, structType); } else if (structType.classname == "Color") { //Color data = new ArkStructColor(ms, structType); } else if (structType.classname == "LinearColor") { //Linear color data = new ArkStructLinearColor(ms, structType); } else if (structType.classname == "UniqueNetIdRepl") { //Some net stuff data = new ArkStructUniqueNetId(ms, structType); } else { //Interpet this as a struct property list. Maybe raise a warning later? throw new Exception("Unknown struct type."); } }
public void DebugReadArkClassname(DotArkDeserializer ds) { long start = ms.Position; int u1 = ReadInt(); int u2 = ReadInt(); ms.Position = start; try { var e = ArkClassName.ReadFromFile(ds); Console.WriteLine($"[Classname Debug] Name={e.classname}, Index={e.index} ({u1}, {u2})"); } catch { Console.WriteLine($"[Classname Debug] Failed ({u1}, {u2})"); } }
public DotArkGameObject gameObjectRef; //Only exists if the above is ObjectPropertyType.TypeID public ObjectProperty(DotArkDeserializer d, int index, int length) { var ms = d.ms; //If the length is four (only seems to happen on version 5), this is an integer. if (length == 4) { objectRefType = ObjectPropertyType.TypeID; dataFilePosition = ms.position; objectId = ms.ReadInt(); } else if (length >= 8) { //Read type int type = ms.ReadInt(); if (type > 1 || type < 0) { throw new Exception($"Unknown ref type! Expected 0 or 1, but got {type} instead!"); } //Convert this to our enum objectRefType = (ObjectPropertyType)type; dataFilePosition = ms.position; //Depending on the type, read it in. if (objectRefType == ObjectPropertyType.TypeID) { objectId = ms.ReadInt(); } if (objectRefType == ObjectPropertyType.TypePath) { className = ms.ReadArkClassname(d); } } else { dataFilePosition = ms.position; throw new Exception($"Unknown object ref length! Expected 4 or >= 8, but got {length} instead."); } //If this is a type ID, I **THINK** this is a refrence to a GameObject if (objectRefType == ObjectPropertyType.TypeID) { if (objectId != -1) { gameObjectRef = d.gameObjects[objectId]; } } }
public InlineArrayProperty(IOMemoryStream ms) : base(ms) { //Read type arrayType = ms.ReadInlineArkClassname(); if (arrayType.classname == "StrProperty") { //Read string array int count = ms.ReadInt(); data = new string[count]; for (int i = 0; i < count; i += 1) { data[i] = ms.ReadUEString(); } } else { //Skip ms.position += length; } }
public ArkStructProps(DotArkDeserializer d, ArkClassName structType) { var ms = d.ms; //This file has more custom data. //Create the dictoanry where we will store data. props = new Dictionary <ArkClassName, DotArkProperty>(); props_string = new Dictionary <string, DotArkProperty>(); //Read through all of the properties in a similar matter to the standard way. DotArkProperty prop = DotArkProperty.ReadPropertyFromDisk(d); while (prop != null) { //Add this to the properties. props.Add(prop.name, prop); if (!props_string.ContainsKey(prop.name.classname)) { props_string.Add(prop.name.classname, prop); } //Continue and read next property. prop = DotArkProperty.ReadPropertyFromDisk(d); } }
public byte byteValue; //Use ONLY if the above boolean is true public InlineByteProperty(IOMemoryStream ms) : base(ms) { //Read in the enum name enumName = ms.ReadInlineArkClassname(); //That can be None, but cannot be null. if (enumName == null) { throw new Exception("Tried to read enum type, but got null!"); } isNormalByte = enumName.IsNone(); //If that type is a None, this is not an enum. If it is, this is an enum. Read the name. if (isNormalByte) { byteValue = ms.ReadByte(); } else { enumValue = ms.ReadInlineArkClassname(); } }
public ArkClassName ReadArkClassname(DotArkDeserializer ds) { return(ArkClassName.ReadFromFile(ds)); }
public void WriteArkClassname(ArkClassName c, DotArkSerializerInstance i) { c.WriteToDotArkFile(i, this); }
public ArkClassName ReadInlineArkClassname() { return(ArkClassName.ReadFromFileInline(this)); }
public ArkClassName ReadArkClassname() { return(ArkClassName.ReadFromFile(this)); }
public ArkStructUniqueNetId(IOMemoryStream ms, ArkClassName structType) { unk = ms.ReadInt(); netId = ms.ReadUEString(); }
public static InlineProperty ReadProperty(IOMemoryStream ms) { //Read type long startPos = ms.position; ArkClassName name = ms.ReadInlineArkClassname(); if (name.IsNone()) { return(null); } ArkClassName type = ms.ReadInlineArkClassname(); //Rewind ms.position = startPos; //Based on the name of the prop, compare. InlineProperty p; switch (type.classname) { case "IntProperty": p = new InlineIntProperty(ms); break; case "StructProperty": p = new InlineStructProperty(ms); break; case "UInt64Property": p = new InlineUInt64Property(ms); break; case "StrProperty": p = new InlineStrProperty(ms); break; case "BoolProperty": p = new InlineBoolProperty(ms); break; case "ArrayProperty": p = new InlineArrayProperty(ms); break; case "ByteProperty": p = new InlineByteProperty(ms); break; case "UInt16Property": p = new InlineUInt16Property(ms); break; case "FloatProperty": p = new InlineFloatProperty(ms); break; case "DoubleProperty": p = new InlineDoubleProperty(ms); break; case "ObjectProperty": p = new InlineObjectProperty(ms); break; case "UInt32Property": p = new InlineUInt32Property(ms); break; default: //Default and read a base one, then skip p = new InlineProperty(ms); Console.WriteLine($"Unknown property {p.name.classname} ({p.type.classname}) at {p.startPos}. Attempting to skip; this will probably cause a crash."); ms.position += p.length; break; } return(p); }
private static DotArkProperty ReadObjectProperty(DotArkDeserializer d, int index, int length, ArkClassName type) { //Open int arraySize = d.ms.ReadInt(); List <ObjectProperty> data = new List <ObjectProperty>(); for (int i = 0; i < arraySize; i++) { data.Add(new ObjectProperty(d, index, length)); } //Create return(new ArrayProperty <ObjectProperty> { arrayType = type, index = index, items = data, size = length }); }
public static DotArkProperty ReadPropertyFromDisk(DotArkDeserializer d) { var ms = d.ms; //First, read a name and open it. ArkClassName name = ms.ReadArkClassname(d); //If this name is null, we've done something wrong. if (name == null) { throw new Exception("A property reading error occurred and got an unexpected NULL value; do not save"); } //If the name is None, we've read to the final property and we can stop. if (name.IsNone()) { return(null); } //Now, read the type ArkClassName type = ms.ReadArkClassname(d); //If the type is None or unreadable, something has gone wrong. if (type == null) { throw new Exception($"A property name was identified as {name.classname}, but the type failed to read."); } //Read in the index and size int size = ms.ReadInt(); int index = ms.ReadInt(); //Based on the type, deserialize this. DotArkProperty prop; switch (type.classname) { case "IntProperty": prop = new IntProperty(d, index, size); break; case "UInt32Property": prop = new UInt32Property(d, index, size); break; case "Int8Property": prop = new Int8Property(d, index, size); break; case "Int16Property": prop = new Int16Property(d, index, size); break; case "UInt16Property": prop = new UInt16Property(d, index, size); break; case "UInt64Property": prop = new UInt64Property(d, index, size); break; case "BoolProperty": prop = new BoolProperty(d, index, size); break; case "ByteProperty": prop = new ByteProperty(d, index, size); break; case "FloatProperty": prop = new FloatProperty(d, index, size); break; case "DoubleProperty": prop = new DoubleProperty(d, index, size); break; case "NameProperty": prop = new NameProperty(d, index, size); break; case "ObjectProperty": prop = new ObjectProperty(d, index, size); break; case "StrProperty": prop = new StrProperty(d, index, size); break; case "StructProperty": prop = new StructProperty(d, index, size); break; case "ArrayProperty": prop = DotArkArray.ReadArray(d, index, size); //UNFINISHED break; case "TextProperty": prop = new TextProperty(d, index, size); break; default: //Unknown throw new Exception($"Type {type.classname} was not a valid property type. Something failed to read."); } //Set additional values in the property and return it. prop.type = type; prop.name = name; prop.index = index; prop.size = size; return(prop); }