private static void build_warren(EventHandler callback) { MapBuilder.begin_map(); int num = 0; while (MapBuilder.fMap.Areas.Count < MapBuilder.fData.MaxAreaCount && MapBuilder.fEndpoints.Count != 0 && num != 100) { int num1 = Session.Random.Next() % MapBuilder.fEndpoints.Count; Endpoint item = MapBuilder.fEndpoints[num1]; bool flag = true; switch (Session.Random.Next() % 10) { case 0: case 1: case 2: { try { flag = MapBuilder.add_area(item); break; } catch (Exception exception) { LogSystem.Trace(exception); flag = false; break; } } case 3: case 4: case 5: case 6: case 7: { try { flag = MapBuilder.add_corridor(item, false); break; } catch (Exception exception1) { LogSystem.Trace(exception1); flag = false; break; } } case 8: { try { if (item.Category != TileCategory.Doorway) { flag = MapBuilder.add_doorway(item); } break; } catch (Exception exception2) { LogSystem.Trace(exception2); flag = false; break; } } case 9: { try { flag = MapBuilder.add_stairway(item); break; } catch (Exception exception3) { LogSystem.Trace(exception3); flag = false; break; } } } if (!flag) { num++; } else { MapBuilder.fEndpoints.Remove(item); num = 0; callback(null, null); } } List <TileData> tileDatas = new List <TileData>(); foreach (TileData tile in MapBuilder.fMap.Tiles) { Tile tile1 = Session.FindTile(tile.TileID, SearchType.Global); if (tile1 != null) { if (tile1.Category != TileCategory.Doorway) { continue; } Rectangle _rect = MapBuilder.get_rect(tile1, tile); int num2 = 0; int left = _rect.Left; while (left != _rect.Right) { int top = _rect.Top - 1; if (MapBuilder.tile_at_point(new Point(left, top)) != null) { left++; } else { num2++; break; } } int left1 = _rect.Left; while (left1 != _rect.Right) { int bottom = _rect.Bottom + 1; if (MapBuilder.tile_at_point(new Point(left1, bottom)) != null) { left1++; } else { num2++; break; } } int top1 = _rect.Top; while (top1 != _rect.Bottom) { int left2 = _rect.Left - 1; if (MapBuilder.tile_at_point(new Point(left2, top1)) != null) { top1++; } else { num2++; break; } } int top2 = _rect.Top; while (top2 != _rect.Bottom) { int right = _rect.Right + 1; if (MapBuilder.tile_at_point(new Point(right, top2)) != null) { top2++; } else { num2++; break; } } if (num2 == 2) { continue; } tileDatas.Add(tile); } else { tileDatas.Add(tile); } } foreach (TileData tileData in tileDatas) { MapBuilder.fMap.Tiles.Remove(tileData); callback(null, null); } }