Пример #1
0
        public static float TerrainHighland(float x, float y, OverworldGeneratorV2 generator, float river, float start,
                                            float width, float height, float baseAdjust)
        {
            float h = generator.SimplexInstance(0).GetValue(x / width, y / width) * height * river; //-140 to 140

            h = h < start ? start + ((h - start) / 4.5f) : h;

            if (h < 0f)
            {
                h = 0; //0 to 140
            }

            if (h > 0f)
            {
                float st = h * 1.5f > 15f ? 15f : h * 1.5f;                            // 0 to 15
                h += generator.SimplexInstance(4).GetValue(x / 70f, y / 70f, 1f) * st; // 0 to 155
                h  = h * river;
            }

            h += BlendedHillHeight(generator.SimplexInstance(0).GetValue(x / 20f, y / 20f), 0f) * 4f;
            h += BlendedHillHeight(generator.SimplexInstance(0).GetValue(x / 12f, y / 12f), 0f) * 2f;
            h += BlendedHillHeight(generator.SimplexInstance(0).GetValue(x / 5f, y / 5f), 0f) * 1f;

            if (h < 0)
            {
                h = h / 2f;
            }

            if (h < -3)
            {
                h = (h + 3f) / 2f - 3f;
            }

            return((GetTerrainBase(generator, river)) + (h + baseAdjust) * river);
        }
Пример #2
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));
        }
Пример #3
0
        public float ErodedNoise(OverworldGeneratorV2 generator, int x, int y, float river, float border, float biomeHeight)
        {
            float r;
            // river of actualRiverProportions now maps to 1;
            float riverFlattening = 1f - river;

            riverFlattening = riverFlattening - (1 - OverworldGeneratorV2.ActualRiverProportion);
            // return biomeHeight if no river effect
            if (riverFlattening < 0)
            {
                return(biomeHeight);
            }

            // what was 1 set back to 1;
            riverFlattening /= OverworldGeneratorV2.ActualRiverProportion;

            // back to usual meanings: 1 = no river 0 = river
            r = 1f - riverFlattening;

            if ((r < 1f && biomeHeight > 55f))
            {
                float irregularity = generator.SimplexInstance(0).GetValue(x / 12f, y / 12f) * 2f +
                                     generator.SimplexInstance(0).GetValue(x / 8f, y / 8f);
                // less on the bottom and more on the sides
                irregularity = irregularity * (1 + r);
                return((biomeHeight * (r)) + ((55f + irregularity) * 1.0f) * (1f - r));
            }
            else
            {
                return(biomeHeight);
            }

            return(biomeHeight);
        }
Пример #4
0
        public static float GetRiverStrength(BlockCoordinates blockPos, OverworldGeneratorV2 generator)
        {
            int    worldX     = blockPos.X;
            int    worldZ     = blockPos.Z;
            double pX         = worldX;
            double pZ         = worldZ;
            var    jitterData = SimplexData2D.NewDisk();

            //New river curve function. No longer creates worldwide curve correlations along cardinal axes.
            generator.SimplexInstance(1).GetValue((float)worldX / 240.0f, (float)worldZ / 240.0f, jitterData);
            pX += jitterData.GetDeltaX() * generator.RiverLargeBendSize;
            pZ += jitterData.GetDeltaY() * generator.RiverLargeBendSize;

            generator.SimplexInstance(2).GetValue((float)worldX / 80.0f, (float)worldZ / 80.0f, jitterData);
            pX += jitterData.GetDeltaX() * generator.RiverSmallBendSize;
            pZ += jitterData.GetDeltaY() * generator.RiverSmallBendSize;

            pX /= generator.RiverSeperation;
            pZ /= generator.RiverSeperation;

            //New cellular noise.
            double riverFactor = generator.CellularInstance(0).Eval2D(pX, pZ).InteriorValue;

            // the output is a curved function of relative distance from the center, so adjust to make it flatter
            riverFactor = BayesianAdjustment((float)riverFactor, 0.5f);
            if (riverFactor > generator.RiverValleyLevel)
            {
                return(0);
            } // no river effect

            return((float)(riverFactor / generator.RiverValleyLevel - 1d));
        }
