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); } } } }
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); } } } }
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); } } } }
private void ParseGameObjectsFromStream(Stream stream, Int3 batchId, Int3 cellId, int level, List <EntitySpawnPoint> spawnPoints) { ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream); for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++) { GameObject gameObject = DeserializeGameObject(stream); if (gameObject.TotalComponents > 0) { AbsoluteEntityCell absoluteEntityCell = new AbsoluteEntityCell(batchId, cellId, level); Transform transform = gameObject.GetComponent <Transform>(); EntitySlotsPlaceholder entitySlotsPlaceholder = gameObject.GetComponent <EntitySlotsPlaceholder>(); EntitySlot entitySlot = gameObject.GetComponent <EntitySlot>(); if (!ReferenceEquals(entitySlotsPlaceholder, null)) { spawnPoints.AddRange(EntitySpawnPoint.From(absoluteEntityCell, entitySlotsPlaceholder)); } else if (!ReferenceEquals(entitySlot, null)) { spawnPoints.Add(EntitySpawnPoint.From(absoluteEntityCell, transform.Position, transform.Rotation, transform.Scale, gameObject.ClassId, entitySlot)); } else { spawnPoints.Add(EntitySpawnPoint.From(absoluteEntityCell, transform.Position, transform.Rotation, transform.Scale, gameObject.ClassId)); } } } }
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); } } } }
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); } } } }
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); } } } }