TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
Minecart.cs
Go to the documentation of this file.
1using System;
2using Microsoft.Xna.Framework;
4
5namespace Terraria;
6
7public static class Minecart
8{
9 private enum TrackState
10 {
11 NoTrack = -1,
13 OnTrack,
17 OnFront,
18 OnBack
19 }
20
21 private const int TotalFrames = 36;
22
23 public const int LeftDownDecoration = 36;
24
25 public const int RightDownDecoration = 37;
26
27 public const int BouncyBumperDecoration = 38;
28
29 public const int RegularBumperDecoration = 39;
30
31 public const int Flag_OnTrack = 0;
32
33 public const int Flag_BouncyBumper = 1;
34
35 public const int Flag_UsedRamp = 2;
36
37 public const int Flag_HitSwitch = 3;
38
39 public const int Flag_BoostLeft = 4;
40
41 public const int Flag_BoostRight = 5;
42
43 private const int NoConnection = -1;
44
45 private const int TopConnection = 0;
46
47 private const int MiddleConnection = 1;
48
49 private const int BottomConnection = 2;
50
51 private const int BumperEnd = -1;
52
53 private const int BouncyEnd = -2;
54
55 private const int RampEnd = -3;
56
57 private const int OpenEnd = -4;
58
59 public const float BoosterSpeed = 4f;
60
61 private const int Type_Normal = 0;
62
63 private const int Type_Pressure = 1;
64
65 private const int Type_Booster = 2;
66
67 private static Vector2 _trackMagnetOffset = new Vector2(25f, 26f);
68
69 private const float MinecartTextureWidth = 50f;
70
71 private static int[] _leftSideConnection;
72
73 private static int[] _rightSideConnection;
74
75 private static int[] _trackType;
76
77 private static bool[] _boostLeft;
78
79 private static Vector2[] _texturePosition;
80
81 private static short _firstPressureFrame;
82
83 private static short _firstLeftBoostFrame;
84
85 private static short _firstRightBoostFrame;
86
87 private static int[][] _trackSwitchOptions;
88
89 private static int[][] _tileHeight;
90
91 public static void Initialize()
92 {
93 //IL_00f2: Unknown result type (might be due to invalid IL or missing references)
94 //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
95 //IL_0120: Unknown result type (might be due to invalid IL or missing references)
96 //IL_0125: Unknown result type (might be due to invalid IL or missing references)
97 //IL_0169: Unknown result type (might be due to invalid IL or missing references)
98 //IL_016e: Unknown result type (might be due to invalid IL or missing references)
99 //IL_01b2: Unknown result type (might be due to invalid IL or missing references)
100 //IL_01b7: Unknown result type (might be due to invalid IL or missing references)
101 //IL_021c: Unknown result type (might be due to invalid IL or missing references)
102 //IL_0221: Unknown result type (might be due to invalid IL or missing references)
103 //IL_0286: Unknown result type (might be due to invalid IL or missing references)
104 //IL_028b: Unknown result type (might be due to invalid IL or missing references)
105 //IL_02dc: Unknown result type (might be due to invalid IL or missing references)
106 //IL_02e1: Unknown result type (might be due to invalid IL or missing references)
107 //IL_0332: Unknown result type (might be due to invalid IL or missing references)
108 //IL_0337: Unknown result type (might be due to invalid IL or missing references)
109 //IL_037e: Unknown result type (might be due to invalid IL or missing references)
110 //IL_0383: Unknown result type (might be due to invalid IL or missing references)
111 //IL_03ca: Unknown result type (might be due to invalid IL or missing references)
112 //IL_03cf: Unknown result type (might be due to invalid IL or missing references)
113 //IL_0427: Unknown result type (might be due to invalid IL or missing references)
114 //IL_042c: Unknown result type (might be due to invalid IL or missing references)
115 //IL_0484: Unknown result type (might be due to invalid IL or missing references)
116 //IL_0489: Unknown result type (might be due to invalid IL or missing references)
117 //IL_04eb: Unknown result type (might be due to invalid IL or missing references)
118 //IL_04f0: Unknown result type (might be due to invalid IL or missing references)
119 //IL_0552: Unknown result type (might be due to invalid IL or missing references)
120 //IL_0557: Unknown result type (might be due to invalid IL or missing references)
121 //IL_058b: Unknown result type (might be due to invalid IL or missing references)
122 //IL_0590: Unknown result type (might be due to invalid IL or missing references)
123 //IL_05c4: Unknown result type (might be due to invalid IL or missing references)
124 //IL_05c9: Unknown result type (might be due to invalid IL or missing references)
125 //IL_0626: Unknown result type (might be due to invalid IL or missing references)
126 //IL_062b: Unknown result type (might be due to invalid IL or missing references)
127 //IL_0688: Unknown result type (might be due to invalid IL or missing references)
128 //IL_068d: Unknown result type (might be due to invalid IL or missing references)
129 //IL_06ea: Unknown result type (might be due to invalid IL or missing references)
130 //IL_06ef: Unknown result type (might be due to invalid IL or missing references)
131 //IL_074c: Unknown result type (might be due to invalid IL or missing references)
132 //IL_0751: Unknown result type (might be due to invalid IL or missing references)
133 //IL_0798: Unknown result type (might be due to invalid IL or missing references)
134 //IL_079d: Unknown result type (might be due to invalid IL or missing references)
135 //IL_07ce: Unknown result type (might be due to invalid IL or missing references)
136 //IL_07d3: Unknown result type (might be due to invalid IL or missing references)
137 //IL_080f: Unknown result type (might be due to invalid IL or missing references)
138 //IL_0814: Unknown result type (might be due to invalid IL or missing references)
139 //IL_0850: Unknown result type (might be due to invalid IL or missing references)
140 //IL_0855: Unknown result type (might be due to invalid IL or missing references)
141 //IL_089a: Unknown result type (might be due to invalid IL or missing references)
142 //IL_089f: Unknown result type (might be due to invalid IL or missing references)
143 //IL_08e4: Unknown result type (might be due to invalid IL or missing references)
144 //IL_08e9: Unknown result type (might be due to invalid IL or missing references)
145 //IL_0942: Unknown result type (might be due to invalid IL or missing references)
146 //IL_0947: Unknown result type (might be due to invalid IL or missing references)
147 //IL_09a0: Unknown result type (might be due to invalid IL or missing references)
148 //IL_09a5: Unknown result type (might be due to invalid IL or missing references)
149 //IL_0a08: Unknown result type (might be due to invalid IL or missing references)
150 //IL_0a0d: Unknown result type (might be due to invalid IL or missing references)
151 //IL_0a70: Unknown result type (might be due to invalid IL or missing references)
152 //IL_0a75: Unknown result type (might be due to invalid IL or missing references)
153 //IL_0aae: Unknown result type (might be due to invalid IL or missing references)
154 //IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
155 //IL_0aec: Unknown result type (might be due to invalid IL or missing references)
156 //IL_0af1: Unknown result type (might be due to invalid IL or missing references)
157 //IL_0b48: Unknown result type (might be due to invalid IL or missing references)
158 //IL_0b4d: Unknown result type (might be due to invalid IL or missing references)
159 //IL_0ba4: Unknown result type (might be due to invalid IL or missing references)
160 //IL_0ba9: Unknown result type (might be due to invalid IL or missing references)
161 //IL_0c00: Unknown result type (might be due to invalid IL or missing references)
162 //IL_0c05: Unknown result type (might be due to invalid IL or missing references)
163 //IL_0c5c: Unknown result type (might be due to invalid IL or missing references)
164 //IL_0c61: Unknown result type (might be due to invalid IL or missing references)
165 //IL_0c7b: Unknown result type (might be due to invalid IL or missing references)
166 //IL_0c80: Unknown result type (might be due to invalid IL or missing references)
167 //IL_0c96: Unknown result type (might be due to invalid IL or missing references)
168 //IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
169 //IL_0cb1: Unknown result type (might be due to invalid IL or missing references)
170 //IL_0cb6: Unknown result type (might be due to invalid IL or missing references)
171 //IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
172 //IL_0cd1: Unknown result type (might be due to invalid IL or missing references)
173 //IL_0ce8: Unknown result type (might be due to invalid IL or missing references)
174 //IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
175 //IL_0cf7: Unknown result type (might be due to invalid IL or missing references)
176 if (!Main.dedServ && (float)TextureAssets.MinecartMount.Width() != 50f)
177 {
178 throw new Exception("Be sure to update Minecart.textureWidth to match the actual texture size of " + 50f + ".");
179 }
180 _rightSideConnection = new int[36];
181 _leftSideConnection = new int[36];
182 _trackType = new int[36];
183 _boostLeft = new bool[36];
184 _texturePosition = (Vector2[])(object)new Vector2[40];
185 _tileHeight = new int[36][];
186 for (int i = 0; i < 36; i++)
187 {
188 int[] array = new int[8];
189 for (int j = 0; j < array.Length; j++)
190 {
191 array[j] = 5;
192 }
193 _tileHeight[i] = array;
194 }
195 int num = 0;
198 _tileHeight[num][0] = -4;
199 _tileHeight[num][7] = -4;
200 _texturePosition[num] = new Vector2(0f, 0f);
201 num++;
204 _texturePosition[num] = new Vector2(1f, 0f);
205 num++;
208 for (int k = 0; k < 4; k++)
209 {
210 _tileHeight[num][k] = -1;
211 }
212 _texturePosition[num] = new Vector2(2f, 1f);
213 num++;
216 for (int l = 4; l < 8; l++)
217 {
218 _tileHeight[num][l] = -1;
219 }
220 _texturePosition[num] = new Vector2(3f, 1f);
221 num++;
224 _tileHeight[num][0] = 1;
225 _tileHeight[num][1] = 2;
226 _tileHeight[num][2] = 3;
227 _tileHeight[num][3] = 3;
228 _tileHeight[num][4] = 4;
229 _tileHeight[num][5] = 4;
230 _texturePosition[num] = new Vector2(0f, 2f);
231 num++;
234 _tileHeight[num][2] = 4;
235 _tileHeight[num][3] = 4;
236 _tileHeight[num][4] = 3;
237 _tileHeight[num][5] = 3;
238 _tileHeight[num][6] = 2;
239 _tileHeight[num][7] = 1;
240 _texturePosition[num] = new Vector2(1f, 2f);
241 num++;
244 _tileHeight[num][4] = 6;
245 _tileHeight[num][5] = 6;
246 _tileHeight[num][6] = 7;
247 _tileHeight[num][7] = 8;
248 _texturePosition[num] = new Vector2(0f, 1f);
249 num++;
252 _tileHeight[num][0] = 8;
253 _tileHeight[num][1] = 7;
254 _tileHeight[num][2] = 6;
255 _tileHeight[num][3] = 6;
256 _texturePosition[num] = new Vector2(1f, 1f);
257 num++;
260 for (int m = 0; m < 8; m++)
261 {
262 _tileHeight[num][m] = 8 - m;
263 }
264 _texturePosition[num] = new Vector2(0f, 3f);
265 num++;
268 for (int n = 0; n < 8; n++)
269 {
270 _tileHeight[num][n] = n + 1;
271 }
272 _texturePosition[num] = new Vector2(1f, 3f);
273 num++;
276 _tileHeight[num][0] = 1;
277 _tileHeight[num][1] = 2;
278 for (int num12 = 2; num12 < 8; num12++)
279 {
280 _tileHeight[num][num12] = -1;
281 }
282 _texturePosition[num] = new Vector2(4f, 1f);
283 num++;
286 _tileHeight[num][6] = 2;
287 _tileHeight[num][7] = 1;
288 for (int num23 = 0; num23 < 6; num23++)
289 {
290 _tileHeight[num][num23] = -1;
291 }
292 _texturePosition[num] = new Vector2(5f, 1f);
293 num++;
296 _tileHeight[num][0] = 8;
297 _tileHeight[num][1] = 7;
298 _tileHeight[num][2] = 6;
299 for (int num26 = 3; num26 < 8; num26++)
300 {
301 _tileHeight[num][num26] = -1;
302 }
303 _texturePosition[num] = new Vector2(6f, 1f);
304 num++;
307 _tileHeight[num][5] = 6;
308 _tileHeight[num][6] = 7;
309 _tileHeight[num][7] = 8;
310 for (int num27 = 0; num27 < 5; num27++)
311 {
312 _tileHeight[num][num27] = -1;
313 }
314 _texturePosition[num] = new Vector2(7f, 1f);
315 num++;
318 _tileHeight[num][0] = -4;
319 _texturePosition[num] = new Vector2(2f, 0f);
320 num++;
323 _tileHeight[num][7] = -4;
324 _texturePosition[num] = new Vector2(3f, 0f);
325 num++;
328 for (int num28 = 0; num28 < 6; num28++)
329 {
330 _tileHeight[num][num28] = num28 + 1;
331 }
332 _tileHeight[num][6] = -3;
333 _tileHeight[num][7] = -3;
334 _texturePosition[num] = new Vector2(4f, 0f);
335 num++;
338 _tileHeight[num][0] = -3;
339 _tileHeight[num][1] = -3;
340 for (int num29 = 2; num29 < 8; num29++)
341 {
342 _tileHeight[num][num29] = 8 - num29;
343 }
344 _texturePosition[num] = new Vector2(5f, 0f);
345 num++;
348 for (int num30 = 0; num30 < 6; num30++)
349 {
350 _tileHeight[num][num30] = 8 - num30;
351 }
352 _tileHeight[num][6] = -3;
353 _tileHeight[num][7] = -3;
354 _texturePosition[num] = new Vector2(6f, 0f);
355 num++;
358 _tileHeight[num][0] = -3;
359 _tileHeight[num][1] = -3;
360 for (int num31 = 2; num31 < 8; num31++)
361 {
362 _tileHeight[num][num31] = num31 + 1;
363 }
364 _texturePosition[num] = new Vector2(7f, 0f);
365 num++;
368 _tileHeight[num][0] = -4;
369 _tileHeight[num][7] = -4;
370 _trackType[num] = 1;
371 _texturePosition[num] = new Vector2(0f, 4f);
372 num++;
375 _trackType[num] = 1;
376 _texturePosition[num] = new Vector2(1f, 4f);
377 num++;
380 _tileHeight[num][0] = -4;
381 _trackType[num] = 1;
382 _texturePosition[num] = new Vector2(0f, 5f);
383 num++;
386 _tileHeight[num][7] = -4;
387 _trackType[num] = 1;
388 _texturePosition[num] = new Vector2(1f, 5f);
389 num++;
392 for (int num2 = 0; num2 < 6; num2++)
393 {
394 _tileHeight[num][num2] = -2;
395 }
396 _texturePosition[num] = new Vector2(2f, 2f);
397 num++;
400 for (int num3 = 2; num3 < 8; num3++)
401 {
402 _tileHeight[num][num3] = -2;
403 }
404 _texturePosition[num] = new Vector2(3f, 2f);
405 num++;
408 _tileHeight[num][0] = 1;
409 _tileHeight[num][1] = 2;
410 for (int num4 = 2; num4 < 8; num4++)
411 {
412 _tileHeight[num][num4] = -2;
413 }
414 _texturePosition[num] = new Vector2(4f, 2f);
415 num++;
418 _tileHeight[num][6] = 2;
419 _tileHeight[num][7] = 1;
420 for (int num5 = 0; num5 < 6; num5++)
421 {
422 _tileHeight[num][num5] = -2;
423 }
424 _texturePosition[num] = new Vector2(5f, 2f);
425 num++;
428 _tileHeight[num][0] = 8;
429 _tileHeight[num][1] = 7;
430 _tileHeight[num][2] = 6;
431 for (int num6 = 3; num6 < 8; num6++)
432 {
433 _tileHeight[num][num6] = -2;
434 }
435 _texturePosition[num] = new Vector2(6f, 2f);
436 num++;
439 _tileHeight[num][5] = 6;
440 _tileHeight[num][6] = 7;
441 _tileHeight[num][7] = 8;
442 for (int num7 = 0; num7 < 5; num7++)
443 {
444 _tileHeight[num][num7] = -2;
445 }
446 _texturePosition[num] = new Vector2(7f, 2f);
447 num++;
450 _trackType[num] = 2;
451 _boostLeft[num] = false;
452 _texturePosition[num] = new Vector2(2f, 3f);
453 num++;
456 _trackType[num] = 2;
457 _boostLeft[num] = true;
458 _texturePosition[num] = new Vector2(3f, 3f);
459 num++;
462 for (int num8 = 0; num8 < 8; num8++)
463 {
464 _tileHeight[num][num8] = 8 - num8;
465 }
466 _trackType[num] = 2;
467 _boostLeft[num] = false;
468 _texturePosition[num] = new Vector2(4f, 3f);
469 num++;
472 for (int num9 = 0; num9 < 8; num9++)
473 {
474 _tileHeight[num][num9] = num9 + 1;
475 }
476 _trackType[num] = 2;
477 _boostLeft[num] = true;
478 _texturePosition[num] = new Vector2(5f, 3f);
479 num++;
482 for (int num10 = 0; num10 < 8; num10++)
483 {
484 _tileHeight[num][num10] = 8 - num10;
485 }
486 _trackType[num] = 2;
487 _boostLeft[num] = true;
488 _texturePosition[num] = new Vector2(6f, 3f);
489 num++;
492 for (int num11 = 0; num11 < 8; num11++)
493 {
494 _tileHeight[num][num11] = num11 + 1;
495 }
496 _trackType[num] = 2;
497 _boostLeft[num] = false;
498 _texturePosition[num] = new Vector2(7f, 3f);
499 num++;
500 _texturePosition[36] = new Vector2(0f, 6f);
501 _texturePosition[37] = new Vector2(1f, 6f);
502 _texturePosition[39] = new Vector2(0f, 7f);
503 _texturePosition[38] = new Vector2(1f, 7f);
504 for (int num13 = 0; num13 < _texturePosition.Length; num13++)
505 {
507 reference *= 18f;
508 }
509 for (int num14 = 0; num14 < _tileHeight.Length; num14++)
510 {
511 int[] array2 = _tileHeight[num14];
512 for (int num15 = 0; num15 < array2.Length; num15++)
513 {
514 if (array2[num15] >= 0)
515 {
516 array2[num15] = (8 - array2[num15]) * 2;
517 }
518 }
519 }
520 int[] array3 = new int[36];
521 _trackSwitchOptions = new int[64][];
522 for (int num16 = 0; num16 < 64; num16++)
523 {
524 int num17 = 0;
525 for (int num18 = 1; num18 < 256; num18 <<= 1)
526 {
527 if ((num16 & num18) == num18)
528 {
529 num17++;
530 }
531 }
532 int num19 = 0;
533 for (int num20 = 0; num20 < 36; num20++)
534 {
535 array3[num20] = -1;
536 int num21 = 0;
537 switch (_leftSideConnection[num20])
538 {
539 case 0:
540 num21 |= 1;
541 break;
542 case 1:
543 num21 |= 2;
544 break;
545 case 2:
546 num21 |= 4;
547 break;
548 }
550 {
551 case 0:
552 num21 |= 8;
553 break;
554 case 1:
555 num21 |= 0x10;
556 break;
557 case 2:
558 num21 |= 0x20;
559 break;
560 }
561 if (num17 < 2)
562 {
563 if (num16 != num21)
564 {
565 continue;
566 }
567 }
568 else if (num21 == 0 || (num16 & num21) != num21)
569 {
570 continue;
571 }
572 array3[num20] = num20;
573 num19++;
574 }
575 if (num19 == 0)
576 {
577 continue;
578 }
579 int[] array4 = new int[num19];
580 int num22 = 0;
581 for (int num24 = 0; num24 < 36; num24++)
582 {
583 if (array3[num24] != -1)
584 {
586 num22++;
587 }
588 }
590 }
594 for (int num25 = 0; num25 < _trackType.Length; num25++)
595 {
596 switch (_trackType[num25])
597 {
598 case 1:
599 if (_firstPressureFrame == -1)
600 {
601 _firstPressureFrame = (short)num25;
602 }
603 break;
604 case 2:
605 if (_boostLeft[num25])
606 {
607 if (_firstLeftBoostFrame == -1)
608 {
610 }
611 }
612 else if (_firstRightBoostFrame == -1)
613 {
615 }
616 break;
617 }
618 }
619 }
620
621 public static bool IsPressurePlate(Tile tile)
622 {
623 if (tile == null)
624 {
625 return false;
626 }
627 if (tile.active() && tile.type == 314 && (tile.frameX == 20 || tile.frameX == 21))
628 {
629 return true;
630 }
631 return false;
632 }
633
634 public static BitsByte TrackCollision(Player Player, ref Vector2 Position, ref Vector2 Velocity, ref Vector2 lastBoost, int Width, int Height, bool followDown, bool followUp, int fallStart, bool trackOnly, Mount.MountDelegatesData delegatesData)
635 {
636 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
637 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
638 //IL_003f: Unknown result type (might be due to invalid IL or missing references)
639 //IL_0044: Unknown result type (might be due to invalid IL or missing references)
640 //IL_0049: Unknown result type (might be due to invalid IL or missing references)
641 //IL_004e: Unknown result type (might be due to invalid IL or missing references)
642 //IL_0050: Unknown result type (might be due to invalid IL or missing references)
643 //IL_0055: Unknown result type (might be due to invalid IL or missing references)
644 //IL_0065: Unknown result type (might be due to invalid IL or missing references)
645 //IL_0066: Unknown result type (might be due to invalid IL or missing references)
646 //IL_008e: Unknown result type (might be due to invalid IL or missing references)
647 //IL_0093: Unknown result type (might be due to invalid IL or missing references)
648 //IL_0095: Unknown result type (might be due to invalid IL or missing references)
649 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
650 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
651 //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
652 //IL_00c4: Unknown result type (might be due to invalid IL or missing references)
653 //IL_0112: Unknown result type (might be due to invalid IL or missing references)
654 //IL_025d: Unknown result type (might be due to invalid IL or missing references)
655 //IL_025f: Unknown result type (might be due to invalid IL or missing references)
656 //IL_0261: Unknown result type (might be due to invalid IL or missing references)
657 //IL_0266: Unknown result type (might be due to invalid IL or missing references)
658 //IL_04ac: Unknown result type (might be due to invalid IL or missing references)
659 //IL_022e: Unknown result type (might be due to invalid IL or missing references)
660 //IL_0230: Unknown result type (might be due to invalid IL or missing references)
661 //IL_0232: Unknown result type (might be due to invalid IL or missing references)
662 //IL_0237: Unknown result type (might be due to invalid IL or missing references)
663 //IL_02a1: Unknown result type (might be due to invalid IL or missing references)
664 //IL_0285: Unknown result type (might be due to invalid IL or missing references)
665 //IL_0287: Unknown result type (might be due to invalid IL or missing references)
666 //IL_0289: Unknown result type (might be due to invalid IL or missing references)
667 //IL_028e: Unknown result type (might be due to invalid IL or missing references)
668 //IL_03cc: Unknown result type (might be due to invalid IL or missing references)
669 //IL_06ee: Unknown result type (might be due to invalid IL or missing references)
670 //IL_06fd: Unknown result type (might be due to invalid IL or missing references)
671 //IL_071a: Unknown result type (might be due to invalid IL or missing references)
672 //IL_0359: Unknown result type (might be due to invalid IL or missing references)
673 //IL_034d: Unknown result type (might be due to invalid IL or missing references)
674 //IL_0336: Unknown result type (might be due to invalid IL or missing references)
675 //IL_032a: Unknown result type (might be due to invalid IL or missing references)
676 //IL_02e5: Unknown result type (might be due to invalid IL or missing references)
677 //IL_02bb: Unknown result type (might be due to invalid IL or missing references)
678 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
679 //IL_03da: Unknown result type (might be due to invalid IL or missing references)
680 //IL_03aa: Unknown result type (might be due to invalid IL or missing references)
681 //IL_0809: Unknown result type (might be due to invalid IL or missing references)
682 //IL_080e: Unknown result type (might be due to invalid IL or missing references)
683 //IL_0733: Unknown result type (might be due to invalid IL or missing references)
684 //IL_035e: Unknown result type (might be due to invalid IL or missing references)
685 //IL_036b: Unknown result type (might be due to invalid IL or missing references)
686 //IL_0370: Unknown result type (might be due to invalid IL or missing references)
687 //IL_0372: Unknown result type (might be due to invalid IL or missing references)
688 //IL_0377: Unknown result type (might be due to invalid IL or missing references)
689 //IL_03b5: Unknown result type (might be due to invalid IL or missing references)
690 //IL_074a: Unknown result type (might be due to invalid IL or missing references)
691 //IL_06ab: Unknown result type (might be due to invalid IL or missing references)
692 //IL_06b0: Unknown result type (might be due to invalid IL or missing references)
693 //IL_0404: Unknown result type (might be due to invalid IL or missing references)
694 //IL_0763: Unknown result type (might be due to invalid IL or missing references)
695 //IL_0412: Unknown result type (might be due to invalid IL or missing references)
696 //IL_0825: Unknown result type (might be due to invalid IL or missing references)
697 //IL_082c: Unknown result type (might be due to invalid IL or missing references)
698 //IL_0856: Unknown result type (might be due to invalid IL or missing references)
699 //IL_0858: Unknown result type (might be due to invalid IL or missing references)
700 //IL_08f6: Unknown result type (might be due to invalid IL or missing references)
701 //IL_08fd: Unknown result type (might be due to invalid IL or missing references)
702 //IL_0791: Unknown result type (might be due to invalid IL or missing references)
703 //IL_07a1: Unknown result type (might be due to invalid IL or missing references)
704 //IL_087f: Unknown result type (might be due to invalid IL or missing references)
705 //IL_0891: Unknown result type (might be due to invalid IL or missing references)
706 //IL_08a4: Unknown result type (might be due to invalid IL or missing references)
707 //IL_05df: Unknown result type (might be due to invalid IL or missing references)
708 //IL_05f5: Unknown result type (might be due to invalid IL or missing references)
709 //IL_08d6: Unknown result type (might be due to invalid IL or missing references)
710 //IL_08c3: Unknown result type (might be due to invalid IL or missing references)
711 //IL_08ca: Unknown result type (might be due to invalid IL or missing references)
712 //IL_07d3: Unknown result type (might be due to invalid IL or missing references)
713 //IL_07d6: Unknown result type (might be due to invalid IL or missing references)
714 //IL_07db: Unknown result type (might be due to invalid IL or missing references)
715 //IL_07c2: Unknown result type (might be due to invalid IL or missing references)
716 //IL_07c4: Unknown result type (might be due to invalid IL or missing references)
717 //IL_07c9: Unknown result type (might be due to invalid IL or missing references)
718 //IL_07e2: Unknown result type (might be due to invalid IL or missing references)
719 //IL_07e4: Unknown result type (might be due to invalid IL or missing references)
720 //IL_07e6: Unknown result type (might be due to invalid IL or missing references)
721 //IL_07eb: Unknown result type (might be due to invalid IL or missing references)
722 if (followDown && followUp)
723 {
724 followDown = false;
725 followUp = false;
726 }
727 Vector2 vector = default(Vector2);
728 ((Vector2)(ref vector))._002Ector((float)(Width / 2) - 25f, (float)(Height / 2));
729 Vector2 vector2 = Position + new Vector2((float)(Width / 2) - 25f, (float)(Height / 2)) + _trackMagnetOffset;
730 Vector2 vector3 = Velocity;
731 float num = ((Vector2)(ref vector3)).Length();
732 ((Vector2)(ref vector3)).Normalize();
733 Vector2 vector4 = vector2;
734 Tile tile = default(Tile);
735 bool flag = false;
736 bool flag2 = true;
737 int num12 = -1;
738 int num20 = -1;
739 int num21 = -1;
741 bool flag3 = false;
742 bool flag4 = false;
743 bool flag5 = false;
744 bool flag6 = false;
745 Vector2 vector5 = Vector2.Zero;
746 Vector2 vector6 = Vector2.Zero;
747 BitsByte result = default(BitsByte);
748 while (true)
749 {
750 int num22 = (int)(vector4.X / 16f);
751 int num23 = (int)(vector4.Y / 16f);
752 int num24 = (int)vector4.X % 16 / 2;
753 if (flag2)
754 {
755 num21 = num24;
756 }
757 bool flag7 = num24 != num21;
758 if ((trackState == TrackState.OnBack || trackState == TrackState.OnTrack || trackState == TrackState.OnFront) && num22 != num12)
759 {
760 int num25 = ((trackState != TrackState.OnBack) ? tile.FrontTrack() : tile.BackTrack());
762 {
763 case 0:
764 num23--;
765 vector4.Y -= 2f;
766 break;
767 case 2:
768 num23++;
769 vector4.Y += 2f;
770 break;
771 }
772 }
774 bool flag8 = false;
775 if (num22 != num12 || num23 != num20)
776 {
777 if (flag2)
778 {
779 flag2 = false;
780 }
781 else
782 {
783 flag8 = true;
784 }
785 tile = Main.tile[num22, num23];
786 if (tile == null)
787 {
788 tile = (Main.tile[num22, num23] = default(Tile));
789 }
790 flag = ((tile.nactive() && tile.type == 314) ? true : false);
791 }
792 if (flag)
793 {
795 int num26 = tile.FrontTrack();
796 int num2 = tile.BackTrack();
797 int num3 = _tileHeight[num26][num24];
798 switch (num3)
799 {
800 case -4:
801 if (trackState == TrackState.OnFront)
802 {
803 if (trackOnly)
804 {
805 vector4 -= vector6;
806 num = 0f;
807 trackState2 = TrackState.OnFront;
808 flag6 = true;
809 }
810 else
811 {
812 trackState2 = TrackState.NoTrack;
813 flag5 = true;
814 }
815 }
816 break;
817 case -1:
818 if (trackState == TrackState.OnFront)
819 {
820 vector4 -= vector6;
821 num = 0f;
822 trackState2 = TrackState.OnFront;
823 flag6 = true;
824 }
825 break;
826 case -2:
827 if (trackState != TrackState.OnFront)
828 {
829 break;
830 }
831 if (trackOnly)
832 {
833 vector4 -= vector6;
834 num = 0f;
835 trackState2 = TrackState.OnFront;
836 flag6 = true;
837 break;
838 }
839 if (vector3.X < 0f)
840 {
841 float num6 = (float)(num22 * 16 + (num24 + 1) * 2) - vector4.X;
842 vector4.X += num6;
843 num += num6 / vector3.X;
844 }
845 vector3.X = 0f - vector3.X;
846 result[1] = true;
847 trackState2 = TrackState.OnFront;
848 break;
849 case -3:
850 if (trackState == TrackState.OnFront)
851 {
852 trackState = TrackState.NoTrack;
853 Matrix val = ((!(Velocity.X > 0f)) ? ((_rightSideConnection[num26] != 2) ? Matrix.CreateRotationZ(-(float)Math.PI / 4f) : Matrix.CreateRotationZ((float)Math.PI / 4f)) : ((_leftSideConnection[num26] != 2) ? Matrix.CreateRotationZ((float)Math.PI / 4f) : Matrix.CreateRotationZ(-(float)Math.PI / 4f)));
854 vector5 = Vector2.Transform(new Vector2(Velocity.X, 0f), val);
855 vector5.X = Velocity.X;
856 flag4 = true;
857 num = 0f;
858 }
859 break;
860 default:
861 {
862 float num4 = num23 * 16 + num3;
863 if (num22 != num12 && trackState == TrackState.NoTrack && vector4.Y > num4 && vector4.Y - num4 < 2f)
864 {
865 flag8 = false;
866 trackState = TrackState.AboveFront;
867 }
868 TrackState trackState4 = ((!(vector4.Y < num4)) ? ((!(vector4.Y > num4)) ? TrackState.OnTrack : TrackState.BelowTrack) : TrackState.AboveTrack);
869 if (num2 != -1)
870 {
871 float num5 = num23 * 16 + _tileHeight[num2][num24];
872 trackState3 = ((!(vector4.Y < num5)) ? ((!(vector4.Y > num5)) ? TrackState.OnTrack : TrackState.BelowTrack) : TrackState.AboveTrack);
873 }
874 switch (trackState4)
875 {
876 case TrackState.OnTrack:
877 trackState2 = ((trackState3 == TrackState.OnTrack) ? TrackState.OnTrack : TrackState.OnFront);
878 break;
879 case TrackState.AboveTrack:
880 trackState2 = trackState3 switch
881 {
882 TrackState.OnTrack => TrackState.OnBack,
883 TrackState.BelowTrack => TrackState.AboveFront,
884 TrackState.AboveTrack => TrackState.AboveTrack,
885 _ => TrackState.AboveFront,
886 };
887 break;
888 case TrackState.BelowTrack:
889 trackState2 = trackState3 switch
890 {
891 TrackState.OnTrack => TrackState.OnBack,
892 TrackState.AboveTrack => TrackState.AboveBack,
893 TrackState.BelowTrack => TrackState.BelowTrack,
894 _ => TrackState.BelowTrack,
895 };
896 break;
897 }
898 break;
899 }
900 }
901 }
902 if (!flag8)
903 {
904 if (trackState != trackState2)
905 {
906 bool flag9 = false;
907 if (flag7 || vector3.Y > 0f)
908 {
909 switch (trackState)
910 {
911 case TrackState.AboveTrack:
912 switch (trackState2)
913 {
914 case TrackState.AboveFront:
915 trackState2 = TrackState.OnBack;
916 break;
917 case TrackState.AboveBack:
918 trackState2 = TrackState.OnFront;
919 break;
920 case TrackState.AboveTrack:
921 trackState2 = TrackState.OnTrack;
922 break;
923 }
924 break;
925 case TrackState.AboveFront:
926 if (trackState2 == TrackState.BelowTrack)
927 {
928 trackState2 = TrackState.OnFront;
929 }
930 break;
931 case TrackState.AboveBack:
932 if (trackState2 == TrackState.BelowTrack)
933 {
934 trackState2 = TrackState.OnBack;
935 }
936 break;
937 case TrackState.OnFront:
938 trackState2 = TrackState.OnFront;
939 flag9 = true;
940 break;
941 case TrackState.OnBack:
942 trackState2 = TrackState.OnBack;
943 flag9 = true;
944 break;
945 case TrackState.OnTrack:
946 {
947 int num7 = _tileHeight[tile.FrontTrack()][num24];
948 int num8 = _tileHeight[tile.BackTrack()][num24];
949 trackState2 = ((!followDown) ? ((!followUp) ? TrackState.OnFront : ((num7 >= num8) ? TrackState.OnBack : TrackState.OnFront)) : ((num7 >= num8) ? TrackState.OnFront : TrackState.OnBack));
950 flag9 = true;
951 break;
952 }
953 }
954 int num9 = -1;
955 switch (trackState2)
956 {
957 case TrackState.OnTrack:
958 case TrackState.OnFront:
959 num9 = tile.FrontTrack();
960 break;
961 case TrackState.OnBack:
962 num9 = tile.BackTrack();
963 break;
964 }
965 if (num9 != -1)
966 {
967 if (!flag9 && Velocity.Y > Player.defaultGravity)
968 {
969 int num10 = (int)(Position.Y / 16f);
970 if (fallStart < num10 - 1)
971 {
972 delegatesData.MinecartLandingSound(Player, Position, Width, Height);
973 WheelSparks(delegatesData.MinecartDust, Position, Width, Height, 10);
974 }
975 }
976 if (trackState == TrackState.AboveFront && _trackType[num9] == 1)
977 {
978 flag3 = true;
979 }
980 vector3.Y = 0f;
981 vector4.Y = num23 * 16 + _tileHeight[num9][num24];
982 }
983 }
984 }
985 }
986 else if (trackState2 == TrackState.OnFront || trackState2 == TrackState.OnBack || trackState2 == TrackState.OnTrack)
987 {
988 if (flag && _trackType[tile.FrontTrack()] == 1)
989 {
990 flag3 = true;
991 }
992 vector3.Y = 0f;
993 }
994 if (trackState2 == TrackState.OnFront)
995 {
996 int num11 = tile.FrontTrack();
997 if (_trackType[num11] == 2 && lastBoost.X == 0f && lastBoost.Y == 0f)
998 {
999 lastBoost = new Vector2((float)num22, (float)num23);
1000 if (_boostLeft[num11])
1001 {
1002 result[4] = true;
1003 }
1004 else
1005 {
1006 result[5] = true;
1007 }
1008 }
1009 }
1010 num21 = num24;
1012 num12 = num22;
1013 num20 = num23;
1014 if (num > 0f)
1015 {
1016 float num13 = vector4.X % 2f;
1017 float num14 = vector4.Y % 2f;
1018 float num15 = 3f;
1019 float num16 = 3f;
1020 if (vector3.X < 0f)
1021 {
1022 num15 = num13 + 0.125f;
1023 }
1024 else if (vector3.X > 0f)
1025 {
1026 num15 = 2f - num13;
1027 }
1028 if (vector3.Y < 0f)
1029 {
1030 num16 = num14 + 0.125f;
1031 }
1032 else if (vector3.Y > 0f)
1033 {
1034 num16 = 2f - num14;
1035 }
1036 if (num15 == 3f && num16 == 3f)
1037 {
1038 break;
1039 }
1040 float num17 = Math.Abs(num15 / vector3.X);
1041 float num18 = Math.Abs(num16 / vector3.Y);
1042 float num19 = ((num17 < num18) ? num17 : num18);
1043 if (num19 > num)
1044 {
1045 vector6 = vector3 * num;
1046 num = 0f;
1047 }
1048 else
1049 {
1050 vector6 = vector3 * num19;
1051 num -= num19;
1052 }
1053 vector4 += vector6;
1054 continue;
1055 }
1056 if (lastBoost.X != (float)num12 || lastBoost.Y != (float)num20)
1057 {
1058 lastBoost = Vector2.Zero;
1059 }
1060 break;
1061 }
1062 if (flag3)
1063 {
1064 result[3] = true;
1065 }
1066 if (flag5)
1067 {
1068 Velocity.X = vector4.X - vector2.X;
1069 Velocity.Y = Player.defaultGravity;
1070 }
1071 else if (flag4)
1072 {
1073 result[2] = true;
1074 Velocity = vector5;
1075 }
1076 else if (result[1])
1077 {
1078 Velocity.X = 0f - Velocity.X;
1079 Position.X = vector4.X - _trackMagnetOffset.X - vector.X - Velocity.X;
1080 if (vector3.Y == 0f)
1081 {
1082 Velocity.Y = 0f;
1083 }
1084 }
1085 else
1086 {
1087 if (flag6)
1088 {
1089 Velocity.X = vector4.X - vector2.X;
1090 }
1091 if (vector3.Y == 0f)
1092 {
1093 Velocity.Y = 0f;
1094 }
1095 }
1096 Position.Y += vector4.Y - vector2.Y - Velocity.Y;
1097 Position.Y = (float)Math.Round(Position.Y, 2);
1098 if (trackState == TrackState.OnTrack || (uint)(trackState - 5) <= 1u)
1099 {
1100 result[0] = true;
1101 }
1102 return result;
1103 }
1104
1105 public static bool FrameTrack(int i, int j, bool pound, bool mute = false)
1106 {
1107 if (_trackType == null)
1108 {
1109 return false;
1110 }
1111 Tile tile = Main.tile[i, j];
1112 if (tile == null)
1113 {
1114 tile = (Main.tile[i, j] = default(Tile));
1115 }
1116 if (mute && tile.type != 314)
1117 {
1118 return false;
1119 }
1121 int num = tile.FrontTrack();
1122 int num3 = tile.BackTrack();
1123 int num4 = ((num >= 0 && num < _trackType.Length) ? _trackType[num] : 0);
1124 int num5 = -1;
1125 int num6 = -1;
1127 if (array == null)
1128 {
1129 if (pound)
1130 {
1131 return false;
1132 }
1133 tile.FrontTrack(0);
1134 tile.BackTrack(-1);
1135 return false;
1136 }
1137 if (!pound)
1138 {
1139 int num7 = -1;
1140 int num8 = -1;
1141 bool flag = false;
1142 for (int k = 0; k < array.Length; k++)
1143 {
1144 int num9 = array[k];
1145 if (num3 == array[k])
1146 {
1147 num6 = k;
1148 }
1149 if (_trackType[num9] != num4)
1150 {
1151 continue;
1152 }
1154 {
1155 if (num == array[k])
1156 {
1157 num5 = k;
1158 flag = true;
1159 }
1160 if (num7 == -1)
1161 {
1162 num7 = k;
1163 }
1164 }
1165 else
1166 {
1167 if (num == array[k])
1168 {
1169 num5 = k;
1170 flag = false;
1171 }
1172 if (num8 == -1)
1173 {
1174 num8 = k;
1175 }
1176 }
1177 }
1178 if (num8 != -1)
1179 {
1180 if (num5 == -1 || flag)
1181 {
1182 num5 = num8;
1183 }
1184 }
1185 else
1186 {
1187 if (num5 == -1)
1188 {
1189 switch (num4)
1190 {
1191 case 2:
1192 return false;
1193 case 1:
1194 return false;
1195 }
1196 num5 = num7;
1197 }
1198 num6 = -1;
1199 }
1200 }
1201 else
1202 {
1203 for (int l = 0; l < array.Length; l++)
1204 {
1205 if (num == array[l])
1206 {
1207 num5 = l;
1208 }
1209 if (num3 == array[l])
1210 {
1211 num6 = l;
1212 }
1213 }
1214 int num10 = 0;
1215 int num2 = 0;
1216 for (int m = 0; m < array.Length; m++)
1217 {
1218 if (_trackType[array[m]] == num4)
1219 {
1220 if (_leftSideConnection[array[m]] == -1 || _rightSideConnection[array[m]] == -1)
1221 {
1222 num2++;
1223 }
1224 else
1225 {
1226 num10++;
1227 }
1228 }
1229 }
1230 if (num10 < 2 && num2 < 2)
1231 {
1232 return false;
1233 }
1234 bool flag2 = num10 == 0;
1235 bool flag3 = false;
1236 if (!flag2)
1237 {
1238 while (!flag3)
1239 {
1240 num6++;
1241 if (num6 >= array.Length)
1242 {
1243 num6 = -1;
1244 break;
1245 }
1246 if ((_leftSideConnection[array[num6]] != _leftSideConnection[array[num5]] || _rightSideConnection[array[num6]] != _rightSideConnection[array[num5]]) && _trackType[array[num6]] == num4 && _leftSideConnection[array[num6]] != -1 && _rightSideConnection[array[num6]] != -1)
1247 {
1248 flag3 = true;
1249 }
1250 }
1251 }
1252 if (!flag3)
1253 {
1254 do
1255 {
1256 num5++;
1257 if (num5 >= array.Length)
1258 {
1259 num5 = -1;
1260 do
1261 {
1262 num5++;
1263 }
1264 while (_trackType[array[num5]] != num4 || (_leftSideConnection[array[num5]] == -1 || _rightSideConnection[array[num5]] == -1) != flag2);
1265 break;
1266 }
1267 }
1268 while (_trackType[array[num5]] != num4 || (_leftSideConnection[array[num5]] == -1 || _rightSideConnection[array[num5]] == -1) != flag2);
1269 }
1270 }
1271 bool flag4 = false;
1272 switch (num5)
1273 {
1274 case -2:
1275 if (tile.FrontTrack() != _firstPressureFrame)
1276 {
1277 flag4 = true;
1278 }
1279 break;
1280 case -1:
1281 if (tile.FrontTrack() != 0)
1282 {
1283 flag4 = true;
1284 }
1285 break;
1286 default:
1287 if (tile.FrontTrack() != array[num5])
1288 {
1289 flag4 = true;
1290 }
1291 break;
1292 }
1293 if (num6 == -1)
1294 {
1295 if (tile.BackTrack() != -1)
1296 {
1297 flag4 = true;
1298 }
1299 }
1300 else if (tile.BackTrack() != array[num6])
1301 {
1302 flag4 = true;
1303 }
1304 switch (num5)
1305 {
1306 case -2:
1307 tile.FrontTrack(_firstPressureFrame);
1308 break;
1309 case -1:
1310 tile.FrontTrack(0);
1311 break;
1312 default:
1313 tile.FrontTrack((short)array[num5]);
1314 break;
1315 }
1316 if (num6 == -1)
1317 {
1318 tile.BackTrack(-1);
1319 }
1320 else
1321 {
1322 tile.BackTrack((short)array[num6]);
1323 }
1324 if (pound && flag4 && !mute)
1325 {
1326 WorldGen.KillTile(i, j, fail: true);
1327 }
1328 return true;
1329 }
1330
1331 private static int GetNearbyTilesSetLookupIndex(int i, int j)
1332 {
1333 int num = 0;
1334 if (Main.tile[i - 1, j - 1] != null && Main.tile[i - 1, j - 1].type == 314)
1335 {
1336 num++;
1337 }
1338 if (Main.tile[i - 1, j] != null && Main.tile[i - 1, j].type == 314)
1339 {
1340 num += 2;
1341 }
1342 if (Main.tile[i - 1, j + 1] != null && Main.tile[i - 1, j + 1].type == 314)
1343 {
1344 num += 4;
1345 }
1346 if (Main.tile[i + 1, j - 1] != null && Main.tile[i + 1, j - 1].type == 314)
1347 {
1348 num += 8;
1349 }
1350 if (Main.tile[i + 1, j] != null && Main.tile[i + 1, j].type == 314)
1351 {
1352 num += 16;
1353 }
1354 if (Main.tile[i + 1, j + 1] != null && Main.tile[i + 1, j + 1].type == 314)
1355 {
1356 num += 32;
1357 }
1358 return num;
1359 }
1360
1361 public static bool GetOnTrack(int tileX, int tileY, ref Vector2 Position, int Width, int Height)
1362 {
1363 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
1364 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
1365 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
1366 //IL_0040: Unknown result type (might be due to invalid IL or missing references)
1367 //IL_0045: Unknown result type (might be due to invalid IL or missing references)
1368 //IL_004a: Unknown result type (might be due to invalid IL or missing references)
1369 //IL_004b: Unknown result type (might be due to invalid IL or missing references)
1370 //IL_00e8: Unknown result type (might be due to invalid IL or missing references)
1371 //IL_00e9: Unknown result type (might be due to invalid IL or missing references)
1372 //IL_00ee: Unknown result type (might be due to invalid IL or missing references)
1373 //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
1374 //IL_00f4: Unknown result type (might be due to invalid IL or missing references)
1375 //IL_00f5: Unknown result type (might be due to invalid IL or missing references)
1376 //IL_00f6: Unknown result type (might be due to invalid IL or missing references)
1377 //IL_00fb: Unknown result type (might be due to invalid IL or missing references)
1378 //IL_00fd: Unknown result type (might be due to invalid IL or missing references)
1379 //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
1380 Tile tile = Main.tile[tileX, tileY];
1381 if (tile.type != 314)
1382 {
1383 return false;
1384 }
1385 Vector2 vector = default(Vector2);
1386 ((Vector2)(ref vector))._002Ector((float)(Width / 2) - 25f, (float)(Height / 2));
1387 Vector2 vector2 = Position + vector + _trackMagnetOffset;
1388 int num = (int)vector2.X % 16 / 2;
1389 int num2 = -1;
1390 int num3 = 0;
1391 for (int i = num; i < 8; i++)
1392 {
1393 num3 = _tileHeight[tile.frameX][i];
1394 if (num3 >= 0)
1395 {
1396 num2 = i;
1397 break;
1398 }
1399 }
1400 if (num2 == -1)
1401 {
1402 for (int num4 = num - 1; num4 >= 0; num4--)
1403 {
1404 num3 = _tileHeight[tile.frameX][num4];
1405 if (num3 >= 0)
1406 {
1407 num2 = num4;
1408 break;
1409 }
1410 }
1411 }
1412 if (num2 == -1)
1413 {
1414 return false;
1415 }
1416 vector2.X = tileX * 16 + num2 * 2;
1417 vector2.Y = tileY * 16 + num3;
1419 vector2 -= vector;
1420 Position = vector2;
1421 return true;
1422 }
1423
1424 public static bool OnTrack(Vector2 Position, int Width, int Height)
1425 {
1426 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
1427 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
1428 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
1429 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
1430 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
1431 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
1432 Vector2 val = Position + new Vector2((float)(Width / 2) - 25f, (float)(Height / 2)) + _trackMagnetOffset;
1433 int num = (int)(val.X / 16f);
1434 int num2 = (int)(val.Y / 16f);
1435 if (Main.tile[num, num2] == null)
1436 {
1437 return false;
1438 }
1439 return Main.tile[num, num2].type == 314;
1440 }
1441
1442 public static float TrackRotation(Player player, ref float rotation, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData)
1443 {
1444 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
1445 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
1446 //IL_001a: Unknown result type (might be due to invalid IL or missing references)
1447 //IL_0022: Unknown result type (might be due to invalid IL or missing references)
1448 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
1449 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
1450 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
1451 //IL_0041: Unknown result type (might be due to invalid IL or missing references)
1452 //IL_004c: Unknown result type (might be due to invalid IL or missing references)
1453 //IL_0052: Unknown result type (might be due to invalid IL or missing references)
1454 //IL_006c: Unknown result type (might be due to invalid IL or missing references)
1455 GetWheelsPositions(player, Position, Width, Height, followDown, followUp, delegatesData, out var leftWheel, out var rightWheel);
1456 float num = rightWheel.Y - leftWheel.Y;
1457 float num2 = rightWheel.X - leftWheel.X;
1458 float num3 = num / num2;
1459 float num5 = leftWheel.Y + (Position.X - leftWheel.X) * num3;
1460 float num4 = (Position.X - (float)(int)Position.X) * num3;
1461 rotation = (float)Math.Atan2(num, num2);
1462 return num5 - Position.Y + num4;
1463 }
1464
1465 public static void GetWheelsPositions(Player player, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData, out Vector2 leftWheel, out Vector2 rightWheel)
1466 {
1467 //IL_0002: Unknown result type (might be due to invalid IL or missing references)
1468 //IL_0003: Unknown result type (might be due to invalid IL or missing references)
1469 //IL_000a: Unknown result type (might be due to invalid IL or missing references)
1470 //IL_000b: Unknown result type (might be due to invalid IL or missing references)
1471 //IL_0010: Unknown result type (might be due to invalid IL or missing references)
1472 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
1473 //IL_0042: Unknown result type (might be due to invalid IL or missing references)
1474 //IL_0047: Unknown result type (might be due to invalid IL or missing references)
1475 //IL_0048: Unknown result type (might be due to invalid IL or missing references)
1476 //IL_004d: Unknown result type (might be due to invalid IL or missing references)
1477 //IL_007e: Unknown result type (might be due to invalid IL or missing references)
1478 //IL_0083: Unknown result type (might be due to invalid IL or missing references)
1479 //IL_0084: Unknown result type (might be due to invalid IL or missing references)
1480 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
1481 leftWheel = Position;
1482 rightWheel = Position;
1483 Vector2 lastBoost = Vector2.Zero;
1484 Vector2 Velocity = default(Vector2);
1485 ((Vector2)(ref Velocity))._002Ector(-12f, 0f);
1486 TrackCollision(player, ref leftWheel, ref Velocity, ref lastBoost, Width, Height, followDown, followUp, 0, trackOnly: true, delegatesData);
1487 leftWheel += Velocity;
1488 ((Vector2)(ref Velocity))._002Ector(12f, 0f);
1489 TrackCollision(player, ref rightWheel, ref Velocity, ref lastBoost, Width, Height, followDown, followUp, 0, trackOnly: true, delegatesData);
1490 rightWheel += Velocity;
1491 }
1492
1493 public static void HitTrackSwitch(Vector2 Position, int Width, int Height)
1494 {
1495 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
1496 //IL_0003: Unknown result type (might be due to invalid IL or missing references)
1497 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
1498 Vector2 magnetPosition = GetMagnetPosition(Position, Width, Height);
1499 int num = (int)(magnetPosition.X / 16f);
1500 int num2 = (int)(magnetPosition.Y / 16f);
1502 NetMessage.SendData(59, -1, -1, null, num, num2);
1503 }
1504
1505 public static Vector2 GetMagnetPosition(Vector2 Position, int Width, int Height)
1506 {
1507 //IL_000e: Unknown result type (might be due to invalid IL or missing references)
1508 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
1509 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
1510 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
1511 //IL_002d: Unknown result type (might be due to invalid IL or missing references)
1512 //IL_0032: Unknown result type (might be due to invalid IL or missing references)
1513 new Vector2((float)(Width / 2) - 25f, (float)(Height / 2));
1514 return Position + new Vector2((float)(Width / 2) - 25f, (float)(Height / 2)) + _trackMagnetOffset;
1515 }
1516
1517 public static void FlipSwitchTrack(int i, int j)
1518 {
1519 Tile tileTrack = Main.tile[i, j];
1520 short num = tileTrack.FrontTrack();
1521 if (num == -1)
1522 {
1523 return;
1524 }
1525 switch (_trackType[num])
1526 {
1527 case 0:
1528 if (tileTrack.BackTrack() != -1)
1529 {
1530 tileTrack.FrontTrack(tileTrack.BackTrack());
1531 tileTrack.BackTrack(num);
1532 NetMessage.SendTileSquare(-1, i, j);
1533 }
1534 break;
1535 case 2:
1536 FrameTrack(i, j, pound: true, mute: true);
1537 NetMessage.SendTileSquare(-1, i, j);
1538 break;
1539 }
1540 }
1541
1542 public static void TrackColors(int i, int j, Tile trackTile, out int frontColor, out int backColor)
1543 {
1544 if (trackTile.type == 314)
1545 {
1546 frontColor = trackTile.color();
1547 backColor = frontColor;
1548 if (trackTile.frameY == -1)
1549 {
1550 return;
1551 }
1552 int num = _leftSideConnection[trackTile.frameX];
1553 int num4 = _rightSideConnection[trackTile.frameX];
1554 int num5 = _leftSideConnection[trackTile.frameY];
1555 int num6 = _rightSideConnection[trackTile.frameY];
1556 int num7 = 0;
1557 int num8 = 0;
1558 int num9 = 0;
1559 int num10 = 0;
1560 for (int k = 0; k < 4; k++)
1561 {
1562 int num2 = (k switch
1563 {
1564 1 => num4,
1565 2 => num5,
1566 3 => num6,
1567 _ => num,
1568 }) switch
1569 {
1570 0 => -1,
1571 1 => 0,
1572 2 => 1,
1573 _ => 0,
1574 };
1575 Tile tile = ((k % 2 != 0) ? Main.tile[i + 1, j + num2] : Main.tile[i - 1, j + num2]);
1576 int num3 = ((tile != null && tile.active() && tile.type == 314) ? tile.color() : 0);
1577 switch (k)
1578 {
1579 default:
1580 num7 = num3;
1581 break;
1582 case 1:
1583 num8 = num3;
1584 break;
1585 case 2:
1586 num9 = num3;
1587 break;
1588 case 3:
1589 num10 = num3;
1590 break;
1591 }
1592 }
1593 if (num == num5)
1594 {
1595 if (num8 != 0)
1596 {
1597 frontColor = num8;
1598 }
1599 else if (num7 != 0)
1600 {
1601 frontColor = num7;
1602 }
1603 if (num10 != 0)
1604 {
1605 backColor = num10;
1606 }
1607 else if (num9 != 0)
1608 {
1609 backColor = num9;
1610 }
1611 return;
1612 }
1613 if (num4 == num6)
1614 {
1615 if (num7 != 0)
1616 {
1617 frontColor = num7;
1618 }
1619 else if (num8 != 0)
1620 {
1621 frontColor = num8;
1622 }
1623 if (num9 != 0)
1624 {
1625 backColor = num9;
1626 }
1627 else if (num10 != 0)
1628 {
1629 backColor = num10;
1630 }
1631 return;
1632 }
1633 if (num8 == 0)
1634 {
1635 if (num7 != 0)
1636 {
1637 frontColor = num7;
1638 }
1639 }
1640 else if (num7 != 0)
1641 {
1642 frontColor = ((num4 <= num) ? num8 : num7);
1643 }
1644 if (num10 == 0)
1645 {
1646 if (num9 != 0)
1647 {
1648 backColor = num9;
1649 }
1650 }
1651 else if (num9 != 0)
1652 {
1653 backColor = ((num6 <= num5) ? num10 : num9);
1654 }
1655 }
1656 else
1657 {
1658 frontColor = 0;
1659 backColor = 0;
1660 }
1661 }
1662
1663 public static bool DrawLeftDecoration(int frameID)
1664 {
1666 {
1667 return false;
1668 }
1669 return _leftSideConnection[frameID] == 2;
1670 }
1671
1672 public static bool DrawRightDecoration(int frameID)
1673 {
1675 {
1676 return false;
1677 }
1678 return _rightSideConnection[frameID] == 2;
1679 }
1680
1681 public static bool DrawBumper(int frameID)
1682 {
1684 {
1685 return false;
1686 }
1687 if (_tileHeight[frameID][0] != -1)
1688 {
1689 return _tileHeight[frameID][7] == -1;
1690 }
1691 return true;
1692 }
1693
1694 public static bool DrawBouncyBumper(int frameID)
1695 {
1697 {
1698 return false;
1699 }
1700 if (_tileHeight[frameID][0] != -2)
1701 {
1702 return _tileHeight[frameID][7] == -2;
1703 }
1704 return true;
1705 }
1706
1707 public static void PlaceTrack(Tile trackCache, int style)
1708 {
1709 trackCache.active(active: true);
1710 trackCache.type = 314;
1711 trackCache.frameY = -1;
1712 switch (style)
1713 {
1714 case 0:
1715 trackCache.frameX = -1;
1716 break;
1717 case 1:
1718 trackCache.frameX = _firstPressureFrame;
1719 break;
1720 case 2:
1721 trackCache.frameX = _firstLeftBoostFrame;
1722 break;
1723 case 3:
1724 trackCache.frameX = _firstRightBoostFrame;
1725 break;
1726 }
1727 }
1728
1729 public static int GetTrackItem(Tile trackCache)
1730 {
1731 return _trackType[trackCache.frameX] switch
1732 {
1733 0 => 2340,
1734 1 => 2492,
1735 2 => 2739,
1736 _ => 0,
1737 };
1738 }
1739
1740 public static Rectangle GetSourceRect(int frameID, int animationFrame = 0)
1741 {
1742 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
1743 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
1744 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
1745 //IL_0021: Unknown result type (might be due to invalid IL or missing references)
1746 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
1747 //IL_0056: Unknown result type (might be due to invalid IL or missing references)
1749 {
1750 return new Rectangle(0, 0, 0, 0);
1751 }
1752 Vector2 vector = _texturePosition[frameID];
1753 Rectangle result = default(Rectangle);
1754 ((Rectangle)(ref result))._002Ector((int)vector.X, (int)vector.Y, 16, 16);
1755 if (frameID < 36 && _trackType[frameID] == 2)
1756 {
1757 result.Y += 18 * animationFrame;
1758 }
1759 return result;
1760 }
1761
1763 {
1764 //IL_0005: Unknown result type (might be due to invalid IL or missing references)
1765 //IL_000b: Unknown result type (might be due to invalid IL or missing references)
1767 if (expectedYOffsetForLeft.HasValue)
1768 {
1769 short num = tileTrack.FrontTrack();
1772 {
1773 return false;
1774 }
1775 }
1776 if (expectedYOffsetForRight.HasValue)
1777 {
1778 short num3 = tileTrack.FrontTrack();
1781 {
1782 return false;
1783 }
1784 }
1785 return true;
1786 }
1787
1789 {
1790 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
1791 //IL_0006: Unknown result type (might be due to invalid IL or missing references)
1792 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
1793 //IL_00ec: Unknown result type (might be due to invalid IL or missing references)
1794 //IL_00f2: Unknown result type (might be due to invalid IL or missing references)
1797 if (array == null)
1798 {
1799 return;
1800 }
1802 int num = _trackType[tileSafely.FrontTrack()];
1803 int? num2 = null;
1804 int[] array2 = array;
1805 foreach (int num3 in array2)
1806 {
1809 _ = _trackType[num3];
1810 if (expectedYOffsetForLeft.HasValue)
1811 {
1814 {
1815 continue;
1816 }
1817 }
1818 if (expectedYOffsetForRight.HasValue)
1819 {
1822 {
1823 continue;
1824 }
1825 }
1826 if (_trackType[num3] == num)
1827 {
1828 num2 = num3;
1829 break;
1830 }
1831 }
1832 if (num2.HasValue)
1833 {
1834 tileSafely.FrontTrack((short)num2.Value);
1836 }
1837 }
1838
1840 {
1841 return offsetY switch
1842 {
1843 -1 => 0,
1844 1 => 2,
1845 _ => 1,
1846 };
1847 }
1848
1850 {
1851 return trackConnectionValue switch
1852 {
1853 0 => -1,
1854 2 => 1,
1855 _ => 0,
1856 };
1857 }
1858
1859 public static void WheelSparks(Action<Vector2> DustAction, Vector2 Position, int Width, int Height, int sparkCount)
1860 {
1861 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
1862 //IL_0016: Unknown result type (might be due to invalid IL or missing references)
1863 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
1864 //IL_001c: Unknown result type (might be due to invalid IL or missing references)
1865 //IL_0021: Unknown result type (might be due to invalid IL or missing references)
1866 //IL_0026: Unknown result type (might be due to invalid IL or missing references)
1867 //IL_002c: Unknown result type (might be due to invalid IL or missing references)
1868 Vector2 vector = default(Vector2);
1869 ((Vector2)(ref vector))._002Ector((float)(Width / 2) - 25f, (float)(Height / 2));
1870 Vector2 obj = Position + vector + _trackMagnetOffset;
1871 for (int i = 0; i < sparkCount; i++)
1872 {
1873 DustAction(obj);
1874 }
1875 }
1876
1877 private static short FrontTrack(this Tile tileTrack)
1878 {
1879 return tileTrack.frameX;
1880 }
1881
1882 private static void FrontTrack(this Tile tileTrack, short trackID)
1883 {
1884 tileTrack.frameX = trackID;
1885 }
1886
1887 private static short BackTrack(this Tile tileTrack)
1888 {
1889 return tileTrack.frameY;
1890 }
1891
1892 private static void BackTrack(this Tile tileTrack, short trackID)
1893 {
1894 tileTrack.frameY = trackID;
1895 }
1896}
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:421
static Asset< Texture2D > MinecartMount
static bool dedServ
Definition Main.cs:1301
static Tilemap tile
Definition Main.cs:1820
static bool FrameTrack(int i, int j, bool pound, bool mute=false)
Definition Minecart.cs:1105
const int Type_Normal
Definition Minecart.cs:61
const float BoosterSpeed
Definition Minecart.cs:59
const int LeftDownDecoration
Definition Minecart.cs:23
const int Flag_BouncyBumper
Definition Minecart.cs:33
const int RightDownDecoration
Definition Minecart.cs:25
const int BumperEnd
Definition Minecart.cs:51
static int[] _leftSideConnection
Definition Minecart.cs:71
static bool[] _boostLeft
Definition Minecart.cs:77
static void FrontTrack(this Tile tileTrack, short trackID)
Definition Minecart.cs:1882
static int[][] _trackSwitchOptions
Definition Minecart.cs:87
const int Type_Pressure
Definition Minecart.cs:63
static int ConvertOffsetYToTrackConnectionValue(int offsetY)
Definition Minecart.cs:1839
static BitsByte TrackCollision(Player Player, ref Vector2 Position, ref Vector2 Velocity, ref Vector2 lastBoost, int Width, int Height, bool followDown, bool followUp, int fallStart, bool trackOnly, Mount.MountDelegatesData delegatesData)
Definition Minecart.cs:634
static void TryFittingTileOrientation(Point tileCoords, int? expectedYOffsetForLeft, int? expectedYOffsetForRight)
Definition Minecart.cs:1788
static short FrontTrack(this Tile tileTrack)
Definition Minecart.cs:1877
const int Flag_OnTrack
Definition Minecart.cs:31
static bool DrawBouncyBumper(int frameID)
Definition Minecart.cs:1694
static short _firstPressureFrame
Definition Minecart.cs:81
static void PlaceTrack(Tile trackCache, int style)
Definition Minecart.cs:1707
const int BottomConnection
Definition Minecart.cs:49
static Vector2 GetMagnetPosition(Vector2 Position, int Width, int Height)
Definition Minecart.cs:1505
static bool DrawRightDecoration(int frameID)
Definition Minecart.cs:1672
static bool DrawBumper(int frameID)
Definition Minecart.cs:1681
const int Flag_HitSwitch
Definition Minecart.cs:37
static bool GetOnTrack(int tileX, int tileY, ref Vector2 Position, int Width, int Height)
Definition Minecart.cs:1361
const int NoConnection
Definition Minecart.cs:43
static short _firstRightBoostFrame
Definition Minecart.cs:85
static Rectangle GetSourceRect(int frameID, int animationFrame=0)
Definition Minecart.cs:1740
static void FlipSwitchTrack(int i, int j)
Definition Minecart.cs:1517
static bool OnTrack(Vector2 Position, int Width, int Height)
Definition Minecart.cs:1424
static Vector2[] _texturePosition
Definition Minecart.cs:79
const int Flag_UsedRamp
Definition Minecart.cs:35
const int Type_Booster
Definition Minecart.cs:65
const int TopConnection
Definition Minecart.cs:45
const int MiddleConnection
Definition Minecart.cs:47
static void Initialize()
Definition Minecart.cs:91
const int TotalFrames
Definition Minecart.cs:21
static void TrackColors(int i, int j, Tile trackTile, out int frontColor, out int backColor)
Definition Minecart.cs:1542
const int RampEnd
Definition Minecart.cs:55
static short _firstLeftBoostFrame
Definition Minecart.cs:83
static void GetWheelsPositions(Player player, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData, out Vector2 leftWheel, out Vector2 rightWheel)
Definition Minecart.cs:1465
static bool IsPressurePlate(Tile tile)
Definition Minecart.cs:621
static void WheelSparks(Action< Vector2 > DustAction, Vector2 Position, int Width, int Height, int sparkCount)
Definition Minecart.cs:1859
static int[] _trackType
Definition Minecart.cs:75
static bool DrawLeftDecoration(int frameID)
Definition Minecart.cs:1663
const int Flag_BoostLeft
Definition Minecart.cs:39
const int BouncyEnd
Definition Minecart.cs:53
static float TrackRotation(Player player, ref float rotation, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData)
Definition Minecart.cs:1442
const int OpenEnd
Definition Minecart.cs:57
static int GetTrackItem(Tile trackCache)
Definition Minecart.cs:1729
const int BouncyBumperDecoration
Definition Minecart.cs:27
static short BackTrack(this Tile tileTrack)
Definition Minecart.cs:1887
const float MinecartTextureWidth
Definition Minecart.cs:69
static int[] _rightSideConnection
Definition Minecart.cs:73
static Vector2 _trackMagnetOffset
Definition Minecart.cs:67
static int GetNearbyTilesSetLookupIndex(int i, int j)
Definition Minecart.cs:1331
static void BackTrack(this Tile tileTrack, short trackID)
Definition Minecart.cs:1892
static int[][] _tileHeight
Definition Minecart.cs:89
static void HitTrackSwitch(Vector2 Position, int Width, int Height)
Definition Minecart.cs:1493
static int ConvertTrackConnectionValueToOffsetY(int trackConnectionValue)
Definition Minecart.cs:1849
static bool GetAreExpectationsForSidesMet(Point tileCoords, int? expectedYOffsetForLeft, int? expectedYOffsetForRight)
Definition Minecart.cs:1762
const int Flag_BoostRight
Definition Minecart.cs:41
const int RegularBumperDecoration
Definition Minecart.cs:29
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
static void SendTileSquare(int whoAmi, int tileX, int tileY, int xSize, int ySize, TileChangeType changeType=TileChangeType.None)
static float defaultGravity
Definition Player.cs:2654
static void HitSwitch(int i, int j)
Definition Wiring.cs:254
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
byte color()
Legacy code, use P:Terraria.Tile.TileColor instead.
Definition Tile.cs:1153
bool nactive()
Legacy code, use P:Terraria.Tile.HasUnactuatedTile instead.
Definition Tile.cs:1044
ref ushort type
Legacy code, use P:Terraria.Tile.TileType instead.
Definition Tile.cs:522
bool active()
Legacy code, use P:Terraria.Tile.HasTile instead.
Definition Tile.cs:999
ref short frameX
Legacy code, use P:Terraria.Tile.TileFrameX instead.
Definition Tile.cs:532
A data structure used for accessing information about tiles, walls, wires, and liquids at a single po...
Definition Tile.cs:15