Exemple #1
0
        public void GenerateTrap(GenerationProgress progress)
        {
            progress.Message = "Adding More Temple Traps";

            int minX = WorldGen.tLeft + 5, minY = WorldGen.tTop + 5;
            int maxX = WorldGen.tRight - 5, maxY = WorldGen.tBottom - 5;

            int trapsAmount = 1 + (int)(WorldGen.tRooms * (0.8f + WorldGen.genRand.NextFloat(-0.2f, 0.2f)));

            int tileX, tileY, trapsGen = 0, genAttemps = 0;

            progress.CurrentPassWeight = progress.TotalWeight * 0.01f;
            progress.Set(0);

            bool floorTrap = WorldGen.genRand.NextBool(), cFloorTrap;

            while (trapsGen < trapsAmount)
            {
                tileX = WorldGen.genRand.Next(minX, maxX);
                tileY = WorldGen.genRand.Next(minY, maxY);
                Tile tile = Framing.GetTileSafely(tileX, tileY);

                cFloorTrap = genAttemps > 50 ? WorldGen.genRand.NextBool() : floorTrap;
                if (tile.wall == WallID.LihzahrdBrickUnsafe && !tile.active() && GenerateBoulderTrap(tileX, tileY, cFloorTrap) || ++genAttemps > 100)
                {
                    trapsGen++;
                    floorTrap = WorldGen.genRand.NextBool();
                    progress.Set((float)trapsGen / trapsAmount);
                    genAttemps = 0;
                }
            }
        }
Exemple #2
0
        private void SpreadingGrass(GenerationProgress progress)
        {
            ushort dirtType  = (ushort)(2);
            ushort grassType = (ushort)mod.TileType("ThunderflowGrass");

            for (int i = 0; i < Main.maxTilesX; i++)
            {
                float percent = (float)(i / Main.maxTilesX);
                progress.Set(percent);
                for (int j = Main.maxTilesY - 200; j < Main.maxTilesY; j++)
                {
                    if (Main.tile[i, j].type == dirtType)
                    {
                        Main.tile[i, j].wall = 0;
                        WorldGen.SpreadGrass(i, j, dirtType, grassType, true);
                    }
                }
            }

            for (int i = 0; i < Main.maxTilesX; i++)
            {
                float percent = (float)(i / Main.maxTilesX);
                progress.Set(percent);
                for (int j = Main.maxTilesY - 200; j < Main.maxTilesY; j++)
                {
                    if (Main.tile[i, j].type == grassType)
                    {
                        Main.tile[i, j].wall = 0;
                    }
                }
            }
        }
Exemple #3
0
        private void GenerateFinishingTouches(GenerationProgress progress, int oldX, int oldY)
        {
            int   num        = oldX;
            int   num2       = oldY;
            float worldScale = _worldScale;

            for (int i = 0; (float)i <= 20f * worldScale; i++)
            {
                progress.Set((60f + (float)i / worldScale) * 0.01f);
                num  += GenBase._random.Next((int)(-5f * worldScale), (int)(6f * worldScale));
                num2 += GenBase._random.Next((int)(-5f * worldScale), (int)(6f * worldScale));
                WorldGen.TileRunner(num, num2, GenBase._random.Next(40, 100), GenBase._random.Next(300, 500), 59);
            }
            for (int j = 0; (float)j <= 10f * worldScale; j++)
            {
                progress.Set((80f + (float)j / worldScale * 2f) * 0.01f);
                num  = oldX + GenBase._random.Next((int)(-600f * worldScale), (int)(600f * worldScale));
                num2 = oldY + GenBase._random.Next((int)(-200f * worldScale), (int)(200f * worldScale));
                while (num < 1 || num >= Main.maxTilesX - 1 || num2 < 1 || num2 >= Main.maxTilesY - 1 || Main.tile[num, num2].type != 59)
                {
                    num  = oldX + GenBase._random.Next((int)(-600f * worldScale), (int)(600f * worldScale));
                    num2 = oldY + GenBase._random.Next((int)(-200f * worldScale), (int)(200f * worldScale));
                }
                for (int k = 0; (float)k < 8f * worldScale; k++)
                {
                    num  += GenBase._random.Next(-30, 31);
                    num2 += GenBase._random.Next(-30, 31);
                    int type = -1;
                    if (GenBase._random.Next(7) == 0)
                    {
                        type = -2;
                    }
                    WorldGen.TileRunner(num, num2, GenBase._random.Next(10, 20), GenBase._random.Next(30, 70), type);
                }
            }
            for (int l = 0; (float)l <= 300f * worldScale; l++)
            {
                num  = oldX + GenBase._random.Next((int)(-600f * worldScale), (int)(600f * worldScale));
                num2 = oldY + GenBase._random.Next((int)(-200f * worldScale), (int)(200f * worldScale));
                while (num < 1 || num >= Main.maxTilesX - 1 || num2 < 1 || num2 >= Main.maxTilesY - 1 || Main.tile[num, num2].type != 59)
                {
                    num  = oldX + GenBase._random.Next((int)(-600f * worldScale), (int)(600f * worldScale));
                    num2 = oldY + GenBase._random.Next((int)(-200f * worldScale), (int)(200f * worldScale));
                }
                WorldGen.TileRunner(num, num2, GenBase._random.Next(4, 10), GenBase._random.Next(5, 30), 1);
                if (GenBase._random.Next(4) == 0)
                {
                    int type2 = GenBase._random.Next(63, 69);
                    WorldGen.TileRunner(num + GenBase._random.Next(-1, 2), num2 + GenBase._random.Next(-1, 2), GenBase._random.Next(3, 7), GenBase._random.Next(4, 8), type2);
                }
            }
        }
