private void PlaceStairs() { foreach (Tuple <Point, Point> stairs in this.CreateStairsList()) { Point origin = stairs.Item1; Point point = stairs.Item2; int num = point.X > origin.X ? 1 : -1; ShapeData data = new ShapeData(); for (int y = 0; y < point.Y - origin.Y; ++y) { data.Add(num * (y + 1), y); } WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort)19, this.PlatformStyle), (GenAction) new Actions.SetSlope(num == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(origin.X + (num == 1 ? 1 : -4), origin.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(this.WallType, true), (GenAction) new Actions.PlaceTile((ushort)19, this.PlatformStyle), (GenAction) new Actions.SetFrames(true))); } }
private void PlaceStairs() { foreach (Tuple <Point, Point> item3 in CreateStairsList()) { Point item = item3.Item1; Point item2 = item3.Item2; int num = (item2.X > item.X) ? 1 : (-1); ShapeData shapeData = new ShapeData(); for (int i = 0; i < item2.Y - item.Y; i++) { shapeData.Add(num * (i + 1), i); } WorldUtils.Gen(item, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceTile(19, PlatformStyle), new Actions.SetSlope((num == 1) ? 1 : 2), new Actions.SetFrames(frameNeighbors: true))); WorldUtils.Gen(new Point(item.X + ((num == 1) ? 1 : (-4)), item.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new Actions.Clear(), new Actions.PlaceWall(WallType), new Actions.PlaceTile(19, PlatformStyle), new Actions.SetFrames(frameNeighbors: true))); } }
public void CreateInterpolableLine(int order, Vector3 pointStartA, Vector3 pointEndA, Vector3 pointStartB, Vector3 pointEndB) { GameObject gameObject = GameObject.Instantiate(_linePrefab); LineRenderer line = gameObject.GetComponent <LineRenderer>(); line.SetPosition(0, pointStartA); line.SetPosition(1, pointStartB); gameObject.transform.SetParent(_root.transform); InterpolableLine interpolatedLine = new InterpolableLine(); interpolatedLine.PointStartA = pointStartA; interpolatedLine.PointEndA = pointEndA; interpolatedLine.PointStartB = pointStartB; interpolatedLine.PointEndB = pointEndB; interpolatedLine.Line = line; _interpolatedLines.Add(order, interpolatedLine); }
public void CreateInterpolableCircle(int order, Vector3 centerStart, Vector3 centerEnd, float sizeStart, float sizeEnd) { GameObject gameObject = GameObject.Instantiate(_circlePrefab); SpriteRenderer sprite = gameObject.GetComponent <SpriteRenderer>(); sprite.transform.position = centerStart; sprite.transform.localScale = Vector3.zero; gameObject.transform.SetParent(_root.transform); InterpolableCircle interpolatedCircle = new InterpolableCircle(); interpolatedCircle.Sprite = sprite; interpolatedCircle.CenterStart = centerStart; interpolatedCircle.CenterEnd = centerEnd; interpolatedCircle.SizeStart = sizeStart; interpolatedCircle.SizeEnd = sizeEnd; _interpolatedCircles.Add(order, interpolatedCircle); }
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); }
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); }
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); }
public override bool Place(Point origin, StructureMap structures) { if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), new Conditions.IsSolid()), out Point result) || result == origin) { return(false); } Rectangle room = GetRoom(result); Rectangle rectangle = GetRoom(new Point(room.Center.X, room.Y + 1)); Rectangle rectangle2 = GetRoom(new Point(room.Center.X, room.Y + room.Height + 10)); rectangle2.Y = room.Y + room.Height - 1; float num = RoomSolidPrecentage(rectangle); float num2 = 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 item4 in list) { WorldUtils.Gen(new Point(item4.X - 5, item4.Y - 5), new Shapes.Rectangle(item4.Width + 10, item4.Height + 10), new Actions.TileScanner(0, 59, 147, 1, 161, 53, 396, 397, 368, 367, 60, 70).Output(dictionary)); } List <Tuple <BuildData, int> > list2 = new List <Tuple <BuildData, int> >(); list2.Add(Tuple.Create(BuildData.Default, dictionary[0] + dictionary[1])); list2.Add(Tuple.Create(BuildData.Jungle, dictionary[59] + dictionary[60] * 10)); list2.Add(Tuple.Create(BuildData.Mushroom, dictionary[59] + dictionary[70] * 10)); list2.Add(Tuple.Create(BuildData.Snow, dictionary[147] + dictionary[161])); list2.Add(Tuple.Create(BuildData.Desert, dictionary[397] + dictionary[396] + dictionary[53])); list2.Add(Tuple.Create(BuildData.Granite, dictionary[368])); list2.Add(Tuple.Create(BuildData.Marble, dictionary[367])); list2.Sort(SortBiomeResults); BuildData item = list2[0].Item1; foreach (Rectangle item5 in list) { if (item != BuildData.Granite && WorldUtils.Find(new Point(item5.X - 2, item5.Y - 2), Searches.Chain(new Searches.Rectangle(item5.Width + 4, item5.Height + 4).RequireAll(mode: false), new Conditions.HasLava()), out Point _)) { return(false); } if (!structures.CanPlace(item5, _blacklistedTiles, 5)) { return(false); } } int num3 = room.X; int num4 = room.X + room.Width - 1; List <Rectangle> list3 = new List <Rectangle>(); foreach (Rectangle item6 in list) { num3 = Math.Min(num3, item6.X); num4 = Math.Max(num4, item6.X + item6.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) { continue; } 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 result3; bool flag = WorldUtils.Find(new Point(i, num6), Searches.Chain(new Searches.Down(num7), new Conditions.IsSolid()), out result3); if (num7 < 50) { flag = true; result3 = new Point(i, num6 + num7); } if (flag) { list3.Add(new Rectangle(i, num6, 1, result3.Y - num6)); } } } } List <Point> list4 = new List <Point>(); foreach (Rectangle item7 in list) { if (FindSideExit(new Rectangle(item7.X + item7.Width, item7.Y + 1, 1, item7.Height - 2), isLeft: false, out int exitY)) { list4.Add(new Point(item7.X + item7.Width - 1, exitY)); } if (FindSideExit(new Rectangle(item7.X, item7.Y + 1, 1, item7.Height - 2), isLeft: true, out exitY)) { list4.Add(new Point(item7.X, exitY)); } } 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 num8 = rectangle5.X - rectangle4.X; int num9 = rectangle4.X + rectangle4.Width - (rectangle5.X + rectangle5.Width); if (num8 > num9) { 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>(); if (FindVerticalExit(new Rectangle(rectangle.X + 2, rectangle.Y, rectangle.Width - 4, 1), isUp: true, out int exitX)) { list6.Add(new Point(exitX, rectangle.Y)); } if (FindVerticalExit(new Rectangle(rectangle2.X + 2, rectangle2.Y + rectangle2.Height - 1, rectangle2.Width - 4, 1), isUp: false, out exitX)) { list6.Add(new Point(exitX, rectangle2.Y + rectangle2.Height - 1)); } foreach (Rectangle item8 in list) { WorldUtils.Gen(new Point(item8.X, item8.Y), new Shapes.Rectangle(item8.Width, item8.Height), Actions.Chain(new Actions.SetTile(item.Tile), new Actions.SetFrames(frameNeighbors: true))); WorldUtils.Gen(new Point(item8.X + 1, item8.Y + 1), new Shapes.Rectangle(item8.Width - 2, item8.Height - 2), Actions.Chain(new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(item.Wall))); structures.AddStructure(item8, 8); } foreach (Tuple <Point, Point> item9 in list5) { Point item2 = item9.Item1; Point item3 = item9.Item2; int num10 = (item3.X > item2.X) ? 1 : (-1); ShapeData shapeData = new ShapeData(); for (int m = 0; m < item3.Y - item2.Y; m++) { shapeData.Add(num10 * (m + 1), m); } WorldUtils.Gen(item2, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetSlope((num10 == 1) ? 1 : 2), new Actions.SetFrames(frameNeighbors: true))); WorldUtils.Gen(new Point(item2.X + ((num10 == 1) ? 1 : (-4)), item2.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new Actions.Clear(), new Actions.PlaceWall(item.Wall), new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetFrames(frameNeighbors: true))); } foreach (Point item10 in list4) { WorldUtils.Gen(item10, new Shapes.Rectangle(1, 3), new Actions.ClearTile(frameNeighbors: true)); WorldGen.PlaceTile(item10.X, item10.Y, 10, mute: true, forced: true, -1, item.DoorStyle); } foreach (Point item11 in list6) { WorldUtils.Gen(item11, new Shapes.Rectangle(3, 1), Actions.Chain(new Actions.ClearMetadata(), new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetFrames(frameNeighbors: true))); } foreach (Rectangle item12 in list3) { if (item12.Height > 1 && GenBase._tiles[item12.X, item12.Y - 1].type != 19) { WorldUtils.Gen(new Point(item12.X, item12.Y), new Shapes.Rectangle(item12.Width, item12.Height), Actions.Chain(new Actions.SetTile(124), new Actions.SetFrames(frameNeighbors: true))); Tile tile = GenBase._tiles[item12.X, item12.Y + item12.Height]; tile.slope(0); tile.halfBrick(halfBrick: false); } } Point[] choices = new Point[7] { 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 item13 in list) { int num11 = item13.Width / 8; int num12 = item13.Width / (num11 + 1); int num13 = GenBase._random.Next(2); for (int n = 0; n < num11; n++) { int num14 = (n + 1) * num12 + item13.X; switch (n + num13 % 2) { case 0: { int num15 = item13.Y + Math.Min(item13.Height / 2, item13.Height - 5); Vector2 vector = WorldGen.randHousePicture(); int type = (int)vector.X; int style = (int)vector.Y; if (!WorldGen.nearPicture(num14, num15)) { WorldGen.PlaceTile(num14, num15, type, mute: true, forced: false, -1, style); } break; } case 1: { int num15 = item13.Y + 1; WorldGen.PlaceTile(num14, num15, 34, mute: true, forced: false, -1, GenBase._random.Next(6)); for (int num16 = -1; num16 < 2; num16++) { for (int num17 = 0; num17 < 3; num17++) { GenBase._tiles[num16 + num14, num17 + num15].frameX += 54; } } break; } } } int num18 = item13.Width / 8 + 3; WorldGen.SetupStatueList(); while (num18 > 0) { int num19 = GenBase._random.Next(item13.Width - 3) + 1 + item13.X; int num20 = item13.Y + item13.Height - 2; switch (GenBase._random.Next(4)) { case 0: WorldGen.PlaceSmallPile(num19, num20, GenBase._random.Next(31, 34), 1, 185); break; case 1: WorldGen.PlaceTile(num19, num20, 186, mute: true, forced: false, -1, GenBase._random.Next(22, 26)); break; case 2: { int num21 = GenBase._random.Next(2, WorldGen.statueList.Length); WorldGen.PlaceTile(num19, num20, WorldGen.statueList[num21].X, mute: true, forced: false, -1, WorldGen.statueList[num21].Y); if (WorldGen.StatuesWithTraps.Contains(num21)) { WorldGen.PlaceStatueTrap(num19, num20); } break; } case 3: { Point point = Utils.SelectRandom(GenBase._random, choices); WorldGen.PlaceTile(num19, num20, point.X, mute: true, forced: false, -1, point.Y); break; } } num18--; } } foreach (Rectangle item14 in list) { item.ProcessRoom(item14); } bool flag2 = false; foreach (Rectangle item15 in list) { int num22 = item15.Height - 1 + item15.Y; int style2 = (num22 > (int)Main.worldSurface) ? item.ChestStyle : 0; for (int num23 = 0; num23 < 10; num23++) { int i2 = GenBase._random.Next(2, item15.Width - 2) + item15.X; if (flag2 = WorldGen.AddBuriedChest(i2, num22, 0, notNearOtherChests: false, style2)) { break; } } if (flag2) { break; } for (int num24 = item15.X + 2; num24 <= item15.X + item15.Width - 2; num24++) { if (flag2 = WorldGen.AddBuriedChest(num24, num22, 0, notNearOtherChests: false, style2)) { break; } } if (flag2) { break; } } if (!flag2) { foreach (Rectangle item16 in list) { int num25 = item16.Y - 1; int style3 = (num25 > (int)Main.worldSurface) ? item.ChestStyle : 0; for (int num26 = 0; num26 < 10; num26++) { int i3 = GenBase._random.Next(2, item16.Width - 2) + item16.X; if (flag2 = WorldGen.AddBuriedChest(i3, num25, 0, notNearOtherChests: false, style3)) { break; } } if (flag2) { break; } for (int num27 = item16.X + 2; num27 <= item16.X + item16.Width - 2; num27++) { if (flag2 = WorldGen.AddBuriedChest(num27, num25, 0, notNearOtherChests: false, style3)) { break; } } if (flag2) { break; } } } if (!flag2) { for (int num28 = 0; num28 < 1000; num28++) { int i4 = GenBase._random.Next(list[0].X - 30, list[0].X + 30); int num29 = GenBase._random.Next(list[0].Y - 30, list[0].Y + 30); int style4 = (num29 > (int)Main.worldSurface) ? item.ChestStyle : 0; if (flag2 = WorldGen.AddBuriedChest(i4, num29, 0, notNearOtherChests: false, style4)) { break; } } } if (item == BuildData.Jungle && _sharpenerCount < GenBase._random.Next(2, 5)) { bool flag3 = false; foreach (Rectangle item17 in list) { int num30 = item17.Height - 2 + item17.Y; for (int num31 = 0; num31 < 10; num31++) { int num32 = GenBase._random.Next(2, item17.Width - 2) + item17.X; WorldGen.PlaceTile(num32, num30, 377, mute: true, forced: true); if (flag3 = (GenBase._tiles[num32, num30].active() && GenBase._tiles[num32, num30].type == 377)) { break; } } if (flag3) { break; } for (int num33 = item17.X + 2; num33 <= item17.X + item17.Width - 2; num33++) { if (flag3 = WorldGen.PlaceTile(num33, num30, 377, mute: true, forced: true)) { break; } } if (flag3) { break; } } if (flag3) { _sharpenerCount++; } } if (item == BuildData.Desert && _extractinatorCount < GenBase._random.Next(2, 5)) { bool flag4 = false; foreach (Rectangle item18 in list) { int num34 = item18.Height - 2 + item18.Y; for (int num35 = 0; num35 < 10; num35++) { int num36 = GenBase._random.Next(2, item18.Width - 2) + item18.X; WorldGen.PlaceTile(num36, num34, 219, mute: true, forced: true); if (flag4 = (GenBase._tiles[num36, num34].active() && GenBase._tiles[num36, num34].type == 219)) { break; } } if (flag4) { break; } for (int num37 = item18.X + 2; num37 <= item18.X + item18.Width - 2; num37++) { if (flag4 = WorldGen.PlaceTile(num37, num34, 219, mute: true, forced: true)) { break; } } if (flag4) { break; } } if (flag4) { _extractinatorCount++; } } return(true); }
public override bool Place(Point origin, StructureMap structures) { Point result1; if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin) { return(false); } var room1 = GetRoom(result1); var room2 = GetRoom(new Point(room1.Center.X, room1.Y + 1)); var room3 = GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10)); room3.Y = room1.Y + room1.Height - 1; var num1 = RoomSolidPrecentage(room2); var num2 = RoomSolidPrecentage(room3); room1.Y += 3; room2.Y += 3; room3.Y += 3; var rectangleList1 = new List <Rectangle>(); if (_random.NextFloat() > num1 + 0.200000002980232) { rectangleList1.Add(room2); } else { room2 = room1; } rectangleList1.Add(room1); if (_random.NextFloat() > num2 + 0.200000002980232) { rectangleList1.Add(room3); } else { room3 = room1; } foreach (var rectangle in rectangleList1) { if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220) { return(false); } } var resultsOutput = new Dictionary <ushort, int>(); foreach (var rectangle in rectangleList1) { WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), new Actions.TileScanner((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)); } var tupleList1 = new List <Tuple <BuildData, int> >(); tupleList1.Add(Tuple.Create(BuildData.Default, resultsOutput[0] + resultsOutput[1])); tupleList1.Add(Tuple.Create(BuildData.Jungle, resultsOutput[59] + resultsOutput[60] * 10)); tupleList1.Add(Tuple.Create(BuildData.Mushroom, resultsOutput[59] + resultsOutput[70] * 10)); tupleList1.Add(Tuple.Create(BuildData.Snow, resultsOutput[147] + resultsOutput[161])); tupleList1.Add(Tuple.Create(BuildData.Desert, resultsOutput[397] + resultsOutput[396] + resultsOutput[53])); tupleList1.Add(Tuple.Create(BuildData.Granite, resultsOutput[368])); tupleList1.Add(Tuple.Create(BuildData.Marble, resultsOutput[367])); tupleList1.Sort(SortBiomeResults); var buildData = tupleList1[0].Item1; foreach (var area in rectangleList1) { if (buildData != 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, _blacklistedTiles, 5)) { return(false); } } var val1_1 = room1.X; var val1_2 = room1.X + room1.Width - 1; var rectangleList2 = new List <Rectangle>(); foreach (var rectangle in rectangleList1) { val1_1 = Math.Min(val1_1, rectangle.X); val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1); } var num3 = 6; while (num3 > 4 && (val1_2 - val1_1) % num3 != 0) { --num3; } var x1 = val1_1; while (x1 <= val1_2) { for (var index1 = 0; index1 < rectangleList1.Count; ++index1) { var rectangle = rectangleList1[index1]; if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width) { var y = rectangle.Y + rectangle.Height; var num4 = 50; for (var index2 = index1 + 1; index2 < rectangleList1.Count; ++index2) { if (x1 >= rectangleList1[index2].X && x1 < rectangleList1[index2].X + rectangleList1[index2].Width) { num4 = Math.Min(num4, rectangleList1[index2].Y - y); } } if (num4 > 0) { Point result2; var flag = WorldUtils.Find(new Point(x1, y), Searches.Chain(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 Rectangle(x1, y, 1, result2.Y - y)); } } } } x1 += num3; } var pointList1 = new List <Point>(); foreach (var rectangle in rectangleList1) { int exitY; if (FindSideExit( new 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 (FindSideExit( new Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY)) { pointList1.Add(new Point(rectangle.X, exitY)); } } var tupleList2 = new List <Tuple <Point, Point> >(); for (var index = 1; index < rectangleList1.Count; ++index) { var rectangle1 = rectangleList1[index]; var rectangle2 = rectangleList1[index - 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))); } } var pointList2 = new List <Point>(); int exitX; if (FindVerticalExit(new Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX)) { pointList2.Add(new Point(exitX, room2.Y)); } if (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)); } foreach (var area in rectangleList1) { WorldUtils.Gen(new Point(area.X, area.Y), 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), 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 (var tuple in tupleList2) { var origin1 = tuple.Item1; var point = tuple.Item2; var num4 = point.X > origin1.X ? 1 : -1; var data = new ShapeData(); for (var y = 0; y < point.Y - origin1.Y; ++y) { data.Add(num4 * (y + 1), y); } WorldUtils.Gen(origin1, new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile(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), new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true))); } foreach (var origin1 in pointList1) { WorldUtils.Gen(origin1, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true)); WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle); } foreach (var origin1 in pointList2) { var rectangle = new Shapes.Rectangle(3, 1); var action = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)); WorldUtils.Gen(origin1, rectangle, action); } foreach (var rectangle in rectangleList2) { if (rectangle.Height > 1 && _tiles[rectangle.X, rectangle.Y - 1].type != 19) { WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile(124, false, true), (GenAction) new Actions.SetFrames(true))); var tile = _tiles[rectangle.X, rectangle.Y + rectangle.Height]; tile.slope(0); tile.halfBrick(false); } } var 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 (var rectangle in rectangleList1) { var num4 = rectangle.Width / 8; var num5 = rectangle.Width / (num4 + 1); var num6 = _random.Next(2); for (var index1 = 0; index1 < num4; ++index1) { var num7 = (index1 + 1) * num5 + rectangle.X; switch (index1 + num6 % 2) { case 0: var num8 = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5); var vector2 = WorldGen.randHousePicture(); var x2 = (int)vector2.X; var y = (int)vector2.Y; if (!WorldGen.nearPicture(num7, num8)) { WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y); } break; case 1: var j = rectangle.Y + 1; WorldGen.PlaceTile(num7, j, 34, true, false, -1, _random.Next(6)); for (var index2 = -1; index2 < 2; ++index2) { for (var index3 = 0; index3 < 3; ++index3) { _tiles[index2 + num7, index3 + j].frameX += 54; } } break; } } var num9 = rectangle.Width / 8 + 3; WorldGen.SetupStatueList(); for (; num9 > 0; --num9) { var num7 = _random.Next(rectangle.Width - 3) + 1 + rectangle.X; var num8 = rectangle.Y + rectangle.Height - 2; switch (_random.Next(4)) { case 0: WorldGen.PlaceSmallPile(num7, num8, _random.Next(31, 34), 1, 185); break; case 1: WorldGen.PlaceTile(num7, num8, 186, true, false, -1, _random.Next(22, 26)); break; case 2: var index = _random.Next(2, WorldGen.statueList.Length); WorldGen.PlaceTile(num7, num8, WorldGen.statueList[index].X, true, false, -1, WorldGen.statueList[index].Y); if (WorldGen.StatuesWithTraps.Contains(index)) { WorldGen.PlaceStatueTrap(num7, num8); } break; case 3: var point = Utils.SelectRandom(_random, pointArray); WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y); break; } } } foreach (var room4 in rectangleList1) { buildData.ProcessRoom(room4); } var flag1 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 1 + rectangle.Y; var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; var num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { var 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 (var rectangle in rectangleList1) { var j = rectangle.Y - 1; var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; var num4 = 0; while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style))) { ++num4; } if (!flag1) { var 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 (var index = 0; index < 1000; ++index) { var i = _random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30); var j = _random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30); var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0; if (WorldGen.AddBuriedChest(i, j, 0, false, Style)) { break; } } } if (buildData == BuildData.Jungle && _sharpenerCount < _random.Next(2, 5)) { var flag2 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 2 + rectangle.Y; for (var index = 0; index < 10; ++index) { var i = _random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 377, true, true, -1, 0); if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 377) { break; } } if (!flag2) { var 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) { ++_sharpenerCount; } } if (buildData == BuildData.Desert && _extractinatorCount < _random.Next(2, 5)) { var flag2 = false; foreach (var rectangle in rectangleList1) { var j = rectangle.Height - 2 + rectangle.Y; for (var index = 0; index < 10; ++index) { var i = _random.Next(2, rectangle.Width - 2) + rectangle.X; WorldGen.PlaceTile(i, j, 219, true, true, -1, 0); if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 219) { break; } } if (!flag2) { var 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) { ++_extractinatorCount; } } return(true); }