void GenMainRoad(Stencil s, TerrainDef roadTerrain, TerrainDef divTerrain, TerrainDef sidewalkTerrain) { s.Bound(-3, 0, 3, s.MaxZ) .BorderTerrain(sidewalkTerrain, (m, p) => IsValidSidewalkTerrain(p.GetTerrain(m))); s.Bound(-2, 0, 2, s.MaxZ) .ClearThingsInBounds() .FillTerrain(roadTerrain); var s1 = s; s.Bound(-4, 0, 4, s.MaxZ) .BorderTerrain(TerrainUtility.Bridge, (m, p) => p.GetTerrain(m).IsWater); s.FillTerrain(0, 0, 0, s.MaxZ, divTerrain); s = s.Move(0, roadSpacing.RandomInRange); while (s.Expand(-2).IsInBounds()) { if (s.Chance(roadChance)) { GenSideRoad(s.Left().Move(0, 3), roadTerrain, sidewalkTerrain); } if (s.Chance(roadChance)) { GenSideRoad(s.Right().Move(0, 3), roadTerrain, sidewalkTerrain); } s = s.Move(0, roadSpacing.RandomInRange); } }