Ejemplo n.º 1
0
 public static CaveHouseBiome.BuildData CreateMushroomData()
 {
     CaveHouseBiome.BuildData buildData = new CaveHouseBiome.BuildData();
     buildData.Tile           = (ushort)190;
     buildData.Wall           = (byte)74;
     buildData.PlatformStyle  = 18;
     buildData.DoorStyle      = 6;
     buildData.TableStyle     = 27;
     buildData.WorkbenchStyle = 7;
     buildData.PianoStyle     = 22;
     buildData.BookcaseStyle  = 24;
     buildData.ChairStyle     = 9;
     buildData.ChestStyle     = 32;
     CaveHouseBiome.BuildData.ProcessRoomMethod processRoomMethod = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMushroomRoom);
     buildData.ProcessRoom = processRoomMethod;
     return(buildData);
 }
Ejemplo n.º 2
0
 public static CaveHouseBiome.BuildData CreateDefaultData()
 {
     CaveHouseBiome.BuildData buildData = new CaveHouseBiome.BuildData();
     buildData.Tile           = (ushort)30;
     buildData.Wall           = (byte)27;
     buildData.PlatformStyle  = 0;
     buildData.DoorStyle      = 0;
     buildData.TableStyle     = 0;
     buildData.WorkbenchStyle = 0;
     buildData.PianoStyle     = 0;
     buildData.BookcaseStyle  = 0;
     buildData.ChairStyle     = 0;
     buildData.ChestStyle     = 1;
     CaveHouseBiome.BuildData.ProcessRoomMethod processRoomMethod = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeDefaultRoom);
     buildData.ProcessRoom = processRoomMethod;
     return(buildData);
 }
Ejemplo n.º 3
0
 public static CaveHouseBiome.BuildData CreateMarbleData()
 {
     CaveHouseBiome.BuildData buildData = new CaveHouseBiome.BuildData();
     buildData.Tile           = (ushort)357;
     buildData.Wall           = (byte)179;
     buildData.PlatformStyle  = 29;
     buildData.DoorStyle      = 35;
     buildData.TableStyle     = 34;
     buildData.WorkbenchStyle = 30;
     buildData.PianoStyle     = 29;
     buildData.BookcaseStyle  = 31;
     buildData.ChairStyle     = 35;
     buildData.ChestStyle     = 51;
     CaveHouseBiome.BuildData.ProcessRoomMethod processRoomMethod = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMarbleRoom);
     buildData.ProcessRoom = processRoomMethod;
     return(buildData);
 }
Ejemplo n.º 4
0
 public static CaveHouseBiome.BuildData CreateJungleData()
 {
     CaveHouseBiome.BuildData buildData = new CaveHouseBiome.BuildData();
     buildData.Tile           = (ushort)158;
     buildData.Wall           = (byte)42;
     buildData.PlatformStyle  = 2;
     buildData.DoorStyle      = 2;
     buildData.TableStyle     = 2;
     buildData.WorkbenchStyle = 2;
     buildData.PianoStyle     = 2;
     buildData.BookcaseStyle  = 12;
     buildData.ChairStyle     = 3;
     buildData.ChestStyle     = 8;
     CaveHouseBiome.BuildData.ProcessRoomMethod processRoomMethod = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeJungleRoom);
     buildData.ProcessRoom = processRoomMethod;
     return(buildData);
 }
Ejemplo n.º 5
0
 public static CaveHouseBiome.BuildData CreateSnowData()
 {
     CaveHouseBiome.BuildData buildData = new CaveHouseBiome.BuildData();
     buildData.Tile           = (ushort)321;
     buildData.Wall           = (byte)149;
     buildData.DoorStyle      = 30;
     buildData.PlatformStyle  = 19;
     buildData.TableStyle     = 28;
     buildData.WorkbenchStyle = 23;
     buildData.PianoStyle     = 23;
     buildData.BookcaseStyle  = 25;
     buildData.ChairStyle     = 30;
     buildData.ChestStyle     = 11;
     CaveHouseBiome.BuildData.ProcessRoomMethod processRoomMethod = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeSnowRoom);
     buildData.ProcessRoom = processRoomMethod;
     return(buildData);
 }