Exemple #4
0
        private void GenerateFinishingTouches(GenerationProgress progress, int oldX, int oldY)
        {
            int   i1         = oldX;
            int   j1         = oldY;
            float worldScale = this._worldScale;

            for (int index = 0; (double)index <= 20.0 * (double)worldScale; ++index)
            {
                progress.Set((float)((60.0 + (double)index / (double)worldScale) * 0.00999999977648258));
                i1 += GenBase._random.Next((int)(-5.0 * (double)worldScale), (int)(6.0 * (double)worldScale));
                j1 += GenBase._random.Next((int)(-5.0 * (double)worldScale), (int)(6.0 * (double)worldScale));
                WorldGen.TileRunner(i1, j1, (double)GenBase._random.Next(40, 100), GenBase._random.Next(300, 500), 59, false, 0.0f, 0.0f, false, true, -1);
            }
            for (int index1 = 0; (double)index1 <= 10.0 * (double)worldScale; ++index1)
            {
                progress.Set((float)((80.0 + (double)index1 / (double)worldScale * 2.0) * 0.00999999977648258));
                int i2 = oldX + GenBase._random.Next((int)(-600.0 * (double)worldScale), (int)(600.0 * (double)worldScale));
                int j2;
                for (j2 = oldY + GenBase._random.Next((int)(-200.0 * (double)worldScale), (int)(200.0 * (double)worldScale)); i2 < 1 || i2 >= Main.maxTilesX - 1 || (j2 < 1 || j2 >= Main.maxTilesY - 1) || Main.tile[i2, j2].type != (ushort)59; j2 = oldY + GenBase._random.Next((int)(-200.0 * (double)worldScale), (int)(200.0 * (double)worldScale)))
                {
                    i2 = oldX + GenBase._random.Next((int)(-600.0 * (double)worldScale), (int)(600.0 * (double)worldScale));
                }
                for (int index2 = 0; (double)index2 < 8.0 * (double)worldScale; ++index2)
                {
                    i2 += GenBase._random.Next(-30, 31);
                    j2 += GenBase._random.Next(-30, 31);
                    int type = -1;
                    if (GenBase._random.Next(7) == 0)
                    {
                        type = -2;
                    }
                    WorldGen.TileRunner(i2, j2, (double)GenBase._random.Next(10, 20), GenBase._random.Next(30, 70), type, false, 0.0f, 0.0f, false, true, -1);
                }
            }
            for (int index = 0; (double)index <= 300.0 * (double)worldScale; ++index)
            {
                int i2 = oldX + GenBase._random.Next((int)(-600.0 * (double)worldScale), (int)(600.0 * (double)worldScale));
                int j2;
                for (j2 = oldY + GenBase._random.Next((int)(-200.0 * (double)worldScale), (int)(200.0 * (double)worldScale)); i2 < 1 || i2 >= Main.maxTilesX - 1 || (j2 < 1 || j2 >= Main.maxTilesY - 1) || Main.tile[i2, j2].type != (ushort)59; j2 = oldY + GenBase._random.Next((int)(-200.0 * (double)worldScale), (int)(200.0 * (double)worldScale)))
                {
                    i2 = oldX + GenBase._random.Next((int)(-600.0 * (double)worldScale), (int)(600.0 * (double)worldScale));
                }
                WorldGen.TileRunner(i2, j2, (double)GenBase._random.Next(4, 10), GenBase._random.Next(5, 30), 1, false, 0.0f, 0.0f, false, true, -1);
                if (GenBase._random.Next(4) == 0)
                {
                    int type = GenBase._random.Next(63, 69);
                    WorldGen.TileRunner(i2 + GenBase._random.Next(-1, 2), j2 + GenBase._random.Next(-1, 2), (double)GenBase._random.Next(3, 7), GenBase._random.Next(4, 8), type, false, 0.0f, 0.0f, false, true, -1);
                }
            }
        }
Exemple #5
0
 private void RegolithPass(GenerationProgress progress)
 {
     progress.Message = "Sending meteors to the Moon...";
     for (int tileX = 1; tileX < Main.maxTilesX - 1; tileX++)
     {
         float progressPercent = tileX / Main.maxTilesX;
         progress.Set(progressPercent / 2f);
         float regolithChance = 6;
         for (int tileY = 1; tileY < Main.maxTilesY; tileY++)
         {
             if (Main.tile[tileX, tileY].active())
             {
                 if (regolithChance > 0.1)
                 {
                     Main.tile[tileX, tileY].type = (ushort)ModContent.TileType <Tiles.Regolith>();
                 }
                 regolithChance -= 0.02f;
                 if (regolithChance <= 0)
                 {
                     break;
                 }
             }
         }
     }
     // Generate protolith veins
     for (int tileX = 1; tileX < Main.maxTilesX - 1; tileX++)
     {
         float progressPercent = tileX / Main.maxTilesX;
         progress.Set(0.5f + progressPercent / 2f);
         float regolithChance = 6;
         for (int tileY = 1; tileY < Main.maxTilesY; tileY++)
         {
             if (Main.tile[tileX, tileY].active())
             {
                 double veinChance = (6 - regolithChance) / 6f * 0.006;
                 if (WorldGen.genRand.NextFloat() < veinChance || veinChance == 0)
                 {
                     //WorldGen.TileRunner(tileX, tileY, WorldGen.genRand.Next((int)(6 * veinChance / 0.005), (int)(20 * veinChance / 0.005)), WorldGen.genRand.Next(50, 300), ModContent.TileType<Tiles.Protolith>());
                     WorldGen.TileRunner(tileX, tileY, WorldGen.genRand.Next((int)(6 * veinChance / 0.003), (int)(20 * veinChance / 0.003)), WorldGen.genRand.Next(5, 19), ModContent.TileType <Tiles.Protolith>());
                 }
                 regolithChance -= 0.02f;
                 if (regolithChance < 0)
                 {
                     break;
                 }
             }
         }
     }
 }
Exemple #6
0
        public static bool AttemptToPlaceDragonballsInWorld(GenerationProgress progress = null)
        {
            string PlacingDragonballs = "Placing Dragon Balls";

            if (progress != null)
            {
                progress.Message = PlacingDragonballs;
                progress.Set(0.25f);
            }

            for (int i = 0; i <= 6; i++)
            {
                bool shouldTryToSpawn = !IsExistingDragonBall(i + 1);

                if (shouldTryToSpawn)
                {
                    Point safeCoordinates = GetSafeDragonBallCoordinates();
                    while (!TryPlacingDragonball(i + 1, safeCoordinates.X, safeCoordinates.Y))
                    {
                        safeCoordinates = GetSafeDragonBallCoordinates();
                    }
                }
            }
            return(true);
        }