Пример #5
0
        public static float GetGroundNoise(float x, float y, float amplitude, OverworldGeneratorV2 generator)
        {
            float h = BlendedHillHeight(generator.SimplexInstance(0).GetValue(x / 49f, y / 49f), 0.2f) * amplitude;

            h += BlendedHillHeight(generator.SimplexInstance(1).GetValue(x / 23f, y / 23f), 0.2f) * amplitude / 2f;
            h += BlendedHillHeight(generator.SimplexInstance(2).GetValue(x / 11f, y / 11f), 0.2f) * amplitude / 4f;
            return(h);
        }
        public override float GenerateNoise(OverworldGeneratorV2 generator, int passedX, int passedY, float border, float river)
        {
            var jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(passedX / _jitterWavelength, passedY / _jitterWavelength, jitterData);
            float x         = (float)(passedX + jitterData.GetDeltaX() * _jitterAmplitude);
            float y         = (float)(passedY + jitterData.GetDeltaY() * _jitterAmplitude);
            float bordercap = (bordercap = border * 3.5f - 2.5f) > 1 ? 1.0f : bordercap;
            float rivercap  = (rivercap = 3f * river) > 1 ? 1.0f : rivercap;
            float bumpiness = generator.SimplexInstance(2).GetValue(x / _bumpinessWavelength, y / _bumpinessWavelength) * _bumpinessMultiplier;
            float simplex   = _plateau.Added(generator, x, y) * bordercap * rivercap + bumpiness;
            float added     = PlateauUtil.StepIncrease(simplex, _stepStart, _stepFinish, _stepHeight) / border;

            return(Riverized(generator, BaseHeight + GetGroundNoise(x, y, _groundNoise, generator), river) + added);
        }
Пример #7
0
        public static float Hills(float x, float y, float hillStrength, OverworldGeneratorV2 generator)
        {
            float m = generator.SimplexInstance(0).GetValue(x / 150f, y / 150f);

            m = BlendedHillHeight(m, 0.2f);

            float sm = generator.SimplexInstance(2)
                       .GetValue(x / 55, y / 55); // there are artifacts if this is close to a multiple of 16

            sm = BlendedHillHeight(sm, 0.2f);
            //sm = sm*0.8f;
            sm *= sm * m;
            m  += sm / 3f;

            return(m * hillStrength);
        }
Пример #8
0
        public override float Added(OverworldGeneratorV2 generator, float x, float y)
        {
            float noise = generator.SimplexInstance(Octave).GetValue(x / Wavelength, y / Wavelength);

            noise = Math.Abs(noise);
            noise = TerrainBase.BlendedHillHeight(noise, MinimumSimplex);
            noise = TerrainBase.UnsignedPower(noise, Power);
            return(noise * Spiked.Added(generator, x, y));
        }
Пример #9
0
        public static float TerrainPlateau(float x, float y, OverworldGeneratorV2 generator, float river, float[] height,
                                           float border, float strength, int heightLength, float selectorWaveLength, bool isM)
        {
            var simplex = generator.SimplexInstance(0);

            river = river > 1f ? 1f : river;
            float border2 = border * 4 - 2.5f;

            border2 = border2 > 1f ? 1f : (border2 < 0f) ? 0f : border2;
            float b = simplex.GetValue(x / 40f, y / 40f) * 1.5f;

            float sn = simplex.GetValue(x / selectorWaveLength, y / selectorWaveLength) * 0.5f + 0.5f;

            sn *= border2;
            sn *= river;
            sn += simplex.GetValue(x / 4f, y / 4f) * 0.01f + 0.01f;
            sn += simplex.GetValue(x / 2f, y / 2f) * 0.01f + 0.01f;
            float n, hn, stepUp;

            for (int i = 0; i < heightLength; i += 2)
            {
                n      = (sn - height[i + 1]) / (1 - height[i + 1]);
                n      = n * strength;
                n      = (n < 0f) ? 0f : (n > 1f) ? 1f : n;
                hn     = height[i] * 0.5f * ((sn * 2f) - 0.4f);
                hn     = (hn < 0) ? 0f : hn;
                stepUp = 0f;
                if (sn > height[i + 1])
                {
                    stepUp += (height[i] * n);
                    if (isM)
                    {
                        stepUp += simplex.GetValue(x / 20f, y / 20f) * 3f * n;
                        stepUp += simplex.GetValue(x / 12f, y / 12f) * 2f * n;
                        stepUp += simplex.GetValue(x / 5f, y / 5f) * 1f * n;
                    }
                }

                if (i == 0 && stepUp < hn)
                {
                    b += hn;
                }

                stepUp = (stepUp < 0) ? 0f : stepUp;
                b     += stepUp;
            }

            if (isM)
            {
                b += simplex.GetValue(x / 12, y / 12) * sn;
            }

            //Counteracts smoothing
            b /= border;

            return(Riverized(generator, generator.Preset.GetTerrainBase(), river) + b);
        }
