private void Initialize() { s_PreparePerfMarker.Begin(); drawDebug = false; Debug.Log("AtmosManager: Initializing tiles"); // Initialize all tiles with atmos tileObjects = tileManager.GetAllTiles(); int tilesInstantiated = 0; int pipesInstantiated = 0; int devicesInstantiated = 0; foreach (TileObject tile in tileObjects) { tile.atmos = ScriptableObject.CreateInstance <AtmosObject>(); tile.atmos.MakeEmpty(); tile.atmos.MakeAir(); tile.atmos.RemoveFlux(); // Set walls blocked if (tile.Tile.turf) { if (tile.Tile.turf.isWall) { tile.atmos.SetBlocked(true); } } // Set neighbouring tiles... kill me string[] coords = tile.name.Split(','); int x = Int32.Parse(coords[0].Replace("[", "")); int y = Int32.Parse(coords[1].Replace("]", "")); // Top Tuple <int, int> tileCoordinates = DirectionHelper.ToCardinalVector(Direction.North); TileObject tileNeighbour = tileManager.GetTile(tileCoordinates.Item1 + x, tileCoordinates.Item2 + y); tile.atmos.setTileNeighbour(tileNeighbour, 0); // Bottom Tuple <int, int> tileCoordinates2 = DirectionHelper.ToCardinalVector(Direction.South); TileObject tileNeighbour2 = tileManager.GetTile(tileCoordinates2.Item1 + x, tileCoordinates2.Item2 + y); tile.atmos.setTileNeighbour(tileNeighbour2, 1); // Left Tuple <int, int> tileCoordinates3 = DirectionHelper.ToCardinalVector(Direction.West); TileObject tileNeighbour3 = tileManager.GetTile(tileCoordinates3.Item1 + x, tileCoordinates3.Item2 + y); tile.atmos.setTileNeighbour(tileNeighbour3, 2); // Right Tuple <int, int> tileCoordinates4 = DirectionHelper.ToCardinalVector(Direction.East); TileObject tileNeighbour4 = tileManager.GetTile(tileCoordinates4.Item1 + x, tileCoordinates4.Item2 + y); tile.atmos.setTileNeighbour(tileNeighbour4, 3); atmosTiles.Add(tile.atmos); // Pipe init PipeObject pipe = tile.GetComponentInChildren <PipeObject>(); if (pipe != null) { pipe.SetTileNeighbour(tileNeighbour, 0); pipe.SetTileNeighbour(tileNeighbour2, 1); pipe.SetTileNeighbour(tileNeighbour3, 2); pipe.SetTileNeighbour(tileNeighbour4, 3); pipeTiles.Add(pipe); pipesInstantiated++; } //// Do pumps IAtmosLoop device = tile.GetComponentInChildren <IAtmosLoop>(); if (device != null) { device.SetTileNeighbour(tileNeighbour, 0); device.SetTileNeighbour(tileNeighbour2, 1); device.SetTileNeighbour(tileNeighbour3, 2); device.SetTileNeighbour(tileNeighbour4, 3); deviceTiles.Add(device); devicesInstantiated++; } tilesInstantiated++; } // Set neighbouring atmos after all are created foreach (TileObject tile in tileObjects) { // Atmos tiles and pipes tile.atmos.setAtmosNeighbours(); PipeObject pipe = tile.GetComponentInChildren <PipeObject>(); if (pipe) { pipe.SetAtmosNeighbours(); } IAtmosLoop device = tile.GetComponentInChildren <IAtmosLoop>(); if (device != null) { device.Initialize(); } // tile.atmos.ValidateVacuum(); // Set airlocks to blocked if (tile.Tile.fixtures != null) { Fixture fixture = tile.Tile.fixtures.GetFloorFixtureAtLayer(FloorFixtureLayers.FurnitureFixtureMain); if (fixture) { if (fixture.name.Contains("Airlock")) { tile.atmos.SetBlocked(true); } } } } Debug.Log($"AtmosManager: Finished initializing {tilesInstantiated} tiles, {pipesInstantiated} pipes and {devicesInstantiated} devices"); lastStep = Time.fixedTime; s_PreparePerfMarker.End(); }