protected SetObjectParam ReadParameter(BINAReader reader, SetObjectTypeParam param) { FixPadding(reader, param.DataType); // Special Param Types if (param is SetObjectTypeParamGroup group) { var g = new SetObjectParamGroup(group.Padding); var groupParams = g.Parameters; foreach (var p in group.Parameters) { groupParams.Add(ReadParameter(reader, p)); } reader.FixPadding(group.Padding ?? 16); return(g); } else if (param.DataType == typeof(ObjectReference[])) { long arrOffset = reader.ReadInt64(); ulong arrLength = reader.ReadUInt64(); ulong arrLength2 = reader.ReadUInt64(); long curPos = reader.BaseStream.Position; if (arrLength != arrLength2) { Console.WriteLine( "WARNING: ArrLength ({0}) != ArrLength2 ({1})", arrLength, arrLength2); } var arr = new ObjectReference[arrLength]; if (arrLength > 0 && arrOffset > 0) { reader.JumpTo(arrOffset, false); for (uint i = 0; i < arrLength; ++i) { arr[i] = new ObjectReference(reader); } reader.JumpTo(curPos); } return(new SetObjectParam(param.DataType, arr)); } else if (param.DataType == typeof(ObjectReference)) { return(new SetObjectParam(typeof(ObjectReference), new ObjectReference(reader))); } else if (param.DataType == typeof(string)) { var stringParam = new SetObjectParam(typeof(string), string.Empty); long offset = reader.ReadInt64(); long stringPadding = reader.ReadInt64(); if (offset > 0) { long curPos = reader.BaseStream.Position; reader.JumpTo(offset, false); stringParam.Data = reader.ReadNullTerminatedString(); reader.JumpTo(curPos); } if (stringPadding != 0) { Console.WriteLine("WARNING: String Padding != 0 ({0:X})!!", stringPadding); } //reader.FixPadding(16); return(stringParam); } // Data var objParam = new SetObjectParam(param.DataType, reader.ReadByType(param.DataType)); // Post-Param Padding if (param.DataType == typeof(Vector3)) { uint vecPadding = reader.ReadUInt32(); if (vecPadding != 0) { Console.WriteLine("WARNING: Vector Padding != 0 ({0:X})!!", vecPadding); } } return(objParam); }