Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
JunglePass.cs
Go to the documentation of this file.
1using System;
4using Terraria.IO;
6
8
9public class JunglePass : GenPass
10{
11 private double _worldScale;
12
13 public JunglePass()
14 : base("Jungle", 10154.65234375)
15 {
16 }
17
18 protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
19 {
20 progress.Message = Lang.gen[11].Value;
21 _worldScale = (double)Main.maxTilesX / 4200.0 * 1.5;
22 double worldScale = _worldScale;
23 Point point = CreateStartPoint();
24 int x = point.X;
25 int y = point.Y;
26 Point zero = Point.Zero;
27 ApplyRandomMovement(ref x, ref y, 100, 100);
28 zero.X += x;
29 zero.Y += y;
30 PlaceFirstPassMud(x, y, 3);
31 PlaceGemsAt(x, y, 63, 2);
32 progress.Set(0.15);
33 ApplyRandomMovement(ref x, ref y, 250, 150);
34 zero.X += x;
35 zero.Y += y;
36 PlaceFirstPassMud(x, y, 0);
37 PlaceGemsAt(x, y, 65, 2);
38 progress.Set(0.3);
39 int oldX = x;
40 int oldY = y;
41 ApplyRandomMovement(ref x, ref y, 400, 150);
42 zero.X += x;
43 zero.Y += y;
44 PlaceFirstPassMud(x, y, -3);
45 PlaceGemsAt(x, y, 67, 2);
46 progress.Set(0.45);
47 x = zero.X / 3;
48 y = zero.Y / 3;
49 int num = GenBase._random.Next((int)(400.0 * worldScale), (int)(600.0 * worldScale));
50 int num2 = (int)(25.0 * worldScale);
51 x = Utils.Clamp(x, GenVars.leftBeachEnd + num / 2 + num2, GenVars.rightBeachStart - num / 2 - num2);
52 GenVars.mudWall = true;
53 WorldGen.TileRunner(x, y, num, 10000, 59, addTile: false, 0.0, -20.0, noYChange: true);
55 GenVars.mudWall = false;
56 progress.Set(0.6);
58 GenerateFinishingTouches(progress, oldX, oldY);
59 }
60
61 private void PlaceGemsAt(int x, int y, ushort baseGem, int gemVariants)
62 {
63 for (int i = 0; (double)i < 6.0 * _worldScale; i++)
64 {
65 WorldGen.TileRunner(x + GenBase._random.Next(-(int)(125.0 * _worldScale), (int)(125.0 * _worldScale)), y + GenBase._random.Next(-(int)(125.0 * _worldScale), (int)(125.0 * _worldScale)), GenBase._random.Next(3, 7), GenBase._random.Next(3, 8), GenBase._random.Next(baseGem, baseGem + gemVariants));
66 }
67 }
68
69 private void PlaceFirstPassMud(int x, int y, int xSpeedScale)
70 {
71 GenVars.mudWall = true;
72 WorldGen.TileRunner(x, y, GenBase._random.Next((int)(250.0 * _worldScale), (int)(500.0 * _worldScale)), GenBase._random.Next(50, 150), 59, addTile: false, GenVars.dungeonSide * xSpeedScale);
73 GenVars.mudWall = false;
74 }
75
77 {
78 return new Point(GenVars.jungleOriginX, (int)((double)Main.maxTilesY + Main.rockLayer) / 2);
79 }
80
81 private void ApplyRandomMovement(ref int x, ref int y, int xRange, int yRange)
82 {
83 x += GenBase._random.Next((int)((double)(-xRange) * _worldScale), 1 + (int)((double)xRange * _worldScale));
84 y += GenBase._random.Next((int)((double)(-yRange) * _worldScale), 1 + (int)((double)yRange * _worldScale));
85 y = Utils.Clamp(y, (int)Main.rockLayer, Main.maxTilesY);
86 }
87
88 private void GenerateTunnelToSurface(int i, int j)
89 {
90 //IL_006d: Unknown result type (might be due to invalid IL or missing references)
91 //IL_01ec: Unknown result type (might be due to invalid IL or missing references)
92 //IL_0087: Unknown result type (might be due to invalid IL or missing references)
93 //IL_0090: Unknown result type (might be due to invalid IL or missing references)
94 //IL_0246: Unknown result type (might be due to invalid IL or missing references)
95 //IL_025a: Unknown result type (might be due to invalid IL or missing references)
96 //IL_026f: Unknown result type (might be due to invalid IL or missing references)
97 //IL_0284: Unknown result type (might be due to invalid IL or missing references)
98 //IL_03ce: Unknown result type (might be due to invalid IL or missing references)
99 //IL_03cf: Unknown result type (might be due to invalid IL or missing references)
100 //IL_03d0: Unknown result type (might be due to invalid IL or missing references)
101 //IL_03d5: Unknown result type (might be due to invalid IL or missing references)
102 //IL_03fa: Unknown result type (might be due to invalid IL or missing references)
103 //IL_02ea: Unknown result type (might be due to invalid IL or missing references)
104 //IL_02f9: Unknown result type (might be due to invalid IL or missing references)
105 //IL_041b: Unknown result type (might be due to invalid IL or missing references)
106 //IL_0460: Unknown result type (might be due to invalid IL or missing references)
107 //IL_038e: Unknown result type (might be due to invalid IL or missing references)
108 //IL_0395: Unknown result type (might be due to invalid IL or missing references)
109 //IL_0493: Unknown result type (might be due to invalid IL or missing references)
110 //IL_04c6: Unknown result type (might be due to invalid IL or missing references)
111 //IL_04e7: Unknown result type (might be due to invalid IL or missing references)
112 double num = GenBase._random.Next(5, 11);
113 Vector2D val = default(Vector2D);
114 val.X = i;
115 val.Y = j;
116 Vector2D val2 = default(Vector2D);
117 val2.X = (double)GenBase._random.Next(-10, 11) * 0.1;
118 val2.Y = (double)GenBase._random.Next(10, 20) * 0.1;
119 int num2 = 0;
120 bool flag = true;
121 while (flag)
122 {
123 if (val.Y < Main.worldSurface)
124 {
126 {
127 flag = false;
128 }
129 int value = (int)val.X;
130 int value2 = (int)val.Y;
131 value = Utils.Clamp(value, 10, Main.maxTilesX - 10);
132 value2 = Utils.Clamp(value2, 10, Main.maxTilesY - 10);
133 if (value2 < 5)
134 {
135 value2 = 5;
136 }
137 if (Main.tile[value, value2].wall == 0 && !Main.tile[value, value2].active() && Main.tile[value, value2 - 3].wall == 0 && !Main.tile[value, value2 - 3].active() && Main.tile[value, value2 - 1].wall == 0 && !Main.tile[value, value2 - 1].active() && Main.tile[value, value2 - 4].wall == 0 && !Main.tile[value, value2 - 4].active() && Main.tile[value, value2 - 2].wall == 0 && !Main.tile[value, value2 - 2].active() && Main.tile[value, value2 - 5].wall == 0 && !Main.tile[value, value2 - 5].active())
138 {
139 flag = false;
140 }
141 }
142 GenVars.JungleX = (int)val.X;
143 num += (double)GenBase._random.Next(-20, 21) * 0.1;
144 if (num < 5.0)
145 {
146 num = 5.0;
147 }
148 if (num > 10.0)
149 {
150 num = 10.0;
151 }
152 int value3 = (int)(val.X - num * 0.5);
153 int value4 = (int)(val.X + num * 0.5);
154 int value5 = (int)(val.Y - num * 0.5);
155 int value6 = (int)(val.Y + num * 0.5);
156 int num3 = Utils.Clamp(value3, 10, Main.maxTilesX - 10);
157 value4 = Utils.Clamp(value4, 10, Main.maxTilesX - 10);
158 value5 = Utils.Clamp(value5, 10, Main.maxTilesY - 10);
159 value6 = Utils.Clamp(value6, 10, Main.maxTilesY - 10);
160 for (int k = num3; k < value4; k++)
161 {
162 for (int l = value5; l < value6; l++)
163 {
164 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num * 0.5 * (1.0 + (double)GenBase._random.Next(-10, 11) * 0.015))
165 {
166 WorldGen.KillTile(k, l);
167 }
168 }
169 }
170 num2++;
171 if (num2 > 10 && GenBase._random.Next(50) < num2)
172 {
173 num2 = 0;
174 int num4 = -2;
175 if (GenBase._random.Next(2) == 0)
176 {
177 num4 = 2;
178 }
179 WorldGen.TileRunner((int)val.X, (int)val.Y, GenBase._random.Next(3, 20), GenBase._random.Next(10, 100), -1, addTile: false, num4);
180 }
181 val += val2;
182 val2.Y += (double)GenBase._random.Next(-10, 11) * 0.01;
183 if (val2.Y > 0.0)
184 {
185 val2.Y = 0.0;
186 }
187 if (val2.Y < -2.0)
188 {
189 val2.Y = -2.0;
190 }
191 val2.X += (double)GenBase._random.Next(-10, 11) * 0.1;
192 if (val.X < (double)(i - 200))
193 {
194 val2.X += (double)GenBase._random.Next(5, 21) * 0.1;
195 }
196 if (val.X > (double)(i + 200))
197 {
198 val2.X -= (double)GenBase._random.Next(5, 21) * 0.1;
199 }
200 if (val2.X > 1.5)
201 {
202 val2.X = 1.5;
203 }
204 if (val2.X < -1.5)
205 {
206 val2.X = -1.5;
207 }
208 }
209 }
210
212 {
213 for (int i = 0; i < Main.maxTilesX / 4; i++)
214 {
215 int num = GenBase._random.Next(20, Main.maxTilesX - 20);
216 int num2 = GenBase._random.Next((int)GenVars.worldSurface + 10, Main.UnderworldLayer);
217 while (Main.tile[num, num2].wall != 64 && Main.tile[num, num2].wall != 15)
218 {
219 num = GenBase._random.Next(20, Main.maxTilesX - 20);
220 num2 = GenBase._random.Next((int)GenVars.worldSurface + 10, Main.UnderworldLayer);
221 }
222 WorldGen.MudWallRunner(num, num2);
223 }
224 }
225
226 private void GenerateFinishingTouches(GenerationProgress progress, int oldX, int oldY)
227 {
228 int num = oldX;
229 int num2 = oldY;
230 double worldScale = _worldScale;
231 for (int i = 0; (double)i <= 20.0 * worldScale; i++)
232 {
233 progress.Set((60.0 + (double)i / worldScale) * 0.01);
234 num += GenBase._random.Next((int)(-5.0 * worldScale), (int)(6.0 * worldScale));
235 num2 += GenBase._random.Next((int)(-5.0 * worldScale), (int)(6.0 * worldScale));
236 WorldGen.TileRunner(num, num2, GenBase._random.Next(40, 100), GenBase._random.Next(300, 500), 59);
237 }
238 for (int j = 0; (double)j <= 10.0 * worldScale; j++)
239 {
240 progress.Set((80.0 + (double)j / worldScale * 2.0) * 0.01);
241 num = oldX + GenBase._random.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale));
242 num2 = oldY + GenBase._random.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale));
243 while (num < 1 || num >= Main.maxTilesX - 1 || num2 < 1 || num2 >= Main.maxTilesY - 1 || Main.tile[num, num2].type != 59)
244 {
245 num = oldX + GenBase._random.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale));
246 num2 = oldY + GenBase._random.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale));
247 }
248 for (int k = 0; (double)k < 8.0 * worldScale; k++)
249 {
250 num += GenBase._random.Next(-30, 31);
251 num2 += GenBase._random.Next(-30, 31);
252 int type = -1;
253 if (GenBase._random.Next(7) == 0)
254 {
255 type = -2;
256 }
257 WorldGen.TileRunner(num, num2, GenBase._random.Next(10, 20), GenBase._random.Next(30, 70), type);
258 }
259 }
260 for (int l = 0; (double)l <= 300.0 * worldScale; l++)
261 {
262 num = oldX + GenBase._random.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale));
263 num2 = oldY + GenBase._random.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale));
264 while (num < 1 || num >= Main.maxTilesX - 1 || num2 < 1 || num2 >= Main.maxTilesY - 1 || Main.tile[num, num2].type != 59)
265 {
266 num = oldX + GenBase._random.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale));
267 num2 = oldY + GenBase._random.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale));
268 }
269 WorldGen.TileRunner(num, num2, GenBase._random.Next(4, 10), GenBase._random.Next(5, 30), 1);
270 if (GenBase._random.Next(4) == 0)
271 {
272 int type2 = GenBase._random.Next(63, 69);
273 WorldGen.TileRunner(num + GenBase._random.Next(-1, 2), num2 + GenBase._random.Next(-1, 2), GenBase._random.Next(3, 7), GenBase._random.Next(4, 8), type2);
274 }
275 }
276 }
277}
static double Abs(double value)
void GenerateTunnelToSurface(int i, int j)
Definition JunglePass.cs:88
void PlaceGemsAt(int x, int y, ushort baseGem, int gemVariants)
Definition JunglePass.cs:61
void PlaceFirstPassMud(int x, int y, int xSpeedScale)
Definition JunglePass.cs:69
void GenerateFinishingTouches(GenerationProgress progress, int oldX, int oldY)
override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
Definition JunglePass.cs:18
void ApplyRandomMovement(ref int x, ref int y, int xRange, int yRange)
Definition JunglePass.cs:81
static LocalizedText[] gen
Definition Lang.cs:22
static int maxTilesY
Definition Main.cs:1116
static double worldSurface
Definition Main.cs:1272
static double rockLayer
Definition Main.cs:1274
static int maxTilesX
Definition Main.cs:1114
static Tile[,] tile
Definition Main.cs:1675
static int UnderworldLayer
Definition Main.cs:2825
static UnifiedRandom _random
Definition GenBase.cs:9
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static void MudWallRunner(int i, int j)
static bool drunkWorldGen
Definition WorldGen.cs:1154
static void TileRunner(int i, int j, double strength, int steps, int type, bool addTile=false, double speedX=0.0, double speedY=0.0, bool noYChange=false, bool overRide=true, int ignoreTileType=-1)