private bool ReadField(ObjectReader objectReader, Dictionary <TextField, int> fieldValues, TextField field) { switch (field) { case TextField.End: return(false); case TextField.Colour: case TextField.BackColour: _infoText += $"{field}: {string.Join(", ", objectReader.ReadByte(), objectReader.ReadByte(), objectReader.ReadByte())}\n"; objectReader.ReadByte(); return(true); case TextField.Font: _infoText += $"{field}: {MxrObjectReader.ReadString(objectReader)}\n"; return(true); case TextField.Byte22: _infoText += $"{field}: {objectReader.ReadByte()}\n"; return(true); case TextField.String: var count = objectReader.ReadInt32(); for (int i = 0; i < count; i++) { _infoText += $"{field}[{i}]: {MxrObjectReader.ReadString(objectReader)}\n"; } return(true); default: _infoText += $"{field}: {objectReader.ReadInt32()}\n"; return(true); } }
public bool ReadField(ObjectReader objectReader, Dictionary <ScoreField, int> fieldValues, ScoreField field) { switch (field) { case ScoreField.End: m_Script = Encoding.UTF8.GetBytes(_infoText); return(false); case ScoreField.Index: _infoText += $"{field}: {objectReader.ReadInt32()}\n"; return(true); case ScoreField.Name: m_Name = MxrObjectReader.ReadString(objectReader); objectReader.Position--; return(false); case ScoreField.UnknownArray33: if (objectReader.ReadByte() != 0) { throw new InvalidDataException(); } var bytes = Enumerable.Range(0, objectReader.ReadInt32()).Select(i => objectReader.ReadByte()).ToList(); _infoText += $"{field}: {bytes.Count} {{\n {string.Join(",", bytes)}\n}}\n"; return(true); case ScoreField.UnknownArray34: var strings = new List <object>(); for (int i = 0; objectReader.ReadUInt32() != UInt32.MaxValue; i++) { objectReader.BaseStream.Position -= 4; strings.Add($" {objectReader.ReadInt32()}, {MxrObjectReader.ReadString(objectReader)}, {objectReader.ReadInt32()}"); } _infoText += $"{field}: {strings.Count} {{\n{string.Join(Environment.NewLine, strings)}\n}}\n"; return(true); default: throw new InvalidDataException(); } }
protected override void Read() { MxrObjectReader.Read <TextField>(this, ClassIDType.TextAsset, ReadField); m_Script = Encoding.UTF8.GetBytes(_infoText); }
private bool ReadField(ObjectReader objectReader, Dictionary <TrackField, int> fieldValues, TrackField field) { string value = null; switch (field) { case TrackField.End: m_Script = Encoding.UTF8.GetBytes(_infoText); objectReader.Position--; return(false); case TrackField.Frames: fieldValues[field] = objectReader.ReadInt32(); if (fieldValues[field] == 0) { if (objectReader.ReadByte() != 255) { objectReader.BaseStream.Position--; } } else if (!fieldValues.ContainsKey(TrackField.UnknownByte41)) { if (objectReader.ReadByte() != 32) { throw new InvalidDataException(); } value = MxrAnimation.Read(objectReader, fieldValues[TrackField.Frames]); } break; case TrackField.Start: if (objectReader.ReadByte() != 1) { throw new InvalidDataException(); } return(true); case TrackField.UnknownByte41: fieldValues[field] = objectReader.ReadByte(); break; case TrackField.UnknownByte48: case TrackField.UnknownByte49: string unknown48 = string.Empty; if (fieldValues.ContainsKey(TrackField.UnknownByte41)) { fieldValues.TryGetValue(TrackField.Type, out var resourceType); while (true) { var objectType = (int)objectReader.ReadByte(); if (objectType == 255) { break; } if (objectType == 128) { objectType = objectReader.ReadInt32(); } var objectCount = objectReader.ReadByte(); unknown48 += $"Unknown{objectType}[{objectCount}] = " + string.Join(", ", Enumerable.Range(0, resourceType * objectCount).Select(e => objectReader.ReadSingle())) + Environment.NewLine; } value = unknown48.Length.ToString(); fieldValues[field] = unknown48.Length; } else { fieldValues[field] = objectReader.ReadByte(); } break; case TrackField.Name: value = MxrObjectReader.ReadString(objectReader); break; case TrackField.UnknownArray33: case TrackField.UnknownArray34: case TrackField.UnknownArray35: case TrackField.UnknownArray37: case TrackField.UnknownArray38: case TrackField.UnknownArray42: if (objectReader.ReadByte() != 0) { throw new InvalidDataException(); } var ints = Enumerable.Range(0, objectReader.ReadInt32()) .Select(i => (field == TrackField.UnknownArray34 || field == TrackField.UnknownArray35) ? objectReader.ReadInt32() : objectReader.ReadInt64()) .ToList(); value = ints.Any() ? $"{ints.Count} {{\n {string.Join(", ", ints)}\n}}" : "{ }"; break; case TrackField.Type: fieldValues[field] = objectReader.ReadInt32(); if (fieldValues.ContainsKey(TrackField.UnknownByte41)) { if (objectReader.ReadByte() != 255) { objectReader.BaseStream.Position--; } } else { if (objectReader.ReadByte() != (byte)TrackField.Index) { throw new InvalidDataException(); } m_Name = ((MxrClassIDType)fieldValues[field]).ToString(); var objectIndex = objectReader.ReadInt32(); if (_objectsDic.TryGetValue(MxrSerializedFile.GetPathID(fieldValues[field], objectIndex), out var namedObject)) { m_Name += $" {objectIndex} ({((NamedObject)namedObject).m_Name})"; } else if (objectIndex != -1) { m_Name += $" {objectIndex}"; } value = m_Name; } break; default: fieldValues[field] = objectReader.ReadInt32(); break; } _infoText += $"{field} = {value ?? fieldValues[field].ToString()}\n"; return(true); }
protected override void Read() { _objectsDic = ((MxrSerializedFile)this.reader.assetsFile).ObjectsDic; MxrObjectReader.Read <TrackField>(this, ClassIDType.MonoScript, ReadField, 0, withHeader: false); }
public MxrMovie(ObjectReader objectReader) : base(objectReader) { MxrObjectReader.Read <MovieField>(this, ClassIDType.MovieTexture, ReadField, 0); }
protected override void Read() { m_TextureFormat = TextureFormat.BGRA32; m_TextureSettings = new GLTextureSettings(); MxrObjectReader.Read <TextureField>(this, ClassIDType.Texture2D, ReadField); }
public MxrEar(ObjectReader objectReader) : base(objectReader) { MxrObjectReader.Read <EarField>(this, ClassIDType.AudioListener, ReadField); }
protected override void Read() { MxrObjectReader.Read <ModelField>(this, ClassIDType.Mesh, ReadField); }
public MxrCamera(ObjectReader objectReader) : base(objectReader) { MxrObjectReader.Read <CameraField>(this, ClassIDType.Camera, ReadField); }
private bool ReadField(ObjectReader objectReader, Dictionary <TableField, int> fieldValues, TableField field) { var address = 0; var value = field.ToString() + " = "; switch (field) { case TableField.End: return(false); case TableField.Unknown128: var header = objectReader.ReadBytes(2); var dataLength = 0; switch (header[0]) { case 3: if (header[1] == 32) { header = header.Concat(objectReader.ReadBytes(12)).ToArray(); dataLength = header[6] * 4; } else { dataLength = 4; } break; case 5: dataLength = header[1] == 32 ? 24 : 8; break; case 8: dataLength = 16; break; case 11: if (header[1] == 32) { header = header.Concat(objectReader.ReadBytes(9)).ToArray(); dataLength = header[6]; } else { dataLength = 1; } break; } value += string.Join(", ", header.Concat(objectReader.ReadBytes(dataLength))); break; case TableField.Unknown129: value += string.Join(", ", objectReader.ReadBytes(10)); break; case TableField.Unknown130: address = objectReader.ReadInt32(); value += $"{address.ToString("X8")}, {objectReader.ReadInt32()}, {objectReader.ReadInt32()}, {objectReader.ReadInt32()}"; break; case TableField.Unknown131: case TableField.Unknown132: address = objectReader.ReadInt32(); value += $"{address.ToString("X8")}, {objectReader.ReadInt32()}, {objectReader.ReadInt32()}"; break; default: throw new NotImplementedException(); } var entry = MxrObjectReader.ReadString(objectReader); if (address != 0) { Strings.Add(address, entry); } InfoText += $"{value}, {entry}\n"; if (objectReader.ReadUInt16() != 0) { objectReader.BaseStream.Position--; } return(true); }
protected override void Read() { MxrObjectReader.Read <TableField>(this, ClassIDType.MonoScript, ReadField, withHeader: false); m_Name = "Table"; m_Script = Encoding.UTF8.GetBytes(InfoText); }
protected override void Read() { MxrObjectReader.Read <WaveField>(this, ClassIDType.AudioClip, ReadField); }
public MxrMidi(ObjectReader objectReader) : base(objectReader) { MxrObjectReader.Read <MidiField>(this, ClassIDType.AudioImporter, ReadField); }
protected override void Read() { MxrObjectReader.Read <ScoreField>(this, ClassIDType.MonoScript, ReadField, 0, withHeader: false); }
private bool ReadField(ObjectReader objectReader, Dictionary <ModelField, int> fieldValues, ModelField field) { switch (field) { case ModelField.End: m_SubMeshes = _subMeshes.ToArray(); if (_faceGroups == null) { m_SubMeshes.Single().indices = _indices; } else { for (int i = 0; i < _faceGroups.Length; i++) { foreach (var j in _indicesByFace[i]) { var subMeshIndices = m_SubMeshes[_faceGroups[i]].indices; subMeshIndices.Add(_indices[j + 0]); subMeshIndices.Add(_indices[j + 1]); subMeshIndices.Add(_indices[j + 2]); } } } return(false); case ModelField.UnknownMarker19: return(true); case ModelField.UnknownShort150: _subMesh.Properties.Add(field, objectReader.ReadInt16()); return(true); case ModelField.UnknownArray22: var unknown22 = objectReader.ReadBytes((int)_subMesh.Properties[ModelField.VertexCount]); _subMesh.Properties.Add(field, unknown22.Count()); return(true); case ModelField.Vertices: m_VertexCount = (int)_subMesh.Properties[ModelField.VertexCount]; m_Vertices = objectReader.ReadSingleArray(3 * m_VertexCount); return(true); case ModelField.FacesSingle: _subMesh.Properties[field] = objectReader.ReadByte(); var indices = objectReader.ReadBytes((int)_subMesh.Properties[ModelField.IndexCount]); UnpackFaces(indices.Select(b => (ushort)b).ToArray()); return(true); case ModelField.FacesDouble: UnpackFaces(Enumerable.Range(0, (int)_subMesh.Properties[ModelField.IndexCount]) .Select(i => objectReader.ReadUInt16()).ToArray()); return(true); case ModelField.FaceGroups34: if ((int)_subMesh.Properties[ModelField.IndexCount] != 0) { _faceGroups = Enumerable.Range(0, (int)_subMesh.Properties[ModelField.FaceCount]) .Select(i => objectReader.ReadInt16()) .ToArray(); } return(true); case ModelField.FaceGroups36: var bitsPerItem = objectReader.ReadByte(); var byteCount = (int)_subMesh.Properties[ModelField.FaceCount] * bitsPerItem / 32.0; var faceGroups = objectReader.ReadBytes((int)Math.Ceiling(byteCount)); if (bitsPerItem == 16) { faceGroups = faceGroups.SelectMany(b => new[] { (byte)((b & 0xF0) >> 4), (byte)(b & 0x0F) }) .ToArray(); } if (byteCount != Math.Ceiling(byteCount)) { faceGroups = faceGroups.Take(faceGroups.Length - 1).ToArray(); } _faceGroups = faceGroups.Select(b => (short)b).ToArray(); return(true); case ModelField.UnknownArray113: _subMesh.Properties.Add(field, objectReader.ReadBytes(12)); return(true); case ModelField.UnknownArray115: _subMesh.Properties.Add(field, Enumerable.Range(0, 6) .Select(i => objectReader.ReadUInt32()) .Where(i => i != uint.MaxValue) .ToArray()); return(true); case ModelField.MaterialAmbient: _subMesh.color = Enumerable.Range(0, 4).Select(i => objectReader.ReadSingle()).ToArray(); return(true); case ModelField.MaterialPower: case ModelField.MaterialEmissive: case ModelField.MaterialSpecular: _subMesh.Properties.Add(field, Enumerable.Range(0, 4) .Select(i => objectReader.ReadSingle()) .ToArray()); return(true); case ModelField.UnknownShort149: case ModelField.UnknownShort151: _subMesh.Properties.Add(field, objectReader.ReadInt16()); return(true); case ModelField.FaceCount: case ModelField.IndexCount: case ModelField.VertexCount: case ModelField.UnknownInt21: case ModelField.UnknownInt23: case ModelField.UnknownInt112: case ModelField.UnknownInt114: case ModelField.Texture: case ModelField.UnknownInt129: case ModelField.UnknownInt130: case ModelField.TextureGroup: case ModelField.UnknownInt152: case ModelField.UnknownInt154: case ModelField.UnknownInt176: case ModelField.UnknownInt178: case ModelField.UnknownInt192: case ModelField.UnknownInt193: case ModelField.UnknownInt194: case ModelField.UnknownInt195: case ModelField.UnknownInt198: case ModelField.UnknownInt199: case ModelField.UnknownInt200: case ModelField.UnknownInt201: case ModelField.UnknownInt202: if (_subMesh == null || _subMesh.Properties.ContainsKey(field)) { _subMeshes.Add(_subMesh = new MxrSubMesh()); } _subMesh.Properties.Add(field, objectReader.ReadInt32()); return(true); case ModelField.UnknownFloat148: case ModelField.TextureDivisionU: case ModelField.TextureDivisionV: case ModelField.TexturePositionU: case ModelField.TexturePositionV: case ModelField.TextureRotateX: case ModelField.TextureRotateY: case ModelField.TextureRotateZ: case ModelField.UnknownFloat196: case ModelField.UnknownFloat197: _subMesh.Properties.Add(field, objectReader.ReadSingle()); return(true); case ModelField.GroupName: _subMesh.Properties.Add(field, _subMeshes.Count + " " + MxrObjectReader.ReadString(objectReader)); return(true); default: throw new NotImplementedException(); } }
public MxrLight(ObjectReader objectReader) : base(objectReader) { MxrObjectReader.Read <LightField>(this, ClassIDType.Light, ReadField); }