Esempio n. 1
0
        public static void GenNovus()
        {
            //WorldGen.TileRunner(x, y, (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), TileType<ExampleOre>(), false, 0f, 0f, false, true);
            for (double k = 0; k < (Main.maxTilesX - 200) * (Main.maxTilesY - 150 - (int)Main.rockLayer) / 25.0 / 1.0; k += 1.0)
            {
                int   genx     = WorldGen.genRand.Next(100, Main.maxTilesX - 100);
                int   geny     = WorldGen.genRand.Next((int)0, (int)Main.rockLayer + 150);
                Tile  tile     = Framing.GetTileSafely(genx, geny);
                int   chance   = 0;
                int[] size     = { 3, 8 };
                int   tiletype = TileType <UnmanedOreTile>();
                if (tile.active() && (tile.type == TileID.Dirt || tile.type == TileID.Stone || tile.type == TileID.RainCloud || tile.type == TileID.Cloud))
                {
                    chance = 2;
                    if (tile.active() && tile.type == TileID.RainCloud || tile.type == TileID.Cloud)
                    {
                        chance   = 5;
                        tiletype = TileType <Biomass>();
                        size[0]  = 2;
                        size[1]  = 5;
                    }
                    if (tile.active() && (geny < WorldGen.worldSurfaceLow || (WorldGen.genRand.Next(0, 1000) < 2)))
                    {
                        chance   = 100;
                        tiletype = TileType <Biomass>();
                    }
                }

                if (WorldGen.genRand.Next(0, 100) < chance)
                {
                    IDGWorldGen.TileRunner(genx, geny, (double)WorldGen.genRand.Next(size[0], size[1]), WorldGen.genRand.Next(5, 16), tiletype, false, 0f, 0f, false, true);
                }
            }
        }
