public static Formats.Modl ParseModl(this SsbhParser parser) { var result = new Formats.Modl(); result.Magic = parser.ReadUInt32(); result.MajorVersion = parser.ReadUInt16(); result.MinorVersion = parser.ReadUInt16(); result.ModelFileName = parser.ReadOffsetReadString(); result.SkeletonFileName = parser.ReadOffsetReadString(); { // TODO: Extract this code to a method? long absoluteOffset = parser.ReadRelativeGetAbsoluteOffset(); long elementCount = parser.ReadInt64(); long previousPosition = parser.Position; parser.Seek(absoluteOffset); result.MaterialFileNames = new Formats.ModlMaterialName[elementCount]; for (int i = 0; i < elementCount; i++) { result.MaterialFileNames[i] = parser.ParseModlMaterialName(); } parser.Seek(previousPosition); } result.Unk1 = parser.ReadInt64(); result.MeshString = parser.ReadOffsetReadString(); { // TODO: Extract this code to a method? long absoluteOffset = parser.ReadRelativeGetAbsoluteOffset(); long elementCount = parser.ReadInt64(); long previousPosition = parser.Position; parser.Seek(absoluteOffset); result.ModelEntries = new Formats.ModlEntry[elementCount]; for (int i = 0; i < elementCount; i++) { result.ModelEntries[i] = parser.ParseModlEntry(); } parser.Seek(previousPosition); } return(result); }