Exemplo n.º 1
0
 private static void RetargetSurfaceHistory(
     TerrainPass.SurfaceHistory history,
     int targetX,
     double targetHeight)
 {
     for (int index1 = 0; index1 < history.Length / 2 && history[history.Length - 1] > targetHeight; ++index1)
     {
         for (int index2 = 0; index2 < history.Length - index1 * 2; ++index2)
         {
             double num = history[history.Length - index2 - 1] - 1.0;
             history[history.Length - index2 - 1] = num;
             if (num <= targetHeight)
             {
                 break;
             }
         }
     }
     for (int index = 0; index < history.Length; ++index)
     {
         double worldSurface = history[history.Length - index - 1];
         TerrainPass.RetargetColumn(targetX - index, worldSurface);
     }
 }
Exemplo n.º 2
0
        protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
        {
            int num1 = configuration.Get <int>("FlatBeachPadding");

            progress.Message = Lang.gen[0].Value;
            TerrainPass.TerrainFeatureType featureType = TerrainPass.TerrainFeatureType.Plateau;
            double num2   = (double)Main.maxTilesY * 0.3 * ((double)GenBase._random.Next(90, 110) * 0.005);
            double num3   = (num2 + (double)Main.maxTilesY * 0.2) * ((double)GenBase._random.Next(90, 110) * 0.01);
            double val2_1 = num2;
            double val2_2 = num2;
            double val2_3 = num3;
            double val2_4 = num3;
            double num4   = (double)Main.maxTilesY * 0.23;

            TerrainPass.SurfaceHistory history = new TerrainPass.SurfaceHistory(500);
            int num5 = this.LeftBeachSize + num1;

            for (int index = 0; index < Main.maxTilesX; ++index)
            {
                progress.Set((float)index / (float)Main.maxTilesX);
                val2_1 = Math.Min(num2, val2_1);
                val2_2 = Math.Max(num2, val2_2);
                val2_3 = Math.Min(num3, val2_3);
                val2_4 = Math.Max(num3, val2_4);
                if (num5 <= 0)
                {
                    featureType = (TerrainPass.TerrainFeatureType)GenBase._random.Next(0, 5);
                    num5        = GenBase._random.Next(5, 40);
                    if (featureType == TerrainPass.TerrainFeatureType.Plateau)
                    {
                        num5 *= (int)((double)GenBase._random.Next(5, 30) * 0.2);
                    }
                }
                --num5;
                if ((double)index > (double)Main.maxTilesX * 0.45 && (double)index < (double)Main.maxTilesX * 0.55 && (featureType == TerrainPass.TerrainFeatureType.Mountain || featureType == TerrainPass.TerrainFeatureType.Valley))
                {
                    featureType = (TerrainPass.TerrainFeatureType)GenBase._random.Next(3);
                }
                if ((double)index > (double)Main.maxTilesX * 0.48 && (double)index < (double)Main.maxTilesX * 0.52)
                {
                    featureType = TerrainPass.TerrainFeatureType.Plateau;
                }
                num2 += TerrainPass.GenerateWorldSurfaceOffset(featureType);
                float num6 = 0.17f;
                float num7 = 0.26f;
                if (WorldGen.drunkWorldGen)
                {
                    num6 = 0.15f;
                    num7 = 0.28f;
                }
                if (index < this.LeftBeachSize + num1 || index > Main.maxTilesX - this.RightBeachSize - num1)
                {
                    num2 = Utils.Clamp <double>(num2, (double)Main.maxTilesY * 0.17, num4);
                }
                else if (num2 < (double)Main.maxTilesY * (double)num6)
                {
                    num2 = (double)Main.maxTilesY * (double)num6;
                    num5 = 0;
                }
                else if (num2 > (double)Main.maxTilesY * (double)num7)
                {
                    num2 = (double)Main.maxTilesY * (double)num7;
                    num5 = 0;
                }
                while (GenBase._random.Next(0, 3) == 0)
                {
                    num3 += (double)GenBase._random.Next(-2, 3);
                }
                if (num3 < num2 + (double)Main.maxTilesY * 0.06)
                {
                    ++num3;
                }
                if (num3 > num2 + (double)Main.maxTilesY * 0.35)
                {
                    --num3;
                }
                history.Record(num2);
                TerrainPass.FillColumn(index, num2, num3);
                if (index == Main.maxTilesX - this.RightBeachSize - num1)
                {
                    if (num2 > num4)
                    {
                        TerrainPass.RetargetSurfaceHistory(history, index, num4);
                    }
                    featureType = TerrainPass.TerrainFeatureType.Plateau;
                    num5        = Main.maxTilesX - index;
                }
            }
            Main.worldSurface = (double)(int)(val2_2 + 25.0);
            Main.rockLayer    = val2_4;
            double num8 = (double)((int)((Main.rockLayer - Main.worldSurface) / 6.0) * 6);

            Main.rockLayer = (double)(int)(Main.worldSurface + num8);
            int num9  = (int)(Main.rockLayer + (double)Main.maxTilesY) / 2 + GenBase._random.Next(-100, 20);
            int num10 = num9 + GenBase._random.Next(50, 80);
            int num11 = 20;

            if (val2_3 < val2_2 + (double)num11)
            {
                double num6 = (val2_3 + val2_2) / 2.0;
                double num7 = Math.Abs(val2_3 - val2_2);
                if (num7 < (double)num11)
                {
                    num7 = (double)num11;
                }
                val2_3 = num6 + num7 / 2.0;
                val2_2 = num6 - num7 / 2.0;
            }
            this.RockLayer        = num3;
            this.RockLayerHigh    = val2_4;
            this.RockLayerLow     = val2_3;
            this.WorldSurface     = num2;
            this.WorldSurfaceHigh = val2_2;
            this.WorldSurfaceLow  = val2_1;
            this.WaterLine        = num9;
            this.LavaLine         = num10;
        }