Exemple #7
0
        private void SkyBudGenTask(GenerationProgress progress, List <FloatingIsland> islands)
        {
            progress.Message = "Planting Sky Buds";

            progress.Set(0.9f);

            //Goes through each mapped island, then tries to plant on each cloud tile with no water with a 1/15 chance
            foreach (FloatingIsland island in islands)
            {
                for (int i = island.xMin; i < island.xMax; i++)
                {
                    for (int j = 0; j < Main.maxTilesY * 0.18f; j++)
                    {
                        if ((Framing.GetTileSafely(i, j).type == TileID.Cloud || Framing.GetTileSafely(i, j).type == TileID.RainCloud) && !Framing.GetTileSafely(i, j - 1).active() && Framing.GetTileSafely(i, j - 1).liquid == 0)
                        {
                            if (Main.rand.Next(0, 16) == 0)
                            {
                                WorldGen.Place1x1(i, j - 1, ModContent.TileType <SkyBudHerb>());
                                Framing.GetTileSafely(i, j - 1).frameX = 0;
                            }
                        }
                    }
                }
            }

            progress.End();
        }
Exemple #8
0
        protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
        {
            progress.Message = Lang.gen[11].Value;
            _worldScale      = (float)(Main.maxTilesX / 4200) * 1.5f;
            float worldScale = _worldScale;
            Point point      = CreateStartPoint();
            int   x          = point.X;
            int   y          = point.Y;
            Point zero       = Point.Zero;

            ApplyRandomMovement(ref x, ref y, 100, 100);
            zero.X += x;
            zero.Y += y;
            PlaceFirstPassMud(x, y, 3);
            PlaceGemsAt(x, y, 63, 2);
            progress.Set(0.15f);
            ApplyRandomMovement(ref x, ref y, 250, 150);
            zero.X += x;
            zero.Y += y;
            PlaceFirstPassMud(x, y, 0);
            PlaceGemsAt(x, y, 65, 2);
            progress.Set(0.3f);
            int oldX = x;
            int oldY = y;

            ApplyRandomMovement(ref x, ref y, 400, 150);
            zero.X += x;
            zero.Y += y;
            PlaceFirstPassMud(x, y, -3);
            PlaceGemsAt(x, y, 67, 2);
            progress.Set(0.45f);
            x = zero.X / 3;
            y = zero.Y / 3;
            int num  = GenBase._random.Next((int)(400f * worldScale), (int)(600f * worldScale));
            int num2 = (int)(25f * worldScale);

            x = Utils.Clamp(x, LeftBeachEnd + num / 2 + num2, RightBeachStart - num / 2 - num2);
            WorldGen.mudWall = true;
            WorldGen.TileRunner(x, y, num, 10000, 59, addTile: false, 0f, -20f, noYChange: true);
            GenerateTunnelToSurface(x, y);
            WorldGen.mudWall = false;
            progress.Set(0.6f);
            GenerateHolesInMudWalls();
            GenerateFinishingTouches(progress, oldX, oldY);
        }
Exemple #9
0
        private void WastelandGen(GenerationProgress progress)
        {
            progress.Message = "Creating a barren wasteland.";
            progress.Set(0.20f);
            int     startPositionX = WorldGen.genRand.Next(Main.maxTilesX / 2 - 1200, Main.maxTilesX / 2 - 400);
            int     startPositionY = (int)Main.worldSurface - 300;
            Vector2 generationSize = new Vector2(0, 0);

            if (Main.maxTilesX == 4200 && Main.maxTilesY == 1200)
            {
                generationSize = new Vector2(262, 18);
            }
            if (Main.maxTilesX == 6300 && Main.maxTilesY == 1800)
            {
                generationSize = new Vector2(380, 22);
            }
            if (Main.maxTilesX == 8400 && Main.maxTilesY == 2400)
            {
                generationSize = new Vector2(608, 26);
            }

            var generationStartX = startPositionX;
            var generationStartY = RaycastDown(startPositionX, startPositionY);

            progress.Set(0.50f);

            for (int x = 0; x <= generationSize.X; x++)
            {
                for (int y = 0; y <= generationSize.Y; y++)
                {
                    int generationPositionX = generationStartX + x;
                    int generationPositionY = generationStartY + y;
                    if (Main.tile[generationPositionX, generationPositionY].active())
                    {
                        WorldGen.TileRunner(generationPositionX, generationPositionY, 5, WorldGen.genRand.Next(10, 20), (ushort)mod.TileType(nameof(CoarseRock)), false, 0f, 0f, true, true);

                        if (Main.tile[generationPositionX, generationPositionY].type == mod.TileType(nameof(CoarseRock)))
                        {
                            Main.tile[generationPositionX, generationPositionY].wall = (ushort)mod.WallType(nameof(CoarseRockWall));
                        }
                        progress.Set(0.70f);
                    }
                }
            }
        }
Exemple #10
0
        protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
        {
            progress.Message = Lang.gen[11].Value;
            this._worldScale = (float)(Main.maxTilesX / 4200) * 1.5f;
            float worldScale = this._worldScale;
            Point startPoint = this.CreateStartPoint();
            int   x          = startPoint.X;
            int   y          = startPoint.Y;
            Point zero       = Point.Zero;

            this.ApplyRandomMovement(ref x, ref y, 100, 100);
            zero.X += x;
            zero.Y += y;
            this.PlaceFirstPassMud(x, y, 3);
            this.PlaceGemsAt(x, y, (ushort)63, 2);
            progress.Set(0.15f);
            this.ApplyRandomMovement(ref x, ref y, 250, 150);
            zero.X += x;
            zero.Y += y;
            this.PlaceFirstPassMud(x, y, 0);
            this.PlaceGemsAt(x, y, (ushort)65, 2);
            progress.Set(0.3f);
            int oldX = x;
            int oldY = y;

            this.ApplyRandomMovement(ref x, ref y, 400, 150);
            zero.X += x;
            zero.Y += y;
            this.PlaceFirstPassMud(x, y, -3);
            this.PlaceGemsAt(x, y, (ushort)67, 2);
            progress.Set(0.45f);
            int num1 = zero.X / 3;
            int j    = zero.Y / 3;
            int num2 = GenBase._random.Next((int)(400.0 * (double)worldScale), (int)(600.0 * (double)worldScale));
            int num3 = (int)(25.0 * (double)worldScale);
            int i    = Utils.Clamp <int>(num1, this.LeftBeachEnd + num2 / 2 + num3, this.RightBeachStart - num2 / 2 - num3);

            WorldGen.mudWall = true;
            WorldGen.TileRunner(i, j, (double)num2, 10000, 59, false, 0.0f, -20f, true, true, -1);
            this.GenerateTunnelToSurface(i, j);
            WorldGen.mudWall = false;
            progress.Set(0.6f);
            this.GenerateHolesInMudWalls();
            this.GenerateFinishingTouches(progress, oldX, oldY);
        }
