public TexBlock(EndianBinaryReader reader) { Images = new List <BinaryTextureImage>(); Textures = new List <Texture>(); // Get the offset of the TexBlock, save the reader's current offset, then go to the TexBlock int offset = reader.ReadInt32(); long curOffset = reader.BaseStream.Position; reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin); // Get the offset of the first texture's image data int firstTexOffset = offset + reader.ReadInt32At(offset + 8); // We'll read texture data as long as the next image's width isn't 0 and // the stream's position isn't at the place where the first texture's image data starts. while (reader.PeekReadInt16() != 0 && reader.BaseStream.Position != firstTexOffset) { BinaryTextureImage tex = new BinaryTextureImage(); tex.LoadBinTex(reader, offset); Images.Add(tex); } //DumpTextures(@"D:\SZS Tools\TextureTest"); reader.BaseStream.Seek(curOffset, System.IO.SeekOrigin.Begin); }