Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MiningExplosivesBiome.cs
Go to the documentation of this file.
5
7
9{
10 public override bool Place(Point origin, StructureMap structures)
11 {
12 //IL_0169: Unknown result type (might be due to invalid IL or missing references)
13 if (WorldGen.SolidTile(origin.X, origin.Y))
14 {
15 return false;
16 }
17 if (Main.tile[origin.X, origin.Y].wall == 216 || Main.tile[origin.X, origin.Y].wall == 187)
18 {
19 return false;
20 }
21 ushort type = Utils.SelectRandom<ushort>(GenBase._random, (ushort)((GenVars.goldBar == 19) ? 8 : 169), (ushort)((GenVars.silverBar == 21) ? 9 : 168), (ushort)((GenVars.ironBar == 22) ? 6 : 167), (ushort)((GenVars.copperBar == 20) ? 7 : 166));
22 double num = GenBase._random.NextDouble() * 2.0 - 1.0;
23 if (!WorldUtils.Find(origin, Searches.Chain((num > 0.0) ? ((GenSearch)new Searches.Right(40)) : ((GenSearch)new Searches.Left(40)), new Conditions.IsSolid()), out origin))
24 {
25 return false;
26 }
27 if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out origin))
28 {
29 return false;
30 }
31 ShapeData shapeData = new ShapeData();
32 Ref<int> @ref = new Ref<int>(0);
33 Ref<int> ref2 = new Ref<int>(0);
34 WorldUtils.Gen(origin, new ShapeRunner(10.0, 20, new Vector2D(num, 1.0)).Output(shapeData), Actions.Chain(new Modifiers.Blotches(), new Actions.Scanner(@ref), new Modifiers.IsSolid(), new Actions.Scanner(ref2)));
35 if (ref2.Value < @ref.Value / 2)
36 {
37 return false;
38 }
39 Rectangle area = new Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
40 if (!structures.CanPlace(area))
41 {
42 return false;
43 }
44 WorldUtils.Gen(origin, new ModShapes.All(shapeData), new Actions.SetTile(type, setSelfFrames: true));
45 WorldUtils.Gen(new Point(origin.X - (int)(num * -5.0), origin.Y - 5), new Shapes.Circle(5), Actions.Chain(new Modifiers.Blotches(), new Actions.ClearTile(frameNeighbors: true)));
46 Point result;
47 int num2 = 1 & (WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? 3 : (-3)), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out result) ? 1 : 0);
48 int num3 = ((GenBase._random.Next(4) == 0) ? 3 : 7);
49 if (((uint)num2 & (WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? (-num3) : num3), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out var result2) ? 1u : 0u)) == 0)
50 {
51 return false;
52 }
53 result.Y--;
54 result2.Y--;
55 Tile tile = GenBase._tiles[result.X, result.Y + 1];
56 tile.slope(0);
57 tile.halfBrick(halfBrick: false);
58 for (int i = -1; i <= 1; i++)
59 {
60 WorldUtils.ClearTile(result2.X + i, result2.Y);
61 Tile tile2 = GenBase._tiles[result2.X + i, result2.Y + 1];
62 if (!WorldGen.SolidOrSlopedTile(tile2))
63 {
64 tile2.ResetToType(1);
65 tile2.active(active: true);
66 }
67 tile2.slope(0);
68 tile2.halfBrick(halfBrick: false);
69 WorldUtils.TileFrame(result2.X + i, result2.Y + 1, frameNeighbors: true);
70 }
71 WorldGen.PlaceTile(result.X, result.Y, 141);
72 WorldGen.PlaceTile(result2.X, result2.Y, 411, mute: true, forced: true);
73 WorldUtils.WireLine(result, result2);
74 structures.AddProtectedStructure(area, 5);
75 return true;
76 }
77}
override bool Place(Point origin, StructureMap structures)
static Tile[,] tile
Definition Main.cs:1675
T Value
Definition Ref.cs:5
void ResetToType(ushort type)
Definition Tile.cs:266
bool active()
Definition Tile.cs:565
byte slope()
Definition Tile.cs:684
bool halfBrick()
Definition Tile.cs:650
static GenAction Chain(params GenAction[] actions)
Definition Actions.cs:470
static UnifiedRandom _random
Definition GenBase.cs:9
static GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:123
void AddProtectedStructure(Rectangle area, int padding=0)
bool CanPlace(Rectangle area, int padding=0)
static void TileFrame(int x, int y, bool frameNeighbors=false)
Definition WorldUtils.cs:61
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27
static void WireLine(Point start, Point end)
Definition WorldUtils.cs:81
static void ClearTile(int x, int y, bool frameNeighbors=false)
Definition WorldUtils.cs:37
static bool Gen(Point origin, GenShape shape, GenAction action)
Definition WorldUtils.cs:17
static bool SolidTile(Tile testTile)
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static bool SolidOrSlopedTile(Tile tile)