public Stream26 ToStream() { Stream26 stream = new Stream26(true); int textureCount = this.TextureCount(); int textureMetaDataOffset = 0; if (!this._unkFlag0) { stream.WriteUInt(0xFACECAA7); //meow stream.WriteShort(284); stream.WriteShort((short)textureCount); stream.WriteInt(0); stream.WriteInt(0); stream.WriteInt(-1); int num3 = 2; while ((double)textureCount / Math.Pow(2.0, (double)(num3 - 2)) > 1.0) { num3++; } num3--; stream.WriteInt(num3); //logarithm of textureCount?.. stream.WriteInt(28); stream.WriteNBytes(0xEF, (int)(Math.Pow(2.0, (double)num3) * 12.0 + 28.0)); textureMetaDataOffset = (int)stream.Position; stream.WriteIntAt(8, textureMetaDataOffset); stream.WriteInt(textureMetaDataOffset + textureCount * 44); stream.Position = (long)textureMetaDataOffset; } stream.WriteNBytes(0, 40 * textureCount); for (int i = 0; i < textureCount; i++) { TextureMetadata tex = this.textureList[i]; byte[] array = this.method_2(i); stream.WriteShortAt(textureMetaDataOffset + 40 * i, 2600); stream.WriteShort(tex.unkShort0); stream.WriteInt(tex.unkInt); stream.WriteShort(tex.Width); stream.WriteShort(tex.Height); stream.WriteShort(tex.unkShort3); stream.WriteShort(tex.Width); stream.WriteShort(tex.Height); stream.WriteShort(tex.unkShort3); stream.WriteByte2(tex.MipMapCount); stream.WriteShort(tex.unkShort4); stream.WriteNBytes(0, 5); stream.WriteInt((int)stream.Length); stream.WriteInt(array.Length); stream.WriteInt(0); stream.WriteByteArrayAt((int)stream.Length, array, false); } return stream; }