Beispiel #1
0
        private void LoadUnityFs(UnityDataReader reader)
        {
            unityfsDescriptor             = new UnityfsDescriptor();
            unityfsDescriptor.fsFileSize  = reader.ReadInt64();
            unityfsDescriptor.ciblockSize = reader.ReadUInt32();
            unityfsDescriptor.uiblockSize = reader.ReadUInt32();

            var flags = reader.ReadUInt32();

            var compression = (CompressionType)(flags & 0x3F);

            var blk = new UnityDataArrayReader(ReadCompressedData(reader, (int)unityfsDescriptor.ciblockSize, (int)unityfsDescriptor.uiblockSize, compression));

            blk.ReadBytes(16);             // guid

            // read Archive block infos
            var numBlocks = blk.ReadInt32();

            ArchiveBlockInfo[] blocks = new ArchiveBlockInfo[numBlocks];
            for (int i = 0; i < numBlocks; i++)
            {
                var busize = blk.ReadInt32();
                var bcsize = blk.ReadInt32();
                var bflags = blk.ReadInt16();

                blocks[i] = new ArchiveBlockInfo(busize, bcsize, bflags);
            }

            // Read Asset data infos
            var numNodes = blk.ReadInt32();

            AssetDataInfo[] nodes = new AssetDataInfo[numNodes];
            for (int i = 0; i < numNodes; i++)
            {
                var offset = blk.ReadInt64();
                var size   = blk.ReadInt64();
                var status = blk.ReadInt32();
                var name   = blk.ReadString();

                nodes[i] = new AssetDataInfo(offset, size, status, name);
            }

            // read block storage
            var storage = new ArchiveBlockStorage(blocks, reader);

            foreach (var info in nodes)
            {
                storage.Seek(info.Offset);
                var asset = new Asset(this, storage, info.Name);

                Assets.Add(asset);
            }

            if (Assets.Count > 0)
            {
                Name = Assets[0].Name;
            }
        }
Beispiel #2
0
        void SeekToBlock(long pos)
        {
            Int32 baseOffset = 0;
            Int32 offset     = 0;

            foreach (var b in blocks)
            {
                if ((offset + b.UncompressedSize) > pos)
                {
                    currentBlock = b;
                    break;
                }
                baseOffset += b.compressedSize;
                offset     += b.UncompressedSize;
            }

            this.reader.Seek(basePos + baseOffset);
            if (currentBlock != null)
            {
                var buf = reader.ReadBytes(currentBlock.compressedSize);

                currentStream = new UnityDataArrayReader(currentBlock.Decompress(buf));
            }
        }