예제 #1
0
        private void AzercadmiumOres(GenerationProgress progress)
        {
            progress.Message = "Azercadmium Ores (You can read this? How ancient IS your computer?)";

            // "6E-05" = 0.00006 = normal ore
            for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 0.0005); k++)
            {
                // The inside of this for loop corresponds to one single splotch of our Ore.
                // First, we randomly choose any coordinate in the world by choosing a random x and y value.
                int  x    = WorldGen.genRand.Next(0, Main.maxTilesX);
                int  y    = WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY);
                Tile tile = Framing.GetTileSafely(x, y);
                if (tile.active() && tile.type == TileID.Mud)
                {
                    WorldGen.TileRunner(x, y, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(2, 8), ModContent.TileType <GreenCarnalliteOre>());
                }
            }
            for (int num = 0; num < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00006); num++)               //0.00008
            {
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.rockLayerHigh), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(3, 6), ModContent.TileType <Tiles.Zinc.ZincOre>(), false, 0f, 0f, false, true);
            }
            for (int num2 = 0; num2 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00015); num2++)               //0.0002
            {
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY), (double)WorldGen.genRand.Next(4, 9), WorldGen.genRand.Next(4, 8), ModContent.TileType <Tiles.Zinc.ZincOre>(), false, 0f, 0f, false, true);
            }
        }
예제 #2
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;
                }
            }
        }
예제 #3
0
 private void NewModOres(GenerationProgress progress)
 {
     progress.Message = "Adding New Mod Ores";
     for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 6E-06); k++)
     {
         int x = WorldGen.genRand.Next(0, Main.maxTilesX);
         int y = WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY);
         WorldGen.TileRunner(x, y, WorldGen.genRand.Next(12, 16), WorldGen.genRand.Next(4, 8), mod.TileType("FractaliteTile"));
     }
     //int count = 0;
     //while (count < 1)
     //{
     //    for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 6E-04); k++)
     //    {
     //        int x = WorldGen.genRand.Next(0, Main.maxTilesX);
     //        int y = WorldGen.genRand.Next((int)WorldGen.worldSurface, Main.maxTilesY);
     //        Tile tile = Framing.GetTileSafely(x, y);
     //        if (tile.active() && tile.type == TileID.Mud || tile.type == TileID.JungleGrass)
     //        {
     //            WorldGen.TileRunner(x, y, WorldGen.genRand.Next(4, 6), WorldGen.genRand.Next(3, 6), mod.TileType("LunarWoodTile"));
     //        }
     //    }
     //    count++;
     //}
 }
예제 #4
0
        private void Vaults(GenerationProgress progress)
        {
            progress.Message = "Locking Vaults";
            Point       POrigin = new Point((int)(Main.maxTilesX * 0.3f), 100);
            VaultPlanet planet  = new VaultPlanet();

            planet.Place(POrigin, WorldGen.structures);

            Point origin = new Point((int)(Main.maxTilesX * 0.4f), (int)(Main.maxTilesY * 0.6f));
            Vault a      = new Vault();

            a.Place(origin, WorldGen.structures);

            int DungeonSide = (Main.dungeonX > Main.maxTilesX / 2) ? (-1) : 1;

            origin = new Point(DungeonSide == 1 ? (Main.maxTilesX - 150) : 150, (int)(Main.maxTilesY * 0.7f));
            Vault b = new Vault();

            b.Place(origin, WorldGen.structures);

            origin = new Point((int)(Main.maxTilesX * 0.7f), (int)(Main.maxTilesY * 0.35f));
            Vault c = new Vault();

            c.Place(origin, WorldGen.structures);

            progress.Message = "Entering the Atmosphere";
            Point       OOrigin     = new Point((int)(Main.maxTilesX * 0.25f), 100);
            Observatory observatory = new Observatory();

            observatory.Place(OOrigin, WorldGen.structures);
        }
예제 #5
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;
                    }
                }
            }
        }