Пример #10
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));
        }
Пример #11
0
        public static float TerrainGrasslandHills(int x, int y, OverworldGeneratorV2 generator, float river,
                                                  float vWidth, float vHeight, float hWidth, float hHeight, float bHeight)
        {
            float h = generator.SimplexInstance(0).GetValue(x / vWidth, y / vWidth);

            h = BlendedHillHeight(h, 0.3f);

            float m = generator.SimplexInstance(1).GetValue(x / hWidth, y / hWidth);

            m  = BlendedHillHeight(m, 0.3f) * h;
            m *= m;

            h *= vHeight * river;
            m *= hHeight * river;

            h += TerrainBase.GetGroundNoise(x, y, 4f, generator);

            return(Riverized(generator, bHeight + h, river) + m);
        }
Пример #12
0
        public static float TerrainForest(int x, int y, OverworldGeneratorV2 generator, float river, float baseHeight)
        {
            var simplex = generator.SimplexInstance(0);

            double h = simplex.GetValue(x / 100f, y / 100f) * 8d;

            h += simplex.GetValue(x / 30f, y / 30f) * 4d;
            h += simplex.GetValue(x / 15f, y / 15f) * 2d;
            h += simplex.GetValue(x / 7f, y / 7f);

            return(Riverized(generator, baseHeight + 20f + (float)h, river));
        }
Пример #13
0
        public static float TerrainLonelyMountain(int x, int y, OverworldGeneratorV2 generator, float river,
                                                  float strength, float width, float terrainHeight)
        {
            var   simplex0 = generator.SimplexInstance(0);
            float h        = BlendedHillHeight(simplex0.GetValue(x / 20f, y / 20f), 0) * 3;

            h += BlendedHillHeight(simplex0.GetValue(x / 7f, y / 7f), 0) * 1.3f;

            float m = simplex0.GetValue(x / width, y / width) * strength * river;

            m *= m / 35f;
            m  = m > 70f ? 70f + (m - 70f) / 2.5f : m;

            float st = m * 0.7f;

            st = st > 20f ? 20f : st;
            float c = generator.SimplexInstance(4).GetValue(x / 30f, y / 30f, 1f) * (5f + st);

            float sm = simplex0.GetValue(x / 30f, y / 30f) * 8f + simplex0.GetValue(x / 8f, y / 8f);

            sm *= (m + 10f) / 20f > 2.5f ? 2.5f : (m + 10f) / 20f;
            m  += sm;

            m += c;

            // the parameters can "blow through the ceiling" so pull more extreme values down a bit
            // this should allow a height parameter up to about 120
            if (m > 90)
            {
                m = 90f + (m - 90f) * .75f;
                if (m > 110)
                {
                    m = 110f + (m - 110f) * .75f;
                }
            }

            return(Riverized(generator, terrainHeight + h + m, river));
        }
Пример #14
0
        public static float TerrainBryce(int x, int y, OverworldGeneratorV2 generator, float river, float height)
        {
            var   simplex = generator.SimplexInstance(0);
            float sn      = simplex.GetValue(x / 2f, y / 2f) * 0.5f + 0.5f;

            sn += simplex.GetValue(x, y) * 0.2f + 0.2f;
            sn += simplex.GetValue(x / 4f, y / 4f) * 4f + 4f;
            sn += simplex.GetValue(x / 8f, y / 8f) * 2f + 2f;
            float n = height / sn * 2;

            n += simplex.GetValue(x / 64f, y / 64f) * 4f;
            n  = (sn < 6) ? n : 0f;
            return(Riverized(generator, generator.Preset.GetTerrainBase() + n, river));
        }