Exemple #11
0
        public void GenPetrifiedSafes(GenerationProgress progress)
        {
            progress.Message = Language.GetTextValue("Mods.PboneUtils.WorldGen.PetrifiedSafes");
            progress.Value   = 0;

            const int amount   = 15;
            const int maxTries = 7500;

            int underworldHeight = Main.maxTilesY - 200;

            Vector2[] existingPositions = new Vector2[amount];

            for (int attempts = 0; attempts < amount; attempts++)
            {
                bool success = false;
                int  tries   = 0;

                while (!success)
                {
                    tries++;
                    if (tries > maxTries)
                    {
                        break;
                    }

                    int     i   = WorldGen.genRand.Next(2, Main.maxTilesX);
                    int     j   = WorldGen.genRand.Next(underworldHeight, Main.maxTilesY);
                    Vector2 pos = new Vector2(i, j);

                    bool tooClose        = false;
                    int  minimumDistance = 10;

                    foreach (Vector2 point in existingPositions)
                    {
                        if (Vector2.Distance(point, pos) < minimumDistance)
                        {
                            tooClose = true;
                            break;
                        }
                    }

                    if (tooClose)
                    {
                        continue;
                    }

                    success = MiscVanillaMethods.BetterPlaceObject(i, j, ModContent.TileType <PetrifiedSafeTile>());

                    if (success)
                    {
                        existingPositions[attempts] = new Vector2(i, j);
                    }
                }

                progress.Set(attempts / maxTries);
            }
        }
        public void settleLiquid(GenerationProgress progress)
        {
            progress.Message = Lang.gen[27].Value;
            Liquid.QuickWater(3, -1, -1);
            WorldGen.WaterCheck();
            int k = 0;

            Liquid.quickSettle = true;
            while (k < 10)
            {
                int num = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
                k++;
                float num2 = 0f;
                while (Liquid.numLiquid > 0)
                {
                    float num3 = (float)(num - (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer)) / (float)num;
                    if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > num)
                    {
                        num = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
                    }
                    if (num3 > num2)
                    {
                        num2 = num3;
                    }
                    else
                    {
                        num3 = num2;
                    }
                    if (k == 1)
                    {
                        progress.Set(num3 / 3f + 0.33f);
                    }
                    int num4 = 10;
                    if (k > num4)
                    {
                    }
                    Liquid.UpdateLiquid();
                }
                WorldGen.WaterCheck();
                progress.Set((float)k * 0.1f / 3f + 0.66f);
            }
            Liquid.quickSettle  = false;
            Main.tileSolid[190] = true;
        }
        ////

        public override void Apply(GenerationProgress progress)
        {
            progress.Message = this.Name;               //Lang.gen[76].Value+"..Thin Ice"

            for (int i = 0; i < this.PassDefs.Count; i++)
            {
                this.ApplyPass(progress, this.PassDefs[i]);
            }

            progress.Set(1f);
        }
Exemple #14
0
        private bool RunGohanCleanupRoutine(GenerationProgress progress)
        {
            // we already have the starting position, just cut straight to the build cleanup.
            const string gohanHouseGen = "Cleaning up Grandpa's House...";

            if (progress != null)
            {
                progress.Message = gohanHouseGen;
                progress.Set(0.50f);
            }

            GenerateGohanStructureWithByteArrays(false);
            return(true);
        }
Exemple #15
0
 private void CavePass(GenerationProgress progress)
 {
     progress.Message = "Carving the Moon...";
     for (int currentCaveSpot = 0; currentCaveSpot < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00013); currentCaveSpot++)
     {
         float percentDone = (float)((double)currentCaveSpot / ((double)(Main.maxTilesX * Main.maxTilesY) * 0.00013));
         progress.Set(percentDone);
         if (rockLayerHigh <= (double)Main.maxTilesY)
         {
             int airType = -1;
             WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)rockLayerLow, Main.maxTilesY), WorldGen.genRand.Next(6, 20), WorldGen.genRand.Next(50, 300), airType);
         }
     }
 }
Exemple #16
0
        public override void Apply(GenerationProgress progress)
        {
            progress.Message = "Generating Snaking Caves";               //Lang.gen[76].Value+"..Thin Ice"

            int pad   = WormGenPass.PaddingDistance;
            int tileX = WorldGen.genRand.Next(pad, Main.maxTilesX - pad);
            int tileY = WorldGen.genRand.Next((int)Main.worldSurface + pad, (Main.maxTilesY - 200) - pad);

            WormSystemGen wormSys = CrystalCaveSystemGen.Create(progress, 0.5f, tileX, tileY);

            wormSys.PaintNodes(progress, 0.5f);

            progress.Set(1f);
        }
Exemple #17
0
        private void CustomSpiderCavernGenTask(GenerationProgress progress)
        {
            //Message name should probably change
            progress.Message = "Spawning Extra Spider Caves Tiles";
            progress.Start(0f);

            int tileArray1D = Main.maxTilesX * Main.maxTilesY;

            for (int k = 0; k < tileArray1D; k++)
            {
                progress.Set((float)k / tileArray1D);

                int i = k % Main.maxTilesX;
                int j = k / Main.maxTilesX;

                if (CanSpawnSpiderSac(i, j))
                {
                    WorldGen.PlaceTile(i, j, TileType <SpiderSacTile>(), forced: true);
                }
            }

            progress.Set(1f);
            progress.End();
        }