예제 #6
0
        internal void TerrainTop(GenerationProgress progress)
        {
            //Creates the Grass/Biome area for the variant.
            for (int i = 0; i < Main.maxTilesX; i++)
            {
                for (int j = Main.maxTilesY - 200; j < Main.maxTilesY - 195; j++)
                {
                    if (WorldGen.genRand.Next(20) == 0)
                    {
                        WorldGen.TileRunner(i, j, (int)WorldGen.genRand.Next(4, 6), 50, (2), true);
                    }
                }
            }

            //Replaces area with respective variants.
            for (int i = 0; i < Main.maxTilesX; i++)
            {
                for (int j = Main.maxTilesY - 200; j < Main.maxTilesY; j++)
                {
                    if (Main.tile[i, j].type != (2))
                    {
                        Main.tile[i, j].active(false);
                        Main.tile[i, j].liquid = 0;
                        Main.tile[i, j].wall   = 0;
                        Main.tile[i, j].slope(0);
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Generates a crystal cavern at position topCentre, where topCentre is exactly what it is called.
        /// </summary>
        /// <param name="centre">The top centre point of the cavern.</param>
        public static void VitricDesertGen(GenerationProgress progress)
        {
            progress.Message = "Vitrifying Desert";
            int   size   = (int)(Main.maxTilesX / 28f); //Width of the cavern; value shown here is half the size. So, functional size is actually size * 2.
            Point centre = new Point(WorldGen.UndergroundDesertLocation.X + size, WorldGen.UndergroundDesertLocation.Y + WorldGen.UndergroundDesertLocation.Height + 30);

            DigVitricCave(centre, size);
            for (int i = -4 - WorldGen.genRand.Next(7); i < 10 + WorldGen.genRand.Next(7); ++i) //Digs opening
            {
                for (int j = -12 - WorldGen.genRand.Next(5); j < 14 + WorldGen.genRand.Next(5); ++j)
                {
                    Main.tile[centre.X + i, centre.Y - 20 - j].active(false);
                }
            }

            Vector2 sandMid = GetGroundDirectional(new Vector2(0, 1), centre.ToVector2(), TileID.Platforms);

            Mod m = ModLoader.GetMod("StarlightRiver");

            GenerateSandDunes(new Point((int)sandMid.X, (int)sandMid.Y - 10), (int)(size * 1.15f)); //Generates SAND under the crystals. Wacky!
            GenerateCrystals(centre);                                                               //I wonder what this does
            GenerateFloatingOre(centre, 30, (int)(size * 0.7f));

            LegendWorld.vitricBiome = new Rectangle(centre.X - size, centre.Y - TotalHeight / 2, size * 2, 96);
        }
예제 #8
0
        private void MakeTunnels(GenerationProgress progress)
        {
            progress.Message = "Making mines tunnels";

            float widthScale       = Main.maxTilesX / tunnelsNmb;
            int   tre2             = (int)(2f * widthScale);
            int   numberToGenerate = WorldGen.genRand.Next((tre2 / 2) + 1, tre2 + 1);

            for (int k = 0; k < numberToGenerate; k++)
            {
                bool success  = false;
                int  attempts = 0;
                while (!success)
                {
                    attempts++;
                    if (attempts > 1000)
                    {
                        success = true;
                        continue;
                    }
                    int i = WorldGen.genRand.Next(300, Main.maxTilesX - 200);
                    int j = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY - 230);
                    success = PlaceTunnel(i, j);
                }
            }
        }
예제 #9
0
            private static void InfectArea(GenerationProgress progress)
            {
                var area   = BiomeManager.Get <Epicenter>().Area;
                var widthL = SurfaceWidth / 2f; // The left side of the biome's width.
                var widthR = SurfaceWidth / 2f; // The right side of the biome's width.
                var j      = area.Top;          // The current iterator. We iterate from top to bottom via rows.

                // Just a shortcut function :P
                void InfectRow()
                {
                    for (int i = area.Center.X - (int)widthL; i < area.Center.X + (int)widthR; i++)
                    {
                        TileExtensions.Infect(i, j);
                    }
                }

                float GetJPercent() => (j - area.Top) / (float)area.Height;

                // Initial surface. Skinny.
                for (; GetJPercent() < 0.1 && widthL + widthR < area.Width; j++)
                {
                    widthL += Rand(-1, 1);
                    widthR += Rand(-1, 1);
                    InfectRow();
                }
                progress.Value = 0.3f;

                float inc = 1f; // How the shape of the biome should expand/

                // Expansion. The underground is a lot larger than the above ground.
                for (; GetJPercent() < 0.5 && widthL + widthR < area.Width; j++)
                {
                    inc    += 0.01f;
                    widthL += Rand(-inc / 3, inc);
                    widthR += Rand(-inc / 3, inc);
                    InfectRow();
                }
                progress.Value = 0.5f;

                // The more jagged edges of the bottom of the biome's bottom
                inc = 0f;
                for (; GetJPercent() < 0.8; j++)
                {
                    inc    += 0.02f;
                    widthL += Rand(-inc, inc);
                    widthR += Rand(-inc, inc);
                    InfectRow();
                }
                progress.Value = 0.7f;

                // Finally, close the bottom of the biome
                for (; GetJPercent() < 1 && widthL + widthR > 0 && inc > 0; j++)
                {
                    inc    -= 0.065f;
                    widthL += Rand(-inc - 1, inc / 2);
                    widthR += Rand(-inc - 1, inc / 2);
                    InfectRow();
                }
                progress.Value = 0.9f;
            }
예제 #10
0
        private void UltimateQuestHardmodeOres(GenerationProgress progress)
        {
            //What displays during this step when generating the world
            progress.Message = "Generating Ultimate Quest Ores";

            //ore setup for Uru
            for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 4E-05); k++)
            {
                //where on the x axis the ore can generate
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                //where on the y axis the ore can generate
                int y = WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY);

                //Set the "Strength" and "Step" of the vein
                WorldGen.TileRunner(x, y, WorldGen.genRand.Next(2, 5), WorldGen.genRand.Next(12, 23), ModContent.TileType <Uru>());
            }
            //ore setup for Beskar
            for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
            {
                //where on the x axis the ore can generate
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                //where on the y axis the ore can generate
                int y = WorldGen.genRand.Next((int)WorldGen.rockLayerLow, Main.maxTilesY);

                //Set the "Strength" (Chance of success) and "Step" (Number of ore attempted to be generated) of the vein
                WorldGen.TileRunner(x, y, WorldGen.genRand.Next(5, 6), WorldGen.genRand.Next(10, 15), ModContent.TileType <Beskar>());
            }
        }