Ejemplo n.º 6
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin)
            {
                return(false);
            }
            Microsoft.Xna.Framework.Rectangle room1 = this.GetRoom(result1);
            Microsoft.Xna.Framework.Rectangle room2 = this.GetRoom(new Point(room1.Center.X, room1.Y + 1));
            Microsoft.Xna.Framework.Rectangle room3 = this.GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
            room3.Y = room1.Y + room1.Height - 1;
            float num1 = this.RoomSolidPrecentage(room2);
            float num2 = this.RoomSolidPrecentage(room3);

            room1.Y += 3;
            room2.Y += 3;
            room3.Y += 3;
            List <Microsoft.Xna.Framework.Rectangle> rectangleList1 = new List <Microsoft.Xna.Framework.Rectangle>();

            if ((double)GenBase._random.NextFloat() > (double)num1 + 0.200000002980232)
            {
                rectangleList1.Add(room2);
            }
            else
            {
                room2 = room1;
            }
            rectangleList1.Add(room1);
            if ((double)GenBase._random.NextFloat() > (double)num2 + 0.200000002980232)
            {
                rectangleList1.Add(room3);
            }
            else
            {
                room3 = room1;
            }
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
                {
                    return(false);
                }
            }
            Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), (GenShape) new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12]
                {
                    (ushort)0,
                    (ushort)59,
                    (ushort)147,
                    (ushort)1,
                    (ushort)161,
                    (ushort)53,
                    (ushort)396,
                    (ushort)397,
                    (ushort)368,
                    (ushort)367,
                    (ushort)60,
                    (ushort)70
                }).Output(resultsOutput));
            }
            List <Tuple <CaveHouseBiome.BuildData, int> > tupleList1 = new List <Tuple <CaveHouseBiome.BuildData, int> >();

            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, resultsOutput[(ushort)0] + resultsOutput[(ushort)1]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, resultsOutput[(ushort)59] + resultsOutput[(ushort)60] * 10));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, resultsOutput[(ushort)59] + resultsOutput[(ushort)70] * 10));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, resultsOutput[(ushort)147] + resultsOutput[(ushort)161]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, resultsOutput[(ushort)397] + resultsOutput[(ushort)396] + resultsOutput[(ushort)53]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, resultsOutput[(ushort)368]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, resultsOutput[(ushort)367]));
            Comparison <Tuple <CaveHouseBiome.BuildData, int> > comparison = new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults);

            tupleList1.Sort(comparison);
            int index1 = 0;

            CaveHouseBiome.BuildData buildData = tupleList1[index1].Item1;
            foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
            {
                if (buildData != CaveHouseBiome.BuildData.Granite)
                {
                    Point result2;
                    if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out result2))
                    {
                        return(false);
                    }
                }
                if (!structures.CanPlace(area, CaveHouseBiome._blacklistedTiles, 5))
                {
                    return(false);
                }
            }
            int val1_1 = room1.X;
            int val1_2 = room1.X + room1.Width - 1;
            List <Microsoft.Xna.Framework.Rectangle> rectangleList2 = new List <Microsoft.Xna.Framework.Rectangle>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                val1_1 = Math.Min(val1_1, rectangle.X);
                val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
            }
            int num3 = 6;

            while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
            {
                --num3;
            }
            int x1 = val1_1;

            while (x1 <= val1_2)
            {
                for (int index2 = 0; index2 < rectangleList1.Count; ++index2)
                {
                    Microsoft.Xna.Framework.Rectangle rectangle = rectangleList1[index2];
                    if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width)
                    {
                        int y    = rectangle.Y + rectangle.Height;
                        int num4 = 50;
                        for (int index3 = index2 + 1; index3 < rectangleList1.Count; ++index3)
                        {
                            if (x1 >= rectangleList1[index3].X && x1 < rectangleList1[index3].X + rectangleList1[index3].Width)
                            {
                                num4 = Math.Min(num4, rectangleList1[index3].Y - y);
                            }
                        }
                        if (num4 > 0)
                        {
                            Point result2;
                            bool  flag = WorldUtils.Find(new Point(x1, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2);
                            if (num4 < 50)
                            {
                                flag    = true;
                                result2 = new Point(x1, y + num4);
                            }
                            if (flag)
                            {
                                rectangleList2.Add(new Microsoft.Xna.Framework.Rectangle(x1, y, 1, result2.Y - y));
                            }
                        }
                    }
                }
                x1 += num3;
            }
            List <Point> pointList1 = new List <Point>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int exitY;
                if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
                }
                if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X, exitY));
                }
            }
            List <Tuple <Point, Point> > tupleList2 = new List <Tuple <Point, Point> >();

            for (int index2 = 1; index2 < rectangleList1.Count; ++index2)
            {
                Microsoft.Xna.Framework.Rectangle rectangle1 = rectangleList1[index2];
                Microsoft.Xna.Framework.Rectangle rectangle2 = rectangleList1[index2 - 1];
                if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1)));
                }
                else
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
                }
            }
            List <Point> pointList2 = new List <Point>();
            int          exitX;

            if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX))
            {
                pointList2.Add(new Point(exitX, room2.Y));
            }
            if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX))
            {
                pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
            }
            foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
            {
                WorldUtils.Gen(new Point(area.X, area.Y), (GenShape) new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), (GenShape) new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall, true)));
                structures.AddStructure(area, 8);
            }
            foreach (Tuple <Point, Point> tuple in tupleList2)
            {
                Point     origin1 = tuple.Item1;
                Point     point   = tuple.Item2;
                int       num4    = point.X > origin1.X ? 1 : -1;
                ShapeData data    = new ShapeData();
                for (int y = 0; y < point.Y - origin1.Y; ++y)
                {
                    data.Add(num4 * (y + 1), y);
                }
                WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
            }
            foreach (Point origin1 in pointList1)
            {
                WorldUtils.Gen(origin1, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
                WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle);
            }
            foreach (Point origin1 in pointList2)
            {
                Shapes.Rectangle rectangle = new Shapes.Rectangle(3, 1);
                GenAction        action    = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true));
                WorldUtils.Gen(origin1, (GenShape)rectangle, action);
            }
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList2)
            {
                if (rectangle.Height > 1 && (int)GenBase._tiles[rectangle.X, rectangle.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), (GenShape) new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort)124, false, true), (GenAction) new Actions.SetFrames(true)));
                    Tile tile = GenBase._tiles[rectangle.X, rectangle.Y + rectangle.Height];
                    int  num4 = 0;
                    tile.slope((byte)num4);
                    int num5 = 0;
                    tile.halfBrick(num5 != 0);
                }
            }
            Point[] pointArray = new Point[7]
            {
                new Point(14, buildData.TableStyle),
                new Point(16, 0),
                new Point(18, buildData.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, buildData.PianoStyle),
                new Point(94, 0),
                new Point(101, buildData.BookcaseStyle)
            };
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int num4 = rectangle.Width / 8;
                int num5 = rectangle.Width / (num4 + 1);
                int num6 = GenBase._random.Next(2);
                for (int index2 = 0; index2 < num4; ++index2)
                {
                    int num7 = (index2 + 1) * num5 + rectangle.X;
                    switch (index2 + num6 % 2)
                    {
                    case 0:
                        int     num8    = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
                        Vector2 vector2 = WorldGen.randHousePicture();
                        int     x2      = (int)vector2.X;
                        int     y       = (int)vector2.Y;
                        if (!WorldGen.nearPicture(num7, num8))
                        {
                            WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y);
                            break;
                        }
                        break;

                    case 1:
                        int j = rectangle.Y + 1;
                        WorldGen.PlaceTile(num7, j, 34, true, false, -1, GenBase._random.Next(6));
                        for (int index3 = -1; index3 < 2; ++index3)
                        {
                            for (int index4 = 0; index4 < 3; ++index4)
                            {
                                GenBase._tiles[index3 + num7, index4 + j].frameX += (short)54;
                            }
                        }
                        break;
                    }
                }
                int num9 = rectangle.Width / 8 + 3;
                WorldGen.SetupStatueList();
                for (; num9 > 0; --num9)
                {
                    int num7 = GenBase._random.Next(rectangle.Width - 3) + 1 + rectangle.X;
                    int num8 = rectangle.Y + rectangle.Height - 2;
                    switch (GenBase._random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num7, num8, GenBase._random.Next(31, 34), 1, (ushort)185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num7, num8, 186, true, false, -1, GenBase._random.Next(22, 26));
                        break;

                    case 2:
                        int index2 = GenBase._random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num7, num8, (int)WorldGen.statueList[index2].X, true, false, -1, (int)WorldGen.statueList[index2].Y);
                        if (WorldGen.StatuesWithTraps.Contains(index2))
                        {
                            WorldGen.PlaceStatueTrap(num7, num8);
                            break;
                        }
                        break;

                    case 3:
                        Point point = Utils.SelectRandom <Point>(GenBase._random, pointArray);
                        WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y);
                        break;
                    }
                }
            }
            foreach (Microsoft.Xna.Framework.Rectangle room4 in rectangleList1)
            {
                buildData.ProcessRoom(room4);
            }
            bool flag1 = false;

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int j     = rectangle.Height - 1 + rectangle.Y;
                int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                int num4  = 0;
                while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style)))
                {
                    ++num4;
                }
                if (!flag1)
                {
                    int i = rectangle.X + 2;
                    while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                    {
                        ++i;
                    }
                    if (flag1)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            if (!flag1)
            {
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j     = rectangle.Y - 1;
                    int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    int num4  = 0;
                    while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style)))
                    {
                        ++num4;
                    }
                    if (!flag1)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                        {
                            ++i;
                        }
                        if (flag1)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (!flag1)
            {
                for (int index2 = 0; index2 < 1000; ++index2)
                {
                    int i       = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
                    int num4    = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
                    int num5    = num4 > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    int j       = num4;
                    int contain = 0;
                    int num6    = 0;
                    int Style   = num5;
                    if (WorldGen.AddBuriedChest(i, j, contain, num6 != 0, Style))
                    {
                        break;
                    }
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j = rectangle.Height - 2 + rectangle.Y;
                    for (int index2 = 0; index2 < 10; ++index2)
                    {
                        int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 377, true, true, -1, 0);
                        if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 377)
                        {
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    this._sharpenerCount = this._sharpenerCount + 1;
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j = rectangle.Height - 2 + rectangle.Y;
                    for (int index2 = 0; index2 < 10; ++index2)
                    {
                        int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 219, true, true, -1, 0);
                        if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 219)
                        {
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    this._extractinatorCount = this._extractinatorCount + 1;
                }
            }
            return(true);
        }