Exemple #18
0
        public bool AttemptToPlaceDragonBallsInWorld(GenerationProgress progress = null)
        {
            const string placingDragonBalls = "Placing Dragon Balls";

            if (progress != null)
            {
                progress.Message = placingDragonBalls;
                progress.Set(0.25f);
            }

            for (var i = 0; i < 7; i++)
            {
                TryPlacingDragonBall(i + 1);
            }
            return(true);
        }
Exemple #19
0
 public void AddForges(GenerationProgress progress)
 {
     progress.Message = Language.GetTextValue("LegacyGen.36");
     for (int k = 0; k < Main.maxTilesX / 200; k++)
     {
         float value = k / (Main.maxTilesX / 200);
         progress.Set(value);
         bool flag2 = false;
         int  num   = 0;
         while (!flag2)
         {
             int num2 = WorldGen.genRand.Next(1, Main.maxTilesX);
             int num3 = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 5);
             try
             {
                 if (Main.tile[num2, num3].wall != 13)
                 {
                     if (Main.tile[num2, num3].wall != 14)
                     {
                         continue;
                     }
                 }
                 while (!Main.tile[num2, num3].active())
                 {
                     num3++;
                 }
                 num3--;
                 WorldGen.PlaceTile(num2, num3, 77, false, false, -1, 0);
                 if (Main.tile[num2, num3].type == 77)
                 {
                     flag2 = true;
                 }
                 else
                 {
                     num++;
                     if (num >= 10000)
                     {
                         flag2 = true;
                     }
                 }
             }
             catch
             {
             }
         }
     }
 }
Exemple #20
0
        bool MakeGohanHouse(GenerationProgress progress)
        {
            string GohanHouseGen = "Creating the house of a legend.";

            if (progress != null)
            {
                progress.Message = GohanHouseGen;
                progress.Set(0.25f);
            }

            // before we do anything, create a new World Key for this world
            WorldDragonBallKey = Main.rand.Next(1, int.MaxValue);

            GohanHouseStartPositionX = WorldGen.genRand.Next(Main.maxTilesX / 2 - 70, Main.spawnTileX - 25);
            for (var Attempts = 0; Attempts < 10000; Attempts++)
            {
                for (var i = 0; i < 25; i++)
                {
                    GohanHouseStartPositionY = 190;
                    do
                    {
                        GohanHouseStartPositionY++;
                    }while ((!Main.tile[GohanHouseStartPositionX + i, GohanHouseStartPositionY].active() && GohanHouseStartPositionY < Main.worldSurface) || Main.tile[GohanHouseStartPositionX + i, GohanHouseStartPositionY].type == TileID.Trees || Main.tile[GohanHouseStartPositionX + i, GohanHouseStartPositionY].type == 27);
                    if (!Main.tile[GohanHouseStartPositionX, GohanHouseStartPositionY].active() || Main.tile[GohanHouseStartPositionX, GohanHouseStartPositionY].liquid > 0)
                    {
                        GohanHouseStartPositionX++;
                    }
                    if (Main.tile[GohanHouseStartPositionX + i, GohanHouseStartPositionY].active())
                    {
                        if (Main.tile[GohanHouseStartPositionX, GohanHouseStartPositionY].liquid > 0)
                        {
                            GohanHouseStartPositionX = WorldGen.genRand.Next(Main.maxTilesX / 2 - 70, Main.spawnTileX - 25);
                        }
                        else
                        {
                            goto GenerateBuild;
                        }
                    }
                }
            }
            goto GenerateBuild;

GenerateBuild:
            GenerateGohanStructureWithByteArrays(true);
            return(true);
        }
        private void ApplyPass(GenerationProgress progress, TerrainRemixerGenPassSpec passSpec)
        {
            var       config   = TerrainRemixerConfig.Instance;
            Rectangle tileArea = this.GetRegion(passSpec);

            var then = DateTime.UtcNow;

            if (config.DebugModeInfo)
            {
                LogLibraries.Log("Applying pass " + this.Name + " to " + tileArea.ToString());
            }

            (float[], float, float)map = TerrainRemixerGenPass.GetNoiseMap(
                Main.maxTilesX,
                tileArea.Height,
                passSpec.NoiseFrequency,
                (FastNoise.FractalType)passSpec.WormsMode,
                passSpec.Sharpness,
                //passSpec.IsPerturbed,
                out FastNoise _
                );

            float totalTiles = tileArea.Height * Main.maxTilesX;
            int   botY       = tileArea.Bottom;
            int   rightX     = tileArea.Right;

            for (int y = tileArea.Y; y < botY; y++)
            {
                for (int x = tileArea.X; x < rightX; x++)
                {
                    this.ApplyPassToTile(passSpec, tileArea, map, x, y);

                    // Update progress:
                    float currTile = x + ((y - tileArea.Y) * Main.maxTilesX);
                    progress.Set(currTile / totalTiles);
                }
            }

            var now = DateTime.UtcNow;

            if (config.DebugModeInfo)
            {
                LogLibraries.Log(" Applied pass " + this.Name + ": " + (now - then).TotalSeconds + "s");
            }
        }
Exemple #22
0
        private void GroundPass(GenerationProgress progress)
        {
            progress.Message  = "Landing on the Moon...";
            Main.worldSurface = surfaceLayer + 20; // Hides the underground layer just out of bounds
            Main.rockLayer    = surfaceLayer + 60; // Hides the cavern layer way out of bounds

            int surfaceHeight = (int)surfaceLayer; // If the moon's world size is variable, this probably should depend on that

            rockLayerLow  = surfaceHeight;
            rockLayerHigh = surfaceHeight;
            #region Base ground
            // Generate base ground
            for (int i = 0; i < Main.maxTilesX; i++)
            {
                // Here, we just focus on the progress along the x-axis
                progress.Set((i / (float)Main.maxTilesX - 1)); // Controls the progress bar, should only be set between 0f and 1f
                for (int j = surfaceHeight; j < subworld.height; j++)
                {
                    Main.tile[i, j].active(true);
                    Main.tile[i, j].type = (ushort)ModContent.TileType <Tiles.Protolith>();
                }

                if (WorldGen.genRand.Next(0, 10) == 0) // Not much deviation here
                {
                    surfaceHeight += WorldGen.genRand.Next(-1, 2);
                    if (WorldGen.genRand.Next(0, 10) == 0)
                    {
                        surfaceHeight += WorldGen.genRand.Next(-2, 3);
                    }
                }

                if (surfaceHeight < rockLayerLow)
                {
                    rockLayerLow = surfaceHeight;
                }

                if (surfaceHeight > rockLayerHigh)
                {
                    rockLayerHigh = surfaceHeight;
                }
            }
            #endregion
        }
