private static bool AreRoomsValid( IEnumerable <Microsoft.Xna.Framework.Rectangle> rooms, StructureMap structures, HouseType style) { foreach (Microsoft.Xna.Framework.Rectangle room in rooms) { if (style != HouseType.Granite) { if (WorldUtils.Find(new Point(room.X - 2, room.Y - 2), Searches.Chain(new Searches.Rectangle(room.Width + 4, room.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out Point _)) { return(false); } } if (WorldGen.notTheBees) { if (!structures.CanPlace(room, HouseUtils.BeelistedTiles, 5)) { return(false); } } else if (!structures.CanPlace(room, HouseUtils.BlacklistedTiles, 5)) { return(false); } } return(true); }
public override bool Place(Point origin, StructureMap structures) { Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 1).Output(dictionary)); int num = dictionary[0] + dictionary[1]; if (num < 1250) { return(false); } Point result; bool flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); Point result2; if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - result.Y), new Conditions.IsTile(53)), out result2)) { return(false); } if (!flag) { return(false); } result.Y += 50; ShapeData shapeData = new ShapeData(); ShapeData shapeData2 = new ShapeData(); Point point = new Point(origin.X, origin.Y + 20); Point point2 = new Point(origin.X, origin.Y + 30); float num2 = 0.8f + GenBase._random.NextFloat() * 0.5f; if (!structures.CanPlace(new Rectangle(point.X - (int)(20f * num2), point.Y - 20, (int)(40f * num2), 40))) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), 2)) { return(false); } WorldUtils.Gen(point, new Shapes.Slime(20, num2, 1f), Actions.Chain(new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(shapeData))); WorldUtils.Gen(point2, new Shapes.Mound(14, 14), Actions.Chain(new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0), new Actions.SetFrames(true).Output(shapeData2))); shapeData.Subtract(shapeData2, point, point2); WorldUtils.Gen(point, new ModShapes.InnerOutline(shapeData), Actions.Chain(new Actions.SetTile(2), new Actions.SetFrames(true))); WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid())); WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceWall(68), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, 1), new ActionVines(3, 5))); ShapeData data = new ShapeData(); WorldUtils.Gen(new Point(origin.X, result.Y + 10), new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397).Output(data))); WorldUtils.Gen(new Point(origin.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(true)); if (GenBase._random.Next(3) == 0) { WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17); } else { WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15); } WorldUtils.Gen(point2, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.Offset(0, -1), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, -1), new ActionGrass())); structures.AddStructure(new Rectangle(point.X - (int)(20f * num2), point.Y - 20, (int)(40f * num2), 40), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y, false)) { return(false); } Point result; if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result)) { return(false); } result.Y += 2; Ref <int> count = new Ref <int>(0); WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count))); if (count.Value < 20 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0)) { return(false); } WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)229, true, true))); ShapeData data = new ShapeData(); WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2, byte.MaxValue))); WorldUtils.Gen(new Point(result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data, true), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort)59, true, true))); structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0); return(true); }
public List <int> GetPossibleChestsToTrapify(StructureMap structures) { List <int> intList = new List <int>(); bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length]; for (int index = 0; index < validTiles.Length; ++index) { validTiles[index] = TileID.Sets.GeneralPlacementTiles[index]; } validTiles[21] = true; validTiles[467] = true; for (int index = 0; index < 8000; ++index) { Chest chest = Main.chest[index]; if (chest != null) { Point position1 = new Point(chest.x, chest.y); if (DeadMansChestBiome.IsAGoodSpot(position1)) { this.ClearCaches(); Point position2 = new Point(position1.X, position1.Y + 1); this.FindBoulderTrapSpots(position2); this.FindDartTrapSpots(position2); if (this.AreThereEnoughTraps() && (structures == null || structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(position1.X, position1.Y, 1, 1), validTiles, 10))) { intList.Add(index); } } } } return(intList); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[(int)origin.X, (int)origin.Y].active() && WorldGen.SolidTile((int)origin.X, (int)origin.Y)) { return(false); } Point result; if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result)) { return(false); } // ISSUE: explicit reference operation // ISSUE: variable of a reference type Point& local = @result; // ISSUE: explicit reference operation int num = (^ local).Y + 2; // ISSUE: explicit reference operation (^ local).Y = (__Null)num; Ref <int> count = new Ref <int>(0); WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count))); if (count.Value < 20 || !structures.CanPlace(new Rectangle(result.X - 8, result.Y - 8, 16, 16), 0)) { return(false); } WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)229, true, true))); ShapeData data = new ShapeData(); WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2, byte.MaxValue))); WorldUtils.Gen(new Point((int)result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data, true), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort)59, true, true))); structures.AddStructure(new Rectangle(result.X - 8, result.Y - 8, 16, 16), 0); return(true); }
public List <int> GetPossibleChestsToTrapify(StructureMap structures) { List <int> list = new List <int>(); bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; for (int i = 0; i < array.Length; i++) { array[i] = TileID.Sets.GeneralPlacementTiles[i]; } array[21] = true; array[467] = true; for (int j = 0; j < 8000; j++) { Chest chest = Main.chest[j]; if (chest == null) { continue; } Point position = new Point(chest.x, chest.y); if (IsAGoodSpot(position)) { ClearCaches(); Point position2 = new Point(position.X, position.Y + 1); FindBoulderTrapSpots(position2); FindDartTrapSpots(position2); if (AreThereEnoughTraps() && (structures == null || structures.CanPlace(new Rectangle(position.X, position.Y, 1, 1), array, 10))) { list.Add(j); } } } return(list); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y)) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out var result)) { return(false); } result.Y += 2; Ref <int> @ref = new Ref <int>(0); WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(@ref))); if (@ref.Value < 20) { return(false); } if (!structures.CanPlace(new Rectangle(result.X - 8, result.Y - 8, 16, 16))) { return(false); } WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, setSelfFrames: true))); ShapeData data = new ShapeData(); WorldUtils.Gen(result, new Shapes.Circle(4, 3), Actions.Chain(new Modifiers.Blotches(), new Modifiers.IsSolid(), new Actions.ClearTile(frameNeighbors: true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), new Actions.SetLiquid(2))); WorldUtils.Gen(new Point(result.X, result.Y + 1), new ModShapes.InnerOutline(data), Actions.Chain(new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, setSelfFrames: true))); structures.AddProtectedStructure(new Rectangle(result.X - 8, result.Y - 8, 16, 16)); return(true); }
public override bool Place(Point origin, StructureMap structures) { Rectangle structureBound = new Rectangle(origin.X - WIDTH / 2, origin.Y - HEIGHT / 2, WIDTH, HEIGHT); if (!structures.CanPlace(structureBound)) { return(false); } Dictionary <ushort, int> environmentTile = new Dictionary <ushort, int>(); WorldUtils.Gen(structureBound.Location, new Shapes.Rectangle(WIDTH, HEIGHT), new Actions.TileScanner( new ushort[] { (ushort)ModLoader.GetMod("TUA").TileType("StardustRock"), (ushort)ModLoader.GetMod("TUA").TileType("StardustIce") } ).Output(environmentTile)); int total = 0; foreach (KeyValuePair <ushort, int> pair in environmentTile) { total += pair.Value; } if (total < 4000) { return(false); } generateForest(origin); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new Conditions.IsSolid()), out origin)) { return(false); } Point result; if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile(new ushort[1] { 25 }).AreaAnd(8, 1)), out result)) { return(false); } ShapeData data1 = new ShapeData(); ShapeData shapeData1 = new ShapeData(); ShapeData shapeData2 = new ShapeData(); for (int index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain(new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3, 0.3).Output(data1))); } for (int index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain(new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3, 0.3).Output(shapeData1))); } for (int index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain(new Modifiers.Offset(0, (int)(7.5 * (double)index) - 10), new Modifiers.Blotches(3, 0.3).Output(shapeData2))); } ShapeData data2 = new ShapeData(shapeData1); shapeData1.Subtract(shapeData2, origin, origin); data2.Subtract(shapeData1, origin, origin); Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2); if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2)) { return(false); } WorldUtils.Gen(origin, new ModShapes.All(data1), Actions.Chain(new Actions.SetTile((ushort)25, true, true), new Actions.PlaceWall(3, true))); WorldUtils.Gen(origin, new ModShapes.All(shapeData1), new Actions.SetTile(0, true, true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.ClearTile(true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData1), Actions.Chain(new Modifiers.IsTouchingAir(true), new Modifiers.NotTouching(0 != 0, new ushort[1] { 25 }), new Actions.SetTile(23, true, true))); WorldUtils.Gen(origin, new ModShapes.All(data2), new Actions.PlaceWall(69, true)); structures.AddStructure(bounds, 2); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (WorldGen.SolidTile((int)origin.X, (int)origin.Y)) { return(false); } ushort type = Utils.SelectRandom <ushort>(GenBase._random, new ushort[4] { (ushort)(WorldGen.goldBar == 19 ? 8 : 169), (ushort)(WorldGen.silverBar == 21 ? 9 : 168), (ushort)(WorldGen.ironBar == 22 ? 6 : 167), (ushort)(WorldGen.copperBar == 20 ? 7 : 166) }); double num1 = GenBase._random.NextDouble() * 2.0 - 1.0; if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin)) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin)) { return(false); } ShapeData shapeData = new ShapeData(); Ref <int> count1 = new Ref <int>(0); Ref <int> count2 = new Ref <int>(0); WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2))); if (count2.Value < count1.Value / 2) { return(false); } Rectangle area; // ISSUE: explicit reference operation ((Rectangle)@area).\u002Ector(origin.X - 15, origin.Y - 10, 30, 20); if (!structures.CanPlace(area, 0)) { return(false); } WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true)); WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true))); Point result1; int num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0); int num3 = GenBase._random.Next(4) == 0 ? 3 : 7; Point result2; int num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0; if ((num2 & num4) == 0) { return(false); } // ISSUE: explicit reference operation // ISSUE: variable of a reference type __Null& local1 = @result1.Y; // ISSUE: cast to a reference type // ISSUE: explicit reference operation int num5 = ^ (int&)local1 - 1;
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y)) { return(false); } Point origin2; if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new GenCondition[] { new Conditions.IsSolid() }), out origin2)) { return(false); } origin2.Y += 2; Ref <int> @ref = new Ref <int>(0); WorldUtils.Gen(origin2, new Shapes.Circle(8), Actions.Chain(new GenAction[] { new Modifiers.IsSolid(), new Actions.Scanner(@ref) })); if (@ref.Value < 20) { return(false); } if (!structures.CanPlace(new Rectangle(origin2.X - 8, origin2.Y - 8, 16, 16), 0)) { return(false); } WorldUtils.Gen(origin2, new Shapes.Circle(8), Actions.Chain(new GenAction[] { new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, true, true) })); ShapeData data = new ShapeData(); WorldUtils.Gen(origin2, new Shapes.Circle(4, 3), Actions.Chain(new GenAction[] { new Modifiers.Blotches(2, 0.3), new Modifiers.IsSolid(), new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), new Actions.SetLiquid(2, 255) })); WorldUtils.Gen(new Point(origin2.X, origin2.Y + 1), new ModShapes.InnerOutline(data, true), Actions.Chain(new GenAction[] { new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, true, true) })); structures.AddStructure(new Rectangle(origin2.X - 8, origin2.Y - 8, 16, 16), 0); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new Conditions.IsSolid()), out origin)) { return(false); } Point result; if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile(25).AreaAnd(8, 1)), out result)) { return(false); } ShapeData shapeData = new ShapeData(); ShapeData shapeData2 = new ShapeData(); ShapeData shapeData3 = new ShapeData(); for (int i = 0; i < 6; i++) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + i), Actions.Chain(new Modifiers.Offset(0, 5 * i + 5), new Modifiers.Blotches(3).Output(shapeData))); } for (int j = 0; j < 6; j++) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + j), Actions.Chain(new Modifiers.Offset(0, 2 * j + 18), new Modifiers.Blotches(3).Output(shapeData2))); } for (int k = 0; k < 6; k++) { WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2), Actions.Chain(new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), new Modifiers.Blotches(3).Output(shapeData3))); } ShapeData shapeData4 = new ShapeData(shapeData2); shapeData2.Subtract(shapeData3, origin, origin); shapeData4.Subtract(shapeData2, origin, origin); Rectangle bounds = ShapeData.GetBounds(origin, shapeData, shapeData3); if (!structures.CanPlace(bounds, ValidTiles, 2)) { return(false); } WorldUtils.Gen(origin, new ModShapes.All(shapeData), Actions.Chain(new Actions.SetTile(25, true), new Actions.PlaceWall(3))); WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.SetTile(0, true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData3), new Actions.ClearTile(true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.IsTouchingAir(true), new Modifiers.NotTouching(false, 25), new Actions.SetTile(23, true))); WorldUtils.Gen(origin, new ModShapes.All(shapeData4), new Actions.PlaceWall(69)); structures.AddStructure(bounds, 2); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point y; if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y)) { return(false); } Searches.Down down = new Searches.Down(80); GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() }; if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out y)) { return(false); } y.Y = y.Y + 2; Ref <int> @ref = new Ref <int>(0); Shapes.Circle circle = new Shapes.Circle(8); GenAction[] genActionArray = new GenAction[] { new Modifiers.IsSolid(), new Actions.Scanner(@ref) }; WorldUtils.Gen(y, circle, Actions.Chain(genActionArray)); if (@ref.Value < 20) { return(false); } if (!structures.CanPlace(new Rectangle(y.X - 8, y.Y - 8, 16, 16), 0)) { return(false); } Shapes.Circle circle1 = new Shapes.Circle(8); GenAction[] radialDither = new GenAction[] { new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, true, true) }; WorldUtils.Gen(y, circle1, Actions.Chain(radialDither)); ShapeData shapeDatum = new ShapeData(); Shapes.Circle circle2 = new Shapes.Circle(4, 3); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(2, 0.3), new Modifiers.IsSolid(), new Actions.ClearTile(true), (new Modifiers.RectangleMask(-6, 6, 0, 3)).Output(shapeDatum), new Actions.SetLiquid(2, 255) }; WorldUtils.Gen(y, circle2, Actions.Chain(blotch)); Point point = new Point(y.X, y.Y + 1); ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true); GenAction[] isEmpty = new GenAction[] { new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, true, true) }; WorldUtils.Gen(point, innerOutline, Actions.Chain(isEmpty)); structures.AddStructure(new Rectangle(y.X - 8, y.Y - 8, 16, 16), 0); 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); }
public override bool Place(Point origin, StructureMap structures) { Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[2] { (ushort)0, (ushort)1 }).Output(resultsOutput)); if (resultsOutput[(ushort)0] + resultsOutput[(ushort)1] < 1250) { return(false); } Point result1; bool flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result1); Point result2; if (WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(origin.Y - result1.Y), (GenCondition) new Conditions.IsTile(new ushort[1] { (ushort)53 })), out result2) || !flag) { return(false); } result1.Y += 50; ShapeData data1 = new ShapeData(); ShapeData shapeData = new ShapeData(); Point point1 = new Point(origin.X, origin.Y + 20); Point point2 = new Point(origin.X, origin.Y + 30); float xScale = (float)(0.800000011920929 + (double)GenBase._random.NextFloat() * 0.5); if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 0) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result1.Y + 10, 1, origin.Y - result1.Y - 9), 2)) { return(false); } WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1))); WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort)0, false, true), new Actions.SetFrames(true).Output(shapeData))); data1.Subtract(shapeData, point1, point2); WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1, true), Actions.Chain((GenAction) new Actions.SetTile((ushort)2, false, true), (GenAction) new Actions.SetFrames(true))); WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue))); WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((byte)68, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1] { (ushort)2 }), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 52))); ShapeData data2 = new ShapeData(); WorldUtils.Gen(new Point(origin.X, result1.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result1.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.2), new Actions.ClearTile(false).Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1] { (ushort)53 }), new Actions.SetTile((ushort)397, false, true).Output(data2))); WorldUtils.Gen(new Point(origin.X, result1.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true)); if (GenBase._random.Next(3) == 0) { WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17); } else { WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15); } WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1] { (ushort)2 }), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass())); structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { var count1 = new Ref <int>(0); var count2 = new Ref <int>(0); WorldUtils.Gen(origin, new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1))); if (count1.Value < count2.Value - 5) { return(false); } var radius = _random.Next(6, 10); var num1 = _random.Next(5); if (!structures.CanPlace( new Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 0)) { return(false); } var data = new ShapeData(); WorldUtils.Gen(origin, new Shapes.Slime(radius), Actions.Chain( new Modifiers.Blotches(num1, num1, num1, 1, 0.3).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles((ushort)53), (GenAction) new Actions.SetTile(397, true, true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall(16, true))); WorldUtils.Gen(origin, new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Actions.SetLiquid(0, 0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall(16, true))); Point result; if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result)) { return(false); } var j = result.Y - 1; var flag = _random.Next() % 2 == 0; if (_random.Next() % 10 != 0) { var num2 = _random.Next(1, 4); var num3 = flag ? 4 : -(radius >> 1); for (var index1 = 0; index1 < num2; ++index1) { var num4 = _random.Next(1, 3); for (var index2 = 0; index2 < num4; ++index2) { WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 331, false, false, -1, 0); } } } var num5 = (radius - 3) * (flag ? -1 : 1); if (_random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X + num5, j, 186, false, false, -1, 0); } if (_random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X, j, 215, true, false, -1, 0); if (_tiles[origin.X, j].active() && _tiles[origin.X, j].type == 215) { _tiles[origin.X, j].frameY += 36; _tiles[origin.X - 1, j].frameY += 36; _tiles[origin.X + 1, j].frameY += 36; _tiles[origin.X, j - 1].frameY += 36; _tiles[origin.X - 1, j - 1].frameY += 36; _tiles[origin.X + 1, j - 1].frameY += 36; } } structures.AddStructure( new Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { Ref <int> @ref = new Ref <int>(0); Ref <int> ref2 = new Ref <int>(0); Ref <int> count = new Ref <int>(0); Ref <int> ref3 = new Ref <int>(0); WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Actions.Scanner(count), new Modifiers.IsSolid(), new Actions.Scanner(@ref), new Modifiers.OnlyTiles(60, 59), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(60), new Actions.Scanner(ref3))); if ((float)ref2.Value / (float)@ref.Value < 0.75f || ref3.Value < 2) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100))) { return(false); } int x = origin.X; int y = origin.Y; int num = 150; for (int i = x - num; i < x + num; i += 10) { if (i <= 0 || i > Main.maxTilesX - 1) { continue; } for (int j = y - num; j < y + num; j += 10) { if (j > 0 && j <= Main.maxTilesY - 1) { if (Main.tile[i, j].active() && Main.tile[i, j].type == 226) { return(false); } if (Main.tile[i, j].wall == 87 || Main.tile[i, j].wall == 3 || Main.tile[i, j].wall == 83) { return(false); } } } } int x2 = origin.X; int y2 = origin.Y; int num2 = 0; int[] array = new int[10]; int[] array2 = new int[10]; Vector2 vector = new Vector2(x2, y2); Vector2 vector2 = vector; int num3 = WorldGen.genRand.Next(2, 5); for (int k = 0; k < num3; k++) { int num4 = WorldGen.genRand.Next(2, 5); for (int l = 0; l < num4; l++) { vector2 = WorldGen.Hive((int)vector.X, (int)vector.Y); } vector = vector2; array[num2] = (int)vector.X; array2[num2] = (int)vector.Y; num2++; } for (int m = 0; m < num2; m++) { int num5 = array[m]; int num6 = array2[m]; bool flag = false; int num7 = 1; if (WorldGen.genRand.Next(2) == 0) { num7 = -1; } while (num5 > 10 && num5 < Main.maxTilesX - 10 && num6 > 10 && num6 < Main.maxTilesY - 10 && (!Main.tile[num5, num6].active() || !Main.tile[num5, num6 + 1].active() || !Main.tile[num5 + 1, num6].active() || !Main.tile[num5 + 1, num6 + 1].active())) { num5 += num7; if (Math.Abs(num5 - array[m]) > 50) { flag = true; break; } } if (flag) { continue; } num5 += num7; for (int n = num5 - 1; n <= num5 + 2; n++) { for (int num8 = num6 - 1; num8 <= num6 + 2; num8++) { if (n < 10 || n > Main.maxTilesX - 10) { flag = true; } else if (Main.tile[n, num8].active() && Main.tile[n, num8].type != 225) { flag = true; break; } } } if (flag) { continue; } for (int num9 = num5 - 1; num9 <= num5 + 2; num9++) { for (int num10 = num6 - 1; num10 <= num6 + 2; num10++) { if (num9 >= num5 && num9 <= num5 + 1 && num10 >= num6 && num10 <= num6 + 1) { Main.tile[num9, num10].active(false); Main.tile[num9, num10].liquid = byte.MaxValue; Main.tile[num9, num10].honey(true); } else { Main.tile[num9, num10].active(true); Main.tile[num9, num10].type = 225; } } } num7 *= -1; num6++; int num11 = 0; while ((num11 < 4 || WorldGen.SolidTile(num5, num6)) && num5 > 10 && num5 < Main.maxTilesX - 10) { num11++; num5 += num7; if (WorldGen.SolidTile(num5, num6)) { WorldGen.PoundTile(num5, num6); if (!Main.tile[num5, num6 + 1].active()) { Main.tile[num5, num6 + 1].active(true); Main.tile[num5, num6 + 1].type = 225; } } } } WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp((int)vector.X, 5, Main.maxTilesX - 5); WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp((int)vector.Y, 5, Main.maxTilesY - 5); WorldGen.numLarva++; int num12 = (int)vector.X; int num13 = (int)vector.Y; for (int num14 = num12 - 1; num14 <= num12 + 1 && num14 > 0 && num14 < Main.maxTilesX; num14++) { for (int num15 = num13 - 2; num15 <= num13 + 1 && num15 > 0 && num15 < Main.maxTilesY; num15++) { if (num15 != num13 + 1) { Main.tile[num14, num15].active(false); continue; } Main.tile[num14, num15].active(true); Main.tile[num14, num15].type = 225; Main.tile[num14, num15].slope(0); Main.tile[num14, num15].halfBrick(false); } } structures.AddStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (WorldGen.SolidTile(origin.X, origin.Y) && _tiles[origin.X, origin.Y].wall == 3) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), (GenCondition) new Conditions.IsSolid()), out origin)) { return(false); } Point result; if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile((ushort)25).AreaAnd(8, 1)), out result)) { return(false); } var data1 = new ShapeData(); var shapeData1 = new ShapeData(); var shapeData2 = new ShapeData(); for (var index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(_random.Next(10, 12) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3, 0.3).Output(data1))); } for (var index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(_random.Next(5, 7) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3, 0.3).Output(shapeData1))); } for (var index = 0; index < 6; ++index) { WorldUtils.Gen(origin, new Shapes.Circle(_random.Next(4, 6) + index / 2), Actions.Chain((GenAction) new Modifiers.Offset(0, (int)(7.5 * index) - 10), new Modifiers.Blotches(3, 0.3).Output(shapeData2))); } var data2 = new ShapeData(shapeData1); shapeData1.Subtract(shapeData2, origin, origin); data2.Subtract(shapeData1, origin, origin); var bounds = ShapeData.GetBounds(origin, data1, shapeData2); if (!structures.CanPlace(bounds, ValidTiles, 2)) { return(false); } WorldUtils.Gen(origin, new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.SetTile(25, true, true), (GenAction) new Actions.PlaceWall(3, true))); WorldUtils.Gen(origin, new ModShapes.All(shapeData1), new Actions.SetTile(0, true, true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.ClearTile(true)); WorldUtils.Gen(origin, new ModShapes.All(shapeData1), Actions.Chain( (GenAction) new Modifiers.IsTouchingAir(true), (GenAction) new Modifiers.NotTouching(false, (ushort)25), (GenAction) new Actions.SetTile(23, true, true))); WorldUtils.Gen(origin, new ModShapes.All(data2), new Actions.PlaceWall(69, true)); structures.AddStructure(bounds, 2); return(true); }
public override bool Place(Point origin, StructureMap structures) { var count1 = new Ref <int>(0); var count2 = new Ref <int>(0); var count3 = new Ref <int>(0); var count4 = new Ref <int>(0); WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain( (GenAction) new Actions.Scanner(count3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.OnlyTiles((ushort)60, (ushort)59), (GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.OnlyTiles((ushort)60), (GenAction) new Actions.Scanner(count4))); if (count2.Value / (double)count1.Value < 0.75 || count4.Value < 2 || !structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 0)) { return(false); } var x1 = origin.X; var y1 = origin.Y; var num1 = 150; var index1 = x1 - num1; while (index1 < x1 + num1) { if (index1 > 0 && index1 <= Main.maxTilesX - 1) { var index2 = y1 - num1; while (index2 < y1 + num1) { if (index2 > 0 && index2 <= Main.maxTilesY - 1 && (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == 226 || Main.tile[index1, index2].wall == 87 || Main.tile[index1, index2].wall == 3 || Main.tile[index1, index2].wall == 83)) { return(false); } index2 += 10; } } index1 += 10; } var x2 = origin.X; var y2 = origin.Y; var index3 = 0; var numArray1 = new int[10]; var numArray2 = new int[10]; var vector2_1 = new Vector2(x2, y2); var vector2_2 = vector2_1; var num2 = WorldGen.genRand.Next(2, 5); for (var index2 = 0; index2 < num2; ++index2) { var num3 = WorldGen.genRand.Next(2, 5); for (var index4 = 0; index4 < num3; ++index4) { vector2_2 = WorldGen.Hive((int)vector2_1.X, (int)vector2_1.Y); } vector2_1 = vector2_2; numArray1[index3] = (int)vector2_1.X; numArray2[index3] = (int)vector2_1.Y; ++index3; } for (var index2 = 0; index2 < index3; ++index2) { var index4 = numArray1[index2]; var index5 = numArray2[index2]; var flag = false; var num3 = 1; if (WorldGen.genRand.Next(2) == 0) { num3 = -1; } while (index4 > 10 && index4 < Main.maxTilesX - 10 && index5 > 10 && index5 < Main.maxTilesY - 10 && (!Main.tile[index4, index5].active() || !Main.tile[index4, index5 + 1].active() || !Main.tile[index4 + 1, index5].active() || !Main.tile[index4 + 1, index5 + 1].active())) { index4 += num3; if (Math.Abs(index4 - numArray1[index2]) > 50) { flag = true; break; } } if (!flag) { var i = index4 + num3; for (var index6 = i - 1; index6 <= i + 2; ++index6) { for (var index7 = index5 - 1; index7 <= index5 + 2; ++index7) { if (index6 < 10 || index6 > Main.maxTilesX - 10) { flag = true; } else if (Main.tile[index6, index7].active() && Main.tile[index6, index7].type != 225) { flag = true; break; } } } if (!flag) { for (var index6 = i - 1; index6 <= i + 2; ++index6) { for (var index7 = index5 - 1; index7 <= index5 + 2; ++index7) { if (index6 >= i && index6 <= i + 1 && index7 >= index5 && index7 <= index5 + 1) { Main.tile[index6, index7].active(false); Main.tile[index6, index7].liquid = byte.MaxValue; Main.tile[index6, index7].honey(true); } else { Main.tile[index6, index7].active(true); Main.tile[index6, index7].type = 225; } } } var num4 = num3 * -1; var j = index5 + 1; var num5 = 0; while ((num5 < 4 || WorldGen.SolidTile(i, j)) && i > 10 && i < Main.maxTilesX - 10) { ++num5; i += num4; if (WorldGen.SolidTile(i, j)) { WorldGen.PoundTile(i, j); if (!Main.tile[i, j + 1].active()) { Main.tile[i, j + 1].active(true); Main.tile[i, j + 1].type = 225; } } } } } } WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp((int)vector2_1.X, 5, Main.maxTilesX - 5); WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp((int)vector2_1.Y, 5, Main.maxTilesY - 5); ++WorldGen.numLarva; var x3 = (int)vector2_1.X; var y3 = (int)vector2_1.Y; for (var index2 = x3 - 1; index2 <= x3 + 1 && index2 > 0 && index2 < Main.maxTilesX; ++index2) { for (var index4 = y3 - 2; index4 <= y3 + 1 && index4 > 0 && index4 < Main.maxTilesY; ++index4) { if (index4 != y3 + 1) { Main.tile[index2, index4].active(false); } else { Main.tile[index2, index4].active(true); Main.tile[index2, index4].type = 225; Main.tile[index2, index4].slope(0); Main.tile[index2, index4].halfBrick(false); } } } structures.AddStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); 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); }
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) { Ref <int> @ref = new Ref <int>(0); Ref <int> ref2 = new Ref <int>(0); WorldUtils.Gen(origin, new Shapes.Circle(10), Actions.Chain(new Actions.Scanner(ref2), new Modifiers.IsSolid(), new Actions.Scanner(@ref))); if (@ref.Value < ref2.Value - 5) { return(false); } int num = GenBase._random.Next(6, 10); int num2 = GenBase._random.Next(5); if (!structures.CanPlace(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2))) { return(false); } ushort type = (byte)(196 + WorldGen.genRand.Next(4)); for (int i = origin.X - num; i <= origin.X + num; i++) { for (int j = origin.Y - num; j <= origin.Y + num; j++) { if (Main.tile[i, j].active()) { int type2 = Main.tile[i, j].type; if (type2 == 53 || type2 == 396 || type2 == 397 || type2 == 404) { type = 187; } if (type2 == 161 || type2 == 147) { type = 40; } if (type2 == 60) { type = (byte)(204 + WorldGen.genRand.Next(4)); } if (type2 == 367) { type = 178; } if (type2 == 368) { type = 180; } } } } ShapeData data = new ShapeData(); WorldUtils.Gen(origin, new Shapes.Slime(num), Actions.Chain(new Modifiers.Blotches(num2, num2, num2, 1).Output(data), new Modifiers.Offset(0, -2), new Modifiers.OnlyTiles(53), new Actions.SetTile(397, setSelfFrames: true), new Modifiers.OnlyWalls(default(ushort)), new Actions.PlaceWall(type))); WorldUtils.Gen(origin, new ModShapes.All(data), Actions.Chain(new Actions.ClearTile(), new Actions.SetLiquid(0, 0), new Actions.SetFrames(frameNeighbors: true), new Modifiers.OnlyWalls(default(ushort)), new Actions.PlaceWall(type))); if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out Point result)) { return(false); } int num3 = result.Y - 1; bool flag = GenBase._random.Next() % 2 == 0; if (GenBase._random.Next() % 10 != 0) { int num4 = GenBase._random.Next(1, 4); int num5 = flag ? 4 : (-(num >> 1)); for (int k = 0; k < num4; k++) { int num6 = GenBase._random.Next(1, 3); for (int l = 0; l < num6; l++) { WorldGen.PlaceTile(origin.X + num5 - k, num3 - l, 332, mute: true); } } } int num7 = (num - 3) * ((!flag) ? 1 : (-1)); if (GenBase._random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X + num7, num3, 186); } if (GenBase._random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X, num3, 215, mute: true); if (GenBase._tiles[origin.X, num3].active() && GenBase._tiles[origin.X, num3].type == 215) { GenBase._tiles[origin.X, num3].frameY += 36; GenBase._tiles[origin.X - 1, num3].frameY += 36; GenBase._tiles[origin.X + 1, num3].frameY += 36; GenBase._tiles[origin.X, num3 - 1].frameY += 36; GenBase._tiles[origin.X - 1, num3 - 1].frameY += 36; GenBase._tiles[origin.X + 1, num3 - 1].frameY += 36; } } structures.AddProtectedStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point point; bool flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), new GenCondition[] { new Conditions.IsSolid() }), out point); if (!flag || point == origin) { return(false); } Rectangle room = this.GetRoom(point); Rectangle rectangle = this.GetRoom(new Point(room.Center.X, room.Y + 1)); Rectangle rectangle2 = this.GetRoom(new Point(room.Center.X, room.Y + room.Height + 10)); rectangle2.Y = room.Y + room.Height - 1; float num = this.RoomSolidPrecentage(rectangle); float num2 = this.RoomSolidPrecentage(rectangle2); room.Y += 3; rectangle.Y += 3; rectangle2.Y += 3; List <Rectangle> list = new List <Rectangle>(); if (GenBase._random.NextFloat() > num + 0.2f) { list.Add(rectangle); } else { rectangle = room; } list.Add(room); if (GenBase._random.NextFloat() > num2 + 0.2f) { list.Add(rectangle2); } else { rectangle2 = room; } Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); foreach (Rectangle current in list) { WorldUtils.Gen(new Point(current.X - 5, current.Y - 5), new Shapes.Rectangle(current.Width + 10, current.Height + 10), new Actions.TileScanner(new ushort[] { 0, 59, 147, 1, 161, 53, 396, 397, 368, 367, 60, 70 }).Output(dictionary)); } List <Tuple <CaveHouseBiome.BuildData, int> > list2 = new List <Tuple <CaveHouseBiome.BuildData, int> >(); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, dictionary[0] + dictionary[1])); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, dictionary[59] + dictionary[60] * 10)); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, dictionary[59] + dictionary[70] * 10)); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, dictionary[147] + dictionary[161])); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, dictionary[397] + dictionary[396] + dictionary[53])); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, dictionary[368])); list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, dictionary[367])); list2.Sort(new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults)); CaveHouseBiome.BuildData item = list2[0].Item1; foreach (Rectangle current2 in list) { if (item != CaveHouseBiome.BuildData.Granite) { Point point2; bool flag2 = WorldUtils.Find(new Point(current2.X - 2, current2.Y - 2), Searches.Chain(new Searches.Rectangle(current2.Width + 4, current2.Height + 4).RequireAll(false), new GenCondition[] { new Conditions.HasLava() }), out point2); if (flag2) { bool result = false; return(result); } } if (!structures.CanPlace(current2, CaveHouseBiome._blacklistedTiles, 5)) { bool result = false; return(result); } } int num3 = room.X; int num4 = room.X + room.Width - 1; List <Rectangle> list3 = new List <Rectangle>(); foreach (Rectangle current3 in list) { num3 = Math.Min(num3, current3.X); num4 = Math.Max(num4, current3.X + current3.Width - 1); } int num5 = 6; while (num5 > 4 && (num4 - num3) % num5 != 0) { num5--; } for (int i = num3; i <= num4; i += num5) { for (int j = 0; j < list.Count; j++) { Rectangle rectangle3 = list[j]; if (i >= rectangle3.X && i < rectangle3.X + rectangle3.Width) { int num6 = rectangle3.Y + rectangle3.Height; int num7 = 50; for (int k = j + 1; k < list.Count; k++) { if (i >= list[k].X && i < list[k].X + list[k].Width) { num7 = Math.Min(num7, list[k].Y - num6); } } if (num7 > 0) { Point point3; bool flag3 = WorldUtils.Find(new Point(i, num6), Searches.Chain(new Searches.Down(num7), new GenCondition[] { new Conditions.IsSolid() }), out point3); if (num7 < 50) { flag3 = true; point3 = new Point(i, num6 + num7); } if (flag3) { list3.Add(new Rectangle(i, num6, 1, point3.Y - num6)); } } } } } List <Point> list4 = new List <Point>(); foreach (Rectangle current4 in list) { int num8; bool flag4 = this.FindSideExit(new Rectangle(current4.X + current4.Width, current4.Y + 1, 1, current4.Height - 2), false, out num8); if (flag4) { list4.Add(new Point(current4.X + current4.Width - 1, num8)); } flag4 = this.FindSideExit(new Rectangle(current4.X, current4.Y + 1, 1, current4.Height - 2), true, out num8); if (flag4) { list4.Add(new Point(current4.X, num8)); } } List <Tuple <Point, Point> > list5 = new List <Tuple <Point, Point> >(); for (int l = 1; l < list.Count; l++) { Rectangle rectangle4 = list[l]; Rectangle rectangle5 = list[l - 1]; int num9 = rectangle5.X - rectangle4.X; int num10 = rectangle4.X + rectangle4.Width - (rectangle5.X + rectangle5.Width); if (num9 > num10) { list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X + rectangle4.Width - 1, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Width - rectangle4.Height + 1, rectangle4.Y + rectangle4.Height - 1))); } else { list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Height - 1, rectangle4.Y + rectangle4.Height - 1))); } } List <Point> list6 = new List <Point>(); int num11; bool flag5 = this.FindVerticalExit(new Rectangle(rectangle.X + 2, rectangle.Y, rectangle.Width - 4, 1), true, out num11); if (flag5) { list6.Add(new Point(num11, rectangle.Y)); } flag5 = this.FindVerticalExit(new Rectangle(rectangle2.X + 2, rectangle2.Y + rectangle2.Height - 1, rectangle2.Width - 4, 1), false, out num11); if (flag5) { list6.Add(new Point(num11, rectangle2.Y + rectangle2.Height - 1)); } foreach (Rectangle current5 in list) { WorldUtils.Gen(new Point(current5.X, current5.Y), new Shapes.Rectangle(current5.Width, current5.Height), Actions.Chain(new GenAction[] { new Actions.SetTile(item.Tile, false, true), new Actions.SetFrames(true) })); WorldUtils.Gen(new Point(current5.X + 1, current5.Y + 1), new Shapes.Rectangle(current5.Width - 2, current5.Height - 2), Actions.Chain(new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(item.Wall, true) })); structures.AddStructure(current5, 8); } foreach (Tuple <Point, Point> current6 in list5) { Point item2 = current6.Item1; Point item3 = current6.Item2; int num12 = (item3.X > item2.X) ? 1 : -1; ShapeData shapeData = new ShapeData(); for (int m = 0; m < item3.Y - item2.Y; m++) { shapeData.Add(num12 * (m + 1), m); } WorldUtils.Gen(item2, new ModShapes.All(shapeData), Actions.Chain(new GenAction[] { new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetSlope((num12 == 1) ? 1 : 2), new Actions.SetFrames(true) })); WorldUtils.Gen(new Point(item2.X + ((num12 == 1) ? 1 : -4), item2.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new GenAction[] { new Actions.Clear(), new Actions.PlaceWall(item.Wall, true), new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetFrames(true) })); } foreach (Point current7 in list4) { WorldUtils.Gen(current7, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true)); WorldGen.PlaceTile(current7.X, current7.Y, 10, true, true, -1, item.DoorStyle); } foreach (Point current8 in list6) { WorldUtils.Gen(current8, new Shapes.Rectangle(3, 1), Actions.Chain(new GenAction[] { new Actions.ClearMetadata(), new Actions.PlaceTile(19, item.PlatformStyle), new Actions.SetFrames(true) })); } foreach (Rectangle current9 in list3) { if (current9.Height > 1 && GenBase._tiles[current9.X, current9.Y - 1].type != 19) { WorldUtils.Gen(new Point(current9.X, current9.Y), new Shapes.Rectangle(current9.Width, current9.Height), Actions.Chain(new GenAction[] { new Actions.SetTile(124, false, true), new Actions.SetFrames(true) })); Tile tile = GenBase._tiles[current9.X, current9.Y + current9.Height]; tile.slope(0); tile.halfBrick(false); } } Point[] choices = new Point[] { new Point(14, item.TableStyle), new Point(16, 0), new Point(18, item.WorkbenchStyle), new Point(86, 0), new Point(87, item.PianoStyle), new Point(94, 0), new Point(101, item.BookcaseStyle) }; foreach (Rectangle current10 in list) { int num13 = current10.Width / 8; int num14 = current10.Width / (num13 + 1); int num15 = GenBase._random.Next(2); for (int n = 0; n < num13; n++) { int num16 = (n + 1) * num14 + current10.X; switch (n + num15 % 2) { case 0: { int num17 = current10.Y + Math.Min(current10.Height / 2, current10.Height - 5); Vector2 vector = WorldGen.randHousePicture(); int type = (int)vector.X; int style = (int)vector.Y; if (!WorldGen.nearPicture(num16, num17)) { WorldGen.PlaceTile(num16, num17, type, true, false, -1, style); } break; } case 1: { int num17 = current10.Y + 1; WorldGen.PlaceTile(num16, num17, 34, true, false, -1, GenBase._random.Next(6)); for (int num18 = -1; num18 < 2; num18++) { for (int num19 = 0; num19 < 3; num19++) { Tile expr_E29 = GenBase._tiles[num18 + num16, num19 + num17]; expr_E29.frameX += 54; } } break; } } } int num20 = current10.Width / 8 + 3; WorldGen.SetupStatueList(); while (num20 > 0) { int num21 = GenBase._random.Next(current10.Width - 3) + 1 + current10.X; int num22 = current10.Y + current10.Height - 2; switch (GenBase._random.Next(4)) { case 0: WorldGen.PlaceSmallPile(num21, num22, GenBase._random.Next(31, 34), 1, 185); break; case 1: WorldGen.PlaceTile(num21, num22, 186, true, false, -1, GenBase._random.Next(22, 26)); break; case 2: { int num23 = GenBase._random.Next(2, WorldGen.statueList.Length); WorldGen.PlaceTile(num21, num22, (int)WorldGen.statueList[num23].X, true, false, -1, (int)WorldGen.statueList[num23].Y); if (WorldGen.StatuesWithTraps.Contains(num23)) { WorldGen.PlaceStatueTrap(num21, num22); } break; } case 3: { Point point4 = Utils.SelectRandom <Point>(GenBase._random, choices); WorldGen.PlaceTile(num21, num22, point4.X, true, false, -1, point4.Y); break; } } num20--; } } foreach (Rectangle current11 in list) { item.ProcessRoom(current11); } bool flag6 = false; foreach (Rectangle current12 in list) { int num24 = current12.Height - 1 + current12.Y; int style2 = (num24 > (int)Main.worldSurface) ? item.ChestStyle : 0; for (int num25 = 0; num25 < 10; num25++) { int i2 = GenBase._random.Next(2, current12.Width - 2) + current12.X; if (flag6 = WorldGen.AddBuriedChest(i2, num24, 0, false, style2)) { break; } } if (flag6) { break; } int num26 = current12.X + 2; while (num26 <= current12.X + current12.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num26, num24, 0, false, style2))) { num26++; } if (flag6) { break; } } if (!flag6) { foreach (Rectangle current13 in list) { int num27 = current13.Y - 1; int style3 = (num27 > (int)Main.worldSurface) ? item.ChestStyle : 0; for (int num28 = 0; num28 < 10; num28++) { int i3 = GenBase._random.Next(2, current13.Width - 2) + current13.X; if (flag6 = WorldGen.AddBuriedChest(i3, num27, 0, false, style3)) { break; } } if (flag6) { break; } int num29 = current13.X + 2; while (num29 <= current13.X + current13.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num29, num27, 0, false, style3))) { num29++; } if (flag6) { break; } } } if (!flag6) { for (int num30 = 0; num30 < 1000; num30++) { int i4 = GenBase._random.Next(list[0].X - 30, list[0].X + 30); int num31 = GenBase._random.Next(list[0].Y - 30, list[0].Y + 30); int style4 = (num31 > (int)Main.worldSurface) ? item.ChestStyle : 0; if (flag6 = WorldGen.AddBuriedChest(i4, num31, 0, false, style4)) { break; } } } if (item == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5)) { bool flag7 = false; foreach (Rectangle current14 in list) { int num32 = current14.Height - 2 + current14.Y; for (int num33 = 0; num33 < 10; num33++) { int num34 = GenBase._random.Next(2, current14.Width - 2) + current14.X; WorldGen.PlaceTile(num34, num32, 377, true, true, -1, 0); if (flag7 = (GenBase._tiles[num34, num32].active() && GenBase._tiles[num34, num32].type == 377)) { break; } } if (flag7) { break; } int num35 = current14.X + 2; while (num35 <= current14.X + current14.Width - 2 && !(flag7 = WorldGen.PlaceTile(num35, num32, 377, true, true, -1, 0))) { num35++; } if (flag7) { break; } } if (flag7) { this._sharpenerCount++; } } if (item == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5)) { bool flag8 = false; foreach (Rectangle current15 in list) { int num36 = current15.Height - 2 + current15.Y; for (int num37 = 0; num37 < 10; num37++) { int num38 = GenBase._random.Next(2, current15.Width - 2) + current15.X; WorldGen.PlaceTile(num38, num36, 219, true, true, -1, 0); if (flag8 = (GenBase._tiles[num38, num36].active() && GenBase._tiles[num38, num36].type == 219)) { break; } } if (flag8) { break; } int num39 = current15.X + 2; while (num39 <= current15.X + current15.Width - 2 && !(flag8 = WorldGen.PlaceTile(num39, num36, 219, true, true, -1, 0))) { num39++; } if (flag8) { break; } } if (flag8) { this._extractinatorCount++; } } return(true); }
public override bool Place(Point origin, StructureMap structures) { if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 0) || HiveBiome.TooCloseToImportantLocations(origin)) { return(false); } Ref <int> count1 = new Ref <int>(0); Ref <int> count2 = new Ref <int>(0); Ref <int> count3 = new Ref <int>(0); WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(15), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.OnlyTiles(new ushort[2] { (ushort)60, (ushort)59 }), (GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.OnlyTiles(new ushort[1] { (ushort)60 }), (GenAction) new Actions.Scanner(count3))); if ((double)count2.Value / (double)count1.Value < 0.75 || count3.Value < 2) { return(false); } int index1 = 0; int[] numArray1 = new int[1000]; int[] numArray2 = new int[1000]; Vector2 position1 = origin.ToVector2(); int num1 = WorldGen.genRand.Next(2, 5); if (WorldGen.drunkWorldGen) { num1 += WorldGen.genRand.Next(7, 10); } for (int index2 = 0; index2 < num1; ++index2) { Vector2 vector2 = position1; int num2 = WorldGen.genRand.Next(2, 5); for (int index3 = 0; index3 < num2; ++index3) { vector2 = HiveBiome.CreateHiveTunnel((int)position1.X, (int)position1.Y, WorldGen.genRand); } position1 = vector2; numArray1[index1] = (int)position1.X; numArray2[index1] = (int)position1.Y; ++index1; } HiveBiome.FrameOutAllHiveContents(origin, 50); for (int index2 = 0; index2 < index1; ++index2) { int x1 = numArray1[index2]; int y = numArray2[index2]; int dir = 1; if (WorldGen.genRand.Next(2) == 0) { dir = -1; } bool flag = false; while (WorldGen.InWorld(x1, y, 10) && HiveBiome.BadSpotForHoneyFall(x1, y)) { x1 += dir; if (Math.Abs(x1 - numArray1[index2]) > 50) { flag = true; break; } } if (!flag) { int x2 = x1 + dir; if (!HiveBiome.SpotActuallyNotInHive(x2, y)) { HiveBiome.CreateBlockedHoneyCube(x2, y); HiveBiome.CreateDentForHoneyFall(x2, y, dir); } } } HiveBiome.CreateStandForLarva(position1); if (WorldGen.drunkWorldGen) { for (int index2 = 0; index2 < 1000; ++index2) { Vector2 position2 = position1; position2.X += (float)WorldGen.genRand.Next(-50, 51); position2.Y += (float)WorldGen.genRand.Next(-50, 51); if (WorldGen.InWorld((int)position2.X, (int)position2.Y, 0) && (double)Vector2.Distance(position1, position2) > 10.0 && (!Main.tile[(int)position2.X, (int)position2.Y].active() && Main.tile[(int)position2.X, (int)position2.Y].wall == (ushort)86)) { HiveBiome.CreateStandForLarva(position2); break; } } } structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point point; if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3) { return(false); } Searches.Down down = new Searches.Down(100); GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() }; if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out origin)) { return(false); } Point point1 = new Point(origin.X - 4, origin.Y); Searches.Down down1 = new Searches.Down(5); GenCondition[] genConditionArray = new GenCondition[1]; ushort[] numArray = new ushort[] { 25 }; genConditionArray[0] = (new Conditions.IsTile(numArray)).AreaAnd(8, 1); if (!WorldUtils.Find(point1, Searches.Chain(down1, genConditionArray), out point)) { return(false); } ShapeData shapeDatum = new ShapeData(); ShapeData shapeDatum1 = new ShapeData(); ShapeData shapeDatum2 = new ShapeData(); for (int i = 0; i < 6; i++) { Shapes.Circle circle = new Shapes.Circle(GenBase._random.Next(10, 12) + i); GenAction[] offset = new GenAction[] { new Modifiers.Offset(0, 5 * i + 5), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum) }; WorldUtils.Gen(origin, circle, Actions.Chain(offset)); } for (int j = 0; j < 6; j++) { Shapes.Circle circle1 = new Shapes.Circle(GenBase._random.Next(5, 7) + j); GenAction[] genActionArray = new GenAction[] { new Modifiers.Offset(0, 2 * j + 18), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum1) }; WorldUtils.Gen(origin, circle1, Actions.Chain(genActionArray)); } for (int k = 0; k < 6; k++) { Shapes.Circle circle2 = new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2); GenAction[] offset1 = new GenAction[] { new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum2) }; WorldUtils.Gen(origin, circle2, Actions.Chain(offset1)); } ShapeData shapeDatum3 = new ShapeData(shapeDatum1); shapeDatum1.Subtract(shapeDatum2, origin, origin); shapeDatum3.Subtract(shapeDatum1, origin, origin); ShapeData[] shapeDataArray = new ShapeData[] { shapeDatum, shapeDatum2 }; Rectangle bounds = ShapeData.GetBounds(origin, shapeDataArray); if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2)) { return(false); } ModShapes.All all = new ModShapes.All(shapeDatum); GenAction[] setTile = new GenAction[] { new Actions.SetTile(25, true, true), new Actions.PlaceWall(3, true) }; WorldUtils.Gen(origin, all, Actions.Chain(setTile)); WorldUtils.Gen(origin, new ModShapes.All(shapeDatum1), new Actions.SetTile(0, true, true)); WorldUtils.Gen(origin, new ModShapes.All(shapeDatum2), new Actions.ClearTile(true)); ModShapes.All all1 = new ModShapes.All(shapeDatum1); GenAction[] isTouchingAir = new GenAction[] { new Modifiers.IsTouchingAir(true), null, null }; ushort[] numArray1 = new ushort[] { 25 }; isTouchingAir[1] = new Modifiers.NotTouching(false, numArray1); isTouchingAir[2] = new Actions.SetTile(23, true, true); WorldUtils.Gen(origin, all1, Actions.Chain(isTouchingAir)); WorldUtils.Gen(origin, new ModShapes.All(shapeDatum3), new Actions.PlaceWall(69, true)); structures.AddStructure(bounds, 2); return(true); }
public override bool Place(Point origin, StructureMap structures) { Point y; Point point; Dictionary <ushort, int> nums = new Dictionary <ushort, int>(); Point point1 = new Point(origin.X - 25, origin.Y - 25); Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50); ushort[] numArray = new ushort[] { 0, 1 }; WorldUtils.Gen(point1, rectangle, (new Actions.TileScanner(numArray)).Output(nums)); if (nums[0] + nums[1] < 1250) { return(false); } Searches.Up up = new Searches.Up(1000); GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(1, 50).Not() }; bool flag = WorldUtils.Find(origin, Searches.Chain(up, genConditionArray), out y); Point point2 = origin; Searches.Up up1 = new Searches.Up(origin.Y - y.Y); GenCondition[] isTile = new GenCondition[1]; ushort[] numArray1 = new ushort[] { 53 }; isTile[0] = new Conditions.IsTile(numArray1); if (WorldUtils.Find(point2, Searches.Chain(up1, isTile), out point)) { return(false); } if (!flag) { return(false); } y.Y = y.Y + 50; ShapeData shapeDatum = new ShapeData(); ShapeData shapeDatum1 = new ShapeData(); Point point3 = new Point(origin.X, origin.Y + 20); Point point4 = new Point(origin.X, origin.Y + 30); float single = 0.8f + GenBase._random.NextFloat() * 0.5f; if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 0)) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X, y.Y + 10, 1, origin.Y - y.Y - 9), 2)) { return(false); } Shapes.Slime slime = new Shapes.Slime(20, single, 1f); GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(2, 0.4), (new Actions.ClearTile(true)).Output(shapeDatum) }; WorldUtils.Gen(point3, slime, Actions.Chain(blotch)); Shapes.Mound mound = new Shapes.Mound(14, 14); GenAction[] genActionArray = new GenAction[] { new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0, false, true), (new Actions.SetFrames(true)).Output(shapeDatum1) }; WorldUtils.Gen(point4, mound, Actions.Chain(genActionArray)); shapeDatum.Subtract(shapeDatum1, point3, point4); ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true); GenAction[] setTile = new GenAction[] { new Actions.SetTile(2, false, true), new Actions.SetFrames(true) }; WorldUtils.Gen(point3, innerOutline, Actions.Chain(setTile)); ModShapes.All all = new ModShapes.All(shapeDatum); GenAction[] rectangleMask = new GenAction[] { new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid(0, 255) }; WorldUtils.Gen(point3, all, Actions.Chain(rectangleMask)); ModShapes.All all1 = new ModShapes.All(shapeDatum); GenAction[] placeWall = new GenAction[] { new Actions.PlaceWall(68, true), null, null, null }; ushort[] numArray2 = new ushort[] { 2 }; placeWall[1] = new Modifiers.OnlyTiles(numArray2); placeWall[2] = new Modifiers.Offset(0, 1); placeWall[3] = new ActionVines(3, 5, 52); WorldUtils.Gen(point3, all1, Actions.Chain(placeWall)); ShapeData shapeDatum2 = new ShapeData(); Point point5 = new Point(origin.X, y.Y + 10); Shapes.Rectangle rectangle1 = new Shapes.Rectangle(1, origin.Y - y.Y - 9); GenAction[] onlyTile = new GenAction[] { new Modifiers.Blotches(2, 0.2), (new Actions.ClearTile(false)).Output(shapeDatum2), new Modifiers.Expand(1), null, null }; ushort[] numArray3 = new ushort[] { 53 }; onlyTile[3] = new Modifiers.OnlyTiles(numArray3); onlyTile[4] = (new Actions.SetTile(397, false, true)).Output(shapeDatum2); WorldUtils.Gen(point5, rectangle1, Actions.Chain(onlyTile)); WorldUtils.Gen(new Point(origin.X, y.Y + 10), new ModShapes.All(shapeDatum2), new Actions.SetFrames(true)); if (GenBase._random.Next(3) != 0) { WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15); } else { WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17); } ModShapes.All all2 = new ModShapes.All(shapeDatum1); GenAction[] offset = new GenAction[] { new Modifiers.Offset(0, -1), null, null, null }; ushort[] numArray4 = new ushort[] { 2 }; offset[1] = new Modifiers.OnlyTiles(numArray4); offset[2] = new Modifiers.Offset(0, -1); offset[3] = new ActionGrass(); WorldUtils.Gen(point4, all2, Actions.Chain(offset)); structures.AddStructure(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { if (WorldGen.SolidTile(origin.X, origin.Y)) { return(false); } ushort type = Utils.SelectRandom <ushort>(GenBase._random, new ushort[4] { WorldGen.goldBar == 19 ? (ushort)8 : (ushort)169, WorldGen.silverBar == 21 ? (ushort)9 : (ushort)168, WorldGen.ironBar == 22 ? (ushort)6 : (ushort)167, WorldGen.copperBar == 20 ? (ushort)7 : (ushort)166 }); double num1 = GenBase._random.NextDouble() * 2.0 - 1.0; if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin)) { return(false); } if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin)) { return(false); } ShapeData shapeData = new ShapeData(); Ref <int> count1 = new Ref <int>(0); Ref <int> count2 = new Ref <int>(0); WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2))); if (count2.Value < count1.Value / 2) { return(false); } Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20); if (!structures.CanPlace(area, 0)) { return(false); } WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true)); WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true))); Point result1; bool flag = ((true ? 1 : 0) & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0)) != 0; int num2 = GenBase._random.Next(4) == 0 ? 3 : 7; Point result2; if (((flag ? 1 : 0) & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num2 : num2), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0)) == 0) { return(false); } --result1.Y; --result2.Y; Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1]; tile1.slope((byte)0); tile1.halfBrick(false); for (int index = -1; index <= 1; ++index) { WorldUtils.ClearTile(result2.X + index, result2.Y, false); Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1]; if (!WorldGen.SolidOrSlopedTile(tile2)) { tile2.ResetToType((ushort)1); tile2.active(true); } tile2.slope((byte)0); tile2.halfBrick(false); WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true); } WorldGen.PlaceTile(result1.X, result1.Y, 141, false, false, -1, 0); WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true, -1, 0); WorldUtils.WireLine(result1, result2); structures.AddStructure(area, 5); return(true); }
public override bool Place(Point origin, StructureMap structures) { Ref <int> @ref = new Ref <int>(0); Ref <int> ref1 = new Ref <int>(0); Ref <int> ref2 = new Ref <int>(0); Ref <int> ref3 = new Ref <int>(0); Shapes.Circle circle = new Shapes.Circle(15); GenAction[] scanner = new GenAction[] { new Actions.Scanner(ref2), new Modifiers.IsSolid(), new Actions.Scanner(@ref), null, null, null, null }; ushort[] numArray = new ushort[] { 60, 59 }; scanner[3] = new Modifiers.OnlyTiles(numArray); scanner[4] = new Actions.Scanner(ref1); ushort[] numArray1 = new ushort[] { 60 }; scanner[5] = new Modifiers.OnlyTiles(numArray1); scanner[6] = new Actions.Scanner(ref3); WorldUtils.Gen(origin, circle, Actions.Chain(scanner)); if ((float)ref1.Value / (float)@ref.Value < 0.75f || ref3.Value < 2) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 0)) { return(false); } int x = origin.X; int y = origin.Y; int num = 150; for (int i = x - num; i < x + num; i = i + 10) { if (i > 0 && i <= Main.maxTilesX - 1) { for (int j = y - num; j < y + num; j = j + 10) { if (j > 0 && j <= Main.maxTilesY - 1) { if (Main.tile[i, j].active() && Main.tile[i, j].type == 226) { return(false); } if (Main.tile[i, j].wall == 87 || Main.tile[i, j].wall == 3 || Main.tile[i, j].wall == 83) { return(false); } } } } } int x1 = origin.X; int y1 = origin.Y; int num1 = 0; int[] x2 = new int[10]; int[] y2 = new int[10]; Vector2 vector2 = new Vector2((float)x1, (float)y1); Vector2 vector21 = vector2; int num2 = WorldGen.genRand.Next(2, 5); for (int k = 0; k < num2; k++) { int num3 = WorldGen.genRand.Next(2, 5); for (int l = 0; l < num3; l++) { vector21 = WorldGen.Hive((int)vector2.X, (int)vector2.Y); } vector2 = vector21; x2[num1] = (int)vector2.X; y2[num1] = (int)vector2.Y; num1++; } for (int m = 0; m < num1; m++) { int num4 = x2[m]; int num5 = y2[m]; bool flag = false; int num6 = 1; if (WorldGen.genRand.Next(2) == 0) { num6 = -1; } while (num4 > 10 && num4 < Main.maxTilesX - 10 && num5 > 10 && num5 < Main.maxTilesY - 10 && (!Main.tile[num4, num5].active() || !Main.tile[num4, num5 + 1].active() || !Main.tile[num4 + 1, num5].active() || !Main.tile[num4 + 1, num5 + 1].active())) { num4 = num4 + num6; if (Math.Abs(num4 - x2[m]) <= 50) { continue; } flag = true; break; } if (!flag) { num4 = num4 + num6; for (int n = num4 - 1; n <= num4 + 2; n++) { for (int o = num5 - 1; o <= num5 + 2; o++) { if (n < 10 || n > Main.maxTilesX - 10) { flag = true; } else if (Main.tile[n, o].active() && Main.tile[n, o].type != 225) { flag = true; break; } } } if (!flag) { for (int p = num4 - 1; p <= num4 + 2; p++) { for (int q = num5 - 1; q <= num5 + 2; q++) { if (p < num4 || p > num4 + 1 || q < num5 || q > num5 + 1) { Main.tile[p, q].active(true); Main.tile[p, q].type = 225; } else { Main.tile[p, q].active(false); Main.tile[p, q].liquid = 255; Main.tile[p, q].honey(true); } } } num6 = num6 * -1; num5++; int num7 = 0; while ((num7 < 4 || WorldGen.SolidTile(num4, num5)) && num4 > 10 && num4 < Main.maxTilesX - 10) { num7++; num4 = num4 + num6; if (!WorldGen.SolidTile(num4, num5)) { continue; } WorldGen.PoundTile(num4, num5); if (Main.tile[num4, num5 + 1].active()) { continue; } Main.tile[num4, num5 + 1].active(true); Main.tile[num4, num5 + 1].type = 225; } } } } WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp <int>((int)vector2.X, 5, Main.maxTilesX - 5); WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp <int>((int)vector2.Y, 5, Main.maxTilesY - 5); WorldGen.numLarva = WorldGen.numLarva + 1; int x3 = (int)vector2.X; int y3 = (int)vector2.Y; for (int r = x3 - 1; r <= x3 + 1 && r > 0 && r < Main.maxTilesX; r++) { for (int s = y3 - 2; s <= y3 + 1 && s > 0 && s < Main.maxTilesY; s++) { if (s == y3 + 1) { Main.tile[r, s].active(true); Main.tile[r, s].type = 225; Main.tile[r, s].slope(0); Main.tile[r, s].halfBrick(false); } else { Main.tile[r, s].active(false); } } } structures.AddStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); return(true); }
public override bool Place(Point origin, StructureMap structures) { Ref <int> count1 = new Ref <int>(0); Ref <int> count2 = new Ref <int>(0); WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1))); if (count1.Value < count2.Value - 5) { return(false); } int radius = GenBase._random.Next(6, 10); int num1 = GenBase._random.Next(5); if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 0)) { return(false); } ushort type1 = (ushort)(byte)(196 + WorldGen.genRand.Next(4)); for (int index1 = origin.X - radius; index1 <= origin.X + radius; ++index1) { for (int index2 = origin.Y - radius; index2 <= origin.Y + radius; ++index2) { if (Main.tile[index1, index2].active()) { int type2 = (int)Main.tile[index1, index2].type; if (type2 == 53 || type2 == 396 || (type2 == 397 || type2 == 404)) { type1 = (ushort)187; } if (type2 == 161 || type2 == 147) { type1 = (ushort)40; } if (type2 == 60) { type1 = (ushort)(byte)(204 + WorldGen.genRand.Next(4)); } if (type2 == 367) { type1 = (ushort)178; } if (type2 == 368) { type1 = (ushort)180; } } } } ShapeData data = new ShapeData(); WorldUtils.Gen(origin, (GenShape) new Shapes.Slime(radius), Actions.Chain(new Modifiers.Blotches(num1, num1, num1, 1, 0.3).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles(new ushort[1] { (ushort)53 }), (GenAction) new Actions.SetTile((ushort)397, true, true), (GenAction) new Modifiers.OnlyWalls(new ushort[1]), (GenAction) new Actions.PlaceWall(type1, true))); WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Actions.SetLiquid(0, (byte)0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new ushort[1]), (GenAction) new Actions.PlaceWall(type1, true))); Point result; if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result)) { return(false); } int j = result.Y - 1; bool flag = GenBase._random.Next() % 2 == 0; if (GenBase._random.Next() % 10 != 0) { int num2 = GenBase._random.Next(1, 4); int num3 = flag ? 4 : -(radius >> 1); for (int index1 = 0; index1 < num2; ++index1) { int num4 = GenBase._random.Next(1, 3); for (int index2 = 0; index2 < num4; ++index2) { WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 332, true, false, -1, 0); } } } int num5 = (radius - 3) * (flag ? -1 : 1); if (GenBase._random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X + num5, j, 186, false, false, -1, 0); } if (GenBase._random.Next() % 10 != 0) { WorldGen.PlaceTile(origin.X, j, 215, true, false, -1, 0); if (GenBase._tiles[origin.X, j].active() && GenBase._tiles[origin.X, j].type == (ushort)215) { GenBase._tiles[origin.X, j].frameY += (short)36; GenBase._tiles[origin.X - 1, j].frameY += (short)36; GenBase._tiles[origin.X + 1, j].frameY += (short)36; GenBase._tiles[origin.X, j - 1].frameY += (short)36; GenBase._tiles[origin.X - 1, j - 1].frameY += (short)36; GenBase._tiles[origin.X + 1, j - 1].frameY += (short)36; } } structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4); return(true); }
public override bool Place(Point origin, StructureMap structures) { Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>(); WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 1).Output(dictionary)); if (dictionary[0] + dictionary[1] < 1250) { return(false); } Point result; bool flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - result.Y), new Conditions.IsTile(53)), out var _)) { return(false); } if (!flag) { return(false); } result.Y += 50; ShapeData shapeData = new ShapeData(); ShapeData shapeData2 = new ShapeData(); Point point = new Point(origin.X, origin.Y + 20); Point point2 = new Point(origin.X, origin.Y + 30); bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; for (int i = 0; i < array.Length; i++) { array[i] = TileID.Sets.GeneralPlacementTiles[i]; } array[21] = false; array[467] = false; float num = 0.8f + GenBase._random.NextFloat() * 0.5f; if (!structures.CanPlace(new Rectangle(point.X - (int)(20f * num), point.Y - 20, (int)(40f * num), 40), array)) { return(false); } if (!structures.CanPlace(new Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), array, 2)) { return(false); } WorldUtils.Gen(point, new Shapes.Slime(20, num, 1f), Actions.Chain(new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(frameNeighbors: true).Output(shapeData))); WorldUtils.Gen(point2, new Shapes.Mound(14, 14), Actions.Chain(new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0), new Actions.SetFrames(frameNeighbors: true).Output(shapeData2))); shapeData.Subtract(shapeData2, point, point2); WorldUtils.Gen(point, new ModShapes.InnerOutline(shapeData), Actions.Chain(new Actions.SetTile(2), new Actions.SetFrames(frameNeighbors: true))); WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid())); WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceWall(68), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, 1), new ActionVines(3, 5, 382))); if (GenBase._random.NextFloat() <= _chanceOfEntrance) { ShapeData data = new ShapeData(); WorldUtils.Gen(new Point(origin.X, result.Y + 10), new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(191, 192), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397).Output(data))); WorldUtils.Gen(new Point(origin.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true)); } if (GenBase._random.NextFloat() <= _chanceOfRealSword) { WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, mute: true, forced: false, -1, 17); } else { WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, mute: true, forced: false, -1, 15); } WorldUtils.Gen(point2, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.Offset(0, -1), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, -1), new ActionGrass())); structures.AddProtectedStructure(new Rectangle(point.X - (int)(20f * num), point.Y - 20, (int)(40f * num), 40), 10); return(true); }