Ejemplo n.º 7
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point point;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point);

            if (!flag || point == origin)
            {
                return(false);
            }
            Rectangle room       = this.GetRoom(point);
            Rectangle rectangle  = this.GetRoom(new Point(room.Center.X, room.Y + 1));
            Rectangle rectangle2 = this.GetRoom(new Point(room.Center.X, room.Y + room.Height + 10));

            rectangle2.Y = room.Y + room.Height - 1;
            float num  = this.RoomSolidPrecentage(rectangle);
            float num2 = this.RoomSolidPrecentage(rectangle2);

            room.Y       += 3;
            rectangle.Y  += 3;
            rectangle2.Y += 3;
            List <Rectangle> list = new List <Rectangle>();

            if (GenBase._random.NextFloat() > num + 0.2f)
            {
                list.Add(rectangle);
            }
            else
            {
                rectangle = room;
            }
            list.Add(room);
            if (GenBase._random.NextFloat() > num2 + 0.2f)
            {
                list.Add(rectangle2);
            }
            else
            {
                rectangle2 = room;
            }
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            foreach (Rectangle current in list)
            {
                WorldUtils.Gen(new Point(current.X - 5, current.Y - 5), new Shapes.Rectangle(current.Width + 10, current.Height + 10), new Actions.TileScanner(new ushort[]
                {
                    0,
                    59,
                    147,
                    1,
                    161,
                    53,
                    396,
                    397,
                    368,
                    367,
                    60,
                    70
                }).Output(dictionary));
            }
            List <Tuple <CaveHouseBiome.BuildData, int> > list2 = new List <Tuple <CaveHouseBiome.BuildData, int> >();

            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, dictionary[0] + dictionary[1]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, dictionary[59] + dictionary[60] * 10));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, dictionary[59] + dictionary[70] * 10));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, dictionary[147] + dictionary[161]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, dictionary[397] + dictionary[396] + dictionary[53]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, dictionary[368]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, dictionary[367]));
            list2.Sort(new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults));
            CaveHouseBiome.BuildData item = list2[0].Item1;
            foreach (Rectangle current2 in list)
            {
                if (item != CaveHouseBiome.BuildData.Granite)
                {
                    Point point2;
                    bool  flag2 = WorldUtils.Find(new Point(current2.X - 2, current2.Y - 2), Searches.Chain(new Searches.Rectangle(current2.Width + 4, current2.Height + 4).RequireAll(false), new GenCondition[]
                    {
                        new Conditions.HasLava()
                    }), out point2);
                    if (flag2)
                    {
                        bool result = false;
                        return(result);
                    }
                }
                if (!structures.CanPlace(current2, CaveHouseBiome._blacklistedTiles, 5))
                {
                    bool result = false;
                    return(result);
                }
            }
            int num3 = room.X;
            int num4 = room.X + room.Width - 1;
            List <Rectangle> list3 = new List <Rectangle>();

            foreach (Rectangle current3 in list)
            {
                num3 = Math.Min(num3, current3.X);
                num4 = Math.Max(num4, current3.X + current3.Width - 1);
            }
            int num5 = 6;

            while (num5 > 4 && (num4 - num3) % num5 != 0)
            {
                num5--;
            }
            for (int i = num3; i <= num4; i += num5)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    Rectangle rectangle3 = list[j];
                    if (i >= rectangle3.X && i < rectangle3.X + rectangle3.Width)
                    {
                        int num6 = rectangle3.Y + rectangle3.Height;
                        int num7 = 50;
                        for (int k = j + 1; k < list.Count; k++)
                        {
                            if (i >= list[k].X && i < list[k].X + list[k].Width)
                            {
                                num7 = Math.Min(num7, list[k].Y - num6);
                            }
                        }
                        if (num7 > 0)
                        {
                            Point point3;
                            bool  flag3 = WorldUtils.Find(new Point(i, num6), Searches.Chain(new Searches.Down(num7), new GenCondition[]
                            {
                                new Conditions.IsSolid()
                            }), out point3);
                            if (num7 < 50)
                            {
                                flag3  = true;
                                point3 = new Point(i, num6 + num7);
                            }
                            if (flag3)
                            {
                                list3.Add(new Rectangle(i, num6, 1, point3.Y - num6));
                            }
                        }
                    }
                }
            }
            List <Point> list4 = new List <Point>();

            foreach (Rectangle current4 in list)
            {
                int  num8;
                bool flag4 = this.FindSideExit(new Rectangle(current4.X + current4.Width, current4.Y + 1, 1, current4.Height - 2), false, out num8);
                if (flag4)
                {
                    list4.Add(new Point(current4.X + current4.Width - 1, num8));
                }
                flag4 = this.FindSideExit(new Rectangle(current4.X, current4.Y + 1, 1, current4.Height - 2), true, out num8);
                if (flag4)
                {
                    list4.Add(new Point(current4.X, num8));
                }
            }
            List <Tuple <Point, Point> > list5 = new List <Tuple <Point, Point> >();

            for (int l = 1; l < list.Count; l++)
            {
                Rectangle rectangle4 = list[l];
                Rectangle rectangle5 = list[l - 1];
                int       num9       = rectangle5.X - rectangle4.X;
                int       num10      = rectangle4.X + rectangle4.Width - (rectangle5.X + rectangle5.Width);
                if (num9 > num10)
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X + rectangle4.Width - 1, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Width - rectangle4.Height + 1, rectangle4.Y + rectangle4.Height - 1)));
                }
                else
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Height - 1, rectangle4.Y + rectangle4.Height - 1)));
                }
            }
            List <Point> list6 = new List <Point>();
            int          num11;
            bool         flag5 = this.FindVerticalExit(new Rectangle(rectangle.X + 2, rectangle.Y, rectangle.Width - 4, 1), true, out num11);

            if (flag5)
            {
                list6.Add(new Point(num11, rectangle.Y));
            }
            flag5 = this.FindVerticalExit(new Rectangle(rectangle2.X + 2, rectangle2.Y + rectangle2.Height - 1, rectangle2.Width - 4, 1), false, out num11);
            if (flag5)
            {
                list6.Add(new Point(num11, rectangle2.Y + rectangle2.Height - 1));
            }
            foreach (Rectangle current5 in list)
            {
                WorldUtils.Gen(new Point(current5.X, current5.Y), new Shapes.Rectangle(current5.Width, current5.Height), Actions.Chain(new GenAction[]
                {
                    new Actions.SetTile(item.Tile, false, true),
                    new Actions.SetFrames(true)
                }));
                WorldUtils.Gen(new Point(current5.X + 1, current5.Y + 1), new Shapes.Rectangle(current5.Width - 2, current5.Height - 2), Actions.Chain(new GenAction[]
                {
                    new Actions.ClearTile(true),
                    new Actions.PlaceWall(item.Wall, true)
                }));
                structures.AddStructure(current5, 8);
            }
            foreach (Tuple <Point, Point> current6 in list5)
            {
                Point     item2     = current6.Item1;
                Point     item3     = current6.Item2;
                int       num12     = (item3.X > item2.X) ? 1 : -1;
                ShapeData shapeData = new ShapeData();
                for (int m = 0; m < item3.Y - item2.Y; m++)
                {
                    shapeData.Add(num12 * (m + 1), m);
                }
                WorldUtils.Gen(item2, new ModShapes.All(shapeData), Actions.Chain(new GenAction[]
                {
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetSlope((num12 == 1) ? 1 : 2),
                    new Actions.SetFrames(true)
                }));
                WorldUtils.Gen(new Point(item2.X + ((num12 == 1) ? 1 : -4), item2.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new GenAction[]
                {
                    new Actions.Clear(),
                    new Actions.PlaceWall(item.Wall, true),
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetFrames(true)
                }));
            }
            foreach (Point current7 in list4)
            {
                WorldUtils.Gen(current7, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true));
                WorldGen.PlaceTile(current7.X, current7.Y, 10, true, true, -1, item.DoorStyle);
            }
            foreach (Point current8 in list6)
            {
                WorldUtils.Gen(current8, new Shapes.Rectangle(3, 1), Actions.Chain(new GenAction[]
                {
                    new Actions.ClearMetadata(),
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetFrames(true)
                }));
            }
            foreach (Rectangle current9 in list3)
            {
                if (current9.Height > 1 && GenBase._tiles[current9.X, current9.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(current9.X, current9.Y), new Shapes.Rectangle(current9.Width, current9.Height), Actions.Chain(new GenAction[]
                    {
                        new Actions.SetTile(124, false, true),
                        new Actions.SetFrames(true)
                    }));
                    Tile tile = GenBase._tiles[current9.X, current9.Y + current9.Height];
                    tile.slope(0);
                    tile.halfBrick(false);
                }
            }
            Point[] choices = new Point[]
            {
                new Point(14, item.TableStyle),
                new Point(16, 0),
                new Point(18, item.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, item.PianoStyle),
                new Point(94, 0),
                new Point(101, item.BookcaseStyle)
            };
            foreach (Rectangle current10 in list)
            {
                int num13 = current10.Width / 8;
                int num14 = current10.Width / (num13 + 1);
                int num15 = GenBase._random.Next(2);
                for (int n = 0; n < num13; n++)
                {
                    int num16 = (n + 1) * num14 + current10.X;
                    switch (n + num15 % 2)
                    {
                    case 0:
                    {
                        int     num17  = current10.Y + Math.Min(current10.Height / 2, current10.Height - 5);
                        Vector2 vector = WorldGen.randHousePicture();
                        int     type   = (int)vector.X;
                        int     style  = (int)vector.Y;
                        if (!WorldGen.nearPicture(num16, num17))
                        {
                            WorldGen.PlaceTile(num16, num17, type, true, false, -1, style);
                        }
                        break;
                    }

                    case 1:
                    {
                        int num17 = current10.Y + 1;
                        WorldGen.PlaceTile(num16, num17, 34, true, false, -1, GenBase._random.Next(6));
                        for (int num18 = -1; num18 < 2; num18++)
                        {
                            for (int num19 = 0; num19 < 3; num19++)
                            {
                                Tile expr_E29 = GenBase._tiles[num18 + num16, num19 + num17];
                                expr_E29.frameX += 54;
                            }
                        }
                        break;
                    }
                    }
                }
                int num20 = current10.Width / 8 + 3;
                WorldGen.SetupStatueList();
                while (num20 > 0)
                {
                    int num21 = GenBase._random.Next(current10.Width - 3) + 1 + current10.X;
                    int num22 = current10.Y + current10.Height - 2;
                    switch (GenBase._random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num21, num22, GenBase._random.Next(31, 34), 1, 185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num21, num22, 186, true, false, -1, GenBase._random.Next(22, 26));
                        break;

                    case 2:
                    {
                        int num23 = GenBase._random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num21, num22, (int)WorldGen.statueList[num23].X, true, false, -1, (int)WorldGen.statueList[num23].Y);
                        if (WorldGen.StatuesWithTraps.Contains(num23))
                        {
                            WorldGen.PlaceStatueTrap(num21, num22);
                        }
                        break;
                    }

                    case 3:
                    {
                        Point point4 = Utils.SelectRandom <Point>(GenBase._random, choices);
                        WorldGen.PlaceTile(num21, num22, point4.X, true, false, -1, point4.Y);
                        break;
                    }
                    }
                    num20--;
                }
            }
            foreach (Rectangle current11 in list)
            {
                item.ProcessRoom(current11);
            }
            bool flag6 = false;

            foreach (Rectangle current12 in list)
            {
                int num24  = current12.Height - 1 + current12.Y;
                int style2 = (num24 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                for (int num25 = 0; num25 < 10; num25++)
                {
                    int i2 = GenBase._random.Next(2, current12.Width - 2) + current12.X;
                    if (flag6 = WorldGen.AddBuriedChest(i2, num24, 0, false, style2))
                    {
                        break;
                    }
                }
                if (flag6)
                {
                    break;
                }
                int num26 = current12.X + 2;
                while (num26 <= current12.X + current12.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num26, num24, 0, false, style2)))
                {
                    num26++;
                }
                if (flag6)
                {
                    break;
                }
            }
            if (!flag6)
            {
                foreach (Rectangle current13 in list)
                {
                    int num27  = current13.Y - 1;
                    int style3 = (num27 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                    for (int num28 = 0; num28 < 10; num28++)
                    {
                        int i3 = GenBase._random.Next(2, current13.Width - 2) + current13.X;
                        if (flag6 = WorldGen.AddBuriedChest(i3, num27, 0, false, style3))
                        {
                            break;
                        }
                    }
                    if (flag6)
                    {
                        break;
                    }
                    int num29 = current13.X + 2;
                    while (num29 <= current13.X + current13.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num29, num27, 0, false, style3)))
                    {
                        num29++;
                    }
                    if (flag6)
                    {
                        break;
                    }
                }
            }
            if (!flag6)
            {
                for (int num30 = 0; num30 < 1000; num30++)
                {
                    int i4     = GenBase._random.Next(list[0].X - 30, list[0].X + 30);
                    int num31  = GenBase._random.Next(list[0].Y - 30, list[0].Y + 30);
                    int style4 = (num31 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                    if (flag6 = WorldGen.AddBuriedChest(i4, num31, 0, false, style4))
                    {
                        break;
                    }
                }
            }
            if (item == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag7 = false;
                foreach (Rectangle current14 in list)
                {
                    int num32 = current14.Height - 2 + current14.Y;
                    for (int num33 = 0; num33 < 10; num33++)
                    {
                        int num34 = GenBase._random.Next(2, current14.Width - 2) + current14.X;
                        WorldGen.PlaceTile(num34, num32, 377, true, true, -1, 0);
                        if (flag7 = (GenBase._tiles[num34, num32].active() && GenBase._tiles[num34, num32].type == 377))
                        {
                            break;
                        }
                    }
                    if (flag7)
                    {
                        break;
                    }
                    int num35 = current14.X + 2;
                    while (num35 <= current14.X + current14.Width - 2 && !(flag7 = WorldGen.PlaceTile(num35, num32, 377, true, true, -1, 0)))
                    {
                        num35++;
                    }
                    if (flag7)
                    {
                        break;
                    }
                }
                if (flag7)
                {
                    this._sharpenerCount++;
                }
            }
            if (item == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag8 = false;
                foreach (Rectangle current15 in list)
                {
                    int num36 = current15.Height - 2 + current15.Y;
                    for (int num37 = 0; num37 < 10; num37++)
                    {
                        int num38 = GenBase._random.Next(2, current15.Width - 2) + current15.X;
                        WorldGen.PlaceTile(num38, num36, 219, true, true, -1, 0);
                        if (flag8 = (GenBase._tiles[num38, num36].active() && GenBase._tiles[num38, num36].type == 219))
                        {
                            break;
                        }
                    }
                    if (flag8)
                    {
                        break;
                    }
                    int num39 = current15.X + 2;
                    while (num39 <= current15.X + current15.Width - 2 && !(flag8 = WorldGen.PlaceTile(num39, num36, 219, true, true, -1, 0)))
                    {
                        num39++;
                    }
                    if (flag8)
                    {
                        break;
                    }
                }
                if (flag8)
                {
                    this._extractinatorCount++;
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || Point.op_Equality(result1, origin))
            {
                return(false);
            }
            Rectangle room1 = this.GetRoom(result1);
            // ISSUE: explicit reference operation
            Rectangle room2 = this.GetRoom(new Point((int)((Rectangle)@room1).get_Center().X, room1.Y + 1));
            // ISSUE: explicit reference operation
            Rectangle room3 = this.GetRoom(new Point((int)((Rectangle)@room1).get_Center().X, room1.Y + room1.Height + 10));

            room3.Y = (__Null)(room1.Y + room1.Height - 1);
            float num1 = this.RoomSolidPrecentage(room2);
            float num2 = this.RoomSolidPrecentage(room3);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rectangle& local1 = @room1;
            // ISSUE: explicit reference operation
            int num3 = (^ local1).Y + 3;

            // ISSUE: explicit reference operation
            (^ local1).Y = (__Null)num3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rectangle& local2 = @room2;
            // ISSUE: explicit reference operation
            int num4 = (^ local2).Y + 3;

            // ISSUE: explicit reference operation
            (^ local2).Y = (__Null)num4;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rectangle& local3 = @room3;
            // ISSUE: explicit reference operation
            int num5 = (^ local3).Y + 3;

            // ISSUE: explicit reference operation
            (^ local3).Y = (__Null)num5;
            List <Rectangle> rectangleList1 = new List <Rectangle>();

            if ((double)GenBase._random.NextFloat() > (double)num1 + 0.200000002980232)
            {
                rectangleList1.Add(room2);
            }
            else
            {
                room2 = room1;
            }
            rectangleList1.Add(room1);
            if ((double)GenBase._random.NextFloat() > (double)num2 + 0.200000002980232)
            {
                rectangleList1.Add(room3);
            }
            else
            {
                room3 = room1;
            }
            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    if (current.Y + current.Height > Main.maxTilesY - 220)
                    {
                        return(false);
                    }
                }
            }
            Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();

            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    WorldUtils.Gen(new Point(current.X - 10, current.Y - 10), (GenShape) new Shapes.Rectangle(current.Width + 20, current.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12]
                    {
                        (ushort)0,
                        (ushort)59,
                        (ushort)147,
                        (ushort)1,
                        (ushort)161,
                        (ushort)53,
                        (ushort)396,
                        (ushort)397,
                        (ushort)368,
                        (ushort)367,
                        (ushort)60,
                        (ushort)70
                    }).Output(resultsOutput));
                }
            }
            List <Tuple <CaveHouseBiome.BuildData, int> > tupleList1 = new List <Tuple <CaveHouseBiome.BuildData, int> >();

            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Default, (M1)(resultsOutput[(ushort)0] + resultsOutput[(ushort)1])));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Jungle, (M1)(resultsOutput[(ushort)59] + resultsOutput[(ushort)60] * 10)));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Mushroom, (M1)(resultsOutput[(ushort)59] + resultsOutput[(ushort)70] * 10)));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Snow, (M1)(resultsOutput[(ushort)147] + resultsOutput[(ushort)161])));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Desert, (M1)(resultsOutput[(ushort)397] + resultsOutput[(ushort)396] + resultsOutput[(ushort)53])));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Granite, (M1)resultsOutput[(ushort)368]));
            tupleList1.Add((Tuple <CaveHouseBiome.BuildData, int>)Tuple.Create <CaveHouseBiome.BuildData, int>((M0)CaveHouseBiome.BuildData.Marble, (M1)resultsOutput[(ushort)367]));
            tupleList1.Sort(new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults));
            CaveHouseBiome.BuildData buildData = tupleList1[0].get_Item1();
            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    if (buildData != CaveHouseBiome.BuildData.Granite)
                    {
                        Point result2;
                        if (WorldUtils.Find(new Point(current.X - 2, current.Y - 2), Searches.Chain(new Searches.Rectangle(current.Width + 4, current.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out result2))
                        {
                            return(false);
                        }
                    }
                    if (!structures.CanPlace(current, CaveHouseBiome._blacklistedTiles, 5))
                    {
                        return(false);
                    }
                }
            }
            int val1_1 = (int)room1.X;
            int val1_2 = room1.X + room1.Width - 1;
            List <Rectangle> rectangleList2 = new List <Rectangle>();

            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    val1_1 = Math.Min(val1_1, (int)current.X);
                    val1_2 = Math.Max(val1_2, current.X + current.Width - 1);
                }
            }
            int num6 = 6;

            while (num6 > 4 && (val1_2 - val1_1) % num6 != 0)
            {
                --num6;
            }
            int num7 = val1_1;

            while (num7 <= val1_2)
            {
                for (int index1 = 0; index1 < rectangleList1.Count; ++index1)
                {
                    Rectangle rectangle = rectangleList1[index1];
                    if (num7 >= rectangle.X && num7 < rectangle.X + rectangle.Width)
                    {
                        int num8 = (int)(rectangle.Y + rectangle.Height);
                        int num9 = 50;
                        for (int index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
                        {
                            if (num7 >= rectangleList1[index2].X && num7 < rectangleList1[index2].X + rectangleList1[index2].Width)
                            {
                                num9 = Math.Min(num9, rectangleList1[index2].Y - num8);
                            }
                        }
                        if (num9 > 0)
                        {
                            Point result2;
                            bool  flag = WorldUtils.Find(new Point(num7, num8), Searches.Chain((GenSearch) new Searches.Down(num9), (GenCondition) new Conditions.IsSolid()), out result2);
                            if (num9 < 50)
                            {
                                flag    = true;
                                result2 = new Point(num7, num8 + num9);
                            }
                            if (flag)
                            {
                                rectangleList2.Add(new Rectangle(num7, num8, 1, result2.Y - num8));
                            }
                        }
                    }
                }
                num7 += num6;
            }
            List <Point> pointList1 = new List <Point>();

            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    int       exitY;
                    if (this.FindSideExit(new Rectangle((int)(current.X + current.Width), current.Y + 1, 1, current.Height - 2), false, out exitY))
                    {
                        pointList1.Add(new Point(current.X + current.Width - 1, exitY));
                    }
                    if (this.FindSideExit(new Rectangle((int)current.X, current.Y + 1, 1, current.Height - 2), true, out exitY))
                    {
                        pointList1.Add(new Point((int)current.X, exitY));
                    }
                }
            }
            List <Tuple <Point, Point> > tupleList2 = new List <Tuple <Point, Point> >();

            for (int index = 1; index < rectangleList1.Count; ++index)
            {
                Rectangle rectangle1 = rectangleList1[index];
                Rectangle rectangle2 = rectangleList1[index - 1];
                if ((int)(rectangle2.X - rectangle1.X) > (int)(rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width)))
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1)));
                }
                else
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point((int)rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
                }
            }
            List <Point> pointList2 = new List <Point>();
            int          exitX;

            if (this.FindVerticalExit(new Rectangle(room2.X + 2, (int)room2.Y, room2.Width - 4, 1), true, out exitX))
            {
                pointList2.Add(new Point(exitX, (int)room2.Y));
            }
            if (this.FindVerticalExit(new Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX))
            {
                pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
            }
            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    WorldUtils.Gen(new Point((int)current.X, (int)current.Y), (GenShape) new Shapes.Rectangle((int)current.Width, (int)current.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true), (GenAction) new Actions.SetFrames(true)));
                    WorldUtils.Gen(new Point(current.X + 1, current.Y + 1), (GenShape) new Shapes.Rectangle(current.Width - 2, current.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall, true)));
                    structures.AddStructure(current, 8);
                }
            }
            using (List <Tuple <Point, Point> > .Enumerator enumerator = tupleList2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Tuple <Point, Point> current = enumerator.Current;
                    Point     origin1            = current.get_Item1();
                    Point     point = current.get_Item2();
                    int       num8  = point.X > origin1.X ? 1 : -1;
                    ShapeData data  = new ShapeData();
                    for (int y = 0; y < point.Y - origin1.Y; ++y)
                    {
                        data.Add(num8 * (y + 1), y);
                    }
                    WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num8 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
                    WorldUtils.Gen(new Point(origin1.X + (num8 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
                }
            }
            using (List <Point> .Enumerator enumerator = pointList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Point current = enumerator.Current;
                    WorldUtils.Gen(current, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
                    WorldGen.PlaceTile((int)current.X, (int)current.Y, 10, true, true, -1, buildData.DoorStyle);
                }
            }
            using (List <Point> .Enumerator enumerator = pointList2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    WorldUtils.Gen(enumerator.Current, (GenShape) new Shapes.Rectangle(3, 1), Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
                }
            }
            using (List <Rectangle> .Enumerator enumerator = rectangleList2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    if (current.Height > 1 && (int)GenBase._tiles[(int)current.X, current.Y - 1].type != 19)
                    {
                        WorldUtils.Gen(new Point((int)current.X, (int)current.Y), (GenShape) new Shapes.Rectangle((int)current.Width, (int)current.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort)124, false, true), (GenAction) new Actions.SetFrames(true)));
                        Tile tile = GenBase._tiles[(int)current.X, (int)(current.Y + current.Height)];
                        tile.slope((byte)0);
                        tile.halfBrick(false);
                    }
                }
            }
            Point[] pointArray = new Point[7]
            {
                new Point(14, buildData.TableStyle),
                new Point(16, 0),
                new Point(18, buildData.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, buildData.PianoStyle),
                new Point(94, 0),
                new Point(101, buildData.BookcaseStyle)
            };
            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    int       num8    = current.Width / 8;
                    int       num9    = current.Width / (num8 + 1);
                    int       num10   = GenBase._random.Next(2);
                    for (int index1 = 0; index1 < num8; ++index1)
                    {
                        int num11 = (index1 + 1) * num9 + current.X;
                        switch (index1 + num10 % 2)
                        {
                        case 0:
                            int     num12   = current.Y + Math.Min(current.Height / 2, current.Height - 5);
                            Vector2 vector2 = WorldGen.randHousePicture();
                            int     x       = (int)vector2.X;
                            int     y       = (int)vector2.Y;
                            if (!WorldGen.nearPicture(num11, num12))
                            {
                                WorldGen.PlaceTile(num11, num12, x, true, false, -1, y);
                                break;
                            }
                            break;

                        case 1:
                            int j = current.Y + 1;
                            WorldGen.PlaceTile(num11, j, 34, true, false, -1, GenBase._random.Next(6));
                            for (int index2 = -1; index2 < 2; ++index2)
                            {
                                for (int index3 = 0; index3 < 3; ++index3)
                                {
                                    GenBase._tiles[index2 + num11, index3 + j].frameX += (short)54;
                                }
                            }
                            break;
                        }
                    }
                    int num13 = current.Width / 8 + 3;
                    WorldGen.SetupStatueList();
                    for (; num13 > 0; --num13)
                    {
                        int num11 = GenBase._random.Next(current.Width - 3) + 1 + current.X;
                        int num12 = current.Y + current.Height - 2;
                        switch (GenBase._random.Next(4))
                        {
                        case 0:
                            WorldGen.PlaceSmallPile(num11, num12, GenBase._random.Next(31, 34), 1, (ushort)185);
                            break;

                        case 1:
                            WorldGen.PlaceTile(num11, num12, 186, true, false, -1, GenBase._random.Next(22, 26));
                            break;

                        case 2:
                            int index = GenBase._random.Next(2, WorldGen.statueList.Length);
                            WorldGen.PlaceTile(num11, num12, (int)WorldGen.statueList[index].X, true, false, -1, (int)WorldGen.statueList[index].Y);
                            if (WorldGen.StatuesWithTraps.Contains(index))
                            {
                                WorldGen.PlaceStatueTrap(num11, num12);
                                break;
                            }
                            break;

                        case 3:
                            Point point = Utils.SelectRandom <Point>(GenBase._random, pointArray);
                            WorldGen.PlaceTile(num11, num12, (int)point.X, true, false, -1, (int)point.Y);
                            break;
                        }
                    }
                }
            }
            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    buildData.ProcessRoom(current);
                }
            }
            bool flag1 = false;

            using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Rectangle current = enumerator.Current;
                    int       j       = current.Height - 1 + current.Y;
                    int       Style   = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    int       num8    = 0;
                    while (num8 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, current.Width - 2) + current.X, j, 0, false, Style)))
                    {
                        ++num8;
                    }
                    if (!flag1)
                    {
                        int i = current.X + 2;
                        while (i <= current.X + current.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                        {
                            ++i;
                        }
                        if (flag1)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (!flag1)
            {
                using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Rectangle current = enumerator.Current;
                        int       j       = current.Y - 1;
                        int       Style   = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                        int       num8    = 0;
                        while (num8 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, current.Width - 2) + current.X, j, 0, false, Style)))
                        {
                            ++num8;
                        }
                        if (!flag1)
                        {
                            int i = current.X + 2;
                            while (i <= current.X + current.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                            {
                                ++i;
                            }
                            if (flag1)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            if (!flag1)
            {
                for (int index = 0; index < 1000; ++index)
                {
                    int i     = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
                    int j     = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
                    int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    if (WorldGen.AddBuriedChest(i, j, 0, false, Style))
                    {
                        break;
                    }
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Rectangle current = enumerator.Current;
                        int       j       = current.Height - 2 + current.Y;
                        for (int index = 0; index < 10; ++index)
                        {
                            int i = GenBase._random.Next(2, current.Width - 2) + current.X;
                            WorldGen.PlaceTile(i, j, 377, true, true, -1, 0);
                            if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 377)
                            {
                                break;
                            }
                        }
                        if (!flag2)
                        {
                            int i = current.X + 2;
                            while (i <= current.X + current.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0)))
                            {
                                ++i;
                            }
                            if (flag2)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (flag2)
                {
                    ++this._sharpenerCount;
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                using (List <Rectangle> .Enumerator enumerator = rectangleList1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Rectangle current = enumerator.Current;
                        int       j       = current.Height - 2 + current.Y;
                        for (int index = 0; index < 10; ++index)
                        {
                            int i = GenBase._random.Next(2, current.Width - 2) + current.X;
                            WorldGen.PlaceTile(i, j, 219, true, true, -1, 0);
                            if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 219)
                            {
                                break;
                            }
                        }
                        if (!flag2)
                        {
                            int i = current.X + 2;
                            while (i <= current.X + current.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0)))
                            {
                                ++i;
                            }
                            if (flag2)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (flag2)
                {
                    ++this._extractinatorCount;
                }
            }
            return(true);
        }