Exemple #1
0
            private static void GenerateSpike(int i, int direction, int baseWidth, float attenuation)
            {
                // Get the lowest Y value
                int j = WorldgenExtensions.GetLowestInRange(i, i + baseWidth * direction, Area.Top, p => WorldGen.SolidOrSlopedTile(p.X, p.Y));

                // Add a base to the spike
                for (int k = 0; k < baseWidth; k++)
                {
                    for (int l = j; l < j + 4; l++)
                    {
                        WorldGen.PlaceTile(i + k * direction, j, TileType <Tiles.Epicenter.InfectedStone>(), forced: true);
                    }
                }

                // Create the jagged spike formation
                while (baseWidth > 0)
                {
                    for (int k = 0; k < baseWidth; k++)
                    {
                        WorldGen.PlaceTile(i + k * direction, j, TileType <Tiles.Epicenter.InfectedStone>(), forced: true);
                    }

                    if (WorldGen.genRand.NextFloat() < attenuation)
                    {
                        baseWidth--;
                    }

                    if (WorldGen.genRand.NextFloat() < attenuation)
                    {
                        i += 1 * direction;
                    }
                    j--;
                }
            }
Exemple #2
0
            private static IEnumerable<LostBuilding> InstantiateBuildings(int i, int j, int direction)
            {
                while (Math.Abs(i - Biome.Area.Center.X) < Biome.Area.Width / 2)
                {
                    int width = WorldGen.genRand.Next(16, 21);
                    int height = WorldGen.genRand.Next(Biome.Area.Height / 2, Biome.Area.Height);
                    int floorHeight = WorldGen.genRand.Next(10, 14);
                    height -= height % floorHeight;

                    int buildingJ = WorldgenExtensions.GetLowestInRange(i, i + width * direction, j, p => WorldGen.SolidOrSlopedTile(p.X, p.Y));
                    buildingJ += WorldGen.genRand.Next(-4, -1);

                    yield return new LostBuilding(direction, i, buildingJ, width, height, floorHeight);

                    i += direction * width + direction * WorldGen.genRand.Next(7, 13);
                }
            }
            private static void SetArea(GenerationProgress progress)
            {
                var xPercent = ConfigReader.Get <float>("worldgen.epicenter.world edge offset");

                var dungeonLeft = Main.dungeonX < Main.maxTilesX / 2;

                var width  = (int)(Main.maxTilesX * 0.08);
                var height = (int)(Main.maxTilesY * 0.7);
                int x      = (int)(!dungeonLeft
                    ? xPercent * Main.maxTilesX
                    : (1 - xPercent) * Main.maxTilesX - width
                                   );
                int y = WorldgenExtensions.GetHighestInRange(x + width / 2 - SurfaceWidth / 2, x + width / 2 + SurfaceWidth / 2, (int)WorldGen.worldSurfaceLow, p => WorldGen.SolidOrSlopedTile(p.X, p.Y));

                BiomeManager.Get <Epicenter>().Area = new Rectangle(x, y, width, height);
                progress.Value = 0.1f;
            }
Exemple #4
0
            public void Generate(GenerationProgress progress)
            {
                progress.Message = "Erilipah Epicenter";

                var o_baseWidth   = ConfigReader.Get <int>("worldgen.mouth.outer spike base width");
                var o_attenuation = ConfigReader.Get <float>("worldgen.mouth.outer spike attenuation");

                GenerateSpikePair(Area.Center.X, 60, o_baseWidth, o_attenuation);

                var i_baseWidth   = ConfigReader.Get <int>("worldgen.mouth.inner spike base width");
                var i_attenuation = ConfigReader.Get <float>("worldgen.mouth.inner spike attenuation");

                GenerateSpikePair(Area.Center.X, 35, i_baseWidth, i_attenuation);

                int pitStart = WorldgenExtensions.GetLowestInRange(Area.Center.X - 10, Area.Center.X + 10, (int)WorldGen.worldSurfaceLow, p => WorldGen.SolidOrSlopedTile(p.X, p.Y));

                GeneratePit(Area.Center.X, pitStart - 6);
            }
Exemple #5
0
            private static void GeneratePit(int i, int j)
            {
                int basinDepth = ConfigReader.Get <int>("worldgen.mouth.basin depth");

                float widthL = 3;
                float widthR = 3;
                float inc    = 0;

                void ClearRow()
                {
                    int left  = i - (int)widthL;
                    int right = i + (int)widthR;

                    for (int k = left; k <= right; k++)
                    {
                        WorldGen.KillTile(k, j);

                        if (!InfectiousWall.InfectWall(k, j))
                        {
                            Framing.GetTileSafely(k, j).wall = (ushort)InfectiousWall.Default;
                        }
                    }
                }

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

                // Create the opening
                for (; GetJPercent() < 0.15f && widthL + widthR < Epicenter.SurfaceWidth * 0.8; j++)
                {
                    inc    += 0.07f;
                    widthL += WorldGen.genRand.NextFloat(-inc / 2, inc);
                    widthR += WorldGen.genRand.NextFloat(-inc / 2, inc);
                    ClearRow();
                }

                Rectangle basin = new Rectangle(i - (int)widthL, j, (int)(widthL + widthR), basinDepth);

                // Create the "stomach" area
                int oldJ = j;

                for (; j < oldJ + basinDepth; j++)
                {
                    widthL += WorldGen.genRand.NextFloat(-1, 1);
                    widthR += WorldGen.genRand.NextFloat(-1, 1);
                    ClearRow();
                }

                for (; widthL + widthR > 0 && inc > 0; j++)
                {
                    inc    -= 0.015f;
                    widthL += WorldGen.genRand.NextFloat(-inc - 1, inc / 2);
                    widthR += WorldGen.genRand.NextFloat(-inc - 1, inc / 2);
                    ClearRow();
                }

                int lowest = WorldgenExtensions.GetLowestInRange(basin.Left, basin.Right, basin.Top, p => WorldGen.SolidOrSlopedTile(p.X, p.Y));

                basin.Height = lowest - basin.Top;

                BiomeManager.Get <Mouth>().Basin = basin;
            }