Exemple #23
0
        bool MakeGohanHouse(GenerationProgress progress)
        {
            string gohanHouseGen = "Creating the house of a legend.";

            if (progress != null)
            {
                progress.Message = gohanHouseGen;
                progress.Set(0.25f);
            }

            gohanHouseStartPositionX = WorldGen.genRand.Next(Main.maxTilesX / 2 - 70, Main.spawnTileX - 25);
            for (var attempts = 0; attempts < 10000; attempts++)
            {
                for (var i = 0; i < 25; i++)
                {
                    gohanHouseStartPositionY = 190;
                    do
                    {
                        gohanHouseStartPositionY++;
                    }while ((!Main.tile[gohanHouseStartPositionX + i, gohanHouseStartPositionY].active() && gohanHouseStartPositionY < Main.worldSurface) || Main.tile[gohanHouseStartPositionX + i, gohanHouseStartPositionY].type == TileID.Trees || Main.tile[gohanHouseStartPositionX + i, gohanHouseStartPositionY].type == 27);
                    if (!Main.tile[gohanHouseStartPositionX, gohanHouseStartPositionY].active() || Main.tile[gohanHouseStartPositionX, gohanHouseStartPositionY].liquid > 0)
                    {
                        gohanHouseStartPositionX++;
                    }
                    if (Main.tile[gohanHouseStartPositionX + i, gohanHouseStartPositionY].active())
                    {
                        if (Main.tile[gohanHouseStartPositionX, gohanHouseStartPositionY].liquid > 0)
                        {
                            gohanHouseStartPositionX = WorldGen.genRand.Next(Main.maxTilesX / 2 - 70, Main.spawnTileX - 25);
                        }
                        else
                        {
                            goto GenerateBuild;
                        }
                    }
                }
            }
            goto GenerateBuild;

GenerateBuild:
            GenerateGohanStructureWithByteArrays(true);
            return(true);
        }
        bool MakeGravGenerator(GenerationProgress progress)
        {
            string gravGeneratorGen = "Placing some high tech doodads.";

            if (progress != null)
            {
                progress.Message = gravGeneratorGen;
                progress.Set(0.25f);
            }

            gravGeneratorStartPositionX = WorldGen.genRand.Next(Main.maxTilesX - 500, Main.maxTilesX - 200);
            for (var attempts = 0; attempts < 10000; attempts++)
            {
                for (var i = 0; i < 25; i++)
                {
                    gravGeneratorStartPositionY = 190;
                    do
                    {
                        gravGeneratorStartPositionY++;
                    }while ((!Main.tile[gravGeneratorStartPositionX + i, gravGeneratorStartPositionY].active() && gravGeneratorStartPositionX < Main.worldSurface) || Main.tile[gravGeneratorStartPositionX + i, gravGeneratorStartPositionY].type == TileID.Trees || Main.tile[gravGeneratorStartPositionX + i, gravGeneratorStartPositionY].type == 27);
                    if (!Main.tile[gravGeneratorStartPositionX, gravGeneratorStartPositionY].active() || Main.tile[gravGeneratorStartPositionX, gravGeneratorStartPositionY].liquid > 0)
                    {
                        gravGeneratorStartPositionX--;
                    }
                    if (Main.tile[gravGeneratorStartPositionX + i, gravGeneratorStartPositionY].active())
                    {
                        if (Main.tile[gravGeneratorStartPositionX, gravGeneratorStartPositionY].liquid > 0)
                        {
                            gravGeneratorStartPositionX = WorldGen.genRand.Next(Main.maxTilesX - 200, Main.maxTilesX - 500);
                        }
                        else
                        {
                            goto GenerateBuild;
                        }
                    }
                }
            }
            goto GenerateBuild;

GenerateBuild:
            GenerateGravGenerator();
            return(true);
        }
Exemple #25
0
        private void BackgroundPass(GenerationProgress progress)
        {
            // This generates before lunar caves so that there are overhangs
            progress.Message = "Backgrounding the Moon...";
            for (int tileX = 1; tileX < Main.maxTilesX - 1; tileX++)
            {
                int   wall            = 2;
                float progressPercent = tileX / Main.maxTilesX;
                progress.Set(progressPercent);
                bool surroundedTile = false;
                for (int tileY = 2; tileY < Main.maxTilesY - 1; tileY++)
                {
                    if (Main.tile[tileX, tileY].active())
                    {
                        wall = ModContent.WallType <Walls.RegolithWall>();
                    }

                    if (surroundedTile)
                    {
                        Main.tile[tileX, tileY].wall = (ushort)wall;
                    }

                    if
                    (
                        Main.tile[tileX, tileY].active() && // Current tile is active
                        Main.tile[tileX - 1, tileY].active() && // Left tile is active
                        Main.tile[tileX + 1, tileY].active() && // Right tile is active
                        Main.tile[tileX, tileY + 1].active() && // Bottom tile is active
                        Main.tile[tileX - 1, tileY + 1].active() && // Bottom-left tile is active
                        Main.tile[tileX + 1, tileY + 1].active() // Bottom-right tile is active
                                                                 // The following will help to make the walls slightly lower than the terrain
                        && Main.tile[tileX, tileY - 2].active()  // Top tile is active
                    )
                    {
                        surroundedTile = true; // Set the rest of the walls down the column
                    }
                }
            }
        }
