예제 #1
0
        public float LakePressure(OverworldGeneratorV2 generator, int x, int y, float border, float lakeInterval,
                                  float largeBendSize, float mediumBendSize, float smallBendSize)
        {
            if (!this.Config.AllowScenicLakes)
            {
                return(1f);
            }

            double         pX         = x;
            double         pY         = y;
            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(x / 240.0d, y / 240.0d, jitterData);
            pX += jitterData.GetDeltaX() * largeBendSize;
            pY += jitterData.GetDeltaY() * largeBendSize;

            generator.SimplexInstance(0).GetValue(x / 80.0d, y / 80.0d, jitterData);
            pX += jitterData.GetDeltaX() * mediumBendSize;
            pY += jitterData.GetDeltaY() * mediumBendSize;

            generator.SimplexInstance(4).GetValue(x / 30.0d, y / 30.0d, jitterData);
            pX += jitterData.GetDeltaX() * smallBendSize;
            pY += jitterData.GetDeltaY() * smallBendSize;

            VoronoiResult lakeResults = generator.CellularInstance(0).Eval2D(pX / lakeInterval, pY / lakeInterval);

            return((float)(1.0d - lakeResults.InteriorValue));
        }
예제 #2
0
        public override float Added(OverworldGeneratorV2 generator, float x, float y)
        {
            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(x / Wavelength, y / Wavelength, jitterData);
            int pX = (int)Math.Round(x + jitterData.GetDeltaX() * Amplitude);
            int pY = (int)Math.Round(y + jitterData.GetDeltaY() * Amplitude);

            return(Jittered.Added(generator, pX, pY));
        }
        private void FixBiomes(ChunkColumn column,
                               ChunkLandscape landscape, int[] neighboring)
        {
            var orginalBiomes = landscape.Biome.ToArray();

            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            BiomeBase[] jitteredBiomes = new BiomeBase[256];
            BiomeBase   jitterbiome, actualbiome;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    int x = (column.X * 16) + i;
                    int z = (column.Z * 16) + j;
                    this.SimplexInstance(0).GetValue(x, z, jitterData);
                    int pX = (int)Math.Round(x + jitterData.GetDeltaX() * BlendRadius);
                    int pZ = (int)Math.Round(z + jitterData.GetDeltaY() * BlendRadius);
                    actualbiome = landscape.Biome[(x & 15) * 16 + (z & 15)];
                    jitterbiome = landscape.Biome[(pX & 15) * 16 + (pZ & 15)];
                    jitteredBiomes[i * 16 + j] = (actualbiome.Config.SurfaceBlendIn && jitterbiome.Config.SurfaceBlendOut) ? jitterbiome : actualbiome;
                }
            }


            BiomeBase realisticBiome;
            int       realisticBiomeId;


            var noise = landscape.Noise;
            var riverStrength = landscape.River;

            // currently just stuffs the genLayer into the jitter;
            for (int i = 0; i < MAX_BIOMES; i++)
            {
                realisticBiome = orginalBiomes[i];

                bool canBeRiver = riverStrength[i] > 0.7;

                if (noise[i] > 61.5)
                {
                    // replace
                    jitteredBiomes[i] = realisticBiome;
                }
                else
                {
                    // check for river
                    if (canBeRiver && (realisticBiome.Type & BiomeType.Ocean) == 0 && (realisticBiome.Type & BiomeType.Swamp) == 0)
                    {
                        // make river
                        jitteredBiomes[i] = BiomeProvider.GetBiome(realisticBiome.GetRiverBiome());
                    }
                    else
                    {
                        // replace
                        jitteredBiomes[i] = realisticBiome;
                    }
                }
            }

            //  SmoothingSearchStatus beachSearch = new SmoothingSearchStatus(BeachBiome);
            SmoothingSearchStatus landSearch = new SmoothingSearchStatus(LandBiome);

            /*  beachSearch.SetNotHunted();
             * beachSearch.SetAbsent();
             *
             * landSearch.SetNotHunted();
             * landSearch.SetAbsent();*/
            // beachSearch.Hunt(neighboring);
            landSearch.Hunt(neighboring);

            float beachTop = 64.5f;

            for (int i = 0; i < MAX_BIOMES; i++)
            {
                float beachBottom = 61.5f;

                if (noise[i] < beachBottom || noise[i] > RiverAdjusted(beachTop, riverStrength[i]))
                {
                    continue;// this block isn't beach level
                }

                if ((jitteredBiomes[i].Type & BiomeType.Swamp) != 0)
                {
                    continue;
                }

                /* if (beachSearch.IsNotHunted())
                 * {
                 *   beachSearch.Hunt(neighboring);
                 *   landSearch.Hunt(neighboring);
                 * }*/

                //   int foundBiome = beachSearch.Biomes[i];
                // if (foundBiome != -1) {
                int nearestLandBiome = landSearch.Biomes[i];

                if (nearestLandBiome > -1)
                {
                    var foundBiome = BiomeProvider.GetBiome(nearestLandBiome).GetBeachBiome();
                    var biome      = BiomeProvider.GetBiome(foundBiome);

                    if (biome != null && biome.Terrain != null && biome.Surface != null)
                    {
                        jitteredBiomes[i] = biome;
                    }
                }

                //
                // }
            }

            landscape.Biome = jitteredBiomes;
        }