예제 #11
0
            public void Generate(GenerationProgress progress)
            {
                progress.Message = "Greater Erilipah";

                SetArea(progress);
                InfectArea(progress);
            }
예제 #12
0
            public void Generate(GenerationProgress progress)
            {
                const int lostCityHeight = 175;

                progress.Message = "Clearing out the Lost City";

                Rectangle tunnels = BiomeManager.Get <Epicenter.Mouth>().Tunnels;
                Rectangle area    = BiomeManager.Get <LostCity>().Area = new Rectangle(tunnels.X, tunnels.Bottom - 10, tunnels.Width, lostCityHeight);

                var noise = new FastNoise(WorldGen._genRandSeed)
                {
                    NoiseType   = FastNoise.NoiseTypes.CubicFractal,
                    FractalType = FastNoise.FractalTypes.Billow,
                    Frequency   = 0.08f
                };
                var focal         = new Vector2(area.Center.X, (int)(area.Top + area.Width * 0.8));
                var maxMiddleDist = (area.TopLeft() - focal).LengthSquared();

                for (int i = area.Left; i < area.Right; i++)
                {
                    for (int j = area.Top; j < area.Bottom; j++)
                    {
                        var middleDist = (new Vector2(i, j) - focal).LengthSquared() / maxMiddleDist;
                        var result     = noise.GetNoise(i, j);
                        if (result < -0.52f * (1 + middleDist))
                        {
                            WorldGen.KillTile(i, j);
                        }
                    }
                }
            }
예제 #13
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();
        }
