示例#1
0
        public void AddFile(FileStateObject state, Stream src)
        {
            switch (_state.Type)
            {
            case EntryType.GNRL:
                var result = new BA2FileEntryBuilder((BA2FileEntryState)state, src);
                lock (_entries) _entries.Add(result);
                break;

            case EntryType.DX10:
                var resultdx10 = new BA2DX10FileEntryBuilder((BA2DX10EntryState)state, src);
                lock (_entries) _entries.Add(resultdx10);
                break;
            }
        }
示例#2
0
        public async Task AddFile(FileStateObject state, Stream src)
        {
            switch (_state.Type)
            {
            case EntryType.GNRL:
                var result = await BA2FileEntryBuilder.Create((BA2FileEntryState)state, src, _slab);

                lock (_entries) _entries.Add(result);
                break;

            case EntryType.DX10:
                var resultdx10 = await BA2DX10FileEntryBuilder.Create((BA2DX10EntryState)state, src, _slab);

                lock (_entries) _entries.Add(resultdx10);
                break;
            }
        }
示例#3
0
        public static async Task <BA2DX10FileEntryBuilder> Create(BA2DX10EntryState state, Stream src, DiskSlabAllocator slab)
        {
            var builder = new BA2DX10FileEntryBuilder {
                _state = state
            };

            var headerSize = DDS.HeaderSizeForFormat((DXGI_FORMAT)state.PixelFormat) + 4;

            new BinaryReader(src).ReadBytes((int)headerSize);

            // This can't be parallel because it all runs off the same base IO stream.
            builder._chunks = new List <ChunkBuilder>();

            foreach (var chunk in state.Chunks)
            {
                builder._chunks.Add(await ChunkBuilder.Create(state, chunk, src, slab));
            }

            return(builder);
        }