Пример #15
0
        public override float GenerateNoise(OverworldGeneratorV2 generator, int x, int y, float border, float river)
        {
            var   settings   = generator.Preset;
            float duneHeight = (MinDuneHeight + settings.SandDuneHeight);

            duneHeight *= (1f + generator.SimplexInstance(2).GetValue(x / 330f, y / 330f)) / 2f;

            float stPitch  = 200f; // The higher this is, the more smoothly dunes blend with the terrain
            float stFactor = duneHeight;
            float hPitch   = 70;   // Dune scale
            float hDivisor = 40;

            return(TerrainPolar(x, y, generator, river, stPitch, stFactor, hPitch, hDivisor, BaseHeight) + GetGroundNoise(x, y, 1f, generator));
        }
Пример #16
0
        public static float TerrainOcean(int x, int y, OverworldGeneratorV2 generator, float river, float averageFloor)
        {
            var   simplex = generator.SimplexInstance(0);
            float h       = simplex.GetValue(x / 300f, y / 300f) * 8f * river;

            //h = h > 3f ? 3f : h;
            h += simplex.GetValue(x / 50f, y / 50f) * 2f;
            h += simplex.GetValue(x / 15f, y / 15f) * 1f;

            float floNoise = averageFloor + h;

            floNoise = floNoise < _minimumOceanFloor ? _minimumOceanFloor : floNoise;

            return(floNoise);
        }
Пример #17
0
        public static float TerrainGrasslandMountains(int x, int y, OverworldGeneratorV2 generator, float river,
                                                      float hFactor, float mFactor, float baseHeight)
        {
            var   simplex0 = generator.SimplexInstance(0);
            float h        = simplex0.GetValue(x / 100f, y / 100f) * hFactor;

            h += simplex0.GetValue(x / 20f, y / 20f) * 2;

            float m = simplex0.GetValue(x / 230f, y / 230f) * mFactor * river;

            m *= m / 35f;
            m  = m > 70f ? 70f + (m - 70f) / 2.5f : m;

            float c = generator.SimplexInstance(4).GetValue(x / 30f, y / 30f, 1f) * (m * 0.30f);

            float sm = simplex0.GetValue(x / 30f, y / 30f) * 8f + simplex0.GetValue(x / 8f, y / 8f);

            sm *= m / 20f > 2.5f ? 2.5f : m / 20f;
            m  += sm;

            m += c;

            return(Riverized(generator, baseHeight + h + m, river));
        }
Пример #18
0
        public static float TerrainFlatLakes(int x, int y, OverworldGeneratorV2 generator, float river, float baseHeight)
        {
            /*float h = simplex.GetValue(x / 300f, y / 300f) * 40f * river;
             * h = h > hMax ? hMax : h;
             * h += simplex.GetValue(x / 50f, y / 50f) * (12f - h) * 0.4f;
             * h += simplex.GetValue(x / 15f, y / 15f) * (12f - h) * 0.15f;*/

            float ruggedNoise = generator.SimplexInstance(1).GetValue(
                x / 200f,
                y / 200f
                );

            ruggedNoise = BlendedHillHeight(ruggedNoise);
            float h = GetGroundNoise(x, y, 2f * (ruggedNoise + 1f), generator); // ground noise

            return(Riverized(generator, baseHeight + h, river));
        }
Пример #19
0
        public static float TerrainMarsh(int x, int y, OverworldGeneratorV2 generator, float baseHeight, float river)
        {
            var   simplex = generator.SimplexInstance(0);
            float h       = simplex.GetValue(x / 130f, y / 130f) * 20f;

            h += simplex.GetValue(x / 12f, y / 12f) * 2f;
            h += simplex.GetValue(x / 18f, y / 18f) * 4f;

            h = h < 8f ? 0f : h - 8f;

            if (h == 0f)
            {
                h += simplex.GetValue(x / 20f, y / 20f) + simplex.GetValue(x / 5f, y / 5f);
                h *= 2f;
            }

            return(Riverized(generator, baseHeight + h, river));
        }
