public IEnumerator ConstructTK2DDungeonHook(Action <TK2DDungeonAssembler, Dungeon, tk2dTileMap> orig, TK2DDungeonAssembler self, Dungeon d, tk2dTileMap map) { for (int j = 0; j < d.data.Width; j++) { for (int k = 0; k < d.data.Height; k++) { try { self.BuildTileIndicesForCell(d, map, j, k); } catch (Exception ex) { if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Exception caught in TK2DDungeonAssembler.ConstructTK2DDungeonHook at TK2DDungeonAssembler.BuildTileIndicesForCell!"); } Debug.Log("Exception caught in TK2DDungeonAssembler.ConstructTK2DDungeonHook at TK2DDungeonAssembler.BuildTileIndicesForCell!"); Debug.LogException(ex); } } } yield return(null); TileIndices tileIndices = ReflectionHelpers.ReflectGetField <TileIndices>(typeof(TK2DDungeonAssembler), "t", self); if (d.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.WESTGEON || d.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.FINALGEON) { for (int l = 0; l < d.data.Width; l++) { for (int m = 0; m < d.data.Height; m++) { CellData cellData = d.data.cellData[l][m]; if (cellData != null) { if (cellData.type == CellType.FLOOR) { BuildShadowIndex(self, tileIndices, cellData, d, map, l, m); } else if (cellData.type == CellType.PIT) { BuildPitShadowIndex(self, tileIndices, cellData, d, map, l, m); } } } } } TK2DInteriorDecorator decorator = new TK2DInteriorDecorator(self); decorator.PlaceLightDecoration(d, map); for (int i = 0; i < d.data.rooms.Count; i++) { if (d.data.rooms[i].area.prototypeRoom == null || d.data.rooms[i].area.prototypeRoom.usesProceduralDecoration) { decorator.HandleRoomDecoration(d.data.rooms[i], d, map); } else { decorator.HandleRoomDecorationMinimal(d.data.rooms[i], d, map); } if (i % 5 == 0) { yield return(null); } } if ((d.data.rooms.Count - 1) % 5 != 0) { yield return(null); } map.Editor__SpriteCollection = tileIndices.dungeonCollection; if (d.ActuallyGenerateTilemap) { IEnumerator BuildTracker = map.DeferredBuild(tk2dTileMap.BuildFlags.Default); while (BuildTracker.MoveNext()) { yield return(null); } } yield break; }