Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CampsiteBiome.cs
Go to the documentation of this file.
3
5
7{
8 public override bool Place(Point origin, StructureMap structures)
9 {
10 Ref<int> @ref = new Ref<int>(0);
11 Ref<int> ref2 = new Ref<int>(0);
12 WorldUtils.Gen(origin, new Shapes.Circle(10), Actions.Chain(new Actions.Scanner(ref2), new Modifiers.IsSolid(), new Actions.Scanner(@ref)));
13 if (@ref.Value < ref2.Value - 5)
14 {
15 return false;
16 }
17 int num = GenBase._random.Next(6, 10);
18 int num2 = GenBase._random.Next(1, 5);
19 if (!structures.CanPlace(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2)))
20 {
21 return false;
22 }
23 ushort type = (byte)(196 + WorldGen.genRand.Next(4));
24 for (int i = origin.X - num; i <= origin.X + num; i++)
25 {
26 for (int j = origin.Y - num; j <= origin.Y + num; j++)
27 {
28 if (Main.tile[i, j].active())
29 {
30 int type2 = Main.tile[i, j].type;
31 if (type2 == 53 || type2 == 396 || type2 == 397 || type2 == 404)
32 {
33 type = 171;
34 }
35 if (type2 == 161 || type2 == 147)
36 {
37 type = 40;
38 }
39 if (type2 == 60)
40 {
41 type = (byte)(204 + WorldGen.genRand.Next(4));
42 }
43 if (type2 == 367)
44 {
45 type = 178;
46 }
47 if (type2 == 368)
48 {
49 type = 180;
50 }
51 }
52 }
53 }
54 ShapeData data = new ShapeData();
55 WorldUtils.Gen(origin, new Shapes.Slime(num), Actions.Chain(new Modifiers.Blotches(num2, num2, num2, 1, 1.0).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)));
56 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)));
57 if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out var result))
58 {
59 return false;
60 }
61 int num3 = result.Y - 1;
62 bool flag = GenBase._random.Next() % 2 == 0;
63 if (GenBase._random.Next() % 10 != 0)
64 {
65 int num4 = GenBase._random.Next(1, 4);
66 int num5 = (flag ? 4 : (-(num >> 1)));
67 for (int k = 0; k < num4; k++)
68 {
69 int num6 = GenBase._random.Next(1, 3);
70 for (int l = 0; l < num6; l++)
71 {
72 WorldGen.PlaceTile(origin.X + num5 - k, num3 - l, 332, mute: true);
73 }
74 }
75 }
76 int num7 = (num - 3) * ((!flag) ? 1 : (-1));
77 if (GenBase._random.Next() % 10 != 0)
78 {
79 WorldGen.PlaceTile(origin.X + num7, num3, 186);
80 }
81 if (GenBase._random.Next() % 10 != 0)
82 {
83 WorldGen.PlaceTile(origin.X, num3, 215, mute: true);
84 if (GenBase._tiles[origin.X, num3].active() && GenBase._tiles[origin.X, num3].type == 215)
85 {
86 GenBase._tiles[origin.X, num3].frameY += 36;
87 GenBase._tiles[origin.X - 1, num3].frameY += 36;
88 GenBase._tiles[origin.X + 1, num3].frameY += 36;
89 GenBase._tiles[origin.X, num3 - 1].frameY += 36;
90 GenBase._tiles[origin.X - 1, num3 - 1].frameY += 36;
91 GenBase._tiles[origin.X + 1, num3 - 1].frameY += 36;
92 }
93 }
94 structures.AddProtectedStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4);
95 return true;
96 }
97}
override bool Place(Point origin, StructureMap structures)
static Tile[,] tile
Definition Main.cs:1675
T Value
Definition Ref.cs:5
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 bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27
static bool Gen(Point origin, GenShape shape, GenAction action)
Definition WorldUtils.cs:17
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static UnifiedRandom genRand
Definition WorldGen.cs:1215