コード例 #1
0
        /// <summary>Generates decor of every type throughout the biome</summary>
        private static void GenDecoration()
        {
            for (int i = VitricBiome.X + 5; i < VitricBiome.X + (VitricBiome.Width - 5); ++i) //Add vines & decor
            {
                for (int j = VitricBiome.Y; j < VitricBiome.Y + VitricBiome.Height - 10; ++j)
                {
                    if (i >= VitricBiome.Center.X - 52 && i <= VitricBiome.Center.X - 51)
                    {
                        continue;
                    }

                    if (Main.tile[i, j].active() && !Main.tile[i, j + 1].active() && genRand.Next(9) == 0 && ValidGround.Any(x => x == Main.tile[i, j].type)) //Generates vines, random size between 4-23
                    {
                        int targSize = genRand.Next(4, 23);
                        for (int k = 1; k < targSize; ++k)
                        {
                            if (Main.tile[i, j + k].active())
                            {
                                break;
                            }
                            PlaceTile(i, j + k, TileType <VitricVine>());
                        }
                    }
                    else
                    {
                        int type = genRand.Next(7); //Generates multitile decoration randomly
                        if (type == 0)
                        {
                            if (ValidGround.Any(x => x == Main.tile[i, j].type) && Helper.CheckAirRectangle(new Point16(i, j - 1), new Point16(1, 1)))
                            {
                                PlaceTile(i, j - 1, genRand.Next(2) == 0 ? TileType <VitricSmallCactus>() : TileType <VitricRock>(), false, false, -1, genRand.Next(4));
                            }
                        }
                        else if (type == 1)
                        {
                            if (ValidGround.Any(x => x == Main.tile[i, j].type) && Helper.CheckAirRectangle(new Point16(i, j - 2), new Point16(2, 2)) && ValidGround.Any(x => x == Main.tile[i + 1, j].type))
                            {
                                PlaceTile(i, j - 2, genRand.Next(2) == 0 ? TileType <VitricRoundCactus>() : TileType <VitricDecor>(), false, false, -1, genRand.Next(4));
                            }
                        }
                        else if (type == 2)
                        {
                            bool vGround = true;
                            for (int k = 0; k < 3; ++k)
                            {
                                if (!Main.tile[i + k, j].active() || !ValidGround.Any(x => x == Main.tile[i + k, j].type))
                                {
                                    vGround = false;
                                }
                            }
                            if (vGround && Helper.CheckAirRectangle(new Point16(i, j - 2), new Point16(3, 2)))
                            {
                                PlaceTile(i, j - 2, TileType <VitricDecorLarge>(), true, false, -1, genRand.Next(6));
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void ForestHerbGen(GenerationProgress progress)
        {
            progress.Message = "Planting ivy...";
            for (int k = 60; k < Main.maxTilesX - 60; k++)
            {
                if (Main.rand.Next(8) == 0 && k > Main.maxTilesX / 3 && k < Main.maxTilesX / 3 * 2) //Berry Bushes
                {
                    for (int y = 10; y < Main.worldSurface; y++)
                    {
                        if (Main.tile[k, y].type == TileID.Grass && Helper.CheckAirRectangle(new Point16(k, y - 2), new Point16(2, 2)))
                        {
                            Helper.PlaceMultitile(new Point16(k, y - 2), ModContent.TileType <Tiles.Herbology.ForestBerryBush>());
                        }
                    }
                }

                /*else if(Main.rand.Next(30) == 0) //Ivy Patches
                 * {
                 *  int size = Main.rand.Next(7, 20);
                 *
                 *  for (int x = k - (int)(size / 2); x < k + (int)(size / 2); x++)
                 *  {
                 *      for (int y = 10; y < Main.worldSurface; y++)
                 *      {
                 *          if (Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0)
                 *          {
                 *              WorldGen.PlaceTile(x, y - 1, ModContent.TileType<Tiles.Herbology.ForestIvyWild>());
                 *          }
                 *      }
                 *  }
                 *  //k += size * 2;
                 * }*/

                for (int j = 15; j < Main.worldSurface; j++)
                {
                    if (Main.rand.Next(500) == 0) //a check for grass could also be here which would speed up this step
                    {
                        int size = Main.rand.Next(3, 10);

                        for (int x = k - (int)(size / 2); x < k + (int)(size / 2); x++)
                        {
                            for (int y = j - (int)(size / 2); y < j + (int)(size / 2); y++)
                            {
                                if (Main.tile[x, y].active() && Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0) //!Main.tileSolid[Main.tile[x, y - 1].type] may be redundant
                                {
                                    WorldGen.PlaceTile(x, y - 1, ModContent.TileType <Tiles.Herbology.ForestIvyWild>());
                                    //WorldGen.PlaceTile((int)x, y - 2, TileID.RubyGemspark, true, true);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void ForestHerbGen(GenerationProgress progress)
        {
            progress.Message = "Planting the forest...";
            for (int k = 60; k < Main.maxTilesX - 60; k++)
            {
                if (k > Main.maxTilesX / 3 && k < Main.maxTilesX / 3 * 2) //inner part of the world
                {
                    if (k % 50 == 0 && WorldGen.genRand.Next(3) == 0)     //Starlight groves
                    {
                        int max = WorldGen.genRand.Next(30, 50);

                        for (int x = 0; x < max; x++)
                        {
                            bool shouldPlace = (x <5 || x> max - 5) ? WorldGen.genRand.NextBool() : true;

                            if (shouldPlace)
                            {
                                for (int y = 10; y < Main.worldSurface; y++)
                                {
                                    if (Main.tile[k + x, y].type == TileID.Grass)
                                    {
                                        WorldGen.PlaceTile(k + x, y, TileType <Tiles.Forest.Sod>(), true, true);
                                    }
                                }
                            }
                        }

                        k += max + 5;
                    }

                    if (WorldGen.genRand.Next(16) == 0) //Berry Bushes
                    {
                        for (int y = 10; y < Main.worldSurface; y++)
                        {
                            if (Main.tile[k, y].type == TileID.Grass && Main.tile[k + 1, y].type == TileID.Grass && Helper.CheckAirRectangle(new Point16(k, y - 2), new Point16(2, 2)))
                            {
                                Helper.PlaceMultitile(new Point16(k, y - 2), TileType <Tiles.Herbology.ForestBerryBush>());
                                k += 3;
                            }
                        }
                    }

                    else if (WorldGen.genRand.Next(50) == 0) //Palestone
                    {
                        for (int y = 10; y < Main.worldSurface; y++)
                        {
                            bool canPlace = true;

                            for (int w = -2; w < 2; ++w) //Scans are for valid placement (fixed some really bizzare placement issues)
                            {
                                if (Main.tile[k, y].type != TileID.Grass || !Main.tile[k, y].active())
                                {
                                    canPlace = false;
                                    break;
                                }
                            }

                            if (canPlace)
                            {
                                PalestoneChunk(k, y); //Place chunk
                                break;
                            }
                        }
                        k += 15;
                    }
                }

                for (int j = 15; j < Main.worldSurface; j++) //ivy
                {
                    if (WorldGen.genRand.Next(500) == 0)     //a check for grass could also be here which would speed up this step
                    {
                        int size = WorldGen.genRand.Next(6, 15);

                        for (int x = k - size / 2; x < k + size / 2; x++)
                        {
                            for (int y = j - size / 2; y < j + size / 2; y++)
                            {
                                if (Main.tile[x, y].active() && Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0) //!Main.tileSolid[Main.tile[x, y - 1].type] may be redundant
                                {
                                    WorldGen.PlaceTile(x, y - 1, TileType <Tiles.Herbology.ForestIvyWild>());
                                    break;
                                }
                            }
                        }
                    }
                }

                if (WorldGen.genRand.Next(30) == 0 && AnyGrass(k))
                {
                    int size = WorldGen.genRand.Next(10, 15);

                    for (int x = 0; x < size; x++)
                    {
                        int surface = 0;

                        for (int j = 50; j < Main.worldSurface; j++) //Wall Bushes
                        {
                            if (Main.tile[k + x, j].wall != 0 && Main.tile[k, j].wall != WallType <Tiles.Forest.LeafWall>())
                            {
                                surface = j; break;
                            }
                        }

                        int xOff = x > size / 2 ? size - x : x;

                        for (int y = surface - (xOff / 2 + WorldGen.genRand.Next(2)) - 3; true; y++)
                        {
                            WorldGen.PlaceWall(k + x, y, WallType <Tiles.Forest.LeafWall>());
                            if (y - surface > 20 || !WorldGen.InWorld(k + x, y + 1) || Main.tile[k + x, y + 1].wall != 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>Generates ruins using premade structures, or using the GenPillar method.</summary>
        /// <param name="validGround"></param>
        private static void GenRuins()
        {
            Point16[] ruinedHouseSizes = new Point16[6] {
                new Point16(8, 7), new Point16(14, 7), new Point16(12, 7), new Point16(10, 6), new Point16(12, 5), new Point16(14, 7)
            };
            int failCount = 0;

            for (int i = 0; i < 6; ++i)
            {
                if (failCount > 120)
                {
                    break;                  //To many fails, stop
                }
                int x = VitricBiome.X + VitricSlopeOffset + genRand.Next(VitricBiome.Width - (VitricSlopeOffset * 2));
                while (x > VitricBiome.X + VitricBiome.Width / 2 - 71 && x < VitricBiome.X + VitricBiome.Width / 2 + 70)
                {
                    x = VitricBiome.X + genRand.Next(VitricBiome.Width);
                }
                int     ty   = genRand.Next(ruinedHouseSizes.Length);
                Point16 size = ruinedHouseSizes[ty];
                int     y    = FindType(x, (VitricBiome.Y + 38) + (genRand.Next((int)(VitricBiome.Height / 3.2f))), -1, ValidGround) + genRand.Next(2);
                if ((x < VitricBiome.X + VitricBiome.Width / 2 - 71 || x > VitricBiome.X + VitricBiome.Width / 2 + 70) && Helper.CheckAirRectangle(new Point16(x, y - size.Y), new Point16(size.X, size.Y - 3)) && //ScanRectangle(x, y, size.X, size.Y) < 10
                    ValidGround.Any(v => v == Main.tile[x + 1, y].type) && ValidGround.Any(v => v == Main.tile[x + size.X - 1, y].type))
                {
                    StructureHelper.StructureHelper.GenerateStructure("Structures/Vitric/VitricTempleRuins_" + ty, new Point16(x, y - size.Y), StarlightRiver.Instance);
                }
                else
                {
                    i--; failCount++; continue;
                }
            }

            failCount = 0;
            for (int i = 0; i < 4; ++i)
            {
                if (failCount > 60)
                {
                    break;                 //Too many fails, stop
                }
                int x = VitricBiome.X + VitricSlopeOffset + genRand.Next(VitricBiome.Width - (VitricSlopeOffset * 2));
                while (x > VitricBiome.Center.X - 71 && x < VitricBiome.Center.X + 70)
                {
                    x = VitricBiome.X + VitricSlopeOffset + genRand.Next(VitricBiome.Width - (VitricSlopeOffset * 2));
                }
                int y = VitricBiome.Y + genRand.Next(VitricBiome.Height);
                while (Main.tile[x, y].active())
                {
                    y = VitricBiome.Y + genRand.Next(VitricBiome.Height);
                }
                if (RuinedPillarPositions.Any(v => Vector2.Distance(v.ToVector2(), new Vector2(x, y)) < 40) || !GenPillar(x, y))
                {
                    i--;
                    failCount++;
                }
            }
        }