Esempio n. 1
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;
            }
Esempio n. 2
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);
                        }
                    }
                }
            }
Esempio n. 3
0
            public void Generate(GenerationProgress progress)
            {
                progress.Message = "Building up the Lost City";

                var leftSide = InstantiateBuildings(Biome.Area.X - 10, Biome.Area.Bottom, -1);
                var rightSide = InstantiateBuildings(Biome.Area.X + 10, Biome.Area.Bottom, +1);

                ErectBuildings(leftSide);
                ErectBuildings(rightSide);

                BiomeManager.Get<LostCity>().buildings = leftSide.Concat(rightSide).ToList();
            }
Esempio n. 4
0
            public override void Update(GameTime gameTime)
            {
                base.Update(gameTime);

                float targetFade = Math.Min(1, BiomeManager.Get <Epicenter>().TileCounts / (float)BiomeManager.Get <Epicenter>().TileCountThreshold / 5);

                Instance.Fade += (targetFade - Instance.Fade) / 60;

                if (Instance.Fade < 0.01f && targetFade == 0)
                {
                    Instance.Fade = 0;
                }
            }
Esempio n. 5
0
            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;
            }
            public void Generate(GenerationProgress progress)
            {
                progress.Message = "Decorating the Lost City";

                var buildings = BiomeManager.Get<LostCity>().buildings;
                foreach (var building in buildings)
                {
                    for (int j = building.Area.Top; j <= building.Area.Bottom; j += building.FloorHeight)
                    {
                        for (int i = building.Area.Left + 1; i < building.Area.Right; i++)
                        {
                            IterateFloor(i, j, j == building.Area.Bottom);
                        }
                    }
                }

                GenLostChest(buildings);
            }
Esempio n. 7
0
 public override bool IsVisible()
 {
     return(BiomeManager.Get <Epicenter>().TileCounts > 0 || Fade > 0);
 }
Esempio n. 8
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;
            }