public void Read(BinaryReader br, bool isMultiTexture) { var baseOffset = br.BaseStream.Position; Id = br.ReadUInt32(); ushort mipsCount = br.ReadUInt16(); Flags = (AlTextureEntryFlags)br.ReadByte(); br.ReadByte(); // Alignment if (!isMultiTexture) { return; } for (int i = 0; i < mipsCount; ++i) { Bounds.Add(new AlXYWH { X = br.ReadInt16(), Y = br.ReadInt16(), W = br.ReadUInt16(), H = br.ReadUInt16() }); } if ((Flags & AlTextureEntryFlags.IsHasCenterPoint) != 0) { CenterPoint = new AlPoint { X = br.ReadInt16(), Y = br.ReadInt16() }; } if ((Flags & AlTextureEntryFlags.IsHasName) != 0) { br.BaseStream.Seek(baseOffset - 0x20, SeekOrigin.Begin); Name = StringReadingHelper.ReadNullTerminatedStringFromFixedSizeBlock(br, 0x20, Encoding.UTF8); } }
void Load() { BinaryReader br = new BinaryReader(stream); if (new string(br.ReadChars(4)) != "ALAR") { throw new InvalidDataException("Not an AquaLead archive."); } if (br.ReadByte() != 2) { throw new NotSupportedException("Not version 2 archive."); } header = new AlAarHeaderV2(); header.Read(br); entries = new List <AlAarEntryV2>(); for (int i = 0; i < header.Count; ++i) { var entry = new AlAarEntryV2(); entry.Read(br); entries.Add(entry); } foreach (var entry in entries) { if ((entry.Flags & AlAarEntryFlags.IsUseName) != 0) { stream.Seek(entry.Offset - 0x22, SeekOrigin.Begin); entry.Name = StringReadingHelper.ReadNullTerminatedStringFromFixedSizeBlock(br, 0x20, Encoding.UTF8); } if ((entry.Flags & ~AlAarEntryFlags.IsUseName) != 0) { Console.WriteLine($"Entry {entry.Name} has other flags set: {entry.Flags}"); //Debugger.Break(); } } }