Exemple #26
0
        private void RoseQuartzGeneration(GenerationProgress progress)
        {
            progress.Message = "Rose quartz-ifying the sky";
            progress.Start(0f);

            for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 0.005); k++)
            {
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                int y = WorldGen.genRand.Next(0, (int)(Main.maxTilesY * 0.15f));

                Tile tile = Framing.GetTileSafely(x, y);
                if (tile.active() && tile.type == TileID.Dirt)
                {
                    //3rd and 4th values are strength and steps, adjust later if needed
                    WorldGen.TileRunner(x, y, WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(2, 4),
                                        TileType <RoseQuartzTile>());
                }
            }

            progress.Set(1f);
            progress.End();
        }
        ////////////////

        public override void Apply(GenerationProgress progress)
        {
            (int TileX, int TileY)randCenterTile;
            float stepWeight = 1f / (float)this.NeededMirrors;

            if (progress != null)
            {
                progress.Message = "Pre-placing Mounted Magic Mirrors: %";
            }

            for (int i = 0; i < this.NeededMirrors; i++)
            {
                progress?.Set(stepWeight * (float)i);

                if (!this.GetRandomOpenMirrorableCenterTile(out randCenterTile, 1000))
                {
                    break;
                }

                this.MirrorPositions.Set2D(randCenterTile.TileX, randCenterTile.TileY);

                this.SpawnMirror(randCenterTile.TileX, randCenterTile.TileY);
            }
        }
Exemple #28
0
        private void SkyVillageGenTask(GenerationProgress progress)
        {
            progress.Message = "Generating Structures... Sky Village";
            progress.Start(0f);


            #region Mapping Floating Islands
            List <FloatingIsland> islands = new List <FloatingIsland>();
            int    islandsZone            = (int)(Main.maxTilesY * 0.18f);
            bool[] visitedCoords          = new bool[Main.maxTilesX * islandsZone];
            bool validCoordinate(Point16 pos)
            {
                //Making sure the coordinate is within the visitedCoords array
                if (pos.Y >= islandsZone)
                {
                    return(false);
                }

                Tile tile = Framing.GetTileSafely(pos);

                if (tile.type != TileID.Cloud && tile.type != TileID.RainCloud)
                {
                    return(false);
                }

                return(true);
            }

            //left top most visible screen coord is (41, 41)?
            for (int i = 41; i < Main.maxTilesX; i++)
            {
                for (int j = 41; j < islandsZone; j++)
                {
                    Point16 currentPos = new Point16(i, j);
                    if (!validCoordinate(currentPos))
                    {
                        continue;
                    }

                    List <Point16> currentIsland = new List <Point16>();

                    //Simple BFS Algorithm implementation
                    Queue <TileNode> queue        = new Queue <TileNode>();
                    TileNode         startingNode = new TileNode(currentPos);
                    queue.Enqueue(startingNode);

                    while (queue.Count != 0)
                    {
                        TileNode activeNode = queue.Dequeue();
                        if (!validCoordinate(activeNode.position))
                        {
                            continue;
                        }

                        //1D array that holds values of 2D coordinates needs a special formula for the index
                        int index = activeNode.position.Y * Main.maxTilesX + activeNode.position.X;
                        //index = row * maxColumns + column

                        if (visitedCoords[index])
                        {
                            continue;
                        }
                        else
                        {
                            visitedCoords[index] = true;
                        }

                        //If current coord wasn't visited yet, add it to the current island list
                        currentIsland.Add(activeNode.position);

                        List <TileNode> childNodes = activeNode.GetChildren();
                        childNodes.ForEach(child => queue.Enqueue(child));
                    }

                    //300 tiles? I should probably make some tests and define an average/2
                    if (currentIsland.Count > 300)
                    {
                        islands.Add(new FloatingIsland(currentIsland));
                    }

                    progress.Set((i * j / visitedCoords.Length) * 0.80f);
                }
            }
            #endregion

            #region Finding Suitable Spot and Generating it
            int structureWidth  = 160;
            int structureHeight = 92;

            //TODO: MAKE IT CHOOSE SPOTS THAT ARE NOT IN BETWEEN ISLANDS IF THEY'RE CLOSER TO THE CENTER (can happen in small worlds)
            //X
            int worldCenter = Main.maxTilesX / 2;
            int biggestDistanceBetweenIslands = 0;
            int smallestDistanceToWorldCenter = Main.maxTilesX;
            int xCoord = 0;

            for (int i = 0; i < islands.Count; i++)
            {
                //Can't do islands[i + 1] on last element
                if (i != islands.Count - 1)
                {
                    //Finding the biggest distance between two islands where the middle spot between the two is the closest to the world center
                    int distanceBetweenIslands = Math.Abs(islands[i + 1].xMin - islands[i].xMax); //Math.Abs not needed since they're ordered?
                    int theoricalXCoord        = islands[i].xMax + distanceBetweenIslands / 2 - structureWidth / 2;

                    if (distanceBetweenIslands > biggestDistanceBetweenIslands && Math.Abs(theoricalXCoord - worldCenter) < smallestDistanceToWorldCenter)
                    {
                        biggestDistanceBetweenIslands = distanceBetweenIslands;
                        smallestDistanceToWorldCenter = Math.Abs(theoricalXCoord - worldCenter);
                        xCoord = theoricalXCoord;
                    }
                }
            }

            progress.Set(0.85f);

            //Y
            int yAverage = 0;
            foreach (FloatingIsland island in islands)
            {
                yAverage += island.GetYAverage();
            }
            yAverage /= islands.Count;

            //Make sure structure y value doesn't go below 41 (world border)
            yAverage = yAverage - structureHeight > 41 ? yAverage - structureHeight : 42;

            progress.Set(0.90f);
            StructureHelper.StructureHelper.GenerateStructure("Structures/SkyVillageStructure", new Point16(xCoord, yAverage), mod);
            #endregion

            progress.End();
        }
