コード例 #1
0
        public bool TryFindQuestMap(PCCPackage pcc, out int exportIndex, out int dataOffset)
        {
            var index = pcc.FindClass("BioQuestMap");

            exportIndex = -1;
            dataOffset  = -1;

            if (index == 0)
            {
                return(false);
            }

            exportIndex = pcc.Exports.FindIndex(entry => entry.idxClass == index);

            if (exportIndex < 0)
            {
                return(false);
            }

            var mapData       = pcc.Exports[exportIndex].Data;
            var mapProperties = PropertyReader.getPropList(pcc, mapData);

            if (mapProperties.Count <= 0)
            {
                return(false);
            }

            var mapProperty = mapProperties.Find(property => property.TypeVal == PropertyReader.Type.None);

            dataOffset = mapProperty.offend;

            return(true);
        }
コード例 #2
0
        public void SaveToPcc(PCCPackage pcc)
        {
            var index = pcc.FindClass("BioCodexMap");

            if (index == 0)
            {
                return;
            }

            var exportIndex = pcc.Exports.FindIndex(entry => entry.idxClass == index);

            if (exportIndex < 0)
            {
                return;
            }

            var codexMapData       = pcc.Exports[exportIndex].Data;
            var codexMapProperties = PropertyReader.getPropList(pcc, codexMapData);

            if (codexMapProperties.Count <= 0)
            {
                return;
            }

            var codexMapProperty   = codexMapProperties.Find(property => property.TypeVal == PropertyReader.Type.None);
            var codexMapDataOffset = codexMapProperty.offend;

            byte[] bytes;
            var    codexMap = new BioCodexMap(CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value),
                                              CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value));

            // CodexMap
            using (var stream = new MemoryStream())
            {
                ((BinaryBioCodexMap)codexMap).Save(stream);

                bytes = stream.ToArray();
            }

            Array.Resize(ref codexMapData, codexMapDataOffset + bytes.Length);
            bytes.CopyTo(codexMapData, codexMapDataOffset);

            var temp = pcc.Exports[exportIndex];

            Array.Resize(ref temp.Data, codexMapData.Length);
            codexMapData.CopyTo(temp.Data, 0);
            pcc.Exports[exportIndex] = temp;
        }