public static TextureHeader Read(BinaryReader aReader, InfoHeader aInfo) { var texture = new TextureHeader(); texture.ReadBase(aReader); // Textures contain an EntryListOffset var entryListAddress = aReader.ReadInt32() + aInfo.RootAddress; // Addresses we read are offset from the RootAddress stored in the InfoHeader. aReader.BaseStream.Position = entryListAddress; // Now we read the EntryListHeader var entryListHeader = EntryListHeader.Read(aInfo, aReader); // Then we read the entries, which are located at ListAddress + (index * 20) + 4 foreach (int index in Enumerable.Range(0, (int)entryListHeader.Count)) { aReader.BaseStream.Position = entryListHeader.ListAddress + (index * 20) + 4; var entry = Entry.Read(aInfo, aReader); texture.Entries.Add(entry); } texture.GoToEnd(aReader); return(texture); }
public UInt32 ListAddress; // Address of the list. public static EntryListHeader Read(InfoHeader aInfo, BinaryReader aReader) { var entryListHeader = new EntryListHeader(); entryListHeader.Count = aReader.ReadUInt32(); entryListHeader.ListAddress = aReader.ReadUInt32() + aInfo.RootAddress; return(entryListHeader); }