Пример #20
0
        public static float TerrainGrasslandFlats(int x, int y, OverworldGeneratorV2 generator, float river,
                                                  float mPitch, float baseHeight)
        {
            var   simplex = generator.SimplexInstance(0);
            float h       = simplex.GetValue(x / 100f, y / 100f) * 7;

            h += simplex.GetValue(x / 20f, y / 20f) * 2;

            float m = simplex.GetValue(x / 180f, y / 180f) * 35f * river;

            m *= m / mPitch;

            float sm = BlendedHillHeight(simplex.GetValue(x / 30f, y / 30f)) * 8f;

            sm *= m / 20f > 3.75f ? 3.75f : m / 20f;
            m  += sm;

            return(Riverized(generator, baseHeight + h + m, river));
        }
Пример #21
0
        public static float TerrainPolar(float x, float y, OverworldGeneratorV2 generator, float river, float stPitch,
                                         float stFactor, float hPitch, float hDivisor, float baseHeight)
        {
            var   simplex = generator.SimplexInstance(0);
            float floNoise;
            float st = (simplex.GetValue(x / stPitch, y / stPitch) + 0.38f) * stFactor * river;

            st = st < 0.1f ? 0.1f : st;

            float h = simplex.GetValue(x / hPitch, y / hPitch) * st * 2f;

            h  = h > 0f ? -h : h;
            h += st;
            h *= h / hDivisor;
            h += st;

            floNoise = Riverized(generator, baseHeight + h, river);
            return(floNoise);
        }
Пример #22
0
        public static float TerrainPlains(int x, int y, OverworldGeneratorV2 generator, float river, float stPitch,
                                          float stFactor, float hPitch, float heightScale, float baseHeight)
        {
            var   simplex = generator.SimplexInstance(0);
            float floNoise;
            float st = (simplex.GetValue(x / stPitch, y / stPitch) + 0.38f) * stFactor * river;

            st = st < 0.2f ? 0.2f : st;

            float height = simplex.GetValue(x / hPitch, y / hPitch) * st * 2f;

            height  = height > 0f ? -height : height;
            height += st;
            height *= height / heightScale;
            height += st;

            floNoise = Riverized(generator, baseHeight + height, river);
            return(floNoise);
        }
Пример #23
0
        public static float TerrainVolcano(int x, int y, OverworldGeneratorV2 generator, float border, float baseHeight)
        {
            var simplex       = generator.SimplexInstance(0);
            var cellularNoise = generator.CellularInstance(0);

            float st = 15f - (float)(cellularNoise.Eval2D(x / 500d, y / 500d).ShortestDistance * 42d) +
                       (simplex.GetValue(x / 30f, y / 30f) * 2f);

            float h = st < 0f ? 0f : st;

            h  = h < 0f ? 0f : h;
            h += (h * 0.4f) * ((h * 0.4f) * 2f);

            if (h > 10f)
            {
                float d2 = (h - 10f) / 1.5f > 30f ? 30f : (h - 10f) / 1.5f;
                h += (float)cellularNoise.Eval2D(x / 25D, y / 25D).ShortestDistance *d2;
            }

            h += simplex.GetValue(x / 18f, y / 18f) * 3;
            h += simplex.GetValue(x / 8f, y / 8f) * 2;

            return(baseHeight + h * border);
        }
