예제 #1
0
        /**
         * It is suspected that 'cache' is a misnomer carried over from when UWE was actually doing procedurally
         * generated worlds.  In the final release, this 'cache' has simply been baked into a final version that
         * we can parse.
         */
        private void ParseCacheCells(NitroxInt3 batchId, string fileName, List <EntitySpawnPoint> spawnPoints)
        {
            using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                CellsFileHeader cellsFileHeader = serializer.Deserialize <CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.NumCells; cellCounter++)
                {
                    CellHeaderEx cellHeader = serializer.Deserialize <CellHeaderEx>(stream);


                    byte[] serialData = new byte[cellHeader.DataLength];
                    stream.Read(serialData, 0, cellHeader.DataLength);
                    ParseGameObjectsWithHeader(serialData, batchId, cellHeader.CellId, cellHeader.Level, spawnPoints, out bool wasLegacy);

                    if (!wasLegacy)
                    {
                        byte[] legacyData = new byte[cellHeader.LegacyDataLength];
                        stream.Read(legacyData, 0, cellHeader.LegacyDataLength);
                        ParseGameObjectsWithHeader(legacyData, batchId, cellHeader.CellId, cellHeader.Level, spawnPoints, out wasLegacy);

                        byte[] waiterData = new byte[cellHeader.WaiterDataLength];
                        stream.Read(waiterData, 0, cellHeader.WaiterDataLength);
                        ParseGameObjectsFromStream(new MemoryStream(waiterData), batchId, cellHeader.CellId, cellHeader.Level, spawnPoints);
                    }
                }
            }
        }
예제 #2
0
        /**
         * It is suspected that 'cache' is a misnomer carried over from when UWE was actually doing procedurally
         * generated worlds.  In the final release, this 'cache' has simply been baked into a final version that
         * we can parse.
         */
        private void ParseCacheCells(Int3 batchId, string fileName, List <EntitySpawnPoint> spawnPoints)
        {
            using (Stream stream = File.OpenRead(fileName))
            {
                CellsFileHeader cellsFileHeader = serializer.Deserialize <CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellHeaderEx cellHeader = serializer.Deserialize <CellHeaderEx>(stream);

                    bool wasLegacy;

                    byte[] serialData = new byte[cellHeader.dataLength];
                    stream.Read(serialData, 0, cellHeader.dataLength);
                    ParseGameObjectsWithHeader(serialData, batchId, cellHeader.cellId, cellHeader.level, spawnPoints, out wasLegacy);

                    if (!wasLegacy)
                    {
                        byte[] legacyData = new byte[cellHeader.legacyDataLength];
                        stream.Read(legacyData, 0, cellHeader.legacyDataLength);
                        ParseGameObjectsWithHeader(legacyData, batchId, cellHeader.cellId, cellHeader.level, spawnPoints, out wasLegacy);

                        byte[] waiterData = new byte[cellHeader.waiterDataLength];
                        stream.Read(waiterData, 0, cellHeader.waiterDataLength);
                        ParseGameObjectsFromStream(new MemoryStream(waiterData), batchId, cellHeader.cellId, cellHeader.level, spawnPoints);
                    }
                }
            }
        }