Exemplo n.º 1
0
        public IoPackageReader(BinaryReader uasset, Stream ubulk, FIoGlobalData globalData, bool onlyInfo = false)
        {
            Loader     = uasset;
            _ubulk     = ubulk;
            GlobalData = globalData;
            Summary    = new FPackageSummary(this);

            var nameMap    = new List <FNameEntrySerialized>();
            var nameHashes = new List <ulong>();

            if (Summary.NameMapNamesSize > 0)
            {
                Loader.BaseStream.Seek(Summary.NameMapNamesOffset, SeekOrigin.Begin);
                var nameMapNames = Loader.ReadBytes(Summary.NameMapNamesSize);
                Loader.BaseStream.Seek(Summary.NameMapHashesOffset, SeekOrigin.Begin);
                var nameMapHashes = Loader.ReadBytes(Summary.NameMapHashesSize);

                FNameEntrySerialized.LoadNameBatch(nameMap, nameHashes, nameMapNames, nameMapHashes);
            }

            NameMap = nameMap.ToArray();

            Loader.BaseStream.Seek(Summary.ImportMapOffset, SeekOrigin.Begin);
            var importMapCount = (Summary.ExportMapOffset - Summary.ImportMapOffset) / /*sizeof(FPackageObjectIndex)*/ sizeof(ulong);

            ImportMap = new FPackageObjectIndex[importMapCount];
            for (int i = 0; i < importMapCount; i++)
            {
                ImportMap[i] = new FPackageObjectIndex(Loader);
            }

            Loader.BaseStream.Seek(Summary.ExportMapOffset, SeekOrigin.Begin);
            var exportMapCount = (Summary.ExportBundlesOffset - Summary.ExportMapOffset) / FExportMapEntry.SIZE;

            ExportMap = new FExportMapEntry[exportMapCount];
            for (int i = 0; i < exportMapCount; i++)
            {
                ExportMap[i] = new FExportMapEntry(this);
            }

            if (!onlyInfo)
            {
                ReadContent();
            }
        }