Пример #1
0
 public static TerrainDef TerrainAtFromTerrainPatchMakerByFertility(IntVec3 c, Map map, TerrainDef current)
 {
     if (extIslands.terrainPatchMakerByIslandFertility == null)
     {
         return(null);
     }
     return(TerrainThresholdWEO.TerrainAtValue(extIslands.terrainPatchMakerByIslandFertility, GetValueAt(c, noiseFertility), current));
 }
Пример #2
0
        public static bool Prefix(Map map)
        {
            if (!Find.World.HasCaves(map.Tile))
            {
                return(false);
            }
            ModExt_Biome_GenStep_BetterCaves extCaves = map.Biome.GetModExtension <ModExt_Biome_GenStep_BetterCaves>();

            if (extCaves == null || (extCaves.terrainPatchMakerCaveWater == null && extCaves.terrainPatchMakerCaveGravel == null))
            {
                return(true);
            }
            ModuleBase      noiseWater  = new Perlin(extCaves.terrainPatchMakerFrequencyCaveWater, 2.0, 0.5, 6, Rand.Int, QualityMode.Medium);
            ModuleBase      noiseGravel = new Perlin(extCaves.terrainPatchMakerFrequencyCaveGravel, 2.0, 0.5, 6, Rand.Int, QualityMode.Medium);
            MapGenFloatGrid caves       = MapGenerator.Caves;

            foreach (IntVec3 c in map.AllCells)
            {
                if (caves[c] > 0f)
                {
                    TerrainDef terrain = c.GetTerrain(map);
                    if (!terrain.IsRiver)
                    {
                        // Try set water terrain
                        float      valWater        = (float)noiseWater.GetValue(c);
                        TerrainDef currentTerrain  = map.terrainGrid.TerrainAt(c);
                        TerrainDef newTerrainWater = TerrainThresholdWEO.TerrainAtValue(extCaves.terrainPatchMakerCaveWater, valWater, currentTerrain);
                        if (newTerrainWater != null)
                        {
                            map.terrainGrid.SetTerrain(c, newTerrainWater);
                        }
                        else
                        {
                            // Try set gravel terrain if no water was set first
                            float      valGravel        = (float)noiseGravel.GetValue(c);
                            TerrainDef newTerrainGravel = TerrainThresholdWEO.TerrainAtValue(extCaves.terrainPatchMakerCaveGravel, valGravel, currentTerrain);
                            if (newTerrainGravel != null)
                            {
                                map.terrainGrid.SetTerrain(c, newTerrainGravel);
                            }
                        }
                    }
                }
            }
            return(false);
        }