Exemple #29
0
        public override void Generate(GenerationProgress progress, GameConfiguration configuration)
        {
            string GuideHouseGen = Language.GetTextValue("Mods.Antiaris.GuideHouseGen");

            if (progress != null)
            {
                progress.Message = GuideHouseGen;
                progress.Set(0.1f);
            }
            int startX = Main.maxTilesX / 2 + 5;
            int endX   = Main.spawnTileX + 50;

            StartPositionX = 0;
            StartPositionY = 0;
            for (int attempts = 0; attempts < 10000; attempts++)
            {
                StartPositionX = WorldGen.genRand.Next(startX, endX);
                StartPositionY = 200;
                do
                {
                    StartPositionY++;
                }while (!Main.tile[StartPositionX, StartPositionY].active() && StartPositionY < Main.worldSurface);
                if (Main.tile[StartPositionX, StartPositionY].active() && (Main.tile[StartPositionX, StartPositionY].type == TileID.Dirt || Main.tile[StartPositionX, StartPositionY].type == TileID.Grass) && TileUtilities.GetLiquidLevel(StartPositionX, StartPositionY - 1, LiquidType.Water) <= 0)
                {
                    goto GenerateBuild;
                }
            }
            //AntiarisHelper.Log("Continue...");

GenerateBuild:
            //AntiarisHelper.Log("Generating guide house...");
            int SpawnGuide = NPC.NewNPC((StartPositionX + 15) * 16, (StartPositionY - 6) * 16, Mod.Find <ModNPC>("UnconsciousGuide").Type, 0, 0f, 0f, 0f, 0f, 255);

            Main.npc[SpawnGuide].homeTileX = -1;
            Main.npc[SpawnGuide].homeTileY = -1;
            Main.npc[SpawnGuide].direction = 1;
            Main.npc[SpawnGuide].homeless  = false;

            PlaceGrids();

            WorldGen.PlaceObject(StartPositionX + 11, StartPositionY - 13, 79, true, Bed);
            WorldGen.PlaceChest(StartPositionX + 14, StartPositionY - 13, ChestType);
            int ChestIndex2 = Chest.FindChest(StartPositionX + 14, StartPositionY - 14);

            if (ChestIndex2 != -1)
            {
                do_GuideHouseLoot2(Main.chest[ChestIndex2].item);
            }
            WorldGen.PlaceObject(StartPositionX + 11, StartPositionY - 11, 42, true, 3);
            WorldGen.PlaceObject(StartPositionX + 14, StartPositionY - 15, 78, true);
            WorldGen.PlaceObject(StartPositionX + 8, StartPositionY - 5, 387, true);
            WorldGen.PlaceObject(StartPositionX + 11, StartPositionY - 6, 14, true, Table);
            WorldGen.PlaceObject(StartPositionX + 11, StartPositionY - 8, 103, true);
            WorldGen.PlaceObject(StartPositionX + 8, StartPositionY - 10, 50, true);
            WorldGen.PlaceObject(StartPositionX + 9, StartPositionY - 10, 13, true, 1);
            WorldGen.PlaceObject(StartPositionX + 15, StartPositionY - 10, 246, true, 3);
            WorldGen.PlaceObject(StartPositionX + 1, StartPositionY - 5, Mailbox);
            WorldGen.PlaceObject(StartPositionX + 22, StartPositionY - 6, Dray);
            WorldGen.PlaceObject(StartPositionX + 19, StartPositionY - 6, 10, true, Door);
            WorldGen.KillTile(StartPositionX + 11, StartPositionY - 2, false, false, true);
            WorldGen.KillTile(StartPositionX + 12, StartPositionY - 2, false, false, true);
            WorldGen.KillTile(StartPositionX + 11, StartPositionY - 3, false, false, true);
            WorldGen.KillTile(StartPositionX + 12, StartPositionY - 3, false, false, true);
            WorldGen.KillTile(StartPositionX + 10, StartPositionY - 2, false, false, true);
            WorldGen.KillTile(StartPositionX + 9, StartPositionY - 2, false, false, true);
            WorldGen.KillTile(StartPositionX + 10, StartPositionY - 3, false, false, true);
            WorldGen.KillTile(StartPositionX + 9, StartPositionY - 3, false, false, true);
            WorldGen.KillTile(StartPositionX + 8, StartPositionY - 2, false, false, true);
            WorldGen.KillTile(StartPositionX + 8, StartPositionY - 3, false, false, true);
            WorldGen.PlaceChest(StartPositionX + 11, StartPositionY - 2, 21, true, 28);
            int ChestIndex1 = Chest.FindChest(StartPositionX + 11, StartPositionY - 3);

            if (ChestIndex1 != -1)
            {
                do_GuideHouseLoot(Main.chest[ChestIndex1].item);
            }
        }
Exemple #30
0
        protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
        {
            int num = configuration.Get <int>("FlatBeachPadding");

            progress.Message = Lang.gen[0].Value;
            TerrainFeatureType terrainFeatureType = TerrainFeatureType.Plateau;
            int    num2 = 0;
            double num3 = (double)Main.maxTilesY * 0.3;

            num3 *= (double)GenBase._random.Next(90, 110) * 0.005;
            double num4 = num3 + (double)Main.maxTilesY * 0.2;

            num4 *= (double)GenBase._random.Next(90, 110) * 0.01;
            double         num5           = num3;
            double         num6           = num3;
            double         num7           = num4;
            double         num8           = num4;
            double         num9           = (double)Main.maxTilesY * 0.23;
            SurfaceHistory surfaceHistory = new SurfaceHistory(500);

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

            Main.rockLayer = (int)(Main.worldSurface + num12);
            int num13 = (int)(Main.rockLayer + (double)Main.maxTilesY) / 2;

            num13 += GenBase._random.Next(-100, 20);
            int lavaLine = num13 + GenBase._random.Next(50, 80);
            int num14    = 20;

            if (num7 < num6 + (double)num14)
            {
                double num15 = (num7 + num6) / 2.0;
                double num16 = Math.Abs(num7 - num6);
                if (num16 < (double)num14)
                {
                    num16 = num14;
                }
                num7 = num15 + num16 / 2.0;
                num6 = num15 - num16 / 2.0;
            }
            RockLayer        = num4;
            RockLayerHigh    = num8;
            RockLayerLow     = num7;
            WorldSurface     = num3;
            WorldSurfaceHigh = num6;
            WorldSurfaceLow  = num5;
            WaterLine        = num13;
            LavaLine         = lavaLine;
        }