Esempio n. 2
0
        private void PokeExits(int numExits)
        {
            int buffersmoller    = height - 10;
            int distanceToCenter = (buffersmoller * buffersmoller);

            Vector2 center = new Vector2(width / 2, height / 2);

            roomsize = 5;

            foreach (MazeRoom outermostRooms in mazeRooms.Where(testby => testby.gen > maxGen * 0.75f).OrderBy(testby => 0 - (new Vector2(testby.loc.X, testby.loc.Y) - new Vector2(width / 2, height / 2)).LengthSquared()).Take(numExits))
            {
                Point check1   = outermostRooms.loc.ToPoint();
                Point pointvec = (Vector2.Normalize(check1.ToVector2() - center) * 32).ToPoint();
                Point check2   = new Point(check1.X + pointvec.X, check1.Y + pointvec.Y);



                for (int xx = -roomsize; xx <= roomsize; xx += 1)
                {
                    for (int yy = -roomsize; yy <= roomsize; yy += 1)
                    {
                        foreach (Point there in IDGWorldGen.GetLine(check1, check2))
                        {
                            Point16 there2 = new Point16(there.X + xx, there.Y + yy);
                            if (InsideMap(there2.X, there2.Y))
                            {
                                Tile tileline = Main.tile[there2.X, there2.Y];
                                if (tileline.active())
                                {
                                    tileline.active(false);
                                    tileline.type = 0;// TileID.AmberGemspark;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public virtual void AGenPass(GenerationProgress prog)
        {
            UnifiedRandom UniRand  = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);
            int           lastseed = WorldGen._genRandSeed;

            WorldGen._genRandSeed = DimDungeonsProxy.DungeonSeeds;
            enemyseed             = (DimDungeonsProxy.DungeonSeeds);
            prog.Message          = "Loading";          //Sets the text above the worldgen progress bar
            Main.worldSurface     = Main.maxTilesY - 2; //Hides the underground layer just out of bounds
            Main.rockLayer        = Main.maxTilesY;     //Hides the cavern layer way out of bounds
            //Main.spawnTileX = (Main.maxTilesX / 2) / 16;
            prog.Message = "Once was nothing...";
            int tileheight = UniRand.Next(250, 400);


            NoiseGenerator Noisegen = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);

            Noisegen.Amplitude  = 1;
            Noisegen.Frequency *= 0.50;

            int[] tilesz = { TileID.Dirt, TileID.Dirt, TileID.Dirt, TileID.Dirt, TileID.Stone, TileID.Stone, TileID.DiamondGemsparkOff, TileID.SnowFallBlock };

            //Noisegen.Frequency

            for (int x = 0; x < Main.maxTilesX; x += 1)
            {
                for (int y = tileheight; y < Main.maxTilesY; y += 1)
                {
                    double nousey = (double)MathHelper.Clamp((float)Noisegen.Noise(x, y) + 0.40f, -1.00f, 1.00f);
                    Main.tile[x, y].type = TileID.Stone;

                    int index = (int)MathHelper.Clamp((float)(0.50 + nousey / 2.0) * tilesz.Length, 0f, tilesz.Length - 1);
                    Main.tile[x, y].type = (ushort)tilesz[index];
                    Main.tile[x, y].active(true);
                    if (nousey < 0)
                    {
                        Main.tile[x, y].type = TileID.Dirt;
                    }
                }
            }

            List <DungeonTile> gatebackdroptiles = new List <DungeonTile>();

            int roomwidth  = 160;
            int roomheight = 80;

            int center = (width / 2);

            for (int y = (height / 2) - (int)(roomheight); y < height; y += 1)
            {
                for (int x = center; x < center + (int)(roomwidth); x += 1)
                {
                    double input = ((double)center) - (x - 80);

                    float sigmoid = 1f - (1f / (1f + (float)Math.Pow(Math.E, -(input / 10.00))));

                    Vector2 there = new Vector2(x, y + sigmoid * 60f);

                    IDGWorldGen.PlaceMulti(there, TileID.BlueDungeonBrick, 8, WallID.BlueDungeonSlab);
                    if (there.Y < (height / 2) + 1)
                    {
                        gatebackdroptiles.Add(new DungeonTile(there, 0, 0, there.Y > ((height / 2) - 1), 0));
                    }
                }

                for (int x = center - (int)(roomwidth); x < center; x += 1)
                {
                    double input = ((double)center) - (x + 80);

                    float sigmoid = (1f / (1f + (float)Math.Pow(Math.E, -(input / 10.00))));

                    Vector2 there = new Vector2(x, y + sigmoid * 60f);

                    IDGWorldGen.PlaceMulti(there, TileID.BlueDungeonBrick, 8, WallID.PinkDungeonSlab);
                    if (there.Y < (height / 2) + 1)
                    {
                        gatebackdroptiles.Add(new DungeonTile(there, 0, 0, there.Y > ((height / 2) - 1), 0));
                    }
                }
            }

            List <Point> platforms = new List <Point>();

            for (int i = 0; i < gatebackdroptiles.Count; i += 1)
            {
                DungeonTile atilz  = gatebackdroptiles[i];
                int         valuex = (int)atilz.vector.X;
                if (atilz.floor)
                {
                    Main.tile[valuex, (int)atilz.vector.Y + 1].type = TileID.TeamBlockYellow;
                }
                Main.tile[valuex, (int)atilz.vector.Y].active(false);
                Main.tile[valuex, (int)atilz.vector.Y].wall = (atilz.vector.Y % 20 < 3 ? WallID.PinkDungeonSlab : WallID.BlueDungeonTile);

                if (Math.Abs(valuex - (width / 2)) < 100)
                {
                    if (valuex % 12 == 0)
                    {
                        int valuexx = valuex;
                        Main.tile[valuexx, (int)atilz.vector.Y].wall = 0;
                        WorldGen.PlaceWall(valuexx, (int)atilz.vector.Y, WallID.PalladiumColumn);

                        if ((int)atilz.vector.Y % 30 == ((valuex % 24 == 0) ? 15 : 0))
                        {
                            WorldGen.PlaceObject(valuexx, (int)atilz.vector.Y, TileID.Torches, false, 6);
                            for (int iii = -5; iii < 6; iii += 1)
                            {
                                platforms.Add(new Point(valuexx + iii, (int)atilz.vector.Y + 2));
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < platforms.Count; i += 1)
            {
                WorldGen.PlaceTile(platforms[i].X, platforms[i].Y, TileID.Platforms, style: 21);
            }
        }
Esempio n. 4
0
        public virtual void AGenPass(GenerationProgress prog)
        {
            UnifiedRandom UniRand  = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);
            int           lastseed = WorldGen._genRandSeed;

            WorldGen._genRandSeed = DimDungeonsProxy.DungeonSeeds;
            enemyseed             = (DimDungeonsProxy.DungeonSeeds);
            prog.Message          = "Loading";          //Sets the text above the worldgen progress bar
            Main.worldSurface     = Main.maxTilesY - 2; //Hides the underground layer just out of bounds
            Main.rockLayer        = Main.maxTilesY;     //Hides the cavern layer way out of bounds
            //Main.spawnTileX = (Main.maxTilesX / 2) / 16;
            prog.Message = "Once was nothing...";
            int        tileheight   = UniRand.Next(250, 400);
            List <int> surfacelevel = new List <int>();
            int        updown       = UniRand.Next(0, 2) == 0 ? 1 : -1;

            EnemySpawnsOverride = delegate(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo, SGAPocketDim pocket)
            {
                UnifiedRandom UniRand2 = new UnifiedRandom(pocket.enemyseed);
                for (int i = 0; i < pool.Count; i += 1)
                {
                    pool[i] = 0f;
                }
                pool[ModContent.NPCType <NullWatcher>()] = 1f;
                pool[ModContent.NPCType <StygianVein>()] = 0.05f;

                pocket.chooseenemies = true;
                return(1);
            };

            //Base Terrain
            for (int x = 0; x < Main.maxTilesX; x += 1)
            {
                for (int y = tileheight; y < Main.maxTilesY; y += 1)
                {
                    Tile thetile = Framing.GetTileSafely(x, y);
                    thetile.active(true);
                    thetile.type = (ushort)SGAmod.Instance.TileType("Fabric");
                }
                if (Math.Abs(x - Main.maxTilesX / 2) < 30)
                {
                    Main.spawnTileY = tileheight;
                }
                else
                {
                    if (UniRand.Next(0, 10) == 1)
                    {
                        tileheight += UniRand.Next(1, 3) * updown;
                        if (UniRand.Next(0, 4) == 1)
                        {
                            updown = UniRand.Next(0, 2) == 0 ? 1 : -1;
                        }
                    }
                }
                if (surfacelevel.Count < x + 1)
                {
                    surfacelevel.Add(tileheight);
                }
            }


            for (int i = 0; i < 100; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + UniRand.Next(50, 100), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(5, 15), UniRand.Next(5, 15), SGAmod.Instance.TileType("EntrophicOre"), false, 0f, 0f, false, true, UniRand);
            }

            for (int i = 0; i < 300; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + (i % 20 == 0 ? -10 : 60), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(10, 50), UniRand.Next(15, 45) + i, -2, false, 0f, 0f, false, true, UniRand);
            }

            for (int i = 0; i < 150; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + UniRand.Next(20, 160), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(3, 6), UniRand.Next(2, 4), SGAmod.Instance.TileType("HopeOre"), false, 0f, 0f, false, true, UniRand);
            }

            //Noisegen.Frequency

            surfacelevel.Clear();


            //Ancient Fabric and fill in
            tileheight = Main.maxTilesY - Main.rand.Next(400, 400);

            for (int x = Main.maxTilesX - 1; x > 0; x -= 1)
            {
                Tile thetile = Framing.GetTileSafely(x, tileheight);
                IDGWorldGen.TileRunner(x, tileheight, (double)UniRand.Next(5, 10), UniRand.Next(2, 4), SGAmod.Instance.TileType("AncientFabric"), true, 0f, 0f, false, true, UniRand);
                thetile.active(true);
                thetile.type = (ushort)SGAmod.Instance.TileType("AncientFabric");

                for (int i = tileheight; i < Main.maxTilesY; i += 1)
                {
                    Framing.GetTileSafely(x, i).wall = (ushort)SGAmod.Instance.WallType("NullWall");
                }

                if (UniRand.Next(0, 10) == 1)
                {
                    tileheight += UniRand.Next(1, 3) * updown;
                    if (UniRand.Next(0, 4) == 1)
                    {
                        updown = (UniRand.Next(0, 2) == 0 || tileheight > Main.maxTilesY - 300) ? -1 : 1;
                    }
                }
            }

            NoiseGenerator Noisegen = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);

            Noisegen.Amplitude   = 1;
            Noisegen.Octaves     = 4;
            Noisegen.Persistence = 0.750;
            Noisegen.Frequency  *= 1.25;


            for (int y = 0; y < Main.maxTilesY; y += 1)
            {
                for (int x = 0; x < Main.maxTilesX; x += 1)
                {
                    float tilerate = -0.25f + (1f - (y / (float)Main.maxTilesY)) * 1f;
                    Tile  tile     = Main.tile[x, y];
                    if (tile.active() && tile.type == (ushort)SGAmod.Instance.TileType("Fabric"))
                    {
                        float nousey = MathHelper.Clamp((float)Noisegen.Noise(x, y), -1.00f, 1.00f);
                        if (nousey > tilerate)
                        {
                            Main.tile[x, y].type = (ushort)SGAmod.Instance.TileType("HardenedFabric");
                            Main.tile[x, y].color((byte)Paints.Shadow);
                        }
                        else
                        {
                            if (nousey > tilerate - 0.20f)
                            {
                                Main.tile[x, y].color((byte)Paints.Gray);
                            }
                        }
                    }
                }
            }


            WorldGen._genRandSeed = lastseed;
        }
        public static void PlaceCaiburnHallway(Vector2 placementspot, int width, int height, int direction, ref List <Vector2> deways, int generation, int tiletype, int walltype)
        {
            Tile tstart = Framing.GetTileSafely(placementspot);

            int buffersizex = width + WorldGen.genRand.Next(3);
            int buffersizey = height + WorldGen.genRand.Next(3);
            int x           = (int)placementspot.X;
            int y           = (int)placementspot.Y;
            int xbuffer     = -buffersizex;
            int ybuffer     = -buffersizey;

            //ushort[] stoneTypes = new ushort[] { TileID.Stone, TileID.Dirt, TileID.Mud, TileID.ClayBlock };
            for (xbuffer = -buffersizex; xbuffer < buffersizex; xbuffer++)
            {
                for (ybuffer = -buffersizey; ybuffer < buffersizey; ybuffer++)
                {
                    Point loc  = new Point((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer);
                    Tile  tile = Framing.GetTileSafely(loc.X, loc.Y);
                    IDGWorldGen.PlaceMulti(placementspot + new Vector2(xbuffer, ybuffer), tiletype, 4, walltype);
                    deways.Add(new Vector2(loc.X, loc.Y));

                    allDankWater.Add(loc);

                    if (generation > 1000)
                    {
                        if (xbuffer < 2 && xbuffer > -2)
                        {
                            deways.Add(new Vector2((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer - 1));
                            deways.Add(new Vector2((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer - 2));
                            deways.Add(new Vector2((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer - 3));
                        }
                    }
                }
            }

            for (int there = 0; there < 4; there++)
            {
                if (there != direction && WorldGen.genRand.Next(0, direction == 3 ? 50 : 100) > generation)
                {
                    Vector2 edge    = new Vector2(width, 0);
                    int     width2  = 8 + WorldGen.genRand.Next(7);
                    int     height2 = 4 + WorldGen.genRand.Next(3);
                    if (direction == 1)
                    {
                        width2  = 3 + WorldGen.genRand.Next(1);
                        height2 = 5 + WorldGen.genRand.Next(12);
                        edge    = new Vector2(0, -height);
                        edge   += new Vector2(0, -height2);
                    }
                    else if (direction == 2)
                    {
                        edge  = new Vector2(-width, 0);
                        edge += new Vector2(-width2, 0);
                    }
                    else if (direction == 3)
                    {
                        width2  = 3 + WorldGen.genRand.Next(1);
                        height2 = 4 + WorldGen.genRand.Next(12);
                        edge    = new Vector2(0, height);
                        edge   += new Vector2(0, height2);
                    }
                    else
                    {
                        edge += new Vector2(width2, 0);
                    }

                    Tile tile = Framing.GetTileSafely((int)(placementspot + edge * 2f).X, (int)(placementspot + edge * 2f).Y);

                    if (tile.type != TileID.GoldBrick && tile.type != TileID.SilverBrick && tile.type != TileID.CopperBrick && tile.type != SGAmod.Instance.TileType("MoistStone") &&
                        tile.type != TileID.LihzahrdBrick && tile.type != TileID.BlueDungeonBrick && tile.type != TileID.GreenDungeonBrick && tile.type != TileID.PinkDungeonBrick)
                    {
                        PlaceCaiburnHallway(placementspot + edge, width2, height2, there, ref deways, generation + 2, tiletype, walltype);
                    }
                }
                else
                {
                    if (generation < 1000 && generation > 35)
                    {
                        //tiletype = TileID.CopperBrick;
                        //walltype = WallID.CopperBrick;
                        PlaceCaiburnHallway(placementspot + new Vector2(0, -10), 5, 10, 1, ref deways, 1500, tiletype, walltype);
                        break;
                    }
                }
            }
        }
        public static void PlaceCaiburnShrine(Vector2 placementspot, int type)
        {
            Tile tstart       = Framing.GetTileSafely(placementspot);
            int  heighestTile = Main.maxTilesY;
            int  lowestTile   = 0;

            List <Vector2> deways         = new List <Vector2>();
            List <Vector2> dewaysMainroom = new List <Vector2>();

            int buffersizex = 12 + WorldGen.genRand.Next(7);
            int buffersizey = 8 + WorldGen.genRand.Next(3);
            int x           = (int)placementspot.X;
            int y           = (int)placementspot.Y;
            int xbuffer     = -buffersizex;
            int ybuffer     = -buffersizey;

            //ushort[] stoneTypes = new ushort[] { TileID.Stone, TileID.Dirt, TileID.Mud, TileID.ClayBlock };
            for (xbuffer = -buffersizex; xbuffer < buffersizex; xbuffer++)
            {
                for (ybuffer = -buffersizey; ybuffer < buffersizey; ybuffer++)
                {
                    Point loc  = new Point((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer);
                    Tile  tile = Framing.GetTileSafely(loc.X, loc.Y);
                    IDGWorldGen.PlaceMulti(placementspot + new Vector2(xbuffer, ybuffer), SGAmod.Instance.TileType("MoistStone"), 4, SGAmod.Instance.WallType("SwampWall"));
                    dewaysMainroom.Add(new Vector2(loc.X, loc.Y));
                    allDankWater.Add(loc);
                }
            }

            int t1 = SGAmod.Instance.TileType("MoistStone");
            int t2 = SGAmod.Instance.WallType("SwampWall");

            PlaceCaiburnHallway(placementspot + new Vector2(buffersizex * 1, 0), 12, 6, 0, ref deways, 0, t1, t2);
            PlaceCaiburnHallway(placementspot + new Vector2(-buffersizex * 1, 0), 12, 6, 2, ref deways, 0, t1, t2);


            //Clear out area
            for (int aaa = 0; aaa < deways.Count; aaa++)
            {
                if ((int)deways[aaa].Y < heighestTile)
                {
                    heighestTile = (int)deways[aaa].Y;
                }
                if ((int)deways[aaa].Y > lowestTile)
                {
                    lowestTile = (int)deways[aaa].Y;
                }

                Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y);
                tile.active(false);
            }

            //Turn to water
            foreach (Vector2 point in deways.Where(testby => testby.Y > lowestTile - 150))
            {
                if (point.Y + WorldGen.genRand.Next(150) > lowestTile)
                {
                    Tile tile = Framing.GetTileSafely((int)point.X, (int)point.Y);
                    tile.liquid = 20;
                }
            }

            //Remove top area
            HashSet <Point16> removes = new HashSet <Point16>();

            foreach (Vector2 point in deways.Where(testby => testby.Y < heighestTile + 3))
            {
                Point16 point2 = point.ToPoint16();
                if (WorldGen.InWorld(point2.X - 4, point2.Y - 2) && WorldGen.InWorld(point2.X + 4, point2.Y - 2))
                {
                    // if (Main.tile[point2.X - 4, point2.Y-2].type == ModContent.TileType<MoistStone>() && Main.tile[point2.X + 4, point2.Y-2].type == ModContent.TileType<MoistStone>() &&
                    //    Main.tile[point2.X - 4, point2.Y].active() && Main.tile[point2.X - 4, point2.Y].type == ModContent.TileType<MoistStone>() && Main.tile[point2.X + 4, point2.Y].active() && Main.tile[point2.X + 4, point2.Y].type == ModContent.TileType<MoistStone>())
                    //{
                    removes.Add(new Point16(point2.X, point2.Y - 1));
                    removes.Add(new Point16(point2.X, point2.Y - 2));
                    removes.Add(new Point16(point2.X, point2.Y - 3));
                    //}
                }
            }

            //turn to biomass
            foreach (Point16 point2 in removes)
            {
                Tile tile = Framing.GetTileSafely(point2.X, point2.Y);
                if (tile.type == ModContent.TileType <MoistStone>())
                {
                    tile.type = (ushort)ModContent.TileType <Biomass>();
                }
            }


            //Fill some water area with Moist Sand
            //Liquid.QuickWater(3);
            //WaterCheck();

            //Do general object placement
            for (int aaa = 0; aaa < deways.Count; aaa++)
            {
                if (WorldGen.genRand.Next(0, 100) < 20)
                {
                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y + 1);
                    if (tile.active())
                    {
                        string[] onts = new string[] { "SwampGrassGrow", "SwampGrassGrow2", "SwampGrassGrow3" };
                        WorldGen.PlaceObject((int)deways[aaa].X, (int)deways[aaa].Y, SGAmod.Instance.TileType(onts[WorldGen.genRand.Next(onts.Length)]), true);
                    }
                }

                if (WorldGen.genRand.Next(0, 100) < 5)
                {
                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y - 1);
                    if (tile.active())
                    {
                        WorldGen.PlaceObject((int)deways[aaa].X, (int)deways[aaa].Y, TileID.HangingLanterns, false, 16);
                    }
                }
                if (WorldGen.genRand.Next(0, 100) < 5)
                {
                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y + 1);
                    if (tile.active())
                    {
                        WorldGen.placeTrap((int)deways[aaa].X, (int)deways[aaa].Y, 0);
                    }
                }
                if (WorldGen.genRand.Next(0, 100) < 2)
                {
                    Tile tile1 = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y + 1);
                    Tile tile2 = Framing.GetTileSafely((int)deways[aaa].X + 1, (int)deways[aaa].Y + 1);
                    Tile tile3 = Framing.GetTileSafely((int)deways[aaa].X + 1, (int)deways[aaa].Y);
                    Tile tile4 = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y);

                    Vector2 findone = Vector2.Zero;

                    findone = dewaysMainroom.Find(location => new Rectangle((int)location.X - 1, (int)location.Y - 1, 3, 3).Intersects(new Rectangle((int)deways[aaa].X - 1, (int)deways[aaa].Y - 1, 3, 3)));

                    if (tile1.active() && tile2.active() && !tile3.active() && !tile4.active() && findone == Vector2.Zero)
                    {
                        Point loc      = new Point((int)deways[aaa].X, (int)deways[aaa].Y);
                        int   thechest = WorldGen.PlaceChest(loc.X, loc.Y, 21, false, 12);

                        if (thechest > 0)
                        {
                            for (int xx = 0; xx < 2; xx += 1)
                            {
                                for (int yy = 0; yy < 2; yy += 1)
                                {
                                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X + xx, (int)deways[aaa].Y + yy - 1);
                                    tile.color((byte)Paints.DeepGreen);
                                }
                            }


                            List <int> loot = new List <int> {
                                2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2359, 301, 302, 303, 304, 305, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 226, 188, 189, 110, 28
                            };

                            List <int> lootmain = new List <int> {
                                SGAWorld.WorldIsNovus?SGAmod.Instance.ItemType("UnmanedOre") : SGAmod.Instance.ItemType("NoviteOre"), SGAmod.Instance.ItemType("DankWood"), SGAmod.Instance.ItemType("DankWood"), SGAmod.Instance.ItemType("Biomass"), SGAmod.Instance.ItemType("DankWood"), ItemID.SilverCoin, ItemID.LesserManaPotion
                            };
                            List <int> lootrare = new List <int> {
                                SGAmod.Instance.ItemType("DankCore"), SGAmod.Instance.ItemType("DankCore")
                            };
                            List <int> dankrare = new List <int> {
                                SGAmod.Instance.ItemType("DankWoodShield"), SGAmod.Instance.ItemType("MurkyCharm")
                            };
                            int e = 0;

                            for (int kk = 0; kk < 2 + (Main.expertMode ? 1 : 0); kk += 1)
                            {
                                //for (int i = 0; i < WorldGen.genRand.Next(15, Main.expertMode ? 25 : 30); i += 1)
                                //{
                                int index = WorldGen.genRand.Next(0, loot.Count);
                                Main.chest[thechest].item[e].SetDefaults(loot[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(1, Main.expertMode ? 3 : 2);
                                //}
                                e += 1;
                            }
                            if (WorldGen.genRand.Next(0, 100) < 25)
                            {
                                int index = WorldGen.genRand.Next(0, lootrare.Count);
                                Main.chest[thechest].item[e].SetDefaults(lootrare[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(1, Main.expertMode ? 3 : 1);
                                //}
                                e += 1;
                            }
                            if (WorldGen.genRand.Next(0, 20) == 0)
                            {
                                int index = WorldGen.genRand.Next(0, dankrare.Count);
                                Main.chest[thechest].item[e].SetDefaults(dankrare[index]);
                                Main.chest[thechest].item[e].stack = 1;
                                //}
                                e += 1;
                            }
                            for (int kk = 0; kk < 3 + (Main.expertMode ? 1 : 0); kk += 1)
                            {
                                //for (int i = 0; i < WorldGen.genRand.Next(15, Main.expertMode ? 25 : 30); i += 1)
                                //{
                                int index = WorldGen.genRand.Next(0, lootmain.Count);
                                Main.chest[thechest].item[e].SetDefaults(lootmain[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(15, Main.expertMode ? 25 : 45);

                                //}
                                e += 1;
                            }
                        }

                        ///WorldGen.PlaceChestDirect((int)deways[aaa].X, (int)deways[aaa].Y, (ushort)SGAmod.Instance.TileType("OvergrownChest"), 0, 0);
                    }
                }
            }

            for (int aaa = 0; aaa < dewaysMainroom.Count; aaa++)
            {
                Tile tile = Framing.GetTileSafely((int)dewaysMainroom[aaa].X, (int)dewaysMainroom[aaa].Y);
                //Chest.DestroyChest((int)deways[aaa].X, (int)deways[aaa].Y);
                WorldGen.KillTile((int)deways[aaa].X, (int)deways[aaa].Y);
                tile.active(false);
            }


            //Place Sword
            for (int kk = 3; kk < 6; kk += 1)
            {
                Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - kk].active(false);
                for (int xx = 0; xx < 6; xx += 1)
                {
                    Main.tile[(int)placementspot.X - xx, (int)placementspot.Y + buffersizey - kk].active(false);
                    Main.tile[(int)placementspot.X + xx, (int)placementspot.Y + buffersizey - kk].active(false);
                }
            }
            Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - 1].active(true);
            WorldGen.SlopeTile((int)placementspot.X, (int)placementspot.Y + buffersizey - 1, 0);

            for (int xx = 0; xx < 4; xx += 1)
            {
                Main.tile[(int)placementspot.X - xx, (int)placementspot.Y + buffersizey - 1].active(true);
                Main.tile[(int)placementspot.X + xx, (int)placementspot.Y + buffersizey - 1].active(true);
                WorldGen.SlopeTile((int)placementspot.X - xx, (int)placementspot.Y + buffersizey - 1, 0);
                WorldGen.SlopeTile((int)placementspot.X + xx, (int)placementspot.Y + buffersizey - 1, 0);
            }

            Main.tile[(int)placementspot.X - 2, (int)placementspot.Y + buffersizey - 2].active(true); WorldGen.SlopeTile((int)placementspot.X - 2, (int)placementspot.Y + buffersizey - 2, 0);
            Main.tile[(int)placementspot.X - 1, (int)placementspot.Y + buffersizey - 2].active(true); WorldGen.SlopeTile((int)placementspot.X - 1, (int)placementspot.Y + buffersizey - 2, 0);
            Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - 2].active(true); WorldGen.SlopeTile((int)placementspot.X, (int)placementspot.Y + buffersizey - 2, 0);
            Main.tile[(int)placementspot.X + 1, (int)placementspot.Y + buffersizey - 2].active(true); WorldGen.SlopeTile((int)placementspot.X + 1, (int)placementspot.Y + buffersizey - 2, 0);
            Main.tile[(int)placementspot.X + 2, (int)placementspot.Y + buffersizey - 2].active(true); WorldGen.SlopeTile((int)placementspot.X + 2, (int)placementspot.Y + buffersizey - 2, 0);

            Point offset    = new Point(0, -3);
            int   altertype = type == 0 ? SGAmod.Instance.TileType("CaliburnAltar") : (type == 1 ? SGAmod.Instance.TileType("CaliburnAltarB") : SGAmod.Instance.TileType("CaliburnAltarC"));

            WorldGen.PlaceObject((int)placementspot.X + offset.X, (int)placementspot.Y + buffersizey + offset.Y, altertype, false, 0);
            SGAWorld.CaliburnAlterCoordsX[type] = (int)placementspot.X * 16;
            SGAWorld.CaliburnAlterCoordsY[type] = (int)placementspot.Y * 16;
        }
Esempio n. 7
0
        private void BossBox()
        {
            HashSet <Point16> BossBox = new HashSet <Point16>();

            MazeRoom EndPoint      = MazeGraphPoints[0];
            MazeRoom BossRoomPoint = new MazeRoom(new Point16(BossRoom.Center.X, BossRoom.Center.Y), 0, new Point16(0, 0), 0, true);

            EndPoint.previousRoom = BossRoomPoint;
            MazeGraphPoints.Insert(0, BossRoomPoint);

            for (int xx = BossRoom.X; xx < BossRoom.Width + BossRoom.X; xx += 1)
            {
                for (int yy = BossRoom.Y; yy < BossRoom.Height + BossRoom.Y; yy += 1)
                {
                    Vector2 vectordist = (BossRoom.Center.ToVector2() - new Vector2(xx, yy));
                    if (BossRoomInside.Contains(xx, yy) || UniRand.NextFloat(vectordist.Length(), 100) < 100)
                    {
                        IDGWorldGen.PlaceMulti(new Point(xx, yy), TileID.RubyGemspark, UniRand.Next(2, 6), -1, true);
                        BossBox.Add(new Point16(xx, yy));
                    }
                }
            }
            InnerArenaTiles = new HashSet <Point16>(BossBox);
            foreach (Point16 point in BossBox)
            {
                Tile tileline = Main.tile[point.X, point.Y];
                tileline.color((byte)Paints.Shadow);
                //if (BossRoomInside.Contains(point.X, point.Y))
                //{
                tileline.active(false);
                tileline.wall = tileline.wall = (ushort)SGAmod.Instance.WallType("NullWallBossArena");
                //}
            }
            if (roomsize < 5)
            {
                roomsize = 5;
            }

            foreach (Point point in IDGWorldGen.GetLine(startingPoint.ToPoint(), BossRoom.Center))
            {
                for (int xx = -(roomsize + 2); xx <= roomsize + 2; xx += 1)
                {
                    for (int yy = -roomsize; yy < roomsize + 1; yy += 1)
                    {
                        if (InsideMap(point.X + xx, point.Y + yy))
                        {
                            Tile tileline = Main.tile[point.X + xx, point.Y + yy];
                            tileline.active(false);

                            if (BossRoom.Contains(point.X, point.Y))
                            {
                                if (tileline.wall != (ushort)SGAmod.Instance.WallType("NullWall") && tileline.wall != (ushort)SGAmod.Instance.WallType("NullWallBossArena"))
                                {
                                    tileline.wall = (ushort)SGAmod.Instance.WallType("NullWall");
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public void EvilSegmentRooms(List <MazeRoom> ListOfRooms, int type)
        {
            //Do Sub-Boss Room Gen

            float   bossArenaSize = 80;
            Vector2 CorruptionRoomAngleAverage = Vector2.Zero;

            foreach (MazeRoom room in ListOfRooms)
            {
                CorruptionRoomAngleAverage += ((room.loc - Middle).ToVector2());
            }
            CorruptionRoomAngleAverage /= ListOfRooms.Count;

            CorruptionRoomAngleAverage = (Vector2.Normalize(CorruptionRoomAngleAverage) * 500f) + Middle.ToVector2();

            List <MazeRoom> MiniBossRoomsBossArena = new List <MazeRoom>();

            while (MiniBossRoomsBossArena.Count < 10)
            {
                MiniBossRoomsBossArena = ListOfRooms.FindAll(testby => (testby.loc.ToVector2() - CorruptionRoomAngleAverage).Length() < bossArenaSize).ToList();
                bossArenaSize         += 4;
            }

            Vector2 AveragePoint = Vector2.Zero;

            List <Point> ArenaPoints = new List <Point>();
            int          minx = width, miny = height, maxx = 0, maxy = 0;

            //Do Room Carve out
            foreach (MazeRoom room in MiniBossRoomsBossArena)
            {
                AveragePoint += room.loc.ToVector2();
                //IDGWorldGen.PlaceMulti(room.loc.ToPoint(), TileID.Cloud, 8);
                //IDGWorldGen.PlaceMulti(room.loc.ToPoint(), -1, 6);
                minx = Math.Min(minx, room.loc.X); miny = Math.Min(miny, room.loc.Y);
                maxx = Math.Max(maxx, room.loc.X); maxy = Math.Max(maxy, room.loc.Y);
                ArenaPoints.Add(room.loc.ToPoint());
                for (int i = 0; i < 2; i += 1)
                {
                    foreach (MazeRoom room2 in MiniBossRoomsBossArena)
                    {
                        foreach (Point there in IDGWorldGen.GetLine(room.loc.ToPoint(), room2.loc.ToPoint()))
                        {
                            int sizer2 = 8;
                            int sizer  = sizer2 - i * 2;

                            for (int x = -sizer; x <= sizer; x += 1)
                            {
                                for (int y = -sizer; y <= sizer; y += 1)
                                {
                                    Tile tile = Main.tile[there.X + x, there.Y + y];
                                    if (i < 1)
                                    {
                                        if (tile.active())
                                        {
                                            tile.type = type == 0 ? TileID.AmethystGemspark : TileID.AmberGemspark;
                                        }
                                    }
                                    else
                                    {
                                        tile.active(false);
                                        if (tile.wall == 0)
                                        {
                                            tile.wall = type == 0 ? WallID.AmethystGemsparkOff : WallID.AmberGemsparkOff;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            AveragePoint /= MiniBossRoomsBossArena.Count;
            List <MazeRoom> ListofOrderedRooms = ListOfRooms.OrderBy(testby => UniRand.Next(ListOfRooms.Count)).ToList();

            ListofOrderedRooms.Insert(0, new MazeRoom(AveragePoint.ToPoint16(), 0, new Point16(0, 0), 0, true));

            //place orbs/hearts
            int index = 0;
            int heart = type == 0 ? 0 : 1;

            foreach (MazeRoom lootroom in ListofOrderedRooms)
            {
                if (index < 3)
                {
                    IDGWorldGen.PlaceMulti(lootroom.loc.ToPoint(), type == 0 ? TileID.AmethystGemspark : TileID.AmberGemspark, 5, type == 0 ? WallID.AmethystGemspark : WallID.AmberGemspark);
                    IDGWorldGen.PlaceMulti(lootroom.loc.ToPoint(), -1, 3, type == 0 ? WallID.AmethystGemspark : WallID.AmberGemspark);
                    for (int num36 = 0; num36 < 2; num36++)
                    {
                        for (int num37 = 0; num37 < 2; num37++)
                        {
                            int num38 = lootroom.loc.X + num36;
                            int num39 = lootroom.loc.Y + num37;
                            Main.tile[num38, num39].active(active: true);
                            Main.tile[num38, num39].slope(0);
                            Main.tile[num38, num39].halfBrick(halfBrick: false);
                            Main.tile[num38, num39].type   = 31;
                            Main.tile[num38, num39].frameX = (short)(num36 * 18 + 36 * heart);
                            Main.tile[num38, num39].frameY = (short)(num37 * 18 + 36 * 0);
                        }
                    }
                }

                index += 1;
            }
        }
Esempio n. 9
0
        private void MazeGenerator(Point16 starting, int roomIndex, int maxsize, GenerationProgress prog)
        {
            Stack <MazeRoom> mazeStack = new Stack <MazeRoom>();

            maxGen = 0;
            int index = 0;

            currentPosition = starting;
            MazeRoom mazz = new MazeRoom(currentPosition, gen, Flow(currentPosition, flowSize), roomIndex);

            mazeStack.Push(mazz);
            if (roomIndex == 0)
            {
                startingPoint = mazz.loc + mazz.Offset;
                IDGWorldGen.PlaceMulti(startingPoint.ToPoint(), TileID.Adamantite, roomsize * 3);
            }

ResetMove:
            //And now, we gen a maze with depth first!
            //Ah Adamantite, my good friend! Please help me keep track of where we've been!

            while (mazeStack.Count > 0 && index < maxsize)
            {
                MazeRoom whereWeAre = mazeStack.Peek();
                //gen = whereWeAre.gen;
                maxGen = Math.Max(maxGen, gen);

                Point16 newpoint = currentPosition;

                prog.Value   = MathHelper.Clamp(mazeStack.Count / 100f, 0f, 1f);
                prog.Message = whereWeAre.loc.X + ":" + whereWeAre.loc.Y + " Gen " + gen;


                int offset = UniRand.Next(4);

                for (int i = 0; i < 4; i += 1)
                {
                    //Check Card Directions

                    //Point16 cardOffset = (DarkSector.Cardinals[(offset + i) % DarkSector.Cardinals.Length]) * new Point16(sizeCheck, sizeCheck);
                    Point16 cardOffset = (Vector2.UnitX * sizeCheck).RotatedBy(UniRand.NextFloat(MathHelper.TwoPi)).ToPoint16();
                    //(pointhere * sizeCheck).ToPoint16();//(DarkSector.Cardinals[(offset + i) % DarkSector.Cardinals.Length])*sizeCheck;
                    Point16 checkHere = currentPosition + (cardOffset);

                    if (checkHere.X < sizeCheck || checkHere.X > width - sizeCheck || checkHere.Y < sizeCheck || checkHere.Y > height - sizeCheck)
                    {
                        continue;
                    }

                    if (Avoid(checkHere))
                    {
                        continue;
                    }

                    //Found one, moving

                    // Main.tile[checkHere.X, checkHere.Y].type = TileID.Adamantite;
                    //Main.tile[checkHere.X, checkHere.Y].active(true);

                    //Place down some stuff to mark this area so we don't move back here
                    IDGWorldGen.PlaceMulti(checkHere.ToPoint(), TileID.Adamantite, roomsize * 3);

                    //Draw line and connect the dots
                    Point check1 = (currentPosition + Flow(currentPosition, flowSize)).ToPoint();
                    Point check2 = (checkHere + Flow(checkHere, flowSize)).ToPoint();

                    foreach (Point there in IDGWorldGen.GetLine(check1, check2))
                    {
                        Point16 there2 = new Point16(there.X, there.Y);
                        if (InsideMap(there2.X, there2.Y))
                        {
                            Tile tileline = Main.tile[there2.X, there2.Y];
                            //tileline.color((byte)FakeOverworld.Paints.Negative);
                            mazePainter.Add(new MazeRoom(there2, gen, new Point16(0, 0), roomIndex));
                        }
                    }

                    index += 1;
                    gen   += 1;
                    MazeRoom mazepoint = new MazeRoom(checkHere, gen, Flow(currentPosition, flowSize), roomIndex);
                    mazepoint.ConnectedRoom = whereWeAre;

                    if (LastRoom == null || gen > LastRoom.gen)
                    {
                        LastRoom = mazepoint;
                    }

                    mazeStack.Push(mazepoint);
                    mazeRooms.Add(whereWeAre);

                    currentPosition = checkHere;

                    goto ResetMove;
                }

                //Dead end, time to step back

                MazeRoom stepBack = mazeStack.Pop();
                MazeRoom previous = stepBack;
                if (mazeStack.Count > 1)
                {
                    previous         = mazeStack.Peek();
                    previous.deadEnd = false;
                }

                if (!mazeRooms.Any(tester => tester.loc == currentPosition))
                {
                    mazeRooms.Add(new MazeRoom(currentPosition, gen, Flow(currentPosition, flowSize), roomIndex, true));
                }

                gen            -= 1;
                currentPosition = previous.loc;
            }

            mazePainter.OrderBy(orderby => orderby.gen);
            mazeRooms.OrderBy(orderby => orderby.gen);

            /*MazeRoom spawnRoom = mazeRooms[mazeRooms.Count - 1];
             * Main.spawnTileX = spawnRoom.loc.X + spawnRoom.Offset.X;
             * Main.spawnTileY = spawnRoom.loc.Y + spawnRoom.Offset.Y;*/
        }
Esempio n. 10
0
        public virtual void AGenPass(GenerationProgress prog)
        {
            UniRand = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);
            int lastseed = WorldGen._genRandSeed;

            WorldGen._genRandSeed = DimDungeonsProxy.DungeonSeeds;
            enemyseed             = (DimDungeonsProxy.DungeonSeeds);
            prog.Message          = "Loading";          //Sets the text above the worldgen progress bar
            Main.worldSurface     = Main.maxTilesY - 2; //Hides the underground layer just out of bounds
            Main.rockLayer        = Main.maxTilesY;     //Hides the cavern layer way out of bounds
            //Main.spawnTileX = (Main.maxTilesX / 2) / 16;
            prog.Message = "Once was nothing...";

Restart:

            //Rectangle BoxedArea = new Rectangle(bufferSize, bufferSize + surfaceDeep, width - bufferSize * 2, (height - surfaceDeep) - (bufferSize * 2));

            //currentPosition = new Point16(width / 2 + (UniRand.Next(12) * sizeCheck) - sizeCheck * 6, height-200);
            currentPosition = new Point16(width / 2, height / 2);

            BossRoom       = new Rectangle(currentPosition.X - 160, currentPosition.Y - 100, 320, 200);
            BossRoomInside = new Rectangle(BossRoom.Center.X - 100, BossRoom.Center.Y - 60, 200, 120);

            currentPosition = new Point16(currentPosition.X + (UniRand.NextBool() ? 1 : -1) * ((BossRoom.Width / 2) + sizeCheck / 2), currentPosition.Y);


            int     xloc   = 200 + UniRand.Next(width - 400);
            Vector2 center = new Vector2(width, height) / 2f;

            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    prog.Message = ((x * y) + y) / (float)(width * height) * 100f + "%";
                    float dist = (new Vector2(x, y) - center).LengthSquared();
                    Main.tile[x, y].type = (BossRoom.Contains(x, y) || dist > (height * height) / 8f) ? TileID.Adamantite : TileID.CobaltBrick;
                    Main.tile[x, y].active(true);
                }
            }

            for (int i = 0; i < 70; i += 1)
            {
                int     randomx = UniRand.Next(Main.maxTilesX);
                int     randomy = UniRand.Next(surfaceDeep, Main.maxTilesY);
                Vector2 vex     = new Vector2(randomx, randomy);
                if ((currentPosition.ToVector2() - vex).LengthSquared() > bufferSize * bufferSize)
                {
                    IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(30, 100), UniRand.Next(15, 45) + i, TileID.Adamantite, false, 0f, 0f, true, true, UniRand);
                }
            }

            Noisegen            = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);
            Noisegen.Amplitude  = 1;
            Noisegen.Frequency *= 0.50;

            gen = 0;

            mazePainter = new List <MazeRoom>();// HashSet<MazeRoom>();
            mazeRooms   = new List <MazeRoom>();

            MazeGenerator(currentPosition, 0, 20000, prog);

            NoiseGenerator Noisegen2 = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);

            Noisegen2.Amplitude  = 1;
            Noisegen2.Frequency *= 0.050;

            int adder = 0;
            int noisy = 0;

            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    Tile tile = Main.tile[x, (height - 1) - y];
                    tile.type = TileID.CobaltBrick;
                    tile.active(false);

                    prog.Value = (((x + (y * x)) / (float)(width * height)) * 1f);
                    float dist = (new Vector2(x, y) - center).LengthSquared();
                    if (!(dist > (height * height) / 8f))
                    {
                        tile.type = (ushort)ModContent.TileType <HardenedFabric>();
                        tile.active(true);
                    }
                    int dister = (height * height) / 5;

                    if (adder == 0)
                    {
                        noisy = (int)(Noisegen2.Noise(x, y) * (1000 * 1000));
                    }

                    adder = (adder + 1) % noiseDetail;

                    if ((tile.wall == WallID.DirtUnsafe || tile.wall == WallID.DirtUnsafe1 || tile.wall == WallID.DirtUnsafe2 || tile.wall == WallID.DirtUnsafe3 || tile.wall == WallID.DirtUnsafe4) || (dist > noisy + (dister + (y * y) / 4f)))
                    {
                        tile.type = (ushort)ModContent.TileType <HardenedFabric>();
                        tile.wall = 0;
                        tile.active(true);
                    }
                }
            }


            MazePainter();

            RoomFiller();

            PokeExits(5);

            BossBox();

            Main.spawnTileX = width / 2;
            Main.spawnTileY = 100;

            //Celular Crap

            /*for(int passes = 0; passes < 5; passes += 1) {
             *  for (int x = 0; x < Main.maxTilesX; x += 1)
             *  {
             *      for (int y = 0; y < Main.maxTilesY; y += 1)
             *      {
             *          if (GetTilesAround(x,y,1)>4)
             *          Main.tile[x, y].active(true);
             *          else
             *          Main.tile[x, y].active(false);
             *      }
             *  }
             * }*/
        }
        public static void PlaceCaiburnShrine(Vector2 placementspot, int type)
        {
            Tile tstart = Framing.GetTileSafely(placementspot);

            List <Vector2> deways         = new List <Vector2>();
            List <Vector2> dewaysMainroom = new List <Vector2>();

            int buffersizex = 12 + WorldGen.genRand.Next(7);
            int buffersizey = 8 + WorldGen.genRand.Next(3);
            int x           = (int)placementspot.X;
            int y           = (int)placementspot.Y;
            int xbuffer     = -buffersizex;
            int ybuffer     = -buffersizey;

            //ushort[] stoneTypes = new ushort[] { TileID.Stone, TileID.Dirt, TileID.Mud, TileID.ClayBlock };
            for (xbuffer = -buffersizex; xbuffer < buffersizex; xbuffer++)
            {
                for (ybuffer = -buffersizey; ybuffer < buffersizey; ybuffer++)
                {
                    Tile tile = Framing.GetTileSafely((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer);
                    IDGWorldGen.PlaceMulti(placementspot + new Vector2(xbuffer, ybuffer), SGAmod.Instance.TileType("MoistStone"), 4, SGAmod.Instance.WallType("SwampWall"));
                    dewaysMainroom.Add(new Vector2((int)placementspot.X + (int)xbuffer, (int)placementspot.Y + (int)ybuffer));
                }
            }

            int t1 = SGAmod.Instance.TileType("MoistStone");
            int t2 = SGAmod.Instance.WallType("SwampWall");

            PlaceCaiburnHallway(placementspot + new Vector2(buffersizex * 1, 0), 12, 6, 0, ref deways, 0, t1, t2);
            PlaceCaiburnHallway(placementspot + new Vector2(-buffersizex * 1, 0), 12, 6, 2, ref deways, 0, t1, t2);

            for (int aaa = 0; aaa < deways.Count; aaa++)
            {
                Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y);
                tile.active(false);
            }

            for (int aaa = 0; aaa < deways.Count; aaa++)
            {
                if (WorldGen.genRand.Next(0, 100) < 5)
                {
                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y - 1);
                    if (tile.active())
                    {
                        WorldGen.PlaceObject((int)deways[aaa].X, (int)deways[aaa].Y, TileID.HangingLanterns, false, 16);
                    }
                }
                if (WorldGen.genRand.Next(0, 100) < 5)
                {
                    Tile tile = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y + 1);
                    if (tile.active())
                    {
                        WorldGen.placeTrap((int)deways[aaa].X, (int)deways[aaa].Y, 0);
                    }
                }
                if (WorldGen.genRand.Next(0, 100) < 2)
                {
                    Tile tile1 = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y + 1);
                    Tile tile2 = Framing.GetTileSafely((int)deways[aaa].X + 1, (int)deways[aaa].Y + 1);
                    Tile tile3 = Framing.GetTileSafely((int)deways[aaa].X + 1, (int)deways[aaa].Y);
                    Tile tile4 = Framing.GetTileSafely((int)deways[aaa].X, (int)deways[aaa].Y);

                    if (tile1.active() && tile2.active() && !tile3.active() && !tile4.active())
                    {
                        int thechest = WorldGen.PlaceChest((int)deways[aaa].X, (int)deways[aaa].Y, 21, false, 12);

                        if (thechest > 0)
                        {
                            List <int> loot = new List <int> {
                                2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2359, 301, 302, 303, 304, 305, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 226, 188, 189, 110, 28
                            };

                            List <int> lootmain = new List <int> {
                                SGAmod.Instance.ItemType("UnmanedOre"), SGAmod.Instance.ItemType("DankWood"), SGAmod.Instance.ItemType("DankWood"), SGAmod.Instance.ItemType("Biomass"), SGAmod.Instance.ItemType("DankWood"), ItemID.SilverCoin, ItemID.LesserManaPotion
                            };
                            List <int> lootrare = new List <int> {
                                SGAmod.Instance.ItemType("DankCore"), SGAmod.Instance.ItemType("DankCore")
                            };
                            int e = 0;

                            for (int kk = 0; kk < 2 + (Main.expertMode ? 1 : 0); kk += 1)
                            {
                                //for (int i = 0; i < WorldGen.genRand.Next(15, Main.expertMode ? 25 : 30); i += 1)
                                //{
                                int index = WorldGen.genRand.Next(0, loot.Count);
                                Main.chest[thechest].item[e].SetDefaults(loot[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(1, Main.expertMode ? 3 : 2);
                                //}
                                e += 1;
                            }
                            if (WorldGen.genRand.Next(0, 100) < 20)
                            {
                                int index = WorldGen.genRand.Next(0, lootrare.Count);
                                Main.chest[thechest].item[e].SetDefaults(lootrare[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(1, Main.expertMode ? 2 : 1);
                                //}
                                e += 1;
                            }
                            for (int kk = 0; kk < 3 + (Main.expertMode ? 1 : 0); kk += 1)
                            {
                                //for (int i = 0; i < WorldGen.genRand.Next(15, Main.expertMode ? 25 : 30); i += 1)
                                //{
                                int index = WorldGen.genRand.Next(0, lootmain.Count);
                                Main.chest[thechest].item[e].SetDefaults(lootmain[index]);
                                Main.chest[thechest].item[e].stack = WorldGen.genRand.Next(15, Main.expertMode ? 25 : 45);

                                //}
                                e += 1;
                            }
                        }

                        ///WorldGen.PlaceChestDirect((int)deways[aaa].X, (int)deways[aaa].Y, (ushort)SGAmod.Instance.TileType("OvergrownChest"), 0, 0);
                    }
                }
            }

            for (int aaa = 0; aaa < dewaysMainroom.Count; aaa++)
            {
                Tile tile = Framing.GetTileSafely((int)dewaysMainroom[aaa].X, (int)dewaysMainroom[aaa].Y);
                Chest.DestroyChest((int)deways[aaa].X, (int)deways[aaa].Y);
                WorldGen.KillTile((int)deways[aaa].X, (int)deways[aaa].Y);
                tile.active(false);
            }

            for (int kk = 3; kk < 6; kk += 1)
            {
                Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - kk].active(false);
                for (int xx = 0; xx < 6; xx += 1)
                {
                    Main.tile[(int)placementspot.X - xx, (int)placementspot.Y + buffersizey - kk].active(false);
                    Main.tile[(int)placementspot.X + xx, (int)placementspot.Y + buffersizey - kk].active(false);
                }
            }
            Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - 1].active(true);
            for (int xx = 0; xx < 4; xx += 1)
            {
                Main.tile[(int)placementspot.X - xx, (int)placementspot.Y + buffersizey - 1].active(true);
                Main.tile[(int)placementspot.X + xx, (int)placementspot.Y + buffersizey - 1].active(true);
            }

            WorldGen.PlaceTile((int)placementspot.X - 2, (int)placementspot.Y + buffersizey - 2, SGAmod.Instance.TileType("MoistStone"), style: 10);
            Main.tile[(int)placementspot.X - 1, (int)placementspot.Y + buffersizey - 2].active(true);
            Main.tile[(int)placementspot.X, (int)placementspot.Y + buffersizey - 2].active(true);
            Main.tile[(int)placementspot.X + 1, (int)placementspot.Y + buffersizey - 2].active(true);
            Main.tile[(int)placementspot.X - 2, (int)placementspot.Y + buffersizey - 2].active(true);
            WorldGen.PlaceTile((int)placementspot.X + 2, (int)placementspot.Y + buffersizey - 2, SGAmod.Instance.TileType("MoistStone"), style: 41);

            WorldGen.PlaceObject((int)placementspot.X, (int)placementspot.Y + buffersizey - 3, type == 0 ? SGAmod.Instance.TileType("CaliburnAltar")
                : (type == 1 ? SGAmod.Instance.TileType("CaliburnAltarB") : SGAmod.Instance.TileType("CaliburnAltarC")), false, 0);
            SGAWorld.CaliburnAlterCoordsX[type] = (int)placementspot.X * 16;
            SGAWorld.CaliburnAlterCoordsY[type] = (int)placementspot.Y * 16;
        }