Пример #1
0
 public BA2StateObject(BA2Reader ba2Reader)
 {
     Version      = ba2Reader._version;
     HeaderMagic  = ba2Reader._headerMagic;
     Type         = ba2Reader._type;
     HasNameTable = ba2Reader.HasNameTable;
 }
Пример #2
0
 public static async ValueTask <IBSAReader> OpenRead(AbsolutePath filename)
 {
     return(await BSASignatures.MatchesAsync(filename) switch
     {
         Definitions.FileType.TES3 => await TES3Reader.Load(new NativeFileStreamFactory(filename)),
         Definitions.FileType.BSA => await BSAReader.LoadAsync(new NativeFileStreamFactory(filename)),
         Definitions.FileType.BA2 => await BA2Reader.Load(new NativeFileStreamFactory(filename)),
         _ => throw new InvalidDataException("Filename is not a .bsa or .ba2")
     });
Пример #3
0
        public static async Task <BA2Reader> Load(IStreamFactory streamFactory)
        {
            var rdr = new BA2Reader(await streamFactory.GetStream())
            {
                _streamFactory = streamFactory
            };
            await rdr.LoadHeaders();

            return(rdr);
        }
Пример #4
0
        public static async Task <BA2Reader> Load(AbsolutePath filename)
        {
            var rdr = new BA2Reader(await filename.OpenShared())
            {
                _filename = filename
            };
            await rdr.LoadHeaders();

            return(rdr);
        }
Пример #5
0
        public BA2FileEntry(BA2Reader ba2Reader, int index)
        {
            _index = index;
            _bsa   = ba2Reader;
            var _rdr = ba2Reader._rdr;

            _nameHash  = _rdr.ReadUInt32();
            FullPath   = _nameHash.ToString("X");
            _extension = Encoding.UTF7.GetString(_rdr.ReadBytes(4));
            _dirHash   = _rdr.ReadUInt32();
            _flags     = _rdr.ReadUInt32();
            _offset    = _rdr.ReadUInt64();
            _size      = _rdr.ReadUInt32();
            _realSize  = _rdr.ReadUInt32();
            _align     = _rdr.ReadUInt32();
        }
Пример #6
0
        public static async ValueTask <IBSAReader> OpenRead(AbsolutePath filename)
        {
            var fourcc = "";

            using (var file = await filename.OpenRead())
            {
                fourcc = Encoding.ASCII.GetString(new BinaryReader(file).ReadBytes(4));
            }

            if (fourcc == TES3Reader.TES3_MAGIC)
            {
                return(await TES3Reader.Load(filename));
            }
            if (fourcc == "BSA\0")
            {
                return(await BSAReader.Load(filename));
            }
            if (fourcc == "BTDX")
            {
                return(await BA2Reader.Load(filename));
            }
            throw new InvalidDataException("Filename is not a .bsa or .ba2, magic " + fourcc);
        }
Пример #7
0
        public BA2DX10Entry(BA2Reader ba2Reader, int idx)
        {
            _bsa = ba2Reader;
            var _rdr = ba2Reader._rdr;

            _nameHash    = _rdr.ReadUInt32();
            FullPath     = _nameHash.ToString("X");
            _extension   = Encoding.UTF7.GetString(_rdr.ReadBytes(4));
            _dirHash     = _rdr.ReadUInt32();
            _unk8        = _rdr.ReadByte();
            _numChunks   = _rdr.ReadByte();
            _chunkHdrLen = _rdr.ReadUInt16();
            _height      = _rdr.ReadUInt16();
            _width       = _rdr.ReadUInt16();
            _numMips     = _rdr.ReadByte();
            _format      = _rdr.ReadByte();
            _unk16       = _rdr.ReadUInt16();
            _index       = idx;

            _chunks = Enumerable.Range(0, _numChunks)
                      .Select(_ => new BA2TextureChunk(_rdr))
                      .ToList();
        }