Пример #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(Int3 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);

                    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);
                    }
                }
            }
        }
Пример #2
0
        public void ParseFile(Int3 batchId, string pathPrefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            // This isn't always gonna work.
            string path     = Properties.Settings.Default.BuildDir;
            string fileName = path + pathPrefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + "-" + suffix + ".bin";

            if (!File.Exists(fileName))
            {
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellManager.CellHeader        cellHeader      = serializer.Deserialize <CellManager.CellHeader>(stream);
                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }
Пример #3
0
        public void ParseFile(Int3 batchId, string pathPrefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            string path     = Path.Combine(SteamFinder.FindSteamGamePath(264710, "Subnautica"), "SNUnmanagedData/Build18") + "/";
            string fileName = path + pathPrefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + "-" + suffix + ".bin";

            if (!File.Exists(fileName))
            {
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellManager.CellHeader        cellHeader      = serializer.Deserialize <CellManager.CellHeader>(stream);
                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }
Пример #4
0
        public void ParseFile(Int3 batchId, string pathPrefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            // This isn't always gonna work.
            string path     = @"C:\Program Files (x86)\Steam\steamapps\common\Subnautica\SNUnmanagedData\Build18\";
            string fileName = path + pathPrefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + "-" + suffix + ".bin";

            if (!File.Exists(fileName))
            {
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellManager.CellHeader        cellHeader      = serializer.Deserialize <CellManager.CellHeader>(stream);
                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }
Пример #5
0
        public void ParseFile(Int3 batchId, string pathPrefix, string prefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            List <string>     errors         = new List <string>();
            Optional <string> subnauticaPath = GameInstallationFinder.Instance.FindGame(errors);

            if (subnauticaPath.IsEmpty())
            {
                Log.Info($"Could not locate Subnautica installation directory: {Environment.NewLine}{string.Join(Environment.NewLine, errors)}");
                return;
            }

            string path     = Path.Combine(subnauticaPath.Get(), "SNUnmanagedData", "Build18");
            string fileName = Path.Combine(path, pathPrefix, prefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + suffix + ".bin");

            if (!File.Exists(fileName))
            {
                //Log.Debug("File does not exist: " + fileName);
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

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

                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }
Пример #6
0
        public void ParseFile(Int3 batchId, string pathPrefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            Optional <string> subnauticaPath = SteamHelper.FindSubnauticaPath();

            if (subnauticaPath.IsEmpty())
            {
                Log.Info("Could not locate subnautica root in steam using fallback");
                subnauticaPath = Optional <string> .Of(Path.GetFullPath("."));
            }

            string path     = Path.Combine(subnauticaPath.Get(), "SNUnmanagedData/Build18");
            string fileName = Path.Combine(path, pathPrefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + "-" + suffix + ".bin");

            if (!File.Exists(fileName))
            {
                Log.Info("Fallback path and Steam path failed! Please move SNUnmanagedData/Build18 to {0}", Path.Combine(Path.GetFullPath("."), "\\SNUnmanagedData\\Build18"));
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellManager.CellHeader        cellHeader      = serializer.Deserialize <CellManager.CellHeader>(stream);
                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }
Пример #7
0
        public void ParseFile(Int3 batchId, string pathPrefix, string suffix, List <EntitySpawnPoint> spawnPoints)
        {
            Optional <string> subnauticaPath = SteamHelper.FindSubnauticaPath();

            if (subnauticaPath.IsEmpty())
            {
                throw new InvalidOperationException("Could not locate subnautica root");
            }

            string path     = Path.Combine(subnauticaPath.Get(), "SNUnmanagedData/Build18");
            string fileName = Path.Combine(path, pathPrefix + "batch-cells-" + batchId.x + "-" + batchId.y + "-" + batchId.z + "-" + suffix + ".bin");

            if (!File.Exists(fileName))
            {
                return;
            }

            using (Stream stream = File.OpenRead(fileName))
            {
                CellManager.CellsFileHeader cellsFileHeader = serializer.Deserialize <CellManager.CellsFileHeader>(stream);

                for (int cellCounter = 0; cellCounter < cellsFileHeader.numCells; cellCounter++)
                {
                    CellManager.CellHeader        cellHeader      = serializer.Deserialize <CellManager.CellHeader>(stream);
                    ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream);

                    for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++)
                    {
                        GameObject gameObject = DeserializeGameObject(stream);

                        EntitySpawnPoint esp = EntitySpawnPoint.From(batchId, gameObject, cellHeader);
                        spawnPoints.Add(esp);
                    }
                }
            }
        }