예제 #14
0
        private void DolomiteGen(GenerationProgress progress)
        {
            progress.Message = "Shifting Tectonic Plates...";
            ushort Dolomite = (ushort)ModContent.TileType <Tiles.Dolomite.Dolomite>();

            for (int k = 0; k < (Main.rand.Next(4, 8)); k++)
            {
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                int y = WorldGen.genRand.Next((int)WorldGen.rockLayer, Main.maxTilesY);

                for (int i = x - 200; i <= x + 200; i++)
                {
                    for (int j = y - 100; j <= y + 100; j++)
                    {
                        if (i > 20 && j > 20 && i < Main.maxTilesX - 20 && j < Main.maxTilesY - 20)
                        {
                            if (Main.tile[i, j].type is TileID.Stone)
                            {
                                Main.tile[i, j].type = Dolomite;
                            }

                            if (!Main.tile[i, j + 2].active() && Main.tile[i, j].type == Dolomite)
                            {
                                Main.tile[i, j + 1].type = (ushort)ModContent.TileType <Tiles.Dolomite.DolomiteHanging>();
                            }

                            if (i % 15 == 0 && Main.tile[i, j].active() && Main.tile[i, j].type == Dolomite && !Main.tile[i, j - 1].active() && Main.rand.Next(3) == 0)
                            {
                                GenerateBeam(i, j);
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
        public void PaintNodes(GenerationProgress progress, float thisProgress)
        {
            float progressUnit = (float)thisProgress / (float)this.Nodes.Count;

            for (int i = 0; i < this.Nodes.Count; i++)
            {
                if (this.Nodes[i].TileRadius <= 1)
                {
                    continue;
                }

                this.Nodes[i].Paint(
                    r => Math.Max(r * 2, 16),
                    this.PaintTileOuter
                    );
                progress.Value += progressUnit * 0.5f;
            }

            for (int i = 0; i < this.Nodes.Count; i++)
            {
                if (this.Nodes[i].TileRadius <= 1)
                {
                    continue;
                }

                this.Nodes[i].Paint(
                    r => r,
                    this.PaintTileInner
                    );
                progress.Value += progressUnit * 0.5f;
            }

            this.PostProcessPaintedNodes();
        }
예제 #16
0
        private void GenNormalOres(GenerationProgress progress)
        {
            progress.Message = "生成普通矿物中……";
            // 生成数量是地图总物块数量的0.006%
            int size = (int)(Main.maxTilesX * Main.maxTilesY * 9E-04);

            for (int k = 0; k < size; k++)
            {
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                int y = WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY);                 // WorldGen.worldSurfaceLow is actually the highest surface tile. In practice you might want to use WorldGen.rockLayer or other WorldGen values.

                // 如果在地狱层以上
                if (y < WorldGen.rockLayer)
                {
                    // 原版自带矿物生成函数strength代表的是这个生成区域的最大大小,steps代表这个生成区域连接的紧密程度
                    WorldGen.TileRunner(x, y, Main.rand.Next(2, 5), Main.rand.Next(2, 5), mod.TileType("TemplateOre"), false, 0f, 0f, false, true);
                }
                else
                {
                    PlaceCross(x, y);
                }
                // Alternately, we could check the tile already present in the coordinate we are interested. Wrapping WorldGen.TileRunner in the following condition would make the ore only generate in Snow.
                // Tile tile = Framing.GetTileSafely(x, y);
                // if (tile.active() && tile.type == TileID.SnowBlock)
                // {
                //  WorldGen.TileRunner(.....);
                // }
                progress.Value = k / (float)size;
            }
        }
예제 #17
0
        private void The404Ore(GenerationProgress progress)
        {
            // progress.Message is the message shown to the user while the following code is running. Try to make your message clear. You can be a little bit clever, but make sure it is descriptive enough for troubleshooting purposes.
            progress.Message = "404 Crystals";

            // Ores are quite simple, we simply use a for loop and the WorldGen.TileRunner to place splotches of the specified Tile in the world.
            // "6E-05" is "scientific notation". It simply means 0.00006 but in some ways is easier to read.
            for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
            {
                // The inside of this for loop corresponds to one single splotch of our Ore.
                // First, we randomly choose any coordinate in the world by choosing a random x and y value.
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);
                int y = WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY); // WorldGen.worldSurfaceLow is actually the highest surface tile. In practice you might want to use WorldGen.rockLayer or other WorldGen values.

                // Then, we call WorldGen.TileRunner with random "strength" and random "steps", as well as the Tile we wish to place. Feel free to experiment with strength and step to see the shape they generate.
                // WorldGen.TileRunner(x, y, (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), TileType<The404Ore>(), false, 0f, 0f, false, true);

                // Alternately, we could check the tile already present in the coordinate we are interested. Wrapping WorldGen.TileRunner in the following condition would make the ore only generate in Hellstone.

                /*Tile tile = Framing.GetTileSafely(x, y);
                 * if (tile.active() && tile.type == TileID.Hellstone || tile.type == TileID.Ash)
                 * {
                 *  WorldGen.TileRunner(x, y, (double)WorldGen.genRand.Next(2, 4), WorldGen.genRand.Next(3, 5), TileType<The404Ore>(), false, 0f, 0f, false, true);
                 * }*/
            }
        }
예제 #18
0
        private void OreGeneration(GenerationProgress progress)
        {
            progress.Message = "Singularity Mod Ores";

            for (int i = 0; i < (int)((Main.maxTilesX * Main.maxTilesY) * 2E-03); i++)
            {
                int  x    = WorldGen.genRand.Next(0, (int)Main.maxTilesX);
                int  y    = WorldGen.genRand.Next(0, (int)Main.worldSurface / 3);
                Tile tile = Framing.GetTileSafely(x, y);
                if (tile.active() && (tile.type == TileID.Dirt))
                {
                    WorldGen.TileRunner(x, y, WorldGen.genRand.Next(4, 6), WorldGen.genRand.Next(2, 3), TileType <Tiles.EnchantedOre>(), true, 0, 0, false, true);
                }
            }
            for (int i = 0; i < (int)((Main.maxTilesX * Main.maxTilesY) * 2E-04); i++)
            {
                int  x    = WorldGen.genRand.Next(0, (int)Main.maxTilesX);
                int  y    = WorldGen.genRand.Next((int)Main.rockLayer, (int)Main.maxTilesY);
                Tile tile = Framing.GetTileSafely(x, y);
                if (tile.active() && (tile.type == TileID.SnowBlock || tile.type == TileID.IceBlock))
                {
                    WorldGen.TileRunner(x, y, WorldGen.genRand.Next(4, 6), WorldGen.genRand.Next(2, 3), TileType <Tiles.OpalOre>(), true, 0, 0, false, true);
                }
            }
            for (int i = 0; i < (int)((Main.maxTilesX * Main.maxTilesY) * 1E-03); i++)
            {
                int  x    = WorldGen.genRand.Next(0, (int)Main.maxTilesX);
                int  y    = WorldGen.genRand.Next((int)Main.rockLayer, (int)Main.maxTilesY);
                Tile tile = Framing.GetTileSafely(x, y);
                if (tile.active() && (tile.type == TileID.SnowBlock || tile.type == TileID.IceBlock))
                {
                    WorldGen.TileRunner(x, y, WorldGen.genRand.Next(6, 8), WorldGen.genRand.Next(2, 3), TileType <Tiles.GlacialFragment>(), true, 0, 0, false, true);
                }
            }
        }
예제 #19
0
        private void GenSetup(GenerationProgress progress)
        {
            progress.Message = "Initializing";

            Main.worldSurface = Main.maxTilesY * 0.32f;
            Main.rockLayer    = Main.maxTilesY * 0.5f;
        }
예제 #20
0
        public void GenBeneath(GenerationProgress progress)
        {
            progress.Message = "Making Grim Caves...";

            WorldGen.TileRunner(32, 32, WorldGen.genRand.Next(90, 200), 40, TileType <Grimstone>(), true, WorldGen.genRand.Next(9, 20), WorldGen.genRand.Next(-2, 2));
            WorldGen.TileRunner(32, 32, WorldGen.genRand.Next(90, 200), 40, TileType <Grimstone>(), true, WorldGen.genRand.Next(-20, -9), WorldGen.genRand.Next(-2, 2));
        }
예제 #21
0
            public void Generate(GenerationProgress progress)
            {
                //int tunnelsDepth = ConfigReader.Get<int>("worldgen.tunnels.maze depth");

                //progress.Message = "Erilipah Tunnels";

                //var noise = new FastNoise(WorldGen._genRandSeed)
                //{
                //    NoiseType = FastNoise.NoiseTypes.CubicFractal,
                //    FractalType = FastNoise.FractalTypes.Billow,
                //    Frequency = 0.08f
                //};

                //var basin = BiomeManager.Get<Mouth>().Basin;
                //var tunnels = BiomeManager.Get<Mouth>().Tunnels = new Rectangle(basin.X - basin.Width / 2, basin.Bottom - 2, basin.Width * 2, tunnelsDepth);
                //var focal = tunnels.Center.ToVector2();
                //var maxMiddleDist = (tunnels.TopLeft() - focal).LengthSquared();

                //for (int i = tunnels.Left; i < tunnels.Right; i++)
                //{
                //    for (int j = tunnels.Top; j < tunnels.Bottom; j++)
                //    {
                //        var middleDist = (new Vector2(i, j) - focal).LengthSquared() / maxMiddleDist;
                //        var result = noise.GetNoise(i + WorldGen._genRandSeed, j + WorldGen._genRandSeed);
                //        if (result < -0.50f * (1 + middleDist))
                //        {
                //            WorldGen.KillTile(i, j);
                //        }
                //    }
                //}
            }
예제 #22
0
        public void CleanupGohanHouse(GenerationProgress progress = null)
        {
            // bail if the house never generated, something is wrong :(
            if (!_generateGohanHouse)
            {
                return;
            }

            // bail if already done.
            if (_isGohanHouseCleaned)
            {
                return;
            }

            try
            {
                var success = RunGohanCleanupRoutine(progress);
                if (success)
                {
                    _isGohanHouseCleaned = true;
                }
            }
            catch (Exception exception)
            {
                Main.NewText("Oh no, an error happened [CleanupGohanHouse]! Report this to NuovaPrime or MercuriusXeno and send them the file Terraria/ModLoader/Logs/Logs.txt");
                ErrorLogger.Log(exception);
            }
        }
예제 #23
0
        //Copy
        private void AntiGreen(GenerationProgress progress)
        {
            progress.Message = "Begone Blocks (AA)";

            for (int k = 3; k < Main.maxTilesX - 3; k++)
            {
                for (int j = 3; j < Main.maxTilesY - 3; j++)
                {
                    if (Main.tile[k, j].type != TileID.EmeraldGemspark)
                    {
                        int gemCount = 0;
                        for (int g = -1; g < 2; g++)
                        {
                            for (int h = -1; h < 2; h++)
                            {
                                if (Main.tile[k + g, j + h].type == TileID.EmeraldGemspark)
                                {
                                    gemCount++;
                                }
                            }
                        }
                        if (gemCount >= 4) //lowering number increases AA
                        {
                            WorldGen.PlaceTile(k, j, TileID.EmeraldGemsparkOff, true, true);
                        }
                    }
                }
            }
        }
예제 #24
0
        public void InsertWorld(GenerationProgress progress)
        {
            progress.Message = "Loading map";


            int spawnX = Main.spawnTileX;
            int spawnY = Main.spawnTileY;

            for (int i = 0; i < 21; i++)
            {
                for (int j = 0; j < 21; j++)
                {
                    Tile tile = Framing.GetTileSafely(i + spawnX - 25, j + spawnY - 25);
                    tile.type = StarSailorMod.QRCode[j, i] == 1 ? TileID.ObsidianBrick : TileID.Glass;
                    tile.active(true);
                    tile.slope(0);

                    /*
                     * Tile tile2 = Framing.GetTileSafely(i, j);
                     * tile2.type = teo.QRCode[j, i] == 1 ? TileID.ObsidianBrick : TileID.Glass;
                     * tile2.active(true);
                     * tile2.slope(0);
                     */
                }
            }
            tsk.Add("(" + spawnX + "," + spawnY + ")");
        }
예제 #25
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);
        }
        ////

        private void GenerateNodes(GenerationProgress progress, float thisProgress, ISet <WormGen> worms)
        {
            int   maxNodes = worms.Max(wg => wg.CalculateFurthestKeyNode());
            float progStep = thisProgress / (float)maxNodes;

            do
            {
                foreach (WormGen worm in worms.ToArray())
                {
                    if (!worm.GenerateNextKeyNode(this, out WormGen fork))
                    {
                        worms.Remove(worm);
                        continue;
                    }

                    if (fork != null)
                    {
                        worms.Add(fork);
                    }

                    IList <WormNode> interpNodes = worm.CreateInterpolatedNodesFromRecentNodes();
                    if (interpNodes.Count > 0)
                    {
                        this.Nodes = this.Nodes.Union(interpNodes).ToList();
                    }
                }

                progress.Value += progStep;
            } while(worms.Count > 0);
        }
예제 #27
0
 private void ExtraGen(GenerationProgress progress)
 {
     for (int k = 0; k < 125000; k++)
     {
         int  i          = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
         int  j          = WorldGen.genRand.Next(200, (int)Main.worldSurface);
         Tile tile       = Framing.GetTileSafely(i, j);
         Tile bottomTile = Framing.GetTileSafely(i, j + 1);
         if (bottomTile.active() && TileID.Sets.Crimson[bottomTile.type] && (!tile.active() || Main.tileCut[tile.type]) && tile.liquid > 0 && tile.liquidType() == 0)
         {
             int index = WorldGen.PlaceChest(i, j, (ushort)chestTile, false, 2);
             if (index != -1)
             {
                 Chest chest = Main.chest[index];
                 chest.AddShop(AzercadmiumGlobalItem.GetItem(ItemID.ChaosFish));
             }
         }
         if (bottomTile.active() && TileID.Sets.Corrupt[bottomTile.type] && (!tile.active() || Main.tileCut[tile.type]) && tile.liquid > 0 && tile.liquidType() == 0)
         {
             int index = WorldGen.PlaceChest(i, j, (ushort)chestTile, false, 3);
             if (index != -1)
             {
                 Chest chest = Main.chest[index];
                 chest.AddShop(AzercadmiumGlobalItem.GetItem(ItemID.ChaosFish));
             }
         }
     }
 }
예제 #28
0
        public void GenerateBadBiome(GenerationProgress progress)
        {
            float num  = (float)WorldGen.genRand.Next(300, 400) * 0.001f;
            float num2 = (float)WorldGen.genRand.Next(200, 300) * 0.001f;
            int   num4 = (int)((float)Main.maxTilesX * (1f - num));
            int   num5 = 1;

            if (WorldGen.genRand.Next(2) == 0)
            {
                num4 = (int)((float)Main.maxTilesX * num);
                num5 = -1;
            }
            int num6 = 1;

            if (WorldGen.dungeonX < Main.maxTilesX / 2)
            {
                num6 = -1;
            }
            if (num6 < 0)
            {
                num4 = (int)((float)Main.maxTilesX * num2);
            }

            GenerateEvilAlt(num4, num5, BiomeLibs.Biomes.Values.ToList());
        }
예제 #29
0
        public void GenerateGoodBiome(GenerationProgress progress)
        {
            float num  = (float)WorldGen.genRand.Next(300, 400) * 0.001f;
            float num2 = (float)WorldGen.genRand.Next(200, 300) * 0.001f;
            int   num3 = (int)((float)Main.maxTilesX * num);
            int   num5 = 1;

            if (WorldGen.genRand.Next(2) == 0)
            {
                num5 = -1;
            }
            int num6 = 1;

            if (WorldGen.dungeonX < Main.maxTilesX / 2)
            {
                num6 = -1;
            }
            if (num6 < 0)
            {
                num3 = (int)((float)Main.maxTilesX * num2);
            }
            else
            {
                num3 = (int)((float)Main.maxTilesX * (1f - num2));
            }
            DetermineHallowAlt(num3, num5);
        }
예제 #30
0
        protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
        {
            // progress.Message is the message shown to the user while the following code is running.
            // Try to make your message clear. You can be a little bit clever, but make sure it is descriptive enough for troubleshooting purposes.
            progress.Message = "Example Mod Ores";

            // Ores are quite simple, we simply use a for loop and the WorldGen.TileRunner to place splotches of the specified Tile in the world.
            // "6E-05" is "scientific notation". It simply means 0.00006 but in some ways is easier to read.
            for (int k = 0; k < (int)(Main.maxTilesX * Main.maxTilesY * 6E-05); k++)
            {
                // The inside of this for loop corresponds to one single splotch of our Ore.
                // First, we randomly choose any coordinate in the world by choosing a random x and y value.
                int x = WorldGen.genRand.Next(0, Main.maxTilesX);

                // WorldGen.worldSurfaceLow is actually the highest surface tile. In practice you might want to use WorldGen.rockLayer or other WorldGen values.
                int y = WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY);

                // Then, we call WorldGen.TileRunner with random "strength" and random "steps", as well as the Tile we wish to place.
                // Feel free to experiment with strength and step to see the shape they generate.
                WorldGen.TileRunner(x, y, WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), ModContent.TileType <ExampleOre>());

                // Alternately, we could check the tile already present in the coordinate we are interested.
                // Wrapping WorldGen.TileRunner in the following condition would make the ore only generate in Snow.
                // Tile tile = Framing.GetTileSafely(x, y);
                // if (tile.active() && tile.type == TileID.SnowBlock)
                // {
                //  WorldGen.TileRunner(.....);
                // }
            }
        }
예제 #31
0
 public abstract void Apply(GenerationProgress progress);