public static EntitySpawnPoint From(Int3 batchId, GameObject go, CellManager.CellHeader cellHeader) { // Why is this not a constructor? EntitySpawnPoint esp = new EntitySpawnPoint { Level = cellHeader.level, ClassId = go.ClassId, BatchId = batchId, CellId = cellHeader.cellId }; EntitySlot entitySlot = go.GetComponent <EntitySlot>(); if (!ReferenceEquals(entitySlot, null)) { esp.BiomeType = entitySlot.biomeType; esp.Density = entitySlot.density; esp.CanSpawnCreature = entitySlot.IsCreatureSlot(); } Vector3 localPosition = go.GetComponent <Transform>().Position; Int3.Bounds bounds = BatchCells.GetBlockBounds(batchId, cellHeader.cellId, 0, Map.BATCH_DIMENSIONS); UnityEngine.Vector3 center = EntityCell.GetCenter(bounds); esp.Position = new UnityEngine.Vector3(center.x + localPosition.x - Map.BATCH_DIMENSION_CENTERING.x, center.y + localPosition.y - Map.BATCH_DIMENSION_CENTERING.y, center.z + localPosition.z - Map.BATCH_DIMENSION_CENTERING.z); return(esp); }
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 static EntitySpawnPoint From(Int3 batchId, GameObject go, CellManager.CellHeader cellHeader) { // Why is this not a constructor? EntitySpawnPoint esp = new EntitySpawnPoint { AbsoluteEntityCell = new AbsoluteEntityCell(batchId, cellHeader.cellId, cellHeader.level), ClassId = go.ClassId, Density = 1 }; EntitySlot entitySlot = go.GetComponent <EntitySlot>(); if (!ReferenceEquals(entitySlot, null)) { esp.BiomeType = entitySlot.biomeType; esp.Density = entitySlot.density; esp.CanSpawnCreature = entitySlot.IsCreatureSlot(); esp.AllowedTypes = entitySlot.allowedTypes; } esp.Rotation = go.GetComponent <Transform>().Rotation; UnityEngine.Vector3 localPosition = go.GetComponent <Transform>().Position; esp.Position = esp.AbsoluteEntityCell.Center + localPosition; esp.Scale = go.GetComponent <Transform>().Scale; return(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); } } } }
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); } } } }