Пример #24
0
        /// <inheritdoc />
        public override void PaintTerrain(ChunkColumn column,
                                          int blockX,
                                          int blockZ,
                                          int x,
                                          int z,
                                          int depth,
                                          OverworldGeneratorV2 generator,
                                          float[] noise,
                                          float river,
                                          BiomeBase[] biomes)
        {
            var   simplex = generator.SimplexInstance(0);
            float c       = TerrainBase.CalcCliff(x, z, noise);
            int   cliff   = 0;
            bool  m       = false;

            Block b;

            for (int k = 255; k > -1; k--)
            {
                b = column.GetBlockObject(x, k, z);

                if (b is Air)
                {
                    depth = -1;
                }
                else if (b is Stone)
                {
                    depth++;

                    if (depth == 0)
                    {
                        float p = simplex.GetValue(blockX / 8f, blockZ / 8f, k / 8f) * 0.5f;

                        if (c > min && c > sCliff - ((k - sHeight) / sStrength) + p)
                        {
                            cliff = 1;
                        }

                        if (c > cCliff)
                        {
                            cliff = 2;
                        }

                        if (cliff == 1)
                        {
                            if (Rnd.Next(3) == 0)
                            {
                                column.SetBlock(x, k, z, CliffCobbleBlock);
                            }
                            else
                            {
                                column.SetBlock(x, k, z, CliffStoneBlock);
                            }
                        }
                        else if (cliff == 2)
                        {
                            column.SetBlock(x, k, z, ShadowStoneBlock);
                        }
                        else if (k < 63)
                        {
                            if (k < 62)
                            {
                                column.SetBlock(x, k, z, FillerBlock);
                            }
                            else
                            {
                                column.SetBlock(x, k, z, TopBlock);
                            }
                        }
                        else if (simplex.GetValue(blockX / 12f, blockZ / 12f) > mixHeight)
                        {
                            column.SetBlock(x, k, z, mixBlock);
                            m = true;
                        }
                        else
                        {
                            column.SetBlock(x, k, z, TopBlock);
                        }
                    }
                    else if (depth < 6)
                    {
                        if (cliff == 1)
                        {
                            column.SetBlock(x, k, z, CliffStoneBlock);
                        }
                        else if (cliff == 2)
                        {
                            column.SetBlock(x, k, z, ShadowStoneBlock);
                        }
                        else
                        {
                            column.SetBlock(x, k, z, FillerBlock);
                        }
                    }
                }
            }
        }
Пример #25
0
        /// <inheritdoc />
        public override void PaintTerrain(ChunkColumn column,
                                          int blockX,
                                          int blockZ,
                                          int x,
                                          int z,
                                          int depth,
                                          OverworldGeneratorV2 generator,
                                          float[] noise,
                                          float river,
                                          BiomeBase[] biomes)
        {
            var   simplex = generator.SimplexInstance(0);
            float p       = simplex.GetValue(blockX / 8f, blockZ / 8f) * 0.5f;
            float c       = TerrainBase.CalcCliff(x, z, noise);
            int   cliff   = 0;

            Block b;

            for (int y = 255; y > -1; y--)
            {
                b = column.GetBlockObject(x, y, z);
                if (b is Air)
                {
                    depth = -1;
                }
                else if (b is Stone)
                {
                    depth++;

                    if (depth == 0)
                    {
                        if (c > 0.45f && c > 1.5f - ((y - 60f) / 65f) + p)
                        {
                            cliff = 1;
                        }
                        if (c > 1.5f)
                        {
                            cliff = 2;
                        }
                        if (y > 110 + (p * 4) && c < 0.3f + ((y - 100f) / 50f) + p)
                        {
                            cliff = 3;
                        }

                        if (cliff == 1)
                        {
                            if (Rnd.Next(3) == 0)
                            {
                                column.SetBlock(x, y, z, CliffCobbleBlock);
                            }
                            else
                            {
                                column.SetBlock(x, y, z, CliffStoneBlock);
                            }
                        }
                        else if (cliff == 2)
                        {
                            column.SetBlock(x, y, z, ShadowStoneBlock);
                        }
                        else if (cliff == 3)
                        {
                            column.SetBlock(x, y, z, new Snow());
                        }
                        else if (simplex.GetValue(blockX / 50f, blockZ / 50f) + p * 0.6f > 0.24f)
                        {
                            column.SetBlock(x, y, z, MixBlock);
                        }
                        else
                        {
                            column.SetBlock(x, y, z, new Grass());
                        }
                    }
                    else if (depth < 6)
                    {
                        if (cliff == 1)
                        {
                            column.SetBlock(x, y, z, CliffStoneBlock);
                        }
                        else if (cliff == 2)
                        {
                            column.SetBlock(x, y, z, ShadowStoneBlock);
                        }
                        else if (cliff == 3)
                        {
                            column.SetBlock(x, y, z, new Snow());
                        }
                        else
                        {
                            column.SetBlock(x, y, z, new Dirt());
                        }
                    }
                }
            }
        }
