private static void ChozoRuins_ChestRoom(int x, int y, int width, int height, int itemType) { BasicStructure(x, y, width, height, 4, TileID.SandstoneBrick, WallID.SandstoneBrick, 1); for (int j = 0; j < 2; j++) { for (int i = -j; i < 4 + j; i++) { int numX = x + width / 2 - 2; WorldGen.KillTile(numX + i, y + height - 6 + j); WorldGen.PlaceTile(numX + i, y + height - 6 + j, TileID.SandstoneBrick); } } Mod mod = MetroidMod.Instance; int xx = x + width / 2; int yy = y + height - 7; WorldGen.AddBuriedChest(xx, yy, itemType, false, 1); for (int l = xx - 1; l < xx + 1; l++) { for (int m = yy - 1; m < yy + 1; m++) { if (Main.tile[l, m] == null) { Main.tile[l, m] = new Tile(); } Tile tile = Main.tile[l, m]; tile.active(true); tile.type = (ushort)mod.TileType("ChozoChest"); tile.frameX = (short)((tile.frameX / 18 % 2) * 18); tile.frameY = (short)((tile.frameY / 18 % 2) * 18); } } }
public static Task AsyncGenerateChests(int amount) { WorldRefill.isTaskRunning = true; AsyncRemoveEmptyChests(); return(Task.Run(() => { int realcount = 0; for (int trycount = 0; trycount < WorldRefill.config.GenerationMaxTries; trycount++) { int contain; contain = 0; int tryX = WorldGen.genRand.Next(20, Main.maxTilesX - 20); int tryY = WorldGen.genRand.Next((int)Main.worldSurface, Main.maxTilesY - 200); if (!WorldRefill.IsProtected(tryX, tryY)) { while (!Main.tile[tryX, tryY].active()) { tryY++; } tryY--; WorldGen.KillTile(tryX, tryY, noItem: true); WorldGen.KillTile(tryX + 1, tryY, noItem: true); WorldGen.KillTile(tryX, tryY + 1, noItem: true); WorldGen.KillTile(tryX + 1, tryY, noItem: true); if (WorldGen.AddBuriedChest(tryX, tryY, contain, true, 1)) { realcount++; if (realcount == amount) { break; } } } } WorldRefill.realcount = realcount; }).ContinueWith((d) => FinishGen())); }
public override bool Place(Point origin, StructureMap structures) { if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain(new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out var result)) { return(false); } if (!WorldUtils.Find(new Point(result.X, result.Y - 5), Searches.Chain(new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out var result2) || result.Y - 5 - result2.Y > 60) { return(false); } if (result.Y - result2.Y < 30) { return(false); } if (!structures.CanPlace(new Rectangle(result.X - 30, result.Y - 60, 60, 90))) { return(false); } if (!WorldGen.drunkWorldGen || WorldGen.genRand.Next(50) > 0) { Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(result.X - 25, result.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 59, 147, 1).Output(dictionary)); int num = dictionary[0] + dictionary[1]; int num2 = dictionary[59]; if (dictionary[147] > num2 || num > num2 || num2 < 50) { return(false); } } int num3 = (result.Y - result2.Y - 9) / 5; int num4 = num3 * 5; int num5 = 0; double num6 = GenBase._random.NextDouble() + 1.0; double num7 = GenBase._random.NextDouble() + 2.0; if (GenBase._random.Next(2) == 0) { num7 = 0.0 - num7; } for (int i = 0; i < num3; i++) { int num8 = (int)(Math.Sin((double)(i + 1) / 12.0 * num6 * 3.1415927410125732) * num7); int num9 = ((num8 < num5) ? (num8 - num5) : 0); WorldUtils.Gen(new Point(result.X + num5 + num9, result.Y - (i + 1) * 5), new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain(new Actions.RemoveWall(), new Actions.SetTile(383), new Actions.SetFrames())); WorldUtils.Gen(new Point(result.X + num5 + num9 + 2, result.Y - (i + 1) * 5), new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain(new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78))); WorldUtils.Gen(new Point(result.X + num5 + 2, result.Y - i * 5), new Shapes.Rectangle(2, 2), Actions.Chain(new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78))); num5 = num8; } int num10 = 6; if (num7 < 0.0) { num10 = 0; } List <Point> list = new List <Point>(); for (int j = 0; j < 2; j++) { double num11 = ((double)j + 1.0) / 3.0; int num12 = num10 + (int)(Math.Sin((double)num3 * num11 / 12.0 * num6 * 3.1415927410125732) * num7); double num13 = GenBase._random.NextDouble() * 0.78539818525314331 - 0.78539818525314331 - 0.20000000298023224; if (num10 == 0) { num13 -= 1.5707963705062866; } WorldUtils.Gen(new Point(result.X + num12, result.Y - (int)((double)(num3 * 5) * num11)), new ShapeBranch(num13, GenBase._random.Next(12, 16)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); num10 = 6 - num10; } int num14 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.1415927410125732) * num7); WorldUtils.Gen(new Point(result.X + 6 + num14, result.Y - num4), new ShapeBranch(-0.68539818525314333, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); WorldUtils.Gen(new Point(result.X + num14, result.Y - num4), new ShapeBranch(-2.4561944961547852, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); foreach (Point item in list) { WorldUtils.Gen(item, new Shapes.Circle(4), Actions.Chain(new Modifiers.Blotches(4, 2), new Modifiers.SkipTiles(383), new Modifiers.SkipWalls(78), new Actions.SetTile(384), new Actions.SetFrames(frameNeighbors: true))); } for (int k = 0; k < 4; k++) { float angle = (float)k / 3f * 2f + 0.57075f; WorldUtils.Gen(result, new ShapeRoot(angle, GenBase._random.Next(40, 60)), new Actions.SetTile(383, setSelfFrames: true)); } WorldGen.AddBuriedChest(result.X + 3, result.Y - 1, (GenBase._random.Next(4) != 0) ? WorldGen.GetNextJungleChestItem() : 0, notNearOtherChests: false, 10, trySlope: false, 0); structures.AddProtectedStructure(new Rectangle(result.X - 30, result.Y - 30, 60, 60)); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point result1; if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain((GenSearch) new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out result1)) { return(false); } Point result2; if (!WorldUtils.Find(new Point(result1.X, result1.Y - 5), Searches.Chain((GenSearch) new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out result2) || result1.Y - 5 - result2.Y > 60 || (result1.Y - result2.Y < 30 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 60, 60, 90), 0))) { return(false); } Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(result1.X - 25, result1.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4] { (ushort)0, (ushort)59, (ushort)147, (ushort)1 }).Output(resultsOutput)); int num1 = resultsOutput[(ushort)0] + resultsOutput[(ushort)1]; int num2 = resultsOutput[(ushort)59]; if (resultsOutput[(ushort)147] > num2 || num1 > num2 || num2 < 50) { return(false); } int num3 = (result1.Y - result2.Y - 9) / 5; int num4 = num3 * 5; int num5 = 0; double num6 = GenBase._random.NextDouble() + 1.0; double num7 = GenBase._random.NextDouble() + 2.0; if (GenBase._random.Next(2) == 0) { num7 = -num7; } for (int index = 0; index < num3; ++index) { int num8 = (int)(Math.Sin((double)(index + 1) / 12.0 * num6 * 3.14159274101257) * num7); int num9 = num8 < num5 ? num8 - num5 : 0; WorldUtils.Gen(new Point(result1.X + num5 + num9, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain((GenAction) new Actions.RemoveWall(), (GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(false))); WorldUtils.Gen(new Point(result1.X + num5 + num9 + 2, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte)78, true))); WorldUtils.Gen(new Point(result1.X + num5 + 2, result1.Y - index * 5), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte)78, true))); num5 = num8; } int num10 = 6; if (num7 < 0.0) { num10 = 0; } List <Point> endpoints = new List <Point>(); for (int index = 0; index < 2; ++index) { double num8 = ((double)index + 1.0) / 3.0; int num9 = num10 + (int)(Math.Sin((double)num3 * num8 / 12.0 * num6 * 3.14159274101257) * num7); double angle = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232; if (num10 == 0) { angle -= 1.57079637050629; } WorldUtils.Gen(new Point(result1.X + num9, result1.Y - (int)((double)(num3 * 5) * num8)), (GenShape) new ShapeBranch(angle, (double)GenBase._random.Next(12, 16)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true))); num10 = 6 - num10; } int num11 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.14159274101257) * num7); WorldUtils.Gen(new Point(result1.X + 6 + num11, result1.Y - num4), (GenShape) new ShapeBranch(-0.685398185253143, (double)GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(new Point(result1.X + num11, result1.Y - num4), (GenShape) new ShapeBranch(-2.45619455575943, (double)GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true))); foreach (Point origin1 in endpoints) { Shapes.Circle circle = new Shapes.Circle(4); GenAction action = Actions.Chain((GenAction) new Modifiers.Blotches(4, 2, 0.3), (GenAction) new Modifiers.SkipTiles(new ushort[1] { (ushort)383 }), (GenAction) new Modifiers.SkipWalls(new byte[1] { (byte)78 }), (GenAction) new Actions.SetTile((ushort)384, false, true), (GenAction) new Actions.SetFrames(true)); WorldUtils.Gen(origin1, (GenShape)circle, action); } for (int index = 0; index < 4; ++index) { float angle = (float)((double)index / 3.0 * 2.0 + 0.570749998092651); WorldUtils.Gen(result1, (GenShape) new ShapeRoot(angle, (float)GenBase._random.Next(40, 60), 4f, 1f), (GenAction) new Actions.SetTile((ushort)383, true, true)); } WorldGen.AddBuriedChest(result1.X + 3, result1.Y - 1, GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem(), false, 10); structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 30, 60, 60), 0); return(true); }
private bool PrivateReplenisher(GenType type, int amount, ushort oretype = 0, CommandArgs args = null) { int counter = 0; bool success; for (int i = 0; i < TIMEOUT; i++) { success = false; int xRandBase = WorldGen.genRand.Next(1, Main.maxTilesX); int y = 0; switch (type) { case GenType.ore: y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } if (oretype != Terraria.ID.TileID.Hellstone) { WorldGen.OreRunner(xRandBase, y, 2.0, amount, oretype); } else { WorldGen.OreRunner(xRandBase, WorldGen.genRand.Next((int)(Main.maxTilesY) - 200, Main.maxTilesY), 2.0, amount, oretype); } success = true; break; case GenType.chests: if (amount == 0) { int tmpEmpty = 0, empty = 0; for (int x = 0; x < 1000; x++) { if (Main.chest[x] != null) { tmpEmpty++; bool found = false; foreach (Item itm in Main.chest[x].item) { if (itm.netID != 0) { found = true; } } if (found == false) { empty++; WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false); Main.chest[x] = null; } } } args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty); return(true); } y = WorldGen.genRand.Next((int)(Main.worldSurface) - 200, Main.maxTilesY); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } success = WorldGen.AddBuriedChest(xRandBase, y); break; case GenType.pots: y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } success = WorldGen.PlacePot(xRandBase, y); break; case GenType.lifecrystals: y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } success = WorldGen.AddLifeCrystal(xRandBase, y); break; case GenType.altars: y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } WorldGen.Place3x2(xRandBase, y, 26); success = Main.tile[xRandBase, y].type == 26; break; case GenType.trees: WorldGen.AddTrees(); success = true; break; case GenType.floatingisland: y = WorldGen.genRand.Next((int)Main.worldSurface + 175, (int)Main.worldSurface + 300); if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas) { success = false; break; } WorldGen.FloatingIsland(xRandBase, y); success = true; break; case GenType.pyramids: //TODO break; } if (success) { counter++; if (counter >= amount) { return(true); } } } return(false); }
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); }
private void DoChests(CommandArgs args) { if (args.Parameters.Count == 0 || args.Parameters.Count > 2) { args.Player.SendInfoMessage("Usage: /genchests <amount> [gen mode: default/easy/all]"); } int empty = 0; int tmpEmpty = 0; int chests = 0; int maxChests = 1000; string setting = "default"; if (args.Parameters.Count > 1) { setting = args.Parameters[1]; } const int maxtries = 100000; Int32.TryParse(args.Parameters[0], out chests); const int threshold = 100; if (!config.UseInfiniteChests) { for (int x = 0; x < maxChests; x++) { if (Main.chest[x] != null) { tmpEmpty++; bool found = false; foreach (Item itm in Main.chest[x].item) { if (itm.netID != 0) { found = true; } } if (found == false) { empty++; // TShock.Utils.Broadcast(string.Format("Found chest {0} empty at x {1} y {2}", x, Main.chest[x].x, // Main.chest[x].y)); // destroying WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false); Main.chest[x] = null; } } } args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty); } else { try { switch (TShock.Config.StorageType.ToLowerInvariant()) { case "mysql": string[] host = TShock.Config.MySqlHost.Split(':'); ChestDB = new MySqlConnection() { ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", host[0], host.Length == 1 ? "3306" : host[1], TShock.Config.MySqlDbName, TShock.Config.MySqlUsername, TShock.Config.MySqlPassword) }; break; case "sqlite": string sql = Path.Combine(TShock.SavePath, "chests.sqlite"); ChestDB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); break; } } catch (Exception ex) { TShock.Log.ConsoleError(ex.ToString()); } } if (chests + tmpEmpty + threshold > maxChests) { chests = maxChests - tmpEmpty - threshold; } if (chests > 0) { int chestcount = 0; chestcount = tmpEmpty; int tries = 0; int newcount = 0; while (newcount < chests) { int contain; if (setting == "default") { // Moved item list into a separate .txt file int[] itemID = config.DefaultChestIDs; contain = itemID[WorldGen.genRand.Next(0, itemID.Length)]; } else if (setting == "all") { // Updated item list to 1.2.4.1 contain = WorldGen.genRand.Next(ItemList[0], ItemList.Last() + 1); } else if (setting == "easy") { contain = WorldGen.genRand.Next(-24, 364); } else { args.Player.SendWarningMessage("Warning! Typo in second argument: {0}", args.Parameters[1]); return; } int tryX = WorldGen.genRand.Next(20, Main.maxTilesX - 20); int tryY = WorldGen.genRand.Next((int)Main.worldSurface, Main.maxTilesY - 200); if (!config.GenInsideProtectedRegions && IsProtected(tryX, tryY)) { continue; } while (!Main.tile[tryX, tryY].active()) { tryY++; } tryY--; WorldGen.KillTile(tryX, tryY, false, false, false); WorldGen.KillTile(tryX + 1, tryY, false, false, false); WorldGen.KillTile(tryX, tryY + 1, false, false, false); WorldGen.KillTile(tryX + 1, tryY, false, false, false); if (WorldGen.AddBuriedChest(tryX, tryY, contain, true, 1)) { chestcount++; newcount++; if (config.UseInfiniteChests) { StringBuilder items = new StringBuilder(); Terraria.Chest c = Main.chest[0]; if (c != null) { for (int j = 0; j < 40; j++) { items.Append(c.item[j].netID + "," + c.item[j].stack + "," + c.item[j].prefix); if (j != 39) { items.Append(","); } } try { ChestDB.Query("INSERT INTO Chests (X, Y, Account, Items, WorldID) VALUES (@0, @1, '', @2, @3)", c.x, c.y, items.ToString(), Main.worldID); } catch (Exception ex) { TShock.Log.ConsoleError(ex.ToString()); } items.Clear(); Main.chest[0] = null; } } } if (tries + 1 >= maxtries) { break; } tries++; } if (config.UseInfiniteChests) { ChestDB.Dispose(); } args.Player.SendSuccessMessage("Generated {0} new chests - {1} total", newcount, chestcount); InformPlayers(); } }
private void PlaceChests() { if ((double)this._random.NextFloat() > (double)this.ChestChance) { return; } bool flag = false; foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms) { int j = room.Height - 1 + room.Y; int Style = j > (int)Main.worldSurface ? this.ChestStyle : 0; int num = 0; while (num < 10 && !(flag = WorldGen.AddBuriedChest(this._random.Next(2, room.Width - 2) + room.X, j, 0, false, Style, false, (ushort)0))) { ++num; } if (!flag) { int i = room.X + 2; while (i <= room.X + room.Width - 2 && !(flag = WorldGen.AddBuriedChest(i, j, 0, false, Style, false, (ushort)0))) { ++i; } if (flag) { break; } } else { break; } } if (!flag) { foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms) { int j = room.Y - 1; int Style = j > (int)Main.worldSurface ? this.ChestStyle : 0; int num = 0; while (num < 10 && !(flag = WorldGen.AddBuriedChest(this._random.Next(2, room.Width - 2) + room.X, j, 0, false, Style, false, (ushort)0))) { ++num; } if (!flag) { int i = room.X + 2; while (i <= room.X + room.Width - 2 && !(flag = WorldGen.AddBuriedChest(i, j, 0, false, Style, false, (ushort)0))) { ++i; } if (flag) { break; } } else { break; } } } if (flag) { return; } for (int index = 0; index < 1000; ++index) { int i = this._random.Next(this.Rooms[0].X - 30, this.Rooms[0].X + 30); int num1 = this._random.Next(this.Rooms[0].Y - 30, this.Rooms[0].Y + 30); int num2 = num1 > (int)Main.worldSurface ? this.ChestStyle : 0; int j = num1; int Style = num2; if (WorldGen.AddBuriedChest(i, j, 0, false, Style, false, (ushort)0)) { break; } } }
public async Task <bool> Build(TSPlayer tsPlayer, int X, int Y) { return(await Task.Run(() => { int count = Main.chest.Count(c => c != null); if (count > 1000 - MaxChests) { tsPlayer.SendInfoMessage("Creating this chestroom would exceed the chest limit, chestroom cancelled."); return false; } bool first = true; int placed = ChestsPerRow *MaxRows; int itemIndex = ItemIds.Length - 1; for (int y = RowHeight - 1; y >= 0; y--) { for (int x = RowWidth - 1; x >= 0; x--) { if (x > 0 && x < RowWidth - 1 && y > 0 && y < RowHeight - 1) { Main.tile[x + X, y + Y] = new Tile() { wall = BackWall }; } if (x == 0 || x == RowWidth - 1 || y == 0 || y == RowHeight - 1) { Main.tile[x + X, y + Y] = new Tile() { type = TileId }; Main.tile[x + X, y + Y].active(true); } if (y % 5 == 0 && y > 0 && y < RowHeight - 1) { Main.tile[x + X, y + Y].active(true); if ((x % 4 == 2 || x % 4 == 3 || x == 1 || x == RowWidth - 2)) { Main.tile[x + X, y + Y].type = TileId; } else if ((x % 4 == 0 || x % 4 == 1) && x > 1 && x < RowWidth - 2) { Main.tile[x + X, y + Y].type = (byte)19; Main.tile[x + X, y + Y].frameY = PlatformFrameY; } } if (y % 5 == 1 && (x == 1 || x == RowWidth - 2)) { Main.tile[x + X, y + Y].active(true); Main.tile[x + X, y + Y].type = 4; Main.tile[x + X, y + Y].frameY = TorchFrameY; } if (y % 5 == 2 && x % 4 == 3 && x > 0 && x < RowWidth - 2) { if (--placed < MaxChests) { WorldGen.AddBuriedChest(x + X, y + Y, 1, false, ChestId); if (Main.chest[count] != null) { for (int i = 39; i >= 0; i--) { if (itemIndex < 0) { break; } if (first) { i -= 40 - (ItemIds.Length) % 40; first = false; } Item itm = TShock.Utils.GetItemById(ItemIds[itemIndex--]); itm.stack = itm.maxStack; Main.chest[count].item[i] = itm; } } count++; } } } } if (ChestroomPlugin.usinginfchests) { Utils.ConvertToAutoRefill(count - MaxChests, MaxChests); } return true; })); }
public override bool Place(Point origin, StructureMap structures) { Point point; Point point1; Point point2 = new Point(origin.X - 3, origin.Y); Searches.Down down = new Searches.Down(200); GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaAnd(6, 1) }; if (!WorldUtils.Find(point2, Searches.Chain(down, genConditionArray), out point)) { return(false); } Point point3 = new Point(point.X, point.Y - 5); Searches.Up up = new Searches.Up(120); GenCondition[] genConditionArray1 = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(6, 1) }; if (!WorldUtils.Find(point3, Searches.Chain(up, genConditionArray1), out point1) || point.Y - 5 - point1.Y > 60) { return(false); } if (point.Y - point1.Y < 30) { return(false); } if (!structures.CanPlace(new Rectangle(point.X - 30, point.Y - 60, 60, 90), 0)) { return(false); } Dictionary <ushort, int> nums = new Dictionary <ushort, int>(); Point point4 = new Point(point.X - 25, point.Y - 25); Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50); ushort[] numArray = new ushort[] { 0, 59, 147, 1 }; WorldUtils.Gen(point4, rectangle, (new Actions.TileScanner(numArray)).Output(nums)); int item = nums[0] + nums[1]; int num = nums[59]; if (nums[147] > num || item > num || num < 50) { return(false); } int y = (point.Y - point1.Y - 9) / 5; int num1 = y * 5; int num2 = 0; double num3 = GenBase._random.NextDouble() + 1; double num4 = GenBase._random.NextDouble() + 2; if (GenBase._random.Next(2) == 0) { num4 = -num4; } for (int i = 0; i < y; i++) { double num5 = (double)(i + 1) / 12; int num6 = (int)(Math.Sin(num5 * num3 * 3.14159274101257) * num4); int num7 = (num6 < num2 ? num6 - num2 : 0); Point point5 = new Point(point.X + num2 + num7, point.Y - (i + 1) * 5); Shapes.Rectangle rectangle1 = new Shapes.Rectangle(6 + Math.Abs(num6 - num2), 7); GenAction[] removeWall = new GenAction[] { new Actions.RemoveWall(), new Actions.SetTile(383, false, true), new Actions.SetFrames(false) }; WorldUtils.Gen(point5, rectangle1, Actions.Chain(removeWall)); Point point6 = new Point(point.X + num2 + num7 + 2, point.Y - (i + 1) * 5); Shapes.Rectangle rectangle2 = new Shapes.Rectangle(2 + Math.Abs(num6 - num2), 5); GenAction[] clearTile = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) }; WorldUtils.Gen(point6, rectangle2, Actions.Chain(clearTile)); Point point7 = new Point(point.X + num2 + 2, point.Y - i * 5); Shapes.Rectangle rectangle3 = new Shapes.Rectangle(2, 2); GenAction[] genActionArray = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) }; WorldUtils.Gen(point7, rectangle3, Actions.Chain(genActionArray)); num2 = num6; } int num8 = 6; if (num4 < 0) { num8 = 0; } List <Point> points = new List <Point>(); for (int j = 0; j < 2; j++) { double num9 = ((double)j + 1) / 3; int num10 = num8 + (int)(Math.Sin((double)y * num9 / 12 * num3 * 3.14159274101257) * num4); double num11 = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232; if (num8 == 0) { num11 = num11 - 1.57079637050629; } Point point8 = new Point(point.X + num10, point.Y - (int)((double)(y * 5) * num9)); ShapeBranch shapeBranch = (new ShapeBranch(num11, (double)GenBase._random.Next(12, 16))).OutputEndpoints(points); GenAction[] setTile = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point8, shapeBranch, Actions.Chain(setTile)); num8 = 6 - num8; } int num12 = (int)(Math.Sin((double)y / 12 * num3 * 3.14159274101257) * num4); Point point9 = new Point(point.X + 6 + num12, point.Y - num1); ShapeBranch shapeBranch1 = (new ShapeBranch(-0.685398185253143, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points); GenAction[] setTile1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point9, shapeBranch1, Actions.Chain(setTile1)); Point point10 = new Point(point.X + num12, point.Y - num1); ShapeBranch shapeBranch2 = (new ShapeBranch(-2.45619455575943, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points); GenAction[] genActionArray1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point10, shapeBranch2, Actions.Chain(genActionArray1)); foreach (Point point11 in points) { Shapes.Circle circle = new Shapes.Circle(4); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(4, 2, 0.3), null, null, null, null }; ushort[] numArray1 = new ushort[] { 383 }; blotch[1] = new Modifiers.SkipTiles(numArray1); byte[] numArray2 = new byte[] { 78 }; blotch[2] = new Modifiers.SkipWalls(numArray2); blotch[3] = new Actions.SetTile(384, false, true); blotch[4] = new Actions.SetFrames(true); WorldUtils.Gen(point11, circle, Actions.Chain(blotch)); } for (int k = 0; k < 4; k++) { float single = (float)k / 3f * 2f + 0.57075f; WorldUtils.Gen(point, new ShapeRoot(single, (float)GenBase._random.Next(40, 60), 4f, 1f), new Actions.SetTile(383, true, true)); } WorldGen.AddBuriedChest(point.X + 3, point.Y - 1, (GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem()), false, 10); structures.AddStructure(new Rectangle(point.X - 30, point.Y - 30, 60, 60), 0); 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); }
public override bool Place(Point origin, StructureMap structures) { Point result; if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain(new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out result)) { return(false); } Point result2; if (!WorldUtils.Find(new Point(result.X, result.Y - 5), Searches.Chain(new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out result2) || result.Y - 5 - result2.Y > 60) { return(false); } if (result.Y - result2.Y < 30) { return(false); } if (!structures.CanPlace(new Rectangle(result.X - 30, result.Y - 60, 60, 90))) { return(false); } Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(result.X - 25, result.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 59, 147, 1).Output(dictionary)); int num = dictionary[0] + dictionary[1]; int num2 = dictionary[59]; int num3 = dictionary[147]; if (num3 > num2 || num > num2 || num2 < 50) { return(false); } int num4 = (result.Y - result2.Y - 9) / 5; int num5 = num4 * 5; int num6 = 0; double num7 = GenBase._random.NextDouble() + 1.0; double num8 = GenBase._random.NextDouble() + 2.0; if (GenBase._random.Next(2) == 0) { num8 = 0.0 - num8; } for (int i = 0; i < num4; i++) { double num9 = (double)(i + 1) / 12.0; int num10 = (int)(Math.Sin(num9 * num7 * 3.1415927410125732) * num8); int num11 = (num10 < num6) ? (num10 - num6) : 0; WorldUtils.Gen(new Point(result.X + num6 + num11, result.Y - (i + 1) * 5), new Shapes.Rectangle(6 + Math.Abs(num10 - num6), 7), Actions.Chain(new Actions.RemoveWall(), new Actions.SetTile(383), new Actions.SetFrames())); WorldUtils.Gen(new Point(result.X + num6 + num11 + 2, result.Y - (i + 1) * 5), new Shapes.Rectangle(2 + Math.Abs(num10 - num6), 5), Actions.Chain(new Actions.ClearTile(true), new Actions.PlaceWall(78))); WorldUtils.Gen(new Point(result.X + num6 + 2, result.Y - i * 5), new Shapes.Rectangle(2, 2), Actions.Chain(new Actions.ClearTile(true), new Actions.PlaceWall(78))); num6 = num10; } int num12 = 6; if (num8 < 0.0) { num12 = 0; } List <Point> list = new List <Point>(); for (int j = 0; j < 2; j++) { double num13 = ((double)j + 1.0) / 3.0; int num14 = num12 + (int)(Math.Sin((double)num4 * num13 / 12.0 * num7 * 3.1415927410125732) * num8); double num15 = GenBase._random.NextDouble() * 0.78539818525314331 - 0.78539818525314331 - 0.20000000298023224; if (num12 == 0) { num15 -= 1.5707963705062866; } WorldUtils.Gen(new Point(result.X + num14, result.Y - (int)((double)(num4 * 5) * num13)), new ShapeBranch(num15, GenBase._random.Next(12, 16)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(true))); num12 = 6 - num12; } int num16 = (int)(Math.Sin((double)num4 / 12.0 * num7 * 3.1415927410125732) * num8); WorldUtils.Gen(new Point(result.X + 6 + num16, result.Y - num5), new ShapeBranch(-0.68539818525314333, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(true))); WorldUtils.Gen(new Point(result.X + num16, result.Y - num5), new ShapeBranch(-2.45619455575943, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(true))); foreach (Point item in list) { WorldUtils.Gen(item, new Shapes.Circle(4), Actions.Chain(new Modifiers.Blotches(4, 2), new Modifiers.SkipTiles(383), new Modifiers.SkipWalls(78), new Actions.SetTile(384), new Actions.SetFrames(true))); } for (int k = 0; k < 4; k++) { float angle = (float)k / 3f * 2f + 0.57075f; WorldUtils.Gen(result, new ShapeRoot(angle, GenBase._random.Next(40, 60)), new Actions.SetTile(383, true)); } WorldGen.AddBuriedChest(result.X + 3, result.Y - 1, (GenBase._random.Next(4) != 0) ? WorldGen.GetNextJungleChestItem() : 0, false, 10); structures.AddStructure(new Rectangle(result.X - 30, result.Y - 30, 60, 60)); return(true); }
// Token: 0x06000FD2 RID: 4050 RVA: 0x003FBA94 File Offset: 0x003F9C94 public override bool Place(Point origin, StructureMap structures) { Point point; if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain(new Searches.Down(200), new GenCondition[] { new Conditions.IsSolid().AreaAnd(6, 1) }), out point)) { return(false); } Point point2; if (!WorldUtils.Find(new Point(point.X, point.Y - 5), Searches.Chain(new Searches.Up(120), new GenCondition[] { new Conditions.IsSolid().AreaOr(6, 1) }), out point2) || point.Y - 5 - point2.Y > 60) { return(false); } if (point.Y - point2.Y < 30) { return(false); } if (!structures.CanPlace(new Rectangle(point.X - 30, point.Y - 60, 60, 90), 0)) { return(false); } Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(point.X - 25, point.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(new ushort[] { 0, 59, 147, 1 }).Output(dictionary)); int num = dictionary[0] + dictionary[1]; int num2 = dictionary[59]; if (dictionary[147] > num2 || num > num2 || num2 < 50) { return(false); } int num3 = (point.Y - point2.Y - 9) / 5; int num4 = num3 * 5; int num5 = 0; double num6 = GenBase._random.NextDouble() + 1.0; double num7 = GenBase._random.NextDouble() + 2.0; if (GenBase._random.Next(2) == 0) { num7 = -num7; } for (int i = 0; i < num3; i++) { int num8 = (int)(Math.Sin((double)(i + 1) / 12.0 * num6 * 3.1415927410125732) * num7); int num9 = (num8 < num5) ? (num8 - num5) : 0; WorldUtils.Gen(new Point(point.X + num5 + num9, point.Y - (i + 1) * 5), new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain(new GenAction[] { new Actions.RemoveWall(), new Actions.SetTile(383, false, true), new Actions.SetFrames(false) })); WorldUtils.Gen(new Point(point.X + num5 + num9 + 2, point.Y - (i + 1) * 5), new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain(new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) })); WorldUtils.Gen(new Point(point.X + num5 + 2, point.Y - i * 5), new Shapes.Rectangle(2, 2), Actions.Chain(new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) })); num5 = num8; } int num10 = 6; if (num7 < 0.0) { num10 = 0; } List <Point> list = new List <Point>(); for (int j = 0; j < 2; j++) { double num11 = ((double)j + 1.0) / 3.0; int num12 = num10 + (int)(Math.Sin((double)num3 * num11 / 12.0 * num6 * 3.1415927410125732) * num7); double num13 = GenBase._random.NextDouble() * 0.78539818525314331 - 0.78539818525314331 - 0.20000000298023224; if (num10 == 0) { num13 -= 1.5707963705062866; } WorldUtils.Gen(new Point(point.X + num12, point.Y - (int)((double)(num3 * 5) * num11)), new ShapeBranch(num13, (double)GenBase._random.Next(12, 16)).OutputEndpoints(list), Actions.Chain(new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) })); num10 = 6 - num10; } int num14 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.1415927410125732) * num7); WorldUtils.Gen(new Point(point.X + 6 + num14, point.Y - num4), new ShapeBranch(-0.68539818525314333, (double)GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) })); WorldUtils.Gen(new Point(point.X + num14, point.Y - num4), new ShapeBranch(-2.4561944961547852, (double)GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) })); using (List <Point> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { WorldUtils.Gen(enumerator.Current, new Shapes.Circle(4), Actions.Chain(new GenAction[] { new Modifiers.Blotches(4, 2, 0.3), new Modifiers.SkipTiles(new ushort[] { 383 }), new Modifiers.SkipWalls(new byte[] { 78 }), new Actions.SetTile(384, false, true), new Actions.SetFrames(true) })); } } for (int k = 0; k < 4; k++) { float angle = (float)k / 3f * 2f + 0.57075f; WorldUtils.Gen(point, new ShapeRoot(angle, (float)GenBase._random.Next(40, 60), 4f, 1f), new Actions.SetTile(383, true, true)); } WorldGen.AddBuriedChest(point.X + 3, point.Y - 1, (GenBase._random.Next(4) == 0) ? 0 : WorldGen.GetNextJungleChestItem(), false, 10); structures.AddStructure(new Rectangle(point.X - 30, point.Y - 30, 60, 60), 0); return(true); }
public bool Build(TSPlayer tsPlayer, int X, int Y) { int count = 0; for (int ch = 0; ch < 1000; ch++) { if (Main.chest[ch] != null) { count++; } } if (count > (1000 - MaxChests)) { tsPlayer.SendInfoMessage("Creating this chestroom would exceed the chest limit, chestroom cancelled."); return(false); } bool first = true; int placed = ChestsPerRow * MaxRows; int chestitem = Main.maxItemTypes - 1; for (int y = RowHeight - 1; y >= 0; y--) { for (int x = RowWidth - 1; x >= 0; x--) { if (x > 0 && x < RowWidth - 1 && y > 0 && y < RowHeight - 1) { Main.tile[x + X, y + Y] = new Tile() { wall = BackWall }; } if (x == 0 || x == RowWidth - 1 || y == 0 || y == RowHeight - 1) { Main.tile[x + X, y + Y] = new Tile() { type = TileId }; Main.tile[x + X, y + Y].active(true); } if (y % 5 == 0 && y > 0 && y < RowHeight - 1) { Main.tile[x + X, y + Y].active(true); if ((x % 4 == 2 || x % 4 == 3 || x == 1 || x == RowWidth - 2)) { Main.tile[x + X, y + Y].type = TileId; } else if ((x % 4 == 0 || x % 4 == 1) && x > 1 && x < RowWidth - 2) { Main.tile[x + X, y + Y].type = (byte)19; Main.tile[x + X, y + Y].frameY = PlatformFrameY; } } if (y % 5 == 1 && (x == 1 || x == RowWidth - 2)) { Main.tile[x + X, y + Y].active(true); Main.tile[x + X, y + Y].type = 4; Main.tile[x + X, y + Y].frameY = TorchFrameY; } if (y % 5 == 2 && x % 4 == 3 && x > 0 && x < RowWidth - 2) { placed--; if (placed < MaxChests) { WorldGen.AddBuriedChest(x + X, y + Y, 1, false, ChestId); if (Main.chest[count] != null) { for (int i = 39; i >= 0; i--) { while (Utils.ExcludeItem(chestitem)) { chestitem--; } if (chestitem < -48) { break; } if (first) { i -= 40 - (ActualMaxItems + 1) % 40; first = false; } Item itm = TShock.Utils.GetItemById(chestitem); itm.stack = itm.maxStack; Main.chest[count].item[i] = itm; chestitem--; } } count++; } } } } if (main.usinginfchests) { Utils.ConvertToAutoRefill(count - MaxChests, MaxChests); } 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) || 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); }
private void PlaceChests() { if (_random.NextFloat() > ChestChance) { return; } bool flag = false; foreach (Rectangle room in Rooms) { int num = room.Height - 1 + room.Y; int style = (num > (int)Main.worldSurface) ? ChestStyle : 0; for (int i = 0; i < 10; i++) { if (flag = WorldGen.AddBuriedChest(_random.Next(2, room.Width - 2) + room.X, num, 0, notNearOtherChests: false, style, trySlope: false, 0)) { break; } } if (flag) { break; } for (int j = room.X + 2; j <= room.X + room.Width - 2; j++) { if (flag = WorldGen.AddBuriedChest(j, num, 0, notNearOtherChests: false, style, trySlope: false, 0)) { break; } } if (flag) { break; } } if (!flag) { foreach (Rectangle room2 in Rooms) { int num2 = room2.Y - 1; int style2 = (num2 > (int)Main.worldSurface) ? ChestStyle : 0; for (int k = 0; k < 10; k++) { if (flag = WorldGen.AddBuriedChest(_random.Next(2, room2.Width - 2) + room2.X, num2, 0, notNearOtherChests: false, style2, trySlope: false, 0)) { break; } } if (flag) { break; } for (int l = room2.X + 2; l <= room2.X + room2.Width - 2; l++) { if (flag = WorldGen.AddBuriedChest(l, num2, 0, notNearOtherChests: false, style2, trySlope: false, 0)) { break; } } if (flag) { break; } } } if (flag) { return; } for (int m = 0; m < 1000; m++) { int i2 = _random.Next(Rooms[0].X - 30, Rooms[0].X + 30); int num3 = _random.Next(Rooms[0].Y - 30, Rooms[0].Y + 30); int style3 = (num3 > (int)Main.worldSurface) ? ChestStyle : 0; if (flag = WorldGen.AddBuriedChest(i2, num3, 0, notNearOtherChests: false, style3, trySlope: false, 0)) { break; } } }