Example #1
0
        private TerrainDef TerrainFrom(IntVec3 c, Map map, float elevation, float fertility, RiverMaker river, bool preferSolid)
        {
            TerrainDef terrainDef = null;

            if (river != null)
            {
                terrainDef = river.TerrainAt(c, true);
            }
            if (terrainDef == null && preferSolid)
            {
                return(GenStep_RocksFromGrid.RockDefAt(c).building.naturalTerrain);
            }
            TerrainDef terrainDef2 = BeachMaker.BeachTerrainAt(c, map.Biome);

            if (terrainDef2 == TerrainDefOf.WaterOceanDeep)
            {
                return(terrainDef2);
            }
            if (terrainDef != null && terrainDef.IsRiver)
            {
                return(terrainDef);
            }
            if (terrainDef2 != null)
            {
                return(terrainDef2);
            }
            if (terrainDef != null)
            {
                return(terrainDef);
            }
            for (int i = 0; i < map.Biome.terrainPatchMakers.Count; i++)
            {
                terrainDef2 = map.Biome.terrainPatchMakers[i].TerrainAt(c, map, fertility);
                if (terrainDef2 != null)
                {
                    return(terrainDef2);
                }
            }
            if (elevation > 0.55f && elevation < 0.61f)
            {
                return(TerrainDefOf.Gravel);
            }
            if (elevation >= 0.61f)
            {
                return(GenStep_RocksFromGrid.RockDefAt(c).building.naturalTerrain);
            }
            terrainDef2 = TerrainThreshold.TerrainAtValue(map.Biome.terrainsByFertility, fertility);
            if (terrainDef2 != null)
            {
                return(terrainDef2);
            }
            if (!GenStep_Terrain.debug_WarnedMissingTerrain)
            {
                Log.Error(string.Concat(new object[]
                {
                    "No terrain found in biome ",
                    map.Biome.defName,
                    " for elevation=",
                    elevation,
                    ", fertility=",
                    fertility
                }), false);
                GenStep_Terrain.debug_WarnedMissingTerrain = true;
            }
            return(TerrainDefOf.Sand);
        }