Пример #26
0
        public static float TerrainOceanCanyon(int x, int y, OverworldGeneratorV2 generator, float river, float[] height,
                                               float border, float strength, int heightLength, bool booRiver)
        {
            //float b = simplex.GetValue(x / cWidth, y / cWidth) * cHeigth * river;
            //b *= b / cStrength;
            var simplex = generator.SimplexInstance(0);

            river *= 1.3f;
            river  = river > 1f ? 1f : river;
            float r = simplex.GetValue(x / 100f, y / 100f) * 50f;

            r = r <-7.4f ? -7.4f : r> 7.4f ? 7.4f : r;
            float b = (17f + r) * river;

            float hn = simplex.GetValue(x / 12f, y / 12f) * 0.5f;
            float sb = 0f;

            if (b > 0f)
            {
                sb = b;
                sb = sb > 7f ? 7f : sb;
                sb = hn * sb;
            }

            b += sb;

            float cTotal = 0f;
            float cTemp;

            for (int i = 0; i < heightLength; i += 2)
            {
                cTemp = 0;
                if (b > height[i] && border > 0.6f + (height[i] * 0.015f) + hn * 0.2f)
                {
                    cTemp  = b > height[i] + height[i + 1] ? height[i + 1] : b - height[i];
                    cTemp *= strength;
                }

                cTotal += cTemp;
            }


            float bn = 0f;

            if (booRiver)
            {
                if (b < 5f)
                {
                    bn = 5f - b;
                    for (int i = 0; i < 3; i++)
                    {
                        bn *= bn / 4.5f;
                    }
                }
            }
            else if (b < 5f)
            {
                bn = (simplex.GetValue(x / 7f, y / 7f) * 1.3f + simplex.GetValue(x / 15f, y / 15f) * 2f) * (5f - b) *
                     0.2f;
            }

            b += cTotal - bn;

            float floNoise = 30f + b;

            floNoise = floNoise < _minimumOceanFloor ? _minimumOceanFloor : floNoise;

            return(floNoise);
        }
Пример #27
0
        /// <inheritdoc />
        public override void PaintTerrain(ChunkColumn column,
                                          int blockX,
                                          int blockZ,
                                          int x,
                                          int z,
                                          int depth,
                                          OverworldGeneratorV2 generator,
                                          float[] noise,
                                          float river,
                                          BiomeBase[] biomes)
        {
            FastRandom rand    = new FastRandom();
            var        simplex = generator.SimplexInstance(0);
            float      c       = TerrainBase.CalcCliff(x, z, noise);
            bool       cliff   = c > 1.4f;

            for (int y = 255; y > -1; y--)
            {
                Block b = column.GetBlockObject(x, y, z);
                if (b is Air)
                {
                    depth = -1;
                }
                else if (b is Stone)
                {
                    depth++;

                    if (cliff)
                    {
                        if (depth > -1 && depth < 2)
                        {
                            if (rand.Next(3) == 0)
                            {
                                column.SetBlock(x, y, z, CliffCobbleBlock);
                            }
                            else
                            {
                                column.SetBlock(x, y, z, CliffStoneBlock);
                            }
                        }
                        else if (depth < 10)
                        {
                            column.SetBlock(x, y, z, CliffStoneBlock);
                        }
                    }
                    else
                    {
                        if (depth == 0 && y > 61)
                        {
                            if (simplex.GetValue(blockX / width, blockZ / width) > height)                             // > 0.27f, i / 12f
                            {
                                column.SetBlock(x, y, z, mixBlock);
                            }
                            else
                            {
                                column.SetBlock(x, y, z, TopBlock);
                            }
                        }
                        else if (depth < 4)
                        {
                            column.SetBlock(x, y, z, FillerBlock);
                        }
                    }
                }
            }
        }