Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WorldGen.cs
Go to the documentation of this file.
1using System;
9using Terraria.Chat;
11using Terraria.Enums;
21using Terraria.ID;
22using Terraria.IO;
24using Terraria.Map;
28
29namespace Terraria;
30
31public class WorldGen
32{
33 public static class WorldSize
34 {
35 public const int Small = 0;
36
37 public const int Medium = 1;
38
39 public const int Large = 2;
40 }
41
42 public static class SavedOreTiers
43 {
44 public static int Copper = 7;
45
46 public static int Iron = 6;
47
48 public static int Silver = 9;
49
50 public static int Gold = 8;
51
52 public static int Cobalt = 107;
53
54 public static int Mythril = 108;
55
56 public static int Adamantite = 111;
57 }
58
59 public static class Hooks
60 {
62
64
65 public static event Action OnWorldLoad;
66
67 public static void Initialize()
68 {
69 Player.Hooks.OnEnterWorld += delegate(Player player)
70 {
71 if (player.whoAmI == Main.myPlayer)
72 {
74 if (Main.netMode != 1)
75 {
77 }
78 }
79 };
80 OnWorldLoad += mysticLogsEvent.StartWorld;
83 }
84
85 public static void WorldLoaded()
86 {
87 if (Hooks.OnWorldLoad != null)
88 {
90 }
91 }
92
100 }
101
102 public static class Spread
103 {
104 public static void Wall(int x, int y, int wallType)
105 {
106 if (!InWorld(x, y))
107 {
108 return;
109 }
110 ushort wall = (ushort)wallType;
114 list2.Add(new Point(x, y));
115 while (list2.Count > 0)
116 {
117 list.Clear();
119 list2.Clear();
120 while (list.Count > 0)
121 {
122 Point item = list[0];
123 if (!InWorld(item.X, item.Y, 1))
124 {
125 list.Remove(item);
126 continue;
127 }
130 Tile tile = Main.tile[item.X, item.Y];
131 if (SolidTile(item.X, item.Y) || tile.wall != 0)
132 {
133 if (tile.active() && tile.wall == 0)
134 {
135 tile.wall = wall;
136 }
137 continue;
138 }
139 tile.wall = wall;
140 Point item2 = new Point(item.X - 1, item.Y);
141 if (!hashSet.Contains(item2))
142 {
143 list2.Add(item2);
144 }
145 item2 = new Point(item.X + 1, item.Y);
146 if (!hashSet.Contains(item2))
147 {
148 list2.Add(item2);
149 }
150 item2 = new Point(item.X, item.Y - 1);
151 if (!hashSet.Contains(item2))
152 {
153 list2.Add(item2);
154 }
155 item2 = new Point(item.X, item.Y + 1);
156 if (!hashSet.Contains(item2))
157 {
158 list2.Add(item2);
159 }
160 }
161 }
162 }
163
164 public static void Wall2(int x, int y, int wallType)
165 {
166 if (!InWorld(x, y))
167 {
168 return;
169 }
170 ushort num = (ushort)wallType;
171 int num2 = 0;
176 list2.Add(new Point(x, y));
177 while (list2.Count > 0)
178 {
179 list.Clear();
181 list2.Clear();
182 while (list.Count > 0)
183 {
184 Point item = list[0];
185 if (!InWorld(item.X, item.Y, 1))
186 {
187 list.Remove(item);
188 continue;
189 }
192 Tile tile = Main.tile[item.X, item.Y];
193 if (tile.wall == num || WallID.Sets.CannotBeReplacedByWallSpread[tile.wall])
194 {
195 continue;
196 }
197 if (!SolidTile(item.X, item.Y))
198 {
199 bool flag = WallID.Sets.WallSpreadStopsAtAir[num];
200 if (flag && tile.wall == 0)
201 {
202 list.Remove(item);
203 continue;
204 }
205 num2++;
206 if (num2 >= maxWallOut)
207 {
209 continue;
210 }
211 tile.wall = num;
212 Point item2 = new Point(item.X - 1, item.Y);
213 if (!hashSet.Contains(item2))
214 {
215 list2.Add(item2);
216 }
217 item2 = new Point(item.X + 1, item.Y);
218 if (!hashSet.Contains(item2))
219 {
220 list2.Add(item2);
221 }
222 item2 = new Point(item.X, item.Y - 1);
223 if (!hashSet.Contains(item2))
224 {
225 list2.Add(item2);
226 }
227 item2 = new Point(item.X, item.Y + 1);
228 if (!hashSet.Contains(item2))
229 {
230 list2.Add(item2);
231 }
232 if (flag)
233 {
234 item2 = new Point(item.X - 1, item.Y - 1);
235 if (!hashSet.Contains(item2))
236 {
237 list2.Add(item2);
238 }
239 item2 = new Point(item.X + 1, item.Y - 1);
240 if (!hashSet.Contains(item2))
241 {
242 list2.Add(item2);
243 }
244 item2 = new Point(item.X - 1, item.Y + 1);
245 if (!hashSet.Contains(item2))
246 {
247 list2.Add(item2);
248 }
249 item2 = new Point(item.X + 1, item.Y + 1);
250 if (!hashSet.Contains(item2))
251 {
252 list2.Add(item2);
253 }
254 item2 = new Point(item.X - 2, item.Y);
255 if (!hashSet.Contains(item2))
256 {
257 list2.Add(item2);
258 }
259 item2 = new Point(item.X + 2, item.Y);
260 if (!hashSet.Contains(item2))
261 {
262 list2.Add(item2);
263 }
264 }
265 }
266 else if (tile.active())
267 {
268 tile.wall = num;
269 }
270 }
271 }
272 }
273
274 public static void Moss(int x, int y)
275 {
276 if (!InWorld(x, y))
277 {
278 return;
279 }
280 ushort mossWall = GenVars.mossWall;
281 ushort mossTile = GenVars.mossTile;
285 list2.Add(new Point(x, y));
286 while (list2.Count > 0)
287 {
288 list.Clear();
290 list2.Clear();
291 while (list.Count > 0)
292 {
293 Point item = list[0];
294 if (!InWorld(item.X, item.Y, 1))
295 {
296 list.Remove(item);
297 continue;
298 }
301 Tile tile = Main.tile[item.X, item.Y];
302 if (SolidTile(item.X, item.Y) || tile.wall != 0)
303 {
304 if (tile.active())
305 {
306 if (tile.wall == 0)
307 {
308 tile.wall = mossWall;
309 }
310 if (tile.type == 1)
311 {
312 tile.type = mossTile;
313 }
314 }
315 continue;
316 }
317 tile.wall = mossWall;
318 Point item2 = new Point(item.X - 1, item.Y);
319 if (!hashSet.Contains(item2))
320 {
321 list2.Add(item2);
322 }
323 item2 = new Point(item.X + 1, item.Y);
324 if (!hashSet.Contains(item2))
325 {
326 list2.Add(item2);
327 }
328 item2 = new Point(item.X, item.Y - 1);
329 if (!hashSet.Contains(item2))
330 {
331 list2.Add(item2);
332 }
333 item2 = new Point(item.X, item.Y + 1);
334 if (!hashSet.Contains(item2))
335 {
336 list2.Add(item2);
337 }
338 }
339 }
340 }
341
342 public static void Gem(int x, int y)
343 {
344 if (!InWorld(x, y))
345 {
346 return;
347 }
351 list2.Add(new Point(x, y));
352 while (list2.Count > 0)
353 {
354 list.Clear();
356 list2.Clear();
357 while (list.Count > 0)
358 {
359 Point item = list[0];
360 if (!InWorld(item.X, item.Y, 1))
361 {
362 list.Remove(item);
363 continue;
364 }
367 Tile tile = Main.tile[item.X, item.Y];
368 if (SolidTile(item.X, item.Y) || tile.wall != 0)
369 {
370 if (tile.active())
371 {
372 if (Gemmable(tile.type))
373 {
374 tile.type = randGemTile();
375 }
376 Tile tile2 = Main.tile[item.X - 1, item.Y];
377 if (Gemmable(tile2.type))
378 {
379 tile2.type = randGemTile();
380 }
381 tile2 = Main.tile[item.X + 1, item.Y];
382 if (Gemmable(tile2.type))
383 {
384 tile2.type = randGemTile();
385 }
386 tile2 = Main.tile[item.X, item.Y - 1];
387 if (Gemmable(tile2.type))
388 {
389 tile2.type = randGemTile();
390 }
391 tile2 = Main.tile[item.X, item.Y + 1];
392 if (Gemmable(tile2.type))
393 {
394 tile2.type = randGemTile();
395 }
396 }
397 }
398 else
399 {
400 tile.wall = (ushort)(48 + randGem());
401 if (!tile.active() && genRand.Next(2) == 0)
402 {
403 PlaceTile(item.X, item.Y, 178, mute: true, forced: false, -1, randGem());
404 }
405 Point item2 = new Point(item.X - 1, item.Y);
406 if (!hashSet.Contains(item2))
407 {
408 list2.Add(item2);
409 }
410 item2 = new Point(item.X + 1, item.Y);
411 if (!hashSet.Contains(item2))
412 {
413 list2.Add(item2);
414 }
415 item2 = new Point(item.X, item.Y - 1);
416 if (!hashSet.Contains(item2))
417 {
418 list2.Add(item2);
419 }
420 item2 = new Point(item.X, item.Y + 1);
421 if (!hashSet.Contains(item2))
422 {
423 list2.Add(item2);
424 }
425 }
426 }
427 }
428 }
429
430 public static void Spider(int x, int y)
431 {
432 if (!InWorld(x, y))
433 {
434 return;
435 }
436 byte wall = 62;
440 list2.Add(new Point(x, y));
441 while (list2.Count > 0)
442 {
443 list.Clear();
445 list2.Clear();
446 while (list.Count > 0)
447 {
448 Point item = list[0];
449 if (!InWorld(item.X, item.Y, 1))
450 {
451 list.Remove(item);
452 continue;
453 }
456 Tile tile = Main.tile[item.X, item.Y];
457 if (SolidTile(item.X, item.Y) || tile.wall != 0)
458 {
459 if (tile.active() && tile.wall == 0)
460 {
461 tile.wall = wall;
462 }
463 continue;
464 }
465 tile.wall = wall;
467 if (!tile.active())
468 {
469 tile.liquid = 0;
470 tile.lava(lava: false);
471 if (SolidTile(item.X, item.Y + 1) && genRand.Next(3) == 0)
472 {
473 if (genRand.Next(15) == 0)
474 {
475 AddBuriedChest(item.X, item.Y, 939, notNearOtherChests: true, 15, trySlope: false, 0);
476 }
477 else
478 {
479 PlacePot(item.X, item.Y, 28, genRand.Next(19, 21));
480 }
481 }
482 if (!tile.active())
483 {
484 if (SolidTile(item.X, item.Y - 1) && genRand.Next(3) == 0)
485 {
486 PlaceTight(item.X, item.Y, spiders: true);
487 }
488 else if (SolidTile(item.X, item.Y + 1))
489 {
490 PlaceTile(item.X, item.Y, 187, mute: true, forced: false, -1, 9 + genRand.Next(5));
491 if (genRand.Next(3) == 0)
492 {
493 if (!tile.active())
494 {
495 PlaceSmallPile(item.X, item.Y, 34 + genRand.Next(4), 1, 185);
496 }
497 if (!tile.active())
498 {
499 PlaceSmallPile(item.X, item.Y, 48 + genRand.Next(6), 0, 185);
500 }
501 }
502 }
503 }
504 }
505 Point item2 = new Point(item.X - 1, item.Y);
506 if (!hashSet.Contains(item2))
507 {
508 list2.Add(item2);
509 }
510 item2 = new Point(item.X + 1, item.Y);
511 if (!hashSet.Contains(item2))
512 {
513 list2.Add(item2);
514 }
515 item2 = new Point(item.X, item.Y - 1);
516 if (!hashSet.Contains(item2))
517 {
518 list2.Add(item2);
519 }
520 item2 = new Point(item.X, item.Y + 1);
521 if (!hashSet.Contains(item2))
522 {
523 list2.Add(item2);
524 }
525 }
526 }
527 }
528
529 public static void WallDungeon(int x, int y, int wallType)
530 {
531 if (!InWorld(x, y))
532 {
533 return;
534 }
535 ushort num = (ushort)wallType;
539 list2.Add(new Point(x, y));
540 while (list2.Count > 0)
541 {
542 list.Clear();
544 list2.Clear();
545 while (list.Count > 0)
546 {
547 Point item = list[0];
548 if (!InWorld(item.X, item.Y, 1))
549 {
550 list.Remove(item);
551 continue;
552 }
555 Tile tile = Main.tile[item.X, item.Y];
556 if (!SolidTile(item.X, item.Y) && tile.wall != num && tile.wall > 0 && tile.wall != 244)
557 {
558 tile.wall = num;
559 Point item2 = new Point(item.X - 1, item.Y);
560 if (!hashSet.Contains(item2))
561 {
562 list2.Add(item2);
563 }
564 item2 = new Point(item.X + 1, item.Y);
565 if (!hashSet.Contains(item2))
566 {
567 list2.Add(item2);
568 }
569 item2 = new Point(item.X, item.Y - 1);
570 if (!hashSet.Contains(item2))
571 {
572 list2.Add(item2);
573 }
574 item2 = new Point(item.X, item.Y + 1);
575 if (!hashSet.Contains(item2))
576 {
577 list2.Add(item2);
578 }
579 }
580 else if (tile.active())
581 {
582 tile.wall = num;
583 }
584 }
585 }
586 }
587
588 private static bool Gemmable(int type)
589 {
590 if (type != 0 && type != 1 && type != 40 && type != 59 && type != 60 && type != 70 && type != 147)
591 {
592 return type == 161;
593 }
594 return true;
595 }
596 }
597
598 public static class TenthAnniversaryWorldInfo
599 {
600 public static int[] GoodPrefixIdsForAccessory = new int[4] { 65, 68, 72, 76 };
601
602 public static int[] GoodPrefixIdsForMeleeWeapon = new int[3] { 81, 59, 57 };
603
604 public static int[] GoodPrefixIdsForRangedWeapon = new int[3] { 82, 57, 60 };
605
606 public static int[] GoodPrefixIdsForMagicWeapon = new int[3] { 83, 57, 60 };
607
608 public static int[] GoodPrefixIdsForSummonerWeapon = new int[3] { 83, 57, 60 };
609 }
610
611 public struct GrowTreeSettings
612 {
613 public delegate bool IsTileFitForTreeGroundTest(int tileType);
614
616
617 public static class Profiles
618 {
629
640
651
662
673
684
695
706
717
728
730 {
731 switch (itemType)
732 {
733 default:
734 profile = default(GrowTreeSettings);
735 return false;
736 case 4857:
738 return true;
739 case 4852:
741 return true;
742 case 4856:
744 return true;
745 case 4854:
747 return true;
748 case 4855:
750 return true;
751 case 4853:
753 return true;
754 case 4851:
756 return true;
757 case 4907:
759 return true;
760 case 4871:
762 return true;
763 }
764 }
765
766 public static bool TryGetFromTreeId(int tileType, out GrowTreeSettings profile)
767 {
768 switch (tileType)
769 {
770 default:
771 profile = default(GrowTreeSettings);
772 return false;
773 case 589:
775 return true;
776 case 584:
778 return true;
779 case 588:
781 return true;
782 case 586:
784 return true;
785 case 587:
787 return true;
788 case 585:
790 return true;
791 case 583:
793 return true;
794 case 616:
796 return true;
797 case 596:
799 return true;
800 case 634:
802 return true;
803 }
804 }
805 }
806
807 public ushort TreeTileType;
808
809 public int TreeHeightMin;
810
811 public int TreeHeightMax;
812
814
815 public IsTileFitForTreeGroundTest GroundTest;
816
817 public IsWallTypeFitForTreeBack WallTest;
818
819 public ushort SaplingTileType;
820 }
821
822 public struct CheckTreeSettings
823 {
825
826 public GroundValidTest IsGroundValid;
827 }
828
830 {
831 None,
833 }
834
835 public delegate bool GetTreeFoliageDataMethod(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight);
836
837 public struct TileMergeCullCache
838 {
839 public bool CullTop;
840
841 public bool CullBottom;
842
843 public bool CullLeft;
844
845 public bool CullRight;
846
847 public bool CullTopLeft;
848
849 public bool CullTopRight;
850
851 public bool CullBottomLeft;
852
853 public bool CullBottomRight;
854
855 public void Cull(ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
856 {
857 if (CullTop)
858 {
859 up = -1;
860 }
861 if (CullBottom)
862 {
863 down = -1;
864 }
865 if (CullLeft)
866 {
867 left = -1;
868 }
869 if (CullRight)
870 {
871 right = -1;
872 }
873 if (CullTopLeft)
874 {
875 upLeft = -1;
876 }
877 if (CullTopRight)
878 {
879 upRight = -1;
880 }
881 if (CullBottomLeft)
882 {
883 downLeft = -1;
884 }
885 if (CullBottomRight)
886 {
887 downRight = -1;
888 }
889 }
890 }
891
893
895
896 public static int tileReframeCount;
897
898 public static bool noMapUpdate;
899
900 public static int treeBG1;
901
902 public static int treeBG2;
903
904 public static int treeBG3;
905
906 public static int treeBG4;
907
908 public static int corruptBG;
909
910 public static int jungleBG;
911
912 public static int snowBG;
913
914 public static int hallowBG;
915
916 public static int crimsonBG;
917
918 public static int desertBG;
919
920 public static int oceanBG;
921
922 public static int mushroomBG;
923
924 public static int underworldBG;
925
926 public static readonly int oceanDistance = 250;
927
928 public static readonly int beachDistance = 380;
929
930 public static readonly int shimmerSafetyDistance = 150;
931
932 public static bool crimson;
933
934 public static int[] tileCounts = new int[TileID.Count];
935
936 public static int totalEvil;
937
938 public static int totalBlood;
939
940 public static int totalGood;
941
942 public static int totalSolid;
943
944 public static int totalEvil2;
945
946 public static int totalBlood2;
947
948 public static int totalGood2;
949
950 public static int totalSolid2;
951
952 public static byte tEvil;
953
954 public static byte tBlood;
955
956 public static byte tGood;
957
958 public static string currentWorldSeed;
959
960 public static int totalX;
961
962 public static int totalD;
963
964 public static bool IsGeneratingHardMode;
965
966 public static bool noTileActions;
967
968 public static bool spawnEye;
969
970 public static int spawnHardBoss;
971
972 public static volatile bool gen;
973
974 public static bool shadowOrbSmashed;
975
976 public static int shadowOrbCount;
977
978 public static int altarCount;
979
980 public static bool spawnMeteor;
981
982 public static bool loadFailed = false;
983
984 public static bool loadSuccess = false;
985
986 public static bool worldCleared;
987
988 public static bool worldBackup;
989
990 public static bool loadBackup = false;
991
992 private static int lastMaxTilesX;
993
994 private static int lastMaxTilesY;
995
996 private static bool mergeUp;
997
998 private static bool mergeDown;
999
1000 private static bool mergeLeft;
1001
1002 private static bool mergeRight;
1003
1004 private static bool stopDrops;
1005
1006 public static bool noLiquidCheck;
1007
1008 public static bool AllowedToSpreadInfections = true;
1009
1010 [ThreadStatic]
1012
1013 [ThreadStatic]
1014 public static int _genRandSeed = -2;
1015
1016 public static int _lastSeed;
1017
1018 public static string statusText = "";
1019
1020 public static bool destroyObject;
1021
1022 public static int spawnDelay;
1023
1024 public static int prioritizedTownNPCType;
1025
1026 public static int numTileCount;
1027
1028 public static int maxTileCount = 3500;
1029
1030 public static int maxWallOut2 = 5000;
1031
1033
1034 public static int lavaCount;
1035
1036 public static int iceCount;
1037
1038 public static int sandCount;
1039
1040 public static int rockCount;
1041
1042 public static int shroomCount;
1043
1044 public static int maxRoomTiles = 750;
1045
1046 public static int numRoomTiles;
1047
1048 public static int[] roomX = new int[maxRoomTiles];
1049
1050 public static int[] roomY = new int[maxRoomTiles];
1051
1052 public static int roomCeilingsCount;
1053
1054 public static int[] roomCeilingX = new int[maxRoomTiles];
1055
1056 public static int[] roomCeilingY = new int[maxRoomTiles];
1057
1058 public static int roomX1;
1059
1060 public static int roomX2;
1061
1062 public static int roomY1;
1063
1064 public static int roomY2;
1065
1066 public static bool canSpawn;
1067
1068 public static bool[] houseTile = new bool[TileID.Count];
1069
1070 public static int bestX;
1071
1072 public static int bestY;
1073
1074 public static int hiScore;
1075
1076 private static bool roomTorch;
1077
1078 private static bool roomDoor;
1079
1080 private static bool roomChair;
1081
1082 private static bool roomTable;
1083
1084 private static bool roomOccupied;
1085
1086 private static bool roomEvil;
1087
1088 private static bool roomHasStinkbug;
1089
1090 private static bool roomHasEchoStinkbug;
1091
1092 public static int WorldGenParam_Evil = -1;
1093
1094 public static readonly int cactusWaterWidth = 50;
1095
1096 public static readonly int cactusWaterHeight = 25;
1097
1098 public static readonly int cactusWaterLimit = 25;
1099
1101
1103
1104 private static int sharedRoomX;
1105
1107
1108 public const int WorldSizeSmallX = 4200;
1109
1110 public const int WorldSizeSmallY = 1200;
1111
1112 public const int WorldSizeMediumX = 6400;
1113
1114 public const int WorldSizeMediumY = 1800;
1115
1116 public const int WorldSizeLargeX = 8400;
1117
1118 public const int WorldSizeLargeY = 2400;
1119
1121
1122 public static bool generatingWorld = false;
1123
1124 private static int[,] trapDiag = new int[4, 2];
1125
1126 private static bool[] gem = new bool[6];
1127
1128 private static int[] mossType = new int[3];
1129
1130 private static ushort neonMossType;
1131
1132 private static int tileCounterNum;
1133
1134 private static int tileCounterMax = 20;
1135
1136 private static int[] tileCounterX = new int[tileCounterMax];
1137
1138 private static int[] tileCounterY = new int[tileCounterMax];
1139
1141
1142 public static int SmallConsecutivesFound = 0;
1143
1144 public static int SmallConsecutivesEliminated = 0;
1145
1146 public static bool tempRemixWorldGen = false;
1147
1148 public static bool remixWorldGen = false;
1149
1150 public static bool everythingWorldGen = false;
1151
1152 public static bool noTrapsWorldGen = false;
1153
1154 public static bool drunkWorldGen = false;
1155
1156 public static bool getGoodWorldGen = false;
1157
1158 public static bool tempTenthAnniversaryWorldGen = false;
1159
1160 public static bool tenthAnniversaryWorldGen = false;
1161
1162 public static bool dontStarveWorldGen = false;
1163
1164 public static bool notTheBees = false;
1165
1166 public static bool drunkWorldGenText = false;
1167
1168 public static bool placingTraps = false;
1169
1171
1172 private const int ItemSpawnProtectionTime = 18000;
1173
1175
1176 private static int catTailDistance = 8;
1177
1178 public static TreeTopsInfo TreeTops = new TreeTopsInfo();
1179
1181
1182 private static int maxTreeShakes = 500;
1183
1184 private static int numTreeShakes = 0;
1185
1186 private static int[] treeShakeX = new int[maxTreeShakes];
1187
1188 private static int[] treeShakeY = new int[maxTreeShakes];
1189
1190 private static bool fossilBreak = false;
1191
1193
1194 private static bool growGrassUnderground = false;
1195
1196 public const bool BUBBLES_SOLID_STATE_FOR_HOUSING = true;
1197
1198 public static int grassSpread;
1199
1200 private static Point[] heartPos = new Point[100];
1201
1202 private static int heartCount;
1203
1204 private const int strip_w = 200;
1205
1206 private const int strip_h = 50;
1207
1208 private static readonly Vertical64BitStrips bitStrip = new Vertical64BitStrips(202);
1209
1210 public static bool noMapUpdateRefresh = false;
1211
1212 private static bool skipFramingDuringGen = false;
1213
1215 {
1216 get
1217 {
1218 if (_lastSeed != _genRandSeed)
1219 {
1222 }
1223 if (_genRand == null)
1224 {
1227 }
1228 return _genRand;
1229 }
1230 }
1231
1232 public static double oceanLevel => (Main.worldSurface + Main.rockLayer) / 2.0 + 40.0;
1233
1234 public static bool SkipFramingBecauseOfGen
1235 {
1236 get
1237 {
1238 if (generatingWorld)
1239 {
1240 return skipFramingDuringGen;
1241 }
1242 return false;
1243 }
1244 }
1245
1246 public static void SetupStatueList()
1247 {
1249 for (int i = 0; i < 44; i++)
1250 {
1251 list.Add(new Point16(105, i));
1252 }
1253 list[34] = new Point16(349, 0);
1254 list[43] = new Point16(105, 50);
1255 list.Add(new Point16(105, 63));
1256 list.Add(new Point16(105, 64));
1257 list.Add(new Point16(105, 65));
1258 list.Add(new Point16(105, 66));
1259 list.Add(new Point16(105, 68));
1260 list.Add(new Point16(105, 69));
1261 list.Add(new Point16(105, 70));
1262 list.Add(new Point16(105, 71));
1263 list.Add(new Point16(105, 72));
1264 list.Add(new Point16(105, 73));
1265 list.Add(new Point16(105, 75));
1266 list.Add(new Point16(105, 51));
1267 list.Add(new Point16(105, 52));
1268 list.Add(new Point16(105, 53));
1269 list.Add(new Point16(105, 54));
1270 list.Add(new Point16(105, 55));
1271 list.Add(new Point16(105, 56));
1272 list.Add(new Point16(105, 57));
1273 list.Add(new Point16(105, 58));
1274 list.Add(new Point16(105, 59));
1275 list.Add(new Point16(105, 60));
1276 list.Add(new Point16(105, 61));
1277 list.Add(new Point16(105, 62));
1278 list.Add(new Point16(105, 77));
1279 list.Add(new Point16(105, 78));
1280 list.Add(new Point16(105, 67));
1281 list.Add(new Point16(105, 74));
1282 list.Add(new Point16(105, 37));
1283 list.Add(new Point16(105, 2));
1284 GenVars.statueList = list.ToArray();
1285 }
1286
1287 public static void PlaceStatueTrap(int x, int y)
1288 {
1289 for (int i = -10; i <= 10; i++)
1290 {
1291 for (int j = -10; j <= 10; j++)
1292 {
1293 Tile tile = Main.tile[x + i, y + j + 1];
1294 Tile tile2 = Main.tile[x + i, y + j];
1295 if (!tile2.active() && SolidTile2(tile) && tile.type != 162)
1296 {
1297 PlaceTile(x + i, y + j, 135, mute: true);
1298 if (tile2.active() && tile2.type == 135)
1299 {
1300 WorldUtils.WireLine(new Point(x, y), new Point(x + i, y + j));
1301 return;
1302 }
1303 }
1304 }
1305 }
1306 }
1307
1309 {
1310 return new EntitySource_TileBreak(x, y);
1311 }
1312
1314 {
1315 return new EntitySource_TileBreak(x, y);
1316 }
1317
1319 {
1320 return new EntitySource_ShakeTree(x, y);
1321 }
1322
1324 {
1325 return new EntitySource_ShakeTree(x, y);
1326 }
1327
1329 {
1330 return new EntitySource_ShakeTree(x, y);
1331 }
1332
1333 private static IEntitySource GetProjectileSource_PlayerOrWires(int x, int y, bool fromWiring, Player player)
1334 {
1335 if (fromWiring)
1336 {
1337 return new EntitySource_Wiring(x, y);
1338 }
1339 return new EntitySource_TileInteraction(player, x, y);
1340 }
1341
1342 public static bool EmptyLiquid(int x, int y)
1343 {
1344 if (!InWorld(x, y))
1345 {
1346 return false;
1347 }
1348 Tile tile = Main.tile[x, y];
1349 if (tile == null)
1350 {
1351 return false;
1352 }
1353 tile.liquidType();
1354 if (tile.nactive() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
1355 {
1356 return false;
1357 }
1358 tile.Clear(TileDataType.Liquid);
1359 SquareTileFrame(x, y, resetFrame: false);
1360 if (Main.netMode != 0)
1361 {
1362 NetMessage.sendWater(x, y);
1363 }
1364 else
1365 {
1366 Liquid.AddWater(x, y);
1367 }
1368 return true;
1369 }
1370
1371 public static bool PlaceLiquid(int x, int y, byte liquidType, byte amount)
1372 {
1373 if (!InWorld(x, y))
1374 {
1375 return false;
1376 }
1377 Tile tile = Main.tile[x, y];
1378 if (tile == null)
1379 {
1380 return false;
1381 }
1382 byte b = tile.liquidType();
1383 if (tile.nactive() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
1384 {
1385 return false;
1386 }
1387 if (tile.liquid == 0 || liquidType == b)
1388 {
1389 tile.liquidType(liquidType);
1390 if (amount + tile.liquid > 255)
1391 {
1392 amount = (byte)(255 - tile.liquid);
1393 }
1394 tile.liquid += amount;
1395 SquareTileFrame(x, y);
1396 if (Main.netMode != 0)
1397 {
1398 NetMessage.sendWater(x, y);
1399 }
1400 return true;
1401 }
1402 int liquidMergeTileType = 0;
1403 bool waterNearby = b == 0;
1404 bool lavaNearby = b == 1;
1405 bool honeyNearby = b == 2;
1406 bool shimmerNearby = b == 3;
1407 int liquidMergeType = 0;
1409 if (liquidMergeTileType != 0)
1410 {
1411 tile.liquid = 0;
1412 tile.liquidType(0);
1413 PlaceTile(x, y, liquidMergeTileType, mute: true);
1414 SquareTileFrame(x, y);
1415 if (Main.netMode != 0)
1416 {
1417 NetMessage.SendTileSquare(-1, x - 1, y - 1, GetLiquidChangeType(liquidType, b));
1418 }
1419 return true;
1420 }
1421 return false;
1422 }
1423
1424 public static void PlayLiquidChangeSound(TileChangeType eventType, int x, int y, int count = 1)
1425 {
1426 switch (eventType)
1427 {
1428 case TileChangeType.LavaWater:
1429 SoundEngine.PlaySound(SoundID.LiquidsWaterLava, x * 16 + count * 8, y * 16 + count * 8);
1430 break;
1431 case TileChangeType.HoneyWater:
1432 SoundEngine.PlaySound(SoundID.LiquidsHoneyWater, x * 16 + count * 8, y * 16 + count * 8);
1433 break;
1434 case TileChangeType.HoneyLava:
1435 SoundEngine.PlaySound(SoundID.LiquidsHoneyLava, x * 16 + count * 8, y * 16 + count * 8);
1436 break;
1437 case TileChangeType.ShimmerWater:
1438 SoundEngine.PlaySound(19, x * 16 + count * 8, y * 16 + count * 8, 4);
1439 break;
1440 case TileChangeType.ShimmerLava:
1441 SoundEngine.PlaySound(19, x * 16 + count * 8, y * 16 + count * 8, 4);
1442 break;
1443 case TileChangeType.ShimmerHoney:
1444 SoundEngine.PlaySound(19, x * 16 + count * 8, y * 16 + count * 8, 4);
1445 break;
1446 }
1447 }
1448
1449 public static TileChangeType GetLiquidChangeType(int liquidType, int otherLiquidType)
1450 {
1451 if ((liquidType == 0 && otherLiquidType == 1) || (liquidType == 1 && otherLiquidType == 0))
1452 {
1453 return TileChangeType.LavaWater;
1454 }
1455 if ((liquidType == 0 && otherLiquidType == 2) || (liquidType == 2 && otherLiquidType == 0))
1456 {
1457 return TileChangeType.HoneyWater;
1458 }
1459 if ((liquidType == 1 && otherLiquidType == 2) || (liquidType == 2 && otherLiquidType == 1))
1460 {
1461 return TileChangeType.HoneyLava;
1462 }
1463 if ((liquidType == 0 && otherLiquidType == 3) || (liquidType == 3 && otherLiquidType == 0))
1464 {
1465 return TileChangeType.ShimmerWater;
1466 }
1467 if ((liquidType == 1 && otherLiquidType == 3) || (liquidType == 3 && otherLiquidType == 1))
1468 {
1469 return TileChangeType.ShimmerLava;
1470 }
1471 if ((liquidType == 2 && otherLiquidType == 3) || (liquidType == 3 && otherLiquidType == 2))
1472 {
1473 return TileChangeType.ShimmerHoney;
1474 }
1475 return TileChangeType.None;
1476 }
1477
1478 public static bool MoveTownNPC(int x, int y, int n)
1479 {
1480 if (!StartRoomCheck(x, y))
1481 {
1482 string newText = Lang.inter[40].Value;
1483 switch (roomCheckFailureReason)
1484 {
1485 case TownNPCRoomCheckFailureReason.HoleInWallIsTooBig:
1486 newText = Language.GetTextValue("TownNPCHousingFailureReasons.HoleInWallIsTooBig");
1487 break;
1488 case TownNPCRoomCheckFailureReason.RoomCheckStartedInASolidTile:
1489 newText = Language.GetTextValue("TownNPCHousingFailureReasons.RoomCheckStartedInASolidTile");
1490 break;
1491 case TownNPCRoomCheckFailureReason.RoomIsTooBig:
1492 newText = Language.GetTextValue("TownNPCHousingFailureReasons.RoomIsTooBig");
1493 break;
1494 case TownNPCRoomCheckFailureReason.RoomIsTooSmall:
1495 newText = Language.GetTextValue("TownNPCHousingFailureReasons.RoomIsTooSmall");
1496 break;
1497 case TownNPCRoomCheckFailureReason.TooCloseToWorldEdge:
1498 newText = Language.GetTextValue("TownNPCHousingFailureReasons.TooCloseToWorldEdge");
1499 break;
1500 }
1501 Main.NewText(newText, byte.MaxValue, 240, 20);
1502 return false;
1503 }
1505 {
1506 int num = 0;
1507 int num2 = ((!roomTorch) ? 1 : 0) + ((!roomDoor) ? 1 : 0) + ((!roomTable) ? 1 : 0) + ((!roomChair) ? 1 : 0);
1508 string[] array = new string[num2];
1509 if (!roomTorch)
1510 {
1511 array[num] = Language.GetTextValue("Game.HouseLightSource");
1512 num++;
1513 }
1514 if (!roomDoor)
1515 {
1516 array[num] = Language.GetTextValue("Game.HouseDoor");
1517 num++;
1518 }
1519 if (!roomTable)
1520 {
1521 array[num] = Language.GetTextValue("Game.HouseTable");
1522 num++;
1523 }
1524 if (!roomChair)
1525 {
1526 array[num] = Language.GetTextValue("Game.HouseChair");
1527 num++;
1528 }
1529 string key = "Game.HouseMissing_" + num2;
1530 object[] args = array;
1531 Main.NewText(Language.GetTextValue(key, args), byte.MaxValue, 240, 20);
1532 return false;
1533 }
1535 if (n >= 0)
1536 {
1537 type = Main.npc[n].type;
1538 }
1539 bool flag = NPCID.Sets.IsTownPet[type];
1540 if (roomHasStinkbug && !flag)
1541 {
1542 Main.NewText(Language.GetTextValue("TownNPCHousingFailureReasons.RoomHasAStinkbug"), byte.MaxValue, 240, 20);
1543 return false;
1544 }
1545 if (roomHasEchoStinkbug && !flag)
1546 {
1547 Main.NewText(Language.GetTextValue("TownNPCHousingFailureReasons.RoomHasAnEchoStinkbug"), byte.MaxValue, 240, 20);
1548 return false;
1549 }
1550 ScoreRoom(-1, type);
1551 if (hiScore <= 0)
1552 {
1553 if (roomOccupied)
1554 {
1555 Main.NewText(Lang.inter[41].Value, byte.MaxValue, 240, 20);
1556 }
1557 else if (roomEvil)
1558 {
1559 Main.NewText(Lang.inter[42].Value, byte.MaxValue, 240, 20);
1560 }
1561 else
1562 {
1563 Main.NewText(Lang.inter[40].Value, byte.MaxValue, 240, 20);
1564 }
1565 return false;
1566 }
1567 if (n >= 0 && !CheckSpecialTownNPCSpawningConditions(Main.npc[n].type))
1568 {
1569 Main.NewText(Lang.inter[55].Value + " " + Main.npc[n].TypeName, byte.MaxValue, 240, 20);
1570 return false;
1571 }
1572 return true;
1573 }
1574
1575 public static void moveRoom(int x, int y, int n)
1576 {
1577 if (Main.netMode == 1)
1578 {
1579 NetMessage.SendData(60, -1, -1, null, n, x, y);
1580 return;
1581 }
1583 Main.npc[n].homeless = true;
1584 SpawnTownNPC(x, y);
1585 TownManager.SetRoom(Main.npc[n].type, Main.npc[n].homeTileX, Main.npc[n].homeTileY);
1586 }
1587
1588 public static bool IsNPCEvictable(int n)
1589 {
1590 if (n < 0)
1591 {
1592 return false;
1593 }
1596 NPC nPC = Main.npc[n];
1597 Rectangle value = new Rectangle(nPC.homeTileX * 16, nPC.homeTileY * 16, 16, 16);
1598 return hitbox.Intersects(value);
1599 }
1600
1601 public static void kickOut(int n)
1602 {
1603 if (Main.netMode == 1)
1604 {
1605 NetMessage.SendData(60, -1, -1, null, n, 0f, 0f, 1f);
1606 return;
1607 }
1608 Main.npc[n].homeless = true;
1609 TownManager.KickOut(Main.npc[n]);
1610 }
1611
1612 public static bool IsThereASpawnablePrioritizedTownNPC(int x, int y, ref bool canSpawnNewTownNPC)
1613 {
1615 {
1616 canSpawnNewTownNPC = false;
1617 return true;
1618 }
1619 List<int> list = new List<int>();
1620 TownManager.AddOccupantsToList(x, y, list);
1621 for (int i = 0; i < list.Count; i++)
1622 {
1623 int num = list[i];
1625 {
1627 canSpawnNewTownNPC = true;
1628 return true;
1629 }
1630 }
1631 for (int j = 0; j < NPCID.Count; j++)
1632 {
1634 {
1635 continue;
1636 }
1637 if (NPC.AnyNPCs(j))
1638 {
1639 Main.townNPCCanSpawn[j] = false;
1640 continue;
1641 }
1642 if (TownManager.HasRoomQuick(j))
1643 {
1645 canSpawnNewTownNPC = true;
1646 return true;
1647 }
1649 {
1651 canSpawnNewTownNPC = true;
1652 return true;
1653 }
1654 }
1655 return false;
1656 }
1657
1658 public static bool IsThereASpawnablePrioritizedTownNPC_Old(int x, int y)
1659 {
1661 {
1662 return true;
1663 }
1664 List<int> list = new List<int>();
1665 TownManager.AddOccupantsToList(x, y, list);
1666 for (int i = 0; i < list.Count; i++)
1667 {
1668 int num = list[i];
1670 {
1672 return true;
1673 }
1674 }
1675 int num2 = -1;
1676 for (int j = 0; j < NPCID.Count; j++)
1677 {
1679 {
1680 continue;
1681 }
1682 if (NPC.AnyNPCs(j))
1683 {
1684 Main.townNPCCanSpawn[j] = false;
1685 }
1686 else if (TownManager.HasRoomQuick(j))
1687 {
1688 if (num2 == -1)
1689 {
1690 num2 = j;
1691 }
1692 }
1694 {
1696 return true;
1697 }
1698 }
1699 if (num2 != -1)
1700 {
1702 return true;
1703 }
1704 return false;
1705 }
1706
1708 {
1709 if (type == 160)
1710 {
1712 {
1713 return false;
1714 }
1716 int num = 0;
1717 for (int i = startX + 1; i < endX; i++)
1718 {
1719 for (int j = startY + 2; j < endY + 2; j++)
1720 {
1721 Tile tile = Main.tile[i, j];
1722 if (tile.active() && (tile.type == 70 || tile.type == 71 || tile.type == 72 || tile.type == 528))
1723 {
1724 num++;
1725 }
1726 }
1727 }
1729 {
1730 return true;
1731 }
1732 return false;
1733 }
1734 return true;
1735 }
1736
1737 public static void UnspawnTravelNPC()
1738 {
1739 int num = -1;
1740 for (int i = 0; i < 200; i++)
1741 {
1742 if (Main.npc[i].active && Main.npc[i].type == 368)
1743 {
1744 num = i;
1745 break;
1746 }
1747 }
1748 if (num < 0)
1749 {
1750 return;
1751 }
1752 int num2 = (int)(Main.npc[num].Center.X / 16f);
1753 int num3 = (int)(Main.npc[num].Center.Y / 16f);
1754 bool flag = true;
1755 Rectangle value = new Rectangle(num2 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num3 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
1756 for (int j = 0; j < 255; j++)
1757 {
1758 if (Main.player[j].active && new Rectangle((int)Main.player[j].position.X, (int)Main.player[j].position.Y, Main.player[j].width, Main.player[j].height).Intersects(value))
1759 {
1760 flag = false;
1761 break;
1762 }
1763 }
1764 if (flag)
1765 {
1766 string fullName = Main.npc[num].FullName;
1767 if (Main.netMode == 0)
1768 {
1769 Main.NewText(Lang.misc[35].Format(fullName), 50, 125);
1770 }
1771 else if (Main.netMode == 2)
1772 {
1773 ChatHelper.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[35].Key, Main.npc[num].GetFullNetName()), new Color(50, 125, 255));
1774 }
1775 Main.npc[num].active = false;
1776 Main.npc[num].netSkip = -1;
1777 Main.npc[num].life = 0;
1778 NetMessage.SendData(23, -1, -1, null, num);
1779 }
1780 }
1781
1782 public static void SpawnTravelNPC()
1783 {
1784 if (Main.eclipse || !Main.dayTime || (Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0))
1785 {
1786 return;
1787 }
1788 for (int i = 0; i < 200; i++)
1789 {
1790 if (Main.npc[i].active && Main.npc[i].type == 368)
1791 {
1792 return;
1793 }
1794 }
1797 int num = 0;
1798 int[] array = new int[200];
1799 int num2 = 0;
1800 for (int j = 0; j < 200; j++)
1801 {
1802 if (Main.npc[j].active && Main.npc[j].townNPC && Main.npc[j].type != 37 && !Main.npc[j].homeless)
1803 {
1804 array[num2] = j;
1805 num2++;
1806 }
1807 }
1808 if (num2 == 0)
1809 {
1810 return;
1811 }
1812 num = array[Main.rand.Next(num2)];
1813 bestX = Main.npc[num].homeTileX;
1814 bestY = Main.npc[num].homeTileY;
1815 int minValue = bestX;
1816 int num3 = bestX;
1817 int num4 = bestY;
1818 int num5 = bestX;
1819 while (num5 > bestX - 10 && (SolidTile(num5, num4) || Main.tileSolidTop[Main.tile[num5, num4].type]) && (!Main.tile[num5, num4 - 1].active() || !Main.tileSolid[Main.tile[num5, num4 - 1].type] || Main.tileSolidTop[Main.tile[num5, num4 - 1].type]) && (!Main.tile[num5, num4 - 2].active() || !Main.tileSolid[Main.tile[num5, num4 - 2].type] || Main.tileSolidTop[Main.tile[num5, num4 - 2].type]) && (!Main.tile[num5, num4 - 3].active() || !Main.tileSolid[Main.tile[num5, num4 - 3].type] || Main.tileSolidTop[Main.tile[num5, num4 - 3].type]))
1820 {
1821 minValue = num5;
1822 num5--;
1823 }
1824 for (int k = bestX; k < bestX + 10 && (SolidTile(k, num4) || Main.tileSolidTop[Main.tile[k, num4].type]) && (!Main.tile[k, num4 - 1].active() || !Main.tileSolid[Main.tile[k, num4 - 1].type] || Main.tileSolidTop[Main.tile[k, num4 - 1].type]) && (!Main.tile[k, num4 - 2].active() || !Main.tileSolid[Main.tile[k, num4 - 2].type] || Main.tileSolidTop[Main.tile[k, num4 - 2].type]) && (!Main.tile[k, num4 - 3].active() || !Main.tileSolid[Main.tile[k, num4 - 3].type] || Main.tileSolidTop[Main.tile[k, num4 - 3].type]); k++)
1825 {
1826 num3 = k;
1827 }
1828 for (int l = 0; l < 30; l++)
1829 {
1830 int num6 = Main.rand.Next(minValue, num3 + 1);
1831 if (l < 20)
1832 {
1834 {
1835 bestX = num6;
1836 break;
1837 }
1838 }
1839 else if (num6 != bestX)
1840 {
1841 bestX = num6;
1842 break;
1843 }
1844 }
1845 int num7 = bestX;
1846 int num8 = bestY;
1847 bool flag = false;
1848 if (!flag && !((double)num8 > Main.worldSurface))
1849 {
1850 for (int m = 20; m < 500; m++)
1851 {
1852 for (int n = 0; n < 2; n++)
1853 {
1854 num7 = ((n != 0) ? (bestX - m * 2) : (bestX + m * 2));
1855 if (num7 > 10 && num7 < Main.maxTilesX - 10)
1856 {
1857 int num9 = bestY - m;
1858 double num10 = bestY + m;
1859 if (num9 < 10)
1860 {
1861 num9 = 10;
1862 }
1863 if (num10 > Main.worldSurface)
1864 {
1866 }
1867 for (int num11 = num9; (double)num11 < num10; num11++)
1868 {
1869 num8 = num11;
1870 if (!Main.tile[num7, num8].nactive() || !Main.tileSolid[Main.tile[num7, num8].type])
1871 {
1872 continue;
1873 }
1874 if (Main.tile[num7, num8 - 3].liquid != 0 || Main.tile[num7, num8 - 2].liquid != 0 || Main.tile[num7, num8 - 1].liquid != 0 || Collision.SolidTiles(num7 - 1, num7 + 1, num8 - 3, num8 - 1))
1875 {
1876 break;
1877 }
1878 flag = true;
1879 Rectangle value = new Rectangle(num7 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num8 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
1880 for (int num12 = 0; num12 < 255; num12++)
1881 {
1882 if (Main.player[num12].active && new Rectangle((int)Main.player[num12].position.X, (int)Main.player[num12].position.Y, Main.player[num12].width, Main.player[num12].height).Intersects(value))
1883 {
1884 flag = false;
1885 break;
1886 }
1887 }
1888 break;
1889 }
1890 }
1891 if (flag)
1892 {
1893 break;
1894 }
1895 }
1896 if (flag)
1897 {
1898 break;
1899 }
1900 }
1901 }
1902 int num13 = NPC.NewNPC(NPC.GetSpawnSourceForTownSpawn(), num7 * 16, num8 * 16, 368, 1);
1903 Main.npc[num13].homeTileX = bestX;
1904 Main.npc[num13].homeTileY = bestY;
1905 Main.npc[num13].homeless = true;
1906 if (num7 < bestX)
1907 {
1908 Main.npc[num13].direction = 1;
1909 }
1910 else if (num7 > bestX)
1911 {
1912 Main.npc[num13].direction = -1;
1913 }
1914 Main.npc[num13].netUpdate = true;
1915 string fullName = Main.npc[num13].FullName;
1916 if (Main.netMode == 0)
1917 {
1918 Main.NewText(Language.GetTextValue("Announcement.HasArrived", fullName), 50, 125);
1919 }
1920 else if (Main.netMode == 2)
1921 {
1922 ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasArrived", Main.npc[num13].GetFullNetName()), new Color(50, 125, 255));
1923 }
1924 }
1925
1926 public static TownNPCSpawnResult SpawnTownNPC(int x, int y)
1927 {
1928 if (Main.wallHouse[Main.tile[x, y].wall])
1929 {
1930 canSpawn = true;
1931 }
1932 if (!canSpawn)
1933 {
1934 return TownNPCSpawnResult.Blocked;
1935 }
1936 if (!StartRoomCheck(x, y))
1937 {
1938 return TownNPCSpawnResult.Blocked;
1939 }
1941 {
1942 return TownNPCSpawnResult.Blocked;
1943 }
1944 int num = FindAHomelessNPC();
1946 if (num != -1)
1947 {
1948 type = Main.npc[num].type;
1949 }
1951 bool flag = NPCID.Sets.IsTownPet[type] && TownManager.HasRoom(type, out roomPosition);
1952 if ((roomHasStinkbug || roomHasEchoStinkbug) && !flag)
1953 {
1954 return TownNPCSpawnResult.Blocked;
1955 }
1956 ScoreRoom(-1, type);
1957 if (hiScore <= 0)
1958 {
1959 return TownNPCSpawnResult.Blocked;
1960 }
1961 bool canSpawnNewTownNPC = true;
1963 {
1964 return TownNPCSpawnResult.Blocked;
1965 }
1967 if (num != -1)
1968 {
1970 Main.npc[num].homeTileX = bestX;
1971 Main.npc[num].homeTileY = bestY;
1972 Main.npc[num].homeless = false;
1975 return TownNPCSpawnResult.RelocatedHomeless;
1976 }
1977 if (canSpawnNewTownNPC && num == -1)
1978 {
1980 {
1981 int num2 = bestX;
1982 int num3 = bestY;
1986 bestX = num2;
1987 bestY = num3;
1988 if (townNPCSpawnResult == TownNPCSpawnResult.Successful)
1989 {
1990 return townNPCSpawnResult;
1991 }
1992 }
1993 int num4 = bestX;
1994 int num5 = bestY;
1997 {
1998 return TownNPCSpawnResult.BlockedInfiHousing;
1999 }
2000 bool flag2 = false;
2001 if (!flag2)
2002 {
2003 flag2 = true;
2004 Rectangle value = new Rectangle(num4 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num5 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
2005 for (int i = 0; i < 255; i++)
2006 {
2007 if (Main.player[i].active && new Rectangle((int)Main.player[i].position.X, (int)Main.player[i].position.Y, Main.player[i].width, Main.player[i].height).Intersects(value))
2008 {
2009 flag2 = false;
2010 break;
2011 }
2012 }
2013 }
2014 if (!flag2 && !((double)num5 > Main.worldSurface))
2015 {
2016 for (int j = 1; j < 500; j++)
2017 {
2018 for (int k = 0; k < 2; k++)
2019 {
2020 num4 = ((k != 0) ? (bestX - j) : (bestX + j));
2021 if (num4 > 10 && num4 < Main.maxTilesX - 10)
2022 {
2023 int num6 = bestY - j;
2024 double num7 = bestY + j;
2025 if (num6 < 10)
2026 {
2027 num6 = 10;
2028 }
2029 if (num7 > Main.worldSurface)
2030 {
2032 }
2033 for (int l = num6; (double)l < num7; l++)
2034 {
2035 num5 = l;
2036 if (!Main.tile[num4, num5].nactive() || !Main.tileSolid[Main.tile[num4, num5].type])
2037 {
2038 continue;
2039 }
2040 if (Collision.SolidTiles(num4 - 1, num4 + 1, num5 - 3, num5 - 1))
2041 {
2042 break;
2043 }
2044 flag2 = true;
2045 Rectangle value2 = new Rectangle(num4 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num5 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
2046 for (int m = 0; m < 255; m++)
2047 {
2048 if (Main.player[m].active && new Rectangle((int)Main.player[m].position.X, (int)Main.player[m].position.Y, Main.player[m].width, Main.player[m].height).Intersects(value2))
2049 {
2050 flag2 = false;
2051 break;
2052 }
2053 }
2054 break;
2055 }
2056 }
2057 if (flag2)
2058 {
2059 break;
2060 }
2061 }
2062 if (flag2)
2063 {
2064 break;
2065 }
2066 }
2067 }
2068 int num8 = NPC.NewNPC(NPC.GetSpawnSourceForTownSpawn(), num4 * 16, num5 * 16, type, 1);
2069 Main.townNPCCanSpawn[type] = false;
2070 Main.npc[num8].homeTileX = bestX;
2071 Main.npc[num8].homeTileY = bestY;
2072 if (num4 < bestX)
2073 {
2074 Main.npc[num8].direction = 1;
2075 }
2076 else if (num4 > bestX)
2077 {
2078 Main.npc[num8].direction = -1;
2079 }
2080 Main.npc[num8].netUpdate = true;
2081 string fullName = Main.npc[num8].FullName;
2082 if (Main.netMode == 0)
2083 {
2084 Main.NewText(Language.GetTextValue("Announcement.HasArrived", fullName), 50, 125);
2085 }
2086 else if (Main.netMode == 2)
2087 {
2088 ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasArrived", Main.npc[num8].GetFullNetName()), new Color(50, 125, 255));
2089 }
2091 switch (Main.npc[num8].type)
2092 {
2093 case 160:
2095 NPC.unlockedTruffleSpawn = true;
2097 break;
2098 case 17:
2099 NPC.unlockedMerchantSpawn = true;
2100 break;
2101 case 207:
2102 NPC.unlockedDyeTraderSpawn = true;
2103 break;
2104 case 18:
2105 NPC.unlockedNurseSpawn = true;
2106 break;
2107 case 19:
2108 NPC.unlockedArmsDealerSpawn = true;
2109 break;
2110 case 38:
2111 NPC.unlockedDemolitionistSpawn = true;
2112 break;
2113 case 208:
2114 NPC.unlockedPartyGirlSpawn = true;
2115 break;
2116 case 663:
2117 NPC.unlockedPrincessSpawn = true;
2118 break;
2119 case 678:
2120 NPC.unlockedSlimeGreenSpawn = true;
2121 break;
2122 }
2125 }
2126 return TownNPCSpawnResult.Successful;
2127 }
2128
2129 private static int FindAHomelessNPC()
2130 {
2131 int result = -1;
2132 for (int i = 0; i < 200; i++)
2133 {
2134 if (Main.npc[i].active && Main.npc[i].homeless && Main.npc[i].type == prioritizedTownNPCType && CheckSpecialTownNPCSpawningConditions(Main.npc[i].type))
2135 {
2136 result = i;
2137 break;
2138 }
2139 }
2140 return result;
2141 }
2142
2143 private static bool IsRoomConsideredAlreadyOccupied(int spawnTileX, int spawnTileY, int npcTypeToSpawn)
2144 {
2145 bool result = false;
2146 for (int i = 0; i < 200; i++)
2147 {
2148 NPC nPC = Main.npc[i];
2149 if (nPC.active && nPC.townNPC && !nPC.homeless && nPC.homeTileX == spawnTileX && nPC.homeTileY == spawnTileY && !TownManager.CanNPCsLiveWithEachOther(npcTypeToSpawn, nPC))
2150 {
2151 result = true;
2152 break;
2153 }
2154 }
2155 return result;
2156 }
2157
2159 {
2160 bool[] array = new bool[NPCID.Count];
2161 for (int i = 0; i < 200; i++)
2162 {
2163 if (Main.npc[i].active && Main.npc[i].type >= 0 && Main.npc[i].type < NPCID.Count)
2164 {
2165 array[Main.npc[i].type] = true;
2166 }
2167 }
2168 if (array[38] && array[17] && array[107] && array[19] && array[22] && array[124] && array[228] && array[178] && array[18] && array[229] && array[209] && array[54] && array[108] && array[160] && array[20] && array[369] && array[207] && array[227] && array[208] && array[441] && array[353] && array[550] && array[588] && array[633] && array[663])
2169 {
2171 }
2172 if (array[670] && array[678] && array[679] && array[680] && array[681] && array[682] && array[683] && array[684])
2173 {
2175 }
2176 }
2177
2178 public static bool RoomNeeds(int npcType)
2179 {
2180 roomChair = false;
2181 roomDoor = false;
2182 roomTable = false;
2183 roomTorch = false;
2184 for (int i = 0; i < TileID.Sets.RoomNeeds.CountsAsChair.Length; i++)
2185 {
2187 {
2188 roomChair = true;
2189 break;
2190 }
2191 }
2192 for (int j = 0; j < TileID.Sets.RoomNeeds.CountsAsTable.Length; j++)
2193 {
2195 {
2196 roomTable = true;
2197 break;
2198 }
2199 }
2200 for (int k = 0; k < TileID.Sets.RoomNeeds.CountsAsTorch.Length; k++)
2201 {
2203 {
2204 roomTorch = true;
2205 break;
2206 }
2207 }
2208 for (int l = 0; l < TileID.Sets.RoomNeeds.CountsAsDoor.Length; l++)
2209 {
2211 {
2212 roomDoor = true;
2213 break;
2214 }
2215 }
2217 {
2218 canSpawn = true;
2219 }
2220 else
2221 {
2222 canSpawn = false;
2223 }
2224 return canSpawn;
2225 }
2226
2227 public static void QuickFindHome(int npc)
2228 {
2229 bool flag = Main.tileSolid[379];
2230 Main.tileSolid[379] = true;
2231 if (Main.npc[npc].homeTileX > 10 && Main.npc[npc].homeTileY > 10 && Main.npc[npc].homeTileX < Main.maxTilesX - 10 && Main.npc[npc].homeTileY < Main.maxTilesY)
2232 {
2233 canSpawn = false;
2234 StartRoomCheck(Main.npc[npc].homeTileX, Main.npc[npc].homeTileY - 1);
2235 if (!canSpawn)
2236 {
2237 for (int i = Main.npc[npc].homeTileX - 1; i < Main.npc[npc].homeTileX + 2; i++)
2238 {
2239 for (int j = Main.npc[npc].homeTileY - 1; j < Main.npc[npc].homeTileY + 2 && !StartRoomCheck(i, j); j++)
2240 {
2241 }
2242 }
2243 }
2244 if (!canSpawn)
2245 {
2246 int num = 10;
2247 for (int k = Main.npc[npc].homeTileX - num; k <= Main.npc[npc].homeTileX + num; k += 2)
2248 {
2249 for (int l = Main.npc[npc].homeTileY - num; l <= Main.npc[npc].homeTileY + num && !StartRoomCheck(k, l); l += 2)
2250 {
2251 }
2252 }
2253 }
2254 if (canSpawn)
2255 {
2256 RoomNeeds(Main.npc[npc].type);
2257 if (canSpawn)
2258 {
2259 ScoreRoom(npc, Main.npc[npc].type);
2260 }
2261 if (canSpawn && hiScore > 0)
2262 {
2264 }
2265 if (canSpawn && hiScore > 0)
2266 {
2267 Main.npc[npc].homeTileX = bestX;
2268 Main.npc[npc].homeTileY = bestY;
2269 Main.npc[npc].homeless = false;
2271 canSpawn = false;
2272 }
2273 else
2274 {
2275 Main.npc[npc].homeless = true;
2276 }
2277 }
2278 else
2279 {
2280 Main.npc[npc].homeless = true;
2281 }
2282 }
2283 Main.tileSolid[379] = flag;
2284 }
2285
2286 private static bool IsRoomConsideredOccupiedForNPCIndex(int npc)
2287 {
2288 bool result = true;
2289 for (int i = 0; i < 200; i++)
2290 {
2291 if (i != npc)
2292 {
2293 NPC nPC = Main.npc[i];
2294 if (nPC.active && nPC.townNPC && !nPC.homeless && nPC.homeTileX == bestX && nPC.homeTileY == bestY && !TownManager.CanNPCsLiveWithEachOther(Main.npc[npc], nPC))
2295 {
2296 result = false;
2297 break;
2298 }
2299 }
2300 }
2301 return result;
2302 }
2303
2304 private static bool ScoreRoom_IsThisRoomOccupiedBySomeone(int ignoreNPC = -1, int npcTypeAsking = -1)
2305 {
2306 for (int i = 0; i < 200; i++)
2307 {
2308 if (!Main.npc[i].active || !Main.npc[i].townNPC || ignoreNPC == i || Main.npc[i].homeless)
2309 {
2310 continue;
2311 }
2312 for (int j = 0; j < numRoomTiles; j++)
2313 {
2314 if (Main.npc[i].homeTileX != roomX[j] || Main.npc[i].homeTileY != roomY[j])
2315 {
2316 continue;
2317 }
2318 bool flag = false;
2319 for (int k = 0; k < numRoomTiles; k++)
2320 {
2321 if (Main.npc[i].homeTileX == roomX[k] && Main.npc[i].homeTileY - 1 == roomY[k])
2322 {
2323 if (!TownManager.CanNPCsLiveWithEachOther(npcTypeAsking, Main.npc[i]))
2324 {
2325 flag = true;
2326 break;
2327 }
2328 sharedRoomX = Main.npc[i].homeTileX;
2329 }
2330 }
2331 if (flag)
2332 {
2333 return true;
2334 }
2335 }
2336 }
2337 return false;
2338 }
2339
2340 public static void CountTileTypesInArea(int[] tileTypeCounts, int startX, int endX, int startY, int endY)
2341 {
2342 for (int i = startX; i <= endX; i++)
2343 {
2344 for (int j = startY; j <= endY; j++)
2345 {
2346 if (Main.tile[i, j].active())
2347 {
2348 tileTypeCounts[Main.tile[i, j].type]++;
2349 }
2350 }
2351 }
2352 }
2353
2355 {
2356 switch (group)
2357 {
2358 case TileScanGroup.None:
2359 return 0;
2360 case TileScanGroup.Corruption:
2362 case TileScanGroup.Crimson:
2363 return tileTypeCounts[199] + tileTypeCounts[203] + tileTypeCounts[200] + tileTypeCounts[401] + tileTypeCounts[399] + tileTypeCounts[234] + tileTypeCounts[352] - 5 * tileTypeCounts[27];
2364 case TileScanGroup.Hallow:
2365 return tileTypeCounts[109] + tileTypeCounts[110] + tileTypeCounts[113] + tileTypeCounts[117] + tileTypeCounts[116] + tileTypeCounts[164] + tileTypeCounts[403] + tileTypeCounts[402];
2366 case TileScanGroup.TotalGoodEvil:
2367 {
2371 int num = 5 * tileTypeCounts[27];
2374 }
2375 default:
2376 return 0;
2377 }
2378 }
2379
2380 public static void ScoreRoom(int ignoreNPC = -1, int npcTypeAskingToScoreRoom = -1)
2381 {
2382 roomOccupied = false;
2383 roomEvil = false;
2384 sharedRoomX = -1;
2386 {
2387 roomOccupied = true;
2388 hiScore = -1;
2389 return;
2390 }
2391 hiScore = 0;
2392 int num = 0;
2393 int num2 = 50;
2395 int[] tileTypeCounts = new int[TileID.Count];
2398 if (num3 < 50)
2399 {
2400 num3 = 0;
2401 }
2402 num2 -= num3;
2403 if (num3 > 0)
2404 {
2405 roomEvil = true;
2406 }
2407 if (num2 <= -250)
2408 {
2409 hiScore = num2;
2410 return;
2411 }
2412 startX = roomX1;
2413 endX = roomX2;
2414 startY = roomY1;
2415 endY = roomY2;
2416 for (int i = startX + 1; i < endX; i++)
2417 {
2418 for (int j = startY + 2; j < endY + 2; j++)
2419 {
2420 if (!Main.tile[i, j].nactive() || !ScoreRoom_CanBeHomeSpot(i, j))
2421 {
2422 continue;
2423 }
2424 num = num2;
2425 if (!Main.tileSolid[Main.tile[i, j].type] || Main.tileSolidTop[Main.tile[i, j].type] || Collision.SolidTiles(i - 1, i + 1, j - 3, j - 1) || !Main.tile[i - 1, j].nactive() || !Main.tileSolid[Main.tile[i - 1, j].type] || !Main.tile[i + 1, j].nactive() || !Main.tileSolid[Main.tile[i + 1, j].type])
2426 {
2427 continue;
2428 }
2429 int num4 = 0;
2430 int num5 = 0;
2431 for (int k = i - 2; k < i + 3; k++)
2432 {
2433 for (int l = j - 4; l < j; l++)
2434 {
2435 Tile tile = Main.tile[k, l];
2436 if (tile.nactive() && !TileID.Sets.IgnoredInHouseScore[tile.type] && (tile.type != 11 || IsOpenDoorAnchorFrame(k, l)))
2437 {
2438 if (k == i)
2439 {
2440 num4++;
2441 }
2442 else if (TileID.Sets.BasicChest[tile.type])
2443 {
2444 num5++;
2445 }
2446 else
2447 {
2448 num = ((tile.type != 10 && tile.type != 388) ? ((!IsOpenDoorAnchorFrame(k, l) && tile.type != 389) ? ((!Main.tileSolid[tile.type]) ? (num + 5) : (num - 5)) : (num - 20)) : (num - 20));
2449 }
2450 }
2451 }
2452 }
2453 if (sharedRoomX >= 0 && num >= 1 && Math.Abs(sharedRoomX - i) < 3)
2454 {
2455 num = 1;
2456 }
2457 if (num > 0 && num5 > 0)
2458 {
2459 num -= 30 * num5;
2460 if (num < 1)
2461 {
2462 num = 1;
2463 }
2464 }
2465 if (num > 0 && num4 > 0)
2466 {
2467 num -= 15 * num4;
2468 if (num <= 0)
2469 {
2470 num = 0;
2471 }
2472 }
2473 if (num <= hiScore)
2474 {
2475 continue;
2476 }
2477 bool flag = Housing_CheckIfInRoom(i, j);
2478 bool[] array = new bool[3];
2479 for (int m = 1; m <= 3; m++)
2480 {
2481 if (!Main.tile[i, j - m].active() || !Main.tileSolid[Main.tile[i, j - m].type])
2482 {
2483 array[m - 1] = true;
2484 }
2485 if (!Housing_CheckIfInRoom(i, j - m))
2486 {
2487 array[m - 1] = false;
2488 }
2489 }
2490 bool[] array2 = array;
2491 for (int n = 0; n < array2.Length; n++)
2492 {
2493 if (!array2[n])
2494 {
2495 flag = false;
2496 break;
2497 }
2498 }
2499 if (flag && !Housing_CheckIfIsCeiling(i, j))
2500 {
2501 hiScore = num;
2502 bestX = i;
2503 bestY = j;
2504 }
2505 }
2506 }
2507 }
2508
2509 public static void Housing_GetTestedRoomBounds(out int startX, out int endX, out int startY, out int endY)
2510 {
2511 int num = 40;
2512 int num2 = 5;
2513 int num3 = 3;
2514 startX = roomX1 - num2 - 1 - num;
2515 endX = roomX2 + num2 + 1 + num;
2516 startY = roomY1 - num3 - 1 - num;
2517 endY = roomY2 + num3 + 1 + num;
2518 if (startX < 5)
2519 {
2520 startX = 5;
2521 }
2522 if (endX >= Main.maxTilesX - 5)
2523 {
2524 endX = Main.maxTilesX - 6;
2525 }
2526 if (startY < 5)
2527 {
2528 startY = 5;
2529 }
2530 if (endY >= Main.maxTilesY - 5)
2531 {
2532 endY = Main.maxTilesY - 6;
2533 }
2534 }
2535
2536 private static bool ScoreRoom_CanBeHomeSpot(int x, int y)
2537 {
2538 Tile tile = Main.tile[x, y];
2539 if (tile.active())
2540 {
2541 ushort type = tile.type;
2542 if (type == 379)
2543 {
2544 return false;
2545 }
2546 }
2547 return true;
2548 }
2549
2550 private static bool Housing_CheckIfIsCeiling(int i, int j)
2551 {
2552 bool result = false;
2553 for (int k = 0; k < roomCeilingsCount; k++)
2554 {
2555 if (roomCeilingX[k] == i)
2556 {
2557 if (roomCeilingY[k] == j)
2558 {
2559 result = true;
2560 }
2561 break;
2562 }
2563 }
2564 return result;
2565 }
2566
2567 private static bool Housing_CheckIfInRoom(int i, int j)
2568 {
2569 bool result = false;
2570 for (int k = 0; k < numRoomTiles; k++)
2571 {
2572 if (roomX[k] == i && roomY[k] == j)
2573 {
2574 result = true;
2575 break;
2576 }
2577 }
2578 return result;
2579 }
2580
2581 public static bool StartRoomCheck(int x, int y)
2582 {
2583 roomHasStinkbug = false;
2584 roomHasEchoStinkbug = false;
2585 roomX1 = x;
2586 roomX2 = x;
2587 roomY1 = y;
2588 roomY2 = y;
2589 numRoomTiles = 0;
2591 for (int i = 0; i < TileID.Count; i++)
2592 {
2593 houseTile[i] = false;
2594 }
2595 canSpawn = true;
2596 if (Main.tile[x, y].nactive() && Main.tileSolid[Main.tile[x, y].type])
2597 {
2598 roomCheckFailureReason = TownNPCRoomCheckFailureReason.RoomCheckStartedInASolidTile;
2599 canSpawn = false;
2600 return false;
2601 }
2603 CheckRoom(x, y);
2604 if (!canSpawn)
2605 {
2606 return false;
2607 }
2608 if (numRoomTiles < 60)
2609 {
2611 canSpawn = false;
2612 return false;
2613 }
2614 if (canSpawn)
2615 {
2616 return true;
2617 }
2618 return false;
2619 }
2620
2621 public static void CheckRoom(int x, int y)
2622 {
2623 if (!canSpawn)
2624 {
2625 return;
2626 }
2627 if (x < 10 || y < 10 || x >= Main.maxTilesX - 10 || y >= lastMaxTilesY - 10)
2628 {
2630 canSpawn = false;
2631 return;
2632 }
2633 for (int i = 0; i < numRoomTiles; i++)
2634 {
2635 if (roomX[i] == x && roomY[i] == y)
2636 {
2637 return;
2638 }
2639 }
2640 roomX[numRoomTiles] = x;
2641 roomY[numRoomTiles] = y;
2642 bool flag = false;
2643 for (int j = 0; j < roomCeilingsCount; j++)
2644 {
2645 if (roomCeilingX[j] == x)
2646 {
2647 flag = true;
2648 if (roomCeilingY[j] > y)
2649 {
2650 roomCeilingY[j] = y;
2651 }
2652 break;
2653 }
2654 }
2655 if (!flag)
2656 {
2660 }
2661 numRoomTiles++;
2663 {
2665 canSpawn = false;
2666 return;
2667 }
2668 if (Main.tile[x, y].nactive())
2669 {
2670 houseTile[Main.tile[x, y].type] = true;
2671 if (Main.tileSolid[Main.tile[x, y].type] || (Main.tile[x, y].type == 11 && (Main.tile[x, y].frameX == 0 || Main.tile[x, y].frameX == 54 || Main.tile[x, y].frameX == 72 || Main.tile[x, y].frameX == 126)) || Main.tile[x, y].type == 389 || (Main.tile[x, y].type == 386 && ((Main.tile[x, y].frameX < 36 && Main.tile[x, y].frameY == 18) || (Main.tile[x, y].frameX >= 36 && Main.tile[x, y].frameY == 0))))
2672 {
2673 return;
2674 }
2675 }
2676 if (x < roomX1)
2677 {
2678 roomX1 = x;
2679 }
2680 if (x > roomX2)
2681 {
2682 roomX2 = x;
2683 }
2684 if (y < roomY1)
2685 {
2686 roomY1 = y;
2687 }
2688 if (y > roomY2)
2689 {
2690 roomY2 = y;
2691 }
2692 if (Main.tile[x, y].type == 630)
2693 {
2694 roomHasStinkbug = true;
2695 }
2696 if (Main.tile[x, y].type == 631)
2697 {
2698 roomHasEchoStinkbug = true;
2699 }
2700 bool flag2 = false;
2701 bool flag3 = false;
2702 for (int k = -2; k < 3; k++)
2703 {
2704 if (Main.wallHouse[Main.tile[x + k, y].wall])
2705 {
2706 flag2 = true;
2707 }
2708 if (Main.tile[x + k, y].nactive() && (Main.tileSolid[Main.tile[x + k, y].type] || TileID.Sets.HousingWalls[Main.tile[x + k, y].type]))
2709 {
2710 flag2 = true;
2711 }
2712 if (Main.wallHouse[Main.tile[x, y + k].wall])
2713 {
2714 flag3 = true;
2715 }
2716 if (Main.tile[x, y + k].nactive() && (Main.tileSolid[Main.tile[x, y + k].type] || TileID.Sets.HousingWalls[Main.tile[x, y + k].type]))
2717 {
2718 flag3 = true;
2719 }
2720 }
2721 if (!flag2 || !flag3)
2722 {
2724 canSpawn = false;
2725 return;
2726 }
2727 for (int l = x - 1; l < x + 2; l++)
2728 {
2729 for (int m = y - 1; m < y + 2; m++)
2730 {
2731 if ((l != x || m != y) && canSpawn)
2732 {
2733 CheckRoom(l, m);
2734 }
2735 }
2736 }
2737 }
2738
2739 public static void dropMeteor()
2740 {
2741 bool flag = true;
2742 if (Main.netMode == 1)
2743 {
2744 return;
2745 }
2746 for (int i = 0; i < 255; i++)
2747 {
2748 if (Main.player[i].active)
2749 {
2750 flag = false;
2751 break;
2752 }
2753 }
2754 int num = 0;
2755 double num2 = (double)Main.maxTilesX / 4200.0;
2756 int num3 = (int)(400.0 * num2);
2757 for (int j = 5; j < Main.maxTilesX - 5; j++)
2758 {
2759 for (int k = 5; (double)k < Main.worldSurface; k++)
2760 {
2761 if (Main.tile[j, k].active() && Main.tile[j, k].type == 37)
2762 {
2763 num++;
2764 if (num > num3)
2765 {
2766 return;
2767 }
2768 }
2769 }
2770 }
2771 double num4 = 600.0;
2772 int num5 = 0;
2773 while (!flag)
2774 {
2775 double num6 = (double)Main.maxTilesX * 0.08;
2776 int num7 = Main.rand.Next(150, Main.maxTilesX - 150);
2777 while ((double)num7 > (double)Main.spawnTileX - num6 && (double)num7 < (double)Main.spawnTileX + num6)
2778 {
2779 num7 = Main.rand.Next(150, Main.maxTilesX - 150);
2780 }
2781 for (int l = (int)(Main.worldSurface * 0.3); l < Main.maxTilesY; l++)
2782 {
2783 Tile tile = Main.tile[num7, l];
2784 if (!tile.active() || !Main.tileSolid[tile.type] || TileID.Sets.Platforms[tile.type])
2785 {
2786 continue;
2787 }
2788 int num8 = 0;
2789 int num9 = 15;
2790 for (int m = num7 - num9; m < num7 + num9; m++)
2791 {
2792 for (int n = l - num9; n < l + num9; n++)
2793 {
2794 if (SolidTile(m, n))
2795 {
2796 num8++;
2797 if (Main.tile[m, n].type == 189 || Main.tile[m, n].type == 202)
2798 {
2799 num8 -= 100;
2800 }
2801 }
2802 else if (Main.tile[m, n].liquid > 0)
2803 {
2804 num8--;
2805 }
2806 }
2807 }
2808 if ((double)num8 >= num4)
2809 {
2810 flag = meteor(num7, l);
2811 if (!flag)
2812 {
2813 }
2814 }
2815 else
2816 {
2817 num4 -= 0.5;
2818 }
2819 break;
2820 }
2821 num5++;
2823 {
2824 break;
2825 }
2826 }
2827 }
2828
2829 public static bool meteor(int i, int j, bool ignorePlayers = false)
2830 {
2831 if (i < 50 || i > Main.maxTilesX - 50)
2832 {
2833 return false;
2834 }
2835 if (j < 50 || j > Main.maxTilesY - 50)
2836 {
2837 return false;
2838 }
2839 int num = 35;
2840 Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16);
2841 for (int k = 0; k < 255; k++)
2842 {
2843 if (Main.player[k].active && !ignorePlayers)
2844 {
2845 Rectangle value = new Rectangle((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
2846 if (rectangle.Intersects(value))
2847 {
2848 return false;
2849 }
2850 }
2851 }
2852 for (int l = 0; l < 200; l++)
2853 {
2854 if (Main.npc[l].active)
2855 {
2856 Rectangle value2 = new Rectangle((int)Main.npc[l].position.X, (int)Main.npc[l].position.Y, Main.npc[l].width, Main.npc[l].height);
2857 if (rectangle.Intersects(value2))
2858 {
2859 return false;
2860 }
2861 }
2862 }
2863 for (int m = i - num; m < i + num; m++)
2864 {
2865 for (int n = j - num; n < j + num; n++)
2866 {
2867 if (Main.tile[m, n].active())
2868 {
2869 if (TileID.Sets.BasicChest[Main.tile[m, n].type] || Main.tileDungeon[Main.tile[m, n].type])
2870 {
2871 return false;
2872 }
2873 switch (Main.tile[m, n].type)
2874 {
2875 case 226:
2876 case 470:
2877 case 475:
2878 case 488:
2879 case 597:
2880 return false;
2881 }
2882 }
2883 }
2884 }
2885 stopDrops = true;
2886 num = genRand.Next(17, 23);
2887 for (int num2 = i - num; num2 < i + num; num2++)
2888 {
2889 for (int num3 = j - num; num3 < j + num; num3++)
2890 {
2891 if (num3 <= j + Main.rand.Next(-2, 3) - 5)
2892 {
2893 continue;
2894 }
2895 double num4 = Math.Abs(i - num2);
2896 double num5 = Math.Abs(j - num3);
2897 if (Math.Sqrt(num4 * num4 + num5 * num5) < (double)num * 0.9 + (double)Main.rand.Next(-4, 5))
2898 {
2899 if (!Main.tileSolid[Main.tile[num2, num3].type])
2900 {
2901 Main.tile[num2, num3].active(active: false);
2902 }
2903 Main.tile[num2, num3].type = 37;
2904 }
2905 }
2906 }
2907 num = genRand.Next(8, 14);
2908 for (int num6 = i - num; num6 < i + num; num6++)
2909 {
2910 for (int num7 = j - num; num7 < j + num; num7++)
2911 {
2912 if (num7 > j + Main.rand.Next(-2, 3) - 4)
2913 {
2914 double num8 = Math.Abs(i - num6);
2915 double num9 = Math.Abs(j - num7);
2916 if (Math.Sqrt(num8 * num8 + num9 * num9) < (double)num * 0.8 + (double)Main.rand.Next(-3, 4))
2917 {
2918 Main.tile[num6, num7].active(active: false);
2919 }
2920 }
2921 }
2922 }
2923 num = genRand.Next(25, 35);
2924 for (int num10 = i - num; num10 < i + num; num10++)
2925 {
2926 for (int num11 = j - num; num11 < j + num; num11++)
2927 {
2928 double num12 = Math.Abs(i - num10);
2929 double num13 = Math.Abs(j - num11);
2930 if (Math.Sqrt(num12 * num12 + num13 * num13) < (double)num * 0.7)
2931 {
2933 {
2935 }
2936 Main.tile[num10, num11].liquid = 0;
2937 }
2938 if (Main.tile[num10, num11].type == 37)
2939 {
2940 if (!SolidTile(num10 - 1, num11) && !SolidTile(num10 + 1, num11) && !SolidTile(num10, num11 - 1) && !SolidTile(num10, num11 + 1))
2941 {
2942 Main.tile[num10, num11].active(active: false);
2943 }
2944 else if ((Main.tile[num10, num11].halfBrick() || Main.tile[num10 - 1, num11].topSlope()) && !SolidTile(num10, num11 + 1))
2945 {
2946 Main.tile[num10, num11].active(active: false);
2947 }
2948 }
2951 }
2952 }
2953 num = genRand.Next(23, 32);
2954 for (int num14 = i - num; num14 < i + num; num14++)
2955 {
2956 for (int num15 = j - num; num15 < j + num; num15++)
2957 {
2958 if (num15 <= j + genRand.Next(-3, 4) - 3 || !Main.tile[num14, num15].active() || Main.rand.Next(10) != 0)
2959 {
2960 continue;
2961 }
2962 double num16 = Math.Abs(i - num14);
2963 double num17 = Math.Abs(j - num15);
2964 if (Math.Sqrt(num16 * num16 + num17 * num17) < (double)num * 0.8)
2965 {
2967 {
2969 }
2970 Main.tile[num14, num15].type = 37;
2972 }
2973 }
2974 }
2975 num = genRand.Next(30, 38);
2976 for (int num18 = i - num; num18 < i + num; num18++)
2977 {
2978 for (int num19 = j - num; num19 < j + num; num19++)
2979 {
2980 if (num19 <= j + genRand.Next(-2, 3) || !Main.tile[num18, num19].active() || Main.rand.Next(20) != 0)
2981 {
2982 continue;
2983 }
2984 double num20 = Math.Abs(i - num18);
2985 double num21 = Math.Abs(j - num19);
2986 if (Math.Sqrt(num20 * num20 + num21 * num21) < (double)num * 0.85)
2987 {
2989 {
2991 }
2992 Main.tile[num18, num19].type = 37;
2994 }
2995 }
2996 }
2997 stopDrops = false;
2998 if (Main.netMode == 0)
2999 {
3000 Main.NewText(Lang.gen[59].Value, 50, byte.MaxValue, 130);
3001 }
3002 else if (Main.netMode == 2)
3003 {
3004 ChatHelper.BroadcastChatMessage(NetworkText.FromKey(Lang.gen[59].Key), new Color(50, 255, 130));
3005 }
3006 if (Main.netMode != 1)
3007 {
3008 NetMessage.SendTileSquare(-1, i, j, 40);
3009 }
3010 return true;
3011 }
3012
3013 public static void setWorldSize()
3014 {
3015 Main.bottomWorld = Main.maxTilesY * 16;
3016 Main.rightWorld = Main.maxTilesX * 16;
3017 Main.maxSectionsX = Main.maxTilesX / 200;
3018 Main.maxSectionsY = Main.maxTilesY / 150;
3019 }
3020
3021 public static int GetWorldSize()
3022 {
3023 if (Main.maxTilesX <= 4200)
3024 {
3025 return 0;
3026 }
3027 if (Main.maxTilesX <= 6400)
3028 {
3029 return 1;
3030 }
3031 return 2;
3032 }
3033
3034 public static void worldGenCallback(object threadContext)
3035 {
3037 clearWorld();
3040 if (Main.menuMode == 10 || Main.menuMode == 888)
3041 {
3042 Main.menuMode = 6;
3043 }
3045 generatingWorld = false;
3046 }
3047
3049 {
3050 generatingWorld = true;
3051 Main.rand = new UnifiedRandom(Main.ActiveWorldFileData.Seed);
3052 gen = true;
3053 Main.menuMode = 888;
3054 try
3055 {
3056 Main.MenuUI.SetState(new UIWorldLoad());
3057 }
3058 catch
3059 {
3060 }
3061 return Task.Factory.StartNew(worldGenCallback, progress);
3062 }
3063
3064 public static void JustQuit()
3065 {
3066 try
3067 {
3068 SoundEngine.PlaySound(34, -1, -1, 0);
3069 SoundEngine.PlaySound(35, -1, -1, 0);
3070 }
3071 catch
3072 {
3073 }
3074 Main.invasionProgress = -1;
3075 Main.invasionProgressDisplayLeft = 0;
3076 Main.invasionProgressAlpha = 0f;
3077 Main.invasionProgressIcon = 0;
3078 Main.menuMode = 10;
3079 Main.gameMenu = true;
3082 Main.ActivePlayerFileData.StopPlayTimer();
3083 Main.fastForwardTimeToDawn = false;
3084 Main.fastForwardTimeToDusk = false;
3086 if (Main.netMode == 0)
3087 {
3089 Main.player[Main.myPlayer].position = new Vector2(0f, 0f);
3090 }
3091 else if (Main.netMode == 1)
3092 {
3093 Main.menuMode = 0;
3094 Netplay.Disconnect = true;
3095 Main.netMode = 0;
3096 }
3097 }
3098
3099 public static void SaveAndQuitCallBack(object threadContext)
3100 {
3101 int netMode = Main.netMode;
3102 try
3103 {
3104 SoundEngine.PlaySound(34, -1, -1, 0);
3105 SoundEngine.PlaySound(35, -1, -1, 0);
3106 }
3107 catch
3108 {
3109 }
3110 if (netMode == 0)
3111 {
3113 }
3114 Main.invasionProgress = -1;
3115 Main.invasionProgressDisplayLeft = 0;
3116 Main.invasionProgressAlpha = 0f;
3117 Main.invasionProgressIcon = 0;
3118 Main.menuMode = 10;
3119 Main.gameMenu = true;
3122 Main.ActivePlayerFileData.StopPlayTimer();
3125 Rain.ClearRain();
3126 if (netMode == 0)
3127 {
3130 }
3131 else
3132 {
3133 Netplay.Disconnect = true;
3134 Main.netMode = 0;
3135 }
3136 Main.fastForwardTimeToDawn = false;
3137 Main.fastForwardTimeToDusk = false;
3139 Main.menuMode = 0;
3140 if (threadContext != null)
3141 {
3142 ((Action)threadContext)();
3143 }
3144 }
3145
3146 public static void SaveAndQuit(Action callback = null)
3147 {
3150 }
3151
3152 public static void RenameWorld(WorldFileData data, string newName, Action<string> callback = null)
3153 {
3154 data.SetAsActive();
3156 }
3157
3158 public static void RenameWorldCallBack(object threadContext)
3159 {
3160 if (threadContext != null && threadContext is Tuple<string, Action<string>> { Item1: var item, Item2: var item2 })
3161 {
3162 noMapUpdate = true;
3165 noMapUpdate = false;
3166 if (loadFailed || !loadSuccess)
3167 {
3168 Main.LoadWorlds();
3170 return;
3171 }
3172 Main.sectionManager.SetAllSectionsLoaded();
3173 double time = Main.time;
3174 bool dayTime = Main.dayTime;
3177 Main.time = time;
3178 Main.dayTime = dayTime;
3179 Main.worldName = item;
3181 Rain.ClearRain();
3182 Main.fastForwardTimeToDawn = false;
3183 Main.fastForwardTimeToDusk = false;
3185 item2?.Invoke(item);
3186 }
3187 }
3188
3189 public static void playWorldCallBack(object threadContext)
3190 {
3191 if (Main.rand == null)
3192 {
3193 Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
3194 }
3195 for (int i = 0; i < 255; i++)
3196 {
3197 if (i != Main.myPlayer)
3198 {
3199 Main.player[i].active = false;
3200 }
3201 }
3202 noMapUpdate = true;
3205 if (loadFailed || !loadSuccess)
3206 {
3208 if (loadFailed || !loadSuccess)
3209 {
3210 bool isCloudSave = Main.ActiveWorldFileData.IsCloudSave;
3212 {
3213 worldBackup = true;
3214 }
3215 else
3216 {
3217 worldBackup = false;
3218 }
3219 if (!Main.dedServ)
3220 {
3221 if (worldBackup)
3222 {
3223 Main.menuMode = 200;
3224 }
3225 else
3226 {
3227 Main.menuMode = 201;
3228 }
3229 return;
3230 }
3231 if (!worldBackup)
3232 {
3233 Console.WriteLine(Language.GetTextValue("Error.LoadFailedNoBackup"));
3234 return;
3235 }
3240 if (loadFailed || !loadSuccess)
3241 {
3243 if (loadFailed || !loadSuccess)
3244 {
3248 Console.WriteLine(Language.GetTextValue("Error.LoadFailed"));
3249 return;
3250 }
3251 }
3252 }
3253 }
3254 if (Main.mapEnabled)
3255 {
3256 Main.Map.Load();
3257 }
3258 if (Main.netMode != 2)
3259 {
3260 Main.sectionManager.SetAllSectionsLoaded();
3261 }
3262 while (Main.loadMapLock)
3263 {
3264 float num = (float)Main.loadMapLastX / (float)Main.maxTilesX;
3265 Main.statusText = Lang.gen[68].Value + " " + (int)(num * 100f + 1f) + "%";
3266 Thread.Sleep(0);
3267 if (!Main.mapEnabled)
3268 {
3269 break;
3270 }
3271 }
3272 if (Main.gameMenu)
3273 {
3274 Main.gameMenu = false;
3275 }
3276 if (Main.netMode == 0 && Main.anglerWhoFinishedToday.Contains(Main.player[Main.myPlayer].name))
3277 {
3278 Main.anglerQuestFinished = true;
3279 }
3280 Main.player[Main.myPlayer].Spawn(PlayerSpawnContext.SpawningIntoWorld);
3284 Main.resetClouds = true;
3285 noMapUpdate = false;
3286 }
3287
3288 public static void playWorld()
3289 {
3291 }
3292
3293 public static void saveAndPlayCallBack(object threadContext)
3294 {
3296 }
3297
3298 public static void saveAndPlay()
3299 {
3301 }
3302
3307
3312
3313 public static void serverLoadWorldCallBack()
3314 {
3315 Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
3317 if (loadFailed || !loadSuccess)
3318 {
3320 if (loadFailed || !loadSuccess)
3321 {
3322 bool isCloudSave = Main.ActiveWorldFileData.IsCloudSave;
3324 {
3325 worldBackup = true;
3326 }
3327 else
3328 {
3329 worldBackup = false;
3330 }
3331 if (!Main.dedServ)
3332 {
3333 if (worldBackup)
3334 {
3335 Main.menuMode = 200;
3336 }
3337 else
3338 {
3339 Main.menuMode = 201;
3340 }
3341 return;
3342 }
3343 if (!worldBackup)
3344 {
3345 Console.WriteLine(Language.GetTextValue("Error.LoadFailedNoBackup"));
3346 return;
3347 }
3351 if (loadFailed || !loadSuccess)
3352 {
3354 if (loadFailed || !loadSuccess)
3355 {
3356 Console.WriteLine(Language.GetTextValue("Error.LoadFailed"));
3357 return;
3358 }
3359 }
3360 }
3361 }
3366 }
3367
3368 public static Task serverLoadWorld()
3369 {
3370 return Task.Factory.StartNew(serverLoadWorldCallBack);
3371 }
3372
3373 public static void clearWorld()
3374 {
3375 //IL_0298: Unknown result type (might be due to invalid IL or missing references)
3376 //IL_029d: Unknown result type (might be due to invalid IL or missing references)
3378 Main.ladyBugRainBoost = 0;
3379 Main.getGoodWorld = false;
3380 Main.drunkWorld = false;
3381 Main.tenthAnniversaryWorld = false;
3382 Main.dontStarveWorld = false;
3383 Main.notTheBeesWorld = false;
3384 Main.remixWorld = false;
3385 Main.noTrapsWorld = false;
3386 Main.zenithWorld = false;
3387 Main.afterPartyOfDoom = false;
3388 Main.shimmerAlpha = 0f;
3389 Main.shimmerDarken = 0f;
3390 Main.shimmerBrightenDelay = 0f;
3392 NPC.freeCake = false;
3393 NPC.mechQueen = -1;
3394 Main.mapDelay = 2;
3395 Main.waterStyle = 0;
3399 TownManager.Clear();
3401 Main.instance.ClearCachedTileDraws();
3403 TileEntity.Clear();
3404 Main.checkXMas();
3407 Wiring.ClearAll();
3408 Main.ParticleSystem_World_BehindPlayers.Particles.Clear();
3409 Main.ParticleSystem_World_OverPlayers.Particles.Clear();
3410 if (Main.mapReady)
3411 {
3412 for (int i = 0; i < lastMaxTilesX; i++)
3413 {
3414 _ = (float)i / (float)lastMaxTilesX;
3415 Main.statusText = Lang.gen[65].Value;
3416 }
3417 if (Main.Map != null)
3418 {
3419 Main.Map.Clear();
3420 }
3421 }
3422 NPC.MoonLordCountdown = 0;
3423 Main.forceHalloweenForToday = false;
3424 Main.forceXMasForToday = false;
3425 NPC.RevengeManager.Reset();
3426 Main.pumpkinMoon = false;
3427 Main.clearMap = true;
3428 Main.mapTime = 0;
3429 Main.updateMap = false;
3430 Main.mapReady = false;
3431 Main.refreshMap = false;
3432 Main.eclipse = false;
3433 Main.slimeRain = false;
3434 Main.slimeRainTime = 0.0;
3435 Main.slimeWarningTime = 0;
3436 Main.sundialCooldown = 0;
3437 Main.moondialCooldown = 0;
3438 Main.fastForwardTimeToDawn = false;
3439 Main.fastForwardTimeToDusk = false;
3442 mysticLogsEvent.WorldClear();
3445 Main.DroneCameraTracker.WorldClear();
3446 Main.LocalGolfState.WorldClear();
3447 Main.CurrentPan = Vector2.Zero;
3449 Main.wofNPCIndex = -1;
3450 NPC.waveKills = 0f;
3451 spawnHardBoss = 0;
3452 totalSolid2 = 0;
3453 totalGood2 = 0;
3454 totalEvil2 = 0;
3455 totalBlood2 = 0;
3456 totalSolid = 0;
3457 totalGood = 0;
3458 totalEvil = 0;
3459 totalBlood = 0;
3461 Main.maxRaining = 0f;
3462 totalX = 0;
3463 totalD = 0;
3464 tEvil = 0;
3465 tBlood = 0;
3466 tGood = 0;
3467 spawnEye = false;
3469 shadowOrbCount = 0;
3470 altarCount = 0;
3471 SavedOreTiers.Copper = -1;
3472 SavedOreTiers.Iron = -1;
3473 SavedOreTiers.Silver = -1;
3474 SavedOreTiers.Gold = -1;
3475 SavedOreTiers.Cobalt = -1;
3476 SavedOreTiers.Mythril = -1;
3477 SavedOreTiers.Adamantite = -1;
3478 GenVars.shimmerPosition = Vector2D.Zero;
3479 Main.cloudBGActive = 0f;
3480 Main.raining = false;
3481 Main.hardMode = false;
3482 Main.helpText = 0;
3483 Main.BartenderHelpTextIndex = 0;
3484 Main.dungeonX = 0;
3485 Main.dungeonY = 0;
3486 NPC.downedBoss1 = false;
3487 NPC.downedBoss2 = false;
3488 NPC.downedBoss3 = false;
3489 NPC.downedQueenBee = false;
3490 NPC.downedSlimeKing = false;
3491 NPC.downedMechBossAny = false;
3492 NPC.downedMechBoss1 = false;
3493 NPC.downedMechBoss2 = false;
3494 NPC.downedMechBoss3 = false;
3495 NPC.downedFishron = false;
3496 NPC.downedAncientCultist = false;
3497 NPC.downedMoonlord = false;
3498 NPC.downedHalloweenKing = false;
3499 NPC.downedHalloweenTree = false;
3500 NPC.downedChristmasIceQueen = false;
3501 NPC.downedChristmasSantank = false;
3502 NPC.downedChristmasTree = false;
3503 NPC.downedPlantBoss = false;
3504 NPC.downedGolemBoss = false;
3505 NPC.downedEmpressOfLight = false;
3506 NPC.downedQueenSlime = false;
3507 NPC.downedDeerclops = false;
3508 NPC.combatBookWasUsed = false;
3509 NPC.combatBookVolumeTwoWasUsed = false;
3510 NPC.peddlersSatchelWasUsed = false;
3511 NPC.savedStylist = false;
3512 NPC.savedGoblin = false;
3513 NPC.savedWizard = false;
3514 NPC.savedMech = false;
3515 NPC.savedTaxCollector = false;
3516 NPC.savedAngler = false;
3517 NPC.savedBartender = false;
3518 NPC.savedGolfer = false;
3519 NPC.boughtCat = false;
3520 NPC.boughtDog = false;
3521 NPC.boughtBunny = false;
3522 NPC.unlockedSlimeBlueSpawn = false;
3523 NPC.unlockedSlimeGreenSpawn = false;
3524 NPC.unlockedSlimeOldSpawn = false;
3525 NPC.unlockedSlimePurpleSpawn = false;
3526 NPC.unlockedSlimeRainbowSpawn = false;
3527 NPC.unlockedSlimeRedSpawn = false;
3528 NPC.unlockedSlimeYellowSpawn = false;
3529 NPC.unlockedSlimeCopperSpawn = false;
3530 NPC.unlockedMerchantSpawn = false;
3531 NPC.unlockedDemolitionistSpawn = false;
3532 NPC.unlockedPartyGirlSpawn = false;
3533 NPC.unlockedDyeTraderSpawn = false;
3534 NPC.unlockedTruffleSpawn = false;
3535 NPC.unlockedArmsDealerSpawn = false;
3536 NPC.unlockedNurseSpawn = false;
3537 NPC.unlockedPrincessSpawn = false;
3539 NPC.downedGoblins = false;
3540 NPC.downedClown = false;
3541 NPC.downedFrost = false;
3542 NPC.downedPirates = false;
3543 NPC.downedMartians = false;
3544 NPC.downedTowerSolar = (NPC.downedTowerVortex = (NPC.downedTowerNebula = (NPC.downedTowerStardust = (NPC.LunarApocalypseIsUp = false))));
3545 NPC.TowerActiveSolar = (NPC.TowerActiveVortex = (NPC.TowerActiveNebula = (NPC.TowerActiveStardust = false)));
3548 Main.BestiaryTracker.Reset();
3549 Main.PylonSystem.Reset();
3551 Main.CreativeMenu.Reset();
3552 shadowOrbSmashed = false;
3553 spawnMeteor = false;
3554 stopDrops = false;
3555 Main.invasionDelay = 0;
3556 Main.invasionType = 0;
3557 Main.invasionSize = 0;
3558 Main.invasionWarn = 0;
3559 Main.invasionX = 0.0;
3560 Main.invasionSizeStart = 0;
3561 Main.treeX[0] = Main.maxTilesX;
3562 Main.treeX[1] = Main.maxTilesX;
3563 Main.treeX[2] = Main.maxTilesX;
3564 Main.treeStyle[0] = 0;
3565 Main.treeStyle[1] = 0;
3566 Main.treeStyle[2] = 0;
3567 Main.treeStyle[3] = 0;
3568 noLiquidCheck = false;
3569 Liquid.numLiquid = 0;
3570 LiquidBuffer.numLiquidBuffer = 0;
3572 {
3573 for (int j = 0; j < lastMaxTilesX; j++)
3574 {
3575 float num = (float)j / (float)lastMaxTilesX;
3576 Main.statusText = Lang.gen[46].Value + " " + (int)(num * 100f + 1f) + "%";
3577 for (int k = 0; k < lastMaxTilesY; k++)
3578 {
3579 Main.tile[j, k] = null;
3580 }
3581 }
3582 }
3585 if (Main.netMode != 2)
3586 {
3587 Main.sectionManager = new WorldSections(Main.maxTilesX / 200, Main.maxTilesY / 150);
3588 }
3589 if (Main.netMode != 1)
3590 {
3591 for (int l = 0; l < Main.maxTilesX; l++)
3592 {
3593 float num2 = (float)l / (float)Main.maxTilesX;
3594 Main.statusText = Lang.gen[47].Value + " " + (int)(num2 * 100f + 1f) + "%";
3595 for (int m = 0; m < Main.maxTilesY; m++)
3596 {
3597 if (Main.tile[l, m] == null)
3598 {
3599 Main.tile[l, m] = new Tile();
3600 }
3601 else
3602 {
3603 Main.tile[l, m].ClearEverything();
3604 }
3605 }
3606 }
3607 }
3608 for (int n = 0; n < Main.countsAsHostForGameplay.Length; n++)
3609 {
3611 }
3614 for (int num3 = 0; num3 < 6000; num3++)
3615 {
3616 Main.dust[num3] = new Dust();
3617 Main.dust[num3].dustIndex = num3;
3618 }
3619 for (int num4 = 0; num4 < 600; num4++)
3620 {
3621 Main.gore[num4] = new Gore();
3622 }
3623 for (int num5 = 0; num5 < 400; num5++)
3624 {
3625 Main.item[num5] = new Item();
3626 Main.item[num5].whoAmI = num5;
3628 }
3629 for (int num6 = 0; num6 < 200; num6++)
3630 {
3631 Main.npc[num6] = new NPC();
3632 Main.npc[num6].whoAmI = num6;
3633 }
3634 for (int num7 = 0; num7 < 1000; num7++)
3635 {
3636 Main.projectile[num7] = new Projectile();
3637 Main.projectile[num7].whoAmI = num7;
3638 }
3639 for (int num8 = 0; num8 < 8000; num8++)
3640 {
3641 Main.chest[num8] = null;
3642 }
3643 for (int num9 = 0; num9 < 1000; num9++)
3644 {
3645 Main.sign[num9] = null;
3646 }
3647 for (int num10 = 0; num10 < Liquid.maxLiquid; num10++)
3648 {
3649 Main.liquid[num10] = new Liquid();
3650 }
3651 for (int num11 = 0; num11 < 50000; num11++)
3652 {
3654 }
3655 setWorldSize();
3656 Star.SpawnStars();
3657 worldCleared = true;
3658 }
3659
3660 public static void setBG(int bg, int style)
3661 {
3662 switch (bg)
3663 {
3664 case 0:
3665 treeBG1 = style;
3667 break;
3668 case 10:
3669 treeBG2 = style;
3671 break;
3672 case 11:
3673 treeBG3 = style;
3675 break;
3676 case 12:
3677 treeBG4 = style;
3679 break;
3680 case 1:
3681 corruptBG = style;
3682 switch (style)
3683 {
3684 default:
3685 Main.corruptBG[0] = 12;
3686 Main.corruptBG[1] = 13;
3687 Main.corruptBG[2] = 14;
3688 break;
3689 case 1:
3690 Main.corruptBG[0] = 56;
3691 Main.corruptBG[1] = 57;
3692 Main.corruptBG[2] = 58;
3693 break;
3694 case 2:
3695 Main.corruptBG[0] = 211;
3696 Main.corruptBG[1] = 212;
3697 Main.corruptBG[2] = 213;
3698 break;
3699 case 3:
3700 Main.corruptBG[0] = 225;
3701 Main.corruptBG[1] = 226;
3702 Main.corruptBG[2] = 227;
3703 break;
3704 case 4:
3705 Main.corruptBG[0] = 240;
3706 Main.corruptBG[1] = 241;
3707 Main.corruptBG[2] = 242;
3708 break;
3709 }
3710 break;
3711 case 2:
3712 jungleBG = style;
3713 switch (style)
3714 {
3715 default:
3716 Main.jungleBG[0] = 15;
3717 Main.jungleBG[1] = 16;
3718 Main.jungleBG[2] = 17;
3719 break;
3720 case 1:
3721 Main.jungleBG[0] = 59;
3722 Main.jungleBG[1] = 60;
3723 Main.jungleBG[2] = 61;
3724 break;
3725 case 2:
3726 Main.jungleBG[0] = 222;
3727 Main.jungleBG[1] = 223;
3728 Main.jungleBG[2] = 224;
3729 break;
3730 case 3:
3731 Main.jungleBG[0] = 237;
3732 Main.jungleBG[1] = 238;
3733 Main.jungleBG[2] = 239;
3734 break;
3735 case 4:
3736 Main.jungleBG[0] = 284;
3737 Main.jungleBG[1] = 285;
3738 Main.jungleBG[2] = 286;
3739 break;
3740 case 5:
3741 Main.jungleBG[0] = 271;
3742 Main.jungleBG[1] = 272;
3743 Main.jungleBG[2] = 273;
3744 break;
3745 }
3746 break;
3747 case 3:
3748 snowBG = style;
3749 Main.snowMntBG[0] = 35;
3750 Main.snowMntBG[1] = 36;
3751 switch (style)
3752 {
3753 default:
3754 Main.snowBG[0] = 37;
3755 Main.snowBG[1] = 38;
3756 Main.snowBG[2] = 39;
3757 break;
3758 case 1:
3759 Main.snowBG[0] = 97;
3760 Main.snowBG[1] = 96;
3761 Main.snowBG[2] = 95;
3762 break;
3763 case 2:
3764 Main.snowMntBG[0] = 98;
3765 Main.snowMntBG[1] = 99;
3766 Main.snowBG[0] = -1;
3767 Main.snowBG[1] = -1;
3768 Main.snowBG[2] = -1;
3769 break;
3770 case 21:
3771 Main.snowMntBG[0] = 98;
3772 Main.snowMntBG[1] = 99;
3773 Main.snowBG[0] = 95;
3774 Main.snowBG[1] = 96;
3775 Main.snowBG[2] = 97;
3776 break;
3777 case 22:
3778 Main.snowMntBG[0] = 98;
3779 Main.snowMntBG[1] = 99;
3780 Main.snowBG[0] = 37;
3781 Main.snowBG[1] = 38;
3782 Main.snowBG[2] = 39;
3783 break;
3784 case 3:
3785 Main.snowMntBG[0] = 98;
3786 Main.snowMntBG[1] = 100;
3787 Main.snowBG[0] = -1;
3788 Main.snowBG[1] = -1;
3789 Main.snowBG[2] = -1;
3790 break;
3791 case 31:
3792 Main.snowMntBG[0] = 98;
3793 Main.snowMntBG[1] = 100;
3794 Main.snowBG[0] = 95;
3795 Main.snowBG[1] = 96;
3796 Main.snowBG[2] = 97;
3797 break;
3798 case 32:
3799 Main.snowMntBG[0] = 98;
3800 Main.snowMntBG[1] = 100;
3801 Main.snowBG[0] = 37;
3802 Main.snowBG[1] = 38;
3803 Main.snowBG[2] = 39;
3804 break;
3805 case 4:
3806 Main.snowMntBG[0] = 98;
3807 Main.snowMntBG[1] = 101;
3808 Main.snowBG[0] = -1;
3809 Main.snowBG[1] = -1;
3810 Main.snowBG[2] = -1;
3811 break;
3812 case 41:
3813 Main.snowMntBG[0] = 98;
3814 Main.snowMntBG[1] = 101;
3815 Main.snowBG[0] = 95;
3816 Main.snowBG[1] = 96;
3817 Main.snowBG[2] = 97;
3818 break;
3819 case 42:
3820 Main.snowMntBG[0] = 98;
3821 Main.snowMntBG[1] = 101;
3822 Main.snowBG[0] = 37;
3823 Main.snowBG[1] = 38;
3824 Main.snowBG[2] = 39;
3825 break;
3826 case 5:
3827 Main.snowMntBG[0] = -1;
3828 Main.snowMntBG[1] = -1;
3829 Main.snowBG[0] = 258;
3830 Main.snowBG[1] = 259;
3831 Main.snowBG[2] = 260;
3832 break;
3833 case 6:
3834 Main.snowMntBG[0] = -1;
3835 Main.snowMntBG[1] = -1;
3836 Main.snowBG[0] = 263;
3837 Main.snowBG[1] = 264;
3838 Main.snowBG[2] = 265;
3839 break;
3840 case 7:
3841 Main.snowMntBG[0] = 269;
3842 Main.snowMntBG[1] = 270;
3843 Main.snowBG[0] = 267;
3844 Main.snowBG[1] = 266;
3845 Main.snowBG[2] = 268;
3846 break;
3847 }
3848 break;
3849 case 4:
3850 hallowBG = style;
3851 switch (style)
3852 {
3853 default:
3854 Main.hallowBG[0] = 29;
3855 Main.hallowBG[1] = 30;
3856 Main.hallowBG[2] = 31;
3857 break;
3858 case 1:
3859 Main.hallowBG[0] = 102;
3860 Main.hallowBG[1] = 103;
3861 Main.hallowBG[2] = 104;
3862 break;
3863 case 2:
3864 Main.hallowBG[0] = 219;
3865 Main.hallowBG[1] = 220;
3866 Main.hallowBG[2] = 221;
3867 break;
3868 case 3:
3869 Main.hallowBG[0] = 243;
3870 Main.hallowBG[1] = 244;
3871 Main.hallowBG[2] = 245;
3872 break;
3873 case 4:
3874 Main.hallowBG[0] = -1;
3875 Main.hallowBG[1] = 261;
3876 Main.hallowBG[2] = 262;
3877 break;
3878 }
3879 break;
3880 case 5:
3881 crimsonBG = style;
3882 switch (style)
3883 {
3884 default:
3885 Main.crimsonBG[0] = 43;
3886 Main.crimsonBG[1] = 44;
3887 Main.crimsonBG[2] = 45;
3888 break;
3889 case 1:
3890 Main.crimsonBG[0] = 105;
3891 Main.crimsonBG[1] = 106;
3892 Main.crimsonBG[2] = 107;
3893 break;
3894 case 2:
3895 Main.crimsonBG[0] = 174;
3896 Main.crimsonBG[1] = -1;
3897 Main.crimsonBG[2] = 175;
3898 break;
3899 case 3:
3900 Main.crimsonBG[0] = 214;
3901 Main.crimsonBG[1] = 215;
3902 Main.crimsonBG[2] = 216;
3903 break;
3904 case 4:
3905 Main.crimsonBG[0] = -1;
3906 Main.crimsonBG[1] = 229;
3907 Main.crimsonBG[2] = 230;
3908 break;
3909 case 5:
3910 Main.crimsonBG[0] = 255;
3911 Main.crimsonBG[1] = 256;
3912 Main.crimsonBG[2] = 257;
3913 break;
3914 }
3915 break;
3916 case 6:
3917 desertBG = style;
3918 switch (style)
3919 {
3920 default:
3921 Main.desertBG[0] = 21;
3922 Main.desertBG[1] = 20;
3923 Main.desertBG[2] = -1;
3924 break;
3925 case 1:
3926 Main.desertBG[0] = 108;
3927 Main.desertBG[1] = 109;
3928 Main.desertBG[2] = -1;
3929 break;
3930 case 2:
3931 Main.desertBG[0] = 207;
3932 Main.desertBG[1] = 208;
3933 Main.desertBG[2] = -1;
3934 break;
3935 case 3:
3936 Main.desertBG[0] = 217;
3937 Main.desertBG[1] = 218;
3938 Main.desertBG[2] = -1;
3939 break;
3940 case 4:
3941 Main.desertBG[0] = 248;
3942 Main.desertBG[1] = 249;
3943 Main.desertBG[2] = 250;
3944 break;
3945 }
3946 break;
3947 case 7:
3948 oceanBG = style;
3949 switch (style)
3950 {
3951 default:
3952 Main.oceanBG = 28;
3953 break;
3954 case 1:
3955 Main.oceanBG = 110;
3956 break;
3957 case 2:
3958 Main.oceanBG = 111;
3959 break;
3960 case 3:
3961 Main.oceanBG = 209;
3962 break;
3963 case 4:
3964 Main.oceanBG = 210;
3965 break;
3966 case 5:
3967 Main.oceanBG = 283;
3968 break;
3969 }
3970 break;
3971 case 8:
3972 mushroomBG = style;
3973 switch (style)
3974 {
3975 default:
3976 Main.mushroomBG[0] = 46;
3977 Main.mushroomBG[1] = 47;
3978 Main.mushroomBG[2] = 48;
3979 break;
3980 case 1:
3981 Main.mushroomBG[0] = 231;
3982 Main.mushroomBG[1] = 232;
3983 Main.mushroomBG[2] = 233;
3984 break;
3985 case 2:
3986 Main.mushroomBG[0] = 234;
3987 Main.mushroomBG[1] = 235;
3988 Main.mushroomBG[2] = 236;
3989 break;
3990 case 3:
3991 Main.mushroomBG[0] = 287;
3992 Main.mushroomBG[1] = 288;
3993 Main.mushroomBG[2] = 289;
3994 break;
3995 }
3996 break;
3997 case 9:
3998 underworldBG = style;
3999 switch (style)
4000 {
4001 default:
4002 Main.underworldBG[0] = 0;
4003 Main.underworldBG[1] = 1;
4004 Main.underworldBG[2] = 2;
4005 Main.underworldBG[3] = 3;
4006 Main.underworldBG[4] = 4;
4007 break;
4008 case 1:
4009 Main.underworldBG[0] = 5;
4010 Main.underworldBG[1] = 6;
4011 Main.underworldBG[2] = 7;
4012 Main.underworldBG[3] = 8;
4013 Main.underworldBG[4] = 9;
4014 break;
4015 case 2:
4016 Main.underworldBG[0] = 10;
4017 Main.underworldBG[1] = 11;
4018 Main.underworldBG[2] = 12;
4019 Main.underworldBG[3] = 13;
4020 Main.underworldBG[4] = 9;
4021 break;
4022 }
4023 break;
4024 }
4025 }
4026
4027 private static void SetForestBGSet(int style, int[] mountainSet, int[] treeSet)
4028 {
4029 mountainSet[0] = 7;
4030 mountainSet[1] = 8;
4031 switch (style)
4032 {
4033 case 1:
4034 treeSet[0] = 50;
4035 treeSet[1] = 51;
4036 treeSet[2] = 52;
4037 break;
4038 case 2:
4039 treeSet[0] = 53;
4040 treeSet[1] = 54;
4041 treeSet[2] = 55;
4042 break;
4043 case 3:
4044 mountainSet[1] = 90;
4045 treeSet[0] = 91;
4046 treeSet[1] = -1;
4047 treeSet[2] = 92;
4048 break;
4049 case 31:
4050 mountainSet[1] = 90;
4051 treeSet[0] = 91;
4052 treeSet[1] = -1;
4053 treeSet[2] = 11;
4054 break;
4055 case 4:
4056 mountainSet[0] = 93;
4057 mountainSet[1] = 94;
4058 treeSet[0] = -1;
4059 treeSet[1] = -1;
4060 treeSet[2] = -1;
4061 break;
4062 case 5:
4063 mountainSet[0] = 93;
4064 mountainSet[1] = 94;
4065 treeSet[0] = -1;
4066 treeSet[1] = -1;
4067 treeSet[2] = 55;
4068 break;
4069 case 51:
4070 mountainSet[0] = 93;
4071 mountainSet[1] = 94;
4072 treeSet[0] = -1;
4073 treeSet[1] = -1;
4074 treeSet[2] = 11;
4075 break;
4076 case 6:
4077 mountainSet[0] = 171;
4078 mountainSet[1] = 172;
4079 treeSet[0] = 173;
4080 treeSet[1] = -1;
4081 treeSet[2] = -1;
4082 break;
4083 case 7:
4084 mountainSet[0] = 176;
4085 mountainSet[1] = 177;
4086 treeSet[0] = 178;
4087 treeSet[1] = -1;
4088 treeSet[2] = -1;
4089 break;
4090 case 71:
4091 mountainSet[0] = 176;
4092 mountainSet[1] = 177;
4093 treeSet[0] = 178;
4094 treeSet[1] = -1;
4095 treeSet[2] = 11;
4096 break;
4097 case 72:
4098 mountainSet[0] = 176;
4099 mountainSet[1] = 177;
4100 treeSet[0] = 178;
4101 treeSet[1] = -1;
4102 treeSet[2] = 52;
4103 break;
4104 case 73:
4105 mountainSet[0] = 176;
4106 mountainSet[1] = 177;
4107 treeSet[0] = 178;
4108 treeSet[1] = -1;
4109 treeSet[2] = 55;
4110 break;
4111 case 8:
4112 mountainSet[0] = 179;
4113 mountainSet[1] = 180;
4114 treeSet[0] = 184;
4115 treeSet[1] = -1;
4116 treeSet[2] = -1;
4117 break;
4118 case 9:
4119 mountainSet[0] = 277;
4120 mountainSet[1] = 278;
4121 treeSet[0] = 279;
4122 treeSet[1] = -1;
4123 treeSet[2] = -1;
4124 break;
4125 case 10:
4126 mountainSet[0] = 280;
4127 mountainSet[1] = 281;
4128 treeSet[0] = 282;
4129 treeSet[1] = -1;
4130 treeSet[2] = -1;
4131 break;
4132 default:
4133 treeSet[0] = 9;
4134 treeSet[1] = 10;
4135 treeSet[2] = 11;
4136 break;
4137 }
4138 }
4139
4140 public static void RandomizeWeather()
4141 {
4142 Main.numClouds = genRand.Next(10, 200);
4143 Main.windSpeedCurrent = 0f;
4144 while (Main.windSpeedCurrent == 0f)
4145 {
4146 Main.windSpeedCurrent = (float)genRand.Next(-400, 401) * 0.001f;
4147 Main.windSpeedTarget = Main.windSpeedCurrent;
4148 }
4150 }
4151
4152 public static void RandomizeMoonState(UnifiedRandom random, bool garenteeNewStyle = false)
4153 {
4154 int moonType = Main.moonType;
4155 do
4156 {
4157 Main.moonType = random.Next(9);
4158 }
4159 while (garenteeNewStyle && moonType == Main.moonType);
4160 }
4161
4162 public static void RandomizeBackgroundBasedOnPlayer(UnifiedRandom random, Player player)
4163 {
4164 if (player.ZoneGlowshroom)
4165 {
4166 int num = mushroomBG;
4167 while (num == mushroomBG)
4168 {
4169 setBG(8, random.Next(4));
4170 }
4171 }
4172 else if (player.ZoneUnderworldHeight)
4173 {
4174 int num = underworldBG;
4175 while (num == underworldBG)
4176 {
4177 setBG(9, random.Next(3));
4178 }
4179 }
4180 else if (player.ZoneDesert)
4181 {
4182 int num = desertBG;
4183 while (num == desertBG)
4184 {
4185 setBG(6, random.Next(5));
4186 }
4187 }
4188 else if (player.ZoneHallow)
4189 {
4190 int num = hallowBG;
4191 while (num == hallowBG)
4192 {
4193 setBG(4, random.Next(5));
4194 }
4195 }
4196 else if (player.ZoneCorrupt)
4197 {
4198 int num = corruptBG;
4199 while (num == corruptBG)
4200 {
4201 setBG(1, random.Next(5));
4202 }
4203 }
4204 else if (player.ZoneCrimson)
4205 {
4206 int num = crimsonBG;
4207 while (num == crimsonBG)
4208 {
4209 setBG(5, random.Next(6));
4210 }
4211 }
4212 else if (player.ZoneJungle)
4213 {
4214 int num = jungleBG;
4215 while (num == jungleBG)
4216 {
4217 setBG(2, random.Next(6));
4218 }
4219 }
4220 else if (player.ZoneSnow)
4221 {
4222 int num = snowBG;
4223 while (num == snowBG)
4224 {
4225 snowBG = random.Next(8);
4226 if (snowBG == 2 && random.Next(2) == 0)
4227 {
4228 if (random.Next(2) == 0)
4229 {
4230 snowBG = 21;
4231 }
4232 else
4233 {
4234 snowBG = 22;
4235 }
4236 }
4237 if (snowBG == 3 && random.Next(2) == 0)
4238 {
4239 if (random.Next(2) == 0)
4240 {
4241 snowBG = 31;
4242 }
4243 else
4244 {
4245 snowBG = 32;
4246 }
4247 }
4248 if (snowBG == 4 && random.Next(2) == 0)
4249 {
4250 if (random.Next(2) == 0)
4251 {
4252 snowBG = 41;
4253 }
4254 else
4255 {
4256 snowBG = 42;
4257 }
4258 }
4259 setBG(3, snowBG);
4260 }
4261 }
4262 else if (player.ZoneBeach)
4263 {
4264 int num = oceanBG;
4265 while (num == oceanBG)
4266 {
4267 setBG(7, random.Next(6));
4268 }
4269 }
4270 else
4271 {
4272 int num2 = (int)(player.Center.X / 16f);
4273 if (num2 < Main.treeX[0])
4274 {
4275 int num = treeBG1;
4277 {
4279 }
4280 setBG(0, treeBG1);
4281 }
4282 else if (num2 < Main.treeX[1])
4283 {
4284 int num = treeBG2;
4286 {
4288 }
4289 setBG(10, treeBG2);
4290 }
4291 else if (num2 < Main.treeX[2])
4292 {
4293 int num = treeBG3;
4295 {
4297 }
4298 setBG(11, treeBG3);
4299 }
4300 else
4301 {
4302 int num = treeBG4;
4304 {
4306 }
4307 setBG(12, treeBG4);
4308 }
4309 }
4310 BackgroundsCache.UpdateCache();
4311 }
4312
4313 public static void RandomizeBackgrounds(UnifiedRandom random)
4314 {
4317 {
4318 }
4320 while (treeBG3 == treeBG1 || treeBG3 == treeBG2)
4321 {
4323 }
4325 while (treeBG4 == treeBG1 || treeBG4 == treeBG2 || treeBG4 == treeBG3)
4326 {
4328 }
4329 setBG(0, treeBG1);
4330 setBG(10, treeBG2);
4331 setBG(11, treeBG3);
4332 setBG(12, treeBG4);
4333 setBG(1, random.Next(5));
4334 setBG(2, random.Next(6));
4335 snowBG = random.Next(8);
4336 if (snowBG == 2 && random.Next(2) == 0)
4337 {
4338 if (random.Next(2) == 0)
4339 {
4340 snowBG = 21;
4341 }
4342 else
4343 {
4344 snowBG = 22;
4345 }
4346 }
4347 if (snowBG == 3 && random.Next(2) == 0)
4348 {
4349 if (random.Next(2) == 0)
4350 {
4351 snowBG = 31;
4352 }
4353 else
4354 {
4355 snowBG = 32;
4356 }
4357 }
4358 if (snowBG == 4 && random.Next(2) == 0)
4359 {
4360 if (random.Next(2) == 0)
4361 {
4362 snowBG = 41;
4363 }
4364 else
4365 {
4366 snowBG = 42;
4367 }
4368 }
4369 setBG(3, snowBG);
4370 setBG(4, random.Next(5));
4371 setBG(5, random.Next(6));
4372 setBG(6, random.Next(5));
4373 setBG(7, random.Next(6));
4374 setBG(8, random.Next(4));
4375 setBG(9, random.Next(3));
4376 }
4377
4378 private static int RollRandomForestBGStyle(UnifiedRandom random)
4379 {
4380 int num = random.Next(11);
4381 if ((num == 1 || num == 2) && random.Next(2) == 0)
4382 {
4383 num = random.Next(11);
4384 }
4385 if (num == 0)
4386 {
4387 num = random.Next(11);
4388 }
4389 if (num == 3 && random.Next(3) == 0)
4390 {
4391 num = 31;
4392 }
4393 if (num == 5 && random.Next(2) == 0)
4394 {
4395 num = 51;
4396 }
4397 if (num == 7 && random.Next(4) == 0)
4398 {
4399 num = random.Next(71, 74);
4400 }
4401 return num;
4402 }
4403
4404 public static bool IsBackgroundConsideredTheSame(int oldBG, int newBG)
4405 {
4406 switch (oldBG)
4407 {
4408 case 3:
4409 case 31:
4410 if (newBG != 3)
4411 {
4412 return newBG == 31;
4413 }
4414 return true;
4415 case 5:
4416 case 51:
4417 if (newBG != 5)
4418 {
4419 return newBG == 51;
4420 }
4421 return true;
4422 case 7:
4423 case 71:
4424 case 72:
4425 case 73:
4426 if (newBG != 7)
4427 {
4428 if (newBG >= 71)
4429 {
4430 return newBG <= 73;
4431 }
4432 return false;
4433 }
4434 return true;
4435 default:
4436 return oldBG == newBG;
4437 }
4438 }
4439
4440 public static void RandomizeTreeStyle()
4441 {
4442 if (Main.maxTilesX == 4200)
4443 {
4444 Main.treeX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.5 - (double)Main.maxTilesX * 0.25), (int)((double)Main.maxTilesX * 0.5 + (double)Main.maxTilesX * 0.25));
4445 Main.treeStyle[0] = genRand.Next(6);
4446 Main.treeStyle[1] = genRand.Next(6);
4447 while (Main.treeStyle[1] == Main.treeStyle[0])
4448 {
4449 Main.treeStyle[1] = genRand.Next(6);
4450 }
4451 Main.treeX[1] = Main.maxTilesX;
4452 Main.treeX[2] = Main.maxTilesX;
4453 for (int i = 0; i < 2; i++)
4454 {
4455 if (Main.treeStyle[i] == 0 && genRand.Next(3) != 0)
4456 {
4457 Main.treeStyle[i] = 4;
4458 }
4459 }
4460 return;
4461 }
4462 if (Main.maxTilesX == 6400)
4463 {
4464 Main.treeX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.334 - (double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.334 + (double)Main.maxTilesX * 0.2));
4465 Main.treeX[1] = genRand.Next((int)((double)Main.maxTilesX * 0.667 - (double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.667 + (double)Main.maxTilesX * 0.2));
4466 Main.treeStyle[0] = genRand.Next(6);
4467 Main.treeStyle[1] = genRand.Next(6);
4468 Main.treeStyle[2] = genRand.Next(6);
4469 while (Main.treeStyle[1] == Main.treeStyle[0])
4470 {
4471 Main.treeStyle[1] = genRand.Next(6);
4472 }
4473 while (Main.treeStyle[2] == Main.treeStyle[0] || Main.treeStyle[2] == Main.treeStyle[1])
4474 {
4475 Main.treeStyle[2] = genRand.Next(6);
4476 }
4477 Main.treeX[2] = Main.maxTilesX;
4478 for (int j = 0; j < 3; j++)
4479 {
4480 if (Main.treeStyle[j] == 0 && genRand.Next(3) != 0)
4481 {
4482 Main.treeStyle[j] = 4;
4483 }
4484 }
4485 return;
4486 }
4487 Main.treeX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.25 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.25 + (double)Main.maxTilesX * 0.15));
4488 Main.treeX[1] = genRand.Next((int)((double)Main.maxTilesX * 0.5 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.5 + (double)Main.maxTilesX * 0.15));
4489 Main.treeX[2] = genRand.Next((int)((double)Main.maxTilesX * 0.75 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.75 + (double)Main.maxTilesX * 0.15));
4490 Main.treeStyle[0] = genRand.Next(6);
4491 Main.treeStyle[1] = genRand.Next(6);
4492 Main.treeStyle[2] = genRand.Next(6);
4493 Main.treeStyle[3] = genRand.Next(6);
4494 while (Main.treeStyle[1] == Main.treeStyle[0])
4495 {
4496 Main.treeStyle[1] = genRand.Next(6);
4497 }
4498 while (Main.treeStyle[2] == Main.treeStyle[0] || Main.treeStyle[2] == Main.treeStyle[1])
4499 {
4500 Main.treeStyle[2] = genRand.Next(6);
4501 }
4502 while (Main.treeStyle[3] == Main.treeStyle[0] || Main.treeStyle[3] == Main.treeStyle[1] || Main.treeStyle[3] == Main.treeStyle[2])
4503 {
4504 Main.treeStyle[3] = genRand.Next(6);
4505 }
4506 for (int k = 0; k < 4; k++)
4507 {
4508 if (Main.treeStyle[k] == 0 && genRand.Next(3) != 0)
4509 {
4510 Main.treeStyle[k] = 4;
4511 }
4512 }
4513 }
4514
4515 public static void RandomizeCaveBackgrounds()
4516 {
4517 int maxValue = 8;
4518 if (Main.maxTilesX == 4200)
4519 {
4520 Main.caveBackX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.5 - (double)Main.maxTilesX * 0.25), (int)((double)Main.maxTilesX * 0.5 + (double)Main.maxTilesX * 0.25));
4525 while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
4526 {
4528 }
4529 }
4530 else if (Main.maxTilesX == 6400)
4531 {
4532 Main.caveBackX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.334 - (double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.334 + (double)Main.maxTilesX * 0.2));
4533 Main.caveBackX[1] = genRand.Next((int)((double)Main.maxTilesX * 0.667 - (double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.667 + (double)Main.maxTilesX * 0.2));
4538 while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
4539 {
4541 }
4543 {
4545 }
4546 }
4547 else
4548 {
4549 Main.caveBackX[0] = genRand.Next((int)((double)Main.maxTilesX * 0.25 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.25 + (double)Main.maxTilesX * 0.15));
4550 Main.caveBackX[1] = genRand.Next((int)((double)Main.maxTilesX * 0.5 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.5 + (double)Main.maxTilesX * 0.15));
4551 Main.caveBackX[2] = genRand.Next((int)((double)Main.maxTilesX * 0.75 - (double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.75 + (double)Main.maxTilesX * 0.15));
4556 while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
4557 {
4559 }
4561 {
4563 }
4565 {
4567 }
4568 }
4569 Main.iceBackStyle = genRand.Next(4);
4570 Main.hellBackStyle = genRand.Next(3);
4571 Main.jungleBackStyle = genRand.Next(2);
4572 }
4573
4574 private static void ResetGenerator()
4575 {
4576 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
4577 //IL_0077: Unknown result type (might be due to invalid IL or missing references)
4578 GenVars.numOrePatch = 0;
4579 GenVars.numTunnels = 0;
4580 GenVars.numLakes = 0;
4581 GenVars.numMushroomBiomes = 0;
4582 GenVars.numOceanCaveTreasure = 0;
4583 GenVars.numOasis = 0;
4584 GenVars.mudWall = false;
4585 GenVars.hellChest = 0;
4586 GenVars.JungleX = 0;
4587 GenVars.numMCaves = 0;
4588 GenVars.numIslandHouses = 0;
4589 GenVars.skyIslandHouseCount = 0;
4590 GenVars.dEnteranceX = 0;
4591 GenVars.numDRooms = 0;
4592 GenVars.numDDoors = 0;
4593 GenVars.generatedShadowKey = false;
4594 GenVars.numDungeonPlatforms = 0;
4595 GenVars.numJChests = 0;
4596 GenVars.JungleItemCount = 0;
4597 GenVars.lastDungeonHall = Vector2D.Zero;
4598 }
4599
4600 public static bool mayanTrap(int x2, int y2)
4601 {
4602 int num = 1;
4603 if (genRand.Next(3) == 0)
4604 {
4605 num = 0;
4606 }
4607 int num2 = y2;
4608 while (!SolidOrSlopedTile(x2, num2))
4609 {
4610 num2++;
4611 if (num2 >= Main.maxTilesY - 300)
4612 {
4613 return false;
4614 }
4615 }
4616 if (Main.tile[x2, num2].type == 232 || Main.tile[x2, num2].type == 10)
4617 {
4618 return false;
4619 }
4620 num2--;
4621 if (Main.tile[x2, num2].liquid > 0 && Main.tile[x2, num2].lava())
4622 {
4623 return false;
4624 }
4625 if (num == -1 && genRand.Next(20) == 0)
4626 {
4627 num = 2;
4628 }
4629 else if (num == -1)
4630 {
4631 num = genRand.Next(2);
4632 }
4633 if (Main.tile[x2, num2].nactive() || Main.tile[x2 - 1, num2].nactive() || Main.tile[x2 + 1, num2].nactive() || Main.tile[x2, num2 - 1].nactive() || Main.tile[x2 - 1, num2 - 1].nactive() || Main.tile[x2 + 1, num2 - 1].nactive() || Main.tile[x2, num2 - 2].nactive() || Main.tile[x2 - 1, num2 - 2].nactive() || Main.tile[x2 + 1, num2 - 2].nactive())
4634 {
4635 return false;
4636 }
4637 if (Main.tile[x2, num2 + 1].type == 10)
4638 {
4639 return false;
4640 }
4641 if (Main.tile[x2, num2 + 1].type == 48)
4642 {
4643 return false;
4644 }
4645 if (Main.tile[x2, num2 + 1].type == 232)
4646 {
4647 return false;
4648 }
4649 switch (num)
4650 {
4651 case 0:
4652 {
4653 int num12 = x2;
4654 int num13 = num2;
4655 num13 -= genRand.Next(3);
4656 while (InWorld(num12, num13, 5) && !SolidOrSlopedTile(num12, num13))
4657 {
4658 num12--;
4659 }
4660 int num14 = num12;
4662 {
4663 }
4664 int num15 = num12;
4665 int num16 = x2 - num14;
4666 int num17 = num15 - x2;
4667 bool flag = false;
4668 bool flag2 = false;
4669 if (num16 > 5 && num16 < 50)
4670 {
4671 flag = true;
4672 }
4673 if (num17 > 5 && num17 < 50)
4674 {
4675 flag2 = true;
4676 }
4677 if (flag && !SolidOrSlopedTile(num14, num13 + 1))
4678 {
4679 flag = false;
4680 }
4681 if (flag2 && !SolidOrSlopedTile(num15, num13 + 1))
4682 {
4683 flag2 = false;
4684 }
4685 if (flag && (Main.tile[num14, num13].type == 10 || Main.tile[num14, num13].type == 48 || Main.tile[num14, num13 + 1].type == 10 || Main.tile[num14, num13 + 1].type == 48))
4686 {
4687 flag = false;
4688 }
4689 if (flag2 && (Main.tile[num15, num13].type == 10 || Main.tile[num15, num13].type == 48 || Main.tile[num15, num13 + 1].type == 10 || Main.tile[num15, num13 + 1].type == 48))
4690 {
4691 flag2 = false;
4692 }
4693 int num18 = 0;
4694 if (flag && flag2)
4695 {
4696 num18 = 1;
4697 num12 = num14;
4698 if (genRand.Next(2) == 0)
4699 {
4700 num12 = num15;
4701 num18 = -1;
4702 }
4703 }
4704 else if (flag2)
4705 {
4706 num12 = num15;
4707 num18 = -1;
4708 }
4709 else
4710 {
4711 if (!flag)
4712 {
4713 return false;
4714 }
4715 num12 = num14;
4716 num18 = 1;
4717 }
4718 if (Main.tile[num12, num13].wall != 87)
4719 {
4720 return false;
4721 }
4722 if (Main.tile[num12, num13].type == 190)
4723 {
4724 return false;
4725 }
4726 if (Main.tile[num12, num13].type == 135)
4727 {
4728 return false;
4729 }
4730 if (Main.tile[num12, num13].type == 137)
4731 {
4732 return false;
4733 }
4734 if (Main.tile[num12, num13].type == 232)
4735 {
4736 return false;
4737 }
4738 if (Main.tile[num12, num13].type == 237)
4739 {
4740 return false;
4741 }
4742 if (Main.tile[num12, num13].type == 10)
4743 {
4744 return false;
4745 }
4746 PlaceTile(x2, num2, 135, mute: true, forced: true, -1, 6);
4748 int num19 = genRand.Next(3);
4749 if (Main.tile[x2, num2].wire())
4750 {
4751 num19 = 0;
4752 }
4753 if (Main.tile[x2, num2].wire2())
4754 {
4755 num19 = 1;
4756 }
4757 if (Main.tile[x2, num2].wire3())
4758 {
4759 num19 = 2;
4760 }
4761 int num20 = Math.Abs(num12 - x2);
4762 int style2 = 1;
4763 if (num20 < 10 && genRand.Next(3) != 0)
4764 {
4765 style2 = 2;
4766 }
4767 PlaceTile(num12, num13, 137, mute: true, forced: true, -1, style2);
4768 if (num18 == 1)
4769 {
4770 Main.tile[num12, num13].frameX += 18;
4771 }
4772 int num21 = genRand.Next(5);
4773 int num22 = num13;
4774 while (num21 > 0)
4775 {
4776 num21--;
4777 num22--;
4779 {
4780 break;
4781 }
4782 PlaceTile(num12, num22, 137, mute: true, forced: true, -1, style2);
4783 if (num18 == 1)
4784 {
4785 Main.tile[num12, num22].frameX += 18;
4786 }
4787 switch (num19)
4788 {
4789 case 0:
4790 Main.tile[num12, num22].wire(wire: true);
4791 break;
4792 case 1:
4793 Main.tile[num12, num22].wire2(wire2: true);
4794 break;
4795 case 2:
4796 Main.tile[num12, num22].wire3(wire3: true);
4797 break;
4798 }
4799 }
4800 int num23 = x2;
4801 int num24 = num2;
4802 while (num23 != num12 || num24 != num13)
4803 {
4804 switch (num19)
4805 {
4806 case 0:
4807 Main.tile[num23, num24].wire(wire: true);
4808 break;
4809 case 1:
4810 Main.tile[num23, num24].wire2(wire2: true);
4811 break;
4812 case 2:
4813 Main.tile[num23, num24].wire3(wire3: true);
4814 break;
4815 }
4816 if (num23 > num12)
4817 {
4818 num23--;
4819 }
4820 if (num23 < num12)
4821 {
4822 num23++;
4823 }
4824 switch (num19)
4825 {
4826 case 0:
4827 Main.tile[num23, num24].wire(wire: true);
4828 break;
4829 case 1:
4830 Main.tile[num23, num24].wire2(wire2: true);
4831 break;
4832 case 2:
4833 Main.tile[num23, num24].wire3(wire3: true);
4834 break;
4835 }
4836 if (num24 > num13)
4837 {
4838 num24--;
4839 }
4840 if (num24 < num13)
4841 {
4842 num24++;
4843 }
4844 switch (num19)
4845 {
4846 case 0:
4847 Main.tile[num23, num24].wire(wire: true);
4848 break;
4849 case 1:
4850 Main.tile[num23, num24].wire2(wire2: true);
4851 break;
4852 case 2:
4853 Main.tile[num23, num24].wire3(wire3: true);
4854 break;
4855 }
4856 }
4857 return true;
4858 }
4859 case 1:
4860 {
4861 int num3 = x2;
4862 int num4 = num2;
4863 while (!SolidOrSlopedTile(num3, num4))
4864 {
4865 num4--;
4866 if ((double)num4 < Main.worldSurface)
4867 {
4868 return false;
4869 }
4870 }
4871 int num5 = Math.Abs(num4 - num2);
4872 if (num5 < 3)
4873 {
4874 return false;
4875 }
4876 int num6 = genRand.Next(3);
4877 if (Main.tile[x2, num2].wire())
4878 {
4879 num6 = 0;
4880 }
4881 if (Main.tile[x2, num2].wire2())
4882 {
4883 num6 = 1;
4884 }
4885 if (Main.tile[x2, num2].wire3())
4886 {
4887 num6 = 2;
4888 }
4889 int style = 3;
4890 if (num5 < 16 && genRand.Next(3) != 0)
4891 {
4892 style = 4;
4893 }
4894 if (Main.tile[num3, num4].type == 135)
4895 {
4896 return false;
4897 }
4898 if (Main.tile[num3, num4].type == 137)
4899 {
4900 return false;
4901 }
4902 if (Main.tile[num3, num4].type == 232)
4903 {
4904 return false;
4905 }
4906 if (Main.tile[num3, num4].type == 237)
4907 {
4908 return false;
4909 }
4910 if (Main.tile[num3, num4].type == 10)
4911 {
4912 return false;
4913 }
4914 if (Main.tile[num3, num4].wall != 87)
4915 {
4916 return false;
4917 }
4918 PlaceTile(x2, num2, 135, mute: true, forced: true, -1, 6);
4919 PlaceTile(num3, num4, 137, mute: true, forced: true, -1, style);
4920 for (int i = 0; i < 2; i++)
4921 {
4922 int num7 = genRand.Next(1, 5);
4923 int num8 = num3;
4924 int num9 = -1;
4925 if (i == 1)
4926 {
4927 num9 = 1;
4928 }
4929 while (num7 > 0)
4930 {
4931 num7--;
4932 num8 += num9;
4933 if (!SolidTile(num8, num4 - 1) || SolidOrSlopedTile(num8, num4 + 1))
4934 {
4935 break;
4936 }
4937 PlaceTile(num8, num4, 137, mute: true, forced: true, -1, style);
4938 switch (num6)
4939 {
4940 case 0:
4941 Main.tile[num8, num4].wire(wire: true);
4942 break;
4943 case 1:
4944 Main.tile[num8, num4].wire2(wire2: true);
4945 break;
4946 case 2:
4947 Main.tile[num8, num4].wire3(wire3: true);
4948 break;
4949 }
4950 }
4951 }
4952 int num10 = x2;
4953 int num11 = num2;
4954 while (num10 != num3 || num11 != num4)
4955 {
4956 switch (num6)
4957 {
4958 case 0:
4959 Main.tile[num10, num11].wire(wire: true);
4960 break;
4961 case 1:
4962 Main.tile[num10, num11].wire2(wire2: true);
4963 break;
4964 case 2:
4965 Main.tile[num10, num11].wire3(wire3: true);
4966 break;
4967 }
4968 if (num10 > num3)
4969 {
4970 num10--;
4971 }
4972 if (num10 < num3)
4973 {
4974 num10++;
4975 }
4976 switch (num6)
4977 {
4978 case 0:
4979 Main.tile[num10, num11].wire(wire: true);
4980 break;
4981 case 1:
4982 Main.tile[num10, num11].wire2(wire2: true);
4983 break;
4984 case 2:
4985 Main.tile[num10, num11].wire3(wire3: true);
4986 break;
4987 }
4988 if (num11 > num4)
4989 {
4990 num11--;
4991 }
4992 if (num11 < num4)
4993 {
4994 num11++;
4995 }
4996 switch (num6)
4997 {
4998 case 0:
4999 Main.tile[num10, num11].wire(wire: true);
5000 break;
5001 case 1:
5002 Main.tile[num10, num11].wire2(wire2: true);
5003 break;
5004 case 2:
5005 Main.tile[num10, num11].wire3(wire3: true);
5006 break;
5007 }
5008 }
5009 return true;
5010 }
5011 default:
5012 return false;
5013 }
5014 }
5015
5016 public static bool placeLavaTrap(int x, int y)
5017 {
5018 int num = 5;
5019 int num2 = 50;
5020 int num3 = 40;
5021 int num4 = 20;
5022 int num5 = 4;
5023 if (Main.tile[x, y].active() || Main.tile[x, y].liquid < byte.MaxValue || !Main.tile[x, y].lava())
5024 {
5025 return false;
5026 }
5027 int num6 = 0;
5028 for (int i = x - num; i <= x + num; i++)
5029 {
5030 for (int j = y - num; j <= y + num; j++)
5031 {
5032 if (Main.tile[i, j].lava() && !Main.tile[i, j].active() && Main.tile[i, j].liquid == byte.MaxValue)
5033 {
5034 num6++;
5035 }
5036 }
5037 }
5038 if (num6 < num2)
5039 {
5040 return false;
5041 }
5042 int num7 = y;
5043 while (!Main.tile[x, num7].active())
5044 {
5045 num7++;
5046 if (num7 > Main.maxTilesY - 200)
5047 {
5048 return false;
5049 }
5050 }
5051 if (!Main.tileSolid[Main.tile[x, num7].type] || Main.tileSolidTop[Main.tile[x, num7].type])
5052 {
5053 return false;
5054 }
5055 int num8 = num7;
5056 for (int k = x - num4; k <= x + num4; k++)
5057 {
5058 for (int l = num7 - num4; l <= num7 + num4; l++)
5059 {
5060 if (Main.tile[k, l].wire())
5061 {
5062 return false;
5063 }
5064 }
5065 }
5066 while (Main.tile[x, num7].active() && Main.tileSolid[Main.tile[x, num7].type] && !Main.tileSolidTop[Main.tile[x, num7].type])
5067 {
5068 num7++;
5069 if (num7 > Main.maxTilesY - 200)
5070 {
5071 return false;
5072 }
5073 }
5074 Tile tile = Main.tile[x, num7 - 1];
5075 if (Main.tileDungeon[tile.type] || tile.type == 225 || tile.type == 226)
5076 {
5077 return false;
5078 }
5079 int num9 = num7;
5080 while (!Main.tile[x, num7].active())
5081 {
5082 num7++;
5083 if (num7 > Main.maxTilesY - 200 || Main.tile[x, num7].liquid > 0)
5084 {
5085 return false;
5086 }
5087 }
5088 if (!Main.tileSolid[Main.tile[x, num7].type] || Main.tileSolidTop[Main.tile[x, num7].type] || Main.tile[x, num7].type == 162)
5089 {
5090 return false;
5091 }
5092 int num10 = num7 - 1;
5093 if (num10 - num8 > num3)
5094 {
5095 return false;
5096 }
5097 if (num10 - num9 < num5)
5098 {
5099 return false;
5100 }
5101 Main.tile[x, num7].slope(0);
5102 Main.tile[x, num7].halfBrick(halfBrick: false);
5103 PlaceTile(x, num10, 135, mute: false, forced: true, -1, 7);
5104 for (int m = num8; m <= num10; m++)
5105 {
5106 Main.tile[x, m].wire(wire: true);
5107 if (m < num9)
5108 {
5109 Main.tile[x, m].slope(0);
5110 Main.tile[x, m].halfBrick(halfBrick: false);
5111 Main.tile[x, m].actuator(actuator: true);
5112 }
5113 }
5114 return true;
5115 }
5116
5117 public static bool IsTileNearby(int x, int y, int type, int distance)
5118 {
5119 for (int i = x - distance; i <= x + distance; i++)
5120 {
5121 for (int j = y - distance; j <= y + distance; j++)
5122 {
5123 if (InWorld(i, j) && Main.tile[i, j].active() && Main.tile[i, j].type == type)
5124 {
5125 return true;
5126 }
5127 }
5128 }
5129 return false;
5130 }
5131
5132 private static bool placeTNTBarrel(int x, int y)
5133 {
5134 int num = y;
5135 while (!Main.tile[x, num].active())
5136 {
5137 num++;
5138 if (num > Main.maxTilesY - 350)
5139 {
5140 return false;
5141 }
5142 }
5143 num--;
5144 if (Main.tile[x, num].shimmer())
5145 {
5146 return false;
5147 }
5148 if (PlaceTile(x, num, 654))
5149 {
5150 return true;
5151 }
5152 return false;
5153 }
5154
5155 public static bool placeTrap(int x2, int y2, int type = -1)
5156 {
5157 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
5158 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
5159 int num = y2;
5160 if (Vector2D.Distance(new Vector2D((double)x2, (double)y2), GenVars.shimmerPosition) < 100.0)
5161 {
5162 return false;
5163 }
5164 bool flag = false;
5165 bool flag2 = false;
5166 if (noTrapsWorldGen)
5167 {
5168 Main.tileSolid[138] = false;
5169 }
5170 while (!SolidTile(x2, num))
5171 {
5172 num++;
5173 if (num > Main.maxTilesY - 10)
5174 {
5175 return false;
5176 }
5177 if (num >= Main.maxTilesY - 300)
5178 {
5179 flag2 = true;
5180 }
5181 }
5182 if (noTrapsWorldGen)
5183 {
5184 Main.tileSolid[138] = true;
5185 }
5186 num--;
5187 if (!noTrapsWorldGen && IsTileNearby(x2, num, 70, 20))
5188 {
5189 return false;
5190 }
5191 if (Main.tile[x2, num].wall == 87)
5192 {
5193 return false;
5194 }
5195 if (Main.tile[x2, num].liquid > 0 && Main.tile[x2, num].lava())
5196 {
5197 flag = true;
5198 }
5199 if (Main.remixWorld)
5200 {
5201 if (type == -1 && genRand.Next(20) == 0)
5202 {
5203 type = 2;
5204 }
5205 else if (type == -1 && (double)num < Main.rockLayer - 30.0 && genRand.Next(3) != 0)
5206 {
5207 type = 3;
5208 }
5209 else if (type == -1)
5210 {
5211 type = genRand.Next(2);
5212 }
5213 }
5214 else if (type == -1 && genRand.Next(20) == 0)
5215 {
5216 type = 2;
5217 }
5218 else if (type == -1 && num > GenVars.lavaLine + 30 && genRand.Next(6) != 0)
5219 {
5220 type = 3;
5221 }
5222 else if (type == -1)
5223 {
5224 type = genRand.Next(2);
5225 }
5226 if (!InWorld(x2, num, 3))
5227 {
5228 return false;
5229 }
5230 if (flag && type != 3)
5231 {
5232 return false;
5233 }
5234 if (flag2 && type != 3)
5235 {
5236 return false;
5237 }
5238 if (Main.tile[x2, num].nactive() || Main.tile[x2 - 1, num].nactive() || Main.tile[x2 + 1, num].nactive() || Main.tile[x2, num - 1].nactive() || Main.tile[x2 - 1, num - 1].nactive() || Main.tile[x2 + 1, num - 1].nactive() || Main.tile[x2, num - 2].nactive() || Main.tile[x2 - 1, num - 2].nactive() || Main.tile[x2 + 1, num - 2].nactive())
5239 {
5240 return false;
5241 }
5242 if (Main.tile[x2, num + 1].type == 48)
5243 {
5244 return false;
5245 }
5246 if (Main.tile[x2, num + 1].type == 232)
5247 {
5248 return false;
5249 }
5250 if (type == 1)
5251 {
5252 for (int i = x2 - 3; i <= x2 + 3; i++)
5253 {
5254 for (int j = num - 3; j <= num + 3; j++)
5255 {
5256 if (Main.tile[i, j].type == 147 || Main.tile[i, j].type == 161)
5257 {
5258 type = 0;
5259 }
5260 }
5261 }
5262 }
5263 if (noTrapsWorldGen)
5264 {
5265 Main.tileSolid[138] = false;
5266 }
5267 switch (type)
5268 {
5269 case 0:
5270 {
5271 int num20 = x2;
5272 int num21 = num;
5273 num21 -= genRand.Next(3);
5274 while (!SolidTile(num20, num21) && !Main.tileCracked[Main.tile[num20, num21].type])
5275 {
5276 num20--;
5277 if (num20 < 0)
5278 {
5279 return false;
5280 }
5281 }
5282 int num22 = num20;
5283 num20 = x2;
5284 while (!SolidTile(num20, num21) && !Main.tileCracked[Main.tile[num20, num21].type])
5285 {
5286 num20++;
5287 if (num20 > Main.maxTilesX)
5288 {
5289 return false;
5290 }
5291 }
5292 int num23 = num20;
5293 int num24 = x2 - num22;
5294 int num25 = num23 - x2;
5295 bool flag5 = false;
5296 bool flag6 = false;
5297 if (num24 > 5 && num24 < 50)
5298 {
5299 flag5 = true;
5300 }
5301 if (num25 > 5 && num25 < 50)
5302 {
5303 flag6 = true;
5304 }
5305 if (flag5 && !SolidTile(num22, num21 + 1))
5306 {
5307 flag5 = false;
5308 }
5309 if (flag6 && !SolidTile(num23, num21 + 1))
5310 {
5311 flag6 = false;
5312 }
5313 if (flag5 && (Main.tile[num22, num21].type == 10 || Main.tile[num22, num21].type == 48 || Main.tile[num22, num21 + 1].type == 10 || Main.tile[num22, num21 + 1].type == 48))
5314 {
5315 flag5 = false;
5316 }
5317 if (flag6 && (Main.tile[num23, num21].type == 10 || Main.tile[num23, num21].type == 48 || Main.tile[num23, num21 + 1].type == 10 || Main.tile[num23, num21 + 1].type == 48))
5318 {
5319 flag6 = false;
5320 }
5321 int num26 = 0;
5322 if (flag5 && flag6)
5323 {
5324 num26 = 1;
5325 num20 = num22;
5326 if (genRand.Next(2) == 0)
5327 {
5328 num20 = num23;
5329 num26 = -1;
5330 }
5331 }
5332 else if (flag6)
5333 {
5334 num20 = num23;
5335 num26 = -1;
5336 }
5337 else
5338 {
5339 if (!flag5)
5340 {
5341 trapDiag[type, 0]++;
5342 return false;
5343 }
5344 num20 = num22;
5345 num26 = 1;
5346 }
5347 if (Main.tile[num20, num21].type == 190)
5348 {
5349 trapDiag[type, 0]++;
5350 return false;
5351 }
5352 if (Main.tile[x2, num].wall > 0)
5353 {
5354 PlaceTile(x2, num, 135, mute: true, forced: true, -1, 2);
5355 }
5356 else
5357 {
5358 PlaceTile(x2, num, 135, mute: true, forced: true, -1, genRand.Next(2, 4));
5359 }
5361 PlaceTile(num20, num21, 137, mute: true, forced: true);
5362 if (num26 == 1)
5363 {
5364 Main.tile[num20, num21].frameX += 18;
5365 }
5366 int num27 = x2;
5367 int num28 = num;
5368 while (num27 != num20 || num28 != num21)
5369 {
5370 Main.tile[num27, num28].wire(wire: true);
5371 if (num27 > num20)
5372 {
5373 num27--;
5374 }
5375 if (num27 < num20)
5376 {
5377 num27++;
5378 }
5379 Main.tile[num27, num28].wire(wire: true);
5380 if (num28 > num21)
5381 {
5382 num28--;
5383 }
5384 if (num28 < num21)
5385 {
5386 num28++;
5387 }
5388 Main.tile[num27, num28].wire(wire: true);
5389 }
5390 trapDiag[type, 1]++;
5391 return true;
5392 }
5393 case 1:
5394 {
5395 if (noTrapsWorldGen)
5396 {
5397 Main.tileSolid[138] = true;
5398 }
5399 int num3 = x2;
5400 int num4 = num - 8;
5401 num3 += genRand.Next(-1, 2);
5402 if (noTrapsWorldGen)
5403 {
5404 if (IsTileNearby(num3, num4, 138, 6))
5405 {
5406 return false;
5407 }
5408 if (IsTileNearby(num3, num4, 664, 6))
5409 {
5410 return false;
5411 }
5412 }
5413 else
5414 {
5415 if (IsTileNearby(num3, num4, 138, 10))
5416 {
5417 return false;
5418 }
5419 if (IsTileNearby(num3, num4, 664, 10))
5420 {
5421 return false;
5422 }
5423 if (IsTileNearby(num3, num4, 665, 10))
5424 {
5425 return false;
5426 }
5427 }
5428 bool flag3 = true;
5429 while (flag3)
5430 {
5431 bool flag4 = true;
5432 int num5 = 0;
5433 for (int m = num3 - 2; m <= num3 + 3; m++)
5434 {
5435 for (int n = num4; n <= num4 + 3; n++)
5436 {
5437 if (!SolidTile(m, n))
5438 {
5439 flag4 = false;
5440 }
5441 if (Main.tile[m, n].active())
5442 {
5443 if (Main.tile[m, n].type == 226)
5444 {
5445 trapDiag[type, 0]++;
5446 return false;
5447 }
5448 if (Main.tile[m, n].type == 0 || Main.tile[m, n].type == 1 || Main.tile[m, n].type == 59)
5449 {
5450 num5++;
5451 }
5452 }
5453 }
5454 }
5455 num4--;
5456 if ((double)num4 < Main.worldSurface)
5457 {
5458 trapDiag[type, 0]++;
5459 return false;
5460 }
5461 if (flag4 && num5 > 2)
5462 {
5463 flag3 = false;
5464 }
5465 }
5466 if (num - num4 <= 5 || num - num4 >= 40)
5467 {
5468 trapDiag[type, 0]++;
5469 return false;
5470 }
5471 for (int num6 = num3; num6 <= num3 + 1; num6++)
5472 {
5473 for (int num7 = num4; num7 <= num; num7++)
5474 {
5475 KillTile(num6, num7);
5476 }
5477 }
5478 for (int num8 = num3 - 2; num8 <= num3 + 3; num8++)
5479 {
5480 for (int num9 = num4 - 2; num9 <= num4 + 3; num9++)
5481 {
5482 if (SolidTile(num8, num9))
5483 {
5484 Main.tile[num8, num9].type = 1;
5485 }
5486 }
5487 }
5488 if (IsTileNearby(num3, num4, 21, 4) || IsTileNearby(num3, num4, 467, 4))
5489 {
5490 trapDiag[type, 0]++;
5491 return false;
5492 }
5493 PlaceTile(x2, num, 135, mute: true, forced: true, -1, 7);
5494 PlaceTile(num3, num4 + 2, 130, mute: true);
5495 PlaceTile(num3 + 1, num4 + 2, 130, mute: true);
5496 if ((tenthAnniversaryWorldGen || noTrapsWorldGen) && genRand.Next(3) == 0)
5497 {
5498 PlaceTile(num3 + 1, num4 + 1, 664, mute: true);
5499 }
5500 else
5501 {
5502 PlaceTile(num3 + 1, num4 + 1, 138, mute: true);
5503 }
5504 num4 += 2;
5505 Main.tile[num3, num4].wire(wire: true);
5506 Main.tile[num3 + 1, num4].wire(wire: true);
5507 num4++;
5508 PlaceTile(num3, num4, 130, mute: true);
5509 PlaceTile(num3 + 1, num4, 130, mute: true);
5510 Main.tile[num3, num4].wire(wire: true);
5511 Main.tile[num3 + 1, num4].wire(wire: true);
5512 PlaceTile(num3, num4 + 1, 130, mute: true);
5513 PlaceTile(num3 + 1, num4 + 1, 130, mute: true);
5514 Main.tile[num3, num4 + 1].wire(wire: true);
5515 Main.tile[num3 + 1, num4 + 1].wire(wire: true);
5516 int num10 = x2;
5517 int num11 = num;
5518 while (num10 != num3 || num11 != num4)
5519 {
5520 Main.tile[num10, num11].wire(wire: true);
5521 if (num10 > num3)
5522 {
5523 num10--;
5524 }
5525 if (num10 < num3)
5526 {
5527 num10++;
5528 }
5529 Main.tile[num10, num11].wire(wire: true);
5530 if (num11 > num4)
5531 {
5532 num11--;
5533 }
5534 if (num11 < num4)
5535 {
5536 num11++;
5537 }
5538 Main.tile[num10, num11].wire(wire: true);
5539 }
5540 trapDiag[type, 1]++;
5541 return true;
5542 }
5543 case 2:
5544 {
5545 int num12 = genRand.Next(4, 7);
5546 int num13 = x2;
5547 num13 += genRand.Next(-1, 2);
5548 int num14 = num;
5549 for (int num15 = 0; num15 < num12; num15++)
5550 {
5551 num14++;
5552 if (!SolidTile(num13, num14))
5553 {
5554 trapDiag[type, 0]++;
5555 return false;
5556 }
5557 }
5558 for (int num16 = num13 - 2; num16 <= num13 + 2; num16++)
5559 {
5560 for (int num17 = num14 - 2; num17 <= num14 + 2; num17++)
5561 {
5562 if (!SolidTile(num16, num17))
5563 {
5564 return false;
5565 }
5566 }
5567 }
5569 Main.tile[num13, num14].active(active: true);
5570 Main.tile[num13, num14].type = 141;
5571 Main.tile[num13, num14].frameX = 0;
5572 Main.tile[num13, num14].frameY = (short)(18 * genRand.Next(2));
5573 PlaceTile(x2, num, 135, mute: true, forced: true, -1, genRand.Next(2, 4));
5574 int num18 = x2;
5575 int num19 = num;
5576 while (num18 != num13 || num19 != num14)
5577 {
5578 Main.tile[num18, num19].wire(wire: true);
5579 if (num18 > num13)
5580 {
5581 num18--;
5582 }
5583 if (num18 < num13)
5584 {
5585 num18++;
5586 }
5587 Main.tile[num18, num19].wire(wire: true);
5588 if (num19 > num14)
5589 {
5590 num19--;
5591 }
5592 if (num19 < num14)
5593 {
5594 num19++;
5595 }
5596 Main.tile[num18, num19].wire(wire: true);
5597 }
5598 trapDiag[type, 1]++;
5599 break;
5600 }
5601 case 3:
5602 {
5603 if (Main.tile[x2 + 1, num].active())
5604 {
5605 return false;
5606 }
5607 if (Main.tile[x2, num].liquid > 0 && !Main.tile[x2, num].lava())
5608 {
5609 return false;
5610 }
5612 {
5613 if (genRand.Next(3) != 0)
5614 {
5615 return false;
5616 }
5617 if (IsTileNearby(x2, num, 443, 30))
5618 {
5619 return false;
5620 }
5621 }
5622 for (int k = x2; k <= x2 + 1; k++)
5623 {
5624 int j2 = num + 1;
5625 if (!SolidTile(k, j2))
5626 {
5627 return false;
5628 }
5629 }
5630 int num2 = genRand.Next(2);
5631 for (int l = 0; l < 2; l++)
5632 {
5633 Main.tile[x2 + l, num].active(active: true);
5634 Main.tile[x2 + l, num].type = 443;
5635 Main.tile[x2 + l, num].frameX = (short)(18 * l + 36 * num2);
5636 Main.tile[x2 + l, num].frameY = 0;
5637 }
5638 return true;
5639 }
5640 }
5641 if (noTrapsWorldGen)
5642 {
5643 Main.tileSolid[138] = true;
5644 }
5645 return false;
5646 }
5647
5648 public static int countWires(int x, int y, int size)
5649 {
5650 int num = 0;
5651 for (int i = x - size; i <= x + size; i++)
5652 {
5653 for (int j = y - size; j <= y + size; j++)
5654 {
5655 if (InWorld(i, j))
5656 {
5657 if (Main.tile[i, j].wire())
5658 {
5659 num++;
5660 }
5661 if (Main.tile[i, j].wire2())
5662 {
5663 num++;
5664 }
5665 if (Main.tile[i, j].wire3())
5666 {
5667 num++;
5668 }
5669 if (Main.tile[i, j].wire4())
5670 {
5671 num++;
5672 }
5673 }
5674 }
5675 }
5676 return num;
5677 }
5678
5679 public static int countTiles(int x, int y, bool jungle = false, bool lavaOk = false)
5680 {
5681 numTileCount = 0;
5682 shroomCount = 0;
5683 lavaCount = 0;
5684 iceCount = 0;
5685 sandCount = 0;
5686 rockCount = 0;
5687 CountedTiles.Clear();
5688 nextCount(x, y, jungle, lavaOk);
5689 return numTileCount;
5690 }
5691
5692 public static void nextCount(int x, int y, bool jungle = false, bool lavaOk = false)
5693 {
5695 {
5696 return;
5697 }
5699 {
5701 }
5702 else
5703 {
5704 if (CountedTiles.ContainsKey(new Point(x, y)))
5705 {
5706 return;
5707 }
5708 if (Main.tile[x, y].wall == 244)
5709 {
5711 return;
5712 }
5713 if (Main.tile[x, y].shimmer() && Main.tile[x, y].liquid > 0)
5714 {
5716 return;
5717 }
5718 if (!jungle)
5719 {
5720 if (Main.tile[x, y].wall != 0)
5721 {
5723 return;
5724 }
5725 if (!lavaOk)
5726 {
5727 if (Main.tile[x, y].lava() && Main.tile[x, y].liquid > 0)
5728 {
5729 lavaCount++;
5731 return;
5732 }
5733 }
5734 else if (Main.tile[x, y].lava() && Main.tile[x, y].liquid > 0)
5735 {
5736 lavaCount++;
5737 }
5738 }
5739 if (Main.tile[x, y].active())
5740 {
5741 if (Main.tile[x, y].type == 70)
5742 {
5743 shroomCount++;
5744 }
5745 if (Main.tile[x, y].type == 1)
5746 {
5747 rockCount++;
5748 }
5749 if (Main.tile[x, y].type == 147 || Main.tile[x, y].type == 161)
5750 {
5751 iceCount++;
5752 }
5753 if (Main.tile[x, y].type == 53 || Main.tile[x, y].type == 396 || Main.tile[x, y].type == 397)
5754 {
5755 sandCount++;
5756 }
5757 }
5758 if (!SolidTile(x, y))
5759 {
5760 CountedTiles.Add(new Point(x, y), value: true);
5761 numTileCount++;
5762 nextCount(x - 1, y, jungle, lavaOk);
5763 nextCount(x + 1, y, jungle, lavaOk);
5764 nextCount(x, y - 1, jungle, lavaOk);
5765 nextCount(x, y + 1, jungle, lavaOk);
5766 }
5767 }
5768 }
5769
5770 public static int countDirtTiles(int x, int y)
5771 {
5772 numTileCount = 0;
5773 CountedTiles.Clear();
5774 nextDirtCount(x, y);
5775 return numTileCount;
5776 }
5777
5778 public static void nextDirtCount(int x, int y)
5779 {
5781 {
5782 return;
5783 }
5785 {
5787 }
5788 else if (!CountedTiles.ContainsKey(new Point(x, y)))
5789 {
5790 if (Main.tile[x, y].active() && (Main.tile[x, y].type == 147 || Main.tile[x, y].type == 161))
5791 {
5793 }
5794 else if (Main.tile[x, y].wall == 244 || Main.tile[x, y].wall == 83 || Main.tile[x, y].wall == 3 || Main.tile[x, y].wall == 187 || Main.tile[x, y].wall == 216)
5795 {
5797 }
5798 else if (!SolidTile(x, y) && (Main.tile[x, y].wall == 2 || Main.tile[x, y].wall == 59))
5799 {
5800 CountedTiles.Add(new Point(x, y), value: true);
5801 numTileCount++;
5802 nextDirtCount(x - 1, y);
5803 nextDirtCount(x + 1, y);
5804 nextDirtCount(x, y - 1);
5805 nextDirtCount(x, y + 1);
5806 nextDirtCount(x - 1, y - 1);
5807 nextDirtCount(x - 1, y + 1);
5808 nextDirtCount(x + 1, y - 1);
5809 nextDirtCount(x + 1, y + 1);
5810 nextDirtCount(x - 2, y);
5811 nextDirtCount(x + 2, y);
5812 }
5813 }
5814 }
5815
5816 public static bool InWorld(int x, int y, int fluff = 0)
5817 {
5819 {
5820 return false;
5821 }
5822 return true;
5823 }
5824
5825 public static void gemCave(int x, int y)
5826 {
5827 countTiles(x, y);
5828 for (int i = 0; i < 6; i++)
5829 {
5830 gem[i] = false;
5831 }
5832 gem[genRand.Next(6)] = true;
5833 for (int j = 0; j < 6; j++)
5834 {
5835 if (genRand.Next(6) == 0)
5836 {
5837 gem[j] = true;
5838 }
5839 }
5840 Spread.Gem(x, y);
5841 }
5842
5843 public static int randGem()
5844 {
5845 int num = genRand.Next(6);
5846 while (!gem[num])
5847 {
5848 num = genRand.Next(6);
5849 }
5850 return num;
5851 }
5852
5853 public static ushort randGemTile()
5854 {
5855 if (genRand.Next(20) != 0)
5856 {
5857 return 1;
5858 }
5859 return (ushort)randGem() switch
5860 {
5861 0 => 67,
5862 1 => 66,
5863 2 => 63,
5864 3 => 65,
5865 4 => 64,
5866 _ => 68,
5867 };
5868 }
5869
5870 public static void randMoss(bool justNeon = false)
5871 {
5872 neonMossType = genRand.NextFromList(new ushort[4] { 539, 536, 534, 625 });
5873 if (!justNeon)
5874 {
5875 mossType[0] = genRand.Next(5);
5876 mossType[1] = genRand.Next(5);
5877 while (mossType[1] == mossType[0])
5878 {
5879 mossType[1] = genRand.Next(5);
5880 }
5881 mossType[2] = genRand.Next(5);
5882 while (mossType[2] == mossType[0] || mossType[2] == mossType[1])
5883 {
5884 mossType[2] = genRand.Next(5);
5885 }
5886 }
5887 }
5888
5889 public static void neonMossBiome(int i, int j, int maxY = 99999)
5890 {
5891 //IL_005c: Unknown result type (might be due to invalid IL or missing references)
5892 //IL_007f: Unknown result type (might be due to invalid IL or missing references)
5893 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
5894 //IL_008e: Unknown result type (might be due to invalid IL or missing references)
5895 //IL_010f: Unknown result type (might be due to invalid IL or missing references)
5896 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
5897 //IL_0125: Unknown result type (might be due to invalid IL or missing references)
5898 //IL_0130: Unknown result type (might be due to invalid IL or missing references)
5899 //IL_01c1: Unknown result type (might be due to invalid IL or missing references)
5900 //IL_018c: Unknown result type (might be due to invalid IL or missing references)
5901 //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
5902 //IL_0328: Unknown result type (might be due to invalid IL or missing references)
5903 //IL_0329: Unknown result type (might be due to invalid IL or missing references)
5904 //IL_032a: Unknown result type (might be due to invalid IL or missing references)
5905 //IL_032f: Unknown result type (might be due to invalid IL or missing references)
5906 //IL_0384: Unknown result type (might be due to invalid IL or missing references)
5907 //IL_03a8: Unknown result type (might be due to invalid IL or missing references)
5908 //IL_024c: Unknown result type (might be due to invalid IL or missing references)
5909 //IL_025b: Unknown result type (might be due to invalid IL or missing references)
5910 //IL_0267: Unknown result type (might be due to invalid IL or missing references)
5911 //IL_026c: Unknown result type (might be due to invalid IL or missing references)
5912 Vector2D val = default(Vector2D);
5913 val.X = i;
5914 val.Y = j;
5915 Vector2D val2 = default(Vector2D);
5916 val2.X = genRand.NextDouble() * 4.0 - 2.0;
5917 val2.Y = genRand.NextDouble() * 4.0 - 2.0;
5918 if (val2.X == 0.0)
5919 {
5920 val2.X = 1.0;
5921 }
5922 while (((Vector2D)(ref val2)).Length() < 4.0)
5923 {
5924 val2 *= 1.5;
5925 }
5926 double num = genRand.Next(60, 80);
5927 double num2 = genRand.Next(30, 40);
5928 double num3 = (double)Main.maxTilesX / 4200.0;
5929 if (getGoodWorldGen)
5930 {
5931 num3 *= 1.5;
5932 }
5933 num *= num3;
5934 num2 *= num3;
5935 while (num2 > 0.0)
5936 {
5937 num *= 0.98;
5938 num2 -= 1.0;
5939 int num4 = (int)(val.X - num);
5940 int num5 = (int)(val.X + num);
5941 int num6 = (int)(val.Y - num);
5942 int num7 = (int)(val.Y + num);
5943 if (num4 < 1)
5944 {
5945 num4 = 1;
5946 }
5947 if (num5 > Main.maxTilesX - 1)
5948 {
5949 num5 = Main.maxTilesX - 1;
5950 }
5951 if (num6 < 1)
5952 {
5953 num6 = 1;
5954 }
5955 if (num7 > Main.maxTilesY - 1)
5956 {
5957 num7 = Main.maxTilesY - 1;
5958 }
5959 if (Main.remixWorld)
5960 {
5961 if ((double)num6 < Main.worldSurface)
5962 {
5963 num6 = (int)Main.worldSurface;
5964 if (val2.Y < 5.0)
5965 {
5966 val2.Y = 5.0;
5967 }
5968 }
5969 }
5970 else if ((double)num6 < Main.rockLayer)
5971 {
5972 num6 = (int)Main.rockLayer;
5973 if (val2.Y < 5.0)
5974 {
5975 val2.Y = 5.0;
5976 }
5977 }
5978 if (num7 > maxY)
5979 {
5980 num7 = maxY;
5981 if (val2.Y > -5.0)
5982 {
5983 val2.Y = -5.0;
5984 }
5985 }
5986 double num8 = num * (1.0 + genRand.NextDouble() * 0.4 - 0.2);
5987 for (int k = num4; k < num5; k++)
5988 {
5989 for (int l = num6; l < num7; l++)
5990 {
5991 Vector2D val3 = new Vector2D(Math.Abs((double)k - val.X), Math.Abs((double)l - val.Y));
5992 if (((Vector2D)(ref val3)).Length() < num8 * 0.8 && TileType(k, l) == 1 && (!Main.tile[k - 1, l].active() || !Main.tile[k + 1, l].active() || !Main.tile[k, l - 1].active() || !Main.tile[k, l + 1].active()))
5993 {
5994 SpreadGrass(k - 1, l, 1, neonMossType);
5995 }
5996 }
5997 }
5998 val += val2;
5999 val2.X += genRand.NextDouble() * 4.0 - 2.0;
6000 val2.Y += genRand.NextDouble() * 4.0 - 2.0;
6001 val2.Y = Utils.Clamp(val2.Y, -10.0, 10.0);
6002 val2.X = Utils.Clamp(val2.X, -10.0, 10.0);
6003 }
6004 }
6005
6006 public static void setMoss(int x, int y)
6007 {
6008 int num = 0;
6009 num = ((!((double)x < (double)Main.maxTilesX * 0.334)) ? (((double)x < (double)Main.maxTilesX * 0.667) ? 1 : 2) : 0);
6010 GenVars.mossWall = (ushort)(54 + mossType[num]);
6011 GenVars.mossTile = (ushort)(179 + mossType[num]);
6012 }
6013
6015 {
6016 int num = Math.Max(worldCoordsArea.Left, 0);
6017 int num2 = Math.Min(worldCoordsArea.Right, Main.maxTilesX);
6018 int num3 = 0;
6019 for (int i = num; i <= num2; i++)
6020 {
6021 if (i >= 0 && i < Main.maxTilesX)
6022 {
6024 }
6025 }
6026 }
6027
6028 private static int FillWallHolesInColumn(int x, int startY, int endY)
6029 {
6030 int num = 0;
6031 x = Utils.Clamp(x, 2, Main.maxTilesX - 1 - 2);
6032 startY = Math.Max(startY, 2);
6033 endY = Math.Min(endY, Main.maxTilesY - 2);
6034 bool flag = false;
6035 for (int i = startY; i < endY; i++)
6036 {
6037 if (Main.tile[x, i].wall == 0)
6038 {
6039 if (flag)
6040 {
6041 flag = false;
6042 if (FillWallHolesInSpot(x, i, 150))
6043 {
6044 num++;
6045 }
6046 }
6047 }
6048 else
6049 {
6050 flag = true;
6051 }
6052 }
6053 return num;
6054 }
6055
6056 private static bool FillWallHolesInSpot(int originX, int originY, int maxWallsThreshold)
6057 {
6058 if (!InWorld(originX, originY, 2))
6059 {
6060 return false;
6061 }
6066 list2.Add(new Point(originX, originY));
6067 while (list2.Count > 0)
6068 {
6069 list.Clear();
6071 list2.Clear();
6072 while (list.Count > 0)
6073 {
6075 {
6076 return false;
6077 }
6078 Point item = list[0];
6079 if (hashSet.Contains(item))
6080 {
6081 list.Remove(item);
6082 continue;
6083 }
6084 if (!InWorld(item.X, item.Y, 1))
6085 {
6086 list.Remove(item);
6087 continue;
6088 }
6089 hashSet.Add(item);
6090 list.Remove(item);
6091 Tile tile = Main.tile[item.X, item.Y];
6092 if (tile.wall != 0)
6093 {
6094 if (dictionary.ContainsKey(tile.wall))
6095 {
6096 dictionary[tile.wall] = dictionary[tile.wall] + 1;
6097 }
6098 else
6099 {
6100 dictionary[tile.wall] = 1;
6101 }
6102 continue;
6103 }
6104 bool flag = false;
6105 if (!flag)
6106 {
6107 int y = item.Y;
6108 for (int i = item.X - 1; i <= item.X + 1; i++)
6109 {
6110 if (!Main.tile[i, y].active())
6111 {
6112 flag = true;
6113 break;
6114 }
6115 }
6116 }
6117 if (!flag)
6118 {
6119 int x = item.X;
6120 for (int j = item.Y - 1; j <= item.Y + 1; j++)
6121 {
6122 if (!Main.tile[x, j].active())
6123 {
6124 flag = true;
6125 break;
6126 }
6127 }
6128 }
6129 if (flag)
6130 {
6131 Point item2 = new Point(item.X - 1, item.Y);
6132 if (!hashSet.Contains(item2))
6133 {
6134 list2.Add(item2);
6135 }
6136 item2 = new Point(item.X + 1, item.Y);
6137 if (!hashSet.Contains(item2))
6138 {
6139 list2.Add(item2);
6140 }
6141 item2 = new Point(item.X, item.Y - 1);
6142 if (!hashSet.Contains(item2))
6143 {
6144 list2.Add(item2);
6145 }
6146 item2 = new Point(item.X, item.Y + 1);
6147 if (!hashSet.Contains(item2))
6148 {
6149 list2.Add(item2);
6150 }
6151 }
6152 }
6153 }
6154 if (hashSet.Count == 1)
6155 {
6156 return false;
6157 }
6158 ushort wall = 0;
6159 int num = -1;
6161 {
6162 if (item3.Value > num)
6163 {
6164 wall = item3.Key;
6165 num = item3.Value;
6166 }
6167 }
6168 if (num == -1)
6169 {
6170 wall = 2;
6171 }
6172 foreach (Point item4 in hashSet)
6173 {
6174 Tile tile2 = Main.tile[item4.X, item4.Y];
6175 if (tile2.wall == 0)
6176 {
6177 tile2.wall = wall;
6178 }
6179 }
6180 return true;
6181 }
6182
6183 public static void tileCountAndDestroy()
6184 {
6185 for (int i = 10; i < Main.maxTilesX - 10; i++)
6186 {
6187 for (int j = 10; j < Main.maxTilesY - 10; j++)
6188 {
6189 if (Main.tile[i, j].active() && tileCounter(i, j) < tileCounterMax)
6190 {
6192 }
6193 }
6194 }
6195 }
6196
6197 public static int tileCounter(int x, int y)
6198 {
6199 tileCounterNum = 0;
6200 tileCounterNext(x, y);
6201 return tileCounterNum;
6202 }
6203
6204 public static void tileCounterNext(int x, int y)
6205 {
6207 {
6208 return;
6209 }
6210 for (int i = 0; i < tileCounterNum; i++)
6211 {
6212 if (tileCounterX[i] == x && tileCounterY[i] == y)
6213 {
6214 return;
6215 }
6216 }
6220 tileCounterNext(x - 1, y);
6221 tileCounterNext(x + 1, y);
6222 tileCounterNext(x, y - 1);
6223 tileCounterNext(x, y + 1);
6224 }
6225
6226 public static void tileCounterKill()
6227 {
6228 for (int i = 0; i < tileCounterNum; i++)
6229 {
6230 int num = tileCounterX[i];
6231 int num2 = tileCounterY[i];
6232 Main.tile[num, num2].active(active: false);
6233 }
6234 }
6235
6236 private static void AddGenerationPass(string name, WorldGenLegacyMethod method)
6237 {
6238 _generator.Append(new PassLegacy(name, method));
6239 }
6240
6241 private static void AddGenerationPass(GenPass pass)
6242 {
6243 _generator.Append(pass);
6244 }
6245
6246 private static void AddGenerationPass(string name, double weight, WorldGenLegacyMethod method)
6247 {
6248 _generator.Append(new PassLegacy(name, method, weight));
6249 }
6250
6251 public static bool checkUnderground(int x, int y)
6252 {
6253 try
6254 {
6255 int num = 120;
6256 int num2 = 80;
6257 int num3 = 3;
6258 if ((double)y > Main.worldSurface + (double)num2)
6259 {
6260 return true;
6261 }
6262 if ((double)y < Main.worldSurface / 2.0)
6263 {
6264 return false;
6265 }
6266 int num4 = y - num2;
6267 int num5 = x - num / 2;
6268 int num6 = 0;
6269 if (num5 < 0)
6270 {
6271 num5 = 0;
6272 }
6273 if (num5 >= Main.maxTilesX - num)
6274 {
6275 num5 = Main.maxTilesX - num - 1;
6276 }
6277 for (int i = num5; i < num5 + num; i++)
6278 {
6279 for (int j = num4; j < num4 + num3; j++)
6280 {
6281 if (SolidTile(i, j) || Main.tile[x, y].wall > 0)
6282 {
6283 num6++;
6284 }
6285 }
6286 }
6287 if ((double)num6 >= (double)(num * num3) * 0.8)
6288 {
6289 return true;
6290 }
6291 }
6292 catch
6293 {
6294 }
6295 return false;
6296 }
6297
6298 public static int GetNextJungleChestItem()
6299 {
6300 int result = 211;
6301 switch (GenVars.JungleItemCount % 4)
6302 {
6303 case 0:
6304 result = 211;
6305 break;
6306 case 1:
6307 result = 212;
6308 break;
6309 case 2:
6310 result = 213;
6311 break;
6312 case 3:
6313 result = 964;
6314 break;
6315 }
6316 if (genRand.Next(50) == 0)
6317 {
6318 result = 753;
6319 }
6320 else if (genRand.Next(15) == 0)
6321 {
6322 result = 2292;
6323 }
6324 else if (genRand.Next(20) == 0)
6325 {
6326 result = 3017;
6327 }
6329 return result;
6330 }
6331
6332 private static void ScanTileColumnAndRemoveClumps(int x)
6333 {
6334 int num = 0;
6335 int y = 0;
6336 for (int i = 10; i < Main.maxTilesY - 10; i++)
6337 {
6338 if (Main.tile[x, i].active() && Main.tileSolid[Main.tile[x, i].type] && TileID.Sets.CanBeClearedDuringGeneration[Main.tile[x, i].type])
6339 {
6340 if (num == 0)
6341 {
6342 y = i;
6343 }
6344 num++;
6345 continue;
6346 }
6347 if (num > 0 && num < tileCounterMax)
6348 {
6350 if (tileCounter(x, y) < tileCounterMax)
6351 {
6354 }
6355 }
6356 num = 0;
6357 }
6358 }
6359
6360 public static void OreHelper(int X, int Y)
6361 {
6362 for (int i = X - 1; i <= X + 1; i++)
6363 {
6364 for (int j = Y - 1; j <= Y + 1; j++)
6365 {
6366 if (Main.tile[i, j].type == 1 || Main.tile[i, j].type == 40)
6367 {
6368 Main.tile[i, j].type = 0;
6369 }
6370 }
6371 }
6372 }
6373
6374 public static bool StonePatch(int X, int Y)
6375 {
6376 //IL_042f: Unknown result type (might be due to invalid IL or missing references)
6377 //IL_0430: Unknown result type (might be due to invalid IL or missing references)
6378 //IL_0431: Unknown result type (might be due to invalid IL or missing references)
6379 //IL_0436: Unknown result type (might be due to invalid IL or missing references)
6380 //IL_0489: Unknown result type (might be due to invalid IL or missing references)
6381 //IL_04a7: Unknown result type (might be due to invalid IL or missing references)
6382 //IL_0291: Unknown result type (might be due to invalid IL or missing references)
6383 //IL_0298: Unknown result type (might be due to invalid IL or missing references)
6384 //IL_029d: Unknown result type (might be due to invalid IL or missing references)
6385 //IL_02a2: Unknown result type (might be due to invalid IL or missing references)
6386 int num = Y;
6387 while (!SolidTile(X, num))
6388 {
6389 num++;
6390 if ((double)num > Main.worldSurface)
6391 {
6392 return false;
6393 }
6394 }
6395 if (!TileID.Sets.Conversion.Grass[Main.tile[X, num].type] || !TileID.Sets.Conversion.Grass[Main.tile[X - 1, num].type] || !TileID.Sets.Conversion.Grass[Main.tile[X + 1, num].type])
6396 {
6397 return false;
6398 }
6399 if (Main.tile[X, num].wall > 0)
6400 {
6401 return false;
6402 }
6403 for (int i = X - 10; i <= X + 10; i++)
6404 {
6405 for (int j = num + 7; j <= num + 30; j++)
6406 {
6407 if (!Main.tile[i, j].active() || Main.tileDungeon[Main.tile[i, j].type] || TileID.Sets.Clouds[Main.tile[i, j].type] || TileID.Sets.Conversion.Sand[Main.tile[i, j].type] || Main.tile[i, j].wall == 0 || Main.tile[i, j].type == 199 || Main.tile[i, j].type == 23)
6408 {
6409 return false;
6410 }
6411 }
6412 }
6413 Vector2D val = default(Vector2D);
6414 ((Vector2D)(ref val))._002Ector((double)X, (double)num);
6415 Vector2D val2 = default(Vector2D);
6416 val2.X = genRand.NextDouble() * 0.6 - 0.3;
6417 val2.Y = genRand.NextDouble() * 0.5 + 0.5;
6418 double num2 = genRand.Next(13, 18);
6419 int num3 = genRand.Next(13, 19);
6420 if (genRand.Next(3) == 0)
6421 {
6422 num2 += (double)genRand.Next(3);
6423 }
6424 if (genRand.Next(3) == 0)
6425 {
6426 num3 += genRand.Next(3);
6427 }
6428 while (num3 > 0)
6429 {
6430 num3--;
6431 for (int k = X - (int)num2 * 4; (double)k <= (double)X + num2 * 4.0; k++)
6432 {
6433 for (int l = num - (int)num2 * 4; (double)l <= (double)num + num2 * 4.0; l++)
6434 {
6435 double num4 = num2 * (0.7 + genRand.NextDouble() * 0.6) * 0.3;
6436 if (genRand.Next(8) == 0)
6437 {
6438 num4 *= 2.0;
6439 }
6440 Vector2D val3 = val - new Vector2D((double)k, (double)l);
6441 if (((Vector2D)(ref val3)).Length() < num4 * 2.0 && !Main.tile[k, l].active() && Main.tile[k, l + 1].active() && Main.tile[k, l + 1].type == 1 && genRand.Next(7) == 0 && SolidTile(k - 1, l + 1) && SolidTile(k + 1, l + 1))
6442 {
6443 if (genRand.Next(3) != 0)
6444 {
6445 PlaceTile(k, l, 186, mute: true, forced: false, -1, genRand.Next(7, 13));
6446 }
6447 if (genRand.Next(3) != 0)
6448 {
6449 PlaceSmallPile(k, l, genRand.Next(6), 1, 185);
6450 }
6451 PlaceSmallPile(k, l, genRand.Next(6), 0, 185);
6452 }
6453 if (((Vector2D)(ref val3)).Length() < num4)
6454 {
6455 if (Main.tileSolid[Main.tile[k, l].type])
6456 {
6457 Main.tile[k, l].type = 1;
6458 }
6459 if (!gen)
6460 {
6462 }
6463 }
6464 }
6465 }
6466 val += val2;
6467 val2.X += genRand.NextDouble() * 0.2 - 0.1;
6468 val2.Y += genRand.NextDouble() * 0.2 - 0.1;
6469 Utils.Clamp(val2.X, -0.3, 0.3);
6470 Utils.Clamp(val2.Y, 0.5, 1.0);
6471 }
6472 return true;
6473 }
6474
6475 public static bool ShellPile(int X, int Y)
6476 {
6477 //IL_03ef: Unknown result type (might be due to invalid IL or missing references)
6478 //IL_03f0: Unknown result type (might be due to invalid IL or missing references)
6479 //IL_03f1: Unknown result type (might be due to invalid IL or missing references)
6480 //IL_03f6: Unknown result type (might be due to invalid IL or missing references)
6481 //IL_0449: Unknown result type (might be due to invalid IL or missing references)
6482 //IL_0467: Unknown result type (might be due to invalid IL or missing references)
6483 //IL_0123: Unknown result type (might be due to invalid IL or missing references)
6484 //IL_012a: Unknown result type (might be due to invalid IL or missing references)
6485 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
6486 //IL_0134: Unknown result type (might be due to invalid IL or missing references)
6487 int num = Y;
6488 while (!SolidTile(X, num))
6489 {
6490 num++;
6491 if ((double)num > Main.worldSurface)
6492 {
6493 return false;
6494 }
6495 }
6496 if (Main.tile[X, num].type != 53)
6497 {
6498 return false;
6499 }
6500 if (Main.tile[X, num].wall > 0)
6501 {
6502 return false;
6503 }
6504 num--;
6505 Vector2D val = default(Vector2D);
6506 ((Vector2D)(ref val))._002Ector((double)X, (double)num);
6507 Vector2D val2 = default(Vector2D);
6508 val2.X = genRand.NextDouble() * 0.6 - 0.3;
6509 val2.Y = genRand.NextDouble() * 0.5 + 0.5;
6510 double num2 = genRand.Next(2, 4);
6511 if (genRand.Next(10) == 0)
6512 {
6513 num2 += 1.0;
6514 }
6515 int num3 = genRand.Next(3, 6);
6516 while (num3 > 0)
6517 {
6518 num3--;
6519 for (int i = X - (int)num2 * 4; (double)i <= (double)X + num2 * 4.0; i++)
6520 {
6521 int num4 = num + (int)num2 * 4;
6522 while ((double)num4 > (double)num - num2 * 4.0)
6523 {
6524 double num5 = num2 * (double)genRand.Next(70, 91) * 0.01;
6525 Vector2D val3 = val - new Vector2D((double)i, (double)num4);
6526 val3.X *= 0.6;
6527 if (((Vector2D)(ref val3)).Length() < num5)
6528 {
6529 if (num4 <= num + 1 || genRand.Next(6) == 0)
6530 {
6531 Main.tile[i, num4].type = 495;
6532 Main.tile[i, num4].active(active: true);
6533 Main.tile[i, num4].halfBrick(halfBrick: false);
6534 Main.tile[i, num4].slope(0);
6535 if (!Main.tile[i, num4 + 1].active())
6536 {
6537 Main.tile[i, num4 + 1].type = 495;
6538 Main.tile[i, num4 + 1].active(active: true);
6539 Main.tile[i, num4 + 1].halfBrick(halfBrick: false);
6540 Main.tile[i, num4 + 1].slope(0);
6541 if (!Main.tile[i, num4 + 2].active())
6542 {
6543 Main.tile[i, num4 + 2].type = 53;
6544 Main.tile[i, num4 + 2].active(active: true);
6545 Main.tile[i, num4 + 2].halfBrick(halfBrick: false);
6546 Main.tile[i, num4 + 2].slope(0);
6547 if (!Main.tile[i, num4 + 3].active())
6548 {
6549 Main.tile[i, num4 + 3].type = 397;
6550 Main.tile[i, num4 + 3].active(active: true);
6551 Main.tile[i, num4 + 3].halfBrick(halfBrick: false);
6552 Main.tile[i, num4 + 3].slope(0);
6553 }
6554 }
6555 }
6556 if (!gen)
6557 {
6559 }
6560 }
6561 else if (Main.tile[i, num4].type != 495)
6562 {
6563 Main.tile[i, num4].active(active: true);
6564 Main.tile[i, num4].halfBrick(halfBrick: false);
6565 Main.tile[i, num4].slope(0);
6566 Main.tile[i, num4].type = 53;
6567 if (!gen)
6568 {
6570 }
6571 }
6572 }
6573 num4--;
6574 }
6575 }
6576 val += val2;
6577 val2.X += genRand.NextDouble() * 0.2 - 0.1;
6578 val2.Y += genRand.NextDouble() * 0.2 - 0.1;
6579 Utils.Clamp(val2.X, -0.3, 0.3);
6580 Utils.Clamp(val2.Y, 0.5, 1.0);
6581 }
6582 return true;
6583 }
6584
6585 public static bool MarblePileWithStatues(int X, int Y)
6586 {
6587 //IL_0384: Unknown result type (might be due to invalid IL or missing references)
6588 //IL_0386: Unknown result type (might be due to invalid IL or missing references)
6589 //IL_0388: Unknown result type (might be due to invalid IL or missing references)
6590 //IL_038d: Unknown result type (might be due to invalid IL or missing references)
6591 //IL_03eb: Unknown result type (might be due to invalid IL or missing references)
6592 //IL_040a: Unknown result type (might be due to invalid IL or missing references)
6593 //IL_021b: Unknown result type (might be due to invalid IL or missing references)
6594 //IL_0223: Unknown result type (might be due to invalid IL or missing references)
6595 //IL_0228: Unknown result type (might be due to invalid IL or missing references)
6596 //IL_022d: Unknown result type (might be due to invalid IL or missing references)
6597 //IL_0469: Unknown result type (might be due to invalid IL or missing references)
6598 int num = Y;
6599 while (!SolidTile(X, num))
6600 {
6601 num++;
6602 if ((double)num > Main.worldSurface)
6603 {
6604 return false;
6605 }
6606 }
6607 if (Main.tile[X, num].type != 0 && Main.tile[X, num].type != 2)
6608 {
6609 return false;
6610 }
6611 if (Main.tile[X, num].wall > 0)
6612 {
6613 return false;
6614 }
6615 int num2 = 130;
6616 int num3 = 60;
6617 int num4 = (int)MathHelper.Clamp(X - num2, 30f, Main.maxTilesX - 30);
6618 int num5 = (int)MathHelper.Clamp(X + num2, 30f, Main.maxTilesX - 30);
6619 int num6 = (int)MathHelper.Clamp(num - num3, 30f, Main.maxTilesY - 30);
6620 int num7 = (int)MathHelper.Clamp(num + num3, 30f, Main.maxTilesY - 30);
6621 for (int i = num4; i <= num5; i++)
6622 {
6623 for (int j = num6; j <= num7; j++)
6624 {
6625 if (Main.tile[i, j].active() && (Main.tile[i, j].type == 367 || Main.tile[i, j].type == 191))
6626 {
6627 return false;
6628 }
6629 }
6630 }
6631 num--;
6632 Vector2D val = default(Vector2D);
6633 ((Vector2D)(ref val))._002Ector((double)X, (double)num);
6634 Vector2D val2 = default(Vector2D);
6635 val2.X = genRand.NextDouble() * 0.6 - 0.3;
6636 val2.Y = genRand.NextDouble() * 0.5 + 0.5;
6637 double num8 = genRand.Next(2, 4);
6638 if (genRand.Next(10) == 0)
6639 {
6640 num8 += 1.0;
6641 }
6642 int num9 = genRand.Next(3, 6);
6643 while (num9 > 0)
6644 {
6645 num9--;
6646 for (int k = X - (int)num8 * 5; (double)k <= (double)X + num8 * 5.0; k++)
6647 {
6648 int num10 = num + (int)num8 * 3;
6649 while ((double)num10 > (double)num - num8 * 3.0)
6650 {
6651 double num11 = num8 * (double)genRand.Next(70, 91) * 0.01 * 1.2;
6652 Vector2D val3 = val - new Vector2D((double)k, (double)num10);
6653 if (((Vector2D)(ref val3)).Length() > 30.0)
6654 {
6655 ((Vector2D)(ref val))._002Ector((double)X, (double)num);
6656 val2.X = genRand.NextDouble() * 0.6 - 0.3;
6657 val2.Y = genRand.NextDouble() * 0.5 + 0.5;
6658 }
6659 else
6660 {
6661 val3.X *= 0.25;
6662 val3.Y *= 0.8;
6663 if (((Vector2D)(ref val3)).Length() < num11 && Main.tile[k, num10].active())
6664 {
6665 Main.tile[k, num10].active(active: true);
6666 Main.tile[k, num10].halfBrick(halfBrick: false);
6667 Main.tile[k, num10].slope(0);
6668 Main.tile[k, num10].type = 367;
6669 if (!gen)
6670 {
6672 }
6673 }
6674 }
6675 num10--;
6676 }
6677 }
6678 val += val2;
6679 val2.X += genRand.NextDouble() * 0.2 - 0.1;
6680 val2.Y += (0.1 + genRand.NextDouble() * 0.1) * 0.8;
6681 Utils.Clamp(val2.X, -0.3, 0.3);
6682 Utils.Clamp(val2.Y, 0.5, 1.0);
6683 }
6684 int num12 = 0;
6685 for (int l = X - (int)num8 * 5; (double)l <= (double)X + num8 * 5.0; l++)
6686 {
6687 if (num12 >= 3)
6688 {
6689 break;
6690 }
6691 if (l % 2 != 1 && (num12 <= 0 || genRand.Next(5) == 0))
6692 {
6693 int num13 = (int)val.Y - 20;
6694 Tile tile = Main.tile[l, num13];
6695 while (tile != null && !tile.active())
6696 {
6697 num13++;
6698 tile = Main.tile[l, num13];
6699 }
6700 if (tile != null && tile.type == 367 && !Main.tile[l, num13 - 1].active() && Statue(l, num13 - 1, 26))
6701 {
6702 num12++;
6703 }
6704 }
6705 }
6706 return true;
6707 }
6708
6709 public static bool Statue(int x, int y, byte paint)
6710 {
6711 int num = genRand.Next(2, GenVars.statueList.Length);
6712 int x2 = GenVars.statueList[num].X;
6713 int y2 = GenVars.statueList[num].Y;
6714 while (!Main.tile[x, y].active())
6715 {
6716 y++;
6717 if (y >= Main.maxTilesY)
6718 {
6719 break;
6720 }
6721 }
6722 if (y >= Main.maxTilesY)
6723 {
6724 return false;
6725 }
6726 y--;
6727 if (PlaceTile(x, y, x2, mute: true, forced: true, -1, y2))
6728 {
6729 for (int i = 0; i < 2; i++)
6730 {
6731 for (int j = 0; j < 3; j++)
6732 {
6733 Main.tile[x + i, y + j - 2].color(paint);
6734 }
6735 }
6736 return true;
6737 }
6738 return false;
6739 }
6740
6741 public static bool OrePatch(int X, int Y)
6742 {
6743 //IL_04b1: Unknown result type (might be due to invalid IL or missing references)
6744 //IL_04b3: Unknown result type (might be due to invalid IL or missing references)
6745 //IL_04b5: Unknown result type (might be due to invalid IL or missing references)
6746 //IL_04ba: Unknown result type (might be due to invalid IL or missing references)
6747 //IL_050e: Unknown result type (might be due to invalid IL or missing references)
6748 //IL_052d: Unknown result type (might be due to invalid IL or missing references)
6749 //IL_03e6: Unknown result type (might be due to invalid IL or missing references)
6750 //IL_03ee: Unknown result type (might be due to invalid IL or missing references)
6751 //IL_03f3: Unknown result type (might be due to invalid IL or missing references)
6752 //IL_03f8: Unknown result type (might be due to invalid IL or missing references)
6753 ushort type = (ushort)SavedOreTiers.Copper;
6754 if (genRand.Next(3) == 0)
6755 {
6756 type = (ushort)SavedOreTiers.Iron;
6757 }
6758 int num = X;
6759 int num2 = Y;
6760 while (!SolidTile(num, num2))
6761 {
6762 num2++;
6763 if ((double)num2 > Main.worldSurface)
6764 {
6765 return false;
6766 }
6767 }
6768 if (!TileID.Sets.Conversion.Grass[Main.tile[num, num2].type] || !TileID.Sets.Conversion.Grass[Main.tile[num - 1, num2].type] || !TileID.Sets.Conversion.Grass[Main.tile[num + 1, num2].type])
6769 {
6770 return false;
6771 }
6772 if (Main.tile[num, num2].wall > 0)
6773 {
6774 return false;
6775 }
6776 for (int i = num - 10; i <= num + 10; i++)
6777 {
6778 for (int j = num2 + 7; j <= num2 + 30; j++)
6779 {
6780 if (!Main.tile[i, j].active() || Main.tileDungeon[Main.tile[i, j].type] || TileID.Sets.Clouds[Main.tile[i, j].type] || TileID.Sets.Conversion.Sand[Main.tile[i, j].type] || Main.tile[i, j].wall == 0)
6781 {
6782 return false;
6783 }
6784 }
6785 }
6786 num2 += genRand.Next(2);
6787 Main.tile[num, num2].type = type;
6788 Main.tile[num, num2].active(active: true);
6789 OreHelper(num, num2);
6790 if (!gen)
6791 {
6792 SquareTileFrame(num, num2);
6793 }
6794 int num3 = num2;
6795 while (num2 < num3 + genRand.Next(8, 13))
6796 {
6797 num += genRand.Next(-1, 2);
6798 num2 += genRand.Next(1, 3);
6799 if (genRand.Next(3) == 0)
6800 {
6801 num2++;
6802 }
6803 Main.tile[num, num2].type = type;
6804 Main.tile[num, num2].active(active: true);
6805 OreHelper(num, num2);
6806 if (!gen)
6807 {
6808 SquareTileFrame(num, num2);
6809 }
6810 if (genRand.Next(4) == 0)
6811 {
6812 int num4 = num + genRand.Next(-2, 3);
6813 int num5 = num2 + genRand.Next(2);
6814 Main.tile[num4, num5].type = type;
6815 Main.tile[num4, num5].active(active: true);
6817 if (!gen)
6818 {
6820 }
6821 }
6822 }
6823 Vector2D val = default(Vector2D);
6824 ((Vector2D)(ref val))._002Ector((double)num, (double)num2);
6825 Vector2D val2 = default(Vector2D);
6826 val2.X = genRand.NextDouble() * 0.6 - 0.3;
6827 val2.Y = genRand.NextDouble() * 0.5 + 0.5;
6828 double num6 = genRand.Next(5, 9);
6829 int num7 = genRand.Next(9, 14);
6830 if (genRand.Next(3) == 0)
6831 {
6832 num6 += (double)genRand.Next(2);
6833 }
6834 if (genRand.Next(3) == 0)
6835 {
6836 num7 += genRand.Next(2);
6837 }
6838 while (num7 > 0)
6839 {
6840 num7--;
6841 for (int k = num - (int)num6 * 4; (double)k <= (double)num + num6 * 4.0; k++)
6842 {
6843 for (int l = num2 - (int)num6 * 4; (double)l <= (double)num2 + num6 * 4.0; l++)
6844 {
6845 double num8 = num6 * (0.5 + genRand.NextDouble() * 0.5) * 0.1;
6846 double num9 = num6 * (0.7 + genRand.NextDouble() * 0.6) * 0.3;
6847 if (genRand.Next(8) == 0)
6848 {
6849 num9 *= 2.0;
6850 }
6851 Vector2D val3 = val - new Vector2D((double)k, (double)l);
6852 if (((Vector2D)(ref val3)).Length() < num8)
6853 {
6854 Main.tile[k, l].active(active: false);
6855 }
6856 else if (((Vector2D)(ref val3)).Length() < num9)
6857 {
6858 Main.tile[k, l].type = type;
6859 if (genRand.Next(4) == 0)
6860 {
6861 Main.tile[k, l].active(active: true);
6862 }
6863 OreHelper(k, l);
6864 if (!gen)
6865 {
6867 }
6868 }
6869 }
6870 }
6871 val += val2;
6872 val2.X += genRand.NextDouble() * 0.2 - 0.1;
6873 val2.Y += genRand.NextDouble() * 0.2 - 0.1;
6874 Utils.Clamp(val2.X, -0.3, 0.3);
6875 Utils.Clamp(val2.Y, 0.5, 1.0);
6876 }
6877 return true;
6878 }
6879
6880 public static bool PlaceOasis(int X, int Y)
6881 {
6882 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
6883 //IL_00ad: Unknown result type (might be due to invalid IL or missing references)
6884 int i = Y;
6885 if (!Main.tile[X, i].active() && Main.tile[X, i].wall == 0)
6886 {
6887 for (; !Main.tile[X, i].active() && Main.tile[X, i].wall == 0 && (double)i <= Main.worldSurface; i++)
6888 {
6889 }
6890 if ((double)i > Main.worldSurface - 10.0)
6891 {
6892 return false;
6893 }
6894 if (Main.tile[X, i].type != 53)
6895 {
6896 return false;
6897 }
6898 int num = 350;
6899 for (int j = 0; j < GenVars.numOasis; j++)
6900 {
6901 if (Vector2D.Distance(GenVars.oasisPosition[j].ToVector2D(), new Vector2D((double)X, (double)i)) < (double)num)
6902 {
6903 return false;
6904 }
6905 }
6906 int num2 = genRand.Next(45, 61);
6907 int oasisHeight = GenVars.oasisHeight;
6908 int num3 = num2 + 50;
6909 int num4 = 4;
6910 for (int k = X - num3; k <= X + num3; k++)
6911 {
6912 for (int l = i - oasisHeight; l <= i + oasisHeight + num4; l++)
6913 {
6914 Tile tile = Main.tile[k, l];
6915 if (tile.active())
6916 {
6917 if (Main.tileSolid[tile.type])
6918 {
6919 if ((tile.type == 151 || tile.type == 397) && Math.Abs(k - X) < num2 && Math.Abs(l - i) < oasisHeight / 2)
6920 {
6921 return false;
6922 }
6923 if (tile.type != 53)
6924 {
6925 return false;
6926 }
6927 }
6928 }
6929 else if ((tile.liquid > 0 || tile.wall > 0) && Math.Abs(k - X) < num2 && Math.Abs(l - i) < oasisHeight / 2)
6930 {
6931 return false;
6932 }
6933 }
6934 if (k > X - num2 / 2 && k < X - num2 / 2)
6935 {
6936 if (Main.tile[k, i - 6].active())
6937 {
6938 return false;
6939 }
6940 if (!Main.tile[k, i + 1].active())
6941 {
6942 return false;
6943 }
6944 }
6945 }
6946 int num5 = 5;
6947 int num6 = i;
6948 while (!Main.tile[X - num2, i + num5].active() || Main.tile[X - num2, i + num5].wall != 0 || !Main.tile[X + num2, i + num5].active() || Main.tile[X + num2, i + num5].wall != 0)
6949 {
6950 i++;
6951 if (i - num6 > 20)
6952 {
6953 break;
6954 }
6955 }
6956 int num7 = num2 / 2;
6957 int num8 = X - num2 * 3;
6958 int num9 = X + num2 * 3;
6959 int num10 = i - oasisHeight * 4;
6960 int num11 = i + oasisHeight * 3;
6961 if (num8 < 0)
6962 {
6963 num8 = 0;
6964 }
6965 if (num9 > Main.maxTilesX)
6966 {
6968 }
6969 if (num10 < 0)
6970 {
6971 num10 = 0;
6972 }
6973 if (num11 > Main.maxTilesY)
6974 {
6976 }
6977 for (int m = num8; m < num9; m++)
6978 {
6979 for (int n = num10; n < num11; n++)
6980 {
6981 double num12 = (double)Math.Abs(m - X) * 0.7;
6982 double num13 = (double)Math.Abs(n - i) * 1.35;
6983 double num14 = Math.Sqrt(num12 * num12 + num13 * num13);
6984 double num15 = (double)num7 * (0.53 + genRand.NextDouble() * 0.04);
6985 double num16 = (double)Math.Abs(m - X) / (double)(num9 - X);
6986 num16 = 1.0 - num16;
6987 num16 *= 2.3;
6988 num16 *= num16;
6989 num16 *= num16;
6990 if (num14 < num15)
6991 {
6992 if (n == i + 1)
6993 {
6994 Main.tile[m, n].liquid = 127;
6995 }
6996 else if (n > i + 1)
6997 {
6998 Main.tile[m, n].liquid = byte.MaxValue;
6999 }
7000 Main.tile[m, n].lava(lava: false);
7001 Main.tile[m, n].active(active: false);
7002 }
7003 else if (n < i && num12 < num15 + (double)(Math.Abs(n - i) * 3) * num16)
7004 {
7005 if (Main.tile[m, n].type == 53)
7006 {
7007 Main.tile[m, n].active(active: false);
7008 }
7009 }
7010 else if (n >= i && num12 < num15 + (double)Math.Abs(n - i) * num16 && Main.tile[m, n].wall == 0)
7011 {
7012 if (Main.tile[m, n].active() && Main.tileSolid[Main.tile[m, n].type] && !Main.tileSolidTop[Main.tile[m, n].type])
7013 {
7014 Main.tile[m, n].slope(0);
7015 Main.tile[m, n].halfBrick(halfBrick: false);
7016 continue;
7017 }
7018 Main.tile[m, n].active(active: true);
7019 Main.tile[m, n].type = 53;
7020 Main.tile[m, n].slope(0);
7021 Main.tile[m, n].halfBrick(halfBrick: false);
7022 }
7023 }
7024 }
7025 int num17 = 50;
7026 num8 = X - num2 * 2;
7027 num9 = X + num2 * 2;
7028 num11 = i + oasisHeight * 2;
7029 for (int num18 = num8; num18 < num9; num18++)
7030 {
7031 for (int num19 = num11; num19 >= i; num19--)
7032 {
7033 double num20 = (double)Math.Abs(num18 - X) * 0.7;
7034 double num21 = (double)Math.Abs(num19 - i) * 1.35;
7035 double num22 = Math.Sqrt(num20 * num20 + num21 * num21);
7036 double num23 = (double)num7 * 0.5700000000000001;
7037 if (num22 > num23)
7038 {
7039 bool flag = false;
7040 if (!Main.tile[num18, num19].active() && Main.tile[num18, num19].wall == 0)
7041 {
7042 int num24 = -1;
7043 int num25 = -1;
7044 for (int num26 = num18; num26 <= num18 + num17 && Main.tile[num26, num19 + 1].active() && Main.tileSolid[Main.tile[num26, num19 + 1].type] && Main.tile[num26, num19].wall <= 0; num26++)
7045 {
7046 if (Main.tile[num26, num19].active() && Main.tileSolid[Main.tile[num26, num19].type])
7047 {
7048 if (Main.tile[num26, num19].type == 53)
7049 {
7050 flag = true;
7051 }
7052 num25 = num26;
7053 break;
7054 }
7055 if (Main.tile[num26, num19].active())
7056 {
7057 break;
7058 }
7059 }
7060 int num27 = num18;
7061 while (num27 >= num18 - num17 && Main.tile[num27, num19 + 1].active() && Main.tileSolid[Main.tile[num27, num19 + 1].type] && Main.tile[num27, num19].wall <= 0)
7062 {
7063 if (Main.tile[num27, num19].active() && Main.tileSolid[Main.tile[num27, num19].type])
7064 {
7065 if (Main.tile[num27, num19].type == 53)
7066 {
7067 flag = true;
7068 }
7069 num24 = num27;
7070 break;
7071 }
7072 if (Main.tile[num27, num19].active())
7073 {
7074 break;
7075 }
7076 num27--;
7077 }
7078 flag = true;
7079 if (num24 > -1 && num25 > -1 && flag)
7080 {
7081 int num28 = 0;
7082 for (int num29 = num24 + 1; num29 < num25; num29++)
7083 {
7084 if (num25 - num24 > 5 && genRand.Next(5) == 0)
7085 {
7086 num28 = genRand.Next(5, 10);
7087 }
7088 Main.tile[num29, num19].active(active: true);
7089 Main.tile[num29, num19].type = 53;
7090 if (num28 > 0)
7091 {
7092 num28--;
7093 Main.tile[num29, num19 - 1].active(active: true);
7094 Main.tile[num29, num19 - 1].type = 53;
7095 }
7096 }
7097 }
7098 }
7099 }
7100 }
7101 }
7103 {
7106 GenVars.numOasis++;
7107 }
7108 return true;
7109 }
7110 return false;
7111 }
7112
7113 public static bool BiomeTileCheck(int x, int y)
7114 {
7115 int num = 50;
7116 for (int i = x - num; i <= x + num; i++)
7117 {
7118 for (int j = y - num; j <= y + num; j++)
7119 {
7120 if (!InWorld(i, j))
7121 {
7122 continue;
7123 }
7124 if (Main.tile[i, j].active())
7125 {
7126 int type = Main.tile[i, j].type;
7127 if (type == 368 || type == 367 || type == 147 || type == 161 || type == 162 || type == 70 || type == 72 || type == 396 || type == 397)
7128 {
7129 return true;
7130 }
7131 }
7132 int wall = Main.tile[i, j].wall;
7133 if (wall == 187 || wall == 216)
7134 {
7135 return true;
7136 }
7137 }
7138 }
7139 return false;
7140 }
7141
7142 public static bool oceanDepths(int x, int y)
7143 {
7144 if ((double)y > oceanLevel)
7145 {
7146 return false;
7147 }
7149 {
7150 return true;
7151 }
7152 return false;
7153 }
7154
7155 public static void UpdateDesertHiveBounds(int x, int y)
7156 {
7157 if (GenVars.desertHiveHigh > y)
7158 {
7159 GenVars.desertHiveHigh = y;
7160 }
7161 if (GenVars.desertHiveLow < y)
7162 {
7163 GenVars.desertHiveLow = y;
7164 }
7165 if (GenVars.desertHiveLeft > x)
7166 {
7167 GenVars.desertHiveLeft = x;
7168 }
7169 if (GenVars.desertHiveRight < x)
7170 {
7171 GenVars.desertHiveRight = x;
7172 }
7173 }
7174
7176 {
7179 drunkWorldGen = false;
7180 drunkWorldGenText = false;
7181 Main.afterPartyOfDoom = false;
7182 if (seed == 5162020 || everythingWorldGen)
7183 {
7184 drunkWorldGen = true;
7185 drunkWorldGenText = true;
7186 Main.drunkWorld = true;
7187 Main.rand = new UnifiedRandom();
7188 seed = Main.rand.Next(999999999);
7189 if (!Main.dayTime)
7190 {
7191 Main.time = 0.0;
7192 }
7193 }
7194 else if (seed == 5162021 || seed == 5162011)
7195 {
7197 }
7198 Main.notTheBeesWorld = notTheBees;
7199 if (notTheBees)
7200 {
7201 Main.rand = new UnifiedRandom();
7202 seed = Main.rand.Next(999999999);
7203 }
7204 Main.noTrapsWorld = noTrapsWorldGen;
7205 if (noTrapsWorldGen)
7206 {
7207 Main.rand = new UnifiedRandom();
7208 seed = Main.rand.Next(999999999);
7209 }
7210 if (getGoodWorldGen)
7211 {
7212 Main.getGoodWorld = true;
7213 Main.rand = new UnifiedRandom();
7214 seed = Main.rand.Next(999999999);
7215 }
7216 else
7217 {
7218 Main.getGoodWorld = false;
7219 }
7220 Main.tenthAnniversaryWorld = tenthAnniversaryWorldGen;
7222 {
7223 Main.rand = new UnifiedRandom();
7224 seed = Main.rand.Next(999999999);
7225 }
7226 Main.dontStarveWorld = dontStarveWorldGen;
7228 {
7229 Main.rand = new UnifiedRandom();
7230 seed = Main.rand.Next(999999999);
7231 }
7232 Main.remixWorld = remixWorldGen;
7233 if (remixWorldGen)
7234 {
7235 Main.rand = new UnifiedRandom();
7236 seed = Main.rand.Next(999999999);
7237 }
7238 Main.zenithWorld = everythingWorldGen;
7239 Console.WriteLine("Creating world - Seed: {0} Width: {1}, Height: {2}, Evil: {3}, IsExpert: {4}", seed, Main.maxTilesX, Main.maxTilesY, WorldGenParam_Evil, Main.expertMode);
7240 Main.lockMenuBGChange = true;
7241 GenVars.configuration = WorldGenConfiguration.FromEmbeddedPath("Terraria.GameContent.WorldBuilding.Configuration.json");
7243 _lastSeed = seed;
7246 Main.rand = new UnifiedRandom(seed);
7247 GenVars.structures = new StructureMap();
7248 GenVars.desertHiveHigh = Main.maxTilesY;
7249 GenVars.desertHiveLow = 0;
7250 GenVars.desertHiveLeft = Main.maxTilesX;
7251 GenVars.desertHiveRight = 0;
7252 GenVars.worldSurfaceLow = 0.0;
7253 GenVars.worldSurface = 0.0;
7254 GenVars.worldSurfaceHigh = 0.0;
7255 GenVars.rockLayerLow = 0.0;
7256 GenVars.rockLayer = 0.0;
7257 GenVars.rockLayerHigh = 0.0;
7258 GenVars.copper = 7;
7259 GenVars.iron = 6;
7260 GenVars.silver = 9;
7261 GenVars.gold = 8;
7262 GenVars.dungeonSide = 0;
7263 GenVars.jungleHut = (ushort)genRand.Next(5);
7264 GenVars.shellStartXLeft = 0;
7265 GenVars.shellStartYLeft = 0;
7266 GenVars.shellStartXRight = 0;
7267 GenVars.shellStartYRight = 0;
7268 GenVars.PyrX = null;
7269 GenVars.PyrY = null;
7270 GenVars.numPyr = 0;
7271 GenVars.jungleMinX = -1;
7272 GenVars.jungleMaxX = -1;
7273 GenVars.snowMinX = new int[Main.maxTilesY];
7274 GenVars.snowMaxX = new int[Main.maxTilesY];
7275 GenVars.snowTop = 0;
7276 GenVars.snowBottom = 0;
7277 GenVars.skyLakes = 1;
7278 if (Main.maxTilesX > 8000)
7279 {
7280 GenVars.skyLakes++;
7281 }
7282 if (Main.maxTilesX > 6000)
7283 {
7284 GenVars.skyLakes++;
7285 }
7286 GenVars.beachBordersWidth = 275;
7287 GenVars.beachSandRandomCenter = GenVars.beachBordersWidth + 5 + 40;
7288 GenVars.beachSandRandomWidthRange = 20;
7289 GenVars.beachSandDungeonExtraWidth = 40;
7290 GenVars.beachSandJungleExtraWidth = 20;
7291 GenVars.oceanWaterStartRandomMin = 220;
7292 GenVars.oceanWaterStartRandomMax = GenVars.oceanWaterStartRandomMin + 40;
7293 GenVars.oceanWaterForcedJungleLength = 275;
7294 GenVars.leftBeachEnd = 0;
7295 GenVars.rightBeachStart = 0;
7296 GenVars.evilBiomeBeachAvoidance = GenVars.beachSandRandomCenter + 60;
7297 GenVars.evilBiomeAvoidanceMidFixer = 50;
7298 GenVars.lakesBeachAvoidance = GenVars.beachSandRandomCenter + 20;
7299 GenVars.smallHolesBeachAvoidance = GenVars.beachSandRandomCenter + 20;
7300 GenVars.surfaceCavesBeachAvoidance = GenVars.beachSandRandomCenter + 20;
7301 GenVars.surfaceCavesBeachAvoidance2 = GenVars.beachSandRandomCenter + 20;
7302 GenVars.jungleOriginX = 0;
7303 GenVars.snowOriginLeft = 0;
7304 GenVars.snowOriginRight = 0;
7305 GenVars.logX = -1;
7306 GenVars.logY = -1;
7307 GenVars.dungeonLocation = 0;
7309 {
7310 Main.starGame = true;
7311 }
7313 {
7314 if (genRand.Next(2) == 0)
7315 {
7316 GenVars.crimsonLeft = false;
7317 }
7318 else
7319 {
7320 GenVars.crimsonLeft = true;
7321 }
7323 GenVars.skipDesertTileCheck = false;
7324 growGrassUnderground = false;
7325 gen = true;
7326 Liquid.ReInit();
7327 noTileActions = true;
7328 progress.Message = "";
7331 Main.cloudAlpha = 0f;
7332 Main.maxRaining = 0f;
7333 Main.raining = false;
7334 heartCount = 0;
7335 GenVars.extraBastStatueCount = 0;
7336 GenVars.extraBastStatueCountMax = 2;
7337 Main.checkXMas();
7340 GenVars.UndergroundDesertLocation = Rectangle.Empty;
7341 GenVars.UndergroundDesertHiveLocation = Rectangle.Empty;
7342 GenVars.numLarva = 0;
7343 List<int> list3 = new List<int> { 274, 220, 112, 218, 3019 };
7344 if (remixWorldGen)
7345 {
7346 list3 = new List<int> { 274, 220, 683, 218, 3019 };
7347 }
7348 List<int> list4 = new List<int>();
7349 while (list3.Count > 0)
7350 {
7351 int index = genRand.Next(list3.Count);
7352 int item = list3[index];
7353 list4.Add(item);
7354 list3.RemoveAt(index);
7355 }
7356 GenVars.hellChestItem = list4.ToArray();
7357 int num1086 = 86400;
7358 Main.slimeRainTime = -genRand.Next(num1086 * 2, num1086 * 3);
7359 Main.cloudBGActive = -genRand.Next(8640, 86400);
7360 skipFramingDuringGen = false;
7361 SavedOreTiers.Copper = 7;
7362 SavedOreTiers.Iron = 6;
7363 SavedOreTiers.Silver = 9;
7364 SavedOreTiers.Gold = 8;
7365 GenVars.copperBar = 20;
7366 GenVars.ironBar = 22;
7367 GenVars.silverBar = 21;
7368 GenVars.goldBar = 19;
7369 if (genRand.Next(2) == 0)
7370 {
7371 GenVars.copper = 166;
7372 GenVars.copperBar = 703;
7373 SavedOreTiers.Copper = 166;
7374 }
7375 if ((!dontStarveWorldGen || drunkWorldGen) && genRand.Next(2) == 0)
7376 {
7377 GenVars.iron = 167;
7378 GenVars.ironBar = 704;
7379 SavedOreTiers.Iron = 167;
7380 }
7381 if (genRand.Next(2) == 0)
7382 {
7383 GenVars.silver = 168;
7384 GenVars.silverBar = 705;
7385 SavedOreTiers.Silver = 168;
7386 }
7387 if ((!dontStarveWorldGen || drunkWorldGen) && genRand.Next(2) == 0)
7388 {
7389 GenVars.gold = 169;
7390 GenVars.goldBar = 706;
7391 SavedOreTiers.Gold = 169;
7392 }
7393 crimson = genRand.Next(2) == 0;
7394 if (WorldGenParam_Evil == 0)
7395 {
7396 crimson = false;
7397 }
7398 if (WorldGenParam_Evil == 1)
7399 {
7400 crimson = true;
7401 }
7402 if (GenVars.jungleHut == 0)
7403 {
7404 GenVars.jungleHut = 119;
7405 }
7406 else if (GenVars.jungleHut == 1)
7407 {
7408 GenVars.jungleHut = 120;
7409 }
7410 else if (GenVars.jungleHut == 2)
7411 {
7412 GenVars.jungleHut = 158;
7413 }
7414 else if (GenVars.jungleHut == 3)
7415 {
7416 GenVars.jungleHut = 175;
7417 }
7418 else if (GenVars.jungleHut == 4)
7419 {
7420 GenVars.jungleHut = 45;
7421 }
7422 Main.worldID = genRand.Next(int.MaxValue);
7427 TreeTops.CopyExistingWorldInfoForWorldGeneration();
7428 GenVars.dungeonSide = ((genRand.Next(2) != 0) ? 1 : (-1));
7429 if (remixWorldGen)
7430 {
7431 if (GenVars.dungeonSide == -1)
7432 {
7433 double num1087 = 1.0 - (double)genRand.Next(20, 35) * 0.01;
7434 GenVars.jungleOriginX = (int)((double)Main.maxTilesX * num1087);
7435 }
7436 else
7437 {
7438 double num1088 = (double)genRand.Next(20, 35) * 0.01;
7439 GenVars.jungleOriginX = (int)((double)Main.maxTilesX * num1088);
7440 }
7441 }
7442 else
7443 {
7444 int minValue3 = 15;
7445 int maxValue12 = 30;
7447 {
7448 minValue3 = 25;
7449 maxValue12 = 35;
7450 }
7451 if (GenVars.dungeonSide == -1)
7452 {
7453 double num1089 = 1.0 - (double)genRand.Next(minValue3, maxValue12) * 0.01;
7454 GenVars.jungleOriginX = (int)((double)Main.maxTilesX * num1089);
7455 }
7456 else
7457 {
7458 double num1090 = (double)genRand.Next(minValue3, maxValue12) * 0.01;
7459 GenVars.jungleOriginX = (int)((double)Main.maxTilesX * num1090);
7460 }
7461 }
7462 int num1091 = genRand.Next(Main.maxTilesX);
7463 if (drunkWorldGen)
7464 {
7465 GenVars.dungeonSide *= -1;
7466 }
7467 if (GenVars.dungeonSide == 1)
7468 {
7469 while ((double)num1091 < (double)Main.maxTilesX * 0.6 || (double)num1091 > (double)Main.maxTilesX * 0.75)
7470 {
7471 num1091 = genRand.Next(Main.maxTilesX);
7472 }
7473 }
7474 else
7475 {
7476 while ((double)num1091 < (double)Main.maxTilesX * 0.25 || (double)num1091 > (double)Main.maxTilesX * 0.4)
7477 {
7478 num1091 = genRand.Next(Main.maxTilesX);
7479 }
7480 }
7481 if (drunkWorldGen)
7482 {
7483 GenVars.dungeonSide *= -1;
7484 }
7485 int num1092 = genRand.Next(50, 90);
7486 double num1093 = (double)Main.maxTilesX / 4200.0;
7487 num1092 += (int)((double)genRand.Next(20, 40) * num1093);
7488 num1092 += (int)((double)genRand.Next(20, 40) * num1093);
7489 int num1094 = num1091 - num1092;
7490 num1092 = genRand.Next(50, 90);
7491 num1092 += (int)((double)genRand.Next(20, 40) * num1093);
7492 num1092 += (int)((double)genRand.Next(20, 40) * num1093);
7493 int num1095 = num1091 + num1092;
7494 if (num1094 < 0)
7495 {
7496 num1094 = 0;
7497 }
7498 if (num1095 > Main.maxTilesX)
7499 {
7501 }
7502 GenVars.snowOriginLeft = num1094;
7503 GenVars.snowOriginRight = num1095;
7506 {
7507 GenVars.leftBeachEnd = GenVars.beachSandRandomCenter + GenVars.beachSandRandomWidthRange;
7508 }
7509 if (GenVars.dungeonSide == 1)
7510 {
7511 GenVars.leftBeachEnd += GenVars.beachSandDungeonExtraWidth;
7512 }
7513 else
7514 {
7515 GenVars.leftBeachEnd += GenVars.beachSandJungleExtraWidth;
7516 }
7519 {
7520 GenVars.rightBeachStart = Main.maxTilesX - (GenVars.beachSandRandomCenter + GenVars.beachSandRandomWidthRange);
7521 }
7522 if (GenVars.dungeonSide == -1)
7523 {
7524 GenVars.rightBeachStart -= GenVars.beachSandDungeonExtraWidth;
7525 }
7526 else
7527 {
7528 GenVars.rightBeachStart -= GenVars.beachSandJungleExtraWidth;
7529 }
7530 int num1096 = 50;
7531 if (GenVars.dungeonSide == -1)
7532 {
7533 GenVars.dungeonLocation = genRand.Next(GenVars.leftBeachEnd + num1096, (int)((double)Main.maxTilesX * 0.2));
7534 }
7535 else
7536 {
7537 GenVars.dungeonLocation = genRand.Next((int)((double)Main.maxTilesX * 0.8), GenVars.rightBeachStart - num1096);
7538 }
7539 int num1097 = 0;
7540 if (Main.maxTilesX >= 8400)
7541 {
7542 num1097 = 2;
7543 }
7544 else if (Main.maxTilesX >= 6400)
7545 {
7546 num1097 = 1;
7547 }
7548 GenVars.extraBastStatueCountMax = 2 + num1097;
7549 Main.tileSolid[659] = false;
7550 });
7553 {
7554 progress.Message = Lang.gen[1].Value;
7555 int random9 = passConfig.Get<WorldGenRange>("Count").GetRandom(genRand);
7556 double num1080 = passConfig.Get<double>("ChanceOfPyramid");
7557 if (drunkWorldGen)
7558 {
7559 num1080 = 1.0;
7560 }
7561 double num1081 = (double)Main.maxTilesX / 4200.0;
7562 GenVars.PyrX = new int[random9 + 3];
7563 GenVars.PyrY = new int[random9 + 3];
7565 for (int num1082 = 0; num1082 < random9; num1082++)
7566 {
7567 progress.Set((double)num1082 / (double)random9);
7569 bool flag62 = false;
7570 int num1083 = 0;
7571 while (!flag62)
7572 {
7573 origin5 = RandomWorldPoint(0, 500, 0, 500);
7574 bool flag63 = Math.Abs(origin5.X - GenVars.jungleOriginX) < (int)(600.0 * num1081);
7575 bool flag64 = Math.Abs(origin5.X - Main.maxTilesX / 2) < 300;
7576 bool flag65 = origin5.X > GenVars.snowOriginLeft - 300 && origin5.X < GenVars.snowOriginRight + 300;
7577 num1083++;
7578 if (num1083 >= Main.maxTilesX)
7579 {
7580 flag63 = false;
7581 }
7582 if (num1083 >= Main.maxTilesX * 2)
7583 {
7584 flag65 = false;
7585 }
7586 flag62 = !(flag63 || flag64 || flag65);
7587 }
7589 if (genRand.NextDouble() <= num1080)
7590 {
7591 int num1084 = genRand.Next(origin5.X - 200, origin5.X + 200);
7592 for (int num1085 = 0; num1085 < Main.maxTilesY; num1085++)
7593 {
7594 if (Main.tile[num1084, num1085].active())
7595 {
7598 GenVars.numPyr++;
7599 break;
7600 }
7601 }
7602 }
7603 }
7604 });
7606 {
7607 progress.Message = Language.GetTextValue("WorldGeneration.OceanSand");
7608 for (int num1069 = 0; num1069 < 3; num1069++)
7609 {
7610 progress.Set((double)num1069 / 3.0);
7611 int num1070 = genRand.Next(Main.maxTilesX);
7612 while ((double)num1070 > (double)Main.maxTilesX * 0.4 && (double)num1070 < (double)Main.maxTilesX * 0.6)
7613 {
7614 num1070 = genRand.Next(Main.maxTilesX);
7615 }
7616 int num1071 = genRand.Next(35, 90);
7617 if (num1069 == 1)
7618 {
7619 double num1072 = (double)Main.maxTilesX / 4200.0;
7620 num1071 += (int)((double)genRand.Next(20, 40) * num1072);
7621 }
7622 if (genRand.Next(3) == 0)
7623 {
7624 num1071 *= 2;
7625 }
7626 if (num1069 == 1)
7627 {
7628 num1071 *= 2;
7629 }
7630 int num1073 = num1070 - num1071;
7631 num1071 = genRand.Next(35, 90);
7632 if (genRand.Next(3) == 0)
7633 {
7634 num1071 *= 2;
7635 }
7636 if (num1069 == 1)
7637 {
7638 num1071 *= 2;
7639 }
7640 int num1074 = num1070 + num1071;
7641 if (num1073 < 0)
7642 {
7643 num1073 = 0;
7644 }
7645 if (num1074 > Main.maxTilesX)
7646 {
7648 }
7649 if (num1069 == 0)
7650 {
7651 num1073 = 0;
7653 }
7654 else if (num1069 == 2)
7655 {
7658 }
7659 else if (num1069 == 1)
7660 {
7661 continue;
7662 }
7663 int num1075 = genRand.Next(50, 100);
7664 for (int num1076 = num1073; num1076 < num1074; num1076++)
7665 {
7666 if (genRand.Next(2) == 0)
7667 {
7668 num1075 += genRand.Next(-1, 2);
7669 if (num1075 < 50)
7670 {
7671 num1075 = 50;
7672 }
7673 if (num1075 > 200)
7674 {
7675 num1075 = 200;
7676 }
7677 }
7678 for (int num1077 = 0; (double)num1077 < (Main.worldSurface + Main.rockLayer) / 2.0; num1077++)
7679 {
7680 if (Main.tile[num1076, num1077].active())
7681 {
7682 if (num1076 == (num1073 + num1074) / 2 && genRand.Next(6) == 0)
7683 {
7686 GenVars.numPyr++;
7687 }
7688 int num1078 = num1075;
7689 if (num1076 - num1073 < num1078)
7690 {
7692 }
7693 if (num1074 - num1076 < num1078)
7694 {
7696 }
7697 num1078 += genRand.Next(5);
7698 for (int num1079 = num1077; num1079 < num1077 + num1078; num1079++)
7699 {
7700 if (num1076 > num1073 + genRand.Next(5) && num1076 < num1074 - genRand.Next(5))
7701 {
7702 Main.tile[num1076, num1079].type = 53;
7703 }
7704 }
7705 break;
7706 }
7707 }
7708 }
7709 }
7710 });
7711 AddGenerationPass("Sand Patches", delegate
7712 {
7713 int num1064 = (int)((double)Main.maxTilesX * 0.013);
7714 if (remixWorldGen)
7715 {
7716 num1064 /= 4;
7717 }
7718 for (int num1065 = 0; num1065 < num1064; num1065++)
7719 {
7720 int num1066 = genRand.Next(0, Main.maxTilesX);
7721 int num1067 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
7722 if (remixWorldGen)
7723 {
7724 num1067 = genRand.Next((int)Main.rockLayer - 100, Main.maxTilesY - 350);
7725 }
7726 while ((double)num1066 > (double)Main.maxTilesX * 0.46 && (double)num1066 < (double)Main.maxTilesX * 0.54 && (double)num1067 < Main.worldSurface + 150.0)
7727 {
7728 num1066 = genRand.Next(0, Main.maxTilesX);
7729 num1067 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
7730 }
7731 int num1068 = genRand.Next(15, 70);
7732 int steps2 = genRand.Next(20, 130);
7734 }
7735 });
7736 AddGenerationPass("Tunnels", delegate
7737 {
7738 int num1058 = (int)((double)Main.maxTilesX * 0.0015);
7739 if (remixWorldGen)
7740 {
7741 num1058 = (int)((double)num1058 * 1.5);
7742 }
7743 for (int num1059 = 0; num1059 < num1058; num1059++)
7744 {
7746 {
7747 break;
7748 }
7749 int[] array = new int[10];
7750 int[] array2 = new int[10];
7751 int num1060 = genRand.Next(450, Main.maxTilesX - 450);
7752 if (!remixWorldGen)
7753 {
7755 {
7756 num1060 = genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8));
7757 }
7758 else
7759 {
7760 while ((double)num1060 > (double)Main.maxTilesX * 0.4 && (double)num1060 < (double)Main.maxTilesX * 0.6)
7761 {
7762 num1060 = genRand.Next(450, Main.maxTilesX - 450);
7763 }
7764 }
7765 }
7766 int num1061 = 0;
7767 bool flag61;
7768 do
7769 {
7770 flag61 = false;
7771 for (int num1062 = 0; num1062 < 10; num1062++)
7772 {
7773 for (num1060 %= Main.maxTilesX; !Main.tile[num1060, num1061].active(); num1061++)
7774 {
7775 }
7776 if (Main.tile[num1060, num1061].type == 53)
7777 {
7778 flag61 = true;
7779 }
7781 array2[num1062] = num1061 - genRand.Next(11, 16);
7782 num1060 += genRand.Next(5, 11);
7783 }
7784 }
7785 while (flag61);
7788 for (int num1063 = 0; num1063 < 10; num1063++)
7789 {
7790 TileRunner(array[num1063], array2[num1063], genRand.Next(5, 8), genRand.Next(6, 9), 0, addTile: true, -2.0, -0.3);
7791 TileRunner(array[num1063], array2[num1063], genRand.Next(5, 8), genRand.Next(6, 9), 0, addTile: true, 2.0, -0.3);
7792 }
7793 }
7794 });
7796 {
7797 GenVars.numMCaves = 0;
7798 progress.Message = Lang.gen[2].Value;
7799 int num1050 = (int)((double)Main.maxTilesX * 0.001);
7800 if (remixWorldGen)
7801 {
7802 num1050 = (int)((double)num1050 * 1.5);
7803 }
7804 for (int num1051 = 0; num1051 < num1050; num1051++)
7805 {
7806 progress.Set((double)num1051 / (double)num1050);
7807 int num1052 = 0;
7808 bool flag59 = false;
7809 bool flag60 = false;
7810 int num1053 = genRand.Next((int)((double)Main.maxTilesX * 0.25), (int)((double)Main.maxTilesX * 0.75));
7811 while (!flag60)
7812 {
7813 flag60 = true;
7814 if (!remixWorldGen)
7815 {
7816 while (num1053 > Main.maxTilesX / 2 - 90 && num1053 < Main.maxTilesX / 2 + 90)
7817 {
7818 num1053 = genRand.Next((int)((double)Main.maxTilesX * 0.25), (int)((double)Main.maxTilesX * 0.75));
7819 }
7820 }
7821 for (int num1054 = 0; num1054 < GenVars.numMCaves; num1054++)
7822 {
7823 if (Math.Abs(num1053 - GenVars.mCaveX[num1054]) < 100)
7824 {
7825 num1052++;
7826 flag60 = false;
7827 break;
7828 }
7829 }
7830 if (num1052 >= Main.maxTilesX / 5)
7831 {
7832 flag59 = true;
7833 break;
7834 }
7835 }
7836 if (!flag59)
7837 {
7838 for (int num1055 = 0; (double)num1055 < Main.worldSurface; num1055++)
7839 {
7840 if (Main.tile[num1053, num1055].active())
7841 {
7842 for (int num1056 = num1053 - 50; num1056 < num1053 + 50; num1056++)
7843 {
7844 for (int num1057 = num1055 - 25; num1057 < num1055 + 25; num1057++)
7845 {
7846 if (Main.tile[num1056, num1057].active() && (Main.tile[num1056, num1057].type == 53 || Main.tile[num1056, num1057].type == 151 || Main.tile[num1056, num1057].type == 274))
7847 {
7848 flag59 = true;
7849 }
7850 }
7851 }
7852 if (!flag59)
7853 {
7858 break;
7859 }
7860 }
7861 }
7862 }
7863 }
7864 });
7866 {
7867 progress.Message = Lang.gen[3].Value;
7868 int num1047 = 0;
7869 for (int num1048 = 1; num1048 < Main.maxTilesX - 1; num1048++)
7870 {
7871 ushort wall3 = 2;
7872 double value20 = (double)num1048 / (double)Main.maxTilesX;
7873 progress.Set(value20);
7874 bool flag58 = false;
7875 num1047 += genRand.Next(-1, 2);
7876 if (num1047 < 0)
7877 {
7878 num1047 = 0;
7879 }
7880 if (num1047 > 10)
7881 {
7882 num1047 = 10;
7883 }
7884 for (int num1049 = 0; (double)num1049 < Main.worldSurface + 10.0 && !((double)num1049 > Main.worldSurface + (double)num1047); num1049++)
7885 {
7886 if (Main.tile[num1048, num1049].active())
7887 {
7888 wall3 = (ushort)((Main.tile[num1048, num1049].type != 147) ? 2 : 40);
7889 }
7890 if (flag58 && Main.tile[num1048, num1049].wall != 64)
7891 {
7892 Main.tile[num1048, num1049].wall = wall3;
7893 }
7894 if (Main.tile[num1048, num1049].active() && Main.tile[num1048 - 1, num1049].active() && Main.tile[num1048 + 1, num1049].active() && Main.tile[num1048, num1049 + 1].active() && Main.tile[num1048 - 1, num1049 + 1].active() && Main.tile[num1048 + 1, num1049 + 1].active())
7895 {
7896 flag58 = true;
7897 }
7898 }
7899 }
7900 });
7902 {
7903 progress.Message = Lang.gen[4].Value;
7904 double num1041 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.00015;
7905 for (int num1042 = 0; (double)num1042 < num1041; num1042++)
7906 {
7907 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow + 1), genRand.Next(4, 15), genRand.Next(5, 40), 1);
7908 }
7909 progress.Set(0.34);
7910 num1041 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.0002;
7911 for (int num1043 = 0; (double)num1043 < num1041; num1043++)
7912 {
7913 int num1044 = genRand.Next(0, Main.maxTilesX);
7915 if (!Main.tile[num1044, num1045 - 10].active())
7916 {
7918 }
7919 TileRunner(num1044, num1045, genRand.Next(4, 10), genRand.Next(5, 30), 1);
7920 }
7921 progress.Set(0.67);
7922 num1041 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.0045;
7923 for (int num1046 = 0; (double)num1046 < num1041; num1046++)
7924 {
7925 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh + 1), genRand.Next(2, 7), genRand.Next(2, 23), 1);
7926 }
7927 });
7929 {
7930 progress.Message = Lang.gen[5].Value;
7931 double num1037 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.005;
7932 for (int num1038 = 0; (double)num1038 < num1037; num1038++)
7933 {
7934 progress.Set((double)num1038 / num1037);
7935 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(2, 6), genRand.Next(2, 40), 0);
7936 }
7937 if (remixWorldGen)
7938 {
7939 for (int num1039 = 0; num1039 < Main.maxTilesX; num1039++)
7940 {
7941 for (int num1040 = (int)Main.worldSurface + genRand.Next(-1, 3); num1040 < Main.maxTilesY; num1040++)
7942 {
7943 if (Main.tile[num1039, num1040].active())
7944 {
7945 if (Main.tile[num1039, num1040].type == 0)
7946 {
7947 Main.tile[num1039, num1040].type = 1;
7948 }
7949 else if (Main.tile[num1039, num1040].type == 1)
7950 {
7951 Main.tile[num1039, num1040].type = 0;
7952 }
7953 }
7954 }
7955 }
7956 }
7957 });
7959 {
7960 progress.Message = Lang.gen[6].Value;
7961 for (int num1030 = 0; num1030 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2E-05); num1030++)
7962 {
7963 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow), genRand.Next(4, 14), genRand.Next(10, 50), 40);
7964 }
7965 progress.Set(0.25);
7966 if (remixWorldGen)
7967 {
7968 for (int num1031 = 0; num1031 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 7E-05); num1031++)
7969 {
7970 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayer - 25, Main.maxTilesY - 350), genRand.Next(8, 15), genRand.Next(5, 50), 40);
7971 }
7972 }
7973 else
7974 {
7975 for (int num1032 = 0; num1032 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 5E-05); num1032++)
7976 {
7977 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.worldSurfaceHigh + 1), genRand.Next(8, 14), genRand.Next(15, 45), 40);
7978 }
7979 progress.Set(0.5);
7980 for (int num1033 = 0; num1033 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2E-05); num1033++)
7981 {
7982 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh + 1), genRand.Next(8, 15), genRand.Next(5, 50), 40);
7983 }
7984 }
7985 progress.Set(0.75);
7986 for (int num1034 = 5; num1034 < Main.maxTilesX - 5; num1034++)
7987 {
7988 for (int num1035 = 1; (double)num1035 < Main.worldSurface - 1.0; num1035++)
7989 {
7990 if (Main.tile[num1034, num1035].active())
7991 {
7992 for (int num1036 = num1035; num1036 < num1035 + 5; num1036++)
7993 {
7994 if (Main.tile[num1034, num1036].type == 40)
7995 {
7996 Main.tile[num1034, num1036].type = 0;
7997 }
7998 }
7999 break;
8000 }
8001 }
8002 }
8003 });
8005 {
8006 progress.Message = Lang.gen[7].Value;
8008 for (int num1025 = 0; num1025 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0015); num1025++)
8009 {
8010 double value19 = (double)num1025 / ((double)(Main.maxTilesX * Main.maxTilesY) * 0.0015);
8011 progress.Set(value19);
8012 int type14 = -1;
8013 if (genRand.Next(5) == 0)
8014 {
8015 type14 = -2;
8016 }
8017 int num1026 = genRand.Next(0, Main.maxTilesX);
8020 {
8021 while ((double)num1026 < (double)Main.maxTilesX * 0.2 && (double)num1026 > (double)Main.maxTilesX * 0.8 && (double)num1027 < GenVars.worldSurface)
8022 {
8023 num1026 = genRand.Next(0, Main.maxTilesX);
8025 }
8026 }
8027 else
8028 {
8029 while (((num1026 < GenVars.smallHolesBeachAvoidance || num1026 > Main.maxTilesX - GenVars.smallHolesBeachAvoidance) && (double)num1027 < worldSurfaceHigh2) || ((double)num1026 > (double)Main.maxTilesX * 0.45 && (double)num1026 < (double)Main.maxTilesX * 0.55 && (double)num1027 < GenVars.worldSurface))
8030 {
8031 num1026 = genRand.Next(0, Main.maxTilesX);
8033 }
8034 }
8035 int num1028 = genRand.Next(2, 5);
8036 int num1029 = genRand.Next(2, 20);
8037 if (remixWorldGen && (double)num1027 > Main.rockLayer)
8038 {
8039 num1028 = (int)((double)num1028 * 0.8);
8040 num1029 = (int)((double)num1029 * 0.9);
8041 }
8043 num1026 = genRand.Next(0, Main.maxTilesX);
8046 {
8047 num1026 = genRand.Next(0, Main.maxTilesX);
8049 }
8050 num1028 = genRand.Next(8, 15);
8051 num1029 = genRand.Next(7, 30);
8052 if (remixWorldGen && (double)num1027 > Main.rockLayer)
8053 {
8054 num1028 = (int)((double)num1028 * 0.7);
8055 num1029 = (int)((double)num1029 * 0.9);
8056 }
8058 }
8059 });
8061 {
8062 progress.Message = Lang.gen[8].Value;
8063 double worldSurfaceHigh = GenVars.worldSurfaceHigh;
8064 int num1019 = (int)((double)(Main.maxTilesX * Main.maxTilesY) * 3E-05);
8065 if (remixWorldGen)
8066 {
8067 num1019 *= 2;
8068 }
8069 for (int num1020 = 0; num1020 < num1019; num1020++)
8070 {
8071 double value18 = (double)num1020 / (double)num1019;
8072 progress.Set(value18);
8073 if (GenVars.rockLayerHigh <= (double)Main.maxTilesY)
8074 {
8075 int type13 = -1;
8076 if (genRand.Next(6) == 0)
8077 {
8078 type13 = -2;
8079 }
8080 int num1021 = genRand.Next(0, Main.maxTilesX);
8081 int num1022 = genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.rockLayerHigh + 1);
8082 while (((num1021 < GenVars.smallHolesBeachAvoidance || num1021 > Main.maxTilesX - GenVars.smallHolesBeachAvoidance) && (double)num1022 < worldSurfaceHigh) || ((double)num1021 >= (double)Main.maxTilesX * 0.45 && (double)num1021 <= (double)Main.maxTilesX * 0.55 && (double)num1022 < Main.worldSurface))
8083 {
8084 num1021 = genRand.Next(0, Main.maxTilesX);
8086 }
8087 int num1023 = genRand.Next(5, 15);
8088 int num1024 = genRand.Next(30, 200);
8089 if (remixWorldGen)
8090 {
8091 num1023 = (int)((double)num1023 * 1.1);
8092 num1024 = (int)((double)num1024 * 1.9);
8093 }
8095 }
8096 }
8097 });
8099 {
8100 progress.Message = Lang.gen[9].Value;
8101 int num1011 = (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00013);
8102 if (remixWorldGen)
8103 {
8104 num1011 = (int)((double)num1011 * 1.1);
8105 }
8106 for (int num1012 = 0; num1012 < num1011; num1012++)
8107 {
8108 double value17 = (double)num1012 / (double)num1011;
8109 progress.Set(value17);
8110 if (GenVars.rockLayerHigh <= (double)Main.maxTilesY)
8111 {
8112 int type11 = -1;
8113 if (genRand.Next(10) == 0)
8114 {
8115 type11 = -2;
8116 }
8117 int num1013 = genRand.Next(6, 20);
8118 int num1014 = genRand.Next(50, 300);
8119 if (remixWorldGen)
8120 {
8121 num1013 = (int)((double)num1013 * 0.7);
8122 num1014 = (int)((double)num1014 * 0.7);
8123 }
8125 }
8126 }
8127 if (remixWorldGen)
8128 {
8129 num1011 = (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00013 * 0.4);
8130 for (int num1015 = 0; num1015 < num1011; num1015++)
8131 {
8132 if (GenVars.rockLayerHigh <= (double)Main.maxTilesY)
8133 {
8134 int type12 = -1;
8135 if (genRand.Next(10) == 0)
8136 {
8137 type12 = -2;
8138 }
8139 int num1016 = genRand.Next(7, 26);
8140 int steps = genRand.Next(50, 200);
8141 double num1017 = (double)genRand.Next(100, 221) * 0.1;
8142 double num1018 = (double)genRand.Next(-10, 11) * 0.02;
8143 int i5 = genRand.Next(0, Main.maxTilesX);
8144 int j7 = genRand.Next((int)GenVars.rockLayerHigh, Main.maxTilesY);
8145 TileRunner(i5, j7, num1016, steps, type12, addTile: false, num1017, num1018, noYChange: true);
8146 TileRunner(i5, j7, num1016, steps, type12, addTile: false, 0.0 - num1017, 0.0 - num1018, noYChange: true);
8147 }
8148 }
8149 }
8150 });
8152 {
8153 progress.Message = Lang.gen[10].Value;
8154 int num992 = (int)((double)Main.maxTilesX * 0.002);
8155 int num993 = (int)((double)Main.maxTilesX * 0.0007);
8156 int num994 = (int)((double)Main.maxTilesX * 0.0003);
8157 if (remixWorldGen)
8158 {
8159 num992 *= 3;
8160 num993 *= 3;
8161 num994 *= 3;
8162 }
8163 for (int num995 = 0; num995 < num992; num995++)
8164 {
8165 int num996 = genRand.Next(0, Main.maxTilesX);
8166 while (((double)num996 > (double)Main.maxTilesX * 0.45 && (double)num996 < (double)Main.maxTilesX * 0.55) || num996 < GenVars.leftBeachEnd + 20 || num996 > GenVars.rightBeachStart - 20)
8167 {
8168 num996 = genRand.Next(0, Main.maxTilesX);
8169 }
8170 for (int num997 = 0; (double)num997 < GenVars.worldSurfaceHigh; num997++)
8171 {
8172 if (Main.tile[num996, num997].active())
8173 {
8174 TileRunner(num996, num997, genRand.Next(3, 6), genRand.Next(5, 50), -1, addTile: false, (double)genRand.Next(-10, 11) * 0.1, 1.0);
8175 break;
8176 }
8177 }
8178 }
8179 progress.Set(0.2);
8180 for (int num998 = 0; num998 < num993; num998++)
8181 {
8182 int num999 = genRand.Next(0, Main.maxTilesX);
8183 while (((double)num999 > (double)Main.maxTilesX * 0.43 && (double)num999 < (double)Main.maxTilesX * 0.5700000000000001) || num999 < GenVars.leftBeachEnd + 20 || num999 > GenVars.rightBeachStart - 20)
8184 {
8185 num999 = genRand.Next(0, Main.maxTilesX);
8186 }
8187 for (int num1000 = 0; (double)num1000 < GenVars.worldSurfaceHigh; num1000++)
8188 {
8189 if (Main.tile[num999, num1000].active())
8190 {
8191 TileRunner(num999, num1000, genRand.Next(10, 15), genRand.Next(50, 130), -1, addTile: false, (double)genRand.Next(-10, 11) * 0.1, 2.0);
8192 break;
8193 }
8194 }
8195 }
8196 progress.Set(0.4);
8197 for (int num1001 = 0; num1001 < num994; num1001++)
8198 {
8199 int num1002 = genRand.Next(0, Main.maxTilesX);
8200 while (((double)num1002 > (double)Main.maxTilesX * 0.4 && (double)num1002 < (double)Main.maxTilesX * 0.6) || num1002 < GenVars.leftBeachEnd + 20 || num1002 > GenVars.rightBeachStart - 20)
8201 {
8202 num1002 = genRand.Next(0, Main.maxTilesX);
8203 }
8204 for (int num1003 = 0; (double)num1003 < GenVars.worldSurfaceHigh; num1003++)
8205 {
8206 if (Main.tile[num1002, num1003].active())
8207 {
8208 TileRunner(num1002, num1003, genRand.Next(12, 25), genRand.Next(150, 500), -1, addTile: false, (double)genRand.Next(-10, 11) * 0.1, 4.0);
8209 TileRunner(num1002, num1003, genRand.Next(8, 17), genRand.Next(60, 200), -1, addTile: false, (double)genRand.Next(-10, 11) * 0.1, 2.0);
8210 TileRunner(num1002, num1003, genRand.Next(5, 13), genRand.Next(40, 170), -1, addTile: false, (double)genRand.Next(-10, 11) * 0.1, 2.0);
8211 break;
8212 }
8213 }
8214 }
8215 progress.Set(0.6);
8216 for (int num1004 = 0; num1004 < (int)((double)Main.maxTilesX * 0.0004); num1004++)
8217 {
8218 int num1005 = genRand.Next(0, Main.maxTilesX);
8219 while (((double)num1005 > (double)Main.maxTilesX * 0.4 && (double)num1005 < (double)Main.maxTilesX * 0.6) || num1005 < GenVars.leftBeachEnd + 20 || num1005 > GenVars.rightBeachStart - 20)
8220 {
8221 num1005 = genRand.Next(0, Main.maxTilesX);
8222 }
8223 for (int num1006 = 0; (double)num1006 < GenVars.worldSurfaceHigh; num1006++)
8224 {
8225 if (Main.tile[num1005, num1006].active())
8226 {
8227 TileRunner(num1005, num1006, genRand.Next(7, 12), genRand.Next(150, 250), -1, addTile: false, 0.0, 1.0, noYChange: true);
8228 break;
8229 }
8230 }
8231 }
8232 progress.Set(0.8);
8233 double num1007 = (double)Main.maxTilesX / 4200.0;
8234 for (int num1008 = 0; (double)num1008 < 5.0 * num1007; num1008++)
8235 {
8236 try
8237 {
8238 int num1009 = (int)Main.rockLayer;
8239 int num1010 = Main.maxTilesY - 400;
8240 if (num1009 >= num1010)
8241 {
8242 num1009 = num1010 - 1;
8243 }
8245 }
8246 catch
8247 {
8248 }
8249 }
8250 });
8252 {
8254 {
8255 progress.Message = Language.GetTextValue("WorldGeneration.WavyCaves");
8256 double num983 = (double)Main.maxTilesX / 4200.0;
8257 num983 *= num983;
8258 int num984 = (int)(35.0 * num983);
8259 if (Main.remixWorld)
8260 {
8261 num984 /= 3;
8262 }
8263 int num985 = 0;
8264 int num986 = 80;
8265 for (int num987 = 0; num987 < num984; num987++)
8266 {
8267 double num988 = (double)num987 / (double)(num984 - 1);
8268 progress.Set(num988);
8269 int num989 = genRand.Next((int)Main.worldSurface + 100, Main.UnderworldLayer - 100);
8270 int num990 = 0;
8271 while (Math.Abs(num989 - num985) < num986)
8272 {
8273 num990++;
8274 if (num990 > 100)
8275 {
8276 break;
8277 }
8278 num989 = genRand.Next((int)Main.worldSurface + 100, Main.UnderworldLayer - 100);
8279 }
8280 num985 = num989;
8281 int num991 = 80;
8282 int startX = num991 + (int)((double)(Main.maxTilesX - num991 * 2) * num988);
8283 try
8284 {
8285 WavyCaverer(startX, num989, 12 + genRand.Next(3, 6), 0.25 + genRand.NextDouble(), genRand.Next(300, 500), -1);
8286 }
8287 catch
8288 {
8289 }
8290 }
8291 }
8292 });
8294 {
8295 progress.Message = Lang.gen[56].Value;
8296 GenVars.snowTop = (int)Main.worldSurface;
8297 int num975 = GenVars.lavaLine - genRand.Next(160, 200);
8298 int num976 = GenVars.lavaLine;
8299 if (remixWorldGen)
8300 {
8301 num976 = Main.maxTilesY - 250;
8302 num975 = num976 - genRand.Next(160, 200);
8303 }
8306 int num979 = 10;
8307 for (int num980 = 0; num980 <= num976 - 140; num980++)
8308 {
8309 progress.Set((double)num980 / (double)(num976 - 140));
8310 num977 += genRand.Next(-4, 4);
8311 num978 += genRand.Next(-3, 5);
8312 if (num980 > 0)
8313 {
8314 num977 = (num977 + GenVars.snowMinX[num980 - 1]) / 2;
8315 num978 = (num978 + GenVars.snowMaxX[num980 - 1]) / 2;
8316 }
8317 if (GenVars.dungeonSide > 0)
8318 {
8319 if (genRand.Next(4) == 0)
8320 {
8321 num977++;
8322 num978++;
8323 }
8324 }
8325 else if (genRand.Next(4) == 0)
8326 {
8327 num977--;
8328 num978--;
8329 }
8332 for (int num981 = num977; num981 < num978; num981++)
8333 {
8334 if (num980 < num975)
8335 {
8336 if (Main.tile[num981, num980].wall == 2)
8337 {
8338 Main.tile[num981, num980].wall = 40;
8339 }
8340 switch (Main.tile[num981, num980].type)
8341 {
8342 case 0:
8343 case 2:
8344 case 23:
8345 case 40:
8346 case 53:
8347 Main.tile[num981, num980].type = 147;
8348 break;
8349 case 1:
8350 Main.tile[num981, num980].type = 161;
8351 break;
8352 }
8353 }
8354 else
8355 {
8356 num979 += genRand.Next(-3, 4);
8357 if (genRand.Next(3) == 0)
8358 {
8359 num979 += genRand.Next(-4, 5);
8360 if (genRand.Next(3) == 0)
8361 {
8362 num979 += genRand.Next(-6, 7);
8363 }
8364 }
8365 if (num979 < 0)
8366 {
8367 num979 = genRand.Next(3);
8368 }
8369 else if (num979 > 50)
8370 {
8371 num979 = 50 - genRand.Next(3);
8372 }
8373 for (int num982 = num980; num982 < num980 + num979; num982++)
8374 {
8375 if (Main.tile[num981, num982].wall == 2)
8376 {
8377 Main.tile[num981, num982].wall = 40;
8378 }
8379 switch (Main.tile[num981, num982].type)
8380 {
8381 case 0:
8382 case 2:
8383 case 23:
8384 case 40:
8385 case 53:
8386 Main.tile[num981, num982].type = 147;
8387 break;
8388 case 1:
8389 Main.tile[num981, num982].type = 161;
8390 break;
8391 }
8392 }
8393 }
8394 }
8396 {
8397 GenVars.snowBottom = num980;
8398 }
8399 }
8400 });
8402 {
8403 double num971 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.002;
8404 for (int num972 = 0; (double)num972 < num971; num972++)
8405 {
8406 progress.Set((double)num972 / num971);
8407 int num973 = genRand.Next(1, Main.maxTilesX - 1);
8409 if (num974 >= Main.maxTilesY)
8410 {
8411 num974 = Main.maxTilesY - 2;
8412 }
8413 if (Main.tile[num973 - 1, num974].active() && Main.tile[num973 - 1, num974].type == 0 && Main.tile[num973 + 1, num974].active() && Main.tile[num973 + 1, num974].type == 0 && Main.tile[num973, num974 - 1].active() && Main.tile[num973, num974 - 1].type == 0 && Main.tile[num973, num974 + 1].active() && Main.tile[num973, num974 + 1].type == 0)
8414 {
8415 Main.tile[num973, num974].active(active: true);
8416 Main.tile[num973, num974].type = 2;
8417 }
8418 num973 = genRand.Next(1, Main.maxTilesX - 1);
8419 num974 = genRand.Next(0, (int)GenVars.worldSurfaceLow);
8420 if (num974 >= Main.maxTilesY)
8421 {
8422 num974 = Main.maxTilesY - 2;
8423 }
8424 if (Main.tile[num973 - 1, num974].active() && Main.tile[num973 - 1, num974].type == 0 && Main.tile[num973 + 1, num974].active() && Main.tile[num973 + 1, num974].type == 0 && Main.tile[num973, num974 - 1].active() && Main.tile[num973, num974 - 1].type == 0 && Main.tile[num973, num974 + 1].active() && Main.tile[num973, num974 + 1].type == 0)
8425 {
8426 Main.tile[num973, num974].active(active: true);
8427 Main.tile[num973, num974].type = 2;
8428 }
8429 }
8430 });
8433 {
8434 progress.Message = Lang.gen[77].Value;
8435 NotTheBees();
8436 for (int num966 = 0; num966 < Main.maxTilesX; num966++)
8437 {
8438 for (int num967 = 0; num967 < Main.maxTilesY; num967++)
8439 {
8440 if (Main.tile[num966, num967].active())
8441 {
8442 grassSpread = 0;
8443 SpreadGrass(num966, num967, 59, 60);
8444 }
8445 progress.Set(0.2 * ((double)(num966 * Main.maxTilesY + num967) / (double)(Main.maxTilesX * Main.maxTilesY)));
8446 }
8447 }
8450 double num968 = Main.maxTilesX - 20;
8451 for (int num969 = 10; num969 < Main.maxTilesX - 10; num969++)
8452 {
8454 double num970 = (double)(num969 - 10) / num968;
8455 progress.Set(0.2 + num970 * 0.8);
8456 }
8457 });
8459 {
8460 progress.Message = Lang.gen[78].Value;
8461 Main.tileSolid[484] = false;
8462 int num958 = 0;
8464 int num960 = Main.maxTilesX / 2;
8465 int num961 = genRand.Next(num960) / 8;
8466 num961 += num960 / 8;
8467 int x16 = num960 + num961 * -num959;
8468 int num962 = 0;
8470 while (!desertBiome.Place(new Point(x16, (int)GenVars.worldSurfaceHigh + 25), GenVars.structures))
8471 {
8472 num961 = genRand.Next(num960) / 2;
8473 num961 += num960 / 8;
8474 num961 += genRand.Next(num962 / 12);
8475 x16 = num960 + num961 * -num959;
8476 if (++num962 > Main.maxTilesX / 4)
8477 {
8478 num959 *= -1;
8479 num962 = 0;
8480 num958++;
8481 if (num958 >= 2)
8482 {
8483 GenVars.skipDesertTileCheck = true;
8484 }
8485 }
8486 }
8487 if (remixWorldGen)
8488 {
8489 for (int num963 = 50; num963 < Main.maxTilesX - 50; num963++)
8490 {
8491 for (int num964 = (int)Main.rockLayer + genRand.Next(-1, 2); num964 < Main.maxTilesY - 50; num964++)
8492 {
8493 if ((Main.tile[num963, num964].type == 396 || Main.tile[num963, num964].type == 397 || Main.tile[num963, num964].type == 53) && !SolidTile(num963, num964 - 1))
8494 {
8495 for (int num965 = num964; num965 < num964 + genRand.Next(4, 7) && Main.tile[num963, num965 + 1].active() && (Main.tile[num963, num965].type == 396 || Main.tile[num963, num965].type == 397); num965++)
8496 {
8497 Main.tile[num963, num965].type = 53;
8498 }
8499 }
8500 }
8501 }
8502 }
8503 });
8505 {
8506 GenVars.numIslandHouses = 0;
8507 GenVars.skyIslandHouseCount = 0;
8508 progress.Message = Lang.gen[12].Value;
8509 int num948 = (int)((double)Main.maxTilesX * 0.0008);
8510 int num949 = 0;
8511 double num950 = num948 + GenVars.skyLakes;
8512 for (int num951 = 0; (double)num951 < num950; num951++)
8513 {
8514 progress.Set((double)num951 / num950);
8515 int num952 = Main.maxTilesX;
8516 while (--num952 > 0)
8517 {
8518 bool flag57 = true;
8519 int num953 = genRand.Next((int)((double)Main.maxTilesX * 0.1), (int)((double)Main.maxTilesX * 0.9));
8520 while (num953 > Main.maxTilesX / 2 - 150 && num953 < Main.maxTilesX / 2 + 150)
8521 {
8522 num953 = genRand.Next((int)((double)Main.maxTilesX * 0.1), (int)((double)Main.maxTilesX * 0.9));
8523 }
8524 for (int num954 = 0; num954 < GenVars.numIslandHouses; num954++)
8525 {
8527 {
8528 flag57 = false;
8529 break;
8530 }
8531 }
8532 if (flag57)
8533 {
8534 flag57 = false;
8535 int num955 = 0;
8536 for (int num956 = 200; (double)num956 < Main.worldSurface; num956++)
8537 {
8538 if (Main.tile[num953, num956].active())
8539 {
8540 num955 = num956;
8541 flag57 = true;
8542 break;
8543 }
8544 }
8545 if (flag57)
8546 {
8547 int num957 = 0;
8548 num952 = -1;
8549 int val = genRand.Next(90, num955 - 100);
8550 val = Math.Min(val, (int)GenVars.worldSurfaceLow - 50);
8551 if (num949 >= num948)
8552 {
8554 CloudLake(num953, val);
8555 }
8556 else
8557 {
8560 {
8561 if (genRand.Next(2) == 0)
8562 {
8563 num957 = 3;
8564 SnowCloudIsland(num953, val);
8565 }
8566 else
8567 {
8568 num957 = 1;
8570 }
8571 }
8572 else
8573 {
8575 {
8576 num957 = ((GenVars.crimsonLeft && num953 < Main.maxTilesX / 2) ? 5 : ((GenVars.crimsonLeft || num953 <= Main.maxTilesX / 2) ? 4 : 5));
8577 }
8578 else if (getGoodWorldGen || remixWorldGen)
8579 {
8580 num957 = ((!crimson) ? 4 : 5);
8581 }
8582 else if (Main.tenthAnniversaryWorld)
8583 {
8584 num957 = 6;
8585 }
8586 CloudIsland(num953, val);
8587 }
8588 }
8593 num949++;
8594 }
8595 }
8596 }
8597 }
8598 });
8600 {
8601 //IL_0287: Unknown result type (might be due to invalid IL or missing references)
8602 //IL_0292: Unknown result type (might be due to invalid IL or missing references)
8603 progress.Message = Lang.gen[13].Value;
8604 if (remixWorldGen)
8605 {
8606 for (int num927 = 10; num927 < Main.maxTilesX - 10; num927++)
8607 {
8608 for (int num928 = Main.maxTilesY + genRand.Next(3) - 350; num928 < Main.maxTilesY - 10; num928++)
8609 {
8610 if (Main.tile[num927, num928].type == 0)
8611 {
8612 Main.tile[num927, num928].type = 59;
8613 }
8614 }
8615 }
8616 }
8617 double num929 = (double)Main.maxTilesX / 700.0;
8618 if (num929 > (double)GenVars.maxMushroomBiomes)
8619 {
8621 }
8622 for (int num930 = 0; (double)num930 < num929; num930++)
8623 {
8624 int num931 = 0;
8625 bool flag56 = true;
8626 while (flag56)
8627 {
8628 int num932 = genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8));
8629 if (num931 > Main.maxTilesX / 4)
8630 {
8631 num932 = genRand.Next((int)((double)Main.maxTilesX * 0.25), (int)((double)Main.maxTilesX * 0.975));
8632 }
8633 int num933 = ((!remixWorldGen) ? genRand.Next((int)Main.rockLayer + 50, Main.maxTilesY - 300) : genRand.Next((int)Main.worldSurface + 50, (int)Main.rockLayer - 50));
8634 flag56 = false;
8635 int num934 = 100;
8636 int num935 = 500;
8637 for (int num936 = num932 - num934; num936 < num932 + num934; num936 += 3)
8638 {
8639 for (int num937 = num933 - num934; num937 < num933 + num934; num937 += 3)
8640 {
8641 if (InWorld(num936, num937))
8642 {
8643 if (Main.tile[num936, num937].type == 147 || Main.tile[num936, num937].type == 161 || Main.tile[num936, num937].type == 162 || Main.tile[num936, num937].type == 60 || Main.tile[num936, num937].type == 368 || Main.tile[num936, num937].type == 367)
8644 {
8645 flag56 = true;
8646 break;
8647 }
8649 {
8650 flag56 = true;
8651 break;
8652 }
8653 }
8654 else
8655 {
8656 flag56 = true;
8657 }
8658 }
8659 }
8660 if (!flag56)
8661 {
8662 for (int num938 = 0; num938 < GenVars.numMushroomBiomes; num938++)
8663 {
8664 if (Vector2D.Distance(GenVars.mushroomBiomesPosition[num938].ToVector2D(), new Vector2D((double)num932, (double)num933)) < (double)num935)
8665 {
8666 flag56 = true;
8667 }
8668 }
8669 }
8671 {
8673 for (int num939 = 0; num939 < 5; num939++)
8674 {
8675 int i4 = num932 + genRand.Next(-40, 41);
8676 int j6 = num933 + genRand.Next(-40, 41);
8677 ShroomPatch(i4, j6);
8678 }
8682 }
8683 num931++;
8684 if (num931 > Main.maxTilesX / 2)
8685 {
8686 break;
8687 }
8688 }
8689 }
8690 for (int num940 = 0; num940 < Main.maxTilesX; num940++)
8691 {
8692 progress.Set((double)num940 / (double)Main.maxTilesX);
8693 for (int num941 = (int)Main.worldSurface; num941 < Main.maxTilesY; num941++)
8694 {
8695 if (InWorld(num940, num941, 50) && Main.tile[num940, num941].active())
8696 {
8697 grassSpread = 0;
8698 SpreadGrass(num940, num941, 59, 70, repeat: false);
8699 }
8700 }
8701 }
8702 for (int num942 = 0; num942 < Main.maxTilesX; num942++)
8703 {
8704 for (int num943 = (int)Main.worldSurface; num943 < Main.maxTilesY; num943++)
8705 {
8706 if (Main.tile[num942, num943].active() && Main.tile[num942, num943].type == 70)
8707 {
8708 int type10 = 59;
8709 for (int num944 = num942 - 1; num944 <= num942 + 1; num944++)
8710 {
8711 for (int num945 = num943 - 1; num945 <= num943 + 1; num945++)
8712 {
8713 if (Main.tile[num944, num945].active())
8714 {
8715 if (!Main.tile[num944 - 1, num945].active() && !Main.tile[num944 + 1, num945].active())
8716 {
8718 }
8719 else if (!Main.tile[num944, num945 - 1].active() && !Main.tile[num944, num945 + 1].active())
8720 {
8722 }
8723 }
8724 else if (Main.tile[num944 - 1, num945].active() && Main.tile[num944 + 1, num945].active())
8725 {
8727 if (Main.tile[num944 - 1, num943].type == 70)
8728 {
8729 Main.tile[num944 - 1, num943].type = 59;
8730 }
8731 if (Main.tile[num944 + 1, num943].type == 70)
8732 {
8733 Main.tile[num944 + 1, num943].type = 59;
8734 }
8735 }
8736 else if (Main.tile[num944, num945 - 1].active() && Main.tile[num944, num945 + 1].active())
8737 {
8739 if (Main.tile[num944, num943 - 1].type == 70)
8740 {
8741 Main.tile[num944, num943 - 1].type = 59;
8742 }
8743 if (Main.tile[num944, num943 + 1].type == 70)
8744 {
8745 Main.tile[num944, num943 + 1].type = 59;
8746 }
8747 }
8748 }
8749 }
8750 if (genRand.Next(4) == 0)
8751 {
8752 int num946 = num942 + genRand.Next(-20, 21);
8753 int num947 = num943 + genRand.Next(-20, 21);
8754 if (InWorld(num946, num947) && Main.tile[num946, num947].type == 59)
8755 {
8756 Main.tile[num946, num947].type = 70;
8757 }
8758 }
8759 }
8760 }
8761 }
8762 });
8764 {
8765 progress.Message = Lang.gen[80].Value;
8766 int num922 = passConfig.Get<WorldGenRange>("Count").GetRandom(genRand);
8767 double num923 = (double)(Main.maxTilesX - 160) / (double)num922;
8769 int num924 = 0;
8770 int num925 = 0;
8771 while (num925 < num922)
8772 {
8773 double num926 = (double)num925 / (double)num922;
8774 progress.Set(num926);
8775 Point origin4 = RandomRectanglePoint((int)(num926 * (double)(Main.maxTilesX - 160)) + 80, (int)GenVars.rockLayer + 20, (int)num923, Main.maxTilesY - ((int)GenVars.rockLayer + 40) - 200);
8776 if (remixWorldGen)
8777 {
8778 origin4 = RandomRectanglePoint((int)(num926 * (double)(Main.maxTilesX - 160)) + 80, (int)GenVars.worldSurface + 100, (int)num923, (int)GenVars.rockLayer - (int)GenVars.worldSurface - 100);
8779 }
8780 while ((double)origin4.X > (double)Main.maxTilesX * 0.45 && (double)origin4.X < (double)Main.maxTilesX * 0.55)
8781 {
8782 origin4.X = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
8783 }
8784 num924++;
8786 {
8787 num925++;
8788 num924 = 0;
8789 }
8790 else if (num924 > Main.maxTilesX * 10)
8791 {
8792 num922 = num925;
8793 num925++;
8794 num924 = 0;
8795 }
8796 }
8797 });
8799 {
8800 progress.Message = Lang.gen[81].Value;
8801 int num916 = passConfig.Get<WorldGenRange>("Count").GetRandom(genRand);
8802 double num917 = (double)(Main.maxTilesX - 200) / (double)num916;
8804 int num918 = 0;
8805 int num919 = 0;
8806 while (num919 < num916)
8807 {
8808 double num920 = (double)num919 / (double)num916;
8809 progress.Set(num920);
8810 Point point3 = RandomRectanglePoint((int)(num920 * (double)(Main.maxTilesX - 200)) + 100, (int)GenVars.rockLayer + 20, (int)num917, Main.maxTilesY - ((int)GenVars.rockLayer + 40) - 200);
8811 if (remixWorldGen)
8812 {
8813 point3 = RandomRectanglePoint((int)(num920 * (double)(Main.maxTilesX - 200)) + 100, (int)GenVars.worldSurface + 100, (int)num917, (int)GenVars.rockLayer - (int)GenVars.worldSurface - 100);
8814 }
8815 while ((double)point3.X > (double)Main.maxTilesX * 0.45 && (double)point3.X < (double)Main.maxTilesX * 0.55)
8816 {
8817 point3.X = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
8818 }
8819 num918++;
8821 {
8822 list2.Add(point3);
8823 num919++;
8824 }
8825 else if (num918 > Main.maxTilesX * 10)
8826 {
8827 num916 = num919;
8828 num919++;
8829 num918 = 0;
8830 }
8831 }
8833 for (int num921 = 0; num921 < num916; num921++)
8834 {
8836 }
8837 });
8839 {
8840 progress.Message = Lang.gen[14].Value;
8841 double num914 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.001;
8842 for (int num915 = 0; (double)num915 < num914; num915++)
8843 {
8844 progress.Set((double)num915 / num914);
8845 if (remixWorldGen)
8846 {
8847 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.worldSurface, (int)GenVars.rockLayerLow), genRand.Next(2, 6), genRand.Next(2, 40), 59, addTile: false, 0.0, 0.0, noYChange: false, overRide: true, 53);
8848 }
8849 else
8850 {
8851 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(2, 6), genRand.Next(2, 40), 59, addTile: false, 0.0, 0.0, noYChange: false, overRide: true, 53);
8852 }
8853 }
8854 });
8856 {
8857 progress.Message = Lang.gen[15].Value;
8858 for (int num908 = 0; num908 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0001); num908++)
8859 {
8860 int num909 = genRand.Next(0, Main.maxTilesX);
8862 if (remixWorldGen)
8863 {
8864 num910 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
8865 }
8866 if (Main.tile[num909, num910].wall != 187 && Main.tile[num909, num910].wall != 216)
8867 {
8868 TileRunner(num909, num910, genRand.Next(5, 12), genRand.Next(15, 50), 123);
8869 }
8870 }
8871 for (int num911 = 0; num911 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0005); num911++)
8872 {
8873 int num912 = genRand.Next(0, Main.maxTilesX);
8875 if (remixWorldGen)
8876 {
8877 num913 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
8878 }
8879 if (Main.tile[num912, num913].wall != 187 && Main.tile[num912, num913].wall != 216)
8880 {
8881 TileRunner(num912, num913, genRand.Next(2, 5), genRand.Next(2, 5), 123);
8882 }
8883 }
8884 });
8886 {
8887 progress.Message = Lang.gen[16].Value;
8888 if (remixWorldGen)
8889 {
8890 for (int num878 = 0; num878 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); num878++)
8891 {
8892 if (drunkWorldGen)
8893 {
8894 if (genRand.Next(2) == 0)
8895 {
8896 GenVars.copper = 7;
8897 }
8898 else
8899 {
8900 GenVars.copper = 166;
8901 }
8902 }
8904 }
8905 for (int num879 = 0; num879 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 8E-05); num879++)
8906 {
8907 if (drunkWorldGen)
8908 {
8909 if (genRand.Next(2) == 0)
8910 {
8911 GenVars.copper = 7;
8912 }
8913 else
8914 {
8915 GenVars.copper = 166;
8916 }
8917 }
8918 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh), genRand.Next(3, 7), genRand.Next(3, 7), GenVars.copper);
8919 }
8920 for (int num880 = 0; num880 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0002); num880++)
8921 {
8922 if (drunkWorldGen)
8923 {
8924 if (genRand.Next(2) == 0)
8925 {
8926 GenVars.copper = 7;
8927 }
8928 else
8929 {
8930 GenVars.copper = 166;
8931 }
8932 }
8933 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.copper);
8934 }
8935 for (int num881 = 0; num881 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 3E-05); num881++)
8936 {
8937 if (drunkWorldGen)
8938 {
8939 if (genRand.Next(2) == 0)
8940 {
8941 GenVars.iron = 6;
8942 }
8943 else
8944 {
8945 GenVars.iron = 167;
8946 }
8947 }
8948 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.worldSurfaceHigh), genRand.Next(3, 7), genRand.Next(2, 5), GenVars.iron);
8949 }
8950 for (int num882 = 0; num882 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 8E-05); num882++)
8951 {
8952 if (drunkWorldGen)
8953 {
8954 if (genRand.Next(2) == 0)
8955 {
8956 GenVars.iron = 6;
8957 }
8958 else
8959 {
8960 GenVars.iron = 167;
8961 }
8962 }
8963 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh), genRand.Next(3, 6), genRand.Next(3, 6), GenVars.iron);
8964 }
8965 for (int num883 = 0; num883 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0002); num883++)
8966 {
8967 if (drunkWorldGen)
8968 {
8969 if (genRand.Next(2) == 0)
8970 {
8971 GenVars.iron = 6;
8972 }
8973 else
8974 {
8975 GenVars.iron = 167;
8976 }
8977 }
8978 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.iron);
8979 }
8980 for (int num884 = 0; num884 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.6E-05); num884++)
8981 {
8982 if (drunkWorldGen)
8983 {
8984 if (genRand.Next(2) == 0)
8985 {
8986 GenVars.silver = 9;
8987 }
8988 else
8989 {
8990 GenVars.silver = 168;
8991 }
8992 }
8993 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer - 100, Main.maxTilesY - 250), genRand.Next(3, 6), genRand.Next(3, 6), GenVars.silver);
8994 }
8995 for (int num885 = 0; num885 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00015); num885++)
8996 {
8997 if (drunkWorldGen)
8998 {
8999 if (genRand.Next(2) == 0)
9000 {
9001 GenVars.silver = 9;
9002 }
9003 else
9004 {
9005 GenVars.silver = 168;
9006 }
9007 }
9008 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.worldSurface, (int)Main.rockLayer), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.silver);
9009 }
9010 for (int num886 = 0; num886 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00017); num886++)
9011 {
9012 if (drunkWorldGen)
9013 {
9014 if (genRand.Next(2) == 0)
9015 {
9016 GenVars.silver = 9;
9017 }
9018 else
9019 {
9020 GenVars.silver = 168;
9021 }
9022 }
9023 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.silver);
9024 }
9025 for (int num887 = 0; num887 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00012); num887++)
9026 {
9027 if (drunkWorldGen)
9028 {
9029 if (genRand.Next(2) == 0)
9030 {
9031 GenVars.gold = 8;
9032 }
9033 else
9034 {
9035 GenVars.gold = 169;
9036 }
9037 }
9038 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.worldSurface, (int)Main.rockLayer), genRand.Next(4, 8), genRand.Next(4, 8), GenVars.gold);
9039 }
9040 for (int num888 = 0; num888 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00012); num888++)
9041 {
9042 if (drunkWorldGen)
9043 {
9044 if (genRand.Next(2) == 0)
9045 {
9046 GenVars.gold = 8;
9047 }
9048 else
9049 {
9050 GenVars.gold = 169;
9051 }
9052 }
9053 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow - 20), genRand.Next(4, 8), genRand.Next(4, 8), GenVars.gold);
9054 }
9055 if (drunkWorldGen)
9056 {
9057 for (int num889 = 0; num889 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05 / 2.0); num889++)
9058 {
9059 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 204);
9060 }
9061 for (int num890 = 0; num890 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05 / 2.0); num890++)
9062 {
9063 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 22);
9064 }
9065 }
9066 if (crimson)
9067 {
9068 for (int num891 = 0; num891 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 4.25E-05); num891++)
9069 {
9070 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.worldSurface, (int)Main.rockLayer), genRand.Next(3, 6), genRand.Next(4, 8), 204);
9071 }
9072 }
9073 else
9074 {
9075 for (int num892 = 0; num892 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 4.25E-05); num892++)
9076 {
9077 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.worldSurface, (int)Main.rockLayer), genRand.Next(3, 6), genRand.Next(4, 8), 22);
9078 }
9079 }
9080 }
9081 else
9082 {
9083 for (int num893 = 0; num893 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); num893++)
9084 {
9085 if (drunkWorldGen)
9086 {
9087 if (genRand.Next(2) == 0)
9088 {
9089 GenVars.copper = 7;
9090 }
9091 else
9092 {
9093 GenVars.copper = 166;
9094 }
9095 }
9097 }
9098 for (int num894 = 0; num894 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 8E-05); num894++)
9099 {
9100 if (drunkWorldGen)
9101 {
9102 if (genRand.Next(2) == 0)
9103 {
9104 GenVars.copper = 7;
9105 }
9106 else
9107 {
9108 GenVars.copper = 166;
9109 }
9110 }
9111 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh), genRand.Next(3, 7), genRand.Next(3, 7), GenVars.copper);
9112 }
9113 for (int num895 = 0; num895 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0002); num895++)
9114 {
9115 if (drunkWorldGen)
9116 {
9117 if (genRand.Next(2) == 0)
9118 {
9119 GenVars.copper = 7;
9120 }
9121 else
9122 {
9123 GenVars.copper = 166;
9124 }
9125 }
9126 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.copper);
9127 }
9128 for (int num896 = 0; num896 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 3E-05); num896++)
9129 {
9130 if (drunkWorldGen)
9131 {
9132 if (genRand.Next(2) == 0)
9133 {
9134 GenVars.iron = 6;
9135 }
9136 else
9137 {
9138 GenVars.iron = 167;
9139 }
9140 }
9141 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.worldSurfaceHigh), genRand.Next(3, 7), genRand.Next(2, 5), GenVars.iron);
9142 }
9143 for (int num897 = 0; num897 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 8E-05); num897++)
9144 {
9145 if (drunkWorldGen)
9146 {
9147 if (genRand.Next(2) == 0)
9148 {
9149 GenVars.iron = 6;
9150 }
9151 else
9152 {
9153 GenVars.iron = 167;
9154 }
9155 }
9156 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh), genRand.Next(3, 6), genRand.Next(3, 6), GenVars.iron);
9157 }
9158 for (int num898 = 0; num898 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0002); num898++)
9159 {
9160 if (drunkWorldGen)
9161 {
9162 if (genRand.Next(2) == 0)
9163 {
9164 GenVars.iron = 6;
9165 }
9166 else
9167 {
9168 GenVars.iron = 167;
9169 }
9170 }
9171 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.iron);
9172 }
9173 for (int num899 = 0; num899 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.6E-05); num899++)
9174 {
9175 if (drunkWorldGen)
9176 {
9177 if (genRand.Next(2) == 0)
9178 {
9179 GenVars.silver = 9;
9180 }
9181 else
9182 {
9183 GenVars.silver = 168;
9184 }
9185 }
9186 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.worldSurfaceHigh, (int)GenVars.rockLayerHigh), genRand.Next(3, 6), genRand.Next(3, 6), GenVars.silver);
9187 }
9188 for (int num900 = 0; num900 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00015); num900++)
9189 {
9190 if (drunkWorldGen)
9191 {
9192 if (genRand.Next(2) == 0)
9193 {
9194 GenVars.silver = 9;
9195 }
9196 else
9197 {
9198 GenVars.silver = 168;
9199 }
9200 }
9201 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.silver);
9202 }
9203 for (int num901 = 0; num901 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00017); num901++)
9204 {
9205 if (drunkWorldGen)
9206 {
9207 if (genRand.Next(2) == 0)
9208 {
9209 GenVars.silver = 9;
9210 }
9211 else
9212 {
9213 GenVars.silver = 168;
9214 }
9215 }
9216 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow), genRand.Next(4, 9), genRand.Next(4, 8), GenVars.silver);
9217 }
9218 for (int num902 = 0; num902 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00012); num902++)
9219 {
9220 if (drunkWorldGen)
9221 {
9222 if (genRand.Next(2) == 0)
9223 {
9224 GenVars.gold = 8;
9225 }
9226 else
9227 {
9228 GenVars.gold = 169;
9229 }
9230 }
9231 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY), genRand.Next(4, 8), genRand.Next(4, 8), GenVars.gold);
9232 }
9233 for (int num903 = 0; num903 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.00012); num903++)
9234 {
9235 if (drunkWorldGen)
9236 {
9237 if (genRand.Next(2) == 0)
9238 {
9239 GenVars.gold = 8;
9240 }
9241 else
9242 {
9243 GenVars.gold = 169;
9244 }
9245 }
9246 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(0, (int)GenVars.worldSurfaceLow - 20), genRand.Next(4, 8), genRand.Next(4, 8), GenVars.gold);
9247 }
9248 if (drunkWorldGen)
9249 {
9250 for (int num904 = 0; num904 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05 / 2.0); num904++)
9251 {
9252 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 204);
9253 }
9254 for (int num905 = 0; num905 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05 / 2.0); num905++)
9255 {
9256 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 22);
9257 }
9258 }
9259 if (crimson)
9260 {
9261 for (int num906 = 0; num906 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05); num906++)
9262 {
9263 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 204);
9264 }
9265 }
9266 else
9267 {
9268 for (int num907 = 0; num907 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 2.25E-05); num907++)
9269 {
9270 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next((int)Main.rockLayer, Main.maxTilesY), genRand.Next(3, 6), genRand.Next(4, 8), 22);
9271 }
9272 }
9273 }
9274 });
9276 {
9277 progress.Message = Lang.gen[17].Value;
9278 for (int num874 = 0; num874 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0006); num874++)
9279 {
9280 int num875 = genRand.Next(20, Main.maxTilesX - 20);
9281 int num876 = genRand.Next((int)GenVars.worldSurfaceHigh, Main.maxTilesY - 20);
9282 if (num874 < GenVars.numMCaves)
9283 {
9286 }
9287 if (!Main.tile[num875, num876].active() && ((double)num876 > Main.worldSurface || Main.tile[num875, num876].wall > 0))
9288 {
9289 while (!Main.tile[num875, num876].active() && num876 > (int)GenVars.worldSurfaceLow)
9290 {
9291 num876--;
9292 }
9293 num876++;
9294 int num877 = 1;
9295 if (genRand.Next(2) == 0)
9296 {
9297 num877 = -1;
9298 }
9299 for (; !Main.tile[num875, num876].active() && num875 > 10 && num875 < Main.maxTilesX - 10; num875 += num877)
9300 {
9301 }
9302 num875 -= num877;
9303 if ((double)num876 > Main.worldSurface || Main.tile[num875, num876].wall > 0)
9304 {
9305 TileRunner(num875, num876, genRand.Next(4, 11), genRand.Next(2, 4), 51, addTile: true, num877, -1.0, noYChange: false, overRide: false);
9306 }
9307 }
9308 }
9309 });
9311 {
9312 progress.Message = Lang.gen[18].Value;
9313 progress.Set(0.0);
9314 int num838 = Main.maxTilesY - genRand.Next(150, 190);
9315 for (int num839 = 0; num839 < Main.maxTilesX; num839++)
9316 {
9317 num838 += genRand.Next(-3, 4);
9318 if (num838 < Main.maxTilesY - 190)
9319 {
9320 num838 = Main.maxTilesY - 190;
9321 }
9322 if (num838 > Main.maxTilesY - 160)
9323 {
9324 num838 = Main.maxTilesY - 160;
9325 }
9326 for (int num840 = num838 - 20 - genRand.Next(3); num840 < Main.maxTilesY; num840++)
9327 {
9328 if (num840 >= num838)
9329 {
9330 Main.tile[num839, num840].active(active: false);
9331 Main.tile[num839, num840].lava(lava: false);
9332 Main.tile[num839, num840].liquid = 0;
9333 }
9334 else
9335 {
9336 Main.tile[num839, num840].type = 57;
9337 }
9338 }
9339 }
9340 int num841 = Main.maxTilesY - genRand.Next(40, 70);
9341 for (int num842 = 10; num842 < Main.maxTilesX - 10; num842++)
9342 {
9343 num841 += genRand.Next(-10, 11);
9344 if (num841 > Main.maxTilesY - 60)
9345 {
9346 num841 = Main.maxTilesY - 60;
9347 }
9348 if (num841 < Main.maxTilesY - 100)
9349 {
9350 num841 = Main.maxTilesY - 120;
9351 }
9352 for (int num843 = num841; num843 < Main.maxTilesY - 10; num843++)
9353 {
9354 if (!Main.tile[num842, num843].active())
9355 {
9356 Main.tile[num842, num843].lava(lava: true);
9357 Main.tile[num842, num843].liquid = byte.MaxValue;
9358 }
9359 }
9360 }
9361 for (int num844 = 0; num844 < Main.maxTilesX; num844++)
9362 {
9363 if (genRand.Next(50) == 0)
9364 {
9365 int num845 = Main.maxTilesY - 65;
9366 while (!Main.tile[num844, num845].active() && num845 > Main.maxTilesY - 135)
9367 {
9368 num845--;
9369 }
9370 TileRunner(genRand.Next(0, Main.maxTilesX), num845 + genRand.Next(20, 50), genRand.Next(15, 20), 1000, 57, addTile: true, 0.0, genRand.Next(1, 3), noYChange: true);
9371 }
9372 }
9373 Liquid.QuickWater(-2);
9374 for (int num846 = 0; num846 < Main.maxTilesX; num846++)
9375 {
9376 double num847 = (double)num846 / (double)(Main.maxTilesX - 1);
9377 progress.Set(num847 / 2.0 + 0.5);
9378 if (genRand.Next(13) == 0)
9379 {
9380 int num848 = Main.maxTilesY - 65;
9381 while ((Main.tile[num846, num848].liquid > 0 || Main.tile[num846, num848].active()) && num848 > Main.maxTilesY - 140)
9382 {
9383 num848--;
9384 }
9385 if ((!drunkWorldGen && !remixWorldGen) || genRand.Next(3) == 0 || !((double)num846 > (double)Main.maxTilesX * 0.4) || !((double)num846 < (double)Main.maxTilesX * 0.6))
9386 {
9387 TileRunner(num846, num848 - genRand.Next(2, 5), genRand.Next(5, 30), 1000, 57, addTile: true, 0.0, genRand.Next(1, 3), noYChange: true);
9388 }
9389 double num849 = genRand.Next(1, 3);
9390 if (genRand.Next(3) == 0)
9391 {
9392 num849 *= 0.5;
9393 }
9394 if ((!drunkWorldGen && !remixWorldGen) || genRand.Next(3) == 0 || !((double)num846 > (double)Main.maxTilesX * 0.4) || !((double)num846 < (double)Main.maxTilesX * 0.6))
9395 {
9396 if (genRand.Next(2) == 0)
9397 {
9398 TileRunner(num846, num848 - genRand.Next(2, 5), (int)((double)genRand.Next(5, 15) * num849), (int)((double)genRand.Next(10, 15) * num849), 57, addTile: true, 1.0, 0.3);
9399 }
9400 if (genRand.Next(2) == 0)
9401 {
9402 num849 = genRand.Next(1, 3);
9403 TileRunner(num846, num848 - genRand.Next(2, 5), (int)((double)genRand.Next(5, 15) * num849), (int)((double)genRand.Next(10, 15) * num849), 57, addTile: true, -1.0, 0.3);
9404 }
9405 }
9406 TileRunner(num846 + genRand.Next(-10, 10), num848 + genRand.Next(-10, 10), genRand.Next(5, 15), genRand.Next(5, 10), -2, addTile: false, genRand.Next(-1, 3), genRand.Next(-1, 3));
9407 if (genRand.Next(3) == 0)
9408 {
9409 TileRunner(num846 + genRand.Next(-10, 10), num848 + genRand.Next(-10, 10), genRand.Next(10, 30), genRand.Next(10, 20), -2, addTile: false, genRand.Next(-1, 3), genRand.Next(-1, 3));
9410 }
9411 if (genRand.Next(5) == 0)
9412 {
9413 TileRunner(num846 + genRand.Next(-15, 15), num848 + genRand.Next(-15, 10), genRand.Next(15, 30), genRand.Next(5, 20), -2, addTile: false, genRand.Next(-1, 3), genRand.Next(-1, 3));
9414 }
9415 }
9416 }
9417 for (int num850 = 0; num850 < Main.maxTilesX; num850++)
9418 {
9419 TileRunner(genRand.Next(20, Main.maxTilesX - 20), genRand.Next(Main.maxTilesY - 180, Main.maxTilesY - 10), genRand.Next(2, 7), genRand.Next(2, 7), -2);
9420 }
9422 {
9423 for (int num851 = 0; num851 < Main.maxTilesX * 2; num851++)
9424 {
9425 TileRunner(genRand.Next((int)((double)Main.maxTilesX * 0.35), (int)((double)Main.maxTilesX * 0.65)), genRand.Next(Main.maxTilesY - 180, Main.maxTilesY - 10), genRand.Next(5, 20), genRand.Next(5, 10), -2);
9426 }
9427 }
9428 for (int num852 = 0; num852 < Main.maxTilesX; num852++)
9429 {
9430 if (!Main.tile[num852, Main.maxTilesY - 145].active())
9431 {
9432 Main.tile[num852, Main.maxTilesY - 145].liquid = byte.MaxValue;
9433 Main.tile[num852, Main.maxTilesY - 145].lava(lava: true);
9434 }
9435 if (!Main.tile[num852, Main.maxTilesY - 144].active())
9436 {
9437 Main.tile[num852, Main.maxTilesY - 144].liquid = byte.MaxValue;
9438 Main.tile[num852, Main.maxTilesY - 144].lava(lava: true);
9439 }
9440 }
9441 for (int num853 = 0; num853 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0008); num853++)
9442 {
9443 TileRunner(genRand.Next(0, Main.maxTilesX), genRand.Next(Main.maxTilesY - 140, Main.maxTilesY), genRand.Next(2, 7), genRand.Next(3, 7), 58);
9444 }
9445 if (remixWorldGen)
9446 {
9447 int num854 = (int)((double)Main.maxTilesX * 0.38);
9448 int num855 = (int)((double)Main.maxTilesX * 0.62);
9449 int num856 = num854;
9450 int num857 = Main.maxTilesY - 1;
9451 int num858 = Main.maxTilesY - 135;
9452 int num859 = Main.maxTilesY - 160;
9453 bool flag55 = false;
9454 Liquid.QuickWater(-2);
9455 for (; num857 < Main.maxTilesY - 1 || num856 < num855; num856++)
9456 {
9457 if (!flag55)
9458 {
9459 num857 -= genRand.Next(1, 4);
9460 if (num857 < num858)
9461 {
9462 flag55 = true;
9463 }
9464 }
9465 else if (num856 >= num855)
9466 {
9467 num857 += genRand.Next(1, 4);
9468 if (num857 > Main.maxTilesY - 1)
9469 {
9470 num857 = Main.maxTilesY - 1;
9471 }
9472 }
9473 else
9474 {
9476 {
9477 if (genRand.Next(3) == 0)
9478 {
9479 num857 += genRand.Next(-1, 2);
9480 }
9481 else if (genRand.Next(6) == 0)
9482 {
9483 num857 += genRand.Next(-2, 3);
9484 }
9485 else if (genRand.Next(8) == 0)
9486 {
9487 num857 += genRand.Next(-4, 5);
9488 }
9489 }
9490 if (num857 < num859)
9491 {
9492 num857 = num859;
9493 }
9494 if (num857 > num858)
9495 {
9496 num857 = num858;
9497 }
9498 }
9499 for (int num860 = num857; num860 > num857 - 20; num860--)
9500 {
9501 Main.tile[num856, num860].liquid = 0;
9502 }
9503 for (int num861 = num857; num861 < Main.maxTilesY; num861++)
9504 {
9505 Main.tile[num856, num861] = new Tile();
9506 Main.tile[num856, num861].active(active: true);
9507 Main.tile[num856, num861].type = 57;
9508 }
9509 }
9510 Liquid.QuickWater(-2);
9511 for (int num862 = num854; num862 < num855 + 15; num862++)
9512 {
9513 for (int num863 = Main.maxTilesY - 300; num863 < num858 + 20; num863++)
9514 {
9515 Main.tile[num862, num863].liquid = 0;
9516 if (Main.tile[num862, num863].type == 57 && Main.tile[num862, num863].active() && (!Main.tile[num862 - 1, num863 - 1].active() || !Main.tile[num862, num863 - 1].active() || !Main.tile[num862 + 1, num863 - 1].active() || !Main.tile[num862 - 1, num863].active() || !Main.tile[num862 + 1, num863].active() || !Main.tile[num862 - 1, num863 + 1].active() || !Main.tile[num862, num863 + 1].active() || !Main.tile[num862 + 1, num863 + 1].active()))
9517 {
9518 Main.tile[num862, num863].type = 633;
9519 }
9520 }
9521 }
9522 for (int num864 = num854; num864 < num855 + 15; num864++)
9523 {
9524 for (int num865 = Main.maxTilesY - 200; num865 < num858 + 20; num865++)
9525 {
9526 if (Main.tile[num864, num865].type == 633 && Main.tile[num864, num865].active() && !Main.tile[num864, num865 - 1].active() && genRand.Next(3) == 0)
9527 {
9529 }
9530 }
9531 }
9532 }
9533 else if (!drunkWorldGen)
9534 {
9535 for (int num866 = 25; num866 < Main.maxTilesX - 25; num866++)
9536 {
9537 if ((double)num866 < (double)Main.maxTilesX * 0.17 || (double)num866 > (double)Main.maxTilesX * 0.83)
9538 {
9539 for (int num867 = Main.maxTilesY - 300; num867 < Main.maxTilesY - 100 + genRand.Next(-1, 2); num867++)
9540 {
9541 if (Main.tile[num866, num867].type == 57 && Main.tile[num866, num867].active() && (!Main.tile[num866 - 1, num867 - 1].active() || !Main.tile[num866, num867 - 1].active() || !Main.tile[num866 + 1, num867 - 1].active() || !Main.tile[num866 - 1, num867].active() || !Main.tile[num866 + 1, num867].active() || !Main.tile[num866 - 1, num867 + 1].active() || !Main.tile[num866, num867 + 1].active() || !Main.tile[num866 + 1, num867 + 1].active()))
9542 {
9543 Main.tile[num866, num867].type = 633;
9544 }
9545 }
9546 }
9547 }
9548 for (int num868 = 25; num868 < Main.maxTilesX - 25; num868++)
9549 {
9550 if ((double)num868 < (double)Main.maxTilesX * 0.17 || (double)num868 > (double)Main.maxTilesX * 0.83)
9551 {
9552 for (int num869 = Main.maxTilesY - 200; num869 < Main.maxTilesY - 50; num869++)
9553 {
9554 if (Main.tile[num868, num869].type == 633 && Main.tile[num868, num869].active() && !Main.tile[num868, num869 - 1].active() && genRand.Next(3) == 0)
9555 {
9557 }
9558 }
9559 }
9560 }
9561 }
9562 AddHellHouses();
9563 if (drunkWorldGen)
9564 {
9565 for (int num870 = 25; num870 < Main.maxTilesX - 25; num870++)
9566 {
9567 for (int num871 = Main.maxTilesY - 300; num871 < Main.maxTilesY - 100 + genRand.Next(-1, 2); num871++)
9568 {
9569 if (Main.tile[num870, num871].type == 57 && Main.tile[num870, num871].active() && (!Main.tile[num870 - 1, num871 - 1].active() || !Main.tile[num870, num871 - 1].active() || !Main.tile[num870 + 1, num871 - 1].active() || !Main.tile[num870 - 1, num871].active() || !Main.tile[num870 + 1, num871].active() || !Main.tile[num870 - 1, num871 + 1].active() || !Main.tile[num870, num871 + 1].active() || !Main.tile[num870 + 1, num871 + 1].active()))
9570 {
9571 Main.tile[num870, num871].type = 633;
9572 }
9573 }
9574 }
9575 for (int num872 = 25; num872 < Main.maxTilesX - 25; num872++)
9576 {
9577 for (int num873 = Main.maxTilesY - 200; num873 < Main.maxTilesY - 50; num873++)
9578 {
9579 if (Main.tile[num872, num873].type == 633 && Main.tile[num872, num873].active() && !Main.tile[num872, num873 - 1].active() && genRand.Next(3) == 0)
9580 {
9582 }
9583 }
9584 }
9585 }
9586 });
9588 {
9589 int num778 = Main.maxTilesX;
9590 int num779 = 0;
9591 int num780 = Main.maxTilesX;
9592 int num781 = 0;
9593 for (int num782 = 0; num782 < Main.maxTilesX; num782++)
9594 {
9595 for (int num783 = 0; (double)num783 < Main.worldSurface; num783++)
9596 {
9597 if (Main.tile[num782, num783].active())
9598 {
9599 if (Main.tile[num782, num783].type == 60)
9600 {
9601 if (num782 < num778)
9602 {
9603 num778 = num782;
9604 }
9605 if (num782 > num779)
9606 {
9607 num779 = num782;
9608 }
9609 }
9610 else if (Main.tile[num782, num783].type == 147 || Main.tile[num782, num783].type == 161)
9611 {
9612 if (num782 < num780)
9613 {
9614 num780 = num782;
9615 }
9616 if (num782 > num781)
9617 {
9618 num781 = num782;
9619 }
9620 }
9621 }
9622 }
9623 }
9624 int num784 = 10;
9625 num778 -= num784;
9626 num779 += num784;
9627 num780 -= num784;
9628 num781 += num784;
9629 int num785 = 500;
9630 int num786 = 100;
9631 bool flag49 = crimson;
9632 double num787 = (double)Main.maxTilesX * 0.00045;
9633 if (remixWorldGen)
9634 {
9635 num787 *= 2.0;
9636 }
9637 else if (tenthAnniversaryWorldGen)
9638 {
9639 num785 *= 2;
9640 num786 *= 2;
9641 }
9642 if (drunkWorldGen)
9643 {
9644 flag49 = true;
9645 num787 /= 2.0;
9646 }
9647 if (flag49)
9648 {
9649 progress.Message = Lang.gen[72].Value;
9650 for (int num788 = 0; (double)num788 < num787; num788++)
9651 {
9652 int num789 = num780;
9653 int num790 = num781;
9654 int num791 = num778;
9655 int num792 = num779;
9656 double value15 = (double)num788 / num787;
9657 progress.Set(value15);
9658 bool flag50 = false;
9659 int num793 = 0;
9660 int num794 = 0;
9661 int num795 = 0;
9662 while (!flag50)
9663 {
9664 flag50 = true;
9665 int num796 = Main.maxTilesX / 2;
9666 int num797 = 200;
9667 if (drunkWorldGen)
9668 {
9669 num797 = 100;
9670 num793 = ((!GenVars.crimsonLeft) ? genRand.Next((int)((double)Main.maxTilesX * 0.5), Main.maxTilesX - num785) : genRand.Next(num785, (int)((double)Main.maxTilesX * 0.5)));
9671 }
9672 else
9673 {
9675 }
9676 num794 = num793 - genRand.Next(200) - 100;
9677 num795 = num793 + genRand.Next(200) + 100;
9679 {
9681 }
9683 {
9684 num795 = Main.maxTilesX - GenVars.evilBiomeBeachAvoidance;
9685 }
9687 {
9689 }
9691 {
9693 }
9694 if (GenVars.dungeonSide < 0 && num794 < 400)
9695 {
9696 num794 = 400;
9697 }
9698 else if (GenVars.dungeonSide > 0 && num794 > Main.maxTilesX - 400)
9699 {
9700 num794 = Main.maxTilesX - 400;
9701 }
9703 {
9704 flag50 = false;
9705 }
9706 if (!remixWorldGen)
9707 {
9709 {
9710 if (num793 > num796 - num797 && num793 < num796 + num797)
9711 {
9712 flag50 = false;
9713 }
9714 if (num794 > num796 - num797 && num794 < num796 + num797)
9715 {
9716 flag50 = false;
9717 }
9718 if (num795 > num796 - num797 && num795 < num796 + num797)
9719 {
9720 flag50 = false;
9721 }
9722 }
9724 {
9725 flag50 = false;
9726 }
9728 {
9729 flag50 = false;
9730 }
9732 {
9733 flag50 = false;
9734 }
9736 {
9737 num789++;
9738 num790--;
9739 flag50 = false;
9740 }
9742 {
9743 num791++;
9744 num792--;
9745 flag50 = false;
9746 }
9747 }
9748 }
9750 for (int num798 = num794; num798 < num795; num798++)
9751 {
9752 for (int num799 = (int)GenVars.worldSurfaceLow; (double)num799 < Main.worldSurface - 1.0; num799++)
9753 {
9754 if (Main.tile[num798, num799].active())
9755 {
9756 int num800 = num799 + genRand.Next(10, 14);
9757 for (int num801 = num799; num801 < num800; num801++)
9758 {
9759 if (Main.tile[num798, num801].type == 60 && num798 >= num794 + genRand.Next(5) && num798 < num795 - genRand.Next(5))
9760 {
9761 Main.tile[num798, num801].type = 662;
9762 }
9763 }
9764 break;
9765 }
9766 }
9767 }
9768 double num802 = Main.worldSurface + 40.0;
9769 for (int num803 = num794; num803 < num795; num803++)
9770 {
9771 num802 += (double)genRand.Next(-2, 3);
9772 if (num802 < Main.worldSurface + 30.0)
9773 {
9774 num802 = Main.worldSurface + 30.0;
9775 }
9776 if (num802 > Main.worldSurface + 50.0)
9777 {
9778 num802 = Main.worldSurface + 50.0;
9779 }
9780 bool flag51 = false;
9781 for (int num804 = (int)GenVars.worldSurfaceLow; (double)num804 < num802; num804++)
9782 {
9783 if (Main.tile[num803, num804].active())
9784 {
9785 if (Main.tile[num803, num804].type == 53 && num803 >= num794 + genRand.Next(5) && num803 <= num795 - genRand.Next(5))
9786 {
9787 Main.tile[num803, num804].type = 234;
9788 }
9789 if ((double)num804 < Main.worldSurface - 1.0 && !flag51)
9790 {
9791 if (Main.tile[num803, num804].type == 0)
9792 {
9793 grassSpread = 0;
9794 SpreadGrass(num803, num804, 0, 199);
9795 }
9796 else if (Main.tile[num803, num804].type == 59)
9797 {
9798 grassSpread = 0;
9799 SpreadGrass(num803, num804, 59, 662);
9800 }
9801 }
9802 flag51 = true;
9803 if (Main.tile[num803, num804].wall == 216)
9804 {
9805 Main.tile[num803, num804].wall = 218;
9806 }
9807 else if (Main.tile[num803, num804].wall == 187)
9808 {
9809 Main.tile[num803, num804].wall = 221;
9810 }
9811 if (Main.tile[num803, num804].type == 1)
9812 {
9813 if (num803 >= num794 + genRand.Next(5) && num803 <= num795 - genRand.Next(5))
9814 {
9815 Main.tile[num803, num804].type = 203;
9816 }
9817 }
9818 else if (Main.tile[num803, num804].type == 2)
9819 {
9820 Main.tile[num803, num804].type = 199;
9821 }
9822 else if (Main.tile[num803, num804].type == 60)
9823 {
9824 Main.tile[num803, num804].type = 662;
9825 }
9826 else if (Main.tile[num803, num804].type == 161)
9827 {
9828 Main.tile[num803, num804].type = 200;
9829 }
9830 else if (Main.tile[num803, num804].type == 396)
9831 {
9832 Main.tile[num803, num804].type = 401;
9833 }
9834 else if (Main.tile[num803, num804].type == 397)
9835 {
9836 Main.tile[num803, num804].type = 399;
9837 }
9838 }
9839 }
9840 }
9841 int num805 = genRand.Next(10, 15);
9842 for (int num806 = 0; num806 < num805; num806++)
9843 {
9844 int num807 = 0;
9845 bool flag52 = false;
9846 int num808 = 0;
9847 while (!flag52)
9848 {
9849 num807++;
9850 int num809 = genRand.Next(num794 - num808, num795 + num808);
9851 int num810 = genRand.Next((int)(Main.worldSurface - (double)(num808 / 2)), (int)(Main.worldSurface + 100.0 + (double)num808));
9852 while (oceanDepths(num809, num810))
9853 {
9854 num809 = genRand.Next(num794 - num808, num795 + num808);
9855 num810 = genRand.Next((int)(Main.worldSurface - (double)(num808 / 2)), (int)(Main.worldSurface + 100.0 + (double)num808));
9856 }
9857 if (num807 > 100)
9858 {
9859 num808++;
9860 num807 = 0;
9861 }
9862 if (!Main.tile[num809, num810].active())
9863 {
9864 for (; !Main.tile[num809, num810].active(); num810++)
9865 {
9866 }
9867 num810--;
9868 }
9869 else
9870 {
9871 while (Main.tile[num809, num810].active() && (double)num810 > Main.worldSurface)
9872 {
9873 num810--;
9874 }
9875 }
9876 if ((num808 > 10 || (Main.tile[num809, num810 + 1].active() && Main.tile[num809, num810 + 1].type == 203)) && !IsTileNearby(num809, num810, 26, 3))
9877 {
9878 Place3x2(num809, num810, 26, 1);
9879 if (Main.tile[num809, num810].type == 26)
9880 {
9881 flag52 = true;
9882 }
9883 }
9884 if (num808 > 100)
9885 {
9886 flag52 = true;
9887 }
9888 }
9889 }
9890 }
9892 }
9893 if (drunkWorldGen)
9894 {
9895 flag49 = false;
9896 }
9897 if (!flag49)
9898 {
9899 progress.Message = Lang.gen[20].Value;
9900 for (int num811 = 0; (double)num811 < num787; num811++)
9901 {
9902 int num812 = num780;
9903 int num813 = num781;
9904 int num814 = num778;
9905 int num815 = num779;
9906 double value16 = (double)num811 / num787;
9907 progress.Set(value16);
9908 bool flag53 = false;
9909 int num816 = 0;
9910 int num817 = 0;
9911 int num818 = 0;
9912 while (!flag53)
9913 {
9914 flag53 = true;
9915 int num819 = Main.maxTilesX / 2;
9916 int num820 = 200;
9917 num816 = ((!drunkWorldGen) ? genRand.Next(num785, Main.maxTilesX - num785) : (GenVars.crimsonLeft ? genRand.Next((int)((double)Main.maxTilesX * 0.5), Main.maxTilesX - num785) : genRand.Next(num785, (int)((double)Main.maxTilesX * 0.5))));
9918 num817 = num816 - genRand.Next(200) - 100;
9919 num818 = num816 + genRand.Next(200) + 100;
9921 {
9923 }
9925 {
9926 num818 = Main.maxTilesX - GenVars.evilBiomeBeachAvoidance;
9927 }
9929 {
9931 }
9933 {
9935 }
9937 {
9938 flag53 = false;
9939 }
9940 if (!remixWorldGen)
9941 {
9943 {
9944 if (num816 > num819 - num820 && num816 < num819 + num820)
9945 {
9946 flag53 = false;
9947 }
9948 if (num817 > num819 - num820 && num817 < num819 + num820)
9949 {
9950 flag53 = false;
9951 }
9952 if (num818 > num819 - num820 && num818 < num819 + num820)
9953 {
9954 flag53 = false;
9955 }
9956 }
9958 {
9959 flag53 = false;
9960 }
9962 {
9963 flag53 = false;
9964 }
9966 {
9967 flag53 = false;
9968 }
9970 {
9971 num812++;
9972 num813--;
9973 flag53 = false;
9974 }
9976 {
9977 num814++;
9978 num815--;
9979 flag53 = false;
9980 }
9981 }
9982 }
9983 int num821 = 0;
9984 for (int num822 = num817; num822 < num818; num822++)
9985 {
9986 if (num821 > 0)
9987 {
9988 num821--;
9989 }
9990 if (num822 == num816 || num821 == 0)
9991 {
9992 for (int num823 = (int)GenVars.worldSurfaceLow; (double)num823 < Main.worldSurface - 1.0; num823++)
9993 {
9994 if (Main.tile[num822, num823].active() || Main.tile[num822, num823].wall > 0)
9995 {
9996 if (num822 == num816)
9997 {
9998 num821 = 20;
9999 ChasmRunner(num822, num823, genRand.Next(150) + 150, makeOrb: true);
10000 }
10001 else if (genRand.Next(35) == 0 && num821 == 0)
10002 {
10003 num821 = 30;
10004 bool makeOrb = true;
10005 ChasmRunner(num822, num823, genRand.Next(50) + 50, makeOrb);
10006 }
10007 break;
10008 }
10009 }
10010 }
10011 for (int num824 = (int)GenVars.worldSurfaceLow; (double)num824 < Main.worldSurface - 1.0; num824++)
10012 {
10013 if (Main.tile[num822, num824].active())
10014 {
10015 int num825 = num824 + genRand.Next(10, 14);
10016 for (int num826 = num824; num826 < num825; num826++)
10017 {
10018 if (Main.tile[num822, num826].type == 60 && num822 >= num817 + genRand.Next(5) && num822 < num818 - genRand.Next(5))
10019 {
10020 Main.tile[num822, num826].type = 661;
10021 }
10022 }
10023 break;
10024 }
10025 }
10026 }
10027 double num827 = Main.worldSurface + 40.0;
10028 for (int num828 = num817; num828 < num818; num828++)
10029 {
10030 num827 += (double)genRand.Next(-2, 3);
10031 if (num827 < Main.worldSurface + 30.0)
10032 {
10033 num827 = Main.worldSurface + 30.0;
10034 }
10035 if (num827 > Main.worldSurface + 50.0)
10036 {
10037 num827 = Main.worldSurface + 50.0;
10038 }
10039 bool flag54 = false;
10040 for (int num829 = (int)GenVars.worldSurfaceLow; (double)num829 < num827; num829++)
10041 {
10042 if (Main.tile[num828, num829].active())
10043 {
10044 if (Main.tile[num828, num829].type == 53 && num828 >= num817 + genRand.Next(5) && num828 <= num818 - genRand.Next(5))
10045 {
10046 Main.tile[num828, num829].type = 112;
10047 }
10048 if ((double)num829 < Main.worldSurface - 1.0 && !flag54)
10049 {
10050 if (Main.tile[num828, num829].type == 0)
10051 {
10052 grassSpread = 0;
10053 SpreadGrass(num828, num829, 0, 23);
10054 }
10055 else if (Main.tile[num828, num829].type == 59)
10056 {
10057 grassSpread = 0;
10058 SpreadGrass(num828, num829, 59, 661);
10059 }
10060 }
10061 flag54 = true;
10062 if (Main.tile[num828, num829].wall == 216)
10063 {
10064 Main.tile[num828, num829].wall = 217;
10065 }
10066 else if (Main.tile[num828, num829].wall == 187)
10067 {
10068 Main.tile[num828, num829].wall = 220;
10069 }
10070 if (Main.tile[num828, num829].type == 1)
10071 {
10072 if (num828 >= num817 + genRand.Next(5) && num828 <= num818 - genRand.Next(5))
10073 {
10074 Main.tile[num828, num829].type = 25;
10075 }
10076 }
10077 else if (Main.tile[num828, num829].type == 2)
10078 {
10079 Main.tile[num828, num829].type = 23;
10080 }
10081 else if (Main.tile[num828, num829].type == 60)
10082 {
10083 Main.tile[num828, num829].type = 661;
10084 }
10085 else if (Main.tile[num828, num829].type == 161)
10086 {
10087 Main.tile[num828, num829].type = 163;
10088 }
10089 else if (Main.tile[num828, num829].type == 396)
10090 {
10091 Main.tile[num828, num829].type = 400;
10092 }
10093 else if (Main.tile[num828, num829].type == 397)
10094 {
10095 Main.tile[num828, num829].type = 398;
10096 }
10097 }
10098 }
10099 }
10100 for (int num830 = num817; num830 < num818; num830++)
10101 {
10102 for (int num831 = 0; num831 < Main.maxTilesY - 50; num831++)
10103 {
10104 if (Main.tile[num830, num831].active() && Main.tile[num830, num831].type == 31)
10105 {
10106 int num832 = num830 - 13;
10107 int num833 = num830 + 13;
10108 int num834 = num831 - 13;
10109 int num835 = num831 + 13;
10110 for (int num836 = num832; num836 < num833; num836++)
10111 {
10112 if (num836 > 10 && num836 < Main.maxTilesX - 10)
10113 {
10114 for (int num837 = num834; num837 < num835; num837++)
10115 {
10116 if (Math.Abs(num836 - num830) + Math.Abs(num837 - num831) < 9 + genRand.Next(11) && genRand.Next(3) != 0 && Main.tile[num836, num837].type != 31)
10117 {
10118 Main.tile[num836, num837].active(active: true);
10119 Main.tile[num836, num837].type = 25;
10120 if (Math.Abs(num836 - num830) <= 1 && Math.Abs(num837 - num831) <= 1)
10121 {
10122 Main.tile[num836, num837].active(active: false);
10123 }
10124 }
10125 if (Main.tile[num836, num837].type != 31 && Math.Abs(num836 - num830) <= 2 + genRand.Next(3) && Math.Abs(num837 - num831) <= 2 + genRand.Next(3))
10126 {
10127 Main.tile[num836, num837].active(active: false);
10128 }
10129 }
10130 }
10131 }
10132 }
10133 }
10134 }
10135 }
10136 }
10137 });
10139 {
10140 progress.Message = Lang.gen[19].Value;
10141 double num759 = (double)Main.maxTilesX / 4200.0;
10142 int num760 = genRand.Next((int)(num759 * 3.0), (int)(num759 * 6.0));
10143 for (int num761 = 0; num761 < num760; num761++)
10144 {
10145 int num762 = Main.maxTilesX / 4;
10146 if (GenVars.numLakes >= GenVars.maxLakes - 1)
10147 {
10148 break;
10149 }
10150 double value14 = (double)num761 / (double)num760;
10151 progress.Set(value14);
10152 while (num762 > 0)
10153 {
10154 bool flag48 = false;
10155 num762--;
10158 {
10159 num763 = genRand.Next((int)((double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.85));
10160 }
10161 else
10162 {
10163 while ((double)num763 > (double)Main.maxTilesX * 0.45 && (double)num763 < (double)Main.maxTilesX * 0.55)
10164 {
10166 }
10167 }
10168 for (int num764 = 0; num764 < GenVars.numLakes; num764++)
10169 {
10170 if (Math.Abs(num763 - GenVars.LakeX[num764]) < 150)
10171 {
10172 flag48 = true;
10173 break;
10174 }
10175 }
10176 for (int num765 = 0; num765 < GenVars.numMCaves; num765++)
10177 {
10178 if (Math.Abs(num763 - GenVars.mCaveX[num765]) < 100)
10179 {
10180 flag48 = true;
10181 break;
10182 }
10183 }
10184 for (int num766 = 0; num766 < GenVars.numTunnels; num766++)
10185 {
10186 if (Math.Abs(num763 - GenVars.tunnelX[num766]) < 100)
10187 {
10188 flag48 = true;
10189 break;
10190 }
10191 }
10192 if (!flag48)
10193 {
10194 int num767 = (int)GenVars.worldSurfaceLow - 20;
10195 while (!Main.tile[num763, num767].active())
10196 {
10197 num767++;
10198 if ((double)num767 >= Main.worldSurface || Main.tile[num763, num767].wall > 0)
10199 {
10200 flag48 = true;
10201 break;
10202 }
10203 }
10204 if (Main.tile[num763, num767].type == 53)
10205 {
10206 flag48 = true;
10207 }
10208 if (!flag48)
10209 {
10210 int num768 = 50;
10211 for (int num769 = num763 - num768; num769 <= num763 + num768; num769++)
10212 {
10213 for (int num770 = num767 - num768; num770 <= num767 + num768; num770++)
10214 {
10215 if (Main.tile[num769, num770].type == 203 || Main.tile[num769, num770].type == 25)
10216 {
10217 flag48 = true;
10218 break;
10219 }
10220 }
10221 }
10222 if (!flag48)
10223 {
10224 int num771 = num767;
10225 num768 = 20;
10227 {
10228 num767++;
10229 if ((double)num767 > Main.worldSurface - 50.0)
10230 {
10231 flag48 = true;
10232 }
10233 }
10234 if (num767 - num771 <= 10)
10235 {
10236 num768 = 60;
10237 for (int num772 = num763 - num768; num772 <= num763 + num768; num772++)
10238 {
10239 int num773 = num767 - 20;
10240 if (Main.tile[num772, num773].active() || Main.tile[num772, num773].wall > 0)
10241 {
10242 flag48 = true;
10243 }
10244 }
10245 if (!flag48)
10246 {
10247 int num774 = 0;
10248 for (int num775 = num763 - num768; num775 <= num763 + num768; num775++)
10249 {
10250 for (int num776 = num767; num776 <= num767 + num768 * 2; num776++)
10251 {
10252 if (SolidTile(num775, num776))
10253 {
10254 num774++;
10255 }
10256 }
10257 }
10258 int num777 = (num768 * 2 + 1) * (num768 * 2 + 1);
10259 if (!((double)num774 < (double)num777 * 0.8) && !GenVars.UndergroundDesertLocation.Intersects(new Rectangle(num763 - 8, num767 - 8, 16, 16)))
10260 {
10263 GenVars.numLakes++;
10264 break;
10265 }
10266 }
10267 }
10268 }
10269 }
10270 }
10271 }
10272 }
10273 });
10275 {
10276 progress.Set(1.0);
10277 int dungeonLocation = GenVars.dungeonLocation;
10278 int num755 = (int)((Main.worldSurface + Main.rockLayer) / 2.0) + genRand.Next(-200, 200);
10279 int num756 = (int)((Main.worldSurface + Main.rockLayer) / 2.0) + 200;
10280 int num757 = num755;
10281 bool flag47 = false;
10282 for (int num758 = 0; num758 < 10; num758++)
10283 {
10284 if (SolidTile(dungeonLocation, num757 + num758))
10285 {
10286 flag47 = true;
10287 break;
10288 }
10289 }
10290 if (!flag47)
10291 {
10292 for (; num757 < num756 && !SolidTile(dungeonLocation, num757 + 10); num757++)
10293 {
10294 }
10295 }
10296 if (drunkWorldGen)
10297 {
10298 num757 = (int)Main.worldSurface + 70;
10299 }
10300 MakeDungeon(dungeonLocation, num757);
10301 });
10303 {
10305 {
10307 {
10308 switch (Main.tile[num751, num750].type)
10309 {
10310 case 123:
10311 Main.tile[num751, num750].type = 224;
10312 break;
10313 case 59:
10314 {
10315 bool flag46 = true;
10316 int num752 = 3;
10317 for (int num753 = num751 - num752; num753 <= num751 + num752; num753++)
10318 {
10319 for (int num754 = num750 - num752; num754 <= num750 + num752; num754++)
10320 {
10321 if (Main.tile[num753, num754].type == 60 || Main.tile[num753, num754].type == 70 || Main.tile[num753, num754].type == 71 || Main.tile[num753, num754].type == 72)
10322 {
10323 flag46 = false;
10324 break;
10325 }
10326 }
10327 }
10328 if (flag46)
10329 {
10330 Main.tile[num751, num750].type = 224;
10331 }
10332 break;
10333 }
10334 case 1:
10335 Main.tile[num751, num750].type = 161;
10336 break;
10337 }
10338 }
10339 }
10340 });
10342 {
10343 progress.Message = Lang.gen[21].Value;
10344 for (int num749 = 0; num749 < GenVars.numMCaves; num749++)
10345 {
10346 int i3 = GenVars.mCaveX[num749];
10347 int j5 = GenVars.mCaveY[num749];
10348 CaveOpenater(i3, j5);
10349 Cavinator(i3, j5, genRand.Next(40, 50));
10350 }
10351 });
10353 {
10354 int num731 = 50;
10355 progress.Message = Lang.gen[22].Value;
10356 bool floridaStyle = false;
10357 bool floridaStyle2 = false;
10358 if (genRand.Next(4) == 0)
10359 {
10360 if (genRand.Next(2) == 0)
10361 {
10362 floridaStyle = true;
10363 }
10364 else
10365 {
10366 floridaStyle2 = true;
10367 }
10368 }
10369 for (int num732 = 0; num732 < 2; num732++)
10370 {
10371 int num733 = 0;
10372 int num734 = 0;
10373 if (num732 == 0)
10374 {
10375 num733 = 0;
10377 if (GenVars.dungeonSide == 1)
10378 {
10380 }
10381 int num735 = GenVars.leftBeachEnd - num731;
10382 if (num734 > num735)
10383 {
10384 num734 = num735;
10385 }
10386 int num736 = 0;
10387 double num737 = 1.0;
10388 int num738;
10389 for (num738 = 0; !Main.tile[num734 - 1, num738].active(); num738++)
10390 {
10391 }
10392 GenVars.shellStartYLeft = num738;
10393 num738 += genRand.Next(1, 5);
10394 for (int num739 = num734 - 1; num739 >= num733; num739--)
10395 {
10396 if (num739 > 30)
10397 {
10398 num736++;
10400 }
10401 else
10402 {
10403 num737 += 1.0;
10404 }
10405 int num740 = genRand.Next(15, 20);
10406 for (int num741 = 0; (double)num741 < (double)num738 + num737 + (double)num740; num741++)
10407 {
10408 if ((double)num741 < (double)num738 + num737 * 0.75 - 3.0)
10409 {
10410 Main.tile[num739, num741].active(active: false);
10411 if (num741 > num738)
10412 {
10413 Main.tile[num739, num741].liquid = byte.MaxValue;
10414 Main.tile[num739, num741].lava(lava: false);
10415 }
10416 else if (num741 == num738)
10417 {
10418 Main.tile[num739, num741].liquid = 127;
10419 if (GenVars.shellStartXLeft == 0)
10420 {
10421 GenVars.shellStartXLeft = num739;
10422 }
10423 }
10424 }
10425 else if (num741 > num738)
10426 {
10427 Main.tile[num739, num741].type = 53;
10428 Main.tile[num739, num741].active(active: true);
10429 }
10430 Main.tile[num739, num741].wall = 0;
10431 }
10432 }
10433 }
10434 else
10435 {
10438 if (GenVars.dungeonSide == -1)
10439 {
10440 num733 = Main.maxTilesX - GenVars.oceanWaterForcedJungleLength;
10441 }
10442 int num742 = GenVars.rightBeachStart + num731;
10443 if (num733 < num742)
10444 {
10445 num733 = num742;
10446 }
10447 double num743 = 1.0;
10448 int num744 = 0;
10449 int num745;
10450 for (num745 = 0; !Main.tile[num733, num745].active(); num745++)
10451 {
10452 }
10453 GenVars.shellStartXRight = 0;
10454 GenVars.shellStartYRight = num745;
10455 num745 += genRand.Next(1, 5);
10456 for (int num746 = num733; num746 < num734; num746++)
10457 {
10458 if (num746 < num734 - 30)
10459 {
10460 num744++;
10462 }
10463 else
10464 {
10465 num743 += 1.0;
10466 }
10467 int num747 = genRand.Next(15, 20);
10468 for (int num748 = 0; (double)num748 < (double)num745 + num743 + (double)num747; num748++)
10469 {
10470 if ((double)num748 < (double)num745 + num743 * 0.75 - 3.0)
10471 {
10472 Main.tile[num746, num748].active(active: false);
10473 if (num748 > num745)
10474 {
10475 Main.tile[num746, num748].liquid = byte.MaxValue;
10476 Main.tile[num746, num748].lava(lava: false);
10477 }
10478 else if (num748 == num745)
10479 {
10480 Main.tile[num746, num748].liquid = 127;
10481 if (GenVars.shellStartXRight == 0)
10482 {
10483 GenVars.shellStartXRight = num746;
10484 }
10485 }
10486 }
10487 else if (num748 > num745)
10488 {
10489 Main.tile[num746, num748].type = 53;
10490 Main.tile[num746, num748].active(active: true);
10491 }
10492 Main.tile[num746, num748].wall = 0;
10493 }
10494 }
10495 }
10496 }
10497 });
10499 {
10500 progress.Message = Lang.gen[23].Value;
10501 Main.tileSolid[484] = false;
10502 for (int num718 = 63; num718 <= 68; num718++)
10503 {
10504 double value13 = (double)(num718 - 63) / 6.0;
10505 progress.Set(value13);
10506 double num719 = 0.0;
10507 switch (num718)
10508 {
10509 case 67:
10510 num719 = (double)Main.maxTilesX * 0.5;
10511 break;
10512 case 66:
10513 num719 = (double)Main.maxTilesX * 0.45;
10514 break;
10515 case 63:
10516 num719 = (double)Main.maxTilesX * 0.3;
10517 break;
10518 case 65:
10519 num719 = (double)Main.maxTilesX * 0.25;
10520 break;
10521 case 64:
10522 num719 = (double)Main.maxTilesX * 0.1;
10523 break;
10524 case 68:
10525 num719 = (double)Main.maxTilesX * 0.05;
10526 break;
10527 }
10528 num719 *= 0.2;
10529 for (int num720 = 0; (double)num720 < num719; num720++)
10530 {
10531 int num721 = genRand.Next(0, Main.maxTilesX);
10532 int num722 = genRand.Next((int)Main.worldSurface, Main.maxTilesY);
10533 while (Main.tile[num721, num722].type != 1)
10534 {
10535 num721 = genRand.Next(0, Main.maxTilesX);
10537 }
10538 TileRunner(num721, num722, genRand.Next(2, 6), genRand.Next(3, 7), num718);
10539 }
10540 }
10541 for (int num723 = 0; num723 < 2; num723++)
10542 {
10543 int num724 = 1;
10544 int num725 = 5;
10545 int num726 = Main.maxTilesX - 5;
10546 if (num723 == 1)
10547 {
10548 num724 = -1;
10549 num725 = Main.maxTilesX - 5;
10550 num726 = 5;
10551 }
10552 for (int num727 = num725; num727 != num726; num727 += num724)
10553 {
10555 {
10556 for (int num728 = 10; num728 < Main.maxTilesY - 10; num728++)
10557 {
10558 if (Main.tile[num727, num728].active() && Main.tile[num727, num728 + 1].active() && Main.tileSand[Main.tile[num727, num728].type] && Main.tileSand[Main.tile[num727, num728 + 1].type])
10559 {
10560 ushort type9 = Main.tile[num727, num728].type;
10561 int num729 = num727 + num724;
10562 int num730 = num728 + 1;
10563 if (!Main.tile[num729, num728].active() && !Main.tile[num729, num730].active())
10564 {
10565 for (; !Main.tile[num729, num730].active(); num730++)
10566 {
10567 }
10568 num730--;
10569 Main.tile[num727, num728].active(active: false);
10570 Main.tile[num729, num730].active(active: true);
10571 Main.tile[num729, num730].type = type9;
10572 }
10573 }
10574 }
10575 }
10576 }
10577 }
10578 });
10580 {
10581 progress.Message = Lang.gen[24].Value;
10582 for (int num714 = 0; num714 < Main.maxTilesX; num714++)
10583 {
10584 double value12 = (double)num714 / (double)(Main.maxTilesX - 1);
10585 progress.Set(value12);
10586 bool flag45 = false;
10587 int num715 = 0;
10588 for (int num716 = Main.maxTilesY - 1; num716 > 0; num716--)
10589 {
10591 {
10592 ushort type8 = Main.tile[num714, num716].type;
10593 if (flag45 && num716 < (int)Main.worldSurface && num716 != num715 - 1 && TileID.Sets.Falling[type8])
10594 {
10595 for (int num717 = num716; num717 < num715; num717++)
10596 {
10597 Main.tile[num714, num717].ResetToType(type8);
10598 }
10599 }
10600 flag45 = true;
10601 num715 = num716;
10602 }
10603 }
10604 }
10605 });
10607 {
10608 int maxValue11 = 3;
10609 if (remixWorldGen)
10610 {
10611 maxValue11 = 2;
10612 }
10613 for (int num711 = 0; num711 < 2; num711++)
10614 {
10615 if ((num711 != 0 || GenVars.dungeonSide <= 0) && (num711 != 1 || GenVars.dungeonSide >= 0) && (genRand.Next(maxValue11) == 0 || drunkWorldGen || tenthAnniversaryWorldGen))
10616 {
10617 progress.Message = Lang.gen[90].Value;
10618 int num712 = genRand.Next(55, 95);
10619 if (num711 == 1)
10620 {
10621 num712 = genRand.Next(Main.maxTilesX - 95, Main.maxTilesX - 55);
10622 }
10623 int num713;
10624 for (num713 = 0; !Main.tile[num712, num713].active(); num713++)
10625 {
10626 }
10628 }
10629 }
10630 });
10631 AddGenerationPass("Shimmer", delegate
10632 {
10633 //IL_028b: Unknown result type (might be due to invalid IL or missing references)
10634 //IL_0290: Unknown result type (might be due to invalid IL or missing references)
10635 int num702 = 50;
10636 int num703 = (int)(Main.worldSurface + Main.rockLayer) / 2 + num702;
10637 int num704 = (int)((double)((Main.maxTilesY - 250) * 2) + Main.rockLayer) / 3;
10638 if (num704 > Main.maxTilesY - 330 - 100 - 30)
10639 {
10640 num704 = Main.maxTilesY - 330 - 100 - 30;
10641 }
10642 if (num704 <= num703)
10643 {
10644 num704 = num703 + 50;
10645 }
10646 int num705 = genRand.Next(num703, num704);
10647 int num706 = ((GenVars.dungeonSide < 0) ? genRand.Next((int)((double)Main.maxTilesX * 0.89), Main.maxTilesX - 200) : genRand.Next(200, (int)((double)Main.maxTilesX * 0.11)));
10648 int num707 = (int)Main.worldSurface + 150;
10649 int num708 = (int)(Main.rockLayer + Main.worldSurface + 200.0) / 2;
10650 if (num708 <= num707)
10651 {
10652 num708 = num707 + 50;
10653 }
10654 if (tenthAnniversaryWorldGen)
10655 {
10656 num705 = genRand.Next(num707, num708);
10657 }
10658 int num709 = 0;
10659 while (!ShimmerMakeBiome(num706, num705))
10660 {
10661 num709++;
10662 if (tenthAnniversaryWorldGen && num709 < 10000)
10663 {
10664 num705 = genRand.Next(num707, num708);
10665 num706 = ((GenVars.dungeonSide < 0) ? genRand.Next((int)((double)Main.maxTilesX * 0.89), Main.maxTilesX - 200) : genRand.Next(200, (int)((double)Main.maxTilesX * 0.11)));
10666 }
10667 else if (num709 > 20000)
10668 {
10669 num705 = genRand.Next((int)Main.worldSurface + 100 + 20, num704);
10670 num706 = ((GenVars.dungeonSide < 0) ? genRand.Next((int)((double)Main.maxTilesX * 0.8), Main.maxTilesX - 200) : genRand.Next(200, (int)((double)Main.maxTilesX * 0.2)));
10671 }
10672 else
10673 {
10674 num705 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2 + 20, num704);
10675 num706 = ((GenVars.dungeonSide < 0) ? genRand.Next((int)((double)Main.maxTilesX * 0.89), Main.maxTilesX - 200) : genRand.Next(200, (int)((double)Main.maxTilesX * 0.11)));
10676 }
10677 }
10678 GenVars.shimmerPosition = new Vector2D((double)num706, (double)num705);
10679 int num710 = 200;
10680 GenVars.structures.AddProtectedStructure(new Rectangle(num706 - num710 / 2, num705 - num710 / 2, num710, num710));
10681 });
10682 AddGenerationPass("Clean Up Dirt", delegate(GenerationProgress progress, GameConfiguration passConfig)
10683 {
10684 progress.Message = Lang.gen[25].Value;
10685 for (int num696 = 3; num696 < Main.maxTilesX - 3; num696++)
10686 {
10687 double num697 = (double)num696 / (double)Main.maxTilesX;
10688 progress.Set(0.5 * num697);
10689 bool flag43 = true;
10690 for (int num698 = 0; (double)num698 < Main.worldSurface; num698++)
10691 {
10692 if (flag43)
10693 {
10694 if (Main.tile[num696, num698].wall == 2 || Main.tile[num696, num698].wall == 40 || Main.tile[num696, num698].wall == 64 || Main.tile[num696, num698].wall == 86)
10695 {
10696 Main.tile[num696, num698].wall = 0;
10697 }
10698 if (Main.tile[num696, num698].type != 53 && Main.tile[num696, num698].type != 112 && Main.tile[num696, num698].type != 234)
10699 {
10700 if (Main.tile[num696 - 1, num698].wall == 2 || Main.tile[num696 - 1, num698].wall == 40 || Main.tile[num696 - 1, num698].wall == 40)
10701 {
10702 Main.tile[num696 - 1, num698].wall = 0;
10703 }
10704 if ((Main.tile[num696 - 2, num698].wall == 2 || Main.tile[num696 - 2, num698].wall == 40 || Main.tile[num696 - 2, num698].wall == 40) && genRand.Next(2) == 0)
10705 {
10706 Main.tile[num696 - 2, num698].wall = 0;
10707 }
10708 if ((Main.tile[num696 - 3, num698].wall == 2 || Main.tile[num696 - 3, num698].wall == 40 || Main.tile[num696 - 3, num698].wall == 40) && genRand.Next(2) == 0)
10709 {
10710 Main.tile[num696 - 3, num698].wall = 0;
10711 }
10712 if (Main.tile[num696 + 1, num698].wall == 2 || Main.tile[num696 + 1, num698].wall == 40 || Main.tile[num696 + 1, num698].wall == 40)
10713 {
10714 Main.tile[num696 + 1, num698].wall = 0;
10715 }
10716 if ((Main.tile[num696 + 2, num698].wall == 2 || Main.tile[num696 + 2, num698].wall == 40 || Main.tile[num696 + 2, num698].wall == 40) && genRand.Next(2) == 0)
10717 {
10718 Main.tile[num696 + 2, num698].wall = 0;
10719 }
10720 if ((Main.tile[num696 + 3, num698].wall == 2 || Main.tile[num696 + 3, num698].wall == 40 || Main.tile[num696 + 3, num698].wall == 40) && genRand.Next(2) == 0)
10721 {
10722 Main.tile[num696 + 3, num698].wall = 0;
10723 }
10724 if (Main.tile[num696, num698].active())
10725 {
10726 flag43 = false;
10727 }
10728 }
10729 }
10730 else if (Main.tile[num696, num698].wall == 0 && Main.tile[num696, num698 + 1].wall == 0 && Main.tile[num696, num698 + 2].wall == 0 && Main.tile[num696, num698 + 3].wall == 0 && Main.tile[num696, num698 + 4].wall == 0 && Main.tile[num696 - 1, num698].wall == 0 && Main.tile[num696 + 1, num698].wall == 0 && Main.tile[num696 - 2, num698].wall == 0 && Main.tile[num696 + 2, num698].wall == 0 && !Main.tile[num696, num698].active() && !Main.tile[num696, num698 + 1].active() && !Main.tile[num696, num698 + 2].active() && !Main.tile[num696, num698 + 3].active())
10731 {
10732 flag43 = true;
10733 }
10734 }
10735 }
10736 for (int num699 = Main.maxTilesX - 5; num699 >= 5; num699--)
10737 {
10738 double num700 = (double)num699 / (double)Main.maxTilesX;
10739 progress.Set(1.0 - 0.5 * num700);
10740 bool flag44 = true;
10741 for (int num701 = 0; (double)num701 < Main.worldSurface; num701++)
10742 {
10743 if (flag44)
10744 {
10745 if (Main.tile[num699, num701].wall == 2 || Main.tile[num699, num701].wall == 40 || Main.tile[num699, num701].wall == 64)
10746 {
10747 Main.tile[num699, num701].wall = 0;
10748 }
10749 if (Main.tile[num699, num701].type != 53)
10750 {
10751 if (Main.tile[num699 - 1, num701].wall == 2 || Main.tile[num699 - 1, num701].wall == 40 || Main.tile[num699 - 1, num701].wall == 40)
10752 {
10753 Main.tile[num699 - 1, num701].wall = 0;
10754 }
10755 if ((Main.tile[num699 - 2, num701].wall == 2 || Main.tile[num699 - 2, num701].wall == 40 || Main.tile[num699 - 2, num701].wall == 40) && genRand.Next(2) == 0)
10756 {
10757 Main.tile[num699 - 2, num701].wall = 0;
10758 }
10759 if ((Main.tile[num699 - 3, num701].wall == 2 || Main.tile[num699 - 3, num701].wall == 40 || Main.tile[num699 - 3, num701].wall == 40) && genRand.Next(2) == 0)
10760 {
10761 Main.tile[num699 - 3, num701].wall = 0;
10762 }
10763 if (Main.tile[num699 + 1, num701].wall == 2 || Main.tile[num699 + 1, num701].wall == 40 || Main.tile[num699 + 1, num701].wall == 40)
10764 {
10765 Main.tile[num699 + 1, num701].wall = 0;
10766 }
10767 if ((Main.tile[num699 + 2, num701].wall == 2 || Main.tile[num699 + 2, num701].wall == 40 || Main.tile[num699 + 2, num701].wall == 40) && genRand.Next(2) == 0)
10768 {
10769 Main.tile[num699 + 2, num701].wall = 0;
10770 }
10771 if ((Main.tile[num699 + 3, num701].wall == 2 || Main.tile[num699 + 3, num701].wall == 40 || Main.tile[num699 + 3, num701].wall == 40) && genRand.Next(2) == 0)
10772 {
10773 Main.tile[num699 + 3, num701].wall = 0;
10774 }
10775 if (Main.tile[num699, num701].active())
10776 {
10777 flag44 = false;
10778 }
10779 }
10780 }
10781 else if (Main.tile[num699, num701].wall == 0 && Main.tile[num699, num701 + 1].wall == 0 && Main.tile[num699, num701 + 2].wall == 0 && Main.tile[num699, num701 + 3].wall == 0 && Main.tile[num699, num701 + 4].wall == 0 && Main.tile[num699 - 1, num701].wall == 0 && Main.tile[num699 + 1, num701].wall == 0 && Main.tile[num699 - 2, num701].wall == 0 && Main.tile[num699 + 2, num701].wall == 0 && !Main.tile[num699, num701].active() && !Main.tile[num699, num701 + 1].active() && !Main.tile[num699, num701 + 2].active() && !Main.tile[num699, num701 + 3].active())
10782 {
10783 flag44 = true;
10784 }
10785 }
10786 }
10787 });
10788 AddGenerationPass("Pyramids", delegate
10789 {
10792 {
10793 int x15 = undergroundDesertLocation.Center.X;
10794 int j4 = undergroundDesertLocation.Top - 10;
10795 Pyramid(x15, j4);
10796 }
10797 for (int num689 = 0; num689 < GenVars.numPyr; num689++)
10798 {
10799 int num690 = GenVars.PyrX[num689];
10800 int num691 = GenVars.PyrY[num689];
10801 if (num690 > 300 && num690 < Main.maxTilesX - 300 && (GenVars.dungeonSide >= 0 || !((double)num690 < (double)GenVars.dungeonX + (double)Main.maxTilesX * 0.15)) && (GenVars.dungeonSide <= 0 || !((double)num690 > (double)GenVars.dungeonX - (double)Main.maxTilesX * 0.15)) && (!Main.tenthAnniversaryWorld || !undergroundDesertLocation.Contains(num690, num691)))
10802 {
10803 for (; !Main.tile[num690, num691].active() && (double)num691 < Main.worldSurface; num691++)
10804 {
10805 }
10806 if (!((double)num691 >= Main.worldSurface) && Main.tile[num690, num691].type == 53)
10807 {
10808 int num692 = Main.maxTilesX;
10809 for (int num693 = 0; num693 < num689; num693++)
10810 {
10811 int num694 = Math.Abs(num690 - GenVars.PyrX[num693]);
10812 if (num694 < num692)
10813 {
10814 num692 = num694;
10815 }
10816 }
10817 int num695 = 220;
10818 if (drunkWorldGen)
10819 {
10820 num695 /= 2;
10821 }
10822 if (num692 >= num695)
10823 {
10824 num691--;
10825 Pyramid(num690, num691);
10826 }
10827 }
10828 }
10829 }
10830 });
10831 AddGenerationPass("Dirt Rock Wall Runner", delegate
10832 {
10833 for (int num686 = 0; num686 < Main.maxTilesX; num686++)
10834 {
10835 int num687 = genRand.Next(10, Main.maxTilesX - 10);
10836 int num688 = genRand.Next(10, (int)Main.worldSurface);
10837 if (Main.tile[num687, num688].wall == 2)
10838 {
10839 DirtyRockRunner(num687, num688);
10840 }
10841 }
10842 });
10843 AddGenerationPass("Living Trees", delegate
10844 {
10845 int num669 = 200;
10846 double num670 = (double)Main.maxTilesX / 4200.0;
10847 int num671 = genRand.Next(0, (int)(2.0 * num670) + 1);
10848 if (num671 == 0 && genRand.Next(2) == 0)
10849 {
10850 num671++;
10851 }
10852 if (drunkWorldGen)
10853 {
10854 num671 += (int)(2.0 * num670);
10855 }
10856 else if (Main.tenthAnniversaryWorld)
10857 {
10858 num671 += (int)(3.0 * num670);
10859 }
10860 else if (remixWorldGen)
10861 {
10862 num671 += (int)(2.0 * num670);
10863 }
10864 for (int num672 = 0; num672 < num671; num672++)
10865 {
10866 bool flag41 = false;
10867 int num673 = 0;
10868 while (!flag41)
10869 {
10870 num673++;
10871 if (num673 > Main.maxTilesX / 2)
10872 {
10873 flag41 = true;
10874 }
10875 int num674 = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
10876 if (tenthAnniversaryWorldGen && !remixWorldGen)
10877 {
10878 num674 = genRand.Next((int)((double)Main.maxTilesX * 0.15), (int)((float)Main.maxTilesX * 0.85f));
10879 }
10881 {
10882 int num675;
10883 for (num675 = 0; !Main.tile[num674, num675].active() && (double)num675 < Main.worldSurface; num675++)
10884 {
10885 }
10886 if (Main.tile[num674, num675].type == 0)
10887 {
10888 num675--;
10889 if (num675 > 150)
10890 {
10891 bool flag42 = true;
10892 for (int num676 = num674 - 50; num676 < num674 + 50; num676++)
10893 {
10894 for (int num677 = num675 - 50; num677 < num675 + 50; num677++)
10895 {
10896 if (Main.tile[num676, num677].active())
10897 {
10898 switch (Main.tile[num676, num677].type)
10899 {
10900 case 41:
10901 case 43:
10902 case 44:
10903 case 189:
10904 case 196:
10905 case 460:
10906 case 481:
10907 case 482:
10908 case 483:
10909 flag42 = false;
10910 break;
10911 }
10912 }
10913 }
10914 }
10915 for (int num678 = 0; num678 < GenVars.numMCaves; num678++)
10916 {
10917 if (num674 > GenVars.mCaveX[num678] - 50 && num674 < GenVars.mCaveX[num678] + 50)
10918 {
10919 flag42 = false;
10920 break;
10921 }
10922 }
10923 if (flag42)
10924 {
10925 flag41 = GrowLivingTree(num674, num675);
10926 if (flag41)
10927 {
10928 for (int num679 = -1; num679 <= 1; num679++)
10929 {
10930 if (num679 != 0)
10931 {
10932 int num680 = num674;
10933 int num681 = genRand.Next(4);
10934 if (drunkWorldGen || Main.tenthAnniversaryWorld)
10935 {
10936 num681 += genRand.Next(2, 5);
10937 }
10938 else if (remixWorldGen)
10939 {
10940 num681 += genRand.Next(1, 6);
10941 }
10942 for (int num682 = 0; num682 < num681; num682++)
10943 {
10944 num680 += genRand.Next(13, 31) * num679;
10946 {
10947 int num683 = num675;
10948 if (Main.tile[num680, num683].active())
10949 {
10950 while (Main.tile[num680, num683].active())
10951 {
10952 num683--;
10953 }
10954 }
10955 else
10956 {
10957 for (; !Main.tile[num680, num683].active(); num683++)
10958 {
10959 }
10960 num683--;
10961 }
10962 flag42 = true;
10963 for (int num684 = num674 - 50; num684 < num674 + 50; num684++)
10964 {
10965 for (int num685 = num675 - 50; num685 < num675 + 50; num685++)
10966 {
10967 if (Main.tile[num684, num685].active())
10968 {
10969 switch (Main.tile[num684, num685].type)
10970 {
10971 case 41:
10972 case 43:
10973 case 44:
10974 case 189:
10975 case 196:
10976 case 460:
10977 case 481:
10978 case 482:
10979 case 483:
10980 flag42 = false;
10981 break;
10982 }
10983 }
10984 }
10985 }
10986 if (flag42)
10987 {
10988 GrowLivingTree(num680, num683, patch: true);
10989 }
10990 }
10991 }
10992 }
10993 }
10994 }
10995 }
10996 }
10997 }
10998 }
10999 }
11000 }
11001 Main.tileSolid[192] = false;
11002 });
11003 AddGenerationPass("Wood Tree Walls", delegate
11004 {
11005 for (int num665 = 25; num665 < Main.maxTilesX - 25; num665++)
11006 {
11007 for (int num666 = 25; (double)num666 < Main.worldSurface; num666++)
11008 {
11009 if (Main.tile[num665, num666].type == 191 || Main.tile[num665, num666 - 1].type == 191 || Main.tile[num665 - 1, num666].type == 191 || Main.tile[num665 + 1, num666].type == 191 || Main.tile[num665, num666 + 1].type == 191)
11010 {
11011 bool flag40 = true;
11012 for (int num667 = num665 - 1; num667 <= num665 + 1; num667++)
11013 {
11014 for (int num668 = num666 - 1; num668 <= num666 + 1; num668++)
11015 {
11016 if (num667 != num665 && num668 != num666 && Main.tile[num667, num668].type != 191 && Main.tile[num667, num668].wall != 244)
11017 {
11018 flag40 = false;
11019 }
11020 }
11021 }
11022 if (flag40)
11023 {
11024 Main.tile[num665, num666].wall = 244;
11025 }
11026 }
11027 }
11028 }
11029 });
11031 {
11032 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
11033 //IL_0204: Unknown result type (might be due to invalid IL or missing references)
11034 Main.tileSolid[484] = false;
11035 progress.Message = Lang.gen[26].Value;
11036 int num660 = (int)((double)(Main.maxTilesX * Main.maxTilesY) * 3.3E-06);
11037 if (remixWorldGen)
11038 {
11039 num660 *= 3;
11040 }
11041 for (int num661 = 0; num661 < num660; num661++)
11042 {
11043 progress.Set((double)num661 / (double)num660);
11044 for (int num662 = 0; num662 < 10000; num662++)
11045 {
11046 int num663 = genRand.Next(281, Main.maxTilesX - 3 - 280);
11047 while ((double)num663 > (double)Main.maxTilesX * 0.45 && (double)num663 < (double)Main.maxTilesX * 0.55)
11048 {
11049 num663 = genRand.Next(281, Main.maxTilesX - 3 - 280);
11050 }
11051 int num664 = genRand.Next((int)(Main.worldSurface * 2.0 + Main.rockLayer) / 3, (int)(Main.rockLayer + (double)((Main.maxTilesY - 350) * 2)) / 3);
11052 if (remixWorldGen)
11053 {
11054 num664 = genRand.Next(100, (int)((double)Main.maxTilesY * 0.9));
11055 }
11056 while (oceanDepths(num663, num664) || Vector2D.Distance(new Vector2D((double)num663, (double)num664), GenVars.shimmerPosition) < (double)shimmerSafetyDistance)
11057 {
11058 num663 = genRand.Next(281, Main.maxTilesX - 3 - 280);
11059 while ((double)num663 > (double)Main.maxTilesX * 0.45 && (double)num663 < (double)Main.maxTilesX * 0.55)
11060 {
11061 num663 = genRand.Next(281, Main.maxTilesX - 3 - 280);
11062 }
11063 num664 = genRand.Next((int)(Main.worldSurface * 2.0 + Main.rockLayer) / 3, (int)(Main.rockLayer + (double)((Main.maxTilesY - 350) * 2)) / 3);
11064 if (remixWorldGen)
11065 {
11066 num664 = genRand.Next(100, (int)((double)Main.maxTilesY * 0.9));
11067 }
11068 }
11069 int style2 = (crimson ? 1 : 0);
11070 if (drunkWorldGen)
11071 {
11072 style2 = (GenVars.crimsonLeft ? ((num663 < Main.maxTilesX / 2) ? 1 : 0) : ((num663 >= Main.maxTilesX / 2) ? 1 : 0));
11073 }
11074 if (!IsTileNearby(num663, num664, 26, 3))
11075 {
11076 Place3x2(num663, num664, 26, style2);
11077 }
11078 if (Main.tile[num663, num664].type == 26)
11079 {
11080 break;
11081 }
11082 }
11083 }
11084 });
11085 AddGenerationPass("Wet Jungle", delegate(GenerationProgress progress, GameConfiguration passConfig)
11086 {
11087 progress.Set(1.0);
11088 for (int num658 = 0; num658 < Main.maxTilesX; num658++)
11089 {
11090 for (int num659 = (int)GenVars.worldSurfaceLow; (double)num659 < Main.worldSurface - 1.0; num659++)
11091 {
11092 if (Main.tile[num658, num659].active())
11093 {
11094 if (Main.tile[num658, num659].type == 60)
11095 {
11096 Main.tile[num658, num659 - 1].liquid = byte.MaxValue;
11097 Main.tile[num658, num659 - 2].liquid = byte.MaxValue;
11098 }
11099 break;
11100 }
11101 }
11102 }
11103 });
11104 AddGenerationPass("Jungle Temple", delegate(GenerationProgress progress, GameConfiguration passConfig)
11105 {
11106 int num648 = 0;
11107 progress.Message = Lang.gen[70].Value;
11108 long num649 = 0L;
11109 double num650 = 0.25;
11110 bool flag38 = false;
11111 while (true)
11112 {
11113 int num651 = (int)Main.rockLayer;
11114 int num652 = Main.maxTilesY - 500;
11115 if (num651 > num652 - 1)
11116 {
11117 num651 = num652 - 1;
11118 }
11119 int num653 = genRand.Next(num651, num652);
11120 int num654 = (int)(((genRand.NextDouble() * num650 + 0.1) * (double)(-GenVars.dungeonSide) + 0.5) * (double)Main.maxTilesX);
11121 if (remixWorldGen)
11122 {
11123 if (notTheBees)
11124 {
11125 num654 = ((GenVars.dungeonSide <= 0) ? genRand.Next((int)((double)Main.maxTilesX * 0.6), (int)((double)Main.maxTilesX * 0.8)) : genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.4)));
11126 }
11127 else
11128 {
11129 num654 = genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8));
11130 while ((double)num654 > (double)Main.maxTilesX * 0.4 && (double)num654 < (double)Main.maxTilesX * 0.6)
11131 {
11132 num654 = genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8));
11133 }
11134 }
11135 while (Main.tile[num654, num653].active() || Main.tile[num654, num653].wall > 0 || (double)num653 > Main.worldSurface - 5.0)
11136 {
11137 num653--;
11138 }
11139 num653++;
11140 if (Main.tile[num654, num653].active() && (Main.tile[num654, num653].type == 60 || Main.tile[num654, num653].type == 59))
11141 {
11142 int num655 = 10;
11143 bool flag39 = false;
11144 for (int num656 = num654 - num655; num656 <= num656 + num655; num656++)
11145 {
11146 for (int num657 = num653 - num655; num657 < num655; num657++)
11147 {
11148 if (Main.tile[num656, num657].type == 191 || Main.tileDungeon[Main.tile[num656, num657].type])
11149 {
11150 flag39 = true;
11151 }
11152 }
11153 }
11154 if (!flag39)
11155 {
11156 flag38 = true;
11157 num653 -= 10 + genRand.Next(10);
11158 makeTemple(num654, num653);
11159 break;
11160 }
11161 }
11162 }
11163 else if (Main.tile[num654, num653].active() && Main.tile[num654, num653].type == 60)
11164 {
11165 flag38 = true;
11166 makeTemple(num654, num653);
11167 break;
11168 }
11169 if (num649++ > 2000000)
11170 {
11171 if (num650 == 0.35)
11172 {
11173 num648++;
11174 if (num648 > 10)
11175 {
11176 break;
11177 }
11178 }
11179 num650 = Math.Min(0.35, num650 + 0.05);
11180 num649 = 0L;
11181 }
11182 }
11183 if (!flag38)
11184 {
11185 int x14 = Main.maxTilesX - GenVars.dungeonX;
11186 int y14 = (int)Main.rockLayer + 100;
11187 if (remixWorldGen)
11188 {
11189 x14 = ((!notTheBees) ? ((GenVars.dungeonSide > 0) ? ((int)((double)Main.maxTilesX * 0.4)) : ((int)((double)Main.maxTilesX * 0.6))) : ((GenVars.dungeonSide > 0) ? ((int)((double)Main.maxTilesX * 0.3)) : ((int)((double)Main.maxTilesX * 0.7))));
11190 }
11191 makeTemple(x14, y14);
11192 }
11193 });
11195 {
11196 progress.Message = Lang.gen[71].Value;
11197 double num639 = (double)Main.maxTilesX / 4200.0;
11198 double num640 = 1 + genRand.Next((int)(5.0 * num639), (int)(8.0 * num639));
11199 if (drunkWorldGen)
11200 {
11201 num640 *= 0.667;
11202 }
11203 int num641 = 10000;
11206 while (num640 > 0.0 && num641 > 0)
11207 {
11208 num641--;
11209 Point origin3 = RandomWorldPoint((int)(Main.worldSurface + Main.rockLayer) >> 1, 20, 300, 20);
11210 if (drunkWorldGen)
11211 {
11212 RandomWorldPoint((int)Main.worldSurface, 20, 300, 20);
11213 }
11214 if (hiveBiome.Place(origin3, GenVars.structures))
11215 {
11216 num640 -= 1.0;
11217 int num642 = genRand.Next(5);
11218 int num643 = 0;
11219 int num644 = 10000;
11221 {
11222 double num645 = genRand.NextDouble() * 60.0 + 30.0;
11223 double num646 = genRand.NextDouble() * 6.2831854820251465;
11224 int num647 = (int)(Math.Cos(num646) * num645) + origin3.X;
11225 int y13 = (int)(Math.Sin(num646) * num645) + origin3.Y;
11226 num644--;
11227 if (num647 > 50 && num647 < Main.maxTilesX - 50 && honeyPatchBiome.Place(new Point(num647, y13), GenVars.structures))
11228 {
11229 num643++;
11230 }
11231 }
11232 }
11233 }
11234 });
11235 AddGenerationPass("Jungle Chests", delegate
11236 {
11237 int num613 = genRand.Next(40, Main.maxTilesX - 40);
11238 int num614 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 400);
11239 double num615 = genRand.Next(7, 12);
11240 num615 *= (double)Main.maxTilesX / 4200.0;
11241 int num616 = 0;
11242 for (int num617 = 0; (double)num617 < num615; num617++)
11243 {
11244 bool flag36 = true;
11245 while (flag36)
11246 {
11247 num616++;
11248 num613 = genRand.Next(40, Main.maxTilesX / 2 - 40);
11249 if (GenVars.dungeonSide < 0)
11250 {
11251 num613 += Main.maxTilesX / 2;
11252 }
11253 num614 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 400);
11254 int num618 = genRand.Next(2, 4);
11255 int num619 = genRand.Next(2, 4);
11256 Rectangle area = new Rectangle(num613 - num618 - 1, num614 - num619 - 1, num618 + 1, num619 + 1);
11257 if (Main.tile[num613, num614].type == 60)
11258 {
11259 int num620 = 30;
11260 flag36 = false;
11261 for (int num621 = num613 - num620; num621 < num613 + num620; num621 += 3)
11262 {
11263 for (int num622 = num614 - num620; num622 < num614 + num620; num622 += 3)
11264 {
11265 if (Main.tile[num621, num622].active() && (Main.tile[num621, num622].type == 225 || Main.tile[num621, num622].type == 229 || Main.tile[num621, num622].type == 226 || Main.tile[num621, num622].type == 119 || Main.tile[num621, num622].type == 120))
11266 {
11267 flag36 = true;
11268 }
11269 if (Main.tile[num621, num622].wall == 86 || Main.tile[num621, num622].wall == 87)
11270 {
11271 flag36 = true;
11272 }
11273 }
11274 }
11275 if (!GenVars.structures.CanPlace(area, 1))
11276 {
11277 flag36 = true;
11278 }
11279 }
11280 if (!flag36)
11281 {
11282 ushort wall2 = 0;
11283 if (GenVars.jungleHut == 119)
11284 {
11285 wall2 = 23;
11286 }
11287 else if (GenVars.jungleHut == 120)
11288 {
11289 wall2 = 24;
11290 }
11291 else if (GenVars.jungleHut == 158)
11292 {
11293 wall2 = 42;
11294 }
11295 else if (GenVars.jungleHut == 175)
11296 {
11297 wall2 = 45;
11298 }
11299 else if (GenVars.jungleHut == 45)
11300 {
11301 wall2 = 10;
11302 }
11303 for (int num623 = num613 - num618 - 1; num623 <= num613 + num618 + 1; num623++)
11304 {
11305 for (int num624 = num614 - num619 - 1; num624 <= num614 + num619 + 1; num624++)
11306 {
11307 Main.tile[num623, num624].active(active: true);
11309 Main.tile[num623, num624].liquid = 0;
11310 Main.tile[num623, num624].lava(lava: false);
11311 }
11312 }
11313 for (int num625 = num613 - num618; num625 <= num613 + num618; num625++)
11314 {
11315 for (int num626 = num614 - num619; num626 <= num614 + num619; num626++)
11316 {
11317 Main.tile[num625, num626].active(active: false);
11318 Main.tile[num625, num626].wall = wall2;
11319 }
11320 }
11321 bool flag37 = false;
11322 int num627 = 0;
11323 while (!flag37 && num627 < 100)
11324 {
11325 num627++;
11326 int num628 = genRand.Next(num613 - num618, num613 + num618 + 1);
11327 int num629 = genRand.Next(num614 - num619, num614 + num619 - 2);
11328 PlaceTile(num628, num629, 4, mute: true, forced: false, -1, 3);
11329 if (Main.tile[num628, num629].type == 4)
11330 {
11331 flag37 = true;
11332 }
11333 }
11334 for (int num630 = num613 - num618 - 1; num630 <= num613 + num618 + 1; num630++)
11335 {
11336 for (int num631 = num614 + num619 - 2; num631 <= num614 + num619; num631++)
11337 {
11338 Main.tile[num630, num631].active(active: false);
11339 }
11340 }
11341 for (int num632 = num613 - num618 - 1; num632 <= num613 + num618 + 1; num632++)
11342 {
11343 for (int num633 = num614 + num619 - 2; num633 <= num614 + num619 - 1; num633++)
11344 {
11345 Main.tile[num632, num633].active(active: false);
11346 }
11347 }
11348 for (int num634 = num613 - num618 - 1; num634 <= num613 + num618 + 1; num634++)
11349 {
11350 int num635 = 4;
11351 int num636 = num614 + num619 + 2;
11353 {
11354 Main.tile[num634, num636].active(active: true);
11355 Main.tile[num634, num636].type = 59;
11356 num636++;
11357 num635--;
11358 }
11359 }
11360 num618 -= genRand.Next(1, 3);
11361 int num637 = num614 - num619 - 2;
11362 while (num618 > -1)
11363 {
11364 for (int num638 = num613 - num618 - 1; num638 <= num613 + num618 + 1; num638++)
11365 {
11366 Main.tile[num638, num637].active(active: true);
11368 }
11369 num618 -= genRand.Next(1, 3);
11370 num637--;
11371 }
11374 GenVars.structures.AddProtectedStructure(area);
11376 num616 = 0;
11377 }
11378 else if (num616 > Main.maxTilesX * 10)
11379 {
11380 num617++;
11381 num616 = 0;
11382 break;
11383 }
11384 }
11385 }
11386 Main.tileSolid[137] = false;
11387 });
11388 AddGenerationPass("Settle Liquids", delegate(GenerationProgress progress, GameConfiguration passConfig)
11389 {
11390 progress.Message = Lang.gen[27].Value;
11391 if (notTheBees)
11392 {
11393 NotTheBees();
11394 }
11395 Liquid.worldGenTilesIgnoreWater(ignoreSolids: true);
11396 Liquid.QuickWater(3);
11397 WaterCheck();
11398 int num606 = 0;
11399 Liquid.quickSettle = true;
11400 int num607 = 10;
11401 while (num606 < num607)
11402 {
11403 int num608 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
11404 num606++;
11405 double num609 = 0.0;
11406 int num610 = num608 * 5;
11407 while (Liquid.numLiquid > 0)
11408 {
11409 num610--;
11410 if (num610 < 0)
11411 {
11412 break;
11413 }
11414 double num611 = (double)(num608 - (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer)) / (double)num608;
11415 if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > num608)
11416 {
11417 num608 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
11418 }
11419 if (num611 > num609)
11420 {
11421 num609 = num611;
11422 }
11423 else
11424 {
11425 num611 = num609;
11426 }
11427 if (num606 == 1)
11428 {
11429 progress.Set(num611 / 3.0 + 0.33);
11430 }
11431 int num612 = 10;
11432 if (num606 > num612)
11433 {
11434 num612 = num606;
11435 }
11436 Liquid.UpdateLiquid();
11437 }
11438 WaterCheck();
11439 progress.Set((double)num606 * 0.1 / 3.0 + 0.66);
11440 }
11441 Liquid.quickSettle = false;
11442 Liquid.worldGenTilesIgnoreWater(ignoreSolids: false);
11443 Main.tileSolid[484] = false;
11444 });
11445 AddGenerationPass("Remove Water From Sand", delegate(GenerationProgress progress, GameConfiguration passConfig)
11446 {
11447 progress.Set(1.0);
11448 for (int num603 = 400; num603 < Main.maxTilesX - 400; num603++)
11449 {
11450 for (int num604 = 100; (double)num604 < Main.worldSurface - 1.0; num604++)
11451 {
11452 if (Main.tile[num603, num604].active())
11453 {
11454 ushort type7 = Main.tile[num603, num604].type;
11455 if (type7 == 53 || type7 == 396 || type7 == 397 || type7 == 404 || type7 == 407 || type7 == 151)
11456 {
11457 int num605 = num604;
11458 while (num605 > 100)
11459 {
11460 num605--;
11461 if (Main.tile[num603, num605].active())
11462 {
11463 break;
11464 }
11465 Main.tile[num603, num605].liquid = 0;
11466 }
11467 }
11468 break;
11469 }
11470 }
11471 }
11472 Main.tileSolid[192] = true;
11473 });
11475 {
11476 if (!notTheBees)
11477 {
11478 progress.Set(1.0);
11479 int num599 = Main.maxTilesX / 2100;
11480 num599 += genRand.Next(2);
11481 for (int num600 = 0; num600 < num599; num600++)
11482 {
11483 int num601 = beachDistance + 300;
11484 int num602 = Main.maxTilesX * 2;
11485 while (num602 > 0)
11486 {
11487 num602--;
11488 int x13 = genRand.Next(num601, Main.maxTilesX - num601);
11489 int y12 = genRand.Next(100, (int)Main.worldSurface);
11490 if (PlaceOasis(x13, y12))
11491 {
11492 num602 = -1;
11493 }
11494 }
11495 }
11496 }
11497 });
11498 AddGenerationPass("Shell Piles", delegate(GenerationProgress progress, GameConfiguration passConfig)
11499 {
11500 if (dontStarveWorldGen)
11501 {
11502 int num587 = (int)(5.0 * ((double)Main.maxTilesX / 4200.0));
11503 int num588 = 0;
11504 int num589 = 100;
11505 int num590 = Main.maxTilesX / 2;
11506 int num591 = num590 - num589;
11507 int num592 = num590 + num589;
11508 for (int num593 = 0; num593 < 80; num593++)
11509 {
11510 int num594 = genRand.Next(100, Main.maxTilesX - 100);
11511 if (num594 >= num591 && num594 <= num592)
11512 {
11513 num594 = genRand.Next(100, Main.maxTilesX - 100);
11514 if (num594 >= num591 && num594 <= num592)
11515 {
11516 continue;
11517 }
11518 }
11519 int y11 = (int)Main.worldSurface / 2;
11520 if (MarblePileWithStatues(num594, y11))
11521 {
11522 num588++;
11523 if (num588 >= num587)
11524 {
11525 break;
11526 }
11527 }
11528 }
11529 }
11530 if (!notTheBees)
11531 {
11532 progress.Set(1.0);
11533 if (genRand.Next(2) == 0)
11534 {
11535 int shellStartXLeft = GenVars.shellStartXLeft;
11536 int shellStartYLeft = GenVars.shellStartYLeft;
11537 for (int num595 = shellStartXLeft - 20; num595 <= shellStartXLeft + 20; num595++)
11538 {
11539 for (int num596 = shellStartYLeft - 10; num596 <= shellStartYLeft + 10; num596++)
11540 {
11541 if (Main.tile[num595, num596].active() && Main.tile[num595, num596].type == 53 && !Main.tile[num595, num596 - 1].active() && Main.tile[num595, num596 - 1].liquid == 0 && !Main.tile[num595 - 1, num596].active() && Main.tile[num595 - 1, num596].liquid > 0)
11542 {
11543 GenVars.shellStartXLeft = num595;
11544 GenVars.shellStartYLeft = num596;
11545 }
11546 }
11547 }
11548 GenVars.shellStartYLeft -= 50;
11549 GenVars.shellStartXLeft -= genRand.Next(5);
11550 if (genRand.Next(2) == 0)
11551 {
11552 GenVars.shellStartXLeft -= genRand.Next(10);
11553 }
11554 if (genRand.Next(3) == 0)
11555 {
11556 GenVars.shellStartXLeft -= genRand.Next(15);
11557 }
11558 if (genRand.Next(4) != 0)
11559 {
11561 }
11562 int maxValue9 = genRand.Next(2, 4);
11563 if (genRand.Next(maxValue9) == 0)
11564 {
11565 ShellPile(GenVars.shellStartXLeft - genRand.Next(10, 35), GenVars.shellStartYLeft);
11566 }
11567 if (genRand.Next(maxValue9) == 0)
11568 {
11569 ShellPile(GenVars.shellStartXLeft - genRand.Next(40, 65), GenVars.shellStartYLeft);
11570 }
11571 if (genRand.Next(maxValue9) == 0)
11572 {
11573 ShellPile(GenVars.shellStartXLeft - genRand.Next(70, 95), GenVars.shellStartYLeft);
11574 }
11575 if (genRand.Next(maxValue9) == 0)
11576 {
11577 ShellPile(GenVars.shellStartXLeft - genRand.Next(100, 125), GenVars.shellStartYLeft);
11578 }
11579 if (genRand.Next(maxValue9) == 0)
11580 {
11581 ShellPile(GenVars.shellStartXLeft + genRand.Next(10, 25), GenVars.shellStartYLeft);
11582 }
11583 }
11584 if (genRand.Next(2) == 0)
11585 {
11586 int shellStartXRight = GenVars.shellStartXRight;
11587 int shellStartYRight = GenVars.shellStartYRight;
11588 for (int num597 = shellStartXRight - 20; num597 <= shellStartXRight + 20; num597++)
11589 {
11590 for (int num598 = shellStartYRight - 10; num598 <= shellStartYRight + 10; num598++)
11591 {
11592 if (Main.tile[num597, num598].active() && Main.tile[num597, num598].type == 53 && !Main.tile[num597, num598 - 1].active() && Main.tile[num597, num598 - 1].liquid == 0 && !Main.tile[num597 + 1, num598].active() && Main.tile[num597 + 1, num598].liquid > 0)
11593 {
11594 GenVars.shellStartXRight = num597;
11595 GenVars.shellStartYRight = num598;
11596 }
11597 }
11598 }
11599 GenVars.shellStartYRight -= 50;
11600 GenVars.shellStartXRight += genRand.Next(5);
11601 if (genRand.Next(2) == 0)
11602 {
11603 GenVars.shellStartXLeft += genRand.Next(10);
11604 }
11605 if (genRand.Next(3) == 0)
11606 {
11607 GenVars.shellStartXLeft += genRand.Next(15);
11608 }
11609 if (genRand.Next(4) != 0)
11610 {
11612 }
11613 int maxValue10 = genRand.Next(2, 4);
11614 if (genRand.Next(maxValue10) == 0)
11615 {
11616 ShellPile(GenVars.shellStartXRight + genRand.Next(10, 35), GenVars.shellStartYRight);
11617 }
11618 if (genRand.Next(maxValue10) == 0)
11619 {
11620 ShellPile(GenVars.shellStartXRight + genRand.Next(40, 65), GenVars.shellStartYRight);
11621 }
11622 if (genRand.Next(maxValue10) == 0)
11623 {
11624 ShellPile(GenVars.shellStartXRight + genRand.Next(70, 95), GenVars.shellStartYRight);
11625 }
11626 if (genRand.Next(maxValue10) == 0)
11627 {
11628 ShellPile(GenVars.shellStartXRight + genRand.Next(100, 125), GenVars.shellStartYRight);
11629 }
11630 if (genRand.Next(maxValue10) == 0)
11631 {
11632 ShellPile(GenVars.shellStartXRight - genRand.Next(10, 25), GenVars.shellStartYRight);
11633 }
11634 }
11635 }
11636 });
11637 AddGenerationPass("Smooth World", delegate(GenerationProgress progress, GameConfiguration passConfig)
11638 {
11639 progress.Message = Lang.gen[60].Value;
11641 for (int num583 = 20; num583 < Main.maxTilesX - 20; num583++)
11642 {
11643 double value11 = (double)num583 / (double)Main.maxTilesX;
11644 progress.Set(value11);
11645 for (int num584 = 20; num584 < Main.maxTilesY - 20; num584++)
11646 {
11647 if (Main.tile[num583, num584].type != 48 && Main.tile[num583, num584].type != 137 && Main.tile[num583, num584].type != 232 && Main.tile[num583, num584].type != 191 && Main.tile[num583, num584].type != 151 && Main.tile[num583, num584].type != 274)
11648 {
11649 if (!Main.tile[num583, num584 - 1].active() && Main.tile[num583 - 1, num584].type != 136 && Main.tile[num583 + 1, num584].type != 136)
11650 {
11652 {
11653 if (!Main.tile[num583 - 1, num584].halfBrick() && !Main.tile[num583 + 1, num584].halfBrick() && Main.tile[num583 - 1, num584].slope() == 0 && Main.tile[num583 + 1, num584].slope() == 0)
11654 {
11655 if (SolidTile(num583, num584 + 1))
11656 {
11657 if (!SolidTile(num583 - 1, num584) && !Main.tile[num583 - 1, num584 + 1].halfBrick() && SolidTile(num583 - 1, num584 + 1) && SolidTile(num583 + 1, num584) && !Main.tile[num583 + 1, num584 - 1].active())
11658 {
11659 if (genRand.Next(2) == 0)
11660 {
11661 SlopeTile(num583, num584, 2);
11662 }
11663 else
11664 {
11665 PoundTile(num583, num584);
11666 }
11667 }
11668 else if (!SolidTile(num583 + 1, num584) && !Main.tile[num583 + 1, num584 + 1].halfBrick() && SolidTile(num583 + 1, num584 + 1) && SolidTile(num583 - 1, num584) && !Main.tile[num583 - 1, num584 - 1].active())
11669 {
11670 if (genRand.Next(2) == 0)
11671 {
11672 SlopeTile(num583, num584, 1);
11673 }
11674 else
11675 {
11676 PoundTile(num583, num584);
11677 }
11678 }
11679 else if (SolidTile(num583 + 1, num584 + 1) && SolidTile(num583 - 1, num584 + 1) && !Main.tile[num583 + 1, num584].active() && !Main.tile[num583 - 1, num584].active())
11680 {
11681 PoundTile(num583, num584);
11682 }
11683 if (SolidTile(num583, num584))
11684 {
11685 if (SolidTile(num583 - 1, num584) && SolidTile(num583 + 1, num584 + 2) && !Main.tile[num583 + 1, num584].active() && !Main.tile[num583 + 1, num584 + 1].active() && !Main.tile[num583 - 1, num584 - 1].active())
11686 {
11687 KillTile(num583, num584);
11688 }
11689 else if (SolidTile(num583 + 1, num584) && SolidTile(num583 - 1, num584 + 2) && !Main.tile[num583 - 1, num584].active() && !Main.tile[num583 - 1, num584 + 1].active() && !Main.tile[num583 + 1, num584 - 1].active())
11690 {
11691 KillTile(num583, num584);
11692 }
11693 else if (!Main.tile[num583 - 1, num584 + 1].active() && !Main.tile[num583 - 1, num584].active() && SolidTile(num583 + 1, num584) && SolidTile(num583, num584 + 2))
11694 {
11695 if (genRand.Next(5) == 0)
11696 {
11697 KillTile(num583, num584);
11698 }
11699 else if (genRand.Next(5) == 0)
11700 {
11701 PoundTile(num583, num584);
11702 }
11703 else
11704 {
11705 SlopeTile(num583, num584, 2);
11706 }
11707 }
11708 else if (!Main.tile[num583 + 1, num584 + 1].active() && !Main.tile[num583 + 1, num584].active() && SolidTile(num583 - 1, num584) && SolidTile(num583, num584 + 2))
11709 {
11710 if (genRand.Next(5) == 0)
11711 {
11712 KillTile(num583, num584);
11713 }
11714 else if (genRand.Next(5) == 0)
11715 {
11716 PoundTile(num583, num584);
11717 }
11718 else
11719 {
11720 SlopeTile(num583, num584, 1);
11721 }
11722 }
11723 }
11724 }
11725 if (SolidTile(num583, num584) && !Main.tile[num583 - 1, num584].active() && !Main.tile[num583 + 1, num584].active())
11726 {
11727 KillTile(num583, num584);
11728 }
11729 }
11730 }
11731 else if (!Main.tile[num583, num584].active() && Main.tile[num583, num584 + 1].type != 151 && Main.tile[num583, num584 + 1].type != 274)
11732 {
11733 if (Main.tile[num583 + 1, num584].type != 190 && Main.tile[num583 + 1, num584].type != 48 && Main.tile[num583 + 1, num584].type != 232 && SolidTile(num583 - 1, num584 + 1) && SolidTile(num583 + 1, num584) && !Main.tile[num583 - 1, num584].active() && !Main.tile[num583 + 1, num584 - 1].active())
11734 {
11735 if (Main.tile[num583 + 1, num584].type == 495)
11736 {
11737 PlaceTile(num583, num584, Main.tile[num583 + 1, num584].type);
11738 }
11739 else
11740 {
11741 PlaceTile(num583, num584, Main.tile[num583, num584 + 1].type);
11742 }
11743 if (genRand.Next(2) == 0)
11744 {
11745 SlopeTile(num583, num584, 2);
11746 }
11747 else
11748 {
11749 PoundTile(num583, num584);
11750 }
11751 }
11752 if (Main.tile[num583 - 1, num584].type != 190 && Main.tile[num583 - 1, num584].type != 48 && Main.tile[num583 - 1, num584].type != 232 && SolidTile(num583 + 1, num584 + 1) && SolidTile(num583 - 1, num584) && !Main.tile[num583 + 1, num584].active() && !Main.tile[num583 - 1, num584 - 1].active())
11753 {
11754 if (Main.tile[num583 - 1, num584].type == 495)
11755 {
11756 PlaceTile(num583, num584, Main.tile[num583 - 1, num584].type);
11757 }
11758 else
11759 {
11760 PlaceTile(num583, num584, Main.tile[num583, num584 + 1].type);
11761 }
11762 if (genRand.Next(2) == 0)
11763 {
11764 SlopeTile(num583, num584, 1);
11765 }
11766 else
11767 {
11768 PoundTile(num583, num584);
11769 }
11770 }
11771 }
11772 }
11773 else if (!Main.tile[num583, num584 + 1].active() && genRand.Next(2) == 0 && SolidTile(num583, num584) && !Main.tile[num583 - 1, num584].halfBrick() && !Main.tile[num583 + 1, num584].halfBrick() && Main.tile[num583 - 1, num584].slope() == 0 && Main.tile[num583 + 1, num584].slope() == 0 && SolidTile(num583, num584 - 1))
11774 {
11775 if (SolidTile(num583 - 1, num584) && !SolidTile(num583 + 1, num584) && SolidTile(num583 - 1, num584 - 1))
11776 {
11777 SlopeTile(num583, num584, 3);
11778 }
11779 else if (SolidTile(num583 + 1, num584) && !SolidTile(num583 - 1, num584) && SolidTile(num583 + 1, num584 - 1))
11780 {
11781 SlopeTile(num583, num584, 4);
11782 }
11783 }
11785 {
11787 }
11788 }
11789 }
11790 }
11791 for (int num585 = 20; num585 < Main.maxTilesX - 20; num585++)
11792 {
11793 for (int num586 = 20; num586 < Main.maxTilesY - 20; num586++)
11794 {
11795 if (genRand.Next(2) == 0 && !Main.tile[num585, num586 - 1].active() && Main.tile[num585, num586].type != 137 && Main.tile[num585, num586].type != 48 && Main.tile[num585, num586].type != 232 && Main.tile[num585, num586].type != 191 && Main.tile[num585, num586].type != 151 && Main.tile[num585, num586].type != 274 && Main.tile[num585, num586].type != 75 && Main.tile[num585, num586].type != 76 && SolidTile(num585, num586) && Main.tile[num585 - 1, num586].type != 137 && Main.tile[num585 + 1, num586].type != 137)
11796 {
11797 if (SolidTile(num585, num586 + 1) && SolidTile(num585 + 1, num586) && !Main.tile[num585 - 1, num586].active())
11798 {
11799 SlopeTile(num585, num586, 2);
11800 }
11801 if (SolidTile(num585, num586 + 1) && SolidTile(num585 - 1, num586) && !Main.tile[num585 + 1, num586].active())
11802 {
11803 SlopeTile(num585, num586, 1);
11804 }
11805 }
11806 if (Main.tile[num585, num586].slope() == 1 && !SolidTile(num585 - 1, num586))
11807 {
11808 SlopeTile(num585, num586);
11809 PoundTile(num585, num586);
11810 }
11811 if (Main.tile[num585, num586].slope() == 2 && !SolidTile(num585 + 1, num586))
11812 {
11813 SlopeTile(num585, num586);
11814 PoundTile(num585, num586);
11815 }
11816 }
11817 }
11818 Main.tileSolid[137] = true;
11819 Main.tileSolid[190] = false;
11820 Main.tileSolid[192] = false;
11822 });
11823 AddGenerationPass("Waterfalls", delegate(GenerationProgress progress, GameConfiguration passConfig)
11824 {
11825 progress.Message = Lang.gen[69].Value;
11826 Main.tileSolid[191] = false;
11827 for (int num574 = 20; num574 < Main.maxTilesX - 20; num574++)
11828 {
11829 double num575 = (double)num574 / (double)Main.maxTilesX;
11830 progress.Set(num575 * 0.5);
11831 for (int num576 = 20; num576 < Main.maxTilesY - 20; num576++)
11832 {
11833 if (SolidTile(num574, num576) && !Main.tile[num574 - 1, num576].active() && SolidTile(num574, num576 + 1) && !Main.tile[num574 + 1, num576].active() && (Main.tile[num574 - 1, num576].liquid > 0 || Main.tile[num574 + 1, num576].liquid > 0))
11834 {
11835 bool flag35 = true;
11836 int num577 = genRand.Next(8, 20);
11837 int num578 = genRand.Next(8, 20);
11838 num577 = num576 - num577;
11839 num578 += num576;
11840 for (int num579 = num577; num579 <= num578; num579++)
11841 {
11842 if (Main.tile[num574, num579].halfBrick())
11843 {
11844 flag35 = false;
11845 }
11846 }
11847 if ((Main.tile[num574, num576].type == 75 || Main.tile[num574, num576].type == 76) && genRand.Next(10) != 0)
11848 {
11849 flag35 = false;
11850 }
11851 if (flag35)
11852 {
11853 PoundTile(num574, num576);
11854 }
11855 }
11856 }
11857 }
11858 for (int num580 = 20; num580 < Main.maxTilesX - 20; num580++)
11859 {
11860 double num581 = (double)num580 / (double)Main.maxTilesX;
11861 progress.Set(num581 * 0.5 + 0.5);
11862 for (int num582 = 20; num582 < Main.maxTilesY - 20; num582++)
11863 {
11864 if (Main.tile[num580, num582].type != 48 && Main.tile[num580, num582].type != 232 && SolidTile(num580, num582) && SolidTile(num580, num582 + 1))
11865 {
11866 if (!SolidTile(num580 + 1, num582) && Main.tile[num580 - 1, num582].halfBrick() && Main.tile[num580 - 2, num582].liquid > 0)
11867 {
11868 PoundTile(num580, num582);
11869 }
11870 if (!SolidTile(num580 - 1, num582) && Main.tile[num580 + 1, num582].halfBrick() && Main.tile[num580 + 2, num582].liquid > 0)
11871 {
11872 PoundTile(num580, num582);
11873 }
11874 }
11875 }
11876 }
11877 Main.tileSolid[191] = true;
11878 });
11880 {
11881 if (notTheBees)
11882 {
11883 NotTheBees();
11884 }
11885 progress.Set(1.0);
11886 for (int num572 = 10; num572 < Main.maxTilesX - 10; num572++)
11887 {
11888 for (int num573 = (int)Main.worldSurface; num573 < Main.maxTilesY - 100; num573++)
11889 {
11890 if (Main.tile[num572, num573].liquid > 0 && (!Main.tile[num572, num573].lava() || remixWorldGen))
11891 {
11892 MakeWateryIceThing(num572, num573);
11893 }
11894 }
11895 }
11896 Main.tileSolid[226] = false;
11897 Main.tileSolid[162] = false;
11898 });
11899 AddGenerationPass("Wall Variety", delegate(GenerationProgress progress, GameConfiguration passConfig)
11900 {
11901 //IL_0093: Unknown result type (might be due to invalid IL or missing references)
11902 //IL_0098: Unknown result type (might be due to invalid IL or missing references)
11903 progress.Message = Lang.gen[79].Value;
11904 double num568 = (double)(Main.maxTilesX * Main.maxTilesY) / 5040000.0;
11905 int num569 = (int)(300.0 * num568);
11906 int num570 = num569;
11908 while (num569 > 0)
11909 {
11910 progress.Set(1.0 - (double)num569 / (double)num570);
11911 Point point2 = RandomWorldPoint((int)GenVars.worldSurface, 2, 190, 2);
11912 while (Vector2D.Distance(new Vector2D((double)point2.X, (double)point2.Y), GenVars.shimmerPosition) < (double)shimmerSafetyDistance)
11913 {
11914 point2 = RandomWorldPoint((int)GenVars.worldSurface, 2, 190, 2);
11915 }
11916 Tile tile6 = Main.tile[point2.X, point2.Y];
11917 Tile tile7 = Main.tile[point2.X, point2.Y - 1];
11918 ushort num571 = 0;
11919 if (tile6.type == 60)
11920 {
11921 num571 = (ushort)(204 + genRand.Next(4));
11922 }
11923 else if (tile6.type == 1 && tile7.wall == 0)
11924 {
11925 num571 = (remixWorldGen ? (((double)point2.Y > GenVars.rockLayer) ? ((ushort)(196 + genRand.Next(4))) : ((point2.Y <= GenVars.lavaLine || genRand.Next(2) != 0) ? ((ushort)(212 + genRand.Next(4))) : ((ushort)(208 + genRand.Next(4))))) : (((double)point2.Y < GenVars.rockLayer) ? ((ushort)(196 + genRand.Next(4))) : ((point2.Y >= GenVars.lavaLine) ? ((ushort)(208 + genRand.Next(4))) : ((ushort)(212 + genRand.Next(4))))));
11926 }
11927 if (tile6.active() && num571 != 0 && !tile7.active())
11928 {
11929 bool foundInvalidTile = false;
11930 bool flag34 = ((tile6.type != 60) ? WorldUtils.Gen(new Point(point2.X, point2.Y - 1), new ShapeFloodFill(1000), Actions.Chain(new Modifiers.IsNotSolid(), new Actions.Blank().Output(shapeData), new Actions.ContinueWrapper(Actions.Chain(new Modifiers.IsTouching(true, 60, 147, 161, 396, 397, 70, 191), new Modifiers.IsTouching(true, 147, 161, 396, 397, 70, 191), new Actions.Custom(delegate
11931 {
11932 foundInvalidTile = true;
11933 return true;
11934 }))))) : WorldUtils.Gen(new Point(point2.X, point2.Y - 1), new ShapeFloodFill(1000), Actions.Chain(new Modifiers.IsNotSolid(), new Actions.Blank().Output(shapeData), new Actions.ContinueWrapper(Actions.Chain(new Modifiers.IsTouching(true, 147, 161, 396, 397, 70, 191), new Actions.Custom(delegate
11935 {
11936 foundInvalidTile = true;
11937 return true;
11938 }))))));
11939 if (shapeData.Count > 50 && flag34 && !foundInvalidTile)
11940 {
11942 num569--;
11943 }
11944 shapeData.Clear();
11945 }
11946 }
11947 });
11948 AddGenerationPass("Life Crystals", delegate(GenerationProgress progress, GameConfiguration passConfig)
11949 {
11950 if (getGoodWorldGen)
11951 {
11952 Main.tileSolid[56] = false;
11953 }
11954 if (notTheBees)
11955 {
11956 NotTheBees();
11957 }
11958 progress.Message = Lang.gen[28].Value;
11959 double num565 = (double)(Main.maxTilesX * Main.maxTilesY) * 2E-05;
11960 if (tenthAnniversaryWorldGen)
11961 {
11962 num565 *= 1.2;
11963 }
11964 if (Main.starGame)
11965 {
11966 num565 *= Main.starGameMath(0.2);
11967 }
11968 for (int num566 = 0; num566 < (int)num565; num566++)
11969 {
11970 double value10 = (double)num566 / ((double)(Main.maxTilesX * Main.maxTilesY) * 2E-05);
11971 progress.Set(value10);
11972 bool flag33 = false;
11973 int num567 = 0;
11974 while (!flag33)
11975 {
11976 int j3 = genRand.Next((int)(Main.worldSurface * 2.0 + Main.rockLayer) / 3, Main.maxTilesY - 300);
11977 if (remixWorldGen)
11978 {
11979 j3 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 400);
11980 }
11981 if (AddLifeCrystal(genRand.Next(Main.offLimitBorderTiles, Main.maxTilesX - Main.offLimitBorderTiles), j3))
11982 {
11983 flag33 = true;
11984 }
11985 else
11986 {
11987 num567++;
11988 if (num567 >= 10000)
11989 {
11990 flag33 = true;
11991 }
11992 }
11993 }
11994 }
11995 Main.tileSolid[225] = false;
11996 });
11997 AddGenerationPass("Statues", delegate(GenerationProgress progress, GameConfiguration passConfig)
11998 {
11999 progress.Message = Lang.gen[29].Value;
12000 int num558 = 0;
12001 double num559 = (double)Main.maxTilesX / 4200.0;
12002 int num560 = (int)((double)(GenVars.statueList.Length * 2) * num559);
12003 if (noTrapsWorldGen)
12004 {
12005 num560 *= 15;
12006 if (tenthAnniversaryWorldGen || notTheBees)
12007 {
12008 num560 /= 5;
12009 }
12010 }
12011 if (Main.starGame)
12012 {
12013 num560 = (int)((double)num560 * Main.starGameMath(0.2));
12014 }
12015 for (int num561 = 0; num561 < num560; num561++)
12016 {
12017 if (num558 >= GenVars.statueList.Length)
12018 {
12019 num558 = 0;
12020 }
12021 int x12 = GenVars.statueList[num558].X;
12022 int y10 = GenVars.statueList[num558].Y;
12023 double value9 = num561 / num560;
12024 progress.Set(value9);
12025 bool flag32 = false;
12026 int num562 = 0;
12027 while (!flag32)
12028 {
12029 int num563 = genRand.Next(20, Main.maxTilesX - 20);
12030 int num564 = genRand.Next((int)(Main.worldSurface * 2.0 + Main.rockLayer) / 3, Main.maxTilesY - 300);
12031 if (remixWorldGen)
12032 {
12033 genRand.Next((int)Main.worldSurface, Main.maxTilesY - 400);
12034 }
12035 while (oceanDepths(num563, num564))
12036 {
12037 num563 = genRand.Next(20, Main.maxTilesX - 20);
12038 num564 = genRand.Next((int)(Main.worldSurface * 2.0 + Main.rockLayer) / 3, Main.maxTilesY - 300);
12039 if (remixWorldGen)
12040 {
12041 genRand.Next((int)Main.worldSurface, Main.maxTilesY - 400);
12042 }
12043 }
12044 while (!Main.tile[num563, num564].active())
12045 {
12046 num564++;
12047 if (num564 >= Main.maxTilesY)
12048 {
12049 break;
12050 }
12051 }
12052 if (num564 < Main.maxTilesY)
12053 {
12054 num564--;
12055 if (!Main.tile[num563, num564].shimmer())
12056 {
12057 PlaceTile(num563, num564, x12, mute: true, forced: true, -1, y10);
12058 }
12059 if (Main.tile[num563, num564].active() && Main.tile[num563, num564].type == x12)
12060 {
12061 flag32 = true;
12062 if (GenVars.StatuesWithTraps.Contains(num558))
12063 {
12064 PlaceStatueTrap(num563, num564);
12065 }
12066 num558++;
12067 }
12068 else
12069 {
12070 num562++;
12071 if (num562 >= 10000)
12072 {
12073 flag32 = true;
12074 }
12075 }
12076 }
12077 }
12078 }
12079 });
12080 AddGenerationPass("Buried Chests", delegate(GenerationProgress progress, GameConfiguration passConfig)
12081 {
12082 progress.Message = Lang.gen[30].Value;
12083 Main.tileSolid[226] = true;
12084 Main.tileSolid[162] = true;
12085 Main.tileSolid[225] = true;
12087 int random6 = passConfig.Get<WorldGenRange>("CaveHouseCount").GetRandom(genRand);
12088 int random7 = passConfig.Get<WorldGenRange>("UnderworldChestCount").GetRandom(genRand);
12089 int num546 = passConfig.Get<WorldGenRange>("CaveChestCount").GetRandom(genRand);
12090 int random8 = passConfig.Get<WorldGenRange>("AdditionalDesertHouseCount").GetRandom(genRand);
12091 if (Main.starGame)
12092 {
12093 num546 = (int)((double)num546 * Main.starGameMath(0.2));
12094 }
12095 int num547 = random6 + random7 + num546 + random8;
12096 int num548 = 10000;
12097 for (int num549 = 0; num549 < num546; num549++)
12098 {
12099 if (num548 <= 0)
12100 {
12101 break;
12102 }
12103 progress.Set((double)num549 / (double)num547);
12104 int num550 = genRand.Next(20, Main.maxTilesX - 20);
12105 int num551 = genRand.Next((int)((GenVars.worldSurfaceHigh + 20.0 + Main.rockLayer) / 2.0), Main.maxTilesY - 230);
12106 if (remixWorldGen)
12107 {
12108 num551 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 400);
12109 }
12110 ushort wall = Main.tile[num550, num551].wall;
12111 if (Main.wallDungeon[wall] || wall == 87 || oceanDepths(num550, num551) || !AddBuriedChest(num550, num551, 0, notNearOtherChests: false, -1, trySlope: false, 0))
12112 {
12113 num548--;
12114 num549--;
12115 }
12116 }
12117 num548 = 10000;
12118 for (int num552 = 0; num552 < random7; num552++)
12119 {
12120 if (num548 <= 0)
12121 {
12122 break;
12123 }
12124 progress.Set((double)(num552 + num546) / (double)num547);
12125 int num553 = genRand.Next(20, Main.maxTilesX - 20);
12126 int num554 = genRand.Next(Main.UnderworldLayer, Main.maxTilesY - 50);
12127 if (Main.wallDungeon[Main.tile[num553, num554].wall] || !AddBuriedChest(num553, num554, 0, notNearOtherChests: false, -1, trySlope: false, 0))
12128 {
12129 num548--;
12130 num552--;
12131 }
12132 }
12133 num548 = 10000;
12134 for (int num555 = 0; num555 < random6; num555++)
12135 {
12136 if (num548 <= 0)
12137 {
12138 break;
12139 }
12140 progress.Set((double)(num555 + num546 + random7) / (double)num547);
12141 int x11 = genRand.Next(80, Main.maxTilesX - 80);
12142 int y9 = genRand.Next((int)(GenVars.worldSurfaceHigh + 20.0), Main.maxTilesY - 230);
12143 if (remixWorldGen)
12144 {
12145 y9 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 400);
12146 }
12147 if (oceanDepths(x11, y9) || !caveHouseBiome.Place(new Point(x11, y9), GenVars.structures))
12148 {
12149 num548--;
12150 num555--;
12151 }
12152 }
12153 num548 = 10000;
12155 if ((double)undergroundDesertHiveLocation.Y < Main.worldSurface + 26.0)
12156 {
12158 undergroundDesertHiveLocation.Y += num556;
12159 undergroundDesertHiveLocation.Height -= num556;
12160 }
12161 for (int num557 = 0; num557 < random8; num557++)
12162 {
12163 if (num548 <= 0)
12164 {
12165 break;
12166 }
12167 progress.Set((double)(num557 + num546 + random7 + random6) / (double)num547);
12168 if (!caveHouseBiome.Place(RandomRectanglePoint(undergroundDesertHiveLocation), GenVars.structures))
12169 {
12170 num548--;
12171 num557--;
12172 }
12173 }
12174 Main.tileSolid[226] = false;
12175 Main.tileSolid[162] = false;
12176 Main.tileSolid[225] = false;
12177 });
12178 AddGenerationPass("Surface Chests", delegate(GenerationProgress progress, GameConfiguration passConfig)
12179 {
12180 progress.Message = Lang.gen[31].Value;
12181 for (int num536 = 0; num536 < (int)((double)Main.maxTilesX * 0.005); num536++)
12182 {
12183 double value8 = (double)num536 / ((double)Main.maxTilesX * 0.005);
12184 progress.Set(value8);
12185 bool flag30 = false;
12186 int num537 = 0;
12187 while (!flag30)
12188 {
12189 int num538 = genRand.Next(200, Main.maxTilesX - 200);
12190 int num539 = genRand.Next((int)GenVars.worldSurfaceLow, (int)Main.worldSurface);
12191 if (remixWorldGen)
12192 {
12193 num539 = genRand.Next(Main.maxTilesY - 400, Main.maxTilesY - 150);
12194 }
12195 else
12196 {
12197 while (oceanDepths(num538, num539))
12198 {
12199 num538 = genRand.Next(300, Main.maxTilesX - 300);
12200 num539 = genRand.Next((int)GenVars.worldSurfaceLow, (int)Main.worldSurface);
12201 }
12202 }
12203 bool flag31 = false;
12204 if (!Main.tile[num538, num539].active())
12205 {
12206 if (Main.tile[num538, num539].wall == 2 || Main.tile[num538, num539].wall == 59 || Main.tile[num538, num539].wall == 244 || remixWorldGen)
12207 {
12208 flag31 = true;
12209 }
12210 }
12211 else
12212 {
12213 int num540 = 50;
12214 int num541 = num538;
12215 int num542 = num539;
12216 int num543 = 1;
12217 for (int num544 = num541 - num540; num544 <= num541 + num540; num544 += 2)
12218 {
12219 for (int num545 = num542 - num540; num545 <= num542 + num540; num545 += 2)
12220 {
12221 if ((double)num545 < Main.worldSurface && !Main.tile[num544, num545].active() && Main.tile[num544, num545].wall == 244 && genRand.Next(num543) == 0)
12222 {
12223 num543++;
12224 flag31 = true;
12225 num538 = num544;
12226 num539 = num545;
12227 }
12228 }
12229 }
12230 }
12231 if (flag31 && AddBuriedChest(num538, num539, 0, notNearOtherChests: true, -1, trySlope: false, 0))
12232 {
12233 flag30 = true;
12234 }
12235 else
12236 {
12237 num537++;
12238 if (num537 >= 2000)
12239 {
12240 flag30 = true;
12241 }
12242 }
12243 }
12244 }
12245 });
12246 AddGenerationPass("Jungle Chests Placement", delegate(GenerationProgress progress, GameConfiguration passConfig)
12247 {
12248 progress.Message = Lang.gen[32].Value;
12249 for (int num531 = 0; num531 < GenVars.numJChests; num531++)
12250 {
12251 double value7 = (double)num531 / (double)GenVars.numJChests;
12252 progress.Set(value7);
12253 int nextJungleChestItem = GetNextJungleChestItem();
12254 if (!AddBuriedChest(GenVars.JChestX[num531] + genRand.Next(2), GenVars.JChestY[num531], nextJungleChestItem, notNearOtherChests: false, 10, trySlope: false, 0))
12255 {
12256 for (int num532 = GenVars.JChestX[num531] - 1; num532 <= GenVars.JChestX[num531] + 1; num532++)
12257 {
12258 for (int num533 = GenVars.JChestY[num531]; num533 <= GenVars.JChestY[num531] + 2; num533++)
12259 {
12260 KillTile(num532, num533);
12261 }
12262 }
12263 for (int num534 = GenVars.JChestX[num531] - 1; num534 <= GenVars.JChestX[num531] + 1; num534++)
12264 {
12265 for (int num535 = GenVars.JChestY[num531]; num535 <= GenVars.JChestY[num531] + 3; num535++)
12266 {
12267 if (num535 < Main.maxTilesY)
12268 {
12269 Main.tile[num534, num535].slope(0);
12270 Main.tile[num534, num535].halfBrick(halfBrick: false);
12271 }
12272 }
12273 }
12275 }
12276 }
12277 });
12278 AddGenerationPass("Water Chests", delegate(GenerationProgress progress, GameConfiguration passConfig)
12279 {
12280 progress.Message = Lang.gen[33].Value;
12281 for (int num518 = 0; num518 < GenVars.numOceanCaveTreasure; num518++)
12282 {
12283 int contain = genRand.NextFromList(new short[5] { 863, 186, 277, 187, 4404 });
12284 bool flag28 = false;
12285 double num519 = 2.0;
12286 while (!flag28 && num519 < 50.0)
12287 {
12288 num519 += 0.1;
12289 int num520 = genRand.Next(GenVars.oceanCaveTreasure[num518].X - (int)num519, GenVars.oceanCaveTreasure[num518].X + (int)num519 + 1);
12290 int num521 = genRand.Next(GenVars.oceanCaveTreasure[num518].Y - (int)num519 / 2, GenVars.oceanCaveTreasure[num518].Y + (int)num519 / 2 + 1);
12291 num520 = ((num520 >= Main.maxTilesX) ? ((int)((double)num520 + num519 / 2.0)) : ((int)((double)num520 - num519 / 2.0)));
12292 if (Main.tile[num520, num521].liquid > 250 && (Main.tile[num520, num521].liquidType() == 0 || notTheBees || remixWorldGen))
12293 {
12294 flag28 = AddBuriedChest(num520, num521, contain, notNearOtherChests: false, 17, trySlope: true, 0);
12295 }
12296 }
12297 }
12298 int num522 = 0;
12299 double num523 = (double)Main.maxTilesX / 4200.0;
12300 for (int num524 = 0; (double)num524 < 9.0 * num523; num524++)
12301 {
12302 double value6 = (double)num524 / (9.0 * num523);
12303 progress.Set(value6);
12304 int num525 = 0;
12305 num522++;
12306 int maxValue8 = 10;
12307 if (tenthAnniversaryWorldGen)
12308 {
12309 maxValue8 = 7;
12310 }
12311 if (genRand.Next(maxValue8) == 0)
12312 {
12313 num525 = 863;
12314 }
12315 else
12316 {
12317 switch (num522)
12318 {
12319 case 1:
12320 num525 = 186;
12321 break;
12322 case 2:
12323 num525 = 4404;
12324 break;
12325 case 3:
12326 num525 = 277;
12327 break;
12328 default:
12329 num525 = 187;
12330 num522 = 0;
12331 break;
12332 }
12333 }
12334 bool flag29 = false;
12335 int num526 = 0;
12336 while (!flag29)
12337 {
12338 int num527 = genRand.Next(50, Main.maxTilesX - 50);
12339 int num528 = genRand.Next(1, Main.UnderworldLayer);
12340 while (Main.tile[num527, num528].liquid < 250 || (Main.tile[num527, num528].liquidType() != 0 && !notTheBees && !remixWorldGen))
12341 {
12342 num527 = genRand.Next(50, Main.maxTilesX - 50);
12343 num528 = genRand.Next(50, Main.UnderworldLayer);
12344 }
12345 flag29 = AddBuriedChest(num527, num528, num525, notNearOtherChests: false, 17, num527 < beachDistance || num527 > Main.maxTilesX - beachDistance, 0);
12346 num526++;
12347 if (num526 > 10000)
12348 {
12349 break;
12350 }
12351 }
12352 flag29 = false;
12353 num526 = 0;
12354 while (!flag29)
12355 {
12356 int num529 = genRand.Next(50, Main.maxTilesX - 50);
12357 int num530 = genRand.Next((int)Main.worldSurface, Main.UnderworldLayer);
12358 while (Main.tile[num529, num530].liquid < 250 || (Main.tile[num529, num530].liquidType() != 0 && !notTheBees))
12359 {
12360 num529 = genRand.Next(50, Main.maxTilesX - 50);
12361 num530 = genRand.Next((int)Main.worldSurface, Main.UnderworldLayer);
12362 }
12363 flag29 = AddBuriedChest(num529, num530, num525, notNearOtherChests: false, 17, num529 < beachDistance || num529 > Main.maxTilesX - beachDistance, 0);
12364 num526++;
12365 if (num526 > 10000)
12366 {
12367 break;
12368 }
12369 }
12370 }
12371 });
12372 AddGenerationPass("Spider Caves", delegate(GenerationProgress progress, GameConfiguration passConfig)
12373 {
12374 progress.Message = Lang.gen[64].Value;
12375 maxTileCount = 3500;
12376 int num513 = Main.maxTilesX / 2;
12377 int num514 = (int)((double)Main.maxTilesX * 0.005);
12378 if (getGoodWorldGen)
12379 {
12380 num514 *= 3;
12381 }
12382 if (notTheBees)
12383 {
12384 Main.tileSolid[225] = true;
12385 }
12386 for (int num515 = 0; num515 < num514; num515++)
12387 {
12388 double value5 = (double)num515 / ((double)Main.maxTilesX * 0.005);
12389 progress.Set(value5);
12390 int num516 = 0;
12391 int x10 = genRand.Next(200, Main.maxTilesX - 200);
12392 int y8 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 230);
12393 if (remixWorldGen)
12394 {
12395 y8 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
12396 }
12397 int num517 = countTiles(x10, y8, jungle: false, lavaOk: true);
12398 while ((num517 >= 3500 || num517 < 500) && num516 < num513)
12399 {
12400 num516++;
12401 x10 = genRand.Next(200, Main.maxTilesX - 200);
12402 y8 = genRand.Next((int)Main.rockLayer + 30, Main.maxTilesY - 230);
12403 if (remixWorldGen)
12404 {
12405 y8 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
12406 }
12407 num517 = countTiles(x10, y8, jungle: false, lavaOk: true);
12408 if (shroomCount > 1)
12409 {
12410 num517 = 0;
12411 }
12412 }
12413 if (num516 < num513)
12414 {
12415 Spread.Spider(x10, y8);
12416 }
12417 }
12418 if (notTheBees)
12419 {
12420 Main.tileSolid[225] = false;
12421 }
12422 Main.tileSolid[162] = true;
12423 });
12424 AddGenerationPass("Gem Caves", delegate(GenerationProgress progress, GameConfiguration passConfig)
12425 {
12426 if (!notTheBees)
12427 {
12428 progress.Message = Lang.gen[64].Value;
12429 maxTileCount = 300;
12430 double num509 = (double)Main.maxTilesX * 0.003;
12431 if (tenthAnniversaryWorldGen)
12432 {
12433 num509 *= 1.5;
12434 }
12435 if (Main.starGame)
12436 {
12437 num509 *= Main.starGameMath(0.2);
12438 }
12439 for (int num510 = 0; (double)num510 < num509; num510++)
12440 {
12441 double value4 = (double)num510 / num509;
12442 progress.Set(value4);
12443 int num511 = 0;
12444 int x9 = genRand.Next(200, Main.maxTilesX - 200);
12445 int y7 = genRand.Next((int)Main.rockLayer + 30, Main.maxTilesY - 230);
12446 if (remixWorldGen)
12447 {
12448 y7 = genRand.Next((int)Main.worldSurface + 30, (int)Main.rockLayer - 30);
12449 }
12450 int num512 = countTiles(x9, y7);
12451 while ((num512 >= 300 || num512 < 50 || lavaCount > 0 || iceCount > 0 || rockCount == 0) && num511 < 1000)
12452 {
12453 num511++;
12454 x9 = genRand.Next(200, Main.maxTilesX - 200);
12455 y7 = genRand.Next((int)Main.rockLayer + 30, Main.maxTilesY - 230);
12456 if (remixWorldGen)
12457 {
12458 y7 = genRand.Next((int)Main.worldSurface + 30, (int)Main.rockLayer - 30);
12459 }
12460 num512 = countTiles(x9, y7);
12461 }
12462 if (num511 < 1000)
12463 {
12464 gemCave(x9, y7);
12465 }
12466 }
12467 }
12468 });
12470 {
12471 //IL_0393: Unknown result type (might be due to invalid IL or missing references)
12472 //IL_0398: Unknown result type (might be due to invalid IL or missing references)
12473 //IL_04e7: Unknown result type (might be due to invalid IL or missing references)
12474 //IL_04ec: Unknown result type (might be due to invalid IL or missing references)
12475 //IL_05be: Unknown result type (might be due to invalid IL or missing references)
12476 //IL_05c3: Unknown result type (might be due to invalid IL or missing references)
12477 if (!notTheBees || remixWorldGen)
12478 {
12479 progress.Message = Lang.gen[61].Value;
12480 randMoss();
12481 int num479 = Main.maxTilesX / 2100;
12482 if (remixWorldGen)
12483 {
12484 num479 = (int)((double)num479 * 1.5);
12485 }
12486 else if (tenthAnniversaryWorldGen)
12487 {
12488 num479 *= 2;
12489 }
12490 int num480 = 0;
12491 int num481 = 0;
12492 while (num481 < num479)
12493 {
12494 int num482 = genRand.Next(100, Main.maxTilesX - 100);
12495 if (remixWorldGen)
12496 {
12497 num482 = genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
12498 }
12499 else if (tenthAnniversaryWorldGen)
12500 {
12501 if (genRand.Next(2) == 0)
12502 {
12503 randMoss(justNeon: true);
12504 }
12505 }
12506 else if (getGoodWorldGen)
12507 {
12508 while ((double)num482 > (double)Main.maxTilesX * 0.42 && (double)num482 < (double)Main.maxTilesX * 0.48)
12509 {
12510 num482 = genRand.Next(100, Main.maxTilesX - 100);
12511 }
12512 }
12513 else if (!drunkWorldGen)
12514 {
12515 while ((double)num482 > (double)Main.maxTilesX * 0.38 && (double)num482 < (double)Main.maxTilesX * 0.62)
12516 {
12517 num482 = genRand.Next(100, Main.maxTilesX - 100);
12518 }
12519 }
12520 int num483 = ((!remixWorldGen) ? genRand.Next((int)Main.rockLayer + 40, GenVars.lavaLine - 40) : genRand.Next((int)Main.worldSurface + 50, (int)Main.rockLayer - 50));
12521 bool flag27 = false;
12522 int num484 = 50;
12523 for (int num485 = num482 - num484; num485 <= num482 + num484; num485++)
12524 {
12525 for (int num486 = num483 - num484; num486 <= num483 + num484; num486++)
12526 {
12527 if (Main.tile[num485, num486].active())
12528 {
12529 int type6 = Main.tile[num485, num486].type;
12530 if (remixWorldGen)
12531 {
12532 if (type6 == 60 || type6 == 161 || type6 == 147 || Main.tileDungeon[type6] || type6 == 25 || type6 == 203)
12533 {
12534 flag27 = true;
12535 num485 = num482 + num484 + 1;
12536 break;
12537 }
12538 }
12539 else if (type6 == 70 || type6 == 60 || type6 == 367 || type6 == 368 || type6 == 161 || type6 == 147 || type6 == 396 || type6 == 397 || Main.tileDungeon[type6])
12540 {
12541 flag27 = true;
12542 num485 = num482 + num484 + 1;
12543 break;
12544 }
12545 }
12546 }
12547 }
12548 if (flag27)
12549 {
12550 num480++;
12551 if (num480 > Main.maxTilesX)
12552 {
12553 num481++;
12554 }
12555 }
12556 else
12557 {
12558 num480 = 0;
12559 num481++;
12560 int maxY = GenVars.lavaLine;
12561 if (remixWorldGen)
12562 {
12563 maxY = (int)Main.rockLayer + 50;
12564 }
12565 neonMossBiome(num482, num483, maxY);
12566 }
12567 }
12568 maxTileCount = 2500;
12569 for (int num487 = 0; num487 < (int)((double)Main.maxTilesX * 0.01); num487++)
12570 {
12571 double value3 = (double)num487 / ((double)Main.maxTilesX * 0.01);
12572 progress.Set(value3);
12573 int num488 = 0;
12574 int num489 = genRand.Next(200, Main.maxTilesX - 200);
12575 int num490 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, GenVars.waterLine);
12576 if (remixWorldGen)
12577 {
12578 num490 = genRand.Next((int)Main.worldSurface, (int)Main.rockLayer);
12579 }
12580 if (!(Vector2D.Distance(new Vector2D((double)num489, (double)num490), GenVars.shimmerPosition) < (double)shimmerSafetyDistance))
12581 {
12582 int num491 = countTiles(num489, num490);
12583 while ((num491 >= 2500 || num491 < 10 || lavaCount > 0 || iceCount > 0 || rockCount == 0 || shroomCount > 0) && num488 < 1000)
12584 {
12585 num488++;
12586 num489 = genRand.Next(200, Main.maxTilesX - 200);
12587 num490 = genRand.Next((int)Main.rockLayer + 30, Main.maxTilesY - 230);
12588 num491 = countTiles(num489, num490);
12589 }
12590 if (num488 < 1000)
12591 {
12592 setMoss(num489, num490);
12593 Spread.Moss(num489, num490);
12594 }
12595 }
12596 }
12597 for (int num492 = 0; num492 < Main.maxTilesX; num492++)
12598 {
12599 int num493 = genRand.Next(50, Main.maxTilesX - 50);
12600 int num494 = ((!remixWorldGen) ? genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, GenVars.lavaLine) : genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300));
12601 if (!(Vector2D.Distance(new Vector2D((double)num493, (double)num494), GenVars.shimmerPosition) < (double)shimmerSafetyDistance) && Main.tile[num493, num494].type == 1)
12602 {
12603 setMoss(num493, num494);
12605 }
12606 }
12607 double num495 = (double)Main.maxTilesX * 0.05;
12608 while (num495 > 0.0)
12609 {
12610 int num496 = genRand.Next(50, Main.maxTilesX - 50);
12611 int num497 = ((!remixWorldGen) ? genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, GenVars.lavaLine) : genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300));
12612 if (!(Vector2D.Distance(new Vector2D((double)num496, (double)num497), GenVars.shimmerPosition) < (double)shimmerSafetyDistance) && Main.tile[num496, num497].type == 1 && (!Main.tile[num496 - 1, num497].active() || !Main.tile[num496 + 1, num497].active() || !Main.tile[num496, num497 - 1].active() || !Main.tile[num496, num497 + 1].active()))
12613 {
12614 setMoss(num496, num497);
12616 num495 -= 1.0;
12617 }
12618 }
12619 num495 = (double)Main.maxTilesX * 0.065;
12620 if (remixWorldGen)
12621 {
12622 num495 *= 2.0;
12623 }
12624 while (num495 > 0.0)
12625 {
12626 int num498 = genRand.Next(50, Main.maxTilesX - 50);
12627 int num499 = ((!remixWorldGen) ? genRand.Next(GenVars.waterLine, Main.UnderworldLayer) : genRand.Next(GenVars.lavaLine, (int)Main.rockLayer + 50));
12628 if (Main.tile[num498, num499].type == 1 && (!Main.tile[num498 - 1, num499].active() || !Main.tile[num498 + 1, num499].active() || !Main.tile[num498, num499 - 1].active() || !Main.tile[num498, num499 + 1].active()))
12629 {
12630 int num500 = 25;
12631 int num501 = 0;
12632 for (int num502 = num498 - num500; num502 < num498 + num500; num502++)
12633 {
12634 for (int num503 = num499 - num500; num503 < num499 + num500; num503++)
12635 {
12636 if (Main.tile[num502, num503].liquid > 0 && Main.tile[num502, num503].lava())
12637 {
12638 num501++;
12639 }
12640 }
12641 }
12642 if (num501 > 20)
12643 {
12644 Main.tile[num498, num499].type = 381;
12645 num495 -= 1.0;
12646 }
12647 else
12648 {
12649 num495 -= 0.002;
12650 }
12651 }
12652 num495 -= 0.001;
12653 }
12654 for (int num504 = 0; num504 < Main.maxTilesX; num504++)
12655 {
12656 for (int num505 = 0; num505 < Main.maxTilesY; num505++)
12657 {
12658 if (Main.tile[num504, num505].active() && Main.tileMoss[Main.tile[num504, num505].type])
12659 {
12660 for (int num506 = 0; num506 < 4; num506++)
12661 {
12662 int num507 = num504;
12663 int num508 = num505;
12664 if (num506 == 0)
12665 {
12666 num507--;
12667 }
12668 if (num506 == 1)
12669 {
12670 num507++;
12671 }
12672 if (num506 == 2)
12673 {
12674 num508--;
12675 }
12676 if (num506 == 3)
12677 {
12678 num508++;
12679 }
12680 try
12681 {
12682 grassSpread = 0;
12683 SpreadGrass(num507, num508, 1, Main.tile[num504, num505].type);
12684 }
12685 catch
12686 {
12687 grassSpread = 0;
12688 SpreadGrass(num507, num508, 1, Main.tile[num504, num505].type, repeat: false);
12689 }
12690 }
12691 }
12692 }
12693 }
12694 }
12695 });
12696 AddGenerationPass("Temple", delegate
12697 {
12698 Main.tileSolid[162] = false;
12699 Main.tileSolid[226] = true;
12700 templePart2();
12701 Main.tileSolid[232] = false;
12702 });
12703 AddGenerationPass("Cave Walls", delegate(GenerationProgress progress, GameConfiguration passConfig)
12704 {
12705 progress.Message = Lang.gen[63].Value;
12706 maxTileCount = 1500;
12707 for (int num463 = 0; num463 < (int)((double)Main.maxTilesX * 0.04); num463++)
12708 {
12709 double num464 = (double)num463 / ((double)Main.maxTilesX * 0.04);
12710 progress.Set(num464 * 0.66);
12711 int num465 = 0;
12712 int x7 = genRand.Next(200, Main.maxTilesX - 200);
12713 int y5 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 220);
12714 if (remixWorldGen)
12715 {
12716 y5 = genRand.Next((int)Main.worldSurface + 25, (int)Main.rockLayer);
12717 }
12718 int num466 = countTiles(x7, y5, jungle: false, lavaOk: true);
12719 while ((num466 >= maxTileCount || num466 < 10) && num465 < 500)
12720 {
12721 num465++;
12722 x7 = genRand.Next(200, Main.maxTilesX - 200);
12723 y5 = genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 220);
12724 if (remixWorldGen)
12725 {
12726 y5 = genRand.Next((int)Main.worldSurface + 25, (int)Main.rockLayer);
12727 }
12728 num466 = countTiles(x7, y5, jungle: false, lavaOk: true);
12729 }
12730 if (num465 < 500)
12731 {
12732 int num467 = genRand.Next(2);
12733 if ((double)shroomCount > (double)rockCount * 0.75)
12734 {
12735 num467 = 80;
12736 }
12737 else if (iceCount > 0)
12738 {
12739 switch (num467)
12740 {
12741 case 0:
12742 num467 = 40;
12743 break;
12744 case 1:
12745 num467 = 71;
12746 break;
12747 }
12748 }
12749 else if (lavaCount > 0)
12750 {
12751 num467 = 79;
12752 }
12753 else
12754 {
12755 num467 = genRand.Next(4);
12756 switch (num467)
12757 {
12758 case 0:
12759 num467 = 59;
12760 break;
12761 case 1:
12762 num467 = 61;
12763 break;
12764 case 2:
12765 num467 = 170;
12766 break;
12767 case 3:
12768 num467 = 171;
12769 break;
12770 }
12771 }
12772 Spread.Wall(x7, y5, num467);
12773 }
12774 }
12775 if (remixWorldGen)
12776 {
12777 maxTileCount = 1500;
12778 for (int num468 = 0; num468 < (int)((double)Main.maxTilesX * 0.04); num468++)
12779 {
12780 double num469 = (double)num468 / ((double)Main.maxTilesX * 0.04);
12781 progress.Set(num469 * 0.66);
12782 int num470 = 0;
12783 int x8 = genRand.Next(200, Main.maxTilesX - 200);
12784 int y6 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 350);
12785 int num471 = countTiles(x8, y6, jungle: false, lavaOk: true);
12786 while ((num471 >= maxTileCount || num471 < 10) && num470 < 500)
12787 {
12788 num470++;
12789 x8 = genRand.Next(200, Main.maxTilesX - 200);
12790 y6 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 350);
12791 num471 = countTiles(x8, y6, jungle: false, lavaOk: true);
12792 }
12793 if (num470 < 500 && iceCount == 0 && lavaCount == 0 && sandCount == 0)
12794 {
12795 int wallType2 = ((genRand.Next(2) != 0) ? 63 : 2);
12796 Spread.Wall(x8, y6, wallType2);
12797 }
12798 }
12799 }
12800 maxTileCount = 1500;
12801 double num472 = (double)Main.maxTilesX * 0.02;
12802 for (int num473 = 0; (double)num473 < num472; num473++)
12803 {
12804 double num474 = (double)num473 / ((double)Main.maxTilesX * 0.02);
12805 progress.Set(num474 * 0.33 + 0.66);
12806 int num475 = 0;
12807 int num476 = genRand.Next(200, Main.maxTilesX - 200);
12808 int num477 = genRand.Next((int)Main.worldSurface, GenVars.lavaLine);
12809 int num478 = 0;
12810 if (Main.tile[num476, num477].wall == 64)
12811 {
12812 num478 = countTiles(num476, num477, jungle: true);
12813 }
12814 while ((num478 >= maxTileCount || num478 < 10) && num475 < 1000)
12815 {
12816 num475++;
12817 num476 = genRand.Next(200, Main.maxTilesX - 200);
12818 num477 = genRand.Next((int)Main.worldSurface, GenVars.lavaLine);
12819 if (!Main.wallHouse[Main.tile[num476, num477].wall] && Main.tile[num476, num477].wall != 244)
12820 {
12821 num478 = ((Main.tile[num476, num477].wall == 64) ? countTiles(num476, num477, jungle: true) : 0);
12822 }
12823 }
12824 if (num475 < 1000)
12825 {
12826 Spread.Wall2(num476, num477, 15);
12827 }
12828 }
12829 });
12830 AddGenerationPass("Jungle Trees", delegate(GenerationProgress progress, GameConfiguration passConfig)
12831 {
12832 progress.Message = Lang.gen[83].Value;
12833 for (int num461 = 0; num461 < Main.maxTilesX; num461++)
12834 {
12835 progress.Set((double)num461 / (double)Main.maxTilesX);
12836 for (int num462 = (int)Main.worldSurface - 1; num462 < Main.maxTilesY - 350; num462++)
12837 {
12838 if (genRand.Next(10) == 0 || drunkWorldGen)
12839 {
12840 GrowUndergroundTree(num461, num462);
12841 }
12842 }
12843 }
12844 });
12845 AddGenerationPass("Floating Island Houses", delegate(GenerationProgress progress, GameConfiguration passConfig)
12846 {
12847 progress.Set(1.0);
12848 for (int num460 = 0; num460 < GenVars.numIslandHouses; num460++)
12849 {
12850 if (!GenVars.skyLake[num460])
12851 {
12852 IslandHouse(GenVars.floatingIslandHouseX[num460], GenVars.floatingIslandHouseY[num460], GenVars.floatingIslandStyle[num460]);
12853 }
12854 }
12855 });
12856 AddGenerationPass("Quick Cleanup", delegate(GenerationProgress progress, GameConfiguration passConfig)
12857 {
12858 progress.Set(1.0);
12859 if (notTheBees)
12860 {
12861 NotTheBees();
12862 }
12863 Main.tileSolid[137] = false;
12864 Main.tileSolid[130] = false;
12865 for (int num453 = 20; num453 < Main.maxTilesX - 20; num453++)
12866 {
12867 for (int num454 = 20; num454 < Main.maxTilesY - 20; num454++)
12868 {
12869 if ((double)num454 < Main.worldSurface && oceanDepths(num453, num454) && Main.tile[num453, num454].type == 53 && Main.tile[num453, num454].active())
12870 {
12871 if (Main.tile[num453, num454].bottomSlope())
12872 {
12873 Main.tile[num453, num454].slope(0);
12874 }
12875 for (int num455 = num454 + 1; num455 < num454 + genRand.Next(4, 7) && (!Main.tile[num453, num455].active() || (Main.tile[num453, num455].type != 397 && Main.tile[num453, num455].type != 53)) && (!Main.tile[num453, num455 + 1].active() || (Main.tile[num453, num455 + 1].type != 397 && Main.tile[num453, num455 + 1].type != 53 && Main.tile[num453, num455 + 1].type != 495)) && (!Main.tile[num453, num455 + 2].active() || (Main.tile[num453, num455 + 2].type != 397 && Main.tile[num453, num455 + 2].type != 53 && Main.tile[num453, num455 + 2].type != 495)); num455++)
12876 {
12877 Main.tile[num453, num455].type = 0;
12878 Main.tile[num453, num455].active(active: true);
12879 Main.tile[num453, num455].halfBrick(halfBrick: false);
12880 Main.tile[num453, num455].slope(0);
12881 }
12882 }
12883 if (Main.tile[num453, num454].wall == 187 || Main.tile[num453, num454].wall == 216)
12884 {
12885 if (Main.tile[num453, num454].type == 59 || Main.tile[num453, num454].type == 123 || Main.tile[num453, num454].type == 224)
12886 {
12887 Main.tile[num453, num454].type = 397;
12888 }
12889 if (Main.tile[num453, num454].type == 368 || Main.tile[num453, num454].type == 367)
12890 {
12891 Main.tile[num453, num454].type = 397;
12892 }
12893 if ((double)num454 <= Main.rockLayer)
12894 {
12895 Main.tile[num453, num454].liquid = 0;
12896 }
12897 else if (Main.tile[num453, num454].liquid > 0)
12898 {
12899 Main.tile[num453, num454].liquid = byte.MaxValue;
12900 Main.tile[num453, num454].lava(lava: true);
12901 }
12902 }
12903 if ((double)num454 < Main.worldSurface && Main.tile[num453, num454].active() && Main.tile[num453, num454].type == 53 && Main.tile[num453, num454 + 1].wall == 0 && !SolidTile(num453, num454 + 1))
12904 {
12905 ushort num456 = 0;
12906 int num457 = 3;
12907 for (int num458 = num453 - num457; num458 <= num453 + num457; num458++)
12908 {
12909 for (int num459 = num454 - num457; num459 <= num454 + num457; num459++)
12910 {
12911 if (Main.tile[num458, num459].wall > 0)
12912 {
12913 num456 = Main.tile[num458, num459].wall;
12914 break;
12915 }
12916 }
12917 }
12918 if (num456 > 0)
12919 {
12920 Main.tile[num453, num454 + 1].wall = num456;
12921 if (Main.tile[num453, num454].wall == 0)
12922 {
12923 Main.tile[num453, num454].wall = num456;
12924 }
12925 }
12926 }
12928 {
12929 if (Main.tile[num453, num454].topSlope() || Main.tile[num453, num454].halfBrick())
12930 {
12931 if (Main.tile[num453, num454].type != 225 || !Main.tile[num453, num454].halfBrick())
12932 {
12933 if (!SolidTile(num453, num454 + 1))
12934 {
12935 Main.tile[num453, num454].active(active: false);
12936 }
12937 if (Main.tile[num453 + 1, num454].type == 137 || Main.tile[num453 - 1, num454].type == 137)
12938 {
12939 Main.tile[num453, num454].active(active: false);
12940 }
12941 }
12942 }
12943 else if (Main.tile[num453, num454].bottomSlope())
12944 {
12945 if (!SolidTile(num453, num454 - 1))
12946 {
12947 Main.tile[num453, num454].active(active: false);
12948 }
12949 if (Main.tile[num453 + 1, num454].type == 137 || Main.tile[num453 - 1, num454].type == 137)
12950 {
12951 Main.tile[num453, num454].active(active: false);
12952 }
12953 }
12954 }
12955 }
12956 }
12957 });
12959 {
12960 Main.tileSolid[137] = true;
12961 Main.tileSolid[130] = true;
12962 progress.Message = Lang.gen[35].Value;
12963 if (noTrapsWorldGen)
12964 {
12965 Main.tileSolid[138] = true;
12966 int num440 = (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0004);
12967 if (remixWorldGen)
12968 {
12969 num440 /= 2;
12970 }
12971 for (int num441 = 0; num441 < num440; num441++)
12972 {
12973 int num442 = genRand.Next(50, Main.maxTilesX - 50);
12974 int num443;
12975 for (num443 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 250); !Main.tile[num442, num443].active() && num443 < Main.maxTilesY - 250; num443++)
12976 {
12977 }
12978 num443--;
12979 if (!Main.tile[num442, num443].shimmer())
12980 {
12981 PlaceTile(num442, num443, 138, mute: true);
12982 PlaceTile(num442 + 2, num443, 138, mute: true);
12983 PlaceTile(num442 + 1, num443 - 2, 138, mute: true);
12984 }
12985 }
12986 Main.tileSolid[138] = false;
12987 }
12988 double num444 = (double)(Main.maxTilesX * Main.maxTilesY) * 0.0008;
12989 if (Main.starGame)
12990 {
12991 num444 *= Main.starGameMath(0.2);
12992 }
12993 for (int num445 = 0; (double)num445 < num444; num445++)
12994 {
12995 double num446 = (double)num445 / num444;
12996 progress.Set(num446);
12997 bool flag25 = false;
12998 int num447 = 0;
12999 while (!flag25)
13000 {
13001 int num448 = genRand.Next((int)GenVars.worldSurfaceHigh, Main.maxTilesY - 10);
13002 if (num446 > 0.93)
13003 {
13004 num448 = Main.maxTilesY - 150;
13005 }
13006 else if (num446 > 0.75)
13007 {
13009 }
13010 int num449 = genRand.Next(20, Main.maxTilesX - 20);
13011 bool flag26 = false;
13012 for (int num450 = num448; num450 < Main.maxTilesY - 20; num450++)
13013 {
13014 if (!flag26)
13015 {
13016 if (Main.tile[num449, num450].active() && Main.tileSolid[Main.tile[num449, num450].type] && !Main.tile[num449, num450 - 1].lava() && !Main.tile[num449, num450 - 1].shimmer())
13017 {
13018 flag26 = true;
13019 }
13020 }
13021 else if (!((double)num450 < Main.worldSurface) || Main.tile[num449, num450].wall != 0)
13022 {
13023 int style = genRand.Next(0, 4);
13024 int num451 = 0;
13025 int num452 = 0;
13026 if (num450 < Main.maxTilesY - 5)
13027 {
13028 num451 = Main.tile[num449, num450 + 1].type;
13029 num452 = Main.tile[num449, num450].wall;
13030 }
13031 if (num451 == 147 || num451 == 161 || num451 == 162)
13032 {
13033 style = genRand.Next(4, 7);
13034 }
13035 if (num451 == 60)
13036 {
13037 style = genRand.Next(7, 10);
13038 }
13039 if (Main.wallDungeon[Main.tile[num449, num450].wall])
13040 {
13041 style = genRand.Next(10, 13);
13042 }
13043 if (num451 == 41 || num451 == 43 || num451 == 44 || num451 == 481 || num451 == 482 || num451 == 483)
13044 {
13045 style = genRand.Next(10, 13);
13046 }
13047 if (num451 == 22 || num451 == 23 || num451 == 25)
13048 {
13049 style = genRand.Next(16, 19);
13050 }
13051 if (num451 == 199 || num451 == 203 || num451 == 204 || num451 == 200)
13052 {
13053 style = genRand.Next(22, 25);
13054 }
13055 if (num451 == 367)
13056 {
13057 style = genRand.Next(31, 34);
13058 }
13059 if (num451 == 226)
13060 {
13061 style = genRand.Next(28, 31);
13062 }
13063 if (num452 == 187 || num452 == 216)
13064 {
13065 style = genRand.Next(34, 37);
13066 }
13068 {
13069 style = genRand.Next(13, 16);
13070 }
13071 if (!oceanDepths(num449, num450) && !Main.tile[num449, num450].shimmer() && PlacePot(num449, num450, 28, style))
13072 {
13073 flag25 = true;
13074 break;
13075 }
13076 num447++;
13077 if (num447 >= 10000)
13078 {
13079 flag25 = true;
13080 break;
13081 }
13082 }
13083 }
13084 }
13085 }
13086 });
13087 AddGenerationPass("Hellforge", delegate(GenerationProgress progress, GameConfiguration passConfig)
13088 {
13089 progress.Message = Lang.gen[36].Value;
13090 for (int num436 = 0; num436 < Main.maxTilesX / 200; num436++)
13091 {
13092 double value2 = (double)num436 / (double)(Main.maxTilesX / 200);
13093 progress.Set(value2);
13094 bool flag24 = false;
13095 int num437 = 0;
13096 while (!flag24)
13097 {
13098 int num438 = genRand.Next(1, Main.maxTilesX);
13099 int num439 = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 30);
13100 try
13101 {
13102 if (Main.tile[num438, num439].wall == 13 || Main.tile[num438, num439].wall == 14)
13103 {
13104 for (; !Main.tile[num438, num439].active() && num439 < Main.maxTilesY - 20; num439++)
13105 {
13106 }
13107 num439--;
13108 PlaceTile(num438, num439, 77);
13109 if (Main.tile[num438, num439].type == 77)
13110 {
13111 flag24 = true;
13112 }
13113 else
13114 {
13115 num437++;
13116 if (num437 >= 10000)
13117 {
13118 flag24 = true;
13119 }
13120 }
13121 }
13122 }
13123 catch
13124 {
13125 num437++;
13126 if (num437 >= 10000)
13127 {
13128 flag24 = true;
13129 }
13130 }
13131 }
13132 }
13133 });
13134 AddGenerationPass("Spreading Grass", delegate(GenerationProgress progress, GameConfiguration passConfig)
13135 {
13136 if (!notTheBees || remixWorldGen)
13137 {
13138 progress.Message = Lang.gen[37].Value;
13139 for (int num414 = 50; num414 < Main.maxTilesX - 50; num414++)
13140 {
13141 for (int num415 = 50; (double)num415 <= Main.worldSurface; num415++)
13142 {
13143 if (Main.tile[num414, num415].active())
13144 {
13145 int type5 = Main.tile[num414, num415].type;
13146 if (Main.tile[num414, num415].active() && type5 == 60)
13147 {
13148 for (int num416 = num414 - 1; num416 <= num414 + 1; num416++)
13149 {
13150 for (int num417 = num415 - 1; num417 <= num415 + 1; num417++)
13151 {
13152 if (Main.tile[num416, num417].active() && Main.tile[num416, num417].type == 0)
13153 {
13154 if (!Main.tile[num416, num417 - 1].active())
13155 {
13156 Main.tile[num416, num417].type = 60;
13157 }
13158 else
13159 {
13160 Main.tile[num416, num417].type = 59;
13161 }
13162 }
13163 }
13164 }
13165 }
13166 else if (type5 == 1 || type5 == 40 || TileID.Sets.Ore[type5])
13167 {
13168 int num418 = 3;
13169 bool flag22 = false;
13170 ushort num419 = 0;
13171 for (int num420 = num414 - num418; num420 <= num414 + num418; num420++)
13172 {
13173 for (int num421 = num415 - num418; num421 <= num415 + num418; num421++)
13174 {
13175 if (Main.tile[num420, num421].active())
13176 {
13177 if (Main.tile[num420, num421].type == 53 || num419 == 53)
13178 {
13179 num419 = 53;
13180 }
13181 else if (Main.tile[num420, num421].type == 59 || Main.tile[num420, num421].type == 60 || Main.tile[num420, num421].type == 147 || Main.tile[num420, num421].type == 161 || Main.tile[num420, num421].type == 199 || Main.tile[num420, num421].type == 23)
13182 {
13183 num419 = Main.tile[num420, num421].type;
13184 }
13185 }
13186 else if (num421 < num415 && Main.tile[num420, num421].wall == 0)
13187 {
13188 flag22 = true;
13189 }
13190 }
13191 }
13192 if (flag22)
13193 {
13194 switch (num419)
13195 {
13196 case 23:
13197 case 199:
13198 if (Main.tile[num414, num415 - 1].active())
13199 {
13200 num419 = 0;
13201 }
13202 break;
13203 case 59:
13204 case 60:
13206 {
13207 num419 = (ushort)(Main.tile[num414, num415 - 1].active() ? 59 : 60);
13208 }
13209 break;
13210 }
13211 Main.tile[num414, num415].type = num419;
13212 }
13213 }
13214 }
13215 }
13216 }
13217 for (int num422 = 10; num422 < Main.maxTilesX - 10; num422++)
13218 {
13219 bool flag23 = true;
13220 for (int num423 = 0; (double)num423 < Main.worldSurface - 1.0; num423++)
13221 {
13222 if (Main.tile[num422, num423].active())
13223 {
13224 if (flag23 && Main.tile[num422, num423].type == 0)
13225 {
13226 try
13227 {
13228 grassSpread = 0;
13229 SpreadGrass(num422, num423);
13230 }
13231 catch
13232 {
13233 grassSpread = 0;
13234 SpreadGrass(num422, num423, 0, 2, repeat: false);
13235 }
13236 }
13237 if ((double)num423 > GenVars.worldSurfaceHigh)
13238 {
13239 break;
13240 }
13241 flag23 = false;
13242 }
13243 else if (Main.tile[num422, num423].wall == 0)
13244 {
13245 flag23 = true;
13246 }
13247 }
13248 }
13249 if (remixWorldGen)
13250 {
13251 for (int num424 = 5; num424 < Main.maxTilesX - 5; num424++)
13252 {
13253 for (int num425 = (int)GenVars.rockLayerLow + genRand.Next(-1, 2); num425 < Main.maxTilesY - 200; num425++)
13254 {
13255 if (Main.tile[num424, num425].type == 0 && Main.tile[num424, num425].active() && (!Main.tile[num424 - 1, num425 - 1].active() || !Main.tile[num424, num425 - 1].active() || !Main.tile[num424 + 1, num425 - 1].active() || !Main.tile[num424 - 1, num425].active() || !Main.tile[num424 + 1, num425].active() || !Main.tile[num424 - 1, num425 + 1].active() || !Main.tile[num424, num425 + 1].active() || !Main.tile[num424 + 1, num425 + 1].active()))
13256 {
13257 Main.tile[num424, num425].type = 2;
13258 }
13259 }
13260 }
13261 for (int num426 = 5; num426 < Main.maxTilesX - 5; num426++)
13262 {
13263 for (int num427 = (int)GenVars.rockLayerLow + genRand.Next(-1, 2); num427 < Main.maxTilesY - 200; num427++)
13264 {
13265 if (Main.tile[num426, num427].type == 2 && !Main.tile[num426, num427 - 1].active() && genRand.Next(20) == 0)
13266 {
13267 PlaceTile(num426, num427 - 1, 27, mute: true);
13268 }
13269 }
13270 }
13271 int conversionType = 1;
13272 if (crimson)
13273 {
13274 conversionType = 4;
13275 }
13276 int num428 = Main.maxTilesX / 7;
13277 for (int num429 = 10; num429 < Main.maxTilesX - 10; num429++)
13278 {
13279 for (int num430 = 10; num430 < Main.maxTilesY - 10; num430++)
13280 {
13281 if ((double)num430 < Main.worldSurface + (double)genRand.Next(3) || num429 < num428 + genRand.Next(3) || num429 >= Main.maxTilesX - num428 - genRand.Next(3))
13282 {
13283 if (drunkWorldGen)
13284 {
13285 if (GenVars.crimsonLeft)
13286 {
13287 if (num429 < Main.maxTilesX / 2 + genRand.Next(-2, 3))
13288 {
13289 Convert(num429, num430, 4, 1);
13290 }
13291 else
13292 {
13293 Convert(num429, num430, 1, 1);
13294 }
13295 }
13296 else if (num429 < Main.maxTilesX / 2 + genRand.Next(-2, 3))
13297 {
13298 Convert(num429, num430, 1, 1);
13299 }
13300 else
13301 {
13302 Convert(num429, num430, 4, 1);
13303 }
13304 }
13305 else
13306 {
13308 }
13309 Main.tile[num429, num430].color(0);
13310 Main.tile[num429, num430].wallColor(0);
13311 }
13312 }
13313 }
13314 if (remixWorldGen)
13315 {
13316 Main.tileSolid[225] = true;
13317 int num431 = (int)((double)Main.maxTilesX * 0.31);
13318 int num432 = (int)((double)Main.maxTilesX * 0.69);
13319 _ = Main.maxTilesY;
13320 int num433 = Main.maxTilesY - 135;
13321 _ = Main.maxTilesY;
13322 Liquid.QuickWater(-2);
13323 for (int num434 = num431; num434 < num432 + 15; num434++)
13324 {
13325 for (int num435 = Main.maxTilesY - 200; num435 < num433; num435++)
13326 {
13327 Main.tile[num434, num435].liquid = 0;
13328 }
13329 }
13330 Main.tileSolid[225] = false;
13331 Main.tileSolid[484] = false;
13332 }
13333 }
13334 }
13335 });
13336 AddGenerationPass("Surface Ore and Stone", delegate(GenerationProgress progress, GameConfiguration passConfig)
13337 {
13338 progress.Set(1.0);
13339 int num405 = genRand.Next(Main.maxTilesX * 5 / 4200, Main.maxTilesX * 10 / 4200);
13340 for (int num406 = 0; num406 < num405; num406++)
13341 {
13342 int num407 = Main.maxTilesX / 420;
13343 while (num407 > 0)
13344 {
13345 num407--;
13346 int num408 = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
13347 while ((double)num408 >= (double)Main.maxTilesX * 0.48 && (double)num408 <= (double)Main.maxTilesX * 0.52)
13348 {
13349 num408 = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
13350 }
13351 int y3 = genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.worldSurface);
13352 bool flag20 = false;
13353 for (int num409 = 0; num409 < GenVars.numOrePatch; num409++)
13354 {
13355 if (Math.Abs(num408 - GenVars.orePatchX[num409]) < 200)
13356 {
13357 flag20 = true;
13358 }
13359 }
13360 if (!flag20 && OrePatch(num408, y3))
13361 {
13363 {
13366 }
13367 break;
13368 }
13369 }
13370 }
13371 num405 = genRand.Next(1, Main.maxTilesX * 7 / 4200);
13372 for (int num410 = 0; num410 < num405; num410++)
13373 {
13374 int num411 = Main.maxTilesX / 420;
13375 while (num411 > 0)
13376 {
13377 num411--;
13378 int num412 = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
13379 while ((double)num412 >= (double)Main.maxTilesX * 0.47 && (double)num412 <= (double)Main.maxTilesX * 0.53)
13380 {
13381 num412 = genRand.Next(beachDistance, Main.maxTilesX - beachDistance);
13382 }
13383 int y4 = genRand.Next((int)GenVars.worldSurfaceLow, (int)GenVars.worldSurface);
13384 bool flag21 = false;
13385 for (int num413 = 0; num413 < GenVars.numOrePatch; num413++)
13386 {
13387 if (Math.Abs(num412 - GenVars.orePatchX[num413]) < 100)
13388 {
13389 flag21 = true;
13390 }
13391 }
13392 if (!flag21 && StonePatch(num412, y4))
13393 {
13394 break;
13395 }
13396 }
13397 }
13398 });
13399 AddGenerationPass("Place Fallen Log", delegate(GenerationProgress progress, GameConfiguration passConfig)
13400 {
13401 progress.Message = Lang.gen[85].Value;
13402 int num391 = Main.maxTilesX / 2100;
13403 num391 = ((!remixWorldGen) ? (num391 + genRand.Next(-1, 2)) : (num391 + genRand.Next(0, 2)));
13404 for (int num392 = 0; num392 < num391; num392++)
13405 {
13406 progress.Set((double)num392 / (double)num391);
13407 int num393 = beachDistance + 20;
13408 int num394 = 50000;
13409 int num395 = 5000;
13410 while (num394 > 0)
13411 {
13412 num394--;
13413 int num396 = genRand.Next(num393, Main.maxTilesX - num393);
13414 int num397 = genRand.Next(10, (int)Main.worldSurface);
13415 if (remixWorldGen)
13416 {
13417 num397 = genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY - 350);
13418 }
13419 bool flag18 = false;
13420 if (num394 < num395)
13421 {
13422 flag18 = true;
13423 }
13424 if (num394 > num395 / 2)
13425 {
13426 while ((double)num396 > (double)Main.maxTilesX * 0.4 && (double)num396 < (double)Main.maxTilesX * 0.6)
13427 {
13428 num396 = genRand.Next(num393, Main.maxTilesX - num393);
13429 }
13430 }
13431 if (!Main.tile[num396, num397].active() && Main.tile[num396, num397].wall == 0)
13432 {
13433 bool flag19 = true;
13434 if (remixWorldGen)
13435 {
13436 for (; !Main.tile[num396, num397].active() && Main.tile[num396, num397].wall == 0 && num397 <= Main.maxTilesY - 350; num397++)
13437 {
13438 }
13439 }
13440 else
13441 {
13442 for (; !Main.tile[num396, num397].active() && Main.tile[num396, num397].wall == 0 && (double)num397 <= Main.worldSurface; num397++)
13443 {
13444 }
13445 }
13446 if ((double)num397 > Main.worldSurface - 10.0 && !remixWorldGen)
13447 {
13448 flag19 = false;
13449 }
13450 else if (!flag18)
13451 {
13452 int num398 = 50;
13453 for (int num399 = num396 - num398; num399 < num396 + num398; num399++)
13454 {
13455 if (num399 > 10 && num399 < Main.maxTilesX - 10)
13456 {
13457 for (int num400 = num397 - num398; num400 < num397 + num398; num400++)
13458 {
13459 if (num400 > 10 && num400 < Main.maxTilesY - 10)
13460 {
13461 int type4 = Main.tile[num399, num400].type;
13462 switch (type4)
13463 {
13464 case 189:
13465 flag19 = false;
13466 break;
13467 case 53:
13468 flag19 = false;
13469 break;
13470 default:
13471 if (Main.tileDungeon[type4])
13472 {
13473 flag19 = false;
13474 }
13475 else if (TileID.Sets.Crimson[type4])
13476 {
13477 flag19 = false;
13478 }
13479 else if (TileID.Sets.Corrupt[type4])
13480 {
13481 flag19 = false;
13482 }
13483 break;
13484 }
13485 }
13486 }
13487 }
13488 }
13489 if (flag19)
13490 {
13491 int num401 = 10;
13492 int num402 = 10;
13493 for (int num403 = num396 - num401; num403 < num396 + num401; num403++)
13494 {
13495 for (int num404 = num397 - num402; num404 < num397 - 1; num404++)
13496 {
13497 if (Main.tile[num403, num404].active() && Main.tileSolid[Main.tile[num403, num404].type])
13498 {
13499 flag19 = false;
13500 }
13501 if (Main.tile[num403, num404].wall != 0)
13502 {
13503 flag19 = false;
13504 }
13505 }
13506 }
13507 }
13508 }
13509 if (flag19 && (Main.tile[num396, num397 - 1].liquid == 0 || num394 < num395 / 5) && (Main.tile[num396, num397].type == 2 || (notTheBees && Main.tile[num396, num397].type == 60)) && (Main.tile[num396 - 1, num397].type == 2 || (notTheBees && Main.tile[num396 - 1, num397].type == 60)) && (Main.tile[num396 + 1, num397].type == 2 || (notTheBees && Main.tile[num396 + 1, num397].type == 60)))
13510 {
13511 num397--;
13512 PlaceTile(num396, num397, 488);
13513 if (Main.tile[num396, num397].active() && Main.tile[num396, num397].type == 488)
13514 {
13515 if (genRand.Next(2) == 0)
13516 {
13517 GenVars.logX = num396;
13518 GenVars.logY = num397;
13519 }
13520 num394 = -1;
13521 }
13522 }
13523 }
13524 }
13525 }
13526 });
13528 {
13529 if (!notTheBees || noTrapsWorldGen || remixWorldGen)
13530 {
13531 placingTraps = true;
13532 progress.Message = Lang.gen[34].Value;
13533 if (noTrapsWorldGen)
13534 {
13535 progress.Message = Lang.gen[91].Value;
13536 }
13537 double num377 = (double)Main.maxTilesX * 0.05;
13538 if (noTrapsWorldGen)
13539 {
13540 num377 = ((!tenthAnniversaryWorldGen && !notTheBees) ? (num377 * 100.0) : (num377 * 5.0));
13541 }
13542 else if (getGoodWorldGen)
13543 {
13544 num377 *= 1.5;
13545 }
13546 if (Main.starGame)
13547 {
13548 num377 *= Main.starGameMath(0.2);
13549 }
13550 for (int num378 = 0; (double)num378 < num377; num378++)
13551 {
13552 progress.Set((double)num378 / num377 / 2.0);
13553 for (int num379 = 0; num379 < 1150; num379++)
13554 {
13555 if (noTrapsWorldGen)
13556 {
13557 int num380 = genRand.Next(50, Main.maxTilesX - 50);
13558 int num381 = genRand.Next(50, Main.maxTilesY - 50);
13559 if (remixWorldGen)
13560 {
13561 num381 = genRand.Next(50, Main.maxTilesY - 210);
13562 }
13563 if (((double)num381 > Main.worldSurface || Main.tile[num380, num381].wall > 0) && placeTrap(num380, num381))
13564 {
13565 break;
13566 }
13567 }
13568 else
13569 {
13570 int num382 = genRand.Next(200, Main.maxTilesX - 200);
13571 int num383 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 210);
13572 while (oceanDepths(num382, num383))
13573 {
13574 num382 = genRand.Next(200, Main.maxTilesX - 200);
13575 num383 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 210);
13576 }
13577 if (Main.tile[num382, num383].wall == 0 && placeTrap(num382, num383))
13578 {
13579 break;
13580 }
13581 }
13582 }
13583 }
13584 if (noTrapsWorldGen)
13585 {
13586 num377 = Main.maxTilesX * 3;
13587 if (Main.remixWorld)
13588 {
13589 num377 = Main.maxTilesX / 3;
13590 }
13591 if (Main.starGame)
13592 {
13593 num377 *= Main.starGameMath(0.2);
13594 }
13595 for (int num384 = 0; (double)num384 < num377; num384++)
13596 {
13597 if (Main.remixWorld)
13598 {
13599 placeTNTBarrel(genRand.Next(50, Main.maxTilesX - 50), genRand.Next((int)Main.worldSurface, (int)((double)(Main.maxTilesY - 350) + Main.rockLayer) / 2));
13600 }
13601 else
13602 {
13603 placeTNTBarrel(genRand.Next(50, Main.maxTilesX - 50), genRand.Next((int)Main.rockLayer, Main.maxTilesY - 200));
13604 }
13605 }
13606 }
13607 num377 = (double)Main.maxTilesX * 0.003;
13608 if (noTrapsWorldGen)
13609 {
13610 num377 *= 5.0;
13611 }
13612 else if (getGoodWorldGen)
13613 {
13614 num377 *= 1.5;
13615 }
13616 for (int num385 = 0; (double)num385 < num377; num385++)
13617 {
13618 progress.Set((double)num385 / num377 / 2.0 + 0.5);
13619 for (int num386 = 0; num386 < 20000; num386++)
13620 {
13621 int num387 = genRand.Next((int)((double)Main.maxTilesX * 0.15), (int)((double)Main.maxTilesX * 0.85));
13622 int num388 = genRand.Next((int)Main.worldSurface + 20, Main.maxTilesY - 210);
13623 if (Main.tile[num387, num388].wall == 187 && PlaceSandTrap(num387, num388))
13624 {
13625 break;
13626 }
13627 }
13628 }
13629 if (drunkWorldGen && !noTrapsWorldGen && !notTheBees)
13630 {
13631 for (int num389 = 0; num389 < 8; num389++)
13632 {
13633 progress.Message = Lang.gen[34].Value;
13634 num377 = 100.0;
13635 for (int num390 = 0; (double)num390 < num377; num390++)
13636 {
13637 progress.Set((double)num390 / num377);
13638 Thread.Sleep(10);
13639 }
13640 }
13641 }
13642 if (noTrapsWorldGen)
13643 {
13644 Main.tileSolid[138] = true;
13645 }
13646 placingTraps = false;
13647 }
13648 });
13650 {
13651 progress.Message = Lang.gen[89].Value;
13652 Main.tileSolid[229] = false;
13653 Main.tileSolid[190] = false;
13654 Main.tileSolid[196] = false;
13655 Main.tileSolid[189] = false;
13656 Main.tileSolid[202] = false;
13657 Main.tileSolid[460] = false;
13658 Main.tileSolid[484] = false;
13659 if (noTrapsWorldGen)
13660 {
13661 Main.tileSolid[138] = false;
13662 }
13663 for (int num319 = 0; (double)num319 < (double)Main.maxTilesX * 0.06; num319++)
13664 {
13665 int num320 = Main.maxTilesX / 2;
13666 bool flag11 = false;
13667 while (!flag11 && num320 > 0)
13668 {
13669 num320--;
13670 int num321 = genRand.Next(25, Main.maxTilesX - 25);
13671 int num322 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300);
13672 while (oceanDepths(num321, num322))
13673 {
13674 num321 = genRand.Next(25, Main.maxTilesX - 25);
13675 num322 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300);
13676 }
13677 if (!Main.tile[num321, num322].active())
13678 {
13679 int num323 = 186;
13680 for (; !Main.tile[num321, num322 + 1].active() && num322 < Main.maxTilesY - 5; num322++)
13681 {
13682 }
13683 int num324 = genRand.Next(22);
13684 if (num324 >= 16 && num324 <= 22)
13685 {
13686 num324 = genRand.Next(22);
13687 }
13688 if ((Main.tile[num321, num322 + 1].type == 0 || Main.tile[num321, num322 + 1].type == 1 || Main.tileMoss[Main.tile[num321, num322 + 1].type]) && genRand.Next(5) == 0)
13689 {
13690 num324 = genRand.Next(23, 29);
13691 num323 = 187;
13692 }
13693 if (num322 > Main.maxTilesY - 300 || Main.wallDungeon[Main.tile[num321, num322].wall] || Main.tile[num321, num322 + 1].type == 30 || Main.tile[num321, num322 + 1].type == 19 || Main.tile[num321, num322 + 1].type == 25 || Main.tile[num321, num322 + 1].type == 203)
13694 {
13695 num324 = genRand.Next(7);
13696 num323 = 186;
13697 }
13698 if (Main.tile[num321, num322 + 1].type == 147 || Main.tile[num321, num322 + 1].type == 161 || Main.tile[num321, num322 + 1].type == 162)
13699 {
13700 num324 = genRand.Next(26, 32);
13701 num323 = 186;
13702 }
13703 if (Main.tile[num321, num322 + 1].type == 60)
13704 {
13705 num323 = 187;
13706 num324 = genRand.Next(6);
13707 }
13708 if ((Main.tile[num321, num322 + 1].type == 57 || Main.tile[num321, num322 + 1].type == 58) && genRand.Next(3) < 2)
13709 {
13710 num323 = 187;
13711 num324 = genRand.Next(6, 9);
13712 }
13713 if (Main.tile[num321, num322 + 1].type == 226)
13714 {
13715 num323 = 187;
13716 num324 = genRand.Next(18, 23);
13717 }
13718 if (Main.tile[num321, num322 + 1].type == 70)
13719 {
13720 num324 = genRand.Next(32, 35);
13721 num323 = 186;
13722 }
13723 if (Main.tile[num321, num322 + 1].type == 396 || Main.tile[num321, num322 + 1].type == 397 || Main.tile[num321, num322 + 1].type == 404)
13724 {
13725 num324 = genRand.Next(29, 35);
13726 num323 = 187;
13727 }
13728 if (Main.tile[num321, num322 + 1].type == 368)
13729 {
13730 num324 = genRand.Next(35, 41);
13731 num323 = 187;
13732 }
13733 if (Main.tile[num321, num322 + 1].type == 367)
13734 {
13735 num324 = genRand.Next(41, 47);
13736 num323 = 187;
13737 }
13738 if (num323 == 186 && num324 >= 7 && num324 <= 15 && genRand.Next(75) == 0)
13739 {
13740 num323 = 187;
13741 num324 = 17;
13742 }
13743 if (Main.wallDungeon[Main.tile[num321, num322].wall] && genRand.Next(3) != 0)
13744 {
13745 flag11 = true;
13746 }
13747 else
13748 {
13749 if (!Main.tile[num321, num322].shimmer())
13750 {
13751 PlaceTile(num321, num322, num323, mute: true, forced: false, -1, num324);
13752 }
13753 if (Main.tile[num321, num322].type == 186 || Main.tile[num321, num322].type == 187)
13754 {
13755 flag11 = true;
13756 }
13757 if (flag11 && num323 == 186 && num324 <= 7)
13758 {
13759 int num325 = genRand.Next(1, 5);
13760 for (int num326 = 0; num326 < num325; num326++)
13761 {
13762 int num327 = num321 + genRand.Next(-10, 11);
13763 int num328 = num322 - genRand.Next(5);
13764 if (!Main.tile[num327, num328].active())
13765 {
13766 for (; !Main.tile[num327, num328 + 1].active() && num328 < Main.maxTilesY - 5; num328++)
13767 {
13768 }
13769 int x3 = genRand.Next(12, 36);
13770 PlaceSmallPile(num327, num328, x3, 0, 185);
13771 }
13772 }
13773 }
13774 }
13775 }
13776 }
13777 }
13778 for (int num329 = 0; (double)num329 < (double)Main.maxTilesX * 0.01; num329++)
13779 {
13780 int num330 = Main.maxTilesX / 2;
13781 bool flag12 = false;
13782 while (!flag12 && num330 > 0)
13783 {
13784 num330--;
13785 int num331 = genRand.Next(25, Main.maxTilesX - 25);
13786 int num332 = genRand.Next(Main.maxTilesY - 300, Main.maxTilesY - 10);
13787 if (!Main.tile[num331, num332].active())
13788 {
13789 int num333 = 186;
13790 for (; !Main.tile[num331, num332 + 1].active() && num332 < Main.maxTilesY - 5; num332++)
13791 {
13792 }
13793 int num334 = genRand.Next(22);
13794 if (num334 >= 16 && num334 <= 22)
13795 {
13796 num334 = genRand.Next(22);
13797 }
13798 if (num332 > Main.maxTilesY - 300 || Main.wallDungeon[Main.tile[num331, num332].wall] || Main.tile[num331, num332 + 1].type == 30 || Main.tile[num331, num332 + 1].type == 19)
13799 {
13800 num334 = genRand.Next(7);
13801 }
13802 if ((Main.tile[num331, num332 + 1].type == 57 || Main.tile[num331, num332 + 1].type == 58) && genRand.Next(3) < 2)
13803 {
13804 num333 = 187;
13805 num334 = genRand.Next(6, 9);
13806 }
13807 if (Main.tile[num331, num332 + 1].type == 147 || Main.tile[num331, num332 + 1].type == 161 || Main.tile[num331, num332 + 1].type == 162)
13808 {
13809 num334 = genRand.Next(26, 32);
13810 }
13811 PlaceTile(num331, num332, num333, mute: true, forced: false, -1, num334);
13812 if (Main.tile[num331, num332].type == 186 || Main.tile[num331, num332].type == 187)
13813 {
13814 flag12 = true;
13815 }
13816 if (flag12 && num333 == 186 && num334 <= 7)
13817 {
13818 int num335 = genRand.Next(1, 5);
13819 for (int num336 = 0; num336 < num335; num336++)
13820 {
13821 int num337 = num331 + genRand.Next(-10, 11);
13822 int num338 = num332 - genRand.Next(5);
13823 if (!Main.tile[num337, num338].active())
13824 {
13825 for (; !Main.tile[num337, num338 + 1].active() && num338 < Main.maxTilesY - 5; num338++)
13826 {
13827 }
13828 int x4 = genRand.Next(12, 36);
13829 PlaceSmallPile(num337, num338, x4, 0, 185);
13830 }
13831 }
13832 }
13833 }
13834 }
13835 }
13836 for (int num339 = 0; (double)num339 < (double)Main.maxTilesX * 0.003; num339++)
13837 {
13838 int num340 = Main.maxTilesX / 2;
13839 bool flag13 = false;
13840 while (!flag13 && num340 > 0)
13841 {
13842 num340--;
13843 int num341 = 186;
13844 int num342 = genRand.Next(25, Main.maxTilesX - 25);
13845 int num343 = genRand.Next(10, (int)Main.worldSurface);
13846 while (oceanDepths(num342, num343))
13847 {
13848 num342 = genRand.Next(25, Main.maxTilesX - 25);
13849 num343 = genRand.Next(10, (int)Main.worldSurface);
13850 }
13851 if (!Main.tile[num342, num343].active())
13852 {
13853 for (; !Main.tile[num342, num343 + 1].active() && num343 < Main.maxTilesY - 5; num343++)
13854 {
13855 }
13856 int num344 = genRand.Next(7, 13);
13857 if (num343 > Main.maxTilesY - 300 || Main.wallDungeon[Main.tile[num342, num343].wall] || Main.tile[num342, num343 + 1].type == 30 || Main.tile[num342, num343 + 1].type == 19 || Main.tile[num342, num343 + 1].type == 25 || Main.tile[num342, num343 + 1].type == 203 || Main.tile[num342, num343 + 1].type == 234 || Main.tile[num342, num343 + 1].type == 112)
13858 {
13859 num344 = -1;
13860 }
13861 if (Main.tile[num342, num343 + 1].type == 147 || Main.tile[num342, num343 + 1].type == 161 || Main.tile[num342, num343 + 1].type == 162)
13862 {
13863 num344 = genRand.Next(26, 32);
13864 }
13865 if (Main.tile[num342, num343 + 1].type == 53)
13866 {
13867 num341 = 187;
13868 num344 = genRand.Next(52, 55);
13869 }
13870 if (Main.tile[num342, num343 + 1].type == 2 || Main.tile[num342 - 1, num343 + 1].type == 2 || Main.tile[num342 + 1, num343 + 1].type == 2)
13871 {
13872 num341 = 187;
13873 num344 = genRand.Next(14, 17);
13874 }
13875 if (Main.tile[num342, num343 + 1].type == 151 || Main.tile[num342, num343 + 1].type == 274)
13876 {
13877 num341 = 186;
13878 num344 = genRand.Next(7);
13879 }
13880 if (num344 >= 0)
13881 {
13882 PlaceTile(num342, num343, num341, mute: true, forced: false, -1, num344);
13883 }
13884 if (Main.tile[num342, num343].type == num341)
13885 {
13886 flag13 = true;
13887 }
13888 }
13889 }
13890 }
13891 for (int num345 = 0; (double)num345 < (double)Main.maxTilesX * 0.0035; num345++)
13892 {
13893 int num346 = Main.maxTilesX / 2;
13894 bool flag14 = false;
13895 while (!flag14 && num346 > 0)
13896 {
13897 num346--;
13898 int num347 = genRand.Next(25, Main.maxTilesX - 25);
13899 int num348 = genRand.Next(10, (int)Main.worldSurface);
13900 if (!Main.tile[num347, num348].active() && Main.tile[num347, num348].wall > 0)
13901 {
13902 int num349 = 186;
13903 for (; !Main.tile[num347, num348 + 1].active() && num348 < Main.maxTilesY - 5; num348++)
13904 {
13905 }
13906 int num350 = genRand.Next(7, 13);
13907 if (num348 > Main.maxTilesY - 300 || Main.wallDungeon[Main.tile[num347, num348].wall] || Main.tile[num347, num348 + 1].type == 30 || Main.tile[num347, num348 + 1].type == 19)
13908 {
13909 num350 = -1;
13910 }
13911 if (Main.tile[num347, num348 + 1].type == 25)
13912 {
13913 num350 = genRand.Next(7);
13914 }
13915 if (Main.tile[num347, num348 + 1].type == 147 || Main.tile[num347, num348 + 1].type == 161 || Main.tile[num347, num348 + 1].type == 162)
13916 {
13917 num350 = genRand.Next(26, 32);
13918 }
13919 if (Main.tile[num347, num348 + 1].type == 2 || Main.tile[num347 - 1, num348 + 1].type == 2 || Main.tile[num347 + 1, num348 + 1].type == 2)
13920 {
13921 num349 = 187;
13922 num350 = genRand.Next(14, 17);
13923 }
13924 if (Main.tile[num347, num348 + 1].type == 151 || Main.tile[num347, num348 + 1].type == 274)
13925 {
13926 num349 = 186;
13927 num350 = genRand.Next(7);
13928 }
13929 if (num350 >= 0)
13930 {
13931 PlaceTile(num347, num348, num349, mute: true, forced: false, -1, num350);
13932 }
13933 if (Main.tile[num347, num348].type == num349)
13934 {
13935 flag14 = true;
13936 }
13937 if (flag14 && num350 <= 7)
13938 {
13939 int num351 = genRand.Next(1, 5);
13940 for (int num352 = 0; num352 < num351; num352++)
13941 {
13942 int num353 = num347 + genRand.Next(-10, 11);
13943 int num354 = num348 - genRand.Next(5);
13944 if (!Main.tile[num353, num354].active())
13945 {
13946 for (; !Main.tile[num353, num354 + 1].active() && num354 < Main.maxTilesY - 5; num354++)
13947 {
13948 }
13949 int x5 = genRand.Next(12, 36);
13950 PlaceSmallPile(num353, num354, x5, 0, 185);
13951 }
13952 }
13953 }
13954 }
13955 }
13956 }
13957 for (int num355 = 0; (double)num355 < (double)Main.maxTilesX * 0.6; num355++)
13958 {
13959 int num356 = Main.maxTilesX / 2;
13960 bool flag15 = false;
13961 while (!flag15 && num356 > 0)
13962 {
13963 num356--;
13964 int num357 = genRand.Next(25, Main.maxTilesX - 25);
13965 int num358 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 20);
13966 if (Main.tile[num357, num358].wall == 87 && genRand.Next(2) == 0)
13967 {
13968 num357 = genRand.Next(25, Main.maxTilesX - 25);
13969 num358 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 20);
13970 }
13971 while (oceanDepths(num357, num358))
13972 {
13973 num357 = genRand.Next(25, Main.maxTilesX - 25);
13974 num358 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 20);
13975 }
13976 if (!Main.tile[num357, num358].active())
13977 {
13978 for (; !Main.tile[num357, num358 + 1].active() && num358 < Main.maxTilesY - 5; num358++)
13979 {
13980 }
13981 int num359 = genRand.Next(2);
13982 int num360 = genRand.Next(36);
13983 if (num360 >= 28 && num360 <= 35)
13984 {
13985 num360 = genRand.Next(36);
13986 }
13987 if (num359 == 1)
13988 {
13989 num360 = genRand.Next(25);
13990 if (num360 >= 16 && num360 <= 24)
13991 {
13992 num360 = genRand.Next(25);
13993 }
13994 }
13995 if (num358 > Main.maxTilesY - 300)
13996 {
13997 if (num359 == 0)
13998 {
13999 num360 = genRand.Next(12, 28);
14000 }
14001 if (num359 == 1)
14002 {
14003 num360 = genRand.Next(6, 16);
14004 }
14005 }
14006 if (Main.wallDungeon[Main.tile[num357, num358].wall] || Main.tile[num357, num358 + 1].type == 30 || Main.tile[num357, num358 + 1].type == 19 || Main.tile[num357, num358 + 1].type == 25 || Main.tile[num357, num358 + 1].type == 203 || Main.tile[num357, num358].wall == 87)
14007 {
14008 if (num359 == 0 && num360 < 12)
14009 {
14010 num360 += 12;
14011 }
14012 if (num359 == 1 && num360 < 6)
14013 {
14014 num360 += 6;
14015 }
14016 if (num359 == 1 && num360 >= 17)
14017 {
14018 num360 -= 10;
14019 }
14020 }
14021 if (Main.tile[num357, num358 + 1].type == 147 || Main.tile[num357, num358 + 1].type == 161 || Main.tile[num357, num358 + 1].type == 162)
14022 {
14023 if (num359 == 0 && num360 < 12)
14024 {
14025 num360 += 36;
14026 }
14027 if (num359 == 1 && num360 >= 20)
14028 {
14029 num360 += 6;
14030 }
14031 if (num359 == 1 && num360 < 6)
14032 {
14033 num360 += 25;
14034 }
14035 }
14036 if (Main.tile[num357, num358 + 1].type == 151 || Main.tile[num357, num358 + 1].type == 274)
14037 {
14038 if (num359 == 0)
14039 {
14040 num360 = genRand.Next(12, 28);
14041 }
14042 if (num359 == 1)
14043 {
14044 num360 = genRand.Next(12, 19);
14045 }
14046 }
14047 if (Main.tile[num357, num358 + 1].type == 368)
14048 {
14049 if (num359 == 0)
14050 {
14051 num360 = genRand.Next(60, 66);
14052 }
14053 if (num359 == 1)
14054 {
14055 num360 = genRand.Next(47, 53);
14056 }
14057 }
14058 if (Main.tile[num357, num358 + 1].type == 367)
14059 {
14060 if (num359 == 0)
14061 {
14062 num360 = genRand.Next(66, 72);
14063 }
14064 if (num359 == 1)
14065 {
14066 num360 = genRand.Next(53, 59);
14067 }
14068 }
14069 if (Main.wallDungeon[Main.tile[num357, num358].wall] && genRand.Next(3) != 0)
14070 {
14071 flag15 = true;
14072 }
14073 else if (!Main.tile[num357, num358].shimmer())
14074 {
14075 flag15 = PlaceSmallPile(num357, num358, num360, num359, 185);
14076 }
14077 if (flag15 && num359 == 1 && num360 >= 6 && num360 <= 15)
14078 {
14079 int num361 = genRand.Next(1, 5);
14080 for (int num362 = 0; num362 < num361; num362++)
14081 {
14082 int num363 = num357 + genRand.Next(-10, 11);
14083 int num364 = num358 - genRand.Next(5);
14084 if (!Main.tile[num363, num364].active())
14085 {
14086 for (; !Main.tile[num363, num364 + 1].active() && num364 < Main.maxTilesY - 5; num364++)
14087 {
14088 }
14089 int x6 = genRand.Next(12, 36);
14090 PlaceSmallPile(num363, num364, x6, 0, 185);
14091 }
14092 }
14093 }
14094 }
14095 }
14096 }
14097 for (int num365 = 0; (double)num365 < (double)Main.maxTilesX * 0.02; num365++)
14098 {
14099 int num366 = Main.maxTilesX / 2;
14100 bool flag16 = false;
14101 while (!flag16 && num366 > 0)
14102 {
14103 num366--;
14104 int num367 = genRand.Next(25, Main.maxTilesX - 25);
14105 int num368 = genRand.Next(15, (int)Main.worldSurface);
14106 while (oceanDepths(num367, num368))
14107 {
14108 num367 = genRand.Next(25, Main.maxTilesX - 25);
14109 num368 = genRand.Next(15, (int)Main.worldSurface);
14110 }
14111 if (!Main.tile[num367, num368].active())
14112 {
14113 for (; !Main.tile[num367, num368 + 1].active() && num368 < Main.maxTilesY - 5; num368++)
14114 {
14115 }
14116 int num369 = genRand.Next(2);
14117 int num370 = genRand.Next(11);
14118 if (num369 == 1)
14119 {
14120 num370 = genRand.Next(5);
14121 }
14122 if (Main.tile[num367, num368 + 1].type == 147 || Main.tile[num367, num368 + 1].type == 161 || Main.tile[num367, num368 + 1].type == 162)
14123 {
14124 if (num369 == 0 && num370 < 12)
14125 {
14126 num370 += 36;
14127 }
14128 if (num369 == 1 && num370 >= 20)
14129 {
14130 num370 += 6;
14131 }
14132 if (num369 == 1 && num370 < 6)
14133 {
14134 num370 += 25;
14135 }
14136 }
14137 if (Main.tile[num367, num368 + 1].type == 2 && num369 == 1)
14138 {
14139 num370 = genRand.Next(38, 41);
14140 }
14141 if (Main.tile[num367, num368 + 1].type == 151 || Main.tile[num367, num368 + 1].type == 274)
14142 {
14143 if (num369 == 0)
14144 {
14145 num370 = genRand.Next(12, 28);
14146 }
14147 if (num369 == 1)
14148 {
14149 num370 = genRand.Next(12, 19);
14150 }
14151 }
14152 if (!Main.wallDungeon[Main.tile[num367, num368].wall] && Main.tile[num367, num368 + 1].type != 30 && Main.tile[num367, num368 + 1].type != 19 && Main.tile[num367, num368 + 1].type != 41 && Main.tile[num367, num368 + 1].type != 43 && Main.tile[num367, num368 + 1].type != 44 && Main.tile[num367, num368 + 1].type != 481 && Main.tile[num367, num368 + 1].type != 482 && Main.tile[num367, num368 + 1].type != 483 && Main.tile[num367, num368 + 1].type != 45 && Main.tile[num367, num368 + 1].type != 46 && Main.tile[num367, num368 + 1].type != 47 && Main.tile[num367, num368 + 1].type != 175 && Main.tile[num367, num368 + 1].type != 176 && Main.tile[num367, num368 + 1].type != 177 && Main.tile[num367, num368 + 1].type != 53 && Main.tile[num367, num368 + 1].type != 25 && Main.tile[num367, num368 + 1].type != 203)
14153 {
14154 flag16 = PlaceSmallPile(num367, num368, num370, num369, 185);
14155 }
14156 }
14157 }
14158 }
14159 for (int num371 = 0; (double)num371 < (double)Main.maxTilesX * 0.15; num371++)
14160 {
14161 int num372 = Main.maxTilesX / 2;
14162 bool flag17 = false;
14163 while (!flag17 && num372 > 0)
14164 {
14165 num372--;
14166 int num373 = genRand.Next(25, Main.maxTilesX - 25);
14167 int num374 = genRand.Next(15, (int)Main.worldSurface);
14168 if (!Main.tile[num373, num374].active() && (Main.tile[num373, num374].wall == 2 || Main.tile[num373, num374].wall == 40))
14169 {
14170 for (; !Main.tile[num373, num374 + 1].active() && num374 < Main.maxTilesY - 5; num374++)
14171 {
14172 }
14173 int num375 = genRand.Next(2);
14174 int num376 = genRand.Next(11);
14175 if (num375 == 1)
14176 {
14177 num376 = genRand.Next(5);
14178 }
14179 if (Main.tile[num373, num374 + 1].type == 147 || Main.tile[num373, num374 + 1].type == 161 || Main.tile[num373, num374 + 1].type == 162)
14180 {
14181 if (num375 == 0 && num376 < 12)
14182 {
14183 num376 += 36;
14184 }
14185 if (num375 == 1 && num376 >= 20)
14186 {
14187 num376 += 6;
14188 }
14189 if (num375 == 1 && num376 < 6)
14190 {
14191 num376 += 25;
14192 }
14193 }
14194 if (Main.tile[num373, num374 + 1].type == 2 && num375 == 1)
14195 {
14196 num376 = genRand.Next(38, 41);
14197 }
14198 if (Main.tile[num373, num374 + 1].type == 151 || Main.tile[num373, num374 + 1].type == 274)
14199 {
14200 if (num375 == 0)
14201 {
14202 num376 = genRand.Next(12, 28);
14203 }
14204 if (num375 == 1)
14205 {
14206 num376 = genRand.Next(12, 19);
14207 }
14208 }
14209 if ((Main.tile[num373, num374].liquid != byte.MaxValue || Main.tile[num373, num374 + 1].type != 53 || Main.tile[num373, num374].wall != 0) && !Main.wallDungeon[Main.tile[num373, num374].wall] && Main.tile[num373, num374 + 1].type != 30 && Main.tile[num373, num374 + 1].type != 19 && Main.tile[num373, num374 + 1].type != 41 && Main.tile[num373, num374 + 1].type != 43 && Main.tile[num373, num374 + 1].type != 44 && Main.tile[num373, num374 + 1].type != 481 && Main.tile[num373, num374 + 1].type != 482 && Main.tile[num373, num374 + 1].type != 483 && Main.tile[num373, num374 + 1].type != 45 && Main.tile[num373, num374 + 1].type != 46 && Main.tile[num373, num374 + 1].type != 47 && Main.tile[num373, num374 + 1].type != 175 && Main.tile[num373, num374 + 1].type != 176 && Main.tile[num373, num374 + 1].type != 177 && Main.tile[num373, num374 + 1].type != 25 && Main.tile[num373, num374 + 1].type != 203)
14210 {
14211 flag17 = PlaceSmallPile(num373, num374, num376, num375, 185);
14212 }
14213 }
14214 }
14215 }
14216 Main.tileSolid[190] = true;
14217 Main.tileSolid[192] = true;
14218 Main.tileSolid[196] = true;
14219 Main.tileSolid[189] = true;
14220 Main.tileSolid[202] = true;
14221 Main.tileSolid[225] = true;
14222 Main.tileSolid[460] = true;
14223 Main.tileSolid[138] = true;
14224 });
14225 AddGenerationPass("Spawn Point", delegate(GenerationProgress progress, GameConfiguration passConfig)
14226 {
14227 progress.Set(1.0);
14228 int num310 = 5;
14229 bool flag10 = true;
14230 int num311 = Main.maxTilesX / 2;
14231 if (Main.tenthAnniversaryWorld && !remixWorldGen)
14232 {
14233 int num312 = GenVars.beachBordersWidth + 15;
14234 num311 = ((genRand.Next(2) != 0) ? (Main.maxTilesX - num312) : num312);
14235 }
14236 while (flag10)
14237 {
14238 int num313 = num311 + genRand.Next(-num310, num310 + 1);
14239 for (int num314 = 0; num314 < Main.maxTilesY; num314++)
14240 {
14241 if (Main.tile[num313, num314].active())
14242 {
14243 Main.spawnTileX = num313;
14244 Main.spawnTileY = num314;
14245 break;
14246 }
14247 }
14248 flag10 = false;
14249 num310++;
14250 if ((double)Main.spawnTileY > Main.worldSurface)
14251 {
14252 flag10 = true;
14253 }
14254 if (Main.tile[Main.spawnTileX, Main.spawnTileY - 1].liquid > 0)
14255 {
14256 flag10 = true;
14257 }
14258 }
14259 int num315 = 10;
14260 while ((double)Main.spawnTileY > Main.worldSurface)
14261 {
14262 int num316 = genRand.Next(num311 - num315, num311 + num315);
14263 for (int num317 = 0; num317 < Main.maxTilesY; num317++)
14264 {
14265 if (Main.tile[num316, num317].active())
14266 {
14267 Main.spawnTileX = num316;
14268 Main.spawnTileY = num317;
14269 break;
14270 }
14271 }
14272 num315++;
14273 }
14274 if (remixWorldGen)
14275 {
14276 int num318 = Main.maxTilesY - 10;
14278 {
14279 num318--;
14280 }
14281 Main.spawnTileY = num318 + 1;
14282 }
14283 });
14284 AddGenerationPass("Grass Wall", delegate(GenerationProgress progress, GameConfiguration passConfig)
14285 {
14286 maxTileCount = 3500;
14287 progress.Set(1.0);
14288 for (int num298 = 50; num298 < Main.maxTilesX - 50; num298++)
14289 {
14290 for (int num299 = 0; (double)num299 < Main.worldSurface - 10.0; num299++)
14291 {
14292 if (genRand.Next(4) == 0)
14293 {
14294 bool flag8 = false;
14295 int num300 = -1;
14296 int num301 = -1;
14297 if (Main.tile[num298, num299].active() && Main.tile[num298, num299].type == 2 && (Main.tile[num298, num299].wall == 2 || Main.tile[num298, num299].wall == 63))
14298 {
14299 for (int num302 = num298 - 1; num302 <= num298 + 1; num302++)
14300 {
14301 for (int num303 = num299 - 1; num303 <= num299 + 1; num303++)
14302 {
14303 if (Main.tile[num302, num303].wall == 0 && !SolidTile(num302, num303))
14304 {
14305 flag8 = true;
14306 }
14307 }
14308 }
14309 if (flag8)
14310 {
14311 for (int num304 = num298 - 1; num304 <= num298 + 1; num304++)
14312 {
14313 for (int num305 = num299 - 1; num305 <= num299 + 1; num305++)
14314 {
14315 if ((Main.tile[num304, num305].wall == 2 || Main.tile[num304, num305].wall == 15) && !SolidTile(num304, num305))
14316 {
14317 num300 = num304;
14318 num301 = num305;
14319 }
14320 }
14321 }
14322 }
14323 }
14324 if (flag8 && num300 > -1 && num301 > -1 && countDirtTiles(num300, num301) < maxTileCount)
14325 {
14326 try
14327 {
14328 ushort wallType = 63;
14329 if (dontStarveWorldGen && genRand.Next(3) != 0)
14330 {
14331 wallType = 62;
14332 }
14333 Spread.Wall2(num300, num301, wallType);
14334 }
14335 catch
14336 {
14337 }
14338 }
14339 }
14340 }
14341 }
14342 for (int num306 = 5; num306 < Main.maxTilesX - 5; num306++)
14343 {
14344 for (int num307 = 10; (double)num307 < Main.worldSurface - 1.0; num307++)
14345 {
14346 if (Main.tile[num306, num307].wall == 63 && genRand.Next(10) == 0)
14347 {
14348 Main.tile[num306, num307].wall = 65;
14349 }
14350 if (Main.tile[num306, num307].active() && Main.tile[num306, num307].type == 0)
14351 {
14352 bool flag9 = false;
14353 for (int num308 = num306 - 1; num308 <= num306 + 1; num308++)
14354 {
14355 for (int num309 = num307 - 1; num309 <= num307 + 1; num309++)
14356 {
14357 if (Main.tile[num308, num309].wall == 63 || Main.tile[num308, num309].wall == 65)
14358 {
14359 flag9 = true;
14360 break;
14361 }
14362 }
14363 }
14364 if (flag9)
14365 {
14366 SpreadGrass(num306, num307);
14367 }
14368 }
14369 }
14370 }
14371 });
14373 {
14374 progress.Set(1.0);
14376 {
14377 BirthdayParty.GenuineParty = true;
14378 BirthdayParty.PartyDaysOnCooldown = 5;
14379 if (getGoodWorldGen)
14380 {
14381 Main.afterPartyOfDoom = true;
14382 }
14383 int num292;
14384 if (remixWorldGen)
14385 {
14387 NPC.savedTaxCollector = true;
14388 }
14389 else
14390 {
14392 }
14393 Main.npc[num292].homeTileX = Main.spawnTileX;
14394 Main.npc[num292].homeTileY = Main.spawnTileY;
14395 Main.npc[num292].direction = 1;
14396 Main.npc[num292].homeless = true;
14397 Main.npc[num292].GivenName = Language.GetTextValue("GuideNames.Andrew");
14399 Point adjustedFloorPosition = GetAdjustedFloorPosition(Main.spawnTileX + 2, Main.spawnTileY);
14401 Main.npc[num292].homeTileX = adjustedFloorPosition.X;
14402 Main.npc[num292].homeTileY = adjustedFloorPosition.Y;
14403 Main.npc[num292].direction = -1;
14404 Main.npc[num292].homeless = true;
14405 Main.npc[num292].GivenName = Language.GetTextValue("SteampunkerNames.Whitney");
14407 adjustedFloorPosition = GetAdjustedFloorPosition(Main.spawnTileX - 2, Main.spawnTileY);
14409 Main.npc[num292].homeTileX = adjustedFloorPosition.X;
14410 Main.npc[num292].homeTileY = adjustedFloorPosition.Y;
14411 Main.npc[num292].direction = 1;
14412 Main.npc[num292].homeless = true;
14413 Main.npc[num292].GivenName = Language.GetTextValue("PrincessNames.Yorai");
14415 NPC.unlockedPrincessSpawn = true;
14416 adjustedFloorPosition = GetAdjustedFloorPosition(Main.spawnTileX + 4, Main.spawnTileY);
14418 Main.npc[num292].homeTileX = adjustedFloorPosition.X;
14419 Main.npc[num292].homeTileY = adjustedFloorPosition.Y;
14420 Main.npc[num292].direction = -1;
14421 Main.npc[num292].homeless = true;
14422 Main.npc[num292].GivenName = Language.GetTextValue("PartyGirlNames.Amanda");
14424 NPC.unlockedPartyGirlSpawn = true;
14425 adjustedFloorPosition = GetAdjustedFloorPosition(Main.spawnTileX - 4, Main.spawnTileY);
14426 if (Main.remixWorld)
14427 {
14429 Main.npc[num292].GivenName = Language.GetTextValue("SlimeNames_Rainbow.Slimestar");
14430 NPC.unlockedSlimeRainbowSpawn = true;
14431 }
14432 else
14433 {
14435 NPC.boughtBunny = true;
14436 Main.npc[num292].townNpcVariationIndex = 1;
14437 }
14438 Main.npc[num292].homeTileX = adjustedFloorPosition.X;
14439 Main.npc[num292].homeTileY = adjustedFloorPosition.Y;
14440 Main.npc[num292].direction = 1;
14441 Main.npc[num292].homeless = true;
14442 }
14443 else if (remixWorldGen)
14444 {
14445 int num293 = NPC.NewNPC(new EntitySource_WorldGen(), Main.spawnTileX * 16, Main.spawnTileY * 16, 441);
14446 Main.npc[num293].homeTileX = Main.spawnTileX;
14447 Main.npc[num293].homeTileY = Main.spawnTileY;
14448 Main.npc[num293].direction = 1;
14449 Main.npc[num293].homeless = true;
14450 NPC.savedTaxCollector = true;
14451 }
14452 else if (notTheBees)
14453 {
14454 int num294 = NPC.NewNPC(new EntitySource_WorldGen(), Main.spawnTileX * 16, Main.spawnTileY * 16, 17);
14455 Main.npc[num294].homeTileX = Main.spawnTileX;
14456 Main.npc[num294].homeTileY = Main.spawnTileY;
14457 Main.npc[num294].direction = 1;
14458 Main.npc[num294].homeless = true;
14459 NPC.unlockedMerchantSpawn = true;
14460 }
14461 else if (drunkWorldGen)
14462 {
14463 int num295 = NPC.NewNPC(new EntitySource_WorldGen(), Main.spawnTileX * 16, Main.spawnTileY * 16, 208);
14464 Main.npc[num295].homeTileX = Main.spawnTileX;
14465 Main.npc[num295].homeTileY = Main.spawnTileY;
14466 Main.npc[num295].direction = 1;
14467 Main.npc[num295].homeless = true;
14468 NPC.unlockedPartyGirlSpawn = true;
14469 }
14470 else if (getGoodWorldGen)
14471 {
14472 int num296 = NPC.NewNPC(new EntitySource_WorldGen(), Main.spawnTileX * 16, Main.spawnTileY * 16, 38);
14473 Main.npc[num296].homeTileX = Main.spawnTileX;
14474 Main.npc[num296].homeTileY = Main.spawnTileY;
14475 Main.npc[num296].direction = 1;
14476 Main.npc[num296].homeless = true;
14477 NPC.unlockedDemolitionistSpawn = true;
14478 }
14479 else
14480 {
14481 int num297 = NPC.NewNPC(new EntitySource_WorldGen(), Main.spawnTileX * 16, Main.spawnTileY * 16, 22);
14482 Main.npc[num297].homeTileX = Main.spawnTileX;
14483 Main.npc[num297].homeTileY = Main.spawnTileY;
14484 Main.npc[num297].direction = 1;
14485 Main.npc[num297].homeless = true;
14486 }
14487 });
14488 AddGenerationPass("Sunflowers", delegate(GenerationProgress progress, GameConfiguration passConfig)
14489 {
14490 progress.Message = Lang.gen[39].Value;
14491 double num283 = (double)Main.maxTilesX * 0.002;
14492 for (int num284 = 0; (double)num284 < num283; num284++)
14493 {
14494 progress.Set((double)num284 / num283);
14495 int num285 = 0;
14496 int num286 = 0;
14497 _ = Main.maxTilesX / 2;
14498 int num287 = genRand.Next(Main.maxTilesX);
14499 num285 = num287 - genRand.Next(10) - 7;
14500 num286 = num287 + genRand.Next(10) + 7;
14501 if (num285 < 0)
14502 {
14503 num285 = 0;
14504 }
14505 if (num286 > Main.maxTilesX - 1)
14506 {
14507 num286 = Main.maxTilesX - 1;
14508 }
14509 int num288 = 1;
14510 int num289 = (int)Main.worldSurface - 1;
14511 for (int num290 = num285; num290 < num286; num290++)
14512 {
14513 for (int num291 = num288; num291 < num289; num291++)
14514 {
14515 if (Main.tile[num290, num291].type == 2 && Main.tile[num290, num291].active() && !Main.tile[num290, num291 - 1].active())
14516 {
14517 PlaceTile(num290, num291 - 1, 27, mute: true);
14518 }
14519 if (Main.tile[num290, num291].active())
14520 {
14521 break;
14522 }
14523 }
14524 }
14525 }
14526 });
14527 AddGenerationPass("Planting Trees", delegate(GenerationProgress progress, GameConfiguration passConfig)
14528 {
14529 progress.Message = Lang.gen[40].Value;
14530 if (!drunkWorldGen && !Main.tenthAnniversaryWorld)
14531 {
14532 for (int num278 = 0; (double)num278 < (double)Main.maxTilesX * 0.003; num278++)
14533 {
14534 progress.Set((double)num278 / ((double)Main.maxTilesX * 0.003));
14535 int num279 = genRand.Next(50, Main.maxTilesX - 50);
14536 int num280 = genRand.Next(25, 50);
14537 for (int num281 = num279 - num280; num281 < num279 + num280; num281++)
14538 {
14539 for (int num282 = 20; (double)num282 < Main.worldSurface; num282++)
14540 {
14541 GrowEpicTree(num281, num282);
14542 }
14543 }
14544 }
14545 }
14546 AddTrees();
14547 });
14549 {
14550 double num276 = (double)Main.maxTilesX * 1.7;
14551 if (remixWorldGen)
14552 {
14553 num276 *= 5.0;
14554 }
14555 progress.Message = Lang.gen[41].Value;
14556 for (int num277 = 0; (double)num277 < num276; num277++)
14557 {
14558 progress.Set((double)num277 / num276);
14559 PlantAlch();
14560 }
14561 });
14562 AddGenerationPass("Dye Plants", delegate(GenerationProgress progress, GameConfiguration passConfig)
14563 {
14564 progress.Set(1.0);
14565 for (int num275 = 0; num275 < Main.maxTilesX; num275++)
14566 {
14567 plantDye(genRand.Next(100, Main.maxTilesX - 100), genRand.Next(100, Main.UnderworldLayer));
14568 }
14569 MatureTheHerbPlants();
14570 GrowGlowTulips();
14571 });
14572 AddGenerationPass("Webs And Honey", delegate(GenerationProgress progress, GameConfiguration passConfig)
14573 {
14574 progress.Set(1.0);
14575 for (int num265 = 100; num265 < Main.maxTilesX - 100; num265++)
14576 {
14577 int num266 = (int)Main.worldSurface;
14578 if (dontStarveWorldGen)
14579 {
14580 num266 = 50;
14581 }
14582 for (int num267 = num266; num267 < Main.maxTilesY - 100; num267++)
14583 {
14584 if (Main.tile[num265, num267].wall == 86)
14585 {
14586 if (Main.tile[num265, num267].liquid > 0)
14587 {
14588 Main.tile[num265, num267].honey(honey: true);
14589 }
14590 if (genRand.Next(3) == 0)
14591 {
14592 PlaceTight(num265, num267);
14593 }
14594 }
14595 if (Main.tile[num265, num267].wall == 62)
14596 {
14597 Main.tile[num265, num267].liquid = 0;
14598 Main.tile[num265, num267].lava(lava: false);
14599 }
14600 if (Main.tile[num265, num267].wall == 62 && !Main.tile[num265, num267].active() && genRand.Next(10) != 0)
14601 {
14602 int num268 = genRand.Next(2, 5);
14603 int num269 = num265 - num268;
14604 int num270 = num265 + num268;
14605 int num271 = num267 - num268;
14606 int num272 = num267 + num268;
14607 bool flag7 = false;
14608 for (int num273 = num269; num273 <= num270; num273++)
14609 {
14610 for (int num274 = num271; num274 <= num272; num274++)
14611 {
14612 if (SolidTile(num273, num274))
14613 {
14614 flag7 = true;
14615 break;
14616 }
14617 }
14618 }
14619 if (flag7)
14620 {
14621 PlaceTile(num265, num267, 51, mute: true);
14622 TileFrame(num265, num267);
14623 }
14624 }
14625 }
14626 }
14627 });
14629 {
14630 progress.Message = Lang.gen[42].Value;
14631 if (Main.halloween)
14632 {
14633 for (int num259 = 40; num259 < Main.maxTilesX - 40; num259++)
14634 {
14635 for (int num260 = 50; (double)num260 < Main.worldSurface; num260++)
14636 {
14637 if (Main.tile[num259, num260].active() && Main.tile[num259, num260].type == 2 && genRand.Next(15) == 0)
14638 {
14639 PlacePumpkin(num259, num260 - 1);
14640 int num261 = genRand.Next(5);
14641 for (int num262 = 0; num262 < num261; num262++)
14642 {
14643 GrowPumpkin(num259, num260 - 1, 254);
14644 }
14645 }
14646 }
14647 }
14648 }
14649 for (int num263 = 0; num263 < Main.maxTilesX; num263++)
14650 {
14651 progress.Set((double)num263 / (double)Main.maxTilesX);
14652 for (int num264 = 1; num264 < Main.maxTilesY; num264++)
14653 {
14654 if (Main.tile[num263, num264].type == 2 && Main.tile[num263, num264].nactive())
14655 {
14656 if (!Main.tile[num263, num264 - 1].active())
14657 {
14658 PlaceTile(num263, num264 - 1, 3, mute: true);
14659 Main.tile[num263, num264 - 1].CopyPaintAndCoating(Main.tile[num263, num264]);
14660 }
14661 }
14662 else if (Main.tile[num263, num264].type == 23 && Main.tile[num263, num264].nactive())
14663 {
14664 if (!Main.tile[num263, num264 - 1].active())
14665 {
14666 PlaceTile(num263, num264 - 1, 24, mute: true);
14667 }
14668 }
14669 else if (Main.tile[num263, num264].type == 199 && Main.tile[num263, num264].nactive())
14670 {
14671 if (!Main.tile[num263, num264 - 1].active())
14672 {
14673 PlaceTile(num263, num264 - 1, 201, mute: true);
14674 }
14675 }
14676 else if (Main.tile[num263, num264].type == 633 && Main.tile[num263, num264].nactive() && !Main.tile[num263, num264 - 1].active())
14677 {
14678 PlaceTile(num263, num264 - 1, 637, mute: true);
14679 }
14680 }
14681 }
14682 });
14683 AddGenerationPass("Glowing Mushrooms and Jungle Plants", delegate(GenerationProgress progress, GameConfiguration passConfig)
14684 {
14685 progress.Set(1.0);
14686 for (int num257 = 0; num257 < Main.maxTilesX; num257++)
14687 {
14688 for (int num258 = 0; num258 < Main.maxTilesY; num258++)
14689 {
14690 if (Main.tile[num257, num258].active())
14691 {
14692 if (num258 >= (int)Main.worldSurface && Main.tile[num257, num258].type == 70 && !Main.tile[num257, num258 - 1].active())
14693 {
14694 GrowTree(num257, num258);
14695 if (!Main.tile[num257, num258 - 1].active())
14696 {
14697 GrowTree(num257, num258);
14698 if (!Main.tile[num257, num258 - 1].active())
14699 {
14700 GrowTree(num257, num258);
14701 if (!Main.tile[num257, num258 - 1].active())
14702 {
14703 PlaceTile(num257, num258 - 1, 71, mute: true);
14704 }
14705 }
14706 }
14707 }
14708 if (Main.tile[num257, num258].type == 60 && !Main.tile[num257, num258 - 1].active())
14709 {
14710 PlaceTile(num257, num258 - 1, 61, mute: true);
14711 }
14712 }
14713 }
14714 }
14715 });
14716 AddGenerationPass("Jungle Plants", delegate(GenerationProgress progress, GameConfiguration passConfig)
14717 {
14718 progress.Set(1.0);
14719 for (int num254 = 0; num254 < Main.maxTilesX * 100; num254++)
14720 {
14721 int num255 = genRand.Next(40, Main.maxTilesX / 2 - 40);
14722 if (GenVars.dungeonSide < 0)
14723 {
14724 num255 += Main.maxTilesX / 2;
14725 }
14726 int num256;
14727 for (num256 = genRand.Next(Main.maxTilesY - 300); !Main.tile[num255, num256].active() && num256 < Main.maxTilesY - 300; num256++)
14728 {
14729 }
14730 if (Main.tile[num255, num256].active() && Main.tile[num255, num256].type == 60)
14731 {
14732 num256--;
14733 PlaceJunglePlant(num255, num256, 233, genRand.Next(8), 0);
14734 if (Main.tile[num255, num256].type != 233)
14735 {
14736 PlaceJunglePlant(num255, num256, 233, genRand.Next(12), 1);
14737 }
14738 }
14739 }
14740 });
14742 {
14743 progress.Message = Lang.gen[43].Value;
14744 for (int num233 = 5; num233 < Main.maxTilesX - 5; num233++)
14745 {
14746 progress.Set((double)num233 / (double)Main.maxTilesX);
14747 int num234 = 0;
14748 ushort type3 = 52;
14749 int num235 = (int)Main.worldSurface;
14750 if (remixWorldGen)
14751 {
14752 num235 = Main.maxTilesY - 200;
14753 }
14754 for (int num236 = 0; num236 < num235; num236++)
14755 {
14756 if (num234 > 0 && !Main.tile[num233, num236].active())
14757 {
14758 Main.tile[num233, num236].active(active: true);
14759 Main.tile[num233, num236].type = type3;
14760 Main.tile[num233, num236].CopyPaintAndCoating(Main.tile[num233, num236 - 1]);
14761 num234--;
14762 }
14763 else
14764 {
14765 num234 = 0;
14766 }
14767 if (Main.tile[num233, num236].active() && !Main.tile[num233, num236].bottomSlope() && (Main.tile[num233, num236].type == 2 || (Main.tile[num233, num236].type == 192 && genRand.Next(4) == 0)) && GrowMoreVines(num233, num236))
14768 {
14769 type3 = 52;
14770 if (Main.tile[num233, num236].wall == 68 || Main.tile[num233, num236].wall == 65 || Main.tile[num233, num236].wall == 66 || Main.tile[num233, num236].wall == 63)
14771 {
14772 type3 = 382;
14773 }
14774 else if (Main.tile[num233, num236 + 1].wall == 68 || Main.tile[num233, num236 + 1].wall == 65 || Main.tile[num233, num236 + 1].wall == 66 || Main.tile[num233, num236 + 1].wall == 63)
14775 {
14776 type3 = 382;
14777 }
14778 if (remixWorldGen && genRand.Next(5) == 0)
14779 {
14780 type3 = 382;
14781 }
14782 if (genRand.Next(5) < 3)
14783 {
14784 num234 = genRand.Next(1, 10);
14785 }
14786 }
14787 }
14788 num234 = 0;
14789 for (int num237 = 5; num237 < Main.maxTilesY - 5; num237++)
14790 {
14791 if (num234 > 0 && !Main.tile[num233, num237].active())
14792 {
14793 Main.tile[num233, num237].active(active: true);
14794 Main.tile[num233, num237].type = 62;
14795 num234--;
14796 }
14797 else
14798 {
14799 num234 = 0;
14800 }
14801 if (Main.tile[num233, num237].active() && Main.tile[num233, num237].type == 60 && !Main.tile[num233, num237].bottomSlope() && GrowMoreVines(num233, num237))
14802 {
14803 if (notTheBees && num237 < Main.maxTilesY - 10 && Main.tile[num233, num237 - 1].active() && !Main.tile[num233, num237 - 1].bottomSlope() && Main.tile[num233 + 1, num237 - 1].active() && !Main.tile[num233 + 1, num237 - 1].bottomSlope() && (Main.tile[num233, num237 - 1].type == 60 || Main.tile[num233, num237 - 1].type == 444 || Main.tile[num233, num237 - 1].type == 230))
14804 {
14805 bool flag5 = true;
14806 for (int num238 = num233; num238 < num233 + 2; num238++)
14807 {
14808 for (int num239 = num237 + 1; num239 < num237 + 3; num239++)
14809 {
14810 if (Main.tile[num238, num239].active() && (!Main.tileCut[Main.tile[num238, num239].type] || Main.tile[num238, num239].type == 444))
14811 {
14812 flag5 = false;
14813 break;
14814 }
14815 if (Main.tile[num238, num239].liquid > 0 || Main.wallHouse[Main.tile[num238, num239].wall])
14816 {
14817 flag5 = false;
14818 break;
14819 }
14820 }
14821 if (!flag5)
14822 {
14823 break;
14824 }
14825 }
14826 if (flag5 && CountNearBlocksTypes(num233, num237, genRand.Next(3, 10), 1, 444) > 0)
14827 {
14828 flag5 = false;
14829 }
14830 if (flag5)
14831 {
14832 for (int num240 = num233; num240 < num233 + 2; num240++)
14833 {
14834 for (int num241 = num237 + 1; num241 < num237 + 3; num241++)
14835 {
14836 KillTile(num240, num241);
14837 }
14838 }
14839 for (int num242 = num233; num242 < num233 + 2; num242++)
14840 {
14841 for (int num243 = num237 + 1; num243 < num237 + 3; num243++)
14842 {
14843 Main.tile[num242, num243].active(active: true);
14844 Main.tile[num242, num243].type = 444;
14845 Main.tile[num242, num243].frameX = (short)((num242 - num233) * 18);
14846 Main.tile[num242, num243].frameY = (short)((num243 - num237 - 1) * 18);
14847 }
14848 }
14849 continue;
14850 }
14851 }
14852 else if (num233 < Main.maxTilesX - 1 && num237 < Main.maxTilesY - 2 && Main.tile[num233 + 1, num237].active() && Main.tile[num233 + 1, num237].type == 60 && !Main.tile[num233 + 1, num237].bottomSlope() && genRand.Next(40) == 0)
14853 {
14854 bool flag6 = true;
14855 for (int num244 = num233; num244 < num233 + 2; num244++)
14856 {
14857 for (int num245 = num237 + 1; num245 < num237 + 3; num245++)
14858 {
14859 if (Main.tile[num244, num245].active() && (!Main.tileCut[Main.tile[num244, num245].type] || Main.tile[num244, num245].type == 444))
14860 {
14861 flag6 = false;
14862 break;
14863 }
14864 if (Main.tile[num244, num245].liquid > 0 || Main.wallHouse[Main.tile[num244, num245].wall])
14865 {
14866 flag6 = false;
14867 break;
14868 }
14869 }
14870 if (!flag6)
14871 {
14872 break;
14873 }
14874 }
14875 if (flag6 && CountNearBlocksTypes(num233, num237, 20, 1, 444) > 0)
14876 {
14877 flag6 = false;
14878 }
14879 if (flag6)
14880 {
14881 for (int num246 = num233; num246 < num233 + 2; num246++)
14882 {
14883 for (int num247 = num237 + 1; num247 < num237 + 3; num247++)
14884 {
14885 KillTile(num246, num247);
14886 }
14887 }
14888 for (int num248 = num233; num248 < num233 + 2; num248++)
14889 {
14890 for (int num249 = num237 + 1; num249 < num237 + 3; num249++)
14891 {
14892 Main.tile[num248, num249].active(active: true);
14893 Main.tile[num248, num249].type = 444;
14894 Main.tile[num248, num249].frameX = (short)((num248 - num233) * 18);
14895 Main.tile[num248, num249].frameY = (short)((num249 - num237 - 1) * 18);
14896 }
14897 }
14898 continue;
14899 }
14900 }
14901 if (genRand.Next(5) < 3)
14902 {
14903 num234 = genRand.Next(1, 10);
14904 }
14905 }
14906 }
14907 num234 = 0;
14908 for (int num250 = 0; num250 < Main.maxTilesY; num250++)
14909 {
14910 if (num234 > 0 && !Main.tile[num233, num250].active())
14911 {
14912 Main.tile[num233, num250].active(active: true);
14913 Main.tile[num233, num250].type = 528;
14914 num234--;
14915 }
14916 else
14917 {
14918 num234 = 0;
14919 }
14920 if (Main.tile[num233, num250].active() && Main.tile[num233, num250].type == 70 && genRand.Next(5) == 0 && !Main.tile[num233, num250].bottomSlope() && GrowMoreVines(num233, num250) && genRand.Next(5) < 3)
14921 {
14922 num234 = genRand.Next(1, 10);
14923 }
14924 }
14925 num234 = 0;
14926 for (int num251 = 0; num251 < Main.maxTilesY; num251++)
14927 {
14928 if (num234 > 0 && !Main.tile[num233, num251].active())
14929 {
14930 Main.tile[num233, num251].active(active: true);
14931 Main.tile[num233, num251].type = 636;
14932 num234--;
14933 }
14934 else
14935 {
14936 num234 = 0;
14937 }
14938 if (Main.tile[num233, num251].active() && !Main.tile[num233, num251].bottomSlope() && Main.tile[num233, num251].type == 23 && GrowMoreVines(num233, num251) && genRand.Next(5) < 3)
14939 {
14940 num234 = genRand.Next(1, 10);
14941 }
14942 }
14943 num234 = 0;
14944 for (int num252 = 0; num252 < Main.maxTilesY; num252++)
14945 {
14946 if (num234 > 0 && !Main.tile[num233, num252].active())
14947 {
14948 Main.tile[num233, num252].active(active: true);
14949 Main.tile[num233, num252].type = 205;
14950 num234--;
14951 }
14952 else
14953 {
14954 num234 = 0;
14955 }
14956 if (Main.tile[num233, num252].active() && !Main.tile[num233, num252].bottomSlope() && Main.tile[num233, num252].type == 199 && GrowMoreVines(num233, num252) && genRand.Next(5) < 3)
14957 {
14958 num234 = genRand.Next(1, 10);
14959 }
14960 }
14961 num234 = 0;
14962 for (int num253 = 0; num253 < Main.maxTilesY; num253++)
14963 {
14964 if (num234 > 0 && !Main.tile[num233, num253].active())
14965 {
14966 Main.tile[num233, num253].active(active: true);
14967 Main.tile[num233, num253].type = 638;
14968 num234--;
14969 }
14970 else
14971 {
14972 num234 = 0;
14973 }
14974 if (Main.tile[num233, num253].active() && !Main.tile[num233, num253].bottomSlope() && Main.tile[num233, num253].type == 633 && GrowMoreVines(num233, num253) && genRand.Next(5) < 3)
14975 {
14976 num234 = genRand.Next(1, 10);
14977 }
14978 }
14979 }
14980 });
14981 AddGenerationPass("Flowers", delegate(GenerationProgress progress, GameConfiguration passConfig)
14982 {
14983 progress.Message = Lang.gen[44].Value;
14984 int num220 = (int)((double)Main.maxTilesX * 0.004);
14985 if (remixWorldGen)
14986 {
14987 num220 *= 6;
14988 }
14989 for (int num221 = 0; num221 < num220; num221++)
14990 {
14991 progress.Set((double)num221 / (double)num220);
14992 int num222 = genRand.Next(100, Main.maxTilesX - 100);
14993 int num223 = genRand.Next(15, 30);
14994 int num224 = genRand.Next(15, 30);
14995 if (remixWorldGen)
14996 {
14997 num223 = genRand.Next(15, 45);
14998 num224 = genRand.Next(15, 45);
14999 int num225 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 350);
15000 if (GenVars.logX >= 0)
15001 {
15004 GenVars.logX = -1;
15005 }
15006 int num226 = genRand.NextFromList<int>(21, 24, 27, 30, 33, 36, 39, 42);
15007 for (int num227 = num222 - num223; num227 < num222 + num223; num227++)
15008 {
15009 for (int num228 = num225 - num224; num228 < num225 + num224; num228++)
15010 {
15011 if (Main.tile[num227, num228].type != 488 && !Main.tileSolid[Main.tile[num227, num228].type])
15012 {
15013 if (Main.tile[num227, num228].type == 3)
15014 {
15015 Main.tile[num227, num228].frameX = (short)((num226 + genRand.Next(3)) * 18);
15016 if (genRand.Next(3) != 0)
15017 {
15018 Main.tile[num227, num228].type = 73;
15019 }
15020 }
15021 else if (Main.tile[num227, num228 + 1].wall == 0 && (Main.tile[num227, num228 + 1].type == 2 || ((Main.tile[num227, num228 + 1].type == 40 || Main.tile[num227, num228 + 1].type == 1 || TileID.Sets.Ore[Main.tile[num227, num228 + 1].type]) && !Main.tile[num227, num228].active())) && (!Main.tile[num227, num228].active() || Main.tile[num227, num228].type == 185 || Main.tile[num227, num228].type == 186 || Main.tile[num227, num228].type == 187 || (Main.tile[num227, num228].type == 5 && (double)num227 < (double)Main.maxTilesX * 0.48) || (double)num227 > (double)Main.maxTilesX * 0.52))
15022 {
15023 if (Main.tile[num227, num228 + 1].type == 40 || Main.tile[num227, num228 + 1].type == 1 || TileID.Sets.Ore[Main.tile[num227, num228 + 1].type])
15024 {
15025 Main.tile[num227, num228 + 1].type = 2;
15026 if (Main.tile[num227, num228 + 2].type == 40 || Main.tile[num227, num228 + 2].type == 1 || TileID.Sets.Ore[Main.tile[num227, num228 + 2].type])
15027 {
15028 Main.tile[num227, num228 + 2].type = 2;
15029 }
15030 }
15031 KillTile(num227, num228);
15032 if (genRand.Next(2) == 0)
15033 {
15034 Main.tile[num227, num228 + 1].slope(0);
15035 Main.tile[num227, num228 + 1].halfBrick(halfBrick: false);
15036 }
15037 PlaceTile(num227, num228, 3);
15038 if (Main.tile[num227, num228].active() && Main.tile[num227, num228].type == 3)
15039 {
15040 Main.tile[num227, num228].frameX = (short)((num226 + genRand.Next(3)) * 18);
15041 if (genRand.Next(3) != 0)
15042 {
15043 Main.tile[num227, num228].type = 73;
15044 }
15045 }
15046 if (Main.tile[num227, num228 + 2].type == 40 || Main.tile[num227, num228 + 2].type == 1 || TileID.Sets.Ore[Main.tile[num227, num228 + 2].type])
15047 {
15048 Main.tile[num227, num228 + 2].type = 0;
15049 }
15050 }
15051 }
15052 }
15053 }
15054 }
15055 else
15056 {
15057 for (int num229 = num224; (double)num229 < Main.worldSurface - (double)num224 - 1.0; num229++)
15058 {
15059 if (Main.tile[num222, num229].active())
15060 {
15061 if (GenVars.logX >= 0)
15062 {
15065 GenVars.logX = -1;
15066 }
15067 int num230 = genRand.NextFromList<int>(21, 24, 27, 30, 33, 36, 39, 42);
15068 for (int num231 = num222 - num223; num231 < num222 + num223; num231++)
15069 {
15070 for (int num232 = num229 - num224; num232 < num229 + num224; num232++)
15071 {
15072 if (Main.tile[num231, num232].type != 488 && !Main.tileSolid[Main.tile[num231, num232].type])
15073 {
15074 if (Main.tile[num231, num232].type == 3)
15075 {
15076 Main.tile[num231, num232].frameX = (short)((num230 + genRand.Next(3)) * 18);
15077 if (genRand.Next(3) != 0)
15078 {
15079 Main.tile[num231, num232].type = 73;
15080 }
15081 }
15082 else if (Main.tile[num231, num232 + 1].wall == 0 && (Main.tile[num231, num232 + 1].type == 2 || ((Main.tile[num231, num232 + 1].type == 40 || Main.tile[num231, num232 + 1].type == 1 || TileID.Sets.Ore[Main.tile[num231, num232 + 1].type]) && !Main.tile[num231, num232].active())) && (!Main.tile[num231, num232].active() || Main.tile[num231, num232].type == 185 || Main.tile[num231, num232].type == 186 || Main.tile[num231, num232].type == 187 || (Main.tile[num231, num232].type == 5 && (double)num231 < (double)Main.maxTilesX * 0.48) || (double)num231 > (double)Main.maxTilesX * 0.52))
15083 {
15084 if (Main.tile[num231, num232 + 1].type == 40 || Main.tile[num231, num232 + 1].type == 1 || TileID.Sets.Ore[Main.tile[num231, num232 + 1].type])
15085 {
15086 Main.tile[num231, num232 + 1].type = 2;
15087 if (Main.tile[num231, num232 + 2].type == 40 || Main.tile[num231, num232 + 2].type == 1 || TileID.Sets.Ore[Main.tile[num231, num232 + 2].type])
15088 {
15089 Main.tile[num231, num232 + 2].type = 2;
15090 }
15091 }
15092 KillTile(num231, num232);
15093 if (genRand.Next(2) == 0)
15094 {
15095 Main.tile[num231, num232 + 1].slope(0);
15096 Main.tile[num231, num232 + 1].halfBrick(halfBrick: false);
15097 }
15098 PlaceTile(num231, num232, 3);
15099 if (Main.tile[num231, num232].active() && Main.tile[num231, num232].type == 3)
15100 {
15101 Main.tile[num231, num232].frameX = (short)((num230 + genRand.Next(3)) * 18);
15102 if (genRand.Next(3) != 0)
15103 {
15104 Main.tile[num231, num232].type = 73;
15105 }
15106 }
15107 if (Main.tile[num231, num232 + 2].type == 40 || Main.tile[num231, num232 + 2].type == 1 || TileID.Sets.Ore[Main.tile[num231, num232 + 2].type])
15108 {
15109 Main.tile[num231, num232 + 2].type = 0;
15110 }
15111 }
15112 }
15113 }
15114 }
15115 break;
15116 }
15117 }
15118 }
15119 }
15120 });
15121 AddGenerationPass("Mushrooms", delegate(GenerationProgress progress, GameConfiguration passConfig)
15122 {
15123 progress.Message = Lang.gen[45].Value;
15124 int num209 = (int)((double)Main.maxTilesX * 0.002);
15125 if (remixWorldGen)
15126 {
15127 num209 *= 9;
15128 }
15129 for (int num210 = 0; num210 < num209; num210++)
15130 {
15131 progress.Set((double)num210 / (double)num209);
15132 int num211 = genRand.Next(20, Main.maxTilesX - 20);
15133 int num212 = genRand.Next(4, 10);
15134 int num213 = genRand.Next(15, 30);
15135 if (remixWorldGen)
15136 {
15137 num212 = genRand.Next(8, 17);
15138 num213 = genRand.Next(8, 17);
15139 int num214 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 350);
15140 if (Main.tile[num211, num214].active())
15141 {
15142 for (int num215 = num211 - num212; num215 < num211 + num212; num215++)
15143 {
15144 for (int num216 = num214 - num213; num216 < num214 + num213; num216++)
15145 {
15146 if (num215 < 10)
15147 {
15148 break;
15149 }
15150 if (num216 < 0)
15151 {
15152 break;
15153 }
15154 if (num215 > Main.maxTilesX - 10)
15155 {
15156 break;
15157 }
15158 if (num216 > Main.maxTilesY - 10)
15159 {
15160 break;
15161 }
15162 if (Main.tile[num215, num216].type == 3 || Main.tile[num215, num216].type == 24)
15163 {
15164 Main.tile[num215, num216].frameX = 144;
15165 }
15166 else if (Main.tile[num215, num216].type == 201)
15167 {
15168 Main.tile[num215, num216].frameX = 270;
15169 }
15170 }
15171 }
15172 }
15173 }
15174 else
15175 {
15176 for (int num217 = 1; (double)num217 < Main.worldSurface - 1.0; num217++)
15177 {
15178 if (Main.tile[num211, num217].active())
15179 {
15180 for (int num218 = num211 - num212; num218 < num211 + num212; num218++)
15181 {
15182 for (int num219 = num217 - num213; num219 < num217 + num213; num219++)
15183 {
15184 if (num218 < 10)
15185 {
15186 break;
15187 }
15188 if (num219 < 0)
15189 {
15190 break;
15191 }
15192 if (num218 > Main.maxTilesX - 10)
15193 {
15194 break;
15195 }
15196 if (num219 > Main.maxTilesY - 10)
15197 {
15198 break;
15199 }
15200 if (Main.tile[num218, num219].type == 3 || Main.tile[num218, num219].type == 24)
15201 {
15202 Main.tile[num218, num219].frameX = 144;
15203 }
15204 else if (Main.tile[num218, num219].type == 201)
15205 {
15206 Main.tile[num218, num219].frameX = 270;
15207 }
15208 }
15209 }
15210 break;
15211 }
15212 }
15213 }
15214 }
15215 });
15216 AddGenerationPass("Gems In Ice Biome", delegate(GenerationProgress progress, GameConfiguration passConfig)
15217 {
15218 progress.Set(1.0);
15219 for (int num198 = 0; (double)num198 < (double)Main.maxTilesX * 0.25; num198++)
15220 {
15221 int num199 = ((!remixWorldGen) ? genRand.Next((int)(Main.worldSurface + Main.rockLayer) / 2, GenVars.lavaLine) : genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300));
15222 int num200 = genRand.Next(GenVars.snowMinX[num199], GenVars.snowMaxX[num199]);
15223 if (Main.tile[num200, num199].active() && (Main.tile[num200, num199].type == 147 || Main.tile[num200, num199].type == 161 || Main.tile[num200, num199].type == 162 || Main.tile[num200, num199].type == 224))
15224 {
15225 int num201 = genRand.Next(1, 4);
15226 int num202 = genRand.Next(1, 4);
15227 int num203 = genRand.Next(1, 4);
15228 int num204 = genRand.Next(1, 4);
15229 int num205 = genRand.Next(12);
15230 int num206 = 0;
15231 num206 = ((num205 >= 3) ? ((num205 < 6) ? 1 : ((num205 < 8) ? 2 : ((num205 < 10) ? 3 : ((num205 >= 11) ? 5 : 4)))) : 0);
15232 for (int num207 = num200 - num201; num207 < num200 + num202; num207++)
15233 {
15234 for (int num208 = num199 - num203; num208 < num199 + num204; num208++)
15235 {
15236 if (!Main.tile[num207, num208].active())
15237 {
15238 PlaceTile(num207, num208, 178, mute: true, forced: false, -1, num206);
15239 }
15240 }
15241 }
15242 }
15243 }
15244 });
15245 AddGenerationPass("Random Gems", delegate(GenerationProgress progress, GameConfiguration passConfig)
15246 {
15247 progress.Set(1.0);
15248 for (int num184 = 0; num184 < Main.maxTilesX; num184++)
15249 {
15250 int num185 = genRand.Next(20, Main.maxTilesX - 20);
15251 int num186 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 300);
15252 if (!Main.tile[num185, num186].active() && !Main.tile[num185, num186].lava() && !Main.wallDungeon[Main.tile[num185, num186].wall] && Main.tile[num185, num186].wall != 27)
15253 {
15254 int num187 = genRand.Next(12);
15255 int num188 = 0;
15256 num188 = ((num187 >= 3) ? ((num187 < 6) ? 1 : ((num187 < 8) ? 2 : ((num187 < 10) ? 3 : ((num187 >= 11) ? 5 : 4)))) : 0);
15257 PlaceTile(num185, num186, 178, mute: true, forced: false, -1, num188);
15258 }
15259 }
15260 for (int num189 = 0; num189 < Main.maxTilesX; num189++)
15261 {
15262 int num190 = genRand.Next(20, Main.maxTilesX - 20);
15263 int num191 = genRand.Next((int)Main.worldSurface, Main.maxTilesY - 300);
15264 if (!Main.tile[num190, num191].active() && !Main.tile[num190, num191].lava() && (Main.tile[num190, num191].wall == 216 || Main.tile[num190, num191].wall == 187))
15265 {
15266 int num192 = genRand.Next(1, 4);
15267 int num193 = genRand.Next(1, 4);
15268 int num194 = genRand.Next(1, 4);
15269 int num195 = genRand.Next(1, 4);
15270 for (int num196 = num190 - num192; num196 < num190 + num193; num196++)
15271 {
15272 for (int num197 = num191 - num194; num197 < num191 + num195; num197++)
15273 {
15274 if (!Main.tile[num196, num197].active())
15275 {
15276 PlaceTile(num196, num197, 178, mute: true, forced: false, -1, 6);
15277 }
15278 }
15279 }
15280 }
15281 }
15282 });
15283 AddGenerationPass("Moss Grass", delegate(GenerationProgress progress, GameConfiguration passConfig)
15284 {
15285 progress.Set(1.0);
15286 for (int num179 = 5; num179 < Main.maxTilesX - 5; num179++)
15287 {
15288 for (int num180 = 5; num180 < Main.maxTilesY - 5; num180++)
15289 {
15290 if (Main.tile[num179, num180].active() && Main.tileMoss[Main.tile[num179, num180].type])
15291 {
15292 for (int num181 = 0; num181 < 4; num181++)
15293 {
15294 int num182 = num179;
15295 int num183 = num180;
15296 if (num181 == 0)
15297 {
15298 num182--;
15299 }
15300 if (num181 == 1)
15301 {
15302 num182++;
15303 }
15304 if (num181 == 2)
15305 {
15306 num183--;
15307 }
15308 if (num181 == 3)
15309 {
15310 num183++;
15311 }
15312 if (!Main.tile[num182, num183].active())
15313 {
15314 PlaceTile(num182, num183, 184, mute: true);
15315 }
15316 }
15317 }
15318 }
15319 }
15320 });
15321 AddGenerationPass("Muds Walls In Jungle", delegate(GenerationProgress progress, GameConfiguration passConfig)
15322 {
15323 progress.Set(1.0);
15324 int num171 = 0;
15325 int num172 = 0;
15326 bool flag4 = false;
15327 for (int num173 = 5; num173 < Main.maxTilesX - 5; num173++)
15328 {
15329 for (int num174 = 0; (double)num174 < Main.worldSurface + 20.0; num174++)
15330 {
15331 if (Main.tile[num173, num174].active() && Main.tile[num173, num174].type == 60)
15332 {
15333 num171 = num173;
15334 flag4 = true;
15335 break;
15336 }
15337 }
15338 if (flag4)
15339 {
15340 break;
15341 }
15342 }
15343 flag4 = false;
15344 for (int num175 = Main.maxTilesX - 5; num175 > 5; num175--)
15345 {
15346 for (int num176 = 0; (double)num176 < Main.worldSurface + 20.0; num176++)
15347 {
15348 if (Main.tile[num175, num176].active() && Main.tile[num175, num176].type == 60)
15349 {
15350 num172 = num175;
15351 flag4 = true;
15352 break;
15353 }
15354 }
15355 if (flag4)
15356 {
15357 break;
15358 }
15359 }
15360 GenVars.jungleMinX = num171;
15361 GenVars.jungleMaxX = num172;
15362 for (int num177 = num171; num177 <= num172; num177++)
15363 {
15364 for (int num178 = 0; (double)num178 < Main.worldSurface + 20.0; num178++)
15365 {
15366 if (((num177 >= num171 + 2 && num177 <= num172 - 2) || genRand.Next(2) != 0) && ((num177 >= num171 + 3 && num177 <= num172 - 3) || genRand.Next(3) != 0) && (Main.tile[num177, num178].wall == 2 || Main.tile[num177, num178].wall == 59))
15367 {
15368 Main.tile[num177, num178].wall = 15;
15369 }
15370 }
15371 }
15372 });
15374 {
15375 Main.tileSolid[229] = true;
15376 progress.Set(1.0);
15377 for (int num166 = 0; num166 < GenVars.numLarva; num166++)
15378 {
15379 int num167 = GenVars.larvaX[num166];
15380 int num168 = GenVars.larvaY[num166];
15381 for (int num169 = num167 - 1; num169 <= num167 + 1; num169++)
15382 {
15383 for (int num170 = num168 - 2; num170 <= num168 + 1; num170++)
15384 {
15385 if (num170 != num168 + 1)
15386 {
15387 Main.tile[num169, num170].active(active: false);
15388 }
15389 else
15390 {
15391 Main.tile[num169, num170].active(active: true);
15392 Main.tile[num169, num170].type = 225;
15393 Main.tile[num169, num170].slope(0);
15394 Main.tile[num169, num170].halfBrick(halfBrick: false);
15395 }
15396 }
15397 }
15398 PlaceTile(num167, num168, 231, mute: true);
15399 }
15400 Main.tileSolid[232] = true;
15401 Main.tileSolid[162] = true;
15402 });
15403 AddGenerationPass("Settle Liquids Again", delegate(GenerationProgress progress, GameConfiguration passConfig)
15404 {
15405 if (getGoodWorldGen)
15406 {
15407 Main.tileSolid[56] = true;
15408 }
15409 progress.Message = Lang.gen[27].Value;
15410 if (notTheBees)
15411 {
15412 NotTheBees();
15413 }
15414 Liquid.worldGenTilesIgnoreWater(ignoreSolids: true);
15415 Liquid.QuickWater(3);
15416 WaterCheck();
15417 int num160 = 0;
15418 Liquid.quickSettle = true;
15419 int num161 = 10;
15420 while (num160 < num161)
15421 {
15422 int num162 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
15423 num160++;
15424 double num163 = 0.0;
15425 int num164 = num162 * 5;
15426 while (Liquid.numLiquid > 0)
15427 {
15428 num164--;
15429 if (num164 < 0)
15430 {
15431 break;
15432 }
15433 double num165 = (double)(num162 - (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer)) / (double)num162;
15434 if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > num162)
15435 {
15436 num162 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
15437 }
15438 if (num165 > num163)
15439 {
15440 num163 = num165;
15441 }
15442 else
15443 {
15444 num165 = num163;
15445 }
15446 if (num160 == 1)
15447 {
15448 progress.Set(num165 / 3.0 + 0.33);
15449 }
15450 Liquid.UpdateLiquid();
15451 }
15452 WaterCheck();
15453 progress.Set((double)num160 / (double)num161 / 3.0 + 0.66);
15454 }
15455 Liquid.quickSettle = false;
15456 Liquid.worldGenTilesIgnoreWater(ignoreSolids: false);
15457 Main.tileSolid[484] = false;
15458 });
15459 AddGenerationPass("Cactus, Palm Trees, & Coral", delegate(GenerationProgress progress, GameConfiguration passConfig)
15460 {
15461 progress.Message = Lang.gen[38].Value;
15462 int num132 = 8;
15463 if (remixWorldGen)
15464 {
15465 num132 = 2;
15466 }
15467 int num133 = 400;
15468 int num134 = genRand.Next(3, 13);
15469 int num135 = genRand.Next(3, 13);
15470 int num136 = genRand.Next(2, 6);
15471 int num137 = genRand.Next(2, 6);
15472 int num138 = 380;
15473 for (int num139 = 0; num139 < GenVars.numOasis; num139++)
15474 {
15475 int num140 = (int)((double)GenVars.oasisWidth[num139] * 1.5);
15477 {
15479 {
15480 double num143 = 1.0;
15481 int num144 = 8;
15482 for (int num145 = num141 - num144; num145 <= num141 + num144; num145++)
15483 {
15484 for (int num146 = num142 - num144; num146 <= num142 + num144; num146++)
15485 {
15486 if (InWorld(num145, num146) && Main.tile[num145, num146] != null && Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 323)
15487 {
15488 num143 = 0.13;
15489 }
15490 }
15491 }
15492 if (genRand.NextDouble() < num143)
15493 {
15494 GrowPalmTree(num141, num142);
15495 }
15496 if (PlantSeaOat(num141, num142))
15497 {
15498 if (genRand.Next(2) == 0)
15499 {
15500 GrowSeaOat(num141, num142);
15501 }
15502 if (genRand.Next(2) == 0)
15503 {
15504 GrowSeaOat(num141, num142);
15505 }
15506 }
15507 PlaceOasisPlant(num141, num142, 530);
15508 }
15509 }
15510 }
15511 for (int num147 = 0; num147 < 3; num147++)
15512 {
15513 progress.Set((double)num147 / 3.0);
15514 int num148;
15515 int num149;
15516 bool flag3;
15517 int maxValue4;
15518 switch (num147)
15519 {
15520 default:
15521 num148 = 5;
15522 num149 = num138;
15523 flag3 = false;
15524 maxValue4 = num134;
15525 break;
15526 case 1:
15527 num148 = num133;
15528 num149 = Main.maxTilesX - num133;
15529 flag3 = true;
15530 maxValue4 = num132;
15531 break;
15532 case 2:
15533 num148 = Main.maxTilesX - num138;
15534 num149 = Main.maxTilesX - 5;
15535 flag3 = false;
15536 maxValue4 = num135;
15537 break;
15538 }
15539 double num150 = Main.worldSurface - 1.0;
15540 if (remixWorldGen)
15541 {
15542 num150 = Main.maxTilesY - 50;
15543 }
15544 for (int num151 = num148; num151 < num149; num151++)
15545 {
15546 if (genRand.Next(maxValue4) == 0)
15547 {
15548 for (int num152 = 0; (double)num152 < num150; num152++)
15549 {
15551 if (tile4.active() && (tile4.type == 53 || tile4.type == 112 || tile4.type == 234))
15552 {
15553 Tile tile5 = Main.tile[num151, num152 - 1];
15554 if (!tile5.active() && tile5.wall == 0)
15555 {
15556 if (flag3)
15557 {
15558 if (remixWorldGen)
15559 {
15560 if ((double)num152 > Main.worldSurface)
15561 {
15562 if (SolidTile(num151, num152) && Main.tile[num151, num152 + 1].type == 53 && Main.tile[num151, num152 + 2].type == 53)
15563 {
15564 int maxValue5 = 3;
15565 GrowPalmTree(num151, num152);
15566 if (!Main.tile[num151, num152 - 1].active() && genRand.Next(maxValue5) == 0)
15567 {
15568 PlantCactus(num151, num152);
15569 }
15570 }
15571 }
15572 else
15573 {
15574 int num153 = 0;
15575 for (int num154 = num151 - cactusWaterWidth; num154 < num151 + cactusWaterWidth; num154++)
15576 {
15577 for (int num155 = num152 - cactusWaterHeight; num155 < num152 + cactusWaterHeight; num155++)
15578 {
15579 num153 += Main.tile[num154, num155].liquid;
15580 }
15581 }
15582 if (num153 / 255 > cactusWaterLimit)
15583 {
15584 int maxValue6 = 4;
15585 if (genRand.Next(maxValue6) == 0)
15586 {
15587 GrowPalmTree(num151, num152);
15588 }
15589 }
15590 else
15591 {
15592 PlantCactus(num151, num152);
15593 }
15594 }
15595 }
15596 else
15597 {
15598 int num156 = 0;
15599 for (int num157 = num151 - cactusWaterWidth; num157 < num151 + cactusWaterWidth; num157++)
15600 {
15601 for (int num158 = num152 - cactusWaterHeight; num158 < num152 + cactusWaterHeight; num158++)
15602 {
15603 num156 += Main.tile[num157, num158].liquid;
15604 }
15605 }
15606 if (num156 / 255 > cactusWaterLimit)
15607 {
15608 int maxValue7 = 4;
15609 if (genRand.Next(maxValue7) == 0)
15610 {
15611 GrowPalmTree(num151, num152);
15612 }
15613 }
15614 else
15615 {
15616 PlantCactus(num151, num152);
15617 }
15618 }
15619 }
15620 else
15621 {
15622 if (Main.tile[num151, num152 - 2].liquid == byte.MaxValue && Main.tile[num151, num152 - 3].liquid == byte.MaxValue && Main.tile[num151, num152 - 4].liquid == byte.MaxValue)
15623 {
15624 if (genRand.Next(2) == 0)
15625 {
15626 PlaceTile(num151, num152 - 1, 81, mute: true);
15627 }
15628 else
15629 {
15630 PlaceTile(num151, num152 - 1, 324, mute: true, forced: false, -1, RollRandomSeaShellStyle());
15631 }
15632 break;
15633 }
15634 if (Main.tile[num151, num152 - 2].liquid == 0 && (double)num152 < Main.worldSurface)
15635 {
15636 PlaceTile(num151, num152 - 1, 324, mute: true, forced: false, -1, RollRandomSeaShellStyle());
15637 break;
15638 }
15639 }
15640 }
15641 }
15642 }
15643 }
15644 else
15645 {
15646 for (int num159 = 0; (double)num159 < num150; num159++)
15647 {
15648 if (PlantSeaOat(num151, num159))
15649 {
15650 if (genRand.Next(2) == 0)
15651 {
15652 GrowSeaOat(num151, num159);
15653 }
15654 if (genRand.Next(2) == 0)
15655 {
15656 GrowSeaOat(num151, num159);
15657 }
15658 }
15659 PlaceOasisPlant(num151, num159, 530);
15660 }
15661 }
15662 }
15663 }
15664 });
15665 AddGenerationPass("Tile Cleanup", delegate(GenerationProgress progress, GameConfiguration passConfig)
15666 {
15667 progress.Message = Lang.gen[84].Value;
15668 for (int num64 = 40; num64 < Main.maxTilesX - 40; num64++)
15669 {
15670 progress.Set((double)(num64 - 40) / (double)(Main.maxTilesX - 80));
15671 for (int num65 = 40; num65 < Main.maxTilesY - 40; num65++)
15672 {
15673 if (Main.tile[num64, num65].active() && Main.tile[num64, num65].topSlope() && ((Main.tile[num64, num65].leftSlope() && Main.tile[num64 + 1, num65].halfBrick()) || (Main.tile[num64, num65].rightSlope() && Main.tile[num64 - 1, num65].halfBrick())))
15674 {
15675 Main.tile[num64, num65].slope(0);
15676 Main.tile[num64, num65].halfBrick(halfBrick: true);
15677 }
15678 if (Main.tile[num64, num65].active() && Main.tile[num64, num65].liquid > 0 && TileID.Sets.SlowlyDiesInWater[Main.tile[num64, num65].type])
15679 {
15680 KillTile(num64, num65);
15681 }
15682 if (!Main.tile[num64, num65].active() && Main.tile[num64, num65].liquid == 0 && genRand.Next(3) != 0 && SolidTile(num64, num65 - 1))
15683 {
15684 int num66 = genRand.Next(15, 21);
15685 for (int num67 = num65 - 2; num67 >= num65 - num66; num67--)
15686 {
15687 if (Main.tile[num64, num67].liquid >= 128 && !Main.tile[num64, num67].shimmer())
15688 {
15689 int num68 = 373;
15690 if (Main.tile[num64, num67].lava())
15691 {
15692 num68 = 374;
15693 }
15694 else if (Main.tile[num64, num67].honey())
15695 {
15696 num68 = 375;
15697 }
15698 int maxValue3 = num65 - num67;
15699 if (genRand.Next(maxValue3) <= 1)
15700 {
15701 if (Main.tile[num64, num65].wall == 86)
15702 {
15703 num68 = 375;
15704 }
15705 Main.tile[num64, num65].type = (ushort)num68;
15706 Main.tile[num64, num65].frameX = 0;
15707 Main.tile[num64, num65].frameY = 0;
15708 Main.tile[num64, num65].active(active: true);
15709 break;
15710 }
15711 }
15712 }
15713 if (!Main.tile[num64, num65].active())
15714 {
15715 num66 = genRand.Next(3, 11);
15716 for (int num69 = num65 + 1; num69 <= num65 + num66; num69++)
15717 {
15718 if (Main.tile[num64, num69].liquid >= 200 && !Main.tile[num64, num69].shimmer())
15719 {
15720 int num70 = 373;
15721 if (Main.tile[num64, num69].lava())
15722 {
15723 num70 = 374;
15724 }
15725 else if (Main.tile[num64, num69].honey())
15726 {
15727 num70 = 375;
15728 }
15729 int num71 = num69 - num65;
15730 if (genRand.Next(num71 * 3) <= 1)
15731 {
15732 Main.tile[num64, num65].type = (ushort)num70;
15733 Main.tile[num64, num65].frameX = 0;
15734 Main.tile[num64, num65].frameY = 0;
15735 Main.tile[num64, num65].active(active: true);
15736 break;
15737 }
15738 }
15739 }
15740 }
15741 if (!Main.tile[num64, num65].active() && genRand.Next(4) == 0)
15742 {
15743 Tile tile3 = Main.tile[num64, num65 - 1];
15745 {
15746 Main.tile[num64, num65].type = 461;
15747 Main.tile[num64, num65].frameX = 0;
15748 Main.tile[num64, num65].frameY = 0;
15749 Main.tile[num64, num65].active(active: true);
15750 }
15751 }
15752 }
15753 if (Main.tile[num64, num65].type == 137)
15754 {
15755 int num72 = Main.tile[num64, num65].frameY / 18;
15756 if (num72 <= 2 || num72 == 5)
15757 {
15758 int num73 = -1;
15759 if (Main.tile[num64, num65].frameX >= 18)
15760 {
15761 num73 = 1;
15762 }
15763 if (Main.tile[num64 + num73, num65].halfBrick() || Main.tile[num64 + num73, num65].slope() != 0)
15764 {
15765 Main.tile[num64 + num73, num65].active(active: false);
15766 }
15767 }
15768 }
15769 else if (Main.tile[num64, num65].type == 162 && Main.tile[num64, num65 + 1].liquid == 0 && CanKillTile(num64, num65))
15770 {
15771 Main.tile[num64, num65].active(active: false);
15772 }
15773 if (Main.tile[num64, num65].wall == 13 || Main.tile[num64, num65].wall == 14)
15774 {
15775 Main.tile[num64, num65].liquid = 0;
15776 }
15777 if (Main.tile[num64, num65].type == 31)
15778 {
15779 int num74 = Main.tile[num64, num65].frameX / 18;
15780 int num75 = 0;
15781 int num76 = num64;
15782 num75 += num74 / 2;
15783 num75 = ((!drunkWorldGen) ? (crimson ? 1 : 0) : ((Main.tile[num64, num65].wall == 83) ? 1 : 0));
15784 num74 %= 2;
15785 num76 -= num74;
15786 int num77 = Main.tile[num64, num65].frameY / 18;
15787 int num78 = 0;
15788 int num79 = num65;
15789 num78 += num77 / 2;
15790 num77 %= 2;
15791 num79 -= num77;
15792 for (int num80 = 0; num80 < 2; num80++)
15793 {
15794 for (int num81 = 0; num81 < 2; num81++)
15795 {
15796 int num82 = num76 + num80;
15797 int num83 = num79 + num81;
15798 Main.tile[num82, num83].active(active: true);
15799 Main.tile[num82, num83].slope(0);
15800 Main.tile[num82, num83].halfBrick(halfBrick: false);
15801 Main.tile[num82, num83].type = 31;
15802 Main.tile[num82, num83].frameX = (short)(num80 * 18 + 36 * num75);
15803 Main.tile[num82, num83].frameY = (short)(num81 * 18 + 36 * num78);
15804 }
15805 }
15806 }
15807 if (Main.tile[num64, num65].type == 12)
15808 {
15809 int num84 = Main.tile[num64, num65].frameX / 18;
15810 int num85 = 0;
15811 int num86 = num64;
15812 num85 += num84 / 2;
15813 num84 %= 2;
15814 num86 -= num84;
15815 int num87 = Main.tile[num64, num65].frameY / 18;
15816 int num88 = 0;
15817 int num89 = num65;
15818 num88 += num87 / 2;
15819 num87 %= 2;
15820 num89 -= num87;
15821 for (int num90 = 0; num90 < 2; num90++)
15822 {
15823 for (int num91 = 0; num91 < 2; num91++)
15824 {
15825 int num92 = num86 + num90;
15826 int num93 = num89 + num91;
15827 Main.tile[num92, num93].active(active: true);
15828 Main.tile[num92, num93].slope(0);
15829 Main.tile[num92, num93].halfBrick(halfBrick: false);
15830 Main.tile[num92, num93].type = 12;
15831 Main.tile[num92, num93].frameX = (short)(num90 * 18 + 36 * num85);
15832 Main.tile[num92, num93].frameY = (short)(num91 * 18 + 36 * num88);
15833 }
15834 if (!Main.tile[num90, num65 + 2].active())
15835 {
15836 Main.tile[num90, num65 + 2].active(active: true);
15837 if (!Main.tileSolid[Main.tile[num90, num65 + 2].type] || Main.tileSolidTop[Main.tile[num90, num65 + 2].type])
15838 {
15839 Main.tile[num90, num65 + 2].type = 0;
15840 }
15841 }
15842 Main.tile[num90, num65 + 2].slope(0);
15843 Main.tile[num90, num65 + 2].halfBrick(halfBrick: false);
15844 }
15845 }
15846 if (Main.tile[num64, num65].type == 639)
15847 {
15848 int num94 = Main.tile[num64, num65].frameX / 18;
15849 int num95 = 0;
15850 int num96 = num64;
15851 num95 += num94 / 2;
15852 num94 %= 2;
15853 num96 -= num94;
15854 int num97 = Main.tile[num64, num65].frameY / 18;
15855 int num98 = 0;
15856 int num99 = num65;
15857 num98 += num97 / 2;
15858 num97 %= 2;
15859 num99 -= num97;
15860 for (int num100 = 0; num100 < 2; num100++)
15861 {
15862 for (int num101 = 0; num101 < 2; num101++)
15863 {
15864 int num102 = num96 + num100;
15865 int num103 = num99 + num101;
15866 Main.tile[num102, num103].active(active: true);
15867 Main.tile[num102, num103].slope(0);
15868 Main.tile[num102, num103].halfBrick(halfBrick: false);
15869 Main.tile[num102, num103].type = 639;
15870 Main.tile[num102, num103].frameX = (short)(num100 * 18 + 36 * num95);
15871 Main.tile[num102, num103].frameY = (short)(num101 * 18 + 36 * num98);
15872 }
15873 if (!Main.tile[num100, num65 + 2].active())
15874 {
15875 Main.tile[num100, num65 + 2].active(active: true);
15876 if (!Main.tileSolid[Main.tile[num100, num65 + 2].type] || Main.tileSolidTop[Main.tile[num100, num65 + 2].type])
15877 {
15878 Main.tile[num100, num65 + 2].type = 0;
15879 }
15880 }
15881 Main.tile[num100, num65 + 2].slope(0);
15882 Main.tile[num100, num65 + 2].halfBrick(halfBrick: false);
15883 }
15884 }
15886 {
15887 int num104 = Main.tile[num64, num65].frameX / 18;
15888 int num105 = 0;
15889 ushort type2 = 21;
15890 int num106 = num64;
15891 int num107 = num65 - Main.tile[num64, num65].frameY / 18;
15892 if (Main.tile[num64, num65].type == 467)
15893 {
15894 type2 = 467;
15895 }
15896 while (num104 >= 2)
15897 {
15898 num105++;
15899 num104 -= 2;
15900 }
15901 num106 -= num104;
15903 if (num108 != -1)
15904 {
15905 switch (Main.chest[num108].item[0].type)
15906 {
15907 case 1156:
15908 num105 = 23;
15909 break;
15910 case 1571:
15911 num105 = 24;
15912 break;
15913 case 1569:
15914 num105 = 25;
15915 break;
15916 case 1260:
15917 num105 = 26;
15918 break;
15919 case 1572:
15920 num105 = 27;
15921 break;
15922 }
15923 }
15924 for (int num109 = 0; num109 < 2; num109++)
15925 {
15926 for (int num110 = 0; num110 < 2; num110++)
15927 {
15928 int num111 = num106 + num109;
15929 int num112 = num107 + num110;
15930 Main.tile[num111, num112].active(active: true);
15931 Main.tile[num111, num112].slope(0);
15932 Main.tile[num111, num112].halfBrick(halfBrick: false);
15933 Main.tile[num111, num112].type = type2;
15934 Main.tile[num111, num112].frameX = (short)(num109 * 18 + 36 * num105);
15935 Main.tile[num111, num112].frameY = (short)(num110 * 18);
15936 }
15937 if (!Main.tile[num109, num65 + 2].active())
15938 {
15939 Main.tile[num109, num65 + 2].active(active: true);
15940 if (!Main.tileSolid[Main.tile[num109, num65 + 2].type] || Main.tileSolidTop[Main.tile[num109, num65 + 2].type])
15941 {
15942 Main.tile[num109, num65 + 2].type = 0;
15943 }
15944 }
15945 Main.tile[num109, num65 + 2].slope(0);
15946 Main.tile[num109, num65 + 2].halfBrick(halfBrick: false);
15947 }
15948 }
15949 if (Main.tile[num64, num65].type == 28)
15950 {
15951 int num113 = Main.tile[num64, num65].frameX / 18;
15952 int num114 = 0;
15953 int num115 = num64;
15954 while (num113 >= 2)
15955 {
15956 num114++;
15957 num113 -= 2;
15958 }
15959 num115 -= num113;
15960 int num116 = Main.tile[num64, num65].frameY / 18;
15961 int num117 = 0;
15962 int num118 = num65;
15963 while (num116 >= 2)
15964 {
15965 num117++;
15966 num116 -= 2;
15967 }
15968 num118 -= num116;
15969 for (int num119 = 0; num119 < 2; num119++)
15970 {
15971 for (int num120 = 0; num120 < 2; num120++)
15972 {
15973 int num121 = num115 + num119;
15974 int num122 = num118 + num120;
15975 Main.tile[num121, num122].active(active: true);
15976 Main.tile[num121, num122].slope(0);
15977 Main.tile[num121, num122].halfBrick(halfBrick: false);
15978 Main.tile[num121, num122].type = 28;
15979 Main.tile[num121, num122].frameX = (short)(num119 * 18 + 36 * num114);
15980 Main.tile[num121, num122].frameY = (short)(num120 * 18 + 36 * num117);
15981 }
15982 if (!Main.tile[num119, num65 + 2].active())
15983 {
15984 Main.tile[num119, num65 + 2].active(active: true);
15985 if (!Main.tileSolid[Main.tile[num119, num65 + 2].type] || Main.tileSolidTop[Main.tile[num119, num65 + 2].type])
15986 {
15987 Main.tile[num119, num65 + 2].type = 0;
15988 }
15989 }
15990 Main.tile[num119, num65 + 2].slope(0);
15991 Main.tile[num119, num65 + 2].halfBrick(halfBrick: false);
15992 }
15993 }
15994 if (Main.tile[num64, num65].type == 26)
15995 {
15996 int num123 = Main.tile[num64, num65].frameX / 18;
15997 int num124 = 0;
15998 int num125 = num64;
15999 int num126 = num65 - Main.tile[num64, num65].frameY / 18;
16000 while (num123 >= 3)
16001 {
16002 num124++;
16003 num123 -= 3;
16004 }
16005 num125 -= num123;
16006 num124 = (drunkWorldGen ? ((Main.tile[num64, num65].wall == 83) ? 1 : 0) : (crimson ? 1 : 0));
16007 for (int num127 = 0; num127 < 3; num127++)
16008 {
16009 for (int num128 = 0; num128 < 2; num128++)
16010 {
16011 int num129 = num125 + num127;
16012 int num130 = num126 + num128;
16013 Main.tile[num129, num130].active(active: true);
16014 Main.tile[num129, num130].slope(0);
16015 Main.tile[num129, num130].halfBrick(halfBrick: false);
16016 Main.tile[num129, num130].type = 26;
16017 Main.tile[num129, num130].frameX = (short)(num127 * 18 + 54 * num124);
16018 Main.tile[num129, num130].frameY = (short)(num128 * 18);
16019 }
16020 if (!Main.tile[num125 + num127, num126 + 2].active() || !Main.tileSolid[Main.tile[num125 + num127, num126 + 2].type] || Main.tileSolidTop[Main.tile[num125 + num127, num126 + 2].type])
16021 {
16022 Main.tile[num125 + num127, num126 + 2].active(active: true);
16023 if (!TileID.Sets.Platforms[Main.tile[num125 + num127, num126 + 2].type])
16024 {
16025 if (Main.tile[num125 + num127, num126 + 2].type == 484)
16026 {
16027 Main.tile[num125 + num127, num126 + 2].type = 397;
16028 }
16029 else if (TileID.Sets.Boulders[Main.tile[num125 + num127, num126 + 2].type] || !Main.tileSolid[Main.tile[num125 + num127, num126 + 2].type] || Main.tileSolidTop[Main.tile[num125 + num127, num126 + 2].type])
16030 {
16031 Main.tile[num125 + num127, num126 + 2].type = 0;
16032 }
16033 }
16034 }
16035 Main.tile[num125 + num127, num126 + 2].slope(0);
16036 Main.tile[num125 + num127, num126 + 2].halfBrick(halfBrick: false);
16037 if (Main.tile[num125 + num127, num126 + 3].type == 28 && Main.tile[num125 + num127, num126 + 3].frameY % 36 >= 18)
16038 {
16039 Main.tile[num125 + num127, num126 + 3].type = 0;
16040 Main.tile[num125 + num127, num126 + 3].active(active: false);
16041 }
16042 }
16043 for (int num131 = 0; num131 < 3; num131++)
16044 {
16045 if ((Main.tile[num125 - 1, num126 + num131].type == 28 || Main.tile[num125 - 1, num126 + num131].type == 12 || Main.tile[num125 - 1, num126 + num131].type == 639) && Main.tile[num125 - 1, num126 + num131].frameX % 36 < 18)
16046 {
16047 Main.tile[num125 - 1, num126 + num131].type = 0;
16048 Main.tile[num125 - 1, num126 + num131].active(active: false);
16049 }
16050 if ((Main.tile[num125 + 3, num126 + num131].type == 28 || Main.tile[num125 + 3, num126 + num131].type == 12 || Main.tile[num125 - 1, num126 + num131].type == 639) && Main.tile[num125 + 3, num126 + num131].frameX % 36 >= 18)
16051 {
16052 Main.tile[num125 + 3, num126 + num131].type = 0;
16053 Main.tile[num125 + 3, num126 + num131].active(active: false);
16054 }
16055 }
16056 }
16057 if (Main.tile[num64, num65].type == 237 && Main.tile[num64, num65 + 1].type == 232)
16058 {
16059 Main.tile[num64, num65 + 1].type = 226;
16060 }
16061 if (Main.tile[num64, num65].wall == 87)
16062 {
16063 Main.tile[num64, num65].liquid = 0;
16064 }
16065 }
16066 }
16067 });
16068 AddGenerationPass("Lihzahrd Altars", delegate(GenerationProgress progress, GameConfiguration passConfig)
16069 {
16070 progress.Set(1.0);
16071 for (int num58 = 0; num58 < 3; num58++)
16072 {
16073 for (int num59 = 0; num59 < 2; num59++)
16074 {
16075 int num60 = GenVars.lAltarX + num58;
16076 int num61 = GenVars.lAltarY + num59;
16077 Main.tile[num60, num61].active(active: true);
16078 Main.tile[num60, num61].type = 237;
16079 Main.tile[num60, num61].frameX = (short)(num58 * 18);
16080 Main.tile[num60, num61].frameY = (short)(num59 * 18);
16081 }
16082 Main.tile[GenVars.lAltarX + num58, GenVars.lAltarY + 2].active(active: true);
16083 Main.tile[GenVars.lAltarX + num58, GenVars.lAltarY + 2].slope(0);
16084 Main.tile[GenVars.lAltarX + num58, GenVars.lAltarY + 2].halfBrick(halfBrick: false);
16085 Main.tile[GenVars.lAltarX + num58, GenVars.lAltarY + 2].type = 226;
16086 }
16087 for (int num62 = 0; num62 < 3; num62++)
16088 {
16089 for (int num63 = 0; num63 < 2; num63++)
16090 {
16091 int i2 = GenVars.lAltarX + num62;
16092 int j2 = GenVars.lAltarY + num63;
16093 SquareTileFrame(i2, j2);
16094 }
16095 }
16096 });
16097 AddGenerationPass("Micro Biomes", delegate(GenerationProgress progress, GameConfiguration passConfig)
16098 {
16099 progress.Message = Lang.gen[76].Value;
16100 _ = (double)(Main.maxTilesX * Main.maxTilesY) / 5040000.0;
16101 double num36 = 10.0;
16102 if (getGoodWorldGen || noTrapsWorldGen)
16103 {
16104 num36 *= 3.0;
16105 }
16108 int random = passConfig.Get<WorldGenRange>("DeadManChests").GetRandom(genRand);
16109 int num37 = 0;
16110 int num38 = 3000;
16112 {
16113 num38--;
16114 if (num38 <= 0)
16115 {
16116 break;
16117 }
16119 Point origin = new Point(Main.chest[num39].x, Main.chest[num39].y);
16120 deadMansChestBiome.Place(origin, GenVars.structures);
16121 num37++;
16123 }
16124 progress.Set(1.0 / num36);
16125 if (!notTheBees || remixWorldGen)
16126 {
16128 int random2 = passConfig.Get<WorldGenRange>("ThinIcePatchCount").GetRandom(genRand);
16129 int num40 = 0;
16130 int num41 = 1000;
16131 int num42 = 0;
16132 while (num42 < random2)
16133 {
16134 if (thinIceBiome.Place(RandomWorldPoint((int)Main.worldSurface + 20, 50, 200, 50), GenVars.structures))
16135 {
16136 num42++;
16137 num40 = 0;
16138 }
16139 else
16140 {
16141 num40++;
16142 if (num40 > num41)
16143 {
16144 num42++;
16145 num40 = 0;
16146 }
16147 }
16148 }
16149 }
16150 progress.Set(0.1);
16151 progress.Set(2.0 / num36);
16153 int num43 = passConfig.Get<WorldGenRange>("SwordShrineAttempts").GetRandom(genRand);
16154 double num44 = passConfig.Get<double>("SwordShrinePlacementChance");
16155 if (tenthAnniversaryWorldGen)
16156 {
16157 num43 *= 2;
16158 num44 /= 2.0;
16159 }
16160 Point origin2 = default(Point);
16161 for (int num45 = 0; num45 < num43; num45++)
16162 {
16163 if ((num45 == 0 && tenthAnniversaryWorldGen) || !(genRand.NextDouble() > num44))
16164 {
16165 int num46 = 0;
16166 while (num46++ <= Main.maxTilesX)
16167 {
16168 origin2.Y = (int)GenVars.worldSurface + genRand.Next(50, 100);
16169 if (genRand.Next(2) == 0)
16170 {
16171 origin2.X = genRand.Next(50, (int)((double)Main.maxTilesX * 0.3));
16172 }
16173 else
16174 {
16175 origin2.X = genRand.Next((int)((double)Main.maxTilesX * 0.7), Main.maxTilesX - 50);
16176 }
16178 {
16179 break;
16180 }
16181 }
16182 }
16183 }
16184 progress.Set(0.2);
16185 progress.Set(3.0 / num36);
16186 if (!notTheBees || remixWorldGen)
16187 {
16189 int random3 = passConfig.Get<WorldGenRange>("CampsiteCount").GetRandom(genRand);
16190 num38 = 1000;
16191 int num47 = 0;
16192 while (num47 < random3)
16193 {
16194 num38--;
16195 if (num38 <= 0)
16196 {
16197 break;
16198 }
16199 if (campsiteBiome.Place(RandomWorldPoint((int)Main.worldSurface, beachDistance, 200, beachDistance), GenVars.structures))
16200 {
16201 num47++;
16202 }
16203 }
16204 }
16205 progress.Set(4.0 / num36);
16206 if (!notTheBees || remixWorldGen)
16207 {
16209 int num48 = passConfig.Get<WorldGenRange>("ExplosiveTrapCount").GetRandom(genRand);
16210 if ((getGoodWorldGen || noTrapsWorldGen) && !notTheBees)
16211 {
16212 num48 = (int)((double)num48 * 1.5);
16213 }
16214 num38 = 3000;
16215 int num49 = 0;
16216 while (num49 < num48)
16217 {
16218 num38--;
16219 if (num38 <= 0)
16220 {
16221 break;
16222 }
16223 if (remixWorldGen)
16224 {
16225 if (miningExplosivesBiome.Place(RandomWorldPoint((int)Main.worldSurface, beachDistance, (int)GenVars.rockLayer, beachDistance), GenVars.structures))
16226 {
16227 num49++;
16228 }
16229 }
16230 else if (miningExplosivesBiome.Place(RandomWorldPoint((int)GenVars.rockLayer, beachDistance, 200, beachDistance), GenVars.structures))
16231 {
16232 num49++;
16233 }
16234 }
16235 }
16236 progress.Set(0.3);
16237 progress.Set(5.0 / num36);
16239 int random4 = passConfig.Get<WorldGenRange>("LivingTreeCount").GetRandom(genRand);
16240 int num50 = 0;
16241 int num51 = 0;
16242 while (num50 < random4 && num51 < 20000)
16243 {
16244 if (mahoganyTreeBiome.Place(RandomWorldPoint((int)Main.worldSurface + 50, 50, 500, 50), GenVars.structures))
16245 {
16246 num50++;
16247 }
16248 num51++;
16249 }
16250 progress.Set(0.4);
16251 progress.Set(6.0 / num36);
16252 progress.Set(7.0 / num36);
16254 int random5 = passConfig.Get<WorldGenRange>("LongTrackCount").GetRandom(genRand);
16255 WorldGenRange worldGenRange = passConfig.Get<WorldGenRange>("LongTrackLength");
16256 int maxTilesX = Main.maxTilesX;
16257 int num52 = 0;
16258 int num53 = 0;
16259 while (num53 < random5)
16260 {
16261 if (trackGenerator.Place(RandomWorldPoint((int)Main.worldSurface, 10, 200, 10), worldGenRange.ScaledMinimum, worldGenRange.ScaledMaximum))
16262 {
16263 num53++;
16264 num52 = 0;
16265 }
16266 else
16267 {
16268 num52++;
16269 if (num52 > maxTilesX)
16270 {
16271 num53++;
16272 num52 = 0;
16273 }
16274 }
16275 }
16276 progress.Set(8.0 / num36);
16277 random5 = passConfig.Get<WorldGenRange>("StandardTrackCount").GetRandom(genRand);
16278 worldGenRange = passConfig.Get<WorldGenRange>("StandardTrackLength");
16279 num52 = 0;
16280 int num54 = 0;
16281 while (num54 < random5)
16282 {
16283 if (trackGenerator.Place(RandomWorldPoint((int)Main.worldSurface, 10, 200, 10), worldGenRange.ScaledMinimum, worldGenRange.ScaledMaximum))
16284 {
16285 num54++;
16286 num52 = 0;
16287 }
16288 else
16289 {
16290 num52++;
16291 if (num52 > maxTilesX)
16292 {
16293 num54++;
16294 num52 = 0;
16295 }
16296 }
16297 }
16298 progress.Set(9.0 / num36);
16299 if (!notTheBees)
16300 {
16301 double num55 = (double)Main.maxTilesX * 0.02;
16302 if (noTrapsWorldGen)
16303 {
16304 num36 *= 5.0;
16305 }
16306 else if (getGoodWorldGen)
16307 {
16308 num36 *= 2.0;
16309 }
16310 for (int num56 = 0; (double)num56 < num55; num56++)
16311 {
16312 for (int num57 = 0; num57 < 10150; num57++)
16313 {
16314 int x2 = genRand.Next(200, Main.maxTilesX - 200);
16315 int y2 = genRand.Next(GenVars.lavaLine - 100, Main.maxTilesY - 210);
16316 if (placeLavaTrap(x2, y2))
16317 {
16318 break;
16319 }
16320 }
16321 }
16322 }
16323 progress.Set(1.0);
16324 });
16325 AddGenerationPass("Water Plants", delegate(GenerationProgress progress, GameConfiguration passConfig)
16326 {
16327 progress.Message = Lang.gen[88].Value;
16328 int num28 = (int)Main.worldSurface;
16329 if (remixWorldGen)
16330 {
16331 num28 = Main.maxTilesY - 200;
16332 }
16333 for (int num29 = 20; num29 < Main.maxTilesX - 20; num29++)
16334 {
16335 progress.Set((double)num29 / (double)Main.maxTilesX);
16336 for (int num30 = 1; num30 < num28; num30++)
16337 {
16338 if (genRand.Next(5) == 0 && Main.tile[num29, num30].liquid > 0)
16339 {
16340 if (!Main.tile[num29, num30].active())
16341 {
16342 if (genRand.Next(2) == 0)
16343 {
16344 PlaceLilyPad(num29, num30);
16345 }
16346 else
16347 {
16348 Point point = PlaceCatTail(num29, num30);
16349 if (InWorld(point.X, point.Y))
16350 {
16351 int num31 = genRand.Next(14);
16352 for (int num32 = 0; num32 < num31; num32++)
16353 {
16354 GrowCatTail(point.X, point.Y);
16355 }
16356 SquareTileFrame(point.X, point.Y);
16357 }
16358 }
16359 }
16360 if ((!Main.tile[num29, num30].active() || Main.tile[num29, num30].type == 61 || Main.tile[num29, num30].type == 74) && PlaceBamboo(num29, num30))
16361 {
16362 int num33 = genRand.Next(10, 20);
16363 for (int num34 = 0; num34 < num33 && PlaceBamboo(num29, num30 - num34); num34++)
16364 {
16365 }
16366 }
16367 }
16368 }
16370 while ((double)num35 > Main.worldSurface)
16371 {
16372 if (Main.tile[num29, num35].type == 53 && genRand.Next(3) != 0)
16373 {
16374 GrowCheckSeaweed(num29, num35);
16375 }
16376 else if (Main.tile[num29, num35].type == 549)
16377 {
16378 GrowCheckSeaweed(num29, num35);
16379 }
16380 num35--;
16381 }
16382 }
16383 });
16385 {
16386 progress.Set(1.0);
16387 for (int num24 = 20; num24 < Main.maxTilesX - 20; num24++)
16388 {
16389 for (int num25 = (int)Main.worldSurface; num25 < Main.maxTilesY - 20; num25++)
16390 {
16391 if ((Main.tenthAnniversaryWorld || drunkWorldGen || genRand.Next(5) == 0) && Main.tile[num24, num25 - 1].liquid == 0)
16392 {
16393 int num26 = genRand.Next(7);
16394 int treeTileType = 0;
16395 switch (num26)
16396 {
16397 case 0:
16398 treeTileType = 583;
16399 break;
16400 case 1:
16401 treeTileType = 584;
16402 break;
16403 case 2:
16404 treeTileType = 585;
16405 break;
16406 case 3:
16407 treeTileType = 586;
16408 break;
16409 case 4:
16410 treeTileType = 587;
16411 break;
16412 case 5:
16413 treeTileType = 588;
16414 break;
16415 case 6:
16416 treeTileType = 589;
16417 break;
16418 }
16419 TryGrowingTreeByType(treeTileType, num24, num25);
16420 }
16421 if (!oceanDepths(num24, num25) && !Main.tile[num24, num25].active() && genRand.Next(5) == 0)
16422 {
16423 if ((Main.tile[num24, num25 - 1].type == 1 || Main.tile[num24, num25 - 1].type == 147 || Main.tile[num24, num25 - 1].type == 161 || Main.tile[num24, num25 - 1].type == 25 || Main.tile[num24, num25 - 1].type == 203 || Main.tileStone[Main.tile[num24, num25 - 1].type] || Main.tileMoss[Main.tile[num24, num25 - 1].type]) && !Main.tile[num24, num25].active() && !Main.tile[num24, num25 + 1].active())
16424 {
16425 Main.tile[num24, num25 - 1].slope(0);
16426 }
16427 if ((Main.tile[num24, num25 + 1].type == 1 || Main.tile[num24, num25 + 1].type == 147 || Main.tile[num24, num25 + 1].type == 161 || Main.tile[num24, num25 + 1].type == 25 || Main.tile[num24, num25 + 1].type == 203 || Main.tileStone[Main.tile[num24, num25 + 1].type] || Main.tileMoss[Main.tile[num24, num25 + 1].type]) && !Main.tile[num24, num25].active() && !Main.tile[num24, num25 - 1].active())
16428 {
16429 Main.tile[num24, num25 + 1].slope(0);
16430 }
16431 PlaceTight(num24, num25);
16432 }
16433 }
16434 for (int num27 = 5; num27 < (int)Main.worldSurface; num27++)
16435 {
16436 if ((Main.tile[num24, num27 - 1].type == 147 || Main.tile[num24, num27 - 1].type == 161) && genRand.Next(5) == 0)
16437 {
16438 if (!Main.tile[num24, num27].active() && !Main.tile[num24, num27 + 1].active())
16439 {
16440 Main.tile[num24, num27 - 1].slope(0);
16441 }
16442 PlaceTight(num24, num27);
16443 }
16444 if ((Main.tile[num24, num27 - 1].type == 25 || Main.tile[num24, num27 - 1].type == 203) && genRand.Next(5) == 0)
16445 {
16446 if (!Main.tile[num24, num27].active() && !Main.tile[num24, num27 + 1].active())
16447 {
16448 Main.tile[num24, num27 - 1].slope(0);
16449 }
16450 PlaceTight(num24, num27);
16451 }
16452 if ((Main.tile[num24, num27 + 1].type == 25 || Main.tile[num24, num27 + 1].type == 203) && genRand.Next(5) == 0)
16453 {
16454 if (!Main.tile[num24, num27].active() && !Main.tile[num24, num27 - 1].active())
16455 {
16456 Main.tile[num24, num27 + 1].slope(0);
16457 }
16458 PlaceTight(num24, num27);
16459 }
16460 }
16461 }
16462 });
16463 AddGenerationPass("Remove Broken Traps", delegate(GenerationProgress progress, GameConfiguration passConfig)
16464 {
16465 if (!noTrapsWorldGen || tenthAnniversaryWorldGen || notTheBees)
16466 {
16467 progress.Message = Lang.gen[82].Value;
16469 int num21 = 50;
16470 for (int num22 = num21; num22 < Main.maxTilesX - num21; num22++)
16471 {
16472 double value = (double)(num22 - num21) / (double)(Main.maxTilesX - num21 * 2);
16473 progress.Set(value);
16474 for (int num23 = 50; num23 < Main.maxTilesY - 50; num23++)
16475 {
16476 if (Main.tile[num22, num23].wire() && !list.Contains(new Point(num22, num23)))
16477 {
16478 ClearBrokenTraps(new Point(num22, num23), list);
16479 }
16480 }
16481 }
16482 }
16483 });
16484 AddGenerationPass("Final Cleanup", delegate(GenerationProgress progress, GameConfiguration passConfig)
16485 {
16486 Main.tileSolid[484] = false;
16487 FillWallHolesInArea(new Rectangle(0, 0, Main.maxTilesX, (int)Main.worldSurface));
16488 progress.Message = Lang.gen[86].Value;
16489 for (int i = 0; i < Main.maxTilesX; i++)
16490 {
16491 progress.Set((double)i / (double)Main.maxTilesX);
16492 for (int j = 0; j < Main.maxTilesY; j++)
16493 {
16494 if (Main.tile[i, j].active() && !SolidTile(i, j + 1) && (Main.tile[i, j].type == 53 || Main.tile[i, j].type == 112 || Main.tile[i, j].type == 234 || Main.tile[i, j].type == 224 || Main.tile[i, j].type == 123))
16495 {
16496 if ((double)j < Main.worldSurface + 10.0 && !Main.tile[i, j + 1].active() && Main.tile[i, j + 1].wall != 191 && !oceanDepths(i, j))
16497 {
16498 int num = 10;
16499 int num2 = j + 1;
16500 for (int k = num2; k < num2 + 10; k++)
16501 {
16502 if (Main.tile[i, k].active() && Main.tile[i, k].type == 314)
16503 {
16504 num = 0;
16505 break;
16506 }
16507 }
16508 while (!Main.tile[i, num2].active() && num > 0 && num2 < Main.maxTilesY - 50)
16509 {
16510 Main.tile[i, num2 - 1].slope(0);
16511 Main.tile[i, num2 - 1].halfBrick(halfBrick: false);
16512 Main.tile[i, num2].active(active: true);
16513 Main.tile[i, num2].type = Main.tile[i, j].type;
16514 Main.tile[i, num2].slope(0);
16515 Main.tile[i, num2].halfBrick(halfBrick: false);
16516 num2++;
16517 num--;
16518 }
16519 if (num == 0 && !Main.tile[i, num2].active())
16520 {
16521 switch (Main.tile[i, j].type)
16522 {
16523 case 53:
16524 Main.tile[i, num2].type = 397;
16525 Main.tile[i, num2].active(active: true);
16526 break;
16527 case 112:
16528 Main.tile[i, num2].type = 398;
16529 Main.tile[i, num2].active(active: true);
16530 break;
16531 case 234:
16532 Main.tile[i, num2].type = 399;
16533 Main.tile[i, num2].active(active: true);
16534 break;
16535 case 224:
16536 Main.tile[i, num2].type = 147;
16537 Main.tile[i, num2].active(active: true);
16538 break;
16539 case 123:
16540 Main.tile[i, num2].type = 1;
16541 Main.tile[i, num2].active(active: true);
16542 break;
16543 }
16544 }
16545 else if (Main.tile[i, num2].active() && Main.tileSolid[Main.tile[i, num2].type] && !Main.tileSolidTop[Main.tile[i, num2].type])
16546 {
16547 Main.tile[i, num2].slope(0);
16548 Main.tile[i, num2].halfBrick(halfBrick: false);
16549 }
16550 }
16551 else if (Main.tileSolid[Main.tile[i, j + 1].type] && !Main.tileSolidTop[Main.tile[i, j + 1].type] && (Main.tile[i, j + 1].topSlope() || Main.tile[i, j + 1].halfBrick()))
16552 {
16553 Main.tile[i, j + 1].slope(0);
16554 Main.tile[i, j + 1].halfBrick(halfBrick: false);
16555 }
16556 else
16557 {
16558 switch (Main.tile[i, j].type)
16559 {
16560 case 53:
16561 Main.tile[i, j].type = 397;
16562 break;
16563 case 112:
16564 Main.tile[i, j].type = 398;
16565 break;
16566 case 234:
16567 Main.tile[i, j].type = 399;
16568 break;
16569 case 224:
16570 Main.tile[i, j].type = 147;
16571 break;
16572 case 123:
16573 Main.tile[i, j].type = 1;
16574 break;
16575 }
16576 }
16577 if (Main.tile[i, j - 1].type == 323)
16578 {
16579 TileFrame(i, j - 1);
16580 }
16581 }
16582 if ((Main.tile[i, j].wall == 187 || Main.tile[i, j].wall == 216) && Main.tile[i, j].liquid > 0 && !remixWorldGen)
16583 {
16584 Main.tile[i, j].liquid = byte.MaxValue;
16585 Main.tile[i, j].lava(lava: true);
16586 }
16587 if (Main.tile[i, j].type == 485 || Main.tile[i, j].type == 187 || Main.tile[i, j].type == 165)
16588 {
16589 TileFrame(i, j);
16590 }
16591 if (Main.tile[i, j].type == 28)
16592 {
16593 TileFrame(i, j);
16594 }
16595 if (Main.tile[i, j].type == 10 || Main.tile[i, j].type == 11)
16596 {
16597 TileFrame(i, j);
16598 }
16599 if (Main.tile[i, j].type == 26)
16600 {
16601 TileFrame(i, j);
16602 }
16603 if (TileID.Sets.IsATreeTrunk[Main.tile[i, j].type] || Main.tile[i, j].type == 323)
16604 {
16605 TileFrame(i, j);
16606 }
16607 if (Main.tile[i, j].type == 137)
16608 {
16609 Main.tile[i, j].slope(0);
16610 Main.tile[i, j].halfBrick(halfBrick: false);
16611 }
16612 if (Main.tile[i, j].active() && TileID.Sets.Boulders[Main.tile[i, j].type])
16613 {
16614 int num3 = Main.tile[i, j].frameX / 18;
16615 int num4 = i;
16616 num4 -= num3;
16617 int num5 = Main.tile[i, j].frameY / 18;
16618 int num6 = j;
16619 num6 -= num5;
16620 bool flag = false;
16621 for (int l = 0; l < 2; l++)
16622 {
16623 Tile tile = Main.tile[num4 + l, num6 - 1];
16624 if (tile != null && tile.active() && tile.type == 26)
16625 {
16626 flag = true;
16627 break;
16628 }
16629 for (int m = 0; m < 2; m++)
16630 {
16631 int num7 = num4 + l;
16632 int num8 = num6 + m;
16633 Main.tile[num7, num8].active(active: true);
16634 Main.tile[num7, num8].slope(0);
16635 Main.tile[num7, num8].halfBrick(halfBrick: false);
16636 Main.tile[num7, num8].type = Main.tile[i, j].type;
16637 Main.tile[num7, num8].frameX = (short)(l * 18);
16638 Main.tile[num7, num8].frameY = (short)(m * 18);
16639 }
16640 }
16641 if (flag)
16642 {
16643 ushort type = 0;
16644 if (Main.tile[i, j].type == 484)
16645 {
16646 type = 397;
16647 }
16648 for (int n = 0; n < 2; n++)
16649 {
16650 for (int num9 = 0; num9 < 2; num9++)
16651 {
16652 int num10 = num4 + n;
16653 int num11 = num6 + num9;
16654 Main.tile[num10, num11].active(active: true);
16655 Main.tile[num10, num11].slope(0);
16656 Main.tile[num10, num11].halfBrick(halfBrick: false);
16657 Main.tile[num10, num11].type = type;
16658 Main.tile[num10, num11].frameX = 0;
16659 Main.tile[num10, num11].frameY = 0;
16660 }
16661 }
16662 }
16663 }
16664 if (Main.tile[i, j].type == 323 && Main.tile[i, j].liquid > 0)
16665 {
16666 KillTile(i, j);
16667 }
16668 if (Main.wallDungeon[Main.tile[i, j].wall])
16669 {
16670 Main.tile[i, j].lava(lava: false);
16671 if (Main.tile[i, j].active() && Main.tile[i, j].type == 56)
16672 {
16673 KillTile(i, j);
16674 Main.tile[i, j].lava(lava: false);
16675 Main.tile[i, j].liquid = byte.MaxValue;
16676 }
16677 }
16678 if (Main.tile[i, j].active() && Main.tile[i, j].type == 314)
16679 {
16680 int num12 = 15;
16681 int num13 = 1;
16682 int num14 = j;
16683 while (j - num14 < num12)
16684 {
16685 Main.tile[i, num14].liquid = 0;
16686 num14--;
16687 }
16688 for (num14 = j; num14 - j < num13; num14++)
16689 {
16690 Main.tile[i, num14].liquid = 0;
16691 }
16692 }
16693 if (Main.tile[i, j].active() && Main.tile[i, j].type == 332 && !Main.tile[i, j + 1].active())
16694 {
16695 Main.tile[i, j + 1].ClearEverything();
16696 Main.tile[i, j + 1].active(active: true);
16697 Main.tile[i, j + 1].type = 332;
16698 }
16699 if (i > beachDistance && i < Main.maxTilesX - beachDistance && (double)j < Main.worldSurface && Main.tile[i, j].liquid > 0 && Main.tile[i, j].liquid < byte.MaxValue && Main.tile[i - 1, j].liquid < byte.MaxValue && Main.tile[i + 1, j].liquid < byte.MaxValue && Main.tile[i, j + 1].liquid < byte.MaxValue && !TileID.Sets.Clouds[Main.tile[i - 1, j].type] && !TileID.Sets.Clouds[Main.tile[i + 1, j].type] && !TileID.Sets.Clouds[Main.tile[i, j + 1].type])
16700 {
16701 Main.tile[i, j].liquid = 0;
16702 }
16703 }
16704 }
16705 int num15 = 0;
16706 int num16 = 3;
16707 num16 = GetWorldSize() switch
16708 {
16709 1 => 6,
16710 2 => 9,
16711 _ => 3,
16712 };
16713 if (tenthAnniversaryWorldGen)
16714 {
16715 num16 *= 5;
16716 }
16717 int num17 = 50;
16718 int minValue = num17;
16719 int minValue2 = num17;
16720 int maxValue = Main.maxTilesX - num17;
16721 int maxValue2 = Main.maxTilesY - 200;
16722 int num18 = 3000;
16723 while (num15 < num16)
16724 {
16725 num18--;
16726 if (num18 <= 0)
16727 {
16728 break;
16729 }
16730 int num19 = genRand.Next(minValue, maxValue);
16731 int num20 = genRand.Next(minValue2, maxValue2);
16733 if (tile2.active() && tile2.type >= 0 && tile2.type < TileID.Count)
16734 {
16735 bool flag2 = TileID.Sets.Dirt[tile2.type];
16736 if (notTheBees)
16737 {
16738 flag2 = flag2 || TileID.Sets.Mud[tile2.type];
16739 }
16740 if (flag2)
16741 {
16742 num15++;
16743 tile2.ClearTile();
16744 tile2.active(active: true);
16745 tile2.type = 668;
16746 }
16747 }
16748 }
16749 if (noTrapsWorldGen)
16750 {
16751 FinishNoTraps();
16752 }
16754 {
16755 FinishTenthAnniversaryWorld();
16756 }
16757 if (drunkWorldGen)
16758 {
16759 FinishDrunkGen();
16760 }
16761 if (notTheBees)
16762 {
16763 NotTheBees();
16764 FinishNotTheBees();
16765 }
16766 if (getGoodWorldGen)
16767 {
16768 FinishGetGoodWorld();
16769 }
16770 if (remixWorldGen)
16771 {
16772 FinishRemixWorld();
16773 }
16774 ShimmerCleanUp();
16775 notTheBees = false;
16776 getGoodWorldGen = false;
16777 noTileActions = false;
16778 Main.tileSolid[659] = true;
16780 Main.tileSolid[484] = true;
16781 gen = false;
16783 skipFramingDuringGen = false;
16784 progress.Message = Lang.gen[87].Value;
16785 });
16786 _generator.GenerateWorld(customProgressObject);
16787 ConsumePostGenActions(GenVars.structures);
16788 Main.WorldFileMetadata = FileMetadata.FromCurrentSettings(FileType.World);
16790 drunkWorldGenText = false;
16791 }
16792
16793 private static Point GetAdjustedFloorPosition(int x, int y)
16794 {
16795 int num = x - 1;
16796 int num2 = y - 2;
16797 bool isEmpty = false;
16798 bool hasFloor = false;
16799 while (!isEmpty && num2 > Main.spawnTileY - 10)
16800 {
16801 Scan3By3(num, num2, out isEmpty, out hasFloor);
16802 if (!isEmpty)
16803 {
16804 num2--;
16805 }
16806 }
16807 while (!hasFloor && num2 < Main.spawnTileY + 10)
16808 {
16809 Scan3By3(num, num2, out isEmpty, out hasFloor);
16810 if (!hasFloor)
16811 {
16812 num2++;
16813 }
16814 }
16815 return new Point(num + 1, num2 + 2);
16816 }
16817
16818 private static void Scan3By3(int topLeftX, int topLeftY, out bool isEmpty, out bool hasFloor)
16819 {
16820 isEmpty = true;
16821 hasFloor = false;
16822 for (int i = 0; i < 3; i++)
16823 {
16824 int num = 0;
16825 while (num < 3)
16826 {
16827 int i2 = topLeftX + i;
16828 int j = topLeftY + num;
16829 if (!SolidTile(i2, j))
16830 {
16831 num++;
16832 continue;
16833 }
16834 goto IL_001e;
16835 }
16836 continue;
16837 IL_001e:
16838 isEmpty = false;
16839 break;
16840 }
16841 for (int k = 0; k < 3; k++)
16842 {
16843 int i3 = topLeftX + k;
16844 int j2 = topLeftY + 3;
16845 if (SolidTile(i3, j2))
16846 {
16847 hasFloor = true;
16848 break;
16849 }
16850 }
16851 }
16852
16853 private static void FinishTenthAnniversaryWorld()
16854 {
16855 if (!remixWorldGen)
16856 {
16857 if (!getGoodWorldGen && !drunkWorldGen)
16858 {
16859 ConvertSkyIslands(2, growTrees: true);
16860 }
16861 PaintTheDungeon(24, 24);
16862 PaintTheLivingTrees(12, 12);
16863 PaintTheTemple(10, 5);
16864 PaintTheClouds(12, 12);
16865 PaintTheSand(7, 7);
16866 PaintThePyramids(12, 12);
16867 }
16868 PaintTheTrees();
16869 PaintTheMushrooms();
16870 if (!getGoodWorldGen)
16871 {
16872 for (int i = 50; i < Main.maxTilesX - 50; i++)
16873 {
16874 for (int j = 50; j < Main.maxTilesY - 50; j++)
16875 {
16876 Tile tile = Main.tile[i, j];
16877 if (genRand.Next(4) == 0 && tile.active() && tile.type == 138 && tile.frameX == 0 && tile.frameY == 0)
16878 {
16879 Main.tile[i, j].type = 665;
16880 Main.tile[i, j + 1].type = 665;
16881 Main.tile[i + 1, j].type = 665;
16882 Main.tile[i + 1, j + 1].type = 665;
16883 }
16884 }
16885 }
16886 }
16887 if (!getGoodWorldGen)
16888 {
16889 ImproveAllChestContents();
16890 }
16891 }
16892
16893 private static void PaintTheMushrooms()
16894 {
16895 int num = Main.maxTilesY - 20;
16896 byte b = (byte)genRand.Next(1, 13);
16897 if (remixWorldGen)
16898 {
16899 b = 2;
16900 num = Main.maxTilesY - 500;
16901 int num2 = genRand.Next(5, 31);
16902 if (genRand.Next(2) == 0)
16903 {
16904 num2 = genRand.Next(5, 16);
16905 }
16906 for (int i = 20; i < Main.maxTilesX - 20; i++)
16907 {
16908 if (i % num2 == 0)
16909 {
16910 b++;
16911 if (b > 12)
16912 {
16913 b = 1;
16914 }
16915 }
16916 for (int j = Main.maxTilesY - 450; j < Main.maxTilesY - 20; j++)
16917 {
16918 Tile tile = Main.tile[i, j];
16919 if (tile.active() && (tile.type == 70 || tile.type == 578 || tile.type == 190 || tile.type == 71 || tile.type == 528 || (tile.type == 519 && tile.frameY == 90)))
16920 {
16921 tile.color(b);
16922 }
16923 if (tile.wall == 80 || tile.wall == 74)
16924 {
16925 tile.wallColor(b);
16926 }
16927 }
16928 }
16929 }
16930 b = (byte)genRand.Next(1, 13);
16931 int num3 = 0;
16932 for (int k = 20; k < Main.maxTilesX - 20; k++)
16933 {
16934 for (int l = 20; l < num; l++)
16935 {
16936 Tile tile2 = Main.tile[k, l];
16937 if (tile2.active() && (tile2.type == 70 || tile2.type == 578 || tile2.type == 190 || tile2.type == 71 || tile2.type == 528 || (tile2.type == 519 && tile2.frameY == 90)))
16938 {
16939 tile2.color(b);
16940 num3 = 10;
16941 }
16942 if (tile2.wall == 80 || tile2.wall == 74)
16943 {
16944 tile2.wallColor(b);
16945 num3 = 10;
16946 }
16947 }
16948 num3--;
16949 if (num3 == 0)
16950 {
16951 b += (byte)genRand.Next(1, 3);
16952 if (b > 12)
16953 {
16954 b = 1;
16955 }
16956 }
16957 }
16958 }
16959
16960 private static void PaintTheTrees()
16961 {
16962 int num = 20;
16963 if (remixWorldGen)
16964 {
16965 num = (int)Main.worldSurface;
16966 }
16967 byte b = (byte)genRand.Next(1, 13);
16968 bool flag = false;
16969 for (int i = 20; i < Main.maxTilesX - 20; i++)
16970 {
16971 bool flag2 = false;
16972 for (int j = num; j < Main.maxTilesY - 20; j++)
16973 {
16974 Tile tile = Main.tile[i, j];
16975 if (tile.active() && (tile.type == 5 || tile.type == 323 || tile.type == 596 || tile.type == 616))
16976 {
16977 tile.color(b);
16978 flag2 = true;
16979 flag = true;
16980 }
16981 }
16982 if (flag && !flag2)
16983 {
16984 flag = false;
16985 b++;
16986 if (b > 12)
16987 {
16988 b = 1;
16989 }
16990 }
16991 }
16992 }
16993
16994 private static void PaintTheSand(byte tilePaintColor, byte wallPaintColor)
16995 {
16996 for (int i = 20; i < Main.maxTilesX - 20; i++)
16997 {
16998 for (int j = 20; j < Main.maxTilesY - 20; j++)
16999 {
17000 Tile tile = Main.tile[i, j];
17001 if (tile.active() && (tile.type == 53 || tile.type == 396 || tile.type == 397))
17002 {
17003 tile.color(tilePaintColor);
17004 if ((double)j > Main.worldSurface)
17005 {
17006 if (Main.tile[i, j - 1].type == 165 || Main.tile[i, j - 1].type == 185 || Main.tile[i, j - 1].type == 186 || Main.tile[i, j - 1].type == 187)
17007 {
17008 Main.tile[i, j - 1].color(tilePaintColor);
17009 }
17010 if (Main.tile[i, j - 2].type == 165 || Main.tile[i, j - 2].type == 185 || Main.tile[i, j - 2].type == 186 || Main.tile[i, j - 2].type == 187)
17011 {
17012 Main.tile[i, j - 2].color(tilePaintColor);
17013 }
17014 if (Main.tile[i, j + 1].type == 165)
17015 {
17016 Main.tile[i, j + 1].color(tilePaintColor);
17017 }
17018 if (Main.tile[i, j + 2].type == 165)
17019 {
17020 Main.tile[i, j + 2].color(tilePaintColor);
17021 }
17022 }
17023 }
17024 if (tile.wall == 187 || tile.wall == 216)
17025 {
17027 }
17028 }
17029 }
17030 }
17031
17032 private static void PaintThePurityGrass(byte tilePaintColor, byte wallPaintColor)
17033 {
17034 for (int i = 0; i < Main.maxTilesX; i++)
17035 {
17036 for (int j = 0; j < Main.maxTilesY; j++)
17037 {
17038 Tile tile = Main.tile[i, j];
17039 if (tile.active())
17040 {
17041 if (tile.type == 2)
17042 {
17043 tile.color(tilePaintColor);
17044 }
17045 else if (tile.type == 185 || tile.type == 186 || tile.type == 187)
17046 {
17047 Tile tile2 = tile;
17048 int num = j;
17049 while (num < Main.maxTilesY - 20 && (tile2.type == 185 || tile2.type == 186 || tile2.type == 187 || tile2.type == 3 || tile2.type == 73))
17050 {
17051 tile2 = Main.tile[i, ++num];
17052 }
17053 if (tile2.type == 2)
17054 {
17055 tile.color(tilePaintColor);
17056 }
17057 }
17058 }
17059 if (tile.wall == 66 || tile.wall == 63)
17060 {
17062 }
17063 }
17064 }
17065 }
17066
17067 private static void PaintThePyramids(byte tilePaintColor, byte wallPaintColor)
17068 {
17069 for (int i = 0; i < Main.maxTilesX; i++)
17070 {
17071 for (int j = 0; j < Main.maxTilesY; j++)
17072 {
17073 Tile tile = Main.tile[i, j];
17074 if (tile.active() && tile.type == 151)
17075 {
17076 tile.color(tilePaintColor);
17077 }
17078 if (tile.wall == 34)
17079 {
17081 }
17082 }
17083 }
17084 }
17085
17086 private static void PaintTheTemple(byte tilePaintColor, byte wallPaintColor)
17087 {
17088 for (int i = 0; i < Main.maxTilesX; i++)
17089 {
17090 for (int j = 0; j < Main.maxTilesY; j++)
17091 {
17092 Tile tile = Main.tile[i, j];
17093 if (tile.active())
17094 {
17095 bool flag = false;
17096 if (tile.type == 226)
17097 {
17098 flag = true;
17099 }
17100 if (tile.type == 137)
17101 {
17102 int num = tile.frameY / 18;
17103 if (num >= 1 && num <= 4)
17104 {
17105 flag = true;
17106 }
17107 }
17108 if (flag)
17109 {
17110 tile.color(tilePaintColor);
17111 }
17112 }
17113 if (tile.wall == 87)
17114 {
17116 }
17117 }
17118 }
17119 }
17120
17121 private static void PaintTheClouds(byte tilePaintColor, byte wallPaintColor)
17122 {
17123 for (int i = 0; i < Main.maxTilesX; i++)
17124 {
17125 for (int j = 0; j < Main.maxTilesY; j++)
17126 {
17127 Tile tile = Main.tile[i, j];
17128 if (tile.active() && (tile.type == 189 || tile.type == 196 || tile.type == 460))
17129 {
17130 tile.color(tilePaintColor);
17131 }
17132 if (tile.wall == 73)
17133 {
17135 }
17136 }
17137 }
17138 }
17139
17140 private static void PaintTheDungeon(byte tilePaintColor, byte wallPaintColor)
17141 {
17142 for (int i = 0; i < Main.maxTilesX; i++)
17143 {
17144 for (int j = 0; j < Main.maxTilesY; j++)
17145 {
17146 Tile tile = Main.tile[i, j];
17147 if (tile.active())
17148 {
17149 if (Main.tileDungeon[tile.type] || TileID.Sets.CrackedBricks[tile.type])
17150 {
17151 tile.color(tilePaintColor);
17152 }
17153 if (tile.type == 19)
17154 {
17155 int num = tile.frameY / 18;
17156 if (num >= 6 && num <= 12)
17157 {
17158 tile.color(tilePaintColor);
17159 }
17160 }
17161 }
17162 if (Main.wallDungeon[tile.wall])
17163 {
17165 }
17166 }
17167 }
17168 }
17169
17171 {
17172 for (int i = 0; i < Main.maxTilesX; i++)
17173 {
17174 for (int j = 0; j < Main.maxTilesY; j++)
17175 {
17176 Tile tile = Main.tile[i, j];
17177 if (tile.active())
17178 {
17179 if (tile.wall == 244)
17180 {
17182 }
17183 else if (tile.type == 192 || tile.type == 191)
17184 {
17186 }
17187 else if (tile.type == 52 || tile.type == 382)
17188 {
17189 int x = i;
17190 int y = j;
17191 GetVineTop(i, j, out x, out y);
17192 if (Main.tile[x, y].type == 192)
17193 {
17195 }
17196 }
17197 else if (tile.type == 187)
17198 {
17199 Tile tile2 = tile;
17200 int num = 0;
17201 while (tile2.type == 187)
17202 {
17203 num++;
17204 tile2 = Main.tile[i, j + num];
17205 }
17206 if (tile2.type == 192)
17207 {
17209 }
17210 }
17211 }
17212 if (tile.wall == 244)
17213 {
17215 }
17216 }
17217 }
17218 }
17219
17220 private static void ConvertSkyIslands(int convertType, bool growTrees)
17221 {
17222 int num = 0;
17223 for (int i = 20; (double)i < Main.worldSurface; i++)
17224 {
17225 for (int j = 20; j < Main.maxTilesX - 20; j++)
17226 {
17227 Tile tile = Main.tile[j, i];
17228 if (tile.active() && TileID.Sets.Clouds[tile.type])
17229 {
17230 num = i;
17231 break;
17232 }
17233 }
17234 }
17235 for (int k = 20; k <= Main.maxTilesX - 20; k++)
17236 {
17237 for (int l = 20; l < num; l++)
17238 {
17239 Tile tile2 = Main.tile[k, l];
17240 Tile tile3 = Main.tile[k, l - 1];
17241 if (tile2.active() && tile2.type == 2)
17242 {
17243 if (tile3.type == 596 || tile3.type == 616)
17244 {
17245 KillTile(k, l - 1);
17246 }
17247 Convert(k, l, convertType, 1);
17248 ushort type = tile3.type;
17249 if ((uint)(type - 82) <= 1u || (uint)(type - 185) <= 2u || type == 227)
17250 {
17251 KillTile(k, l - 1);
17252 }
17253 if (growTrees && _genRand.Next(3) == 0)
17254 {
17255 GrowTree(k, l);
17256 }
17257 }
17258 }
17259 }
17260 }
17261
17262 private static void ImproveAllChestContents()
17263 {
17264 for (int i = 0; i < 8000; i++)
17265 {
17266 Chest chest = Main.chest[i];
17267 if (chest == null)
17268 {
17269 continue;
17270 }
17271 for (int j = 0; j < 40; j++)
17272 {
17273 Item item = chest.item[j];
17274 if (item != null && !item.IsAir)
17275 {
17276 GiveItemGoodPrefixes(item);
17277 }
17278 }
17279 }
17280 }
17281
17282 private static void GiveItemGoodPrefixes(Item item)
17283 {
17284 if (item.accessory)
17285 {
17287 }
17288 if (item.melee)
17289 {
17291 }
17292 if (item.ranged)
17293 {
17295 }
17296 if (item.magic)
17297 {
17299 }
17300 if (item.summon)
17301 {
17303 }
17304 }
17305
17306 private static void PrefixItemFromOptions(Item item, int[] options)
17307 {
17308 byte prefix = item.prefix;
17309 if (!item.Prefix(-3))
17310 {
17311 return;
17312 }
17314 while (list.Count > 0)
17315 {
17316 int index = _genRand.Next(list.Count);
17317 int num = list[index];
17318 item.Prefix(num);
17319 if (item.prefix == num)
17320 {
17321 return;
17322 }
17323 list.RemoveAt(index);
17324 }
17325 item.Prefix(prefix);
17326 }
17327
17328 private static void NotTheBees()
17329 {
17330 int num = Main.maxTilesX / 7;
17331 if (!notTheBees)
17332 {
17333 return;
17334 }
17335 for (int i = 0; i < Main.maxTilesX; i++)
17336 {
17337 for (int j = 0; j < Main.maxTilesY - 180; j++)
17338 {
17339 if (remixWorldGen && (i < num + genRand.Next(3) || i >= Main.maxTilesX - num - genRand.Next(3) || ((double)j > (Main.worldSurface * 2.0 + Main.rockLayer) / 3.0 + (double)genRand.Next(3) && j < Main.maxTilesY - 350 - genRand.Next(3))))
17340 {
17341 continue;
17342 }
17343 if (Main.tile[i, j].type == 52)
17344 {
17345 Main.tile[i, j].type = 62;
17346 }
17347 if ((SolidOrSlopedTile(i, j) || TileID.Sets.CrackedBricks[Main.tile[i, j].type]) && !TileID.Sets.Ore[Main.tile[i, j].type] && Main.tile[i, j].type != 123 && Main.tile[i, j].type != 40)
17348 {
17349 if (Main.tile[i, j].type == 191 || Main.tile[i, j].type == 383)
17350 {
17351 if (!remixWorldGen)
17352 {
17353 Main.tile[i, j].type = 383;
17354 }
17355 }
17356 else if (Main.tile[i, j].type == 192 || Main.tile[i, j].type == 384)
17357 {
17358 if (!remixWorldGen)
17359 {
17360 Main.tile[i, j].type = 384;
17361 }
17362 }
17363 else if (Main.tile[i, j].type != 151 && Main.tile[i, j].type != 662 && Main.tile[i, j].type != 661 && Main.tile[i, j].type != 189 && Main.tile[i, j].type != 196 && Main.tile[i, j].type != 120 && Main.tile[i, j].type != 158 && Main.tile[i, j].type != 175 && Main.tile[i, j].type != 45 && Main.tile[i, j].type != 119)
17364 {
17365 if (Main.tile[i, j].type >= 63 && Main.tile[i, j].type <= 68)
17366 {
17367 Main.tile[i, j].type = 230;
17368 }
17369 else if (Main.tile[i, j].type != 57 && Main.tile[i, j].type != 76 && Main.tile[i, j].type != 75 && Main.tile[i, j].type != 229 && Main.tile[i, j].type != 230 && Main.tile[i, j].type != 407 && Main.tile[i, j].type != 404)
17370 {
17371 if (Main.tile[i, j].type == 224)
17372 {
17373 Main.tile[i, j].type = 229;
17374 }
17375 else if (Main.tile[i, j].type == 53)
17376 {
17377 if (i < beachDistance + genRand.Next(3) || i > Main.maxTilesX - beachDistance - genRand.Next(3))
17378 {
17379 Main.tile[i, j].type = 229;
17380 }
17381 }
17382 else if ((i <= beachDistance - genRand.Next(3) || i >= Main.maxTilesX - beachDistance + genRand.Next(3) || (Main.tile[i, j].type != 397 && Main.tile[i, j].type != 396)) && Main.tile[i, j].type != 10 && Main.tile[i, j].type != 203 && Main.tile[i, j].type != 25 && Main.tile[i, j].type != 137 && Main.tile[i, j].type != 138 && Main.tile[i, j].type != 141)
17383 {
17384 if (Main.tileDungeon[Main.tile[i, j].type] || TileID.Sets.CrackedBricks[Main.tile[i, j].type])
17385 {
17386 Main.tile[i, j].color(14);
17387 }
17388 else if (Main.tile[i, j].type == 226)
17389 {
17390 Main.tile[i, j].color(15);
17391 }
17392 else if (Main.tile[i, j].type != 202 && Main.tile[i, j].type != 70 && Main.tile[i, j].type != 48 && Main.tile[i, j].type != 232)
17393 {
17394 if (TileID.Sets.Conversion.Grass[Main.tile[i, j].type] || Main.tile[i, j].type == 60 || Main.tile[i, j].type == 70)
17395 {
17396 if (j > GenVars.lavaLine + genRand.Next(-2, 3) + 2)
17397 {
17398 Main.tile[i, j].type = 70;
17399 }
17400 else
17401 {
17402 Main.tile[i, j].type = 60;
17403 }
17404 }
17405 else if (Main.tile[i, j].type == 0 || Main.tile[i, j].type == 59)
17406 {
17407 Main.tile[i, j].type = 59;
17408 }
17409 else if (Main.tile[i, j].type != 633)
17410 {
17411 if (j > GenVars.lavaLine + genRand.Next(-2, 3) + 2)
17412 {
17413 Main.tile[i, j].type = 230;
17414 }
17415 else if (!remixWorldGen || (double)j > Main.worldSurface + (double)genRand.Next(-1, 2))
17416 {
17417 Main.tile[i, j].type = 225;
17418 }
17419 }
17420 }
17421 }
17422 }
17423 }
17424 }
17425 if (Main.tile[i, j].wall != 15 && Main.tile[i, j].wall != 64 && Main.tile[i, j].wall != 204 && Main.tile[i, j].wall != 205 && Main.tile[i, j].wall != 206 && Main.tile[i, j].wall != 207 && Main.tile[i, j].wall != 23 && Main.tile[i, j].wall != 24 && Main.tile[i, j].wall != 42 && Main.tile[i, j].wall != 10 && Main.tile[i, j].wall != 21 && Main.tile[i, j].wall != 82 && Main.tile[i, j].wall != 187 && Main.tile[i, j].wall != 216 && Main.tile[i, j].wall != 34 && Main.tile[i, j].wall != 244)
17426 {
17427 if (Main.tile[i, j].wall == 87)
17428 {
17429 Main.tile[i, j].wallColor(15);
17430 }
17431 else if (Main.wallDungeon[Main.tile[i, j].wall])
17432 {
17433 Main.tile[i, j].wallColor(14);
17434 }
17435 else if (Main.tile[i, j].wall == 2)
17436 {
17437 Main.tile[i, j].wall = 2;
17438 }
17439 else if (Main.tile[i, j].wall == 196)
17440 {
17441 Main.tile[i, j].wall = 196;
17442 }
17443 else if (Main.tile[i, j].wall == 197)
17444 {
17445 Main.tile[i, j].wall = 197;
17446 }
17447 else if (Main.tile[i, j].wall == 198)
17448 {
17449 Main.tile[i, j].wall = 198;
17450 }
17451 else if (Main.tile[i, j].wall == 199)
17452 {
17453 Main.tile[i, j].wall = 199;
17454 }
17455 else if (Main.tile[i, j].wall == 63)
17456 {
17457 Main.tile[i, j].wall = 64;
17458 }
17459 else if (Main.tile[i, j].wall != 3 && Main.tile[i, j].wall != 83 && Main.tile[i, j].wall != 73 && Main.tile[i, j].wall != 62 && Main.tile[i, j].wall != 13 && Main.tile[i, j].wall != 14 && Main.tile[i, j].wall > 0 && (!remixWorldGen || (double)j > Main.worldSurface + (double)genRand.Next(-1, 2)))
17460 {
17461 Main.tile[i, j].wall = 86;
17462 }
17463 }
17464 if (Main.tile[i, j].liquid > 0 && j <= GenVars.lavaLine + 2)
17465 {
17466 if ((double)j > Main.rockLayer && (i < beachDistance + 200 || i > Main.maxTilesX - beachDistance - 200))
17467 {
17468 Main.tile[i, j].honey(honey: false);
17469 }
17470 else if (Main.wallDungeon[Main.tile[i, j].wall])
17471 {
17472 Main.tile[i, j].honey(honey: false);
17473 }
17474 else
17475 {
17476 Main.tile[i, j].honey(honey: true);
17477 }
17478 }
17479 }
17480 }
17481 }
17482
17483 private static void FinishNotTheBees()
17484 {
17485 if (!notTheBees)
17486 {
17487 return;
17488 }
17489 int num = 0;
17490 for (int i = 20; (double)i < Main.worldSurface; i++)
17491 {
17492 for (int j = 20; j < Main.maxTilesX - 20; j++)
17493 {
17494 if (Main.tile[j, i].active() && TileID.Sets.Clouds[Main.tile[j, i].type])
17495 {
17496 num = i;
17497 break;
17498 }
17499 }
17500 }
17501 for (int k = 25; k < Main.maxTilesX - 25; k++)
17502 {
17503 for (int l = 25; l < Main.maxTilesY - 25; l++)
17504 {
17505 if (Main.tile[k, l].type == 571)
17506 {
17507 TileFrame(k, l);
17508 }
17509 int num2 = 20;
17510 if (remixWorldGen)
17511 {
17512 num2 = 10;
17513 }
17514 if (Main.tile[k, l].type == 25 || (remixWorldGen && Main.tile[k, l].type == 23 && (double)l < Main.worldSurface))
17515 {
17516 for (int m = k - num2; m <= k + num2; m++)
17517 {
17518 for (int n = l - num2; n <= l + num2; n++)
17519 {
17520 if (Main.tile[m, n].type == 60)
17521 {
17522 if (Main.tile[m, n + 1].type == 444)
17523 {
17524 KillTile(m, n + 1);
17525 }
17526 Main.tile[m, n].type = 661;
17527 if (Main.tile[m, n - 1].type == 61 || Main.tile[m, n - 1].type == 74)
17528 {
17529 Main.tile[m, n - 1].active(active: false);
17530 PlaceTile(m, n - 1, 24);
17531 }
17532 }
17533 else if (Main.tile[m, n - 1].type == 233 || Main.tile[m, n - 1].type == 82)
17534 {
17535 KillTile(m, n - 1);
17536 }
17537 }
17538 }
17539 }
17540 else if (Main.tile[k, l].type == 203 || (remixWorldGen && Main.tile[k, l].type == 199 && (double)l < Main.worldSurface))
17541 {
17542 for (int num3 = k - num2; num3 <= k + num2; num3++)
17543 {
17544 for (int num4 = l - num2; num4 <= l + num2; num4++)
17545 {
17546 if (Main.tile[num3, num4].type == 60)
17547 {
17548 if (Main.tile[num3, num4 + 1].type == 444)
17549 {
17550 KillTile(num3, num4 + 1);
17551 }
17552 Main.tile[num3, num4].type = 662;
17553 if (Main.tile[num3, num4 - 1].type == 61 || Main.tile[num3, num4 - 1].type == 74)
17554 {
17555 Main.tile[num3, num4 - 1].active(active: false);
17556 PlaceTile(num3, num4 - 1, 201);
17557 }
17558 else if (Main.tile[num3, num4 - 1].type == 233 || Main.tile[num3, num4 - 1].type == 82)
17559 {
17560 KillTile(num3, num4 - 1);
17561 }
17562 }
17563 }
17564 }
17565 }
17566 if (Main.tile[k, l].type == 382 || Main.tile[k, l].type == 52)
17567 {
17568 Main.tile[k, l].type = 62;
17569 }
17570 if (l > GenVars.lavaLine + genRand.Next(-2, 3) + 2)
17571 {
17572 if (!remixWorldGen)
17573 {
17574 SpreadGrass(k, l, 59, 70);
17575 }
17576 }
17577 else
17578 {
17579 SpreadGrass(k, l, 59, 60);
17580 }
17581 if ((double)l > Main.rockLayer + 20.0 + (double)genRand.Next(-2, 3) && l <= GenVars.lavaLine + 2 - 20 - genRand.Next(-2, 3) && (k < beachDistance + 200 - 20 - genRand.Next(-2, 3) || k > Main.maxTilesX - beachDistance - 200 + 20 + genRand.Next(-2, 3)))
17582 {
17583 if (Main.tile[k, l].liquid > 0)
17584 {
17585 Main.tile[k, l].honey(honey: false);
17586 Main.tile[k, l].lava(lava: false);
17587 }
17588 if (Main.tile[k, l].type == 59)
17589 {
17590 bool flag = false;
17591 for (int num5 = k - 1; num5 <= k + 1; num5++)
17592 {
17593 for (int num6 = l - 1; num6 <= l + 1; num6++)
17594 {
17595 if (Main.tile[num5, num6].type == 60)
17596 {
17597 flag = true;
17598 }
17599 }
17600 }
17601 if (!flag)
17602 {
17603 if ((double)l < (Main.rockLayer + (double)GenVars.lavaLine) / 2.0)
17604 {
17605 Main.tile[k, l].type = 161;
17606 }
17607 else
17608 {
17609 Main.tile[k, l].type = 147;
17610 }
17611 }
17612 }
17613 }
17614 if (!remixWorldGen)
17615 {
17616 if ((Main.tile[k, l].type == 7 || Main.tile[k, l].type == 166 || Main.tile[k, l].type == 6 || Main.tile[k, l].type == 167) && (double)l > ((double)GenVars.lavaLine + Main.rockLayer * 2.0) / 3.0 + (double)genRand.Next(-2, 3) + 2.0)
17617 {
17618 Main.tile[k, l].type = 0;
17619 }
17620 }
17621 else if (!remixWorldGen && (Main.tile[k, l].type == 123 || Main.tile[k, l].type == 40) && (double)l > ((double)GenVars.lavaLine + Main.rockLayer) / 2.0 + (double)genRand.Next(-2, 3) + 2.0)
17622 {
17623 Main.tile[k, l].type = 1;
17624 }
17625 if (l <= num || (Main.tile[k, l].liquid != 0 && (Main.tile[k, l].lava() || Main.tile[k, l].shimmer())))
17626 {
17627 continue;
17628 }
17629 if (getGoodWorldGen)
17630 {
17631 if (genRand.Next(150) == 0)
17632 {
17633 PlaceTile(k, l, 231, mute: true);
17634 }
17635 }
17636 else if (genRand.Next(25) == 0)
17637 {
17638 PlaceTile(k, l, 231, mute: true);
17639 }
17640 }
17641 }
17642 for (int num7 = 20; num7 < num; num7++)
17643 {
17644 for (int num8 = 20; num8 <= Main.maxTilesX - 20; num8++)
17645 {
17646 Main.tile[num8, num7].honey(honey: false);
17647 if (Main.tile[num8, num7].type == 375)
17648 {
17649 Main.tile[num8, num7].type = 373;
17650 }
17651 if (!remixWorldGen)
17652 {
17653 if (Main.tile[num8, num7].type == 60)
17654 {
17655 Main.tile[num8, num7].type = 2;
17656 if (genRand.Next(2) == 0)
17657 {
17658 GrowTreeWithSettings(num8, num7, GrowTreeSettings.Profiles.VanityTree_Willow);
17659 }
17660 else
17661 {
17662 GrowTreeWithSettings(num8, num7, GrowTreeSettings.Profiles.VanityTree_Sakura);
17663 }
17664 if (!Main.tile[num8, num7 - 1].active())
17665 {
17666 PlaceTile(num8, num7 - 1, 3);
17667 }
17668 }
17669 if (Main.tile[num8, num7].type == 59)
17670 {
17671 Main.tile[num8, num7].type = 0;
17672 }
17673 }
17674 else
17675 {
17676 GrowTree(num8, num7);
17677 }
17678 }
17679 }
17680 }
17681
17682 private static void FinishGetGoodWorld()
17683 {
17684 int num = 0;
17685 for (int i = 20; (double)i < Main.worldSurface; i++)
17686 {
17687 for (int j = 20; j < Main.maxTilesX - 20; j++)
17688 {
17689 if (Main.tile[j, i].active() && TileID.Sets.Clouds[Main.tile[j, i].type])
17690 {
17691 num = i;
17692 break;
17693 }
17694 }
17695 }
17696 byte b = (byte)genRand.Next(13, 25);
17697 for (int k = 0; k < Main.maxTilesX; k++)
17698 {
17699 bool flag = false;
17700 for (int l = 0; l < Main.maxTilesY; l++)
17701 {
17702 if (!Main.tile[k, l].active() || !Main.tileDungeon[Main.tile[k, l].type])
17703 {
17704 continue;
17705 }
17706 if (Main.tile[k, l].type == 44)
17707 {
17708 b = (byte)genRand.Next(13, 15);
17709 if (genRand.Next(2) == 0)
17710 {
17711 b = (byte)genRand.Next(23, 25);
17712 }
17713 }
17714 if (Main.tile[k, l].type == 43)
17715 {
17716 b = (byte)genRand.Next(15, 19);
17717 }
17718 if (Main.tile[k, l].type == 41)
17719 {
17720 b = (byte)genRand.Next(19, 23);
17721 }
17722 }
17723 if (flag)
17724 {
17725 break;
17726 }
17727 }
17728 for (int m = 0; m < Main.maxTilesX; m++)
17729 {
17730 for (int n = 5; n < Main.maxTilesY - 5; n++)
17731 {
17732 if (Main.tile[m, n].active() && (Main.tileDungeon[Main.tile[m, n].type] || TileID.Sets.CrackedBricks[Main.tile[m, n].type]))
17733 {
17734 Main.tile[m, n].color(b);
17735 }
17736 if (Main.wallDungeon[Main.tile[m, n].wall])
17737 {
17738 Main.tile[m, n].wallColor(b);
17739 }
17740 if (Main.tile[m, n].active())
17741 {
17742 bool flag2 = false;
17743 if (Main.tile[m, n].type == 226)
17744 {
17745 flag2 = true;
17746 }
17747 if (Main.tile[m, n].type == 137)
17748 {
17749 int num2 = Main.tile[m, n].frameY / 18;
17750 if (num2 >= 1 && num2 <= 4)
17751 {
17752 flag2 = true;
17753 }
17754 }
17755 if (flag2)
17756 {
17757 Main.tile[m, n].color(17);
17758 }
17759 }
17760 if (Main.tile[m, n].wall == 87)
17761 {
17762 Main.tile[m, n].wallColor(25);
17763 }
17764 if (!Main.tile[m, n].active())
17765 {
17766 continue;
17767 }
17768 if (!remixWorldGen && Main.tile[m, n].type == 57 && genRand.Next(15) == 0)
17769 {
17770 if (Main.tile[m, n - 1].type == 57)
17771 {
17772 Main.tile[m, n].active(active: false);
17773 }
17774 Main.tile[m, n].liquid = byte.MaxValue;
17775 Main.tile[m, n].lava(lava: true);
17776 }
17777 if (n < num && Main.tile[m, n].type == 2)
17778 {
17779 if (crimson)
17780 {
17781 Main.tile[m, n].type = 199;
17782 }
17783 else
17784 {
17785 Main.tile[m, n].type = 23;
17786 }
17787 if (Main.tile[m, n - 1].type == 3)
17788 {
17789 Main.tile[m, n - 1].active(active: false);
17790 }
17791 if (Main.tile[m, n - 1].type == 73)
17792 {
17793 Main.tile[m, n - 1].active(active: false);
17794 }
17795 if (Main.tile[m, n - 1].type == 27)
17796 {
17797 KillTile(m, n - 1);
17798 }
17799 if (Main.tile[m, n - 1].type == 596)
17800 {
17801 KillTile(m, n - 1);
17802 }
17803 if (Main.tile[m, n - 1].type == 616)
17804 {
17805 KillTile(m, n - 1);
17806 }
17807 if (Main.tile[m, n - 1].type == 82)
17808 {
17809 KillTile(m, n - 1);
17810 }
17811 if (Main.tile[m, n - 1].type == 83)
17812 {
17813 KillTile(m, n - 1);
17814 }
17815 if (Main.tile[m, n - 1].type == 186)
17816 {
17817 KillTile(m, n - 1);
17818 }
17819 if (Main.tile[m, n - 1].type == 187)
17820 {
17821 KillTile(m, n - 1);
17822 }
17823 if (Main.tile[m, n - 1].type == 185)
17824 {
17825 KillTile(m, n - 1);
17826 }
17827 if (Main.tile[m, n - 1].type == 227)
17828 {
17829 KillTile(m, n - 1);
17830 }
17831 }
17832 }
17833 }
17834 for (int num3 = 0; num3 < 8000 && Main.chest[num3] != null; num3++)
17835 {
17836 if (genRand.Next(10) != 0 || Main.chest[num3].item[1].stack == 0)
17837 {
17838 continue;
17839 }
17840 for (int num4 = 1; num4 < 40; num4++)
17841 {
17842 if (Main.chest[num3].item[num4].stack == 0)
17843 {
17844 Main.chest[num3].item[num4].SetDefaults(678);
17845 break;
17846 }
17847 }
17848 }
17849 }
17850
17851 private static void FinishNoTraps()
17852 {
17853 Main.tileSolid[138] = false;
17854 for (int i = 50; i < Main.maxTilesX - 50; i++)
17855 {
17856 for (int j = 50; j < Main.maxTilesY - 50; j++)
17857 {
17858 Tile tile = Main.tile[i, j];
17859 if (genRand.Next(5) == 0 && tile.active() && tile.type == 12 && tile.frameX == 0 && tile.frameY == 0)
17860 {
17861 Main.tile[i, j].type = 665;
17862 Main.tile[i, j + 1].type = 665;
17863 Main.tile[i + 1, j].type = 665;
17864 Main.tile[i + 1, j + 1].type = 665;
17865 }
17866 if (i % 2 != 0 || j % 2 != 0 || !Main.tile[i, j].active() || (Main.tile[i, j].type != 105 && (Main.tile[i, j].type != 467 || (Main.tile[i, j].frameX != 144 && Main.tile[i, j].frameX != 162))))
17867 {
17868 continue;
17869 }
17870 bool flag = false;
17871 for (int k = i - 1; k <= i + 1; k++)
17872 {
17873 for (int l = j - 1; l <= j + 1; l++)
17874 {
17875 if (Main.tile[k, l].wire())
17876 {
17877 flag = true;
17878 }
17879 }
17880 }
17881 if (!flag)
17882 {
17883 bool flag2 = false;
17884 int num = 25;
17885 int num2 = -1;
17886 int num3 = -1;
17887 for (int m = 0; m < num * num; m++)
17888 {
17889 num2 = genRand.Next(i - num, i + num + 1);
17890 num3 = genRand.Next(j - num, j + num + 1);
17891 if (Main.tile[num2, num3].wire())
17892 {
17893 flag2 = true;
17894 break;
17895 }
17896 }
17897 if (flag2)
17898 {
17899 int num4 = i;
17900 int num5 = j;
17901 Main.tile[num4, num5].wire(wire: true);
17902 while (num4 != num2)
17903 {
17904 if (num4 < num2)
17905 {
17906 num4++;
17907 }
17908 if (num4 > num2)
17909 {
17910 num4--;
17911 }
17912 Main.tile[num4, num5].wire(wire: true);
17913 }
17914 while (num5 != num3)
17915 {
17916 if (num5 < num3)
17917 {
17918 num5++;
17919 }
17920 if (num5 > num3)
17921 {
17922 num5--;
17923 }
17924 Main.tile[num4, num5].wire(wire: true);
17925 }
17926 }
17927 else if (Main.tile[i, j].type == 105)
17928 {
17929 num = 15;
17930 bool flag3 = false;
17931 for (int n = 0; n < num * num; n++)
17932 {
17933 num2 = i + genRand.Next(-num, num + 1);
17934 num3 = j + genRand.Next(-num, num + 1);
17935 PlaceTile(num2, num3, 135, mute: true, forced: true, -1, genRand.Next(2, 4));
17936 if (Main.tile[num2, num3].type == 135)
17937 {
17938 flag3 = true;
17939 break;
17940 }
17941 }
17942 if (flag3)
17943 {
17944 int num6 = i;
17945 int num7 = j;
17946 Main.tile[num6, num7].wire(wire: true);
17947 while (num6 != num2)
17948 {
17949 if (num6 < num2)
17950 {
17951 num6++;
17952 }
17953 if (num6 > num2)
17954 {
17955 num6--;
17956 }
17957 Main.tile[num6, num7].wire(wire: true);
17958 }
17959 while (num7 != num3)
17960 {
17961 if (num7 < num3)
17962 {
17963 num7++;
17964 }
17965 if (num7 > num3)
17966 {
17967 num7--;
17968 }
17969 Main.tile[num6, num7].wire(wire: true);
17970 }
17971 }
17972 }
17973 }
17974 if (Main.tile[i, j].type == 467)
17975 {
17976 int num8 = 8;
17977 for (int num9 = 0; num9 < num8 * num8; num9++)
17978 {
17979 int num10 = i + genRand.Next(-num8, num8 + 1);
17980 int num11 = j + genRand.Next(-num8, num8 + 1);
17981 if (Main.tile[num10, num11].type != 0 && Main.tile[num10, num11].type != 1 && !TileID.Sets.Ore[Main.tile[num10, num11].type] && Main.tile[num10, num11].type != 59 && Main.tile[num10, num11].type != 151)
17982 {
17983 continue;
17984 }
17985 bool flag4 = true;
17986 for (int num12 = num10 - 1; num12 <= num10 + 1; num12++)
17987 {
17988 for (int num13 = num11 - 1; num13 <= num11 + 1; num13++)
17989 {
17990 if (!SolidTile(num12, num13))
17991 {
17992 flag4 = false;
17993 }
17994 }
17995 }
17996 if (!flag4)
17997 {
17998 continue;
17999 }
18001 tile2.type = 141;
18002 tile2.frameX = (tile2.frameY = 0);
18003 tile2.slope(0);
18004 tile2.halfBrick(halfBrick: false);
18005 TileFrame(num10, num11, resetFrame: true);
18006 if (Main.tile[num10, num11].type != 141)
18007 {
18008 continue;
18009 }
18010 int num14 = i;
18011 int num15 = j;
18012 Main.tile[num14, num15].wire(wire: true);
18013 while (num14 != num10)
18014 {
18015 if (num14 < num10)
18016 {
18017 num14++;
18018 }
18019 if (num14 > num10)
18020 {
18021 num14--;
18022 }
18023 Main.tile[num14, num15].wire(wire: true);
18024 }
18025 while (num15 != num11)
18026 {
18027 if (num15 < num11)
18028 {
18029 num15++;
18030 }
18031 if (num15 > num11)
18032 {
18033 num15--;
18034 }
18035 Main.tile[num14, num15].wire(wire: true);
18036 }
18037 break;
18038 }
18039 }
18040 else
18041 {
18042 j++;
18043 }
18044 }
18045 }
18046 Main.tileSolid[138] = true;
18047 for (int num16 = 0; num16 < 8000 && Main.chest[num16] != null; num16++)
18048 {
18049 if (genRand.Next(20) != 0 || Main.chest[num16].item[1].stack == 0)
18050 {
18051 continue;
18052 }
18053 for (int num17 = 1; num17 < 40; num17++)
18054 {
18055 if (Main.chest[num16].item[num17].stack == 0)
18056 {
18057 Main.chest[num16].item[num17].SetDefaults(5346);
18058 break;
18059 }
18060 }
18061 }
18062 }
18063
18064 private static void FinishDrunkGen()
18065 {
18066 byte color = (byte)genRand.Next(13, 25);
18067 byte b = 16;
18068 for (int i = 0; i < Main.maxTilesX; i++)
18069 {
18070 bool flag = false;
18071 for (int j = 0; j < Main.maxTilesY; j++)
18072 {
18073 if (!Main.tile[i, j].active() || !Main.tileDungeon[Main.tile[i, j].type])
18074 {
18075 continue;
18076 }
18077 if (Main.tile[i, j].type == 44)
18078 {
18079 color = (byte)genRand.Next(13, 15);
18080 if (genRand.Next(2) == 0)
18081 {
18082 color = (byte)genRand.Next(23, 25);
18083 }
18084 }
18085 if (Main.tile[i, j].type == 43)
18086 {
18087 color = (byte)genRand.Next(15, 19);
18088 }
18089 if (Main.tile[i, j].type == 41)
18090 {
18091 color = (byte)genRand.Next(19, 23);
18092 }
18093 }
18094 if (flag)
18095 {
18096 break;
18097 }
18098 }
18099 for (int k = 10; k < Main.maxTilesX - 10; k++)
18100 {
18101 for (int l = 10; l < Main.maxTilesY - 10; l++)
18102 {
18103 if (Main.tile[k, l].active() && (Main.tileDungeon[Main.tile[k, l].type] || TileID.Sets.CrackedBricks[Main.tile[k, l].type]))
18104 {
18105 Main.tile[k, l].color(color);
18106 }
18107 if (Main.wallDungeon[Main.tile[k, l].wall])
18108 {
18109 Main.tile[k, l].wallColor(25);
18110 }
18111 if (Main.tile[k, l].active())
18112 {
18113 if (Main.tile[k, l].type == 60)
18114 {
18115 int num = 1;
18116 for (int m = k - num; m <= k + num; m++)
18117 {
18118 for (int n = l - num; n <= l + num; n++)
18119 {
18120 if (Main.tile[m, n].type == 147 || Main.tile[m, n].type == 161)
18121 {
18122 Main.tile[m, n].type = 59;
18123 }
18124 }
18125 }
18126 }
18127 bool flag2 = false;
18128 if (Main.tile[k, l].type == 226)
18129 {
18130 flag2 = true;
18131 }
18132 if (Main.tile[k, l].type == 137)
18133 {
18134 int num2 = Main.tile[k, l].frameY / 18;
18135 if (num2 >= 1 && num2 <= 4)
18136 {
18137 flag2 = true;
18138 }
18139 }
18140 if (flag2)
18141 {
18142 Main.tile[k, l].color(b);
18143 }
18144 }
18145 if (Main.tile[k, l].wall == 87)
18146 {
18147 Main.tile[k, l].wallColor(b);
18148 }
18149 }
18150 }
18151 for (int num3 = 0; num3 < 8000 && Main.chest[num3] != null; num3++)
18152 {
18153 if (genRand.Next(15) == 0 && Main.chest[num3].item[1].stack != 0)
18154 {
18155 for (int num4 = 1; num4 < 40; num4++)
18156 {
18157 if (Main.chest[num3].item[num4].stack == 0)
18158 {
18159 Main.chest[num3].item[num4].SetDefaults(5001);
18160 break;
18161 }
18162 }
18163 }
18164 if (genRand.Next(30) != 0 || Main.chest[num3].item[1].stack == 0)
18165 {
18166 continue;
18167 }
18168 for (int num5 = 1; num5 < 40; num5++)
18169 {
18170 if (Main.chest[num3].item[num5].stack == 0)
18171 {
18172 Main.chest[num3].item[num5].SetDefaults(678);
18173 break;
18174 }
18175 }
18176 }
18177 }
18178
18179 private static void FinishRemixWorld()
18180 {
18181 for (int i = 25; i < Main.maxTilesX - 25; i++)
18182 {
18183 for (int j = 25; j < Main.maxTilesY - 25; j++)
18184 {
18185 int conversionType = 1;
18186 if (crimson)
18187 {
18188 conversionType = 4;
18189 }
18190 if (notTheBees && (double)j < Main.worldSurface)
18191 {
18192 if (Main.tile[i, j].honey())
18193 {
18194 if (Main.tileLavaDeath[Main.tile[i, j].type])
18195 {
18196 KillTile(i, j);
18197 }
18198 Main.tile[i, j].lava(lava: true);
18199 }
18200 if (Main.tile[i, j].type == 375)
18201 {
18202 Main.tile[i, j].type = 374;
18203 }
18204 if (Main.tile[i, j].type == 230 || Main.tile[i, j].type == 229 || Main.tile[i, j].type == 659 || Main.tile[i, j].type == 56)
18205 {
18206 KillTile(i, j);
18207 }
18208 if (Main.tile[i, j].type == 82 || Main.tile[i, j].type == 83 || Main.tile[i, j].type == 84)
18209 {
18210 TileFrame(i, j);
18211 }
18212 }
18213 if ((double)j < Main.worldSurface + (double)genRand.Next(3))
18214 {
18215 if (drunkWorldGen)
18216 {
18217 if (GenVars.crimsonLeft)
18218 {
18219 if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18220 {
18221 Convert(i, j, 4, 1);
18222 }
18223 else
18224 {
18225 Convert(i, j, 1, 1);
18226 }
18227 }
18228 else if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18229 {
18230 Convert(i, j, 1, 1);
18231 }
18232 else
18233 {
18234 Convert(i, j, 4, 1);
18235 }
18236 }
18237 else
18238 {
18239 Convert(i, j, conversionType, 1);
18240 }
18241 }
18242 if ((double)j < Main.worldSurface - (double)genRand.Next(19, 22) && (Main.tile[i, j].wall == 178 || Main.tile[i, j].wall == 180))
18243 {
18244 Main.tile[i, j].wall = 0;
18245 }
18246 if (Main.tile[i, j].active() && Main.tile[i, j].type == 56)
18247 {
18248 KillTile(i, j);
18249 }
18250 if (Main.tile[i, j].type == 189 || Main.tile[i, j].type == 196 || Main.tile[i, j].type == 202)
18251 {
18252 if (drunkWorldGen)
18253 {
18254 if (GenVars.crimsonLeft)
18255 {
18256 if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18257 {
18258 Main.tile[i, j].type = 195;
18259 }
18260 else
18261 {
18262 Main.tile[i, j].type = 474;
18263 }
18264 }
18265 else if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18266 {
18267 Main.tile[i, j].type = 474;
18268 }
18269 else
18270 {
18271 Main.tile[i, j].type = 195;
18272 }
18273 }
18274 else if (crimson)
18275 {
18276 Main.tile[i, j].type = 195;
18277 }
18278 else
18279 {
18280 Main.tile[i, j].type = 474;
18281 }
18282 }
18283 if (Main.tile[i, j].wall == 73 || Main.tile[i, j].wall == 82)
18284 {
18285 if (drunkWorldGen)
18286 {
18287 if (GenVars.crimsonLeft)
18288 {
18289 if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18290 {
18291 Main.tile[i, j].wall = 77;
18292 }
18293 else
18294 {
18295 Main.tile[i, j].wall = 233;
18296 }
18297 }
18298 else if (i < Main.maxTilesX / 2 + genRand.Next(-2, 3))
18299 {
18300 Main.tile[i, j].wall = 233;
18301 }
18302 else
18303 {
18304 Main.tile[i, j].wall = 77;
18305 }
18306 }
18307 else if (crimson)
18308 {
18309 Main.tile[i, j].wall = 77;
18310 }
18311 else
18312 {
18313 Main.tile[i, j].wall = 233;
18314 }
18315 }
18316 if ((double)j > Main.rockLayer && j < Main.maxTilesY - 350 && Main.tile[i, j].type == 0 && Main.tile[i, j].active() && (!Main.tile[i - 1, j - 1].active() || !SolidTile(i, j - 1) || !Main.tile[i + 1, j - 1].active() || !Main.tile[i - 1, j].active() || !Main.tile[i + 1, j].active() || !Main.tile[i - 1, j + 1].active() || !Main.tile[i, j + 1].active() || !Main.tile[i + 1, j + 1].active()))
18317 {
18318 Main.tile[i, j].type = 2;
18319 }
18320 }
18321 }
18322 Liquid.QuickWater(-2);
18323 int num = (int)((double)Main.maxTilesX * 0.38);
18324 int num2 = (int)((double)Main.maxTilesX * 0.62);
18325 _ = Main.maxTilesY;
18326 int num3 = Main.maxTilesY - 135;
18327 _ = Main.maxTilesY;
18328 for (int k = num; k < num2 + 15; k++)
18329 {
18330 for (int l = Main.maxTilesY - 200; l < num3 + 10; l++)
18331 {
18332 Main.tile[k, l].liquid = 0;
18333 if (Main.tile[k, l].type == 58)
18334 {
18335 Main.tile[k, l].type = 57;
18336 }
18337 }
18338 }
18339 AddTrees(undergroundOnly: true);
18340 for (int m = 0; m < Main.maxTilesX; m++)
18341 {
18342 byte color = 22;
18343 byte color2 = 22;
18344 if (drunkWorldGen)
18345 {
18346 if ((GenVars.crimsonLeft && m < Main.maxTilesX / 2) || (!GenVars.crimsonLeft && m > Main.maxTilesX / 2))
18347 {
18348 color2 = 13;
18349 color = 13;
18350 }
18351 }
18352 else if (crimson)
18353 {
18354 color2 = 13;
18355 color = 13;
18356 }
18357 for (int n = 0; n < Main.maxTilesY; n++)
18358 {
18359 if (Main.tile[m, n].active() && (Main.tileDungeon[Main.tile[m, n].type] || TileID.Sets.CrackedBricks[Main.tile[m, n].type]))
18360 {
18361 Main.tile[m, n].color(color);
18362 }
18363 if (Main.wallDungeon[Main.tile[m, n].wall])
18364 {
18365 Main.tile[m, n].wallColor(25);
18366 if (Main.tile[m, n].type == 19 && Main.tile[m, n].frameY != 180)
18367 {
18368 Main.tile[m, n].color(color);
18369 }
18370 }
18371 if (Main.tile[m, n].active())
18372 {
18373 bool flag = false;
18375 {
18376 if (Main.tile[m, n].type == 191)
18377 {
18378 flag = true;
18379 }
18380 if (Main.tile[m, n].active() && Main.tile[m, n].type == 151)
18381 {
18382 Main.tile[m, n].color(color);
18383 }
18384 }
18385 if (Main.tile[m, n].type == 226)
18386 {
18387 flag = true;
18388 }
18389 if (Main.tile[m, n].type == 137)
18390 {
18391 int num4 = Main.tile[m, n].frameY / 18;
18392 if (num4 >= 1 && num4 <= 4)
18393 {
18394 flag = true;
18395 }
18396 }
18397 if (flag)
18398 {
18399 Main.tile[m, n].color(color2);
18400 }
18401 }
18402 if (Main.tile[m, n].wall == 244)
18403 {
18404 Main.tile[m, n].wallColor(25);
18405 }
18406 if (Main.tile[m, n].wall == 34)
18407 {
18408 Main.tile[m, n].wallColor(25);
18409 }
18410 if (Main.tile[m, n].wall == 87)
18411 {
18412 Main.tile[m, n].wallColor(25);
18413 Main.tile[m, n].color(color2);
18414 }
18415 }
18416 }
18417 double num5 = (double)Main.maxTilesX / 4200.0;
18418 num5 *= (double)genRand.Next(2, 5);
18419 for (int num6 = 0; (double)num6 < num5; num6++)
18420 {
18421 int num7 = genRand.Next((int)((double)Main.maxTilesX * 0.39), (int)((double)Main.maxTilesX * 0.61));
18422 int num8 = genRand.Next(10, 31);
18423 for (int num9 = num7 - num8; num9 <= num7 + num8; num9++)
18424 {
18425 for (int num10 = Main.maxTilesY - 250; num10 < Main.maxTilesY - 25; num10++)
18426 {
18427 if (Main.tile[num9, num10].type == 637)
18428 {
18429 Main.tile[num9, num10].frameX = (short)(18 * Main.rand.Next(6, 11));
18430 }
18431 }
18432 }
18433 }
18434 if (notTheBees)
18435 {
18436 for (int num11 = 3; num11 < Main.maxTilesX - 3; num11++)
18437 {
18438 bool flag2 = true;
18439 for (int num12 = 0; (double)num12 < Main.worldSurface; num12++)
18440 {
18441 if (flag2)
18442 {
18443 if (Main.tile[num11, num12].wall == 86)
18444 {
18445 Main.tile[num11, num12].wall = 0;
18446 }
18447 if (Main.tile[num11, num12].active())
18448 {
18449 flag2 = false;
18450 }
18451 }
18452 else if (Main.tile[num11, num12].wall == 0 && Main.tile[num11, num12 + 1].wall == 0 && Main.tile[num11, num12 + 2].wall == 0 && Main.tile[num11, num12 + 3].wall == 0 && Main.tile[num11, num12 + 4].wall == 0 && Main.tile[num11 - 1, num12].wall == 0 && Main.tile[num11 + 1, num12].wall == 0 && Main.tile[num11 - 2, num12].wall == 0 && Main.tile[num11 + 2, num12].wall == 0 && !Main.tile[num11, num12].active() && !Main.tile[num11, num12 + 1].active() && !Main.tile[num11, num12 + 2].active() && !Main.tile[num11, num12 + 3].active())
18453 {
18454 flag2 = true;
18455 }
18456 }
18457 }
18458 }
18459 Liquid.QuickWater(-2);
18460 for (int num13 = 0; num13 < Main.maxTilesX; num13++)
18461 {
18462 for (int num14 = 0; num14 < Main.maxTilesY; num14++)
18463 {
18464 if (Main.tile[num13, num14].type == 518)
18465 {
18466 CheckLilyPad(num13, num14);
18467 }
18468 }
18469 }
18470 }
18471
18472 public static bool IsItATrap(Tile tile)
18473 {
18474 if (tile.actuator())
18475 {
18476 return true;
18477 }
18478 if (tile.active() && TileID.Sets.IsAMechanism[tile.type])
18479 {
18480 return true;
18481 }
18482 return false;
18483 }
18484
18485 public static bool IsItATrigger(Tile tile)
18486 {
18487 if (tile.active())
18488 {
18489 if (TileID.Sets.IsATrigger[tile.type])
18490 {
18491 return true;
18492 }
18493 if (tile.type == 467 && tile.frameX / 36 == 4)
18494 {
18495 return true;
18496 }
18497 if (tile.type == 314 && Minecart.IsPressurePlate(tile))
18498 {
18499 return true;
18500 }
18501 }
18502 return false;
18503 }
18504
18505 public static void ClearAllBrokenTraps()
18506 {
18508 for (int i = 50; i < Main.maxTilesX - 50; i++)
18509 {
18510 for (int j = 50; j < Main.maxTilesY - 50; j++)
18511 {
18512 if (Main.tile[i, j].wire() && !list.Contains(new Point(i, j)))
18513 {
18514 ClearBrokenTraps(new Point(i, j), list);
18515 }
18516 }
18517 }
18518 }
18519
18521 {
18522 List<Point> t = new List<Point>();
18523 List<Point> t2 = new List<Point>();
18525 bool flag = false;
18526 bool flag2 = false;
18528 while (t2.Count > 0)
18529 {
18530 Utils.Swap(ref t, ref t2);
18531 while (t.Count > 0)
18532 {
18533 Point item = t[0];
18534 t.RemoveAt(0);
18535 if (!InWorld(item.X, item.Y, 5))
18536 {
18537 continue;
18538 }
18539 Tile tile = Main.tile[item.X, item.Y];
18540 if (tile.wire())
18541 {
18543 list.Add(item);
18544 if (IsItATrap(tile))
18545 {
18546 flag = true;
18547 }
18548 if (IsItATrigger(tile))
18549 {
18550 flag2 = true;
18551 }
18552 if (flag2 && flag)
18553 {
18554 break;
18555 }
18556 Point item2 = new Point(item.X - 1, item.Y);
18557 if (!list.Contains(item2))
18558 {
18559 t2.Add(item2);
18560 }
18561 item2 = new Point(item.X + 1, item.Y);
18562 if (!list.Contains(item2))
18563 {
18564 t2.Add(item2);
18565 }
18566 item2 = new Point(item.X, item.Y - 1);
18567 if (!list.Contains(item2))
18568 {
18569 t2.Add(item2);
18570 }
18571 item2 = new Point(item.X, item.Y + 1);
18572 if (!list.Contains(item2))
18573 {
18574 t2.Add(item2);
18575 }
18576 }
18577 }
18578 if (flag2 && flag)
18579 {
18580 break;
18581 }
18582 }
18583 if (flag2 && flag)
18584 {
18585 return;
18586 }
18587 foreach (Point item3 in list)
18588 {
18589 Tile tile2 = Main.tile[item3.X, item3.Y];
18590 tile2.wire(wire: false);
18591 if (IsItATrap(tile2))
18592 {
18593 if (tile2.actuator())
18594 {
18595 Main.tile[item3.X, item3.Y].actuator(actuator: false);
18596 }
18597 else if (tile2.type != 105)
18598 {
18599 KillTile(item3.X, item3.Y);
18600 }
18601 }
18602 else if (IsItATrigger(tile2))
18603 {
18604 if (tile2.type == 314)
18605 {
18606 tile2.frameX = 1;
18607 }
18608 else
18609 {
18610 KillTile(item3.X, item3.Y);
18611 }
18612 }
18613 }
18614 }
18615
18616 private static double TuneOceanDepth(int count, double depth, bool floridaStyle = false)
18617 {
18618 if (!floridaStyle)
18619 {
18620 if (count < 3)
18621 {
18622 depth += (double)genRand.Next(10, 20) * 0.2;
18623 }
18624 else if (count < 6)
18625 {
18626 depth += (double)genRand.Next(10, 20) * 0.15;
18627 }
18628 else if (count < 9)
18629 {
18630 depth += (double)genRand.Next(10, 20) * 0.1;
18631 }
18632 else if (count < 15)
18633 {
18634 depth += (double)genRand.Next(10, 20) * 0.07;
18635 }
18636 else if (count < 50)
18637 {
18638 depth += (double)genRand.Next(10, 20) * 0.05;
18639 }
18640 else if (count < 75)
18641 {
18642 depth += (double)genRand.Next(10, 20) * 0.04;
18643 }
18644 else if (count < 100)
18645 {
18646 depth += (double)genRand.Next(10, 20) * 0.03;
18647 }
18648 else if (count < 125)
18649 {
18650 depth += (double)genRand.Next(10, 20) * 0.02;
18651 }
18652 else if (count < 150)
18653 {
18654 depth += (double)genRand.Next(10, 20) * 0.01;
18655 }
18656 else if (count < 175)
18657 {
18658 depth += (double)genRand.Next(10, 20) * 0.005;
18659 }
18660 else if (count < 200)
18661 {
18662 depth += (double)genRand.Next(10, 20) * 0.001;
18663 }
18664 else if (count < 230)
18665 {
18666 depth += (double)genRand.Next(10, 20) * 0.01;
18667 }
18668 else if (count < 235)
18669 {
18670 depth += (double)genRand.Next(10, 20) * 0.05;
18671 }
18672 else if (count < 240)
18673 {
18674 depth += (double)genRand.Next(10, 20) * 0.1;
18675 }
18676 else if (count < 245)
18677 {
18678 depth += (double)genRand.Next(10, 20) * 0.05;
18679 }
18680 else if (count < 255)
18681 {
18682 depth += (double)genRand.Next(10, 20) * 0.01;
18683 }
18684 }
18685 else if (count < 3)
18686 {
18687 depth += (double)genRand.Next(10, 20) * 0.001;
18688 }
18689 else if (count < 6)
18690 {
18691 depth += (double)genRand.Next(10, 20) * 0.002;
18692 }
18693 else if (count < 9)
18694 {
18695 depth += (double)genRand.Next(10, 20) * 0.004;
18696 }
18697 else if (count < 15)
18698 {
18699 depth += (double)genRand.Next(10, 20) * 0.007;
18700 }
18701 else if (count < 50)
18702 {
18703 depth += (double)genRand.Next(10, 20) * 0.01;
18704 }
18705 else if (count < 75)
18706 {
18707 depth += (double)genRand.Next(10, 20) * 0.014;
18708 }
18709 else if (count < 100)
18710 {
18711 depth += (double)genRand.Next(10, 20) * 0.019;
18712 }
18713 else if (count < 125)
18714 {
18715 depth += (double)genRand.Next(10, 20) * 0.027;
18716 }
18717 else if (count < 150)
18718 {
18719 depth += (double)genRand.Next(10, 20) * 0.038;
18720 }
18721 else if (count < 175)
18722 {
18723 depth += (double)genRand.Next(10, 20) * 0.052;
18724 }
18725 else if (count < 200)
18726 {
18727 depth += (double)genRand.Next(10, 20) * 0.08;
18728 }
18729 else if (count < 230)
18730 {
18731 depth += (double)genRand.Next(10, 20) * 0.12;
18732 }
18733 else if (count < 235)
18734 {
18735 depth += (double)genRand.Next(10, 20) * 0.16;
18736 }
18737 else if (count < 240)
18738 {
18739 depth += (double)genRand.Next(10, 20) * 0.27;
18740 }
18741 else if (count < 245)
18742 {
18743 depth += (double)genRand.Next(10, 20) * 0.43;
18744 }
18745 else if (count < 255)
18746 {
18747 depth += (double)genRand.Next(10, 20) * 0.6;
18748 }
18749 return depth;
18750 }
18751
18753 {
18754 _postGenActions.Enqueue(action);
18755 }
18756
18757 public static void ConsumePostGenActions(StructureMap structures)
18758 {
18759 while (_postGenActions.Count > 0)
18760 {
18761 _postGenActions.Dequeue()(structures);
18762 }
18763 }
18764
18766 {
18767 return new Point(genRand.Next(rectangle.X, rectangle.X + rectangle.Width), genRand.Next(rectangle.Y, rectangle.Y + rectangle.Height));
18768 }
18769
18770 public static Point RandomRectanglePoint(int x, int y, int width, int height)
18771 {
18772 return new Point(genRand.Next(x, x + width), genRand.Next(y, y + height));
18773 }
18774
18775 public static Point RandomWorldPoint(int padding)
18776 {
18777 return RandomWorldPoint(padding, padding, padding, padding);
18778 }
18779
18780 public static Point RandomWorldPoint(int top = 0, int right = 0, int bottom = 0, int left = 0)
18781 {
18782 return new Point(genRand.Next(left, Main.maxTilesX - right), genRand.Next(top, Main.maxTilesY - bottom));
18783 }
18784
18785 public static bool GrowPalmTree(int i, int y)
18786 {
18787 int num = y;
18788 if (!InWorld(i, y))
18789 {
18790 return false;
18791 }
18792 while (Main.tile[i, num].type == 20)
18793 {
18794 num++;
18795 if (Main.tile[i, num] == null)
18796 {
18797 return false;
18798 }
18799 }
18800 Tile tile = Main.tile[i, num];
18801 Tile tile2 = Main.tile[i, num - 1];
18802 byte color = 0;
18803 if (Main.tenthAnniversaryWorld && !gen)
18804 {
18805 color = (byte)genRand.Next(1, 13);
18806 }
18807 tile.slope();
18808 tile.halfBrick();
18809 if (!tile.active() || tile.halfBrick() || tile.slope() != 0)
18810 {
18811 return false;
18812 }
18813 if (tile2.wall != 0 || tile2.liquid != 0)
18814 {
18815 return false;
18816 }
18817 if (tile.type != 53 && tile.type != 234 && tile.type != 116 && tile.type != 112)
18818 {
18819 return false;
18820 }
18821 if (!EmptyTileCheck(i, i, num - 2, num - 1, 20))
18822 {
18823 return false;
18824 }
18825 if (!EmptyTileCheck(i - 1, i + 1, num - 30, num - 3, 20))
18826 {
18827 return false;
18828 }
18829 int num2 = genRand.Next(10, 21);
18830 int num3 = genRand.Next(-8, 9);
18831 num3 *= 2;
18832 short num4 = 0;
18833 for (int j = 0; j < num2; j++)
18834 {
18835 tile = Main.tile[i, num - 1 - j];
18836 if (j == 0)
18837 {
18838 tile.active(active: true);
18839 tile.type = 323;
18840 tile.frameX = 66;
18841 tile.frameY = 0;
18842 tile.color(color);
18843 continue;
18844 }
18845 if (j == num2 - 1)
18846 {
18847 tile.active(active: true);
18848 tile.type = 323;
18849 tile.frameX = (short)(22 * genRand.Next(4, 7));
18850 tile.frameY = num4;
18851 tile.color(color);
18852 continue;
18853 }
18854 if (num4 != num3)
18855 {
18856 double num5 = (double)j / (double)num2;
18857 bool flag = false;
18858 if (!(num5 < 0.25) && ((num5 < 0.5 && genRand.Next(13) == 0) || (num5 < 0.7 && genRand.Next(9) == 0) || !(num5 < 0.95) || genRand.Next(5) != 0 || true))
18859 {
18860 short num6 = (short)Math.Sign(num3);
18861 num4 += (short)(num6 * 2);
18862 }
18863 }
18864 tile.active(active: true);
18865 tile.type = 323;
18866 tile.frameX = (short)(22 * genRand.Next(0, 3));
18867 tile.frameY = num4;
18868 tile.color(color);
18869 }
18870 RangeFrame(i - 2, num - num2 - 1, i + 2, num + 1);
18871 NetMessage.SendTileSquare(-1, i, num - num2, 1, num2);
18872 return true;
18873 }
18874
18875 public static bool IsPalmOasisTree(int x)
18876 {
18877 if (x >= beachDistance)
18878 {
18879 return x <= Main.maxTilesX - beachDistance;
18880 }
18881 return false;
18882 }
18883
18884 public static bool GrowEpicTree(int i, int y)
18885 {
18886 int j;
18887 for (j = y; Main.tile[i, j].type == 20; j++)
18888 {
18889 }
18890 if (Main.tile[i, j].active() && !Main.tile[i, j].halfBrick() && Main.tile[i, j].slope() == 0 && Main.tile[i, j].type == 2 && Main.tile[i, j - 1].wall == 0 && Main.tile[i, j - 1].liquid == 0 && ((Main.tile[i - 1, j].active() && (Main.tile[i - 1, j].type == 2 || Main.tile[i - 1, j].type == 23 || Main.tile[i - 1, j].type == 60 || Main.tile[i - 1, j].type == 109)) || (Main.tile[i + 1, j].active() && (Main.tile[i + 1, j].type == 2 || Main.tile[i + 1, j].type == 23 || Main.tile[i + 1, j].type == 60 || Main.tile[i + 1, j].type == 109))))
18891 {
18892 int num = 2;
18893 if (EmptyTileCheck(i - num, i + num, j - 55, j - 1, 20))
18894 {
18895 bool flag = false;
18896 bool flag2 = false;
18897 int num2 = genRand.Next(20, 30);
18898 if (drunkWorldGen)
18899 {
18900 num2 = genRand.Next(3, 7);
18901 }
18902 int num3;
18903 for (int k = j - num2; k < j; k++)
18904 {
18905 Main.tile[i, k].frameNumber((byte)genRand.Next(3));
18906 Main.tile[i, k].active(active: true);
18907 Main.tile[i, k].type = 5;
18908 num3 = genRand.Next(3);
18909 int num4 = genRand.Next(10);
18910 if (k == j - 1 || k == j - num2)
18911 {
18912 num4 = 0;
18913 }
18914 while (((num4 == 5 || num4 == 7) && flag) || ((num4 == 6 || num4 == 7) && flag2))
18915 {
18916 num4 = genRand.Next(10);
18917 }
18918 flag = false;
18919 flag2 = false;
18920 if (num4 == 5 || num4 == 7)
18921 {
18922 flag = true;
18923 }
18924 if (num4 == 6 || num4 == 7)
18925 {
18926 flag2 = true;
18927 }
18928 switch (num4)
18929 {
18930 case 1:
18931 if (num3 == 0)
18932 {
18933 Main.tile[i, k].frameX = 0;
18934 Main.tile[i, k].frameY = 66;
18935 }
18936 if (num3 == 1)
18937 {
18938 Main.tile[i, k].frameX = 0;
18939 Main.tile[i, k].frameY = 88;
18940 }
18941 if (num3 == 2)
18942 {
18943 Main.tile[i, k].frameX = 0;
18944 Main.tile[i, k].frameY = 110;
18945 }
18946 break;
18947 case 2:
18948 if (num3 == 0)
18949 {
18950 Main.tile[i, k].frameX = 22;
18951 Main.tile[i, k].frameY = 0;
18952 }
18953 if (num3 == 1)
18954 {
18955 Main.tile[i, k].frameX = 22;
18956 Main.tile[i, k].frameY = 22;
18957 }
18958 if (num3 == 2)
18959 {
18960 Main.tile[i, k].frameX = 22;
18961 Main.tile[i, k].frameY = 44;
18962 }
18963 break;
18964 case 3:
18965 if (num3 == 0)
18966 {
18967 Main.tile[i, k].frameX = 44;
18968 Main.tile[i, k].frameY = 66;
18969 }
18970 if (num3 == 1)
18971 {
18972 Main.tile[i, k].frameX = 44;
18973 Main.tile[i, k].frameY = 88;
18974 }
18975 if (num3 == 2)
18976 {
18977 Main.tile[i, k].frameX = 44;
18978 Main.tile[i, k].frameY = 110;
18979 }
18980 break;
18981 case 4:
18982 if (num3 == 0)
18983 {
18984 Main.tile[i, k].frameX = 22;
18985 Main.tile[i, k].frameY = 66;
18986 }
18987 if (num3 == 1)
18988 {
18989 Main.tile[i, k].frameX = 22;
18990 Main.tile[i, k].frameY = 88;
18991 }
18992 if (num3 == 2)
18993 {
18994 Main.tile[i, k].frameX = 22;
18995 Main.tile[i, k].frameY = 110;
18996 }
18997 break;
18998 case 5:
18999 if (num3 == 0)
19000 {
19001 Main.tile[i, k].frameX = 88;
19002 Main.tile[i, k].frameY = 0;
19003 }
19004 if (num3 == 1)
19005 {
19006 Main.tile[i, k].frameX = 88;
19007 Main.tile[i, k].frameY = 22;
19008 }
19009 if (num3 == 2)
19010 {
19011 Main.tile[i, k].frameX = 88;
19012 Main.tile[i, k].frameY = 44;
19013 }
19014 break;
19015 case 6:
19016 if (num3 == 0)
19017 {
19018 Main.tile[i, k].frameX = 66;
19019 Main.tile[i, k].frameY = 66;
19020 }
19021 if (num3 == 1)
19022 {
19023 Main.tile[i, k].frameX = 66;
19024 Main.tile[i, k].frameY = 88;
19025 }
19026 if (num3 == 2)
19027 {
19028 Main.tile[i, k].frameX = 66;
19029 Main.tile[i, k].frameY = 110;
19030 }
19031 break;
19032 case 7:
19033 if (num3 == 0)
19034 {
19035 Main.tile[i, k].frameX = 110;
19036 Main.tile[i, k].frameY = 66;
19037 }
19038 if (num3 == 1)
19039 {
19040 Main.tile[i, k].frameX = 110;
19041 Main.tile[i, k].frameY = 88;
19042 }
19043 if (num3 == 2)
19044 {
19045 Main.tile[i, k].frameX = 110;
19046 Main.tile[i, k].frameY = 110;
19047 }
19048 break;
19049 default:
19050 if (num3 == 0)
19051 {
19052 Main.tile[i, k].frameX = 0;
19053 Main.tile[i, k].frameY = 0;
19054 }
19055 if (num3 == 1)
19056 {
19057 Main.tile[i, k].frameX = 0;
19058 Main.tile[i, k].frameY = 22;
19059 }
19060 if (num3 == 2)
19061 {
19062 Main.tile[i, k].frameX = 0;
19063 Main.tile[i, k].frameY = 44;
19064 }
19065 break;
19066 }
19067 if (num4 == 5 || num4 == 7)
19068 {
19069 Main.tile[i - 1, k].active(active: true);
19070 Main.tile[i - 1, k].type = 5;
19071 num3 = genRand.Next(3);
19072 if (genRand.Next(3) < 2)
19073 {
19074 if (num3 == 0)
19075 {
19076 Main.tile[i - 1, k].frameX = 44;
19077 Main.tile[i - 1, k].frameY = 198;
19078 }
19079 if (num3 == 1)
19080 {
19081 Main.tile[i - 1, k].frameX = 44;
19082 Main.tile[i - 1, k].frameY = 220;
19083 }
19084 if (num3 == 2)
19085 {
19086 Main.tile[i - 1, k].frameX = 44;
19087 Main.tile[i - 1, k].frameY = 242;
19088 }
19089 }
19090 else
19091 {
19092 if (num3 == 0)
19093 {
19094 Main.tile[i - 1, k].frameX = 66;
19095 Main.tile[i - 1, k].frameY = 0;
19096 }
19097 if (num3 == 1)
19098 {
19099 Main.tile[i - 1, k].frameX = 66;
19100 Main.tile[i - 1, k].frameY = 22;
19101 }
19102 if (num3 == 2)
19103 {
19104 Main.tile[i - 1, k].frameX = 66;
19105 Main.tile[i - 1, k].frameY = 44;
19106 }
19107 }
19108 }
19109 if (num4 != 6 && num4 != 7)
19110 {
19111 continue;
19112 }
19113 Main.tile[i + 1, k].active(active: true);
19114 Main.tile[i + 1, k].type = 5;
19115 num3 = genRand.Next(3);
19116 if (genRand.Next(3) < 2)
19117 {
19118 if (num3 == 0)
19119 {
19120 Main.tile[i + 1, k].frameX = 66;
19121 Main.tile[i + 1, k].frameY = 198;
19122 }
19123 if (num3 == 1)
19124 {
19125 Main.tile[i + 1, k].frameX = 66;
19126 Main.tile[i + 1, k].frameY = 220;
19127 }
19128 if (num3 == 2)
19129 {
19130 Main.tile[i + 1, k].frameX = 66;
19131 Main.tile[i + 1, k].frameY = 242;
19132 }
19133 }
19134 else
19135 {
19136 if (num3 == 0)
19137 {
19138 Main.tile[i + 1, k].frameX = 88;
19139 Main.tile[i + 1, k].frameY = 66;
19140 }
19141 if (num3 == 1)
19142 {
19143 Main.tile[i + 1, k].frameX = 88;
19144 Main.tile[i + 1, k].frameY = 88;
19145 }
19146 if (num3 == 2)
19147 {
19148 Main.tile[i + 1, k].frameX = 88;
19149 Main.tile[i + 1, k].frameY = 110;
19150 }
19151 }
19152 }
19153 int num5 = genRand.Next(3);
19154 bool flag3 = false;
19155 bool flag4 = false;
19156 if (Main.tile[i - 1, j].active() && !Main.tile[i - 1, j].halfBrick() && Main.tile[i - 1, j].slope() == 0 && (Main.tile[i - 1, j].type == 2 || Main.tile[i - 1, j].type == 23 || Main.tile[i - 1, j].type == 60 || Main.tile[i - 1, j].type == 109))
19157 {
19158 flag3 = true;
19159 }
19160 if (Main.tile[i + 1, j].active() && !Main.tile[i + 1, j].halfBrick() && Main.tile[i + 1, j].slope() == 0 && (Main.tile[i + 1, j].type == 2 || Main.tile[i + 1, j].type == 23 || Main.tile[i + 1, j].type == 60 || Main.tile[i + 1, j].type == 109))
19161 {
19162 flag4 = true;
19163 }
19164 if (!flag3)
19165 {
19166 if (num5 == 0)
19167 {
19168 num5 = 2;
19169 }
19170 if (num5 == 1)
19171 {
19172 num5 = 3;
19173 }
19174 }
19175 if (!flag4)
19176 {
19177 if (num5 == 0)
19178 {
19179 num5 = 1;
19180 }
19181 if (num5 == 2)
19182 {
19183 num5 = 3;
19184 }
19185 }
19186 if (flag3 && !flag4)
19187 {
19188 num5 = 2;
19189 }
19190 if (flag4 && !flag3)
19191 {
19192 num5 = 1;
19193 }
19194 if (num5 == 0 || num5 == 1)
19195 {
19196 Main.tile[i + 1, j - 1].active(active: true);
19197 Main.tile[i + 1, j - 1].type = 5;
19198 num3 = genRand.Next(3);
19199 if (num3 == 0)
19200 {
19201 Main.tile[i + 1, j - 1].frameX = 22;
19202 Main.tile[i + 1, j - 1].frameY = 132;
19203 }
19204 if (num3 == 1)
19205 {
19206 Main.tile[i + 1, j - 1].frameX = 22;
19207 Main.tile[i + 1, j - 1].frameY = 154;
19208 }
19209 if (num3 == 2)
19210 {
19211 Main.tile[i + 1, j - 1].frameX = 22;
19212 Main.tile[i + 1, j - 1].frameY = 176;
19213 }
19214 }
19215 if (num5 == 0 || num5 == 2)
19216 {
19217 Main.tile[i - 1, j - 1].active(active: true);
19218 Main.tile[i - 1, j - 1].type = 5;
19219 num3 = genRand.Next(3);
19220 if (num3 == 0)
19221 {
19222 Main.tile[i - 1, j - 1].frameX = 44;
19223 Main.tile[i - 1, j - 1].frameY = 132;
19224 }
19225 if (num3 == 1)
19226 {
19227 Main.tile[i - 1, j - 1].frameX = 44;
19228 Main.tile[i - 1, j - 1].frameY = 154;
19229 }
19230 if (num3 == 2)
19231 {
19232 Main.tile[i - 1, j - 1].frameX = 44;
19233 Main.tile[i - 1, j - 1].frameY = 176;
19234 }
19235 }
19236 num3 = genRand.Next(3);
19237 switch (num5)
19238 {
19239 case 0:
19240 if (num3 == 0)
19241 {
19242 Main.tile[i, j - 1].frameX = 88;
19243 Main.tile[i, j - 1].frameY = 132;
19244 }
19245 if (num3 == 1)
19246 {
19247 Main.tile[i, j - 1].frameX = 88;
19248 Main.tile[i, j - 1].frameY = 154;
19249 }
19250 if (num3 == 2)
19251 {
19252 Main.tile[i, j - 1].frameX = 88;
19253 Main.tile[i, j - 1].frameY = 176;
19254 }
19255 break;
19256 case 1:
19257 if (num3 == 0)
19258 {
19259 Main.tile[i, j - 1].frameX = 0;
19260 Main.tile[i, j - 1].frameY = 132;
19261 }
19262 if (num3 == 1)
19263 {
19264 Main.tile[i, j - 1].frameX = 0;
19265 Main.tile[i, j - 1].frameY = 154;
19266 }
19267 if (num3 == 2)
19268 {
19269 Main.tile[i, j - 1].frameX = 0;
19270 Main.tile[i, j - 1].frameY = 176;
19271 }
19272 break;
19273 case 2:
19274 if (num3 == 0)
19275 {
19276 Main.tile[i, j - 1].frameX = 66;
19277 Main.tile[i, j - 1].frameY = 132;
19278 }
19279 if (num3 == 1)
19280 {
19281 Main.tile[i, j - 1].frameX = 66;
19282 Main.tile[i, j - 1].frameY = 154;
19283 }
19284 if (num3 == 2)
19285 {
19286 Main.tile[i, j - 1].frameX = 66;
19287 Main.tile[i, j - 1].frameY = 176;
19288 }
19289 break;
19290 }
19291 if (genRand.Next(13) != 0)
19292 {
19293 num3 = genRand.Next(3);
19294 if (num3 == 0)
19295 {
19296 Main.tile[i, j - num2].frameX = 22;
19297 Main.tile[i, j - num2].frameY = 198;
19298 }
19299 if (num3 == 1)
19300 {
19301 Main.tile[i, j - num2].frameX = 22;
19302 Main.tile[i, j - num2].frameY = 220;
19303 }
19304 if (num3 == 2)
19305 {
19306 Main.tile[i, j - num2].frameX = 22;
19307 Main.tile[i, j - num2].frameY = 242;
19308 }
19309 }
19310 else
19311 {
19312 num3 = genRand.Next(3);
19313 if (num3 == 0)
19314 {
19315 Main.tile[i, j - num2].frameX = 0;
19316 Main.tile[i, j - num2].frameY = 198;
19317 }
19318 if (num3 == 1)
19319 {
19320 Main.tile[i, j - num2].frameX = 0;
19321 Main.tile[i, j - num2].frameY = 220;
19322 }
19323 if (num3 == 2)
19324 {
19325 Main.tile[i, j - num2].frameX = 0;
19326 Main.tile[i, j - num2].frameY = 242;
19327 }
19328 }
19329 RangeFrame(i - 2, j - num2 - 1, i + 2, j + 1);
19330 if (Main.netMode == 2)
19331 {
19332 NetMessage.SendTileSquare(-1, i, (int)((double)j - (double)num2 * 0.5), num2 + 1);
19333 }
19334 return true;
19335 }
19336 }
19337 return false;
19338 }
19339
19340 public static bool Pyramid(int i, int j)
19341 {
19342 ushort num = 151;
19343 if (Main.tile[i, j].type == 151 || Main.tile[i, j].wall == 151)
19344 {
19345 return false;
19346 }
19347 int num2 = j - genRand.Next(0, 7);
19348 int num3 = genRand.Next(9, 13);
19349 int num4 = 1;
19350 int num5 = j + genRand.Next(75, 125);
19351 for (int k = num2; k < num5; k++)
19352 {
19353 for (int l = i - num4; l < i + num4 - 1; l++)
19354 {
19355 Main.tile[l, k].type = num;
19356 Main.tile[l, k].active(active: true);
19357 Main.tile[l, k].halfBrick(halfBrick: false);
19358 Main.tile[l, k].slope(0);
19359 }
19360 num4++;
19361 }
19362 for (int m = i - num4 - 5; m <= i + num4 + 5; m++)
19363 {
19364 for (int n = j - 1; n <= num5 + 1; n++)
19365 {
19366 bool flag = true;
19367 for (int num6 = m - 1; num6 <= m + 1; num6++)
19368 {
19369 for (int num7 = n - 1; num7 <= n + 1; num7++)
19370 {
19371 if (Main.tile[num6, num7].type != num)
19372 {
19373 flag = false;
19374 }
19375 }
19376 }
19377 if (flag)
19378 {
19379 Main.tile[m, n].wall = 34;
19380 SquareWallFrame(m, n);
19381 }
19382 }
19383 }
19384 int num8 = 1;
19385 if (genRand.Next(2) == 0)
19386 {
19387 num8 = -1;
19388 }
19389 int num9 = i - num3 * num8;
19390 int num10 = j + num3;
19391 int num11 = genRand.Next(5, 8);
19392 bool flag2 = true;
19393 int num12 = genRand.Next(20, 30);
19394 while (flag2)
19395 {
19396 flag2 = false;
19397 bool flag3 = false;
19398 for (int num13 = num10; num13 <= num10 + num11; num13++)
19399 {
19400 int num14 = num9;
19401 if (Main.tile[num14, num13 - 1].type == 53)
19402 {
19403 flag3 = true;
19404 }
19405 if (Main.tile[num14, num13].type == num)
19406 {
19407 Main.tile[num14, num13 + 1].wall = 34;
19408 Main.tile[num14 + num8, num13].wall = 34;
19409 Main.tile[num14, num13].active(active: false);
19410 flag2 = true;
19411 }
19412 if (flag3)
19413 {
19414 Main.tile[num14, num13].type = 53;
19415 Main.tile[num14, num13].active(active: true);
19416 Main.tile[num14, num13].halfBrick(halfBrick: false);
19417 Main.tile[num14, num13].slope(0);
19418 }
19419 }
19420 num9 -= num8;
19421 }
19422 num9 = i - num3 * num8;
19423 bool flag4 = true;
19424 bool flag5 = false;
19425 flag2 = true;
19426 while (flag2)
19427 {
19428 for (int num15 = num10; num15 <= num10 + num11; num15++)
19429 {
19430 int num16 = num9;
19431 Main.tile[num16, num15].active(active: false);
19432 }
19433 num9 += num8;
19434 num10++;
19435 num12--;
19436 if (num10 >= num5 - num11 * 2)
19437 {
19438 num12 = 10;
19439 }
19440 if (num12 <= 0)
19441 {
19442 bool flag6 = false;
19443 if (!flag4 && !flag5)
19444 {
19445 flag5 = true;
19446 flag6 = true;
19447 int num17 = genRand.Next(7, 13);
19448 int num18 = genRand.Next(23, 28);
19449 int num19 = num18;
19450 int num20 = num9;
19451 while (num18 > 0)
19452 {
19453 for (int num21 = num10 - num17 + num11; num21 <= num10 + num11; num21++)
19454 {
19455 if (num18 == num19 || num18 == 1)
19456 {
19457 if (num21 >= num10 - num17 + num11 + 2)
19458 {
19459 Main.tile[num9, num21].active(active: false);
19460 }
19461 }
19462 else if (num18 == num19 - 1 || num18 == 2 || num18 == num19 - 2 || num18 == 3)
19463 {
19464 if (num21 >= num10 - num17 + num11 + 1)
19465 {
19466 Main.tile[num9, num21].active(active: false);
19467 }
19468 }
19469 else
19470 {
19471 Main.tile[num9, num21].active(active: false);
19472 }
19473 }
19474 num18--;
19475 num9 += num8;
19476 }
19477 int num22 = num9 - num8;
19478 int num23 = num22;
19479 int num24 = num20;
19480 if (num22 > num20)
19481 {
19482 num23 = num20;
19483 num24 = num22;
19484 }
19485 int num25 = genRand.Next(3);
19486 if (num25 == 0)
19487 {
19488 num25 = genRand.Next(3);
19489 }
19490 if (Main.tenthAnniversaryWorld && num25 == 0)
19491 {
19492 num25 = 1;
19493 }
19494 switch (num25)
19495 {
19496 case 0:
19497 num25 = 848;
19498 break;
19499 case 1:
19500 num25 = 857;
19501 break;
19502 case 2:
19503 num25 = 934;
19504 break;
19505 }
19506 AddBuriedChest((num23 + num24) / 2, num10, num25, notNearOtherChests: false, 1, trySlope: false, 0);
19507 int num26 = genRand.Next(1, 10);
19508 for (int num27 = 0; num27 < num26; num27++)
19509 {
19510 int i2 = genRand.Next(num23, num24);
19511 int j2 = num10 + num11;
19512 PlaceSmallPile(i2, j2, genRand.Next(16, 19), 1, 185);
19513 }
19514 PlaceTile(num23 + 2, num10 - num17 + num11 + 1, 91, mute: true, forced: false, -1, genRand.Next(4, 7));
19515 PlaceTile(num23 + 3, num10 - num17 + num11, 91, mute: true, forced: false, -1, genRand.Next(4, 7));
19516 PlaceTile(num24 - 2, num10 - num17 + num11 + 1, 91, mute: true, forced: false, -1, genRand.Next(4, 7));
19517 PlaceTile(num24 - 3, num10 - num17 + num11, 91, mute: true, forced: false, -1, genRand.Next(4, 7));
19518 for (int num28 = num23; num28 <= num24; num28++)
19519 {
19520 PlacePot(num28, num10 + num11, 28, genRand.Next(25, 28));
19521 }
19522 }
19523 if (flag4)
19524 {
19525 flag4 = false;
19526 num8 *= -1;
19527 num12 = genRand.Next(15, 20);
19528 }
19529 else if (flag6)
19530 {
19531 num12 = genRand.Next(10, 15);
19532 }
19533 else
19534 {
19535 num8 *= -1;
19536 num12 = genRand.Next(20, 40);
19537 }
19538 }
19539 if (num10 >= num5 - num11)
19540 {
19541 flag2 = false;
19542 }
19543 }
19544 int num29 = genRand.Next(100, 200);
19545 int num30 = genRand.Next(500, 800);
19546 flag2 = true;
19547 int num31 = num11;
19548 num12 = genRand.Next(10, 50);
19549 if (num8 == 1)
19550 {
19551 num9 -= num31;
19552 }
19553 int num32 = genRand.Next(5, 10);
19554 while (flag2)
19555 {
19556 num29--;
19557 num30--;
19558 num12--;
19559 for (int num33 = num9 - num32 - genRand.Next(0, 2); num33 <= num9 + num31 + num32 + genRand.Next(0, 2); num33++)
19560 {
19561 int num34 = num10;
19562 if (num33 >= num9 && num33 <= num9 + num31)
19563 {
19564 Main.tile[num33, num34].active(active: false);
19565 }
19566 else
19567 {
19568 Main.tile[num33, num34].type = num;
19569 Main.tile[num33, num34].active(active: true);
19570 Main.tile[num33, num34].halfBrick(halfBrick: false);
19571 Main.tile[num33, num34].slope(0);
19572 }
19573 if (num33 >= num9 - 1 && num33 <= num9 + 1 + num31)
19574 {
19575 Main.tile[num33, num34].wall = 34;
19576 }
19577 }
19578 num10++;
19579 num9 += num8;
19580 if (num29 <= 0)
19581 {
19582 flag2 = false;
19583 for (int num35 = num9 + 1; num35 <= num9 + num31 - 1; num35++)
19584 {
19585 if (Main.tile[num35, num10].active())
19586 {
19587 flag2 = true;
19588 }
19589 }
19590 }
19591 if (num12 < 0)
19592 {
19593 num12 = genRand.Next(10, 50);
19594 num8 *= -1;
19595 }
19596 if (num30 <= 0)
19597 {
19598 flag2 = false;
19599 }
19600 }
19601 return true;
19602 }
19603
19604 public static bool GrowLivingTree(int i, int j, bool patch = false)
19605 {
19606 //IL_0d1f: Unknown result type (might be due to invalid IL or missing references)
19607 //IL_0d2a: Unknown result type (might be due to invalid IL or missing references)
19608 //IL_0d2f: Unknown result type (might be due to invalid IL or missing references)
19609 //IL_0d34: Unknown result type (might be due to invalid IL or missing references)
19610 int num = 0;
19611 int[] array = new int[1000];
19612 int[] array2 = new int[1000];
19613 int[] array3 = new int[1000];
19614 int[] array4 = new int[1000];
19615 int num2 = 0;
19616 int[] array5 = new int[2000];
19617 int[] array6 = new int[2000];
19618 bool[] array7 = new bool[2000];
19619 if (!SolidTile(i, j + 1))
19620 {
19621 return false;
19622 }
19623 if (Main.tile[i, j].active())
19624 {
19625 return false;
19626 }
19627 if (Main.tile[i, j + 1].type != 0 && Main.tile[i, j + 1].type != 2 && Main.tile[i, j + 1].type != 1 && Main.tile[i, j + 1].type != 40 && !TileID.Sets.Ore[Main.tile[i, j + 1].type] && (!remixWorldGen || !notTheBees || (Main.tile[i, j + 1].type != 60 && Main.tile[i, j + 1].type != 59)))
19628 {
19629 return false;
19630 }
19631 if (j < 150)
19632 {
19633 return false;
19634 }
19635 int num3 = i - genRand.Next(2, 3);
19636 int num4 = i + genRand.Next(2, 3);
19637 if (genRand.Next(5) == 0)
19638 {
19639 if (genRand.Next(2) == 0)
19640 {
19641 num3--;
19642 }
19643 else
19644 {
19645 num4++;
19646 }
19647 }
19648 int num5 = num4 - num3;
19649 bool flag = num5 >= 4;
19650 int num6 = i - 50;
19651 int num7 = i + 50;
19652 if (patch)
19653 {
19654 num6 = i - 20;
19655 num7 = i + 20;
19656 num3 = i - genRand.Next(1, 3);
19657 num4 = i + genRand.Next(1, 3);
19658 flag = num5 >= 4;
19659 }
19660 for (int k = num6; k <= num7; k++)
19661 {
19662 for (int l = 5; l < j - 5; l++)
19663 {
19664 if (Main.tile[k, l].active())
19665 {
19666 if (!patch)
19667 {
19668 return false;
19669 }
19670 int type = Main.tile[k, l].type;
19671 if (type != 2 && type != 0 && type != 1 && type != 191 && type != 192)
19672 {
19673 return false;
19674 }
19675 }
19676 }
19677 }
19678 int num8 = num3;
19679 int num9 = num4;
19680 int minl = num3;
19681 int minr = num4;
19682 bool flag2 = true;
19683 int num10 = genRand.Next(-8, -4);
19684 int num11 = genRand.Next(2);
19685 int num12 = j;
19686 int num13 = genRand.Next(5, 15);
19687 Main.tileSolid[48] = false;
19688 while (flag2)
19689 {
19690 num10++;
19691 if (num10 > num13)
19692 {
19693 num13 = genRand.Next(5, 15);
19694 num10 = 0;
19695 array2[num] = num12 + genRand.Next(5);
19696 if (genRand.Next(5) == 0)
19697 {
19698 num11 = ((num11 == 0) ? 1 : 0);
19699 }
19700 if (num11 == 0)
19701 {
19702 array3[num] = -1;
19703 array[num] = num3;
19704 array4[num] = num4 - num3;
19705 if (genRand.Next(2) == 0)
19706 {
19707 num3++;
19708 }
19709 num8++;
19710 num11 = 1;
19711 }
19712 else
19713 {
19714 array3[num] = 1;
19715 array[num] = num4;
19716 array4[num] = num4 - num3;
19717 if (genRand.Next(2) == 0)
19718 {
19719 num4--;
19720 }
19721 num9--;
19722 num11 = 0;
19723 }
19724 if (num8 == num9)
19725 {
19726 flag2 = false;
19727 }
19728 num++;
19729 }
19730 for (int m = num3; m <= num4; m++)
19731 {
19732 Main.tile[m, num12].type = 191;
19733 Main.tile[m, num12].active(active: true);
19734 Main.tile[m, num12].halfBrick(halfBrick: false);
19735 }
19736 num12--;
19737 }
19738 for (int n = 0; n < num - 1; n++)
19739 {
19740 int num14 = array[n] + array3[n];
19741 int num15 = array2[n];
19742 int num16 = (int)((double)array4[n] * (1.0 + (double)genRand.Next(20, 30) * 0.1));
19743 Main.tile[num14, num15 + 1].type = 191;
19744 Main.tile[num14, num15 + 1].active(active: true);
19745 Main.tile[num14, num15 + 1].halfBrick(halfBrick: false);
19746 int num17 = genRand.Next(3, 5);
19747 while (num16 > 0)
19748 {
19749 num16--;
19750 Main.tile[num14, num15].type = 191;
19751 Main.tile[num14, num15].active(active: true);
19752 Main.tile[num14, num15].halfBrick(halfBrick: false);
19753 if (genRand.Next(10) == 0)
19754 {
19755 num15 = ((genRand.Next(2) != 0) ? (num15 + 1) : (num15 - 1));
19756 }
19757 else
19758 {
19759 num14 += array3[n];
19760 }
19761 if (num17 > 0)
19762 {
19763 num17--;
19764 }
19765 else if (genRand.Next(2) == 0)
19766 {
19767 num17 = genRand.Next(2, 5);
19768 if (genRand.Next(2) == 0)
19769 {
19770 Main.tile[num14, num15].type = 191;
19771 Main.tile[num14, num15].active(active: true);
19772 Main.tile[num14, num15].halfBrick(halfBrick: false);
19773 Main.tile[num14, num15 - 1].type = 191;
19774 Main.tile[num14, num15 - 1].active(active: true);
19775 Main.tile[num14, num15 - 1].halfBrick(halfBrick: false);
19776 array5[num2] = num14;
19777 array6[num2] = num15;
19778 num2++;
19779 }
19780 else
19781 {
19782 Main.tile[num14, num15].type = 191;
19783 Main.tile[num14, num15].active(active: true);
19784 Main.tile[num14, num15].halfBrick(halfBrick: false);
19785 Main.tile[num14, num15 + 1].type = 191;
19786 Main.tile[num14, num15 + 1].active(active: true);
19787 Main.tile[num14, num15 + 1].halfBrick(halfBrick: false);
19788 array5[num2] = num14;
19789 array6[num2] = num15;
19790 num2++;
19791 }
19792 }
19793 if (num16 == 0)
19794 {
19795 array5[num2] = num14;
19796 array6[num2] = num15;
19797 num2++;
19798 }
19799 }
19800 }
19801 int num18 = (num3 + num4) / 2;
19802 int num19 = num12;
19803 int num20 = genRand.Next(num5 * 3, num5 * 5);
19804 int num21 = 0;
19805 int num22 = 0;
19806 while (num20 > 0)
19807 {
19808 Main.tile[num18, num19].type = 191;
19809 Main.tile[num18, num19].active(active: true);
19810 Main.tile[num18, num19].halfBrick(halfBrick: false);
19811 if (num21 > 0)
19812 {
19813 num21--;
19814 }
19815 if (num22 > 0)
19816 {
19817 num22--;
19818 }
19819 for (int num23 = -1; num23 < 2; num23++)
19820 {
19821 if (num23 == 0 || ((num23 >= 0 || num21 != 0) && (num23 <= 0 || num22 != 0)) || genRand.Next(2) != 0)
19822 {
19823 continue;
19824 }
19825 int num24 = num18;
19826 int num25 = num19;
19827 int num26 = genRand.Next(num5, num5 * 3);
19828 if (num23 < 0)
19829 {
19830 num21 = genRand.Next(3, 5);
19831 }
19832 if (num23 > 0)
19833 {
19834 num22 = genRand.Next(3, 5);
19835 }
19836 int num27 = 0;
19837 while (num26 > 0)
19838 {
19839 num26--;
19840 num24 += num23;
19841 Main.tile[num24, num25].type = 191;
19842 Main.tile[num24, num25].active(active: true);
19843 Main.tile[num24, num25].halfBrick(halfBrick: false);
19844 if (num26 == 0)
19845 {
19846 array5[num2] = num24;
19847 array6[num2] = num25;
19848 array7[num2] = true;
19849 num2++;
19850 }
19851 if (genRand.Next(5) == 0)
19852 {
19853 num25 = ((genRand.Next(2) != 0) ? (num25 + 1) : (num25 - 1));
19854 Main.tile[num24, num25].type = 191;
19855 Main.tile[num24, num25].active(active: true);
19856 Main.tile[num24, num25].halfBrick(halfBrick: false);
19857 }
19858 if (num27 > 0)
19859 {
19860 num27--;
19861 }
19862 else if (genRand.Next(3) == 0)
19863 {
19864 num27 = genRand.Next(2, 4);
19865 int num28 = num24;
19866 int num29 = num25;
19867 num29 = ((genRand.Next(2) != 0) ? (num29 + 1) : (num29 - 1));
19868 Main.tile[num28, num29].type = 191;
19869 Main.tile[num28, num29].active(active: true);
19870 Main.tile[num28, num29].halfBrick(halfBrick: false);
19871 array5[num2] = num28;
19872 array6[num2] = num29;
19873 array7[num2] = true;
19874 num2++;
19875 array5[num2] = num28 + genRand.Next(-5, 6);
19876 array6[num2] = num29 + genRand.Next(-5, 6);
19877 array7[num2] = true;
19878 num2++;
19879 }
19880 }
19881 }
19882 array5[num2] = num18;
19883 array6[num2] = num19;
19884 num2++;
19885 if (genRand.Next(4) == 0)
19886 {
19887 num18 = ((genRand.Next(2) != 0) ? (num18 + 1) : (num18 - 1));
19888 Main.tile[num18, num19].type = 191;
19889 Main.tile[num18, num19].active(active: true);
19890 Main.tile[num18, num19].halfBrick(halfBrick: false);
19891 }
19892 num19--;
19893 num20--;
19894 }
19895 for (int num30 = minl; num30 <= minr; num30++)
19896 {
19897 int num31 = genRand.Next(1, 6);
19898 int num32 = j + 1;
19899 while (num31 > 0)
19900 {
19901 if (SolidTile(num30, num32))
19902 {
19903 num31--;
19904 }
19905 Main.tile[num30, num32].type = 191;
19906 Main.tile[num30, num32].active(active: true);
19907 Main.tile[num30, num32].halfBrick(halfBrick: false);
19908 num32++;
19909 }
19910 int num33 = num32;
19911 int num34 = genRand.Next(2, num5 + 1);
19912 for (int num35 = 0; num35 < num34; num35++)
19913 {
19914 num32 = num33;
19915 int num36 = (minl + minr) / 2;
19916 int num37 = 0;
19917 int num38 = 1;
19918 num37 = ((num30 >= num36) ? 1 : (-1));
19919 if (num30 == num36 || (num5 > 6 && (num30 == num36 - 1 || num30 == num36 + 1)))
19920 {
19921 num37 = 0;
19922 }
19923 int num39 = num37;
19924 int num40 = num30;
19925 num31 = genRand.Next((int)((double)num5 * 3.5), num5 * 6);
19926 while (num31 > 0)
19927 {
19928 num31--;
19929 num40 += num37;
19930 if (Main.tile[num40, num32].wall != 244)
19931 {
19932 Main.tile[num40, num32].type = 191;
19933 Main.tile[num40, num32].active(active: true);
19934 Main.tile[num40, num32].halfBrick(halfBrick: false);
19935 }
19936 num32 += num38;
19937 if (Main.tile[num40, num32].wall != 244)
19938 {
19939 Main.tile[num40, num32].type = 191;
19940 Main.tile[num40, num32].active(active: true);
19941 Main.tile[num40, num32].halfBrick(halfBrick: false);
19942 }
19943 if (!Main.tile[num40, num32 + 1].active())
19944 {
19945 num37 = 0;
19946 num38 = 1;
19947 }
19948 if (genRand.Next(3) == 0)
19949 {
19950 num37 = ((num39 < 0) ? ((num37 == 0) ? (-1) : 0) : ((num39 <= 0) ? genRand.Next(-1, 2) : ((num37 == 0) ? 1 : 0)));
19951 }
19952 if (genRand.Next(3) == 0)
19953 {
19954 num38 = ((num38 == 0) ? 1 : 0);
19955 }
19956 }
19957 }
19958 }
19959 if (remixWorldGen)
19960 {
19961 num2 = 0;
19962 }
19963 for (int num41 = 0; num41 < num2; num41++)
19964 {
19965 int num42 = genRand.Next(5, 8);
19966 num42 = (int)((double)num42 * (1.0 + (double)num5 * 0.05));
19967 if (array7[num41])
19968 {
19969 num42 = genRand.Next(6, 12) + num5;
19970 }
19971 int num43 = array5[num41] - num42 * 2;
19972 int num44 = array5[num41] + num42 * 2;
19973 int num45 = array6[num41] - num42 * 2;
19974 int num46 = array6[num41] + num42 * 2;
19975 double num47 = 2.0 - (double)genRand.Next(5) * 0.1;
19976 for (int num48 = num43; num48 <= num44; num48++)
19977 {
19978 for (int num49 = num45; num49 <= num46; num49++)
19979 {
19980 if (Main.tile[num48, num49].type == 191)
19981 {
19982 continue;
19983 }
19984 if (array7[num41])
19985 {
19986 Vector2D val = new Vector2D((double)array5[num41], (double)array6[num41]) - new Vector2D((double)num48, (double)num49);
19987 if (((Vector2D)(ref val)).Length() < (double)num42 * 0.9)
19988 {
19989 Main.tile[num48, num49].type = 192;
19990 Main.tile[num48, num49].active(active: true);
19991 Main.tile[num48, num49].halfBrick(halfBrick: false);
19992 }
19993 }
19994 else if ((double)Math.Abs(array5[num41] - num48) + (double)Math.Abs(array6[num41] - num49) * num47 < (double)num42)
19995 {
19996 Main.tile[num48, num49].type = 192;
19997 Main.tile[num48, num49].active(active: true);
19998 Main.tile[num48, num49].halfBrick(halfBrick: false);
19999 }
20000 }
20001 if (genRand.Next(30) == 0)
20002 {
20003 int num50 = num45;
20004 if (!Main.tile[num48, num50].active())
20005 {
20006 for (; !Main.tile[num48, num50 + 1].active() && num50 < num46; num50++)
20007 {
20008 }
20009 if (Main.tile[num48, num50 + 1].type == 192)
20010 {
20011 PlaceTile(num48, num50, 187, mute: true, forced: false, -1, genRand.Next(50, 52));
20012 }
20013 }
20014 }
20015 if (array7[num41] || genRand.Next(15) != 0)
20016 {
20017 continue;
20018 }
20019 int num51 = num46;
20020 int num52 = num51 + 100;
20021 if (Main.tile[num48, num51].active())
20022 {
20023 continue;
20024 }
20025 for (; !Main.tile[num48, num51 + 1].active() && num51 < num52; num51++)
20026 {
20027 }
20028 if (Main.tile[num48, num51 + 1].type == 192)
20029 {
20030 continue;
20031 }
20032 if (genRand.Next(2) == 0)
20033 {
20034 PlaceTile(num48, num51, 187, mute: true, forced: false, -1, genRand.Next(47, 50));
20035 continue;
20036 }
20037 int num53 = genRand.Next(2);
20038 int x = 72;
20039 if (num53 == 1)
20040 {
20041 x = genRand.Next(59, 62);
20042 }
20043 PlaceSmallPile(num48, num51, x, num53, 185);
20044 }
20045 }
20046 if (flag)
20047 {
20048 bool flag3 = false;
20049 for (int num54 = j; num54 < j + 20 && !((double)num54 >= Main.worldSurface - 2.0); num54++)
20050 {
20051 for (int num55 = minl; num55 <= minr; num55++)
20052 {
20053 if (Main.tile[num55, num54].wall == 0 && !SolidTile(num55, num54))
20054 {
20055 flag3 = true;
20056 }
20057 }
20058 }
20059 if (!flag3)
20060 {
20061 GrowLivingTree_MakePassage(j, num5, ref minl, ref minr, patch);
20062 }
20063 }
20064 Main.tileSolid[48] = true;
20065 return true;
20066 }
20067
20068 public static bool GrowDungeonTree(int i, int j, bool patch = false)
20069 {
20070 //IL_0d08: Unknown result type (might be due to invalid IL or missing references)
20071 //IL_0d13: Unknown result type (might be due to invalid IL or missing references)
20072 //IL_0d18: Unknown result type (might be due to invalid IL or missing references)
20073 //IL_0d1d: Unknown result type (might be due to invalid IL or missing references)
20074 int num = 0;
20075 int[] array = new int[1000];
20076 int[] array2 = new int[1000];
20077 int[] array3 = new int[1000];
20078 int[] array4 = new int[1000];
20079 int num2 = 0;
20080 int[] array5 = new int[2000];
20081 int[] array6 = new int[2000];
20082 bool[] array7 = new bool[2000];
20083 int num3 = i - genRand.Next(2, 3);
20084 int num4 = i + genRand.Next(2, 3);
20085 if (genRand.Next(5) == 0)
20086 {
20087 if (genRand.Next(2) == 0)
20088 {
20089 num3--;
20090 }
20091 else
20092 {
20093 num4++;
20094 }
20095 }
20096 int num5 = num4 - num3;
20097 int num6 = num3;
20098 int num7 = num4;
20099 int minl = num3;
20100 int minr = num4;
20101 bool flag = true;
20102 int num8 = genRand.Next(-8, -4);
20103 int num9 = genRand.Next(2);
20104 int num10 = j;
20105 int num11 = genRand.Next(5, 15);
20106 Main.tileSolid[48] = false;
20107 while (flag)
20108 {
20109 num8++;
20110 if (num8 > num11)
20111 {
20112 num11 = genRand.Next(5, 15);
20113 num8 = 0;
20114 array2[num] = num10 + genRand.Next(5);
20115 if (genRand.Next(5) == 0)
20116 {
20117 num9 = ((num9 == 0) ? 1 : 0);
20118 }
20119 if (num9 == 0)
20120 {
20121 array3[num] = -1;
20122 array[num] = num3;
20123 array4[num] = num4 - num3;
20124 if (genRand.Next(2) == 0)
20125 {
20126 num3++;
20127 }
20128 num6++;
20129 num9 = 1;
20130 }
20131 else
20132 {
20133 array3[num] = 1;
20134 array[num] = num4;
20135 array4[num] = num4 - num3;
20136 if (genRand.Next(2) == 0)
20137 {
20138 num4--;
20139 }
20140 num7--;
20141 num9 = 0;
20142 }
20143 if (num6 == num7)
20144 {
20145 flag = false;
20146 }
20147 num++;
20148 }
20149 for (int k = num3; k <= num4; k++)
20150 {
20151 Main.tile[k, num10].type = 191;
20152 Main.tile[k, num10].active(active: true);
20153 Main.tile[k, num10].halfBrick(halfBrick: false);
20154 Main.tile[k, num10].slope(0);
20155 Main.tile[k, num10].color(28);
20156 }
20157 num10--;
20158 }
20159 for (int l = 0; l < num - 1; l++)
20160 {
20161 int num12 = array[l] + array3[l];
20162 int num13 = array2[l];
20163 int num14 = (int)((double)array4[l] * (1.0 + (double)genRand.Next(20, 30) * 0.1));
20164 Main.tile[num12, num13 + 1].type = 191;
20165 Main.tile[num12, num13 + 1].active(active: true);
20166 Main.tile[num12, num13 + 1].halfBrick(halfBrick: false);
20167 Main.tile[num12, num13 + 1].color(28);
20168 int num15 = genRand.Next(3, 5);
20169 while (num14 > 0)
20170 {
20171 num14--;
20172 Main.tile[num12, num13].type = 191;
20173 Main.tile[num12, num13].active(active: true);
20174 Main.tile[num12, num13].halfBrick(halfBrick: false);
20175 Main.tile[num12, num13].color(28);
20176 Main.tile[num12, num13].slope(0);
20177 if (genRand.Next(10) == 0)
20178 {
20179 num13 = ((genRand.Next(2) != 0) ? (num13 + 1) : (num13 - 1));
20180 }
20181 else
20182 {
20183 num12 += array3[l];
20184 }
20185 if (num15 > 0)
20186 {
20187 num15--;
20188 }
20189 else if (genRand.Next(2) == 0)
20190 {
20191 num15 = genRand.Next(2, 5);
20192 if (genRand.Next(2) == 0)
20193 {
20194 Main.tile[num12, num13].type = 191;
20195 Main.tile[num12, num13].active(active: true);
20196 Main.tile[num12, num13].halfBrick(halfBrick: false);
20197 Main.tile[num12, num13].color(28);
20198 Main.tile[num12, num13].slope(0);
20199 Main.tile[num12, num13 - 1].type = 191;
20200 Main.tile[num12, num13 - 1].active(active: true);
20201 Main.tile[num12, num13 - 1].halfBrick(halfBrick: false);
20202 Main.tile[num12, num13 - 1].color(28);
20203 array5[num2] = num12;
20204 array6[num2] = num13;
20205 num2++;
20206 }
20207 else
20208 {
20209 Main.tile[num12, num13].type = 191;
20210 Main.tile[num12, num13].active(active: true);
20211 Main.tile[num12, num13].halfBrick(halfBrick: false);
20212 Main.tile[num12, num13].color(28);
20213 Main.tile[num12, num13].slope(0);
20214 Main.tile[num12, num13 + 1].type = 191;
20215 Main.tile[num12, num13 + 1].active(active: true);
20216 Main.tile[num12, num13 + 1].halfBrick(halfBrick: false);
20217 Main.tile[num12, num13 + 1].color(28);
20218 array5[num2] = num12;
20219 array6[num2] = num13;
20220 num2++;
20221 }
20222 }
20223 if (num14 == 0)
20224 {
20225 array5[num2] = num12;
20226 array6[num2] = num13;
20227 num2++;
20228 }
20229 }
20230 }
20231 int num16 = (num3 + num4) / 2;
20232 int num17 = num10;
20233 int num18 = genRand.Next(num5 * 3, num5 * 5);
20234 int num19 = 0;
20235 int num20 = 0;
20236 while (num18 > 0)
20237 {
20238 Main.tile[num16, num17].type = 191;
20239 Main.tile[num16, num17].active(active: true);
20240 Main.tile[num16, num17].halfBrick(halfBrick: false);
20241 Main.tile[num16, num17].color(28);
20242 if (num19 > 0)
20243 {
20244 num19--;
20245 }
20246 if (num20 > 0)
20247 {
20248 num20--;
20249 }
20250 for (int m = -1; m < 2; m++)
20251 {
20252 if (m == 0 || ((m >= 0 || num19 != 0) && (m <= 0 || num20 != 0)) || genRand.Next(2) != 0)
20253 {
20254 continue;
20255 }
20256 int num21 = num16;
20257 int num22 = num17;
20258 int num23 = genRand.Next(num5, num5 * 3);
20259 if (m < 0)
20260 {
20261 num19 = genRand.Next(3, 5);
20262 }
20263 if (m > 0)
20264 {
20265 num20 = genRand.Next(3, 5);
20266 }
20267 int num24 = 0;
20268 while (num23 > 0)
20269 {
20270 num23--;
20271 num21 += m;
20272 Main.tile[num21, num22].type = 191;
20273 Main.tile[num21, num22].active(active: true);
20274 Main.tile[num21, num22].halfBrick(halfBrick: false);
20275 Main.tile[num21, num22].color(28);
20276 if (num23 == 0)
20277 {
20278 array5[num2] = num21;
20279 array6[num2] = num22;
20280 array7[num2] = true;
20281 num2++;
20282 }
20283 if (genRand.Next(5) == 0)
20284 {
20285 num22 = ((genRand.Next(2) != 0) ? (num22 + 1) : (num22 - 1));
20286 Main.tile[num21, num22].type = 191;
20287 Main.tile[num21, num22].active(active: true);
20288 Main.tile[num21, num22].halfBrick(halfBrick: false);
20289 Main.tile[num21, num22].color(28);
20290 }
20291 if (num24 > 0)
20292 {
20293 num24--;
20294 }
20295 else if (genRand.Next(3) == 0)
20296 {
20297 num24 = genRand.Next(2, 4);
20298 int num25 = num21;
20299 int num26 = num22;
20300 num26 = ((genRand.Next(2) != 0) ? (num26 + 1) : (num26 - 1));
20301 Main.tile[num25, num26].type = 191;
20302 Main.tile[num25, num26].active(active: true);
20303 Main.tile[num25, num26].halfBrick(halfBrick: false);
20304 Main.tile[num25, num26].color(28);
20305 array5[num2] = num25;
20306 array6[num2] = num26;
20307 array7[num2] = true;
20308 num2++;
20309 array5[num2] = num25 + genRand.Next(-5, 6);
20310 array6[num2] = num26 + genRand.Next(-5, 6);
20311 array7[num2] = true;
20312 num2++;
20313 }
20314 }
20315 }
20316 array5[num2] = num16;
20317 array6[num2] = num17;
20318 num2++;
20319 if (genRand.Next(4) == 0)
20320 {
20321 num16 = ((genRand.Next(2) != 0) ? (num16 + 1) : (num16 - 1));
20322 Main.tile[num16, num17].type = 191;
20323 Main.tile[num16, num17].active(active: true);
20324 Main.tile[num16, num17].halfBrick(halfBrick: false);
20325 Main.tile[num16, num17].color(28);
20326 }
20327 num17--;
20328 num18--;
20329 }
20330 for (int n = minl; n <= minr; n++)
20331 {
20332 int num27 = genRand.Next(1, 6);
20333 int num28 = j + 1;
20334 while (num27 > 0)
20335 {
20336 if (SolidTile(n, num28))
20337 {
20338 num27--;
20339 }
20340 Main.tile[n, num28].type = 191;
20341 Main.tile[n, num28].active(active: true);
20342 Main.tile[n, num28].halfBrick(halfBrick: false);
20343 Main.tile[n, num28].slope(0);
20344 num28++;
20345 }
20346 int num29 = num28;
20347 int num30 = genRand.Next(2, num5 + 1);
20348 for (int num31 = 0; num31 < num30; num31++)
20349 {
20350 num28 = num29;
20351 int num32 = (minl + minr) / 2;
20352 int num33 = 0;
20353 int num34 = 1;
20354 num33 = ((n >= num32) ? 1 : (-1));
20355 if (n == num32 || (num5 > 6 && (n == num32 - 1 || n == num32 + 1)))
20356 {
20357 num33 = 0;
20358 }
20359 int num35 = num33;
20360 int num36 = n;
20361 num27 = genRand.Next((int)((double)num5 * 3.5), num5 * 6);
20362 while (num27 > 0)
20363 {
20364 num27--;
20365 num36 += num33;
20366 if (Main.tile[num36, num28].wall != 244)
20367 {
20368 Main.tile[num36, num28].type = 191;
20369 Main.tile[num36, num28].active(active: true);
20370 Main.tile[num36, num28].halfBrick(halfBrick: false);
20371 Main.tile[num36, num28].slope(0);
20372 }
20373 num28 += num34;
20374 if (Main.tile[num36, num28].wall != 244)
20375 {
20376 Main.tile[num36, num28].type = 191;
20377 Main.tile[num36, num28].active(active: true);
20378 Main.tile[num36, num28].halfBrick(halfBrick: false);
20379 Main.tile[num36, num28].slope(0);
20380 }
20381 if (!Main.tile[num36, num28 + 1].active())
20382 {
20383 num33 = 0;
20384 num34 = 1;
20385 }
20386 if (genRand.Next(3) == 0)
20387 {
20388 num33 = ((num35 < 0) ? ((num33 == 0) ? (-1) : 0) : ((num35 <= 0) ? genRand.Next(-1, 2) : ((num33 == 0) ? 1 : 0)));
20389 }
20390 if (genRand.Next(3) == 0)
20391 {
20392 num34 = ((num34 == 0) ? 1 : 0);
20393 }
20394 }
20395 }
20396 }
20397 if (!remixWorldGen)
20398 {
20399 for (int num37 = 0; num37 < num2; num37++)
20400 {
20401 int num38 = genRand.Next(5, 8);
20402 num38 = (int)((double)num38 * (1.0 + (double)num5 * 0.05));
20403 if (array7[num37])
20404 {
20405 num38 = genRand.Next(6, 12) + num5;
20406 }
20407 int num39 = array5[num37] - num38 * 2;
20408 int num40 = array5[num37] + num38 * 2;
20409 int num41 = array6[num37] - num38 * 2;
20410 int num42 = array6[num37] + num38 * 2;
20411 double num43 = 2.0 - (double)genRand.Next(5) * 0.1;
20412 for (int num44 = num39; num44 <= num40; num44++)
20413 {
20414 for (int num45 = num41; num45 <= num42; num45++)
20415 {
20416 if (Main.tile[num44, num45].type == 191)
20417 {
20418 continue;
20419 }
20420 if (array7[num37])
20421 {
20422 Vector2D val = new Vector2D((double)array5[num37], (double)array6[num37]) - new Vector2D((double)num44, (double)num45);
20423 if (((Vector2D)(ref val)).Length() < (double)num38 * 0.9)
20424 {
20425 Main.tile[num44, num45].type = 192;
20426 Main.tile[num44, num45].active(active: true);
20427 Main.tile[num44, num45].halfBrick(halfBrick: false);
20428 Main.tile[num44, num45].color(28);
20429 }
20430 }
20431 else if ((double)Math.Abs(array5[num37] - num44) + (double)Math.Abs(array6[num37] - num45) * num43 < (double)num38)
20432 {
20433 Main.tile[num44, num45].type = 192;
20434 Main.tile[num44, num45].active(active: true);
20435 Main.tile[num44, num45].halfBrick(halfBrick: false);
20436 Main.tile[num44, num45].color(28);
20437 }
20438 }
20439 }
20440 }
20441 }
20442 GrowDungeonTree_MakePassage(j, num5, ref minl, ref minr, patch);
20443 Main.tileSolid[48] = true;
20444 return true;
20445 }
20446
20447 private static bool GrowLivingTree_HorizontalTunnel(int i, int j)
20448 {
20449 int num = i;
20450 int num2 = i;
20451 int num3 = 80;
20452 bool flag = false;
20453 int num4 = 1;
20454 if (genRand.Next(2) == 0)
20455 {
20456 num4 *= -1;
20457 }
20458 for (int k = 0; k < 2; k++)
20459 {
20460 flag = false;
20461 if (num == i && num4 > 0)
20462 {
20463 for (int l = i + 5; l < i + num3; l++)
20464 {
20465 if (!InWorld(l, j, 10))
20466 {
20467 return false;
20468 }
20469 if ((double)j < Main.worldSurface)
20470 {
20471 for (int m = j - 7; m <= j + 7 && Main.tile[l, m].wall != 0; m++)
20472 {
20473 }
20474 }
20475 if (Main.tile[l, j].type == 48)
20476 {
20477 flag = true;
20478 break;
20479 }
20480 if (Main.tile[l, j].type == 191)
20481 {
20482 for (int n = j - 2; n <= j; n++)
20483 {
20484 if (Main.tile[l + 2, n].wall != 244)
20485 {
20486 flag = true;
20487 }
20488 }
20489 if (!flag)
20490 {
20491 k = 2;
20492 num2 = l + 2;
20493 }
20494 break;
20495 }
20496 if (Main.tile[l, j].active())
20497 {
20498 continue;
20499 }
20500 bool flag2 = true;
20501 for (int num5 = j - 2; num5 <= j; num5++)
20502 {
20503 if ((double)j < Main.worldSurface + 3.0 && (Main.tile[l + 1, num5].wall == 0 || Main.tile[l + 2, num5].wall == 0 || Main.tile[l + 3, num5].wall == 0))
20504 {
20505 return false;
20506 }
20507 if (Main.tile[l, num5].active() || Main.tile[l + 1, num5].active() || Main.tile[l + 2, num5].active())
20508 {
20509 flag2 = false;
20510 }
20511 }
20512 if (flag2)
20513 {
20514 k = 2;
20515 num2 = l;
20516 break;
20517 }
20518 }
20519 }
20520 flag = false;
20521 if (num2 == i && num4 < 0)
20522 {
20523 for (int num6 = i - 5; num6 > i - num3; num6--)
20524 {
20525 if (!InWorld(num6, j, 10))
20526 {
20527 return false;
20528 }
20529 if ((double)j < Main.worldSurface)
20530 {
20531 for (int num7 = j - 7; num7 <= j + 7 && Main.tile[num6, num7].wall != 0; num7++)
20532 {
20533 }
20534 }
20535 if (Main.tile[num6, j].type == 48)
20536 {
20537 flag = true;
20538 break;
20539 }
20540 if (Main.tile[num6, j].type == 191)
20541 {
20542 for (int num8 = j - 2; num8 <= j; num8++)
20543 {
20544 if (Main.tile[num6 - 3, num8].wall != 244)
20545 {
20546 flag = true;
20547 }
20548 }
20549 if (!flag)
20550 {
20551 k = 2;
20552 num = num6 - 2;
20553 }
20554 break;
20555 }
20556 if (!Main.tile[num6, j].active())
20557 {
20558 bool flag3 = true;
20559 for (int num9 = j - 2; num9 <= j; num9++)
20560 {
20561 if ((double)j < Main.worldSurface + 3.0 && (Main.tile[num6 - 1, num9].wall == 0 || Main.tile[num6 - 2, num9].wall == 0 || Main.tile[num6 - 3, num9].wall == 0))
20562 {
20563 return false;
20564 }
20565 if (Main.tile[num6, num9].active() || Main.tile[num6 - 1, num9].active() || Main.tile[num6 - 2, num9].active())
20566 {
20567 flag3 = false;
20568 }
20569 }
20570 if (flag3)
20571 {
20572 k = 2;
20573 num = num6;
20574 break;
20575 }
20576 }
20577 }
20578 }
20579 num4 *= -1;
20580 }
20581 if (num == num2)
20582 {
20583 return false;
20584 }
20585 bool flag4 = false;
20586 bool flag5 = false;
20587 for (int num10 = j - 5; num10 <= j + 1; num10++)
20588 {
20589 for (int num11 = num; num11 <= num2; num11++)
20590 {
20591 int num12 = 2;
20592 if (Math.Abs(num11 - num2) > 3 && Math.Abs(num11 - num) > 3)
20593 {
20594 num12 = 4;
20595 }
20596 if (Main.tile[num11, num10].wall != 244 && Main.tile[num11, num10].type != 19 && Main.tile[num11, num10].type != 15 && Main.tile[num11, num10].type != 304 && Main.tile[num11, num10].type != 21 && Main.tile[num11, num10].type != 10)
20597 {
20598 if (!Main.wallDungeon[Main.tile[num11, num10].wall] && (!Main.tile[num11, num10].active() || (!Main.wallDungeon[Main.tile[num11, num10 - 1].wall] && !Main.wallDungeon[Main.tile[num11, num10 + 1].wall])))
20599 {
20600 Main.tile[num11, num10].active(active: true);
20601 Main.tile[num11, num10].type = 191;
20602 Main.tile[num11, num10].halfBrick(halfBrick: false);
20603 }
20604 if (Main.tile[num11, num10 - 1].type == 40)
20605 {
20606 Main.tile[num11, num10 - 1].type = 0;
20607 }
20608 if (Main.tile[num11, num10 + 1].type == 40)
20609 {
20610 Main.tile[num11, num10 + 1].type = 0;
20611 }
20612 }
20613 if (num10 >= j - num12 && num10 <= j && Main.tile[num11, num10].type != 19 && Main.tile[num11, num10].type != 15 && Main.tile[num11, num10].type != 304 && Main.tile[num11, num10].type != 21 && Main.tile[num11, num10].type != 10 && Main.tile[num11, num10 - 1].type != 15 && Main.tile[num11, num10 - 1].type != 304 && Main.tile[num11, num10 - 1].type != 21 && Main.tile[num11, num10 - 1].type != 10 && Main.tile[num11, num10 + 1].type != 10)
20614 {
20615 if (!Main.wallDungeon[Main.tile[num11, num10].wall])
20616 {
20617 Main.tile[num11, num10].wall = 244;
20618 }
20619 Main.tile[num11, num10].liquid = 0;
20620 Main.tile[num11, num10].active(active: false);
20621 }
20622 if (num10 != j)
20623 {
20624 continue;
20625 }
20626 int style = 7;
20627 if (Main.wallDungeon[Main.tile[num11, num10].wall] || Main.wallDungeon[Main.tile[num11, num10 - 1].wall] || Main.wallDungeon[Main.tile[num11, num10 - 2].wall])
20628 {
20629 style = 13;
20630 }
20631 if (num11 <= num + 4 && !flag4)
20632 {
20633 if (Main.tile[num11 - 1, num10].type == 10 || Main.tile[num11 + 1, num10].type == 10)
20634 {
20635 flag4 = true;
20636 }
20637 else if (genRand.Next(3) == 0)
20638 {
20639 PlaceTile(num11, num10, 10, mute: true, forced: false, -1, style);
20640 if (Main.tile[num11, num10].type == 10)
20641 {
20642 flag4 = true;
20643 }
20644 }
20645 }
20646 if (num11 < num2 - 4 || flag5)
20647 {
20648 continue;
20649 }
20650 if (Main.tile[num11 - 1, num10].type == 10 || Main.tile[num11 + 1, num10].type == 10)
20651 {
20652 flag5 = true;
20653 }
20654 else if (genRand.Next(3) == 0)
20655 {
20656 PlaceTile(num11, num10, 10, mute: true, forced: false, -1, style);
20657 if (Main.tile[num11, num10].type == 10)
20658 {
20659 flag5 = true;
20660 }
20661 }
20662 }
20663 }
20664 return true;
20665 }
20666
20667 private static void GrowDungeonTree_MakePassage(int j, int W, ref int minl, ref int minr, bool noSecretRoom = false)
20668 {
20669 int num = minl;
20670 int num2 = minr;
20671 _ = (minl + minr) / 2;
20672 int num3 = 5;
20673 int num4 = j - 6;
20674 int num5 = 0;
20675 bool flag = true;
20676 genRand.Next(5, 16);
20677 while (true)
20678 {
20679 num4++;
20680 if (num4 > GenVars.dungeonY - 5)
20681 {
20682 break;
20683 }
20684 int num6 = (minl + minr) / 2;
20685 int num7 = 1;
20686 if (num4 > j && W <= 4)
20687 {
20688 num7++;
20689 }
20690 for (int i = minl - num7; i <= minr + num7; i++)
20691 {
20692 if (i > num6 - 2 && i <= num6 + 1)
20693 {
20694 if (num4 > j - 4)
20695 {
20696 if (Main.tile[i, num4].type != 19 && Main.tile[i, num4].type != 15 && Main.tile[i, num4].type != 304 && Main.tile[i, num4].type != 21 && Main.tile[i, num4].type != 10 && Main.tile[i, num4 - 1].type != 15 && Main.tile[i, num4 - 1].type != 304 && Main.tile[i, num4 - 1].type != 21 && Main.tile[i, num4 - 1].type != 10 && Main.tile[i, num4 + 1].type != 10)
20697 {
20698 Main.tile[i, num4].active(active: false);
20699 }
20700 if (!Main.wallDungeon[Main.tile[i, num4].wall])
20701 {
20702 Main.tile[i, num4].wall = 244;
20703 }
20704 if (!Main.wallDungeon[Main.tile[i - 1, num4].wall] && (Main.tile[i - 1, num4].wall > 0 || (double)num4 >= Main.worldSurface))
20705 {
20706 Main.tile[i - 1, num4].wall = 244;
20707 }
20708 if (!Main.wallDungeon[Main.tile[i + 1, num4].wall] && (Main.tile[i + 1, num4].wall > 0 || (double)num4 >= Main.worldSurface))
20709 {
20710 Main.tile[i + 1, num4].wall = 244;
20711 }
20712 if (num4 == j && i > num6 - 2 && i <= num6 + 1)
20713 {
20714 Main.tile[i, num4 + 1].active(active: false);
20715 PlaceTile(i, num4 + 1, 19, mute: true, forced: false, -1, 23);
20716 }
20717 }
20718 }
20719 else
20720 {
20721 if (Main.tile[i, num4].type != 15 && Main.tile[i, num4].type != 304 && Main.tile[i, num4].type != 21 && Main.tile[i, num4].type != 10 && Main.tile[i - 1, num4].type != 10 && Main.tile[i + 1, num4].type != 10)
20722 {
20723 if (!Main.wallDungeon[Main.tile[i, num4].wall])
20724 {
20725 Main.tile[i, num4].type = 191;
20726 Main.tile[i, num4].active(active: true);
20727 Main.tile[i, num4].halfBrick(halfBrick: false);
20728 }
20729 if (Main.tile[i - 1, num4].type == 40)
20730 {
20731 Main.tile[i - 1, num4].type = 0;
20732 }
20733 if (Main.tile[i + 1, num4].type == 40)
20734 {
20735 Main.tile[i + 1, num4].type = 0;
20736 }
20737 }
20738 if (num4 <= j && num4 > j - 4 && i > minl - num7 && i <= minr + num7 - 1)
20739 {
20740 Main.tile[i, num4].wall = 244;
20741 }
20742 }
20743 if (!gen)
20744 {
20745 SquareTileFrame(i, num4);
20746 SquareWallFrame(i, num4);
20747 }
20748 }
20749 num5++;
20750 if (num5 < 6)
20751 {
20752 continue;
20753 }
20754 num5 = 0;
20755 int num8 = genRand.Next(3);
20756 if (num8 == 0)
20757 {
20758 num8 = -1;
20759 }
20760 if (flag)
20761 {
20762 num8 = 2;
20763 }
20764 if (num8 == -1 && Main.tile[minl - num3, num4].wall == 244)
20765 {
20766 num8 = 1;
20767 }
20768 else if (num8 == 1 && Main.tile[minr + num3, num4].wall == 244)
20769 {
20770 num8 = -1;
20771 }
20772 if (num8 == 2)
20773 {
20774 flag = false;
20775 int num9 = 23;
20776 if (Main.wallDungeon[Main.tile[minl, num4 + 1].wall] || Main.wallDungeon[Main.tile[minl + 1, num4 + 1].wall] || Main.wallDungeon[Main.tile[minl + 2, num4 + 1].wall])
20777 {
20778 num9 = 12;
20779 }
20780 if (!SolidTile(minl - 1, num4 + 1) && !SolidTile(minr + 1, num4 + 1) && num9 == 12)
20781 {
20782 continue;
20783 }
20784 for (int k = minl; k <= minr; k++)
20785 {
20786 if (k > num6 - 2 && k <= num6 + 1)
20787 {
20788 Main.tile[k, num4 + 1].active(active: false);
20789 Main.tile[k, num4 + 1].halfBrick(halfBrick: false);
20790 Main.tile[k, num4 + 1].slope(0);
20791 PlaceTile(k, num4 + 1, 19, mute: true, forced: false, -1, num9);
20792 }
20793 }
20794 }
20795 else
20796 {
20797 minl += num8;
20798 minr += num8;
20799 }
20800 }
20801 minl = num;
20802 minr = num2;
20803 _ = (minl + minr) / 2;
20804 for (int l = minl; l <= minr; l++)
20805 {
20806 for (int m = j - 3; m <= j; m++)
20807 {
20808 Main.tile[l, m].active(active: false);
20809 if (!Main.wallDungeon[Main.tile[l, m].wall])
20810 {
20811 Main.tile[l, m].wall = 244;
20812 }
20813 }
20814 }
20815 }
20816
20817 private static void GrowLivingTree_MakePassage(int j, int W, ref int minl, ref int minr, bool noSecretRoom = false)
20818 {
20819 bool flag = noSecretRoom;
20820 int num = minl;
20821 int num2 = minr;
20822 bool flag2 = false;
20823 _ = (minl + minr) / 2;
20824 int num3 = 5;
20825 int num4 = j - 6;
20826 int num5 = 50;
20827 int num6 = genRand.Next(400, 700);
20828 int num7 = 0;
20829 bool flag3 = true;
20830 int num8 = genRand.Next(5, 16);
20831 while (num6 > 0)
20832 {
20833 num4++;
20834 num6--;
20835 num5--;
20836 int num9 = (minl + minr) / 2;
20837 if (!Main.tile[minl, num4].active() && Main.tile[minl, num4].wall == 244 && !Main.tile[minr, num4].active() && Main.tile[minr, num4].wall == 244)
20838 {
20839 num6 = 0;
20840 break;
20841 }
20842 int num10 = 1;
20843 if (num4 > j && W <= 4)
20844 {
20845 num10++;
20846 }
20847 for (int i = minl - num10; i <= minr + num10; i++)
20848 {
20849 if (Main.wallDungeon[Main.tile[i, num4].wall])
20850 {
20851 flag = true;
20852 flag2 = true;
20853 }
20854 if (i > num9 - 2 && i <= num9 + 1)
20855 {
20856 if (num4 > j - 4)
20857 {
20858 if (Main.tile[i, num4].type != 19 && Main.tile[i, num4].type != 15 && Main.tile[i, num4].type != 304 && Main.tile[i, num4].type != 21 && Main.tile[i, num4].type != 10 && Main.tile[i, num4 - 1].type != 15 && Main.tile[i, num4 - 1].type != 304 && Main.tile[i, num4 - 1].type != 21 && Main.tile[i, num4 - 1].type != 10 && Main.tile[i, num4 + 1].type != 10)
20859 {
20860 Main.tile[i, num4].active(active: false);
20861 }
20862 if (!Main.wallDungeon[Main.tile[i, num4].wall])
20863 {
20864 Main.tile[i, num4].wall = 244;
20865 }
20866 if (!Main.wallDungeon[Main.tile[i - 1, num4].wall] && (Main.tile[i - 1, num4].wall > 0 || (double)num4 >= Main.worldSurface))
20867 {
20868 Main.tile[i - 1, num4].wall = 244;
20869 }
20870 if (!Main.wallDungeon[Main.tile[i + 1, num4].wall] && (Main.tile[i + 1, num4].wall > 0 || (double)num4 >= Main.worldSurface))
20871 {
20872 Main.tile[i + 1, num4].wall = 244;
20873 }
20874 if (num4 == j && i > num9 - 2 && i <= num9 + 1)
20875 {
20876 Main.tile[i, num4 + 1].active(active: false);
20877 PlaceTile(i, num4 + 1, 19, mute: true, forced: false, -1, 23);
20878 }
20879 }
20880 }
20881 else
20882 {
20883 if (Main.tile[i, num4].type != 15 && Main.tile[i, num4].type != 304 && Main.tile[i, num4].type != 21 && Main.tile[i, num4].type != 10 && Main.tile[i - 1, num4].type != 10 && Main.tile[i + 1, num4].type != 10)
20884 {
20885 if (!Main.wallDungeon[Main.tile[i, num4].wall])
20886 {
20887 Main.tile[i, num4].type = 191;
20888 Main.tile[i, num4].active(active: true);
20889 Main.tile[i, num4].halfBrick(halfBrick: false);
20890 }
20891 if (Main.tile[i - 1, num4].type == 40)
20892 {
20893 Main.tile[i - 1, num4].type = 0;
20894 }
20895 if (Main.tile[i + 1, num4].type == 40)
20896 {
20897 Main.tile[i + 1, num4].type = 0;
20898 }
20899 }
20900 if (num4 <= j && num4 > j - 4 && i > minl - num10 && i <= minr + num10 - 1)
20901 {
20902 Main.tile[i, num4].wall = 244;
20903 }
20904 }
20905 if (!gen)
20906 {
20907 SquareTileFrame(i, num4);
20908 SquareWallFrame(i, num4);
20909 }
20910 }
20911 num7++;
20912 if (num7 >= 6)
20913 {
20914 num7 = 0;
20915 int num11 = genRand.Next(3);
20916 if (num11 == 0)
20917 {
20918 num11 = -1;
20919 }
20920 if (flag3)
20921 {
20922 num11 = 2;
20923 }
20924 if (num11 == -1 && Main.tile[minl - num3, num4].wall == 244)
20925 {
20926 num11 = 1;
20927 }
20928 else if (num11 == 1 && Main.tile[minr + num3, num4].wall == 244)
20929 {
20930 num11 = -1;
20931 }
20932 if (num11 == 2)
20933 {
20934 flag3 = false;
20935 int style = 23;
20936 if (Main.wallDungeon[Main.tile[minl, num4 + 1].wall] || Main.wallDungeon[Main.tile[minl + 1, num4 + 1].wall] || Main.wallDungeon[Main.tile[minl + 2, num4 + 1].wall])
20937 {
20938 style = 12;
20939 }
20940 for (int k = minl; k <= minr; k++)
20941 {
20942 if (k > num9 - 2 && k <= num9 + 1)
20943 {
20944 Main.tile[k, num4 + 1].active(active: false);
20945 PlaceTile(k, num4 + 1, 19, mute: true, forced: false, -1, style);
20946 }
20947 }
20948 }
20949 else
20950 {
20951 minl += num11;
20952 minr += num11;
20953 }
20954 if (noSecretRoom)
20955 {
20956 num8--;
20957 if (num8 <= 0)
20958 {
20959 num8 = ((!GrowLivingTree_HorizontalTunnel(num9, num4)) ? genRand.Next(2, 11) : genRand.Next(5, 21));
20960 }
20961 }
20962 if (num5 <= 0 && !flag)
20963 {
20964 flag = true;
20965 GrowLivingTreePassageRoom(minl, minr, num4);
20966 }
20967 }
20968 if (flag2)
20969 {
20970 bool flag4 = true;
20971 for (int l = minl; l <= minr; l++)
20972 {
20973 for (int m = num4 + 1; m <= num4 + 2; m++)
20974 {
20975 if (SolidTile(l, m))
20976 {
20977 flag4 = false;
20978 }
20979 }
20980 }
20981 if (flag4)
20982 {
20983 num6 = 0;
20984 }
20985 }
20986 else
20987 {
20988 if (num5 > 0)
20989 {
20990 continue;
20991 }
20992 bool flag5 = true;
20993 for (int n = minl; n <= minr; n++)
20994 {
20995 for (int num12 = num4 + 1; num12 <= num4 + 4; num12++)
20996 {
20997 if (SolidTile(n, num12))
20998 {
20999 flag5 = false;
21000 }
21001 }
21002 }
21003 if (flag5)
21004 {
21005 num6 = 0;
21006 }
21007 }
21008 }
21009 minl = num;
21010 minr = num2;
21011 _ = (minl + minr) / 2;
21012 for (int num13 = minl; num13 <= minr; num13++)
21013 {
21014 for (int num14 = j - 3; num14 <= j; num14++)
21015 {
21016 Main.tile[num13, num14].active(active: false);
21017 bool flag6 = true;
21018 for (int num15 = num13 - 1; num15 <= num13 + 1; num15++)
21019 {
21020 for (int num16 = num14 - 1; num16 <= num14 + 1; num16++)
21021 {
21022 if (!Main.tile[num15, num16].active() && Main.tile[num15, num16].wall == 0)
21023 {
21024 flag6 = false;
21025 }
21026 }
21027 }
21028 if (flag6 && !Main.wallDungeon[Main.tile[num13, num14].wall])
21029 {
21030 Main.tile[num13, num14].wall = 244;
21031 }
21032 }
21033 }
21034 }
21035
21036 private static void GrowLivingTreePassageRoom(int minl, int minr, int Y)
21037 {
21038 int num = genRand.Next(2);
21039 if (num == 0)
21040 {
21041 num = -1;
21042 }
21043 int num2 = Y - 2;
21044 int num3 = (minl + minr) / 2;
21045 if (num < 0)
21046 {
21047 num3--;
21048 }
21049 if (num > 0)
21050 {
21051 num3++;
21052 }
21053 int num4 = genRand.Next(15, 30);
21054 int num5 = num3 + num4;
21055 if (num < 0)
21056 {
21057 num5 = num3;
21058 num3 -= num4;
21059 }
21060 for (int i = num3; i < num5; i++)
21061 {
21062 for (int j = Y - 20; j < Y + 10; j++)
21063 {
21064 if (Main.tile[i, j].wall == 0 && !Main.tile[i, j].active() && (double)j < Main.worldSurface)
21065 {
21066 return;
21067 }
21068 }
21069 }
21070 GenVars.dMinX = num3;
21071 GenVars.dMaxX = num5;
21072 if (num < 0)
21073 {
21074 GenVars.dMinX -= 40;
21075 }
21076 else
21077 {
21078 GenVars.dMaxX += 40;
21079 }
21080 for (int k = num3; k <= num5; k++)
21081 {
21082 for (int l = num2 - 2; l <= Y + 2; l++)
21083 {
21084 if (Main.tile[k - 1, l].type == 40)
21085 {
21086 Main.tile[k - 1, l].type = 0;
21087 }
21088 if (Main.tile[k + 1, l].type == 40)
21089 {
21090 Main.tile[k + 1, l].type = 0;
21091 }
21092 if (Main.tile[k, l - 1].type == 40)
21093 {
21094 Main.tile[k, l - 1].type = 0;
21095 }
21096 if (Main.tile[k, l + 1].type == 40)
21097 {
21098 Main.tile[k, l + 1].type = 0;
21099 }
21100 if (Main.tile[k, l].wall != 244 && Main.tile[k, l].type != 19)
21101 {
21102 Main.tile[k, l].active(active: true);
21103 Main.tile[k, l].type = 191;
21104 Main.tile[k, l].halfBrick(halfBrick: false);
21105 }
21106 if (l >= num2 && l <= Y)
21107 {
21108 Main.tile[k, l].liquid = 0;
21109 Main.tile[k, l].wall = 244;
21110 Main.tile[k, l].active(active: false);
21111 }
21112 }
21113 }
21114 int i2 = (minl + minr) / 2 + 3 * num;
21115 PlaceTile(i2, Y, 10, mute: true, forced: false, -1, 7);
21116 int num6 = genRand.Next(5, 9);
21117 int num7 = genRand.Next(4, 6);
21118 if (num < 0)
21119 {
21120 num5 = num3 + num6;
21121 num3 -= num6;
21122 }
21123 else
21124 {
21125 num3 = num5 - num6;
21126 num5 += num6;
21127 }
21128 num2 = Y - num7;
21129 for (int m = num3 - 2; m <= num5 + 2; m++)
21130 {
21131 for (int n = num2 - 2; n <= Y + 2; n++)
21132 {
21133 if (Main.tile[m - 1, n].type == 40)
21134 {
21135 Main.tile[m - 1, n].type = 40;
21136 }
21137 if (Main.tile[m + 1, n].type == 40)
21138 {
21139 Main.tile[m + 1, n].type = 40;
21140 }
21141 if (Main.tile[m, n - 1].type == 40)
21142 {
21143 Main.tile[m, n - 1].type = 40;
21144 }
21145 if (Main.tile[m, n + 1].type == 40)
21146 {
21147 Main.tile[m, n + 1].type = 40;
21148 }
21149 if (Main.tile[m, n].wall != 244 && Main.tile[m, n].type != 19)
21150 {
21151 Main.tile[m, n].active(active: true);
21152 Main.tile[m, n].type = 191;
21153 Main.tile[m, n].halfBrick(halfBrick: false);
21154 }
21155 if (n >= num2 && n <= Y && m >= num3 && m <= num5)
21156 {
21157 Main.tile[m, n].liquid = 0;
21158 Main.tile[m, n].wall = 244;
21159 Main.tile[m, n].active(active: false);
21160 }
21161 }
21162 }
21163 i2 = num3 - 2;
21164 if (num < 0)
21165 {
21166 i2 = num5 + 2;
21167 }
21168 PlaceTile(i2, Y, 10, mute: true, forced: false, -1, 7);
21169 int num8 = num5;
21170 if (num < 0)
21171 {
21172 num8 = num3;
21173 }
21174 int num9 = 2;
21175 if (genRand.Next(num9) == 0)
21176 {
21177 num9 += 2;
21178 PlaceTile(num8, Y, 15, mute: true, forced: false, -1, 5);
21179 if (num < 0)
21180 {
21181 Main.tile[num8, Y - 1].frameX += 18;
21182 Main.tile[num8, Y].frameX += 18;
21183 }
21184 }
21185 num8 = num5 - 2;
21186 if (num < 0)
21187 {
21188 num8 = num3 + 2;
21189 }
21190 PlaceTile(num8, Y, 304, mute: true);
21191 num8 = num5 - 4;
21192 if (num < 0)
21193 {
21194 num8 = num3 + 4;
21195 }
21196 if (genRand.Next(num9) == 0)
21197 {
21198 PlaceTile(num8, Y, 15, mute: true, forced: false, -1, 5);
21199 if (num > 0)
21200 {
21201 Main.tile[num8, Y - 1].frameX += 18;
21202 Main.tile[num8, Y].frameX += 18;
21203 }
21204 }
21205 num8 = num5 - 7;
21206 if (num < 0)
21207 {
21208 num8 = num3 + 8;
21209 }
21210 int contain = 832;
21211 if (genRand.Next(3) == 0)
21212 {
21213 contain = 4281;
21214 }
21215 if (remixWorldGen)
21216 {
21217 int num10 = genRand.Next(1, 3);
21218 for (int num11 = 0; num11 < num10; num11++)
21219 {
21220 bool flag = false;
21221 while (!flag)
21222 {
21223 int num12 = genRand.Next(Main.maxTilesX / 8, Main.maxTilesX - Main.maxTilesX / 8);
21224 int num13 = genRand.Next((int)Main.rockLayer, Main.maxTilesY - 350);
21225 if (!IsTileNearby(num12, num13, 53, 20) && !IsTileNearby(num12, num13, 147, 20) && !IsTileNearby(num12, num13, 59, 20))
21226 {
21227 flag = AddBuriedChest(num12, num13, contain, notNearOtherChests: false, 12, trySlope: false, 0);
21228 }
21229 }
21230 }
21231 if (crimson)
21232 {
21233 AddBuriedChest(num8, Y, 0, notNearOtherChests: false, 14, trySlope: false, 0);
21234 }
21235 else
21236 {
21237 AddBuriedChest(num8, Y, 0, notNearOtherChests: false, 7, trySlope: false, 0);
21238 }
21239 }
21240 else
21241 {
21242 AddBuriedChest(num8, Y, contain, notNearOtherChests: false, 12, trySlope: false, 0);
21243 }
21244 }
21245
21246 public static void TreeGrowFXCheck(int x, int y)
21247 {
21248 int treeHeight = 1;
21249 int passStyle = -1;
21250 Tile topTile = null;
21251 for (int num = -1; num > -100; num--)
21252 {
21253 Tile tile = Main.tile[x, y + num];
21254 if (!tile.active() || !TileID.Sets.GetsCheckedForLeaves[tile.type])
21255 {
21256 break;
21257 }
21258 topTile = tile;
21259 treeHeight++;
21260 }
21261 for (int i = 1; i < 5; i++)
21262 {
21263 Tile tile2 = Main.tile[x, y + i];
21264 if (tile2.active() && TileID.Sets.GetsCheckedForLeaves[tile2.type])
21265 {
21266 treeHeight++;
21267 continue;
21268 }
21269 GetTreeLeaf(x, topTile, tile2, ref treeHeight, out var _, out passStyle);
21270 break;
21271 }
21272 if (treeHeight > 0 && passStyle > 0)
21273 {
21274 if (Main.netMode == 2)
21275 {
21276 NetMessage.SendData(112, -1, -1, null, 1, x, y, treeHeight, passStyle);
21277 }
21278 if (Main.netMode == 0)
21279 {
21280 TreeGrowFX(x, y, treeHeight, passStyle);
21281 }
21282 }
21283 }
21284
21285 public static void GetTreeLeaf(int x, Tile topTile, Tile t, ref int treeHeight, out int treeFrame, out int passStyle)
21286 {
21287 treeFrame = 0;
21288 passStyle = -1;
21289 if (topTile.frameX == 22 || topTile.frameX == 44 || topTile.frameX == 66)
21290 {
21291 if (topTile.frameY == 220)
21292 {
21293 treeFrame = 1;
21294 }
21295 else if (topTile.frameY == 242)
21296 {
21297 treeFrame = 2;
21298 }
21299 }
21300 if (topTile.frameX == 44 || topTile.frameX == 66)
21301 {
21302 if (topTile.frameY == 220)
21303 {
21304 treeFrame = 1;
21305 }
21306 else if (topTile.frameY == 242)
21307 {
21308 treeFrame = 2;
21309 }
21310 }
21311 switch (topTile.type)
21312 {
21313 case 596:
21314 passStyle = 1248;
21315 break;
21316 case 616:
21317 passStyle = 1257;
21318 break;
21319 case 634:
21320 passStyle = 1278;
21321 break;
21322 case 583:
21323 case 584:
21324 case 585:
21325 case 586:
21326 case 587:
21327 case 588:
21328 case 589:
21329 passStyle = 1249 + (topTile.type - 583);
21330 break;
21331 }
21332 if (passStyle > -1)
21333 {
21334 return;
21335 }
21336 switch (t.type)
21337 {
21338 case 2:
21339 case 477:
21340 passStyle = 910;
21341 break;
21342 case 60:
21343 passStyle = 914;
21344 break;
21345 case 70:
21346 passStyle = 912;
21347 break;
21348 case 23:
21349 case 112:
21350 passStyle = 915;
21351 break;
21352 case 199:
21353 case 234:
21354 passStyle = 916;
21355 break;
21356 case 53:
21357 passStyle = 911;
21358 break;
21359 case 116:
21360 passStyle = 919;
21361 break;
21362 case 147:
21363 passStyle = 913;
21364 break;
21365 case 633:
21366 passStyle = 1278;
21367 break;
21368 case 109:
21369 case 492:
21370 {
21371 int num = 917;
21372 int hollowTreeFoliageStyle = GetHollowTreeFoliageStyle();
21373 if (hollowTreeFoliageStyle != 20)
21374 {
21375 if (x % 3 == 1)
21376 {
21377 treeFrame += 3;
21378 }
21379 if (x % 3 == 2)
21380 {
21381 treeFrame += 6;
21382 }
21383 switch (treeFrame)
21384 {
21385 case 0:
21386 passStyle = 2;
21387 break;
21388 case 1:
21389 passStyle = 1;
21390 break;
21391 case 2:
21392 passStyle = 7;
21393 break;
21394 case 3:
21395 passStyle = 4;
21396 break;
21397 case 4:
21398 passStyle = 5;
21399 break;
21400 case 5:
21401 passStyle = 6;
21402 break;
21403 case 6:
21404 passStyle = 3;
21405 break;
21406 case 7:
21407 passStyle = 8;
21408 break;
21409 case 8:
21410 passStyle = 0;
21411 break;
21412 }
21413 }
21414 else
21415 {
21416 int num2 = 196;
21417 if (x % 6 == 1)
21418 {
21419 treeFrame += 3;
21420 }
21421 else if (x % 6 == 2)
21422 {
21423 treeFrame += 6;
21424 }
21425 else if (x % 6 == 3)
21426 {
21427 treeFrame += 9;
21428 }
21429 else if (x % 6 == 4)
21430 {
21431 treeFrame += 12;
21432 }
21433 else if (x % 6 == 5)
21434 {
21435 treeFrame += 15;
21436 }
21437 switch (treeFrame)
21438 {
21439 case 0:
21440 passStyle = num2;
21441 break;
21442 case 1:
21443 passStyle = num2;
21444 break;
21445 case 2:
21446 passStyle = num2;
21447 break;
21448 case 3:
21449 passStyle = num2 + 1;
21450 break;
21451 case 4:
21452 passStyle = num2 + 2;
21453 break;
21454 case 5:
21455 passStyle = num2 + 1;
21456 break;
21457 case 6:
21458 passStyle = num2 + 3;
21459 break;
21460 case 7:
21461 passStyle = num2 + 4;
21462 break;
21463 case 8:
21464 passStyle = num2 + 5;
21465 break;
21466 case 9:
21467 passStyle = num2 + 6;
21468 break;
21469 case 10:
21470 passStyle = num2 + 6;
21471 break;
21472 case 11:
21473 passStyle = num2 + 6;
21474 break;
21475 case 12:
21476 passStyle = num2 + 7;
21477 break;
21478 case 13:
21479 passStyle = num2 + 7;
21480 break;
21481 case 14:
21482 passStyle = num2 + 7;
21483 break;
21484 case 15:
21485 passStyle = num2 + 8;
21486 break;
21487 case 16:
21488 passStyle = num2 + 8;
21489 break;
21490 case 17:
21491 passStyle = num2 + 8;
21492 break;
21493 }
21494 }
21495 passStyle += num;
21496 treeHeight += 5;
21497 break;
21498 }
21499 }
21500 }
21501
21502 public static void TreeGrowFX(int x, int y, int height, int treeGore, bool hitTree = false)
21503 {
21504 Vector2 vector = new Vector2(x, y) * 16f + new Vector2(8f, 8f);
21505 if (treeGore == 1278)
21506 {
21507 TreeGrowFX_AshShake(x, y, height, hitTree);
21508 return;
21509 }
21510 for (int num = 0; num > -height; num--)
21511 {
21512 float num2 = 10f;
21513 Vector2 vector2 = new Vector2(5f, 7f);
21514 Gore.NewGore(vector + new Vector2(-16f, num * 16) - vector2, Utils.RandomVector2(Main.rand, 0f - num2, num2), treeGore, 0.7f + Main.rand.NextFloat() * 0.6f);
21515 Gore.NewGore(vector + new Vector2(0f, num * 16) - vector2, Utils.RandomVector2(Main.rand, 0f - num2, num2), treeGore, 0.7f + Main.rand.NextFloat() * 0.6f);
21516 Gore.NewGore(vector + new Vector2(16f, num * 16) - vector2, Utils.RandomVector2(Main.rand, 0f - num2, num2), treeGore, 0.7f + Main.rand.NextFloat() * 0.6f);
21517 if (num == -height + 1)
21518 {
21519 int num3 = 20;
21520 if (hitTree)
21521 {
21522 num3 = 5;
21523 }
21524 for (int i = 0; i < num3; i++)
21525 {
21526 Gore.NewGore(vector + new Vector2(0f, num * 16 - 40) + Utils.RandomVector2(Main.rand, -40f, 40f) - vector2, Utils.RandomVector2(Main.rand, -10f, 10f), treeGore, 0.7f + Main.rand.NextFloat() * 0.6f);
21527 }
21528 }
21529 }
21530 }
21531
21532 private static void TreeGrowFX_AshShake(int x, int y, int height, bool hitTree = false)
21533 {
21534 Vector2 vector = new Vector2(x, y) * 16f + new Vector2(8f, 8f);
21535 for (int num = 0; num > -height; num--)
21536 {
21537 if (num >= -height / 2 && Main.rand.Next(3) != 0)
21538 {
21539 int num2 = (hitTree ? 10 : 5);
21540 for (int i = 0; i < num2; i++)
21541 {
21542 Dust.NewDustDirect(vector + new Vector2(-16f, num * 16) + Utils.RandomVector2(Main.rand, -30f, 30f), 4, 4, 31, 0f, -3f, 100).velocity = Main.rand.NextVector2Circular(2f, 2f) + new Vector2(0f, -0.6f);
21543 }
21544 }
21545 if ((float)num >= (float)(-height) * 0.7f && Main.rand.Next(3) != 0)
21546 {
21547 int num3 = (hitTree ? 16 : 10);
21548 for (int j = 0; j < num3; j++)
21549 {
21550 Dust dust = Dust.NewDustDirect(vector + new Vector2(-16f, num * 16) + Utils.RandomVector2(Main.rand, -30f, 30f), 4, 4, 6, 0f, -4f, 0, default(Color), 1f + 0.7f * Main.rand.NextFloat());
21551 dust.velocity = Main.rand.NextVector2Circular(2f, 2f) + new Vector2(0f, -0.6f);
21552 if (Main.rand.Next(2) == 0)
21553 {
21554 dust.velocity *= 2f;
21555 dust.noGravity = true;
21556 }
21557 dust.velocity += new Vector2(0f, hitTree ? (-1f) : (-2f));
21558 }
21559 }
21560 if (!hitTree)
21561 {
21562 Gore.NewGoreDirect(vector + new Vector2(-16f, num * 16 - 40) + Utils.RandomVector2(Main.rand, -40f, 40f) * new Vector2(0.5f, 1f), Vector2.Zero, 61 + Main.rand.Next(3)).velocity *= 0.5f;
21563 }
21564 }
21565 }
21566
21567 public static bool IsTileALeafyTreeTop(int i, int j)
21568 {
21571 {
21572 if (tileSafely.type == 323 && tileSafely.frameX >= 88)
21573 {
21574 return true;
21575 }
21576 if (tileSafely.frameX == 22 && tileSafely.frameY >= 198 && tileSafely.frameY <= 242)
21577 {
21578 return true;
21579 }
21580 }
21581 return false;
21582 }
21583
21584 public static bool IsTileTypeFitForTree(ushort type)
21585 {
21586 switch (type)
21587 {
21588 case 2:
21589 case 23:
21590 case 60:
21591 case 70:
21592 case 109:
21593 case 147:
21594 case 199:
21595 case 477:
21596 case 492:
21597 case 633:
21598 case 661:
21599 case 662:
21600 return true;
21601 default:
21602 return false;
21603 }
21604 }
21605
21606 public static bool GrowTree(int i, int y)
21607 {
21608 int j;
21609 for (j = y; Main.tile[i, j].type == 20; j++)
21610 {
21611 }
21612 if ((Main.tile[i - 1, j - 1].liquid != 0 || Main.tile[i, j - 1].liquid != 0 || Main.tile[i + 1, j - 1].liquid != 0) && !notTheBees)
21613 {
21614 return false;
21615 }
21616 if (Main.tile[i, j].nactive() && !Main.tile[i, j].halfBrick() && Main.tile[i, j].slope() == 0 && IsTileTypeFitForTree(Main.tile[i, j].type) && ((Main.remixWorld && (double)j > Main.worldSurface) || Main.tile[i, j - 1].wall == 0 || DefaultTreeWallTest(Main.tile[i, j - 1].wall)) && ((Main.tile[i - 1, j].active() && IsTileTypeFitForTree(Main.tile[i - 1, j].type)) || (Main.tile[i + 1, j].active() && IsTileTypeFitForTree(Main.tile[i + 1, j].type))))
21617 {
21618 TileColorCache cache = Main.tile[i, j].BlockColorAndCoating();
21619 if (Main.tenthAnniversaryWorld && !gen)
21620 {
21621 cache.Color = (byte)genRand.Next(1, 13);
21622 }
21623 int num = 2;
21624 int num2 = genRand.Next(5, 17);
21625 int num3 = num2 + 4;
21626 if (Main.tile[i, j].type == 60)
21627 {
21628 num3 += 5;
21629 }
21630 bool flag = false;
21631 if (Main.tile[i, j].type == 70 && EmptyTileCheck(i - num, i + num, j - num3, j - 3, 20) && EmptyTileCheck(i - 1, i + 1, j - 2, j - 1, 20))
21632 {
21633 flag = true;
21634 }
21635 if (EmptyTileCheck(i - num, i + num, j - num3, j - 1, 20))
21636 {
21637 flag = true;
21638 }
21639 if (flag)
21640 {
21641 bool flag2 = Main.remixWorld && (double)j < Main.worldSurface;
21642 bool flag3 = false;
21643 bool flag4 = false;
21644 int num4;
21645 for (int k = j - num2; k < j; k++)
21646 {
21647 Main.tile[i, k].frameNumber((byte)genRand.Next(3));
21648 Main.tile[i, k].active(active: true);
21649 Main.tile[i, k].type = 5;
21650 Main.tile[i, k].UseBlockColors(cache);
21651 num4 = genRand.Next(3);
21652 int num5 = genRand.Next(10);
21653 if (k == j - 1 || k == j - num2)
21654 {
21655 num5 = 0;
21656 }
21657 while (((num5 == 5 || num5 == 7) && flag3) || ((num5 == 6 || num5 == 7) && flag4))
21658 {
21659 num5 = genRand.Next(10);
21660 }
21661 flag3 = false;
21662 flag4 = false;
21663 if (num5 == 5 || num5 == 7)
21664 {
21665 flag3 = true;
21666 }
21667 if (num5 == 6 || num5 == 7)
21668 {
21669 flag4 = true;
21670 }
21671 switch (num5)
21672 {
21673 case 1:
21674 if (num4 == 0)
21675 {
21676 Main.tile[i, k].frameX = 0;
21677 Main.tile[i, k].frameY = 66;
21678 }
21679 if (num4 == 1)
21680 {
21681 Main.tile[i, k].frameX = 0;
21682 Main.tile[i, k].frameY = 88;
21683 }
21684 if (num4 == 2)
21685 {
21686 Main.tile[i, k].frameX = 0;
21687 Main.tile[i, k].frameY = 110;
21688 }
21689 break;
21690 case 2:
21691 if (num4 == 0)
21692 {
21693 Main.tile[i, k].frameX = 22;
21694 Main.tile[i, k].frameY = 0;
21695 }
21696 if (num4 == 1)
21697 {
21698 Main.tile[i, k].frameX = 22;
21699 Main.tile[i, k].frameY = 22;
21700 }
21701 if (num4 == 2)
21702 {
21703 Main.tile[i, k].frameX = 22;
21704 Main.tile[i, k].frameY = 44;
21705 }
21706 break;
21707 case 3:
21708 if (num4 == 0)
21709 {
21710 Main.tile[i, k].frameX = 44;
21711 Main.tile[i, k].frameY = 66;
21712 }
21713 if (num4 == 1)
21714 {
21715 Main.tile[i, k].frameX = 44;
21716 Main.tile[i, k].frameY = 88;
21717 }
21718 if (num4 == 2)
21719 {
21720 Main.tile[i, k].frameX = 44;
21721 Main.tile[i, k].frameY = 110;
21722 }
21723 break;
21724 case 4:
21725 if (num4 == 0)
21726 {
21727 Main.tile[i, k].frameX = 22;
21728 Main.tile[i, k].frameY = 66;
21729 }
21730 if (num4 == 1)
21731 {
21732 Main.tile[i, k].frameX = 22;
21733 Main.tile[i, k].frameY = 88;
21734 }
21735 if (num4 == 2)
21736 {
21737 Main.tile[i, k].frameX = 22;
21738 Main.tile[i, k].frameY = 110;
21739 }
21740 break;
21741 case 5:
21742 if (num4 == 0)
21743 {
21744 Main.tile[i, k].frameX = 88;
21745 Main.tile[i, k].frameY = 0;
21746 }
21747 if (num4 == 1)
21748 {
21749 Main.tile[i, k].frameX = 88;
21750 Main.tile[i, k].frameY = 22;
21751 }
21752 if (num4 == 2)
21753 {
21754 Main.tile[i, k].frameX = 88;
21755 Main.tile[i, k].frameY = 44;
21756 }
21757 break;
21758 case 6:
21759 if (num4 == 0)
21760 {
21761 Main.tile[i, k].frameX = 66;
21762 Main.tile[i, k].frameY = 66;
21763 }
21764 if (num4 == 1)
21765 {
21766 Main.tile[i, k].frameX = 66;
21767 Main.tile[i, k].frameY = 88;
21768 }
21769 if (num4 == 2)
21770 {
21771 Main.tile[i, k].frameX = 66;
21772 Main.tile[i, k].frameY = 110;
21773 }
21774 break;
21775 case 7:
21776 if (num4 == 0)
21777 {
21778 Main.tile[i, k].frameX = 110;
21779 Main.tile[i, k].frameY = 66;
21780 }
21781 if (num4 == 1)
21782 {
21783 Main.tile[i, k].frameX = 110;
21784 Main.tile[i, k].frameY = 88;
21785 }
21786 if (num4 == 2)
21787 {
21788 Main.tile[i, k].frameX = 110;
21789 Main.tile[i, k].frameY = 110;
21790 }
21791 break;
21792 default:
21793 if (num4 == 0)
21794 {
21795 Main.tile[i, k].frameX = 0;
21796 Main.tile[i, k].frameY = 0;
21797 }
21798 if (num4 == 1)
21799 {
21800 Main.tile[i, k].frameX = 0;
21801 Main.tile[i, k].frameY = 22;
21802 }
21803 if (num4 == 2)
21804 {
21805 Main.tile[i, k].frameX = 0;
21806 Main.tile[i, k].frameY = 44;
21807 }
21808 break;
21809 }
21810 if (num5 == 5 || num5 == 7)
21811 {
21812 Main.tile[i - 1, k].active(active: true);
21813 Main.tile[i - 1, k].type = 5;
21814 Main.tile[i - 1, k].UseBlockColors(cache);
21815 num4 = genRand.Next(3);
21816 if (genRand.Next(3) < 2 && !flag2)
21817 {
21818 if (num4 == 0)
21819 {
21820 Main.tile[i - 1, k].frameX = 44;
21821 Main.tile[i - 1, k].frameY = 198;
21822 }
21823 if (num4 == 1)
21824 {
21825 Main.tile[i - 1, k].frameX = 44;
21826 Main.tile[i - 1, k].frameY = 220;
21827 }
21828 if (num4 == 2)
21829 {
21830 Main.tile[i - 1, k].frameX = 44;
21831 Main.tile[i - 1, k].frameY = 242;
21832 }
21833 }
21834 else
21835 {
21836 if (num4 == 0)
21837 {
21838 Main.tile[i - 1, k].frameX = 66;
21839 Main.tile[i - 1, k].frameY = 0;
21840 }
21841 if (num4 == 1)
21842 {
21843 Main.tile[i - 1, k].frameX = 66;
21844 Main.tile[i - 1, k].frameY = 22;
21845 }
21846 if (num4 == 2)
21847 {
21848 Main.tile[i - 1, k].frameX = 66;
21849 Main.tile[i - 1, k].frameY = 44;
21850 }
21851 }
21852 }
21853 if (num5 != 6 && num5 != 7)
21854 {
21855 continue;
21856 }
21857 Main.tile[i + 1, k].active(active: true);
21858 Main.tile[i + 1, k].type = 5;
21859 Main.tile[i + 1, k].UseBlockColors(cache);
21860 num4 = genRand.Next(3);
21861 if (genRand.Next(3) < 2 && !flag2)
21862 {
21863 if (num4 == 0)
21864 {
21865 Main.tile[i + 1, k].frameX = 66;
21866 Main.tile[i + 1, k].frameY = 198;
21867 }
21868 if (num4 == 1)
21869 {
21870 Main.tile[i + 1, k].frameX = 66;
21871 Main.tile[i + 1, k].frameY = 220;
21872 }
21873 if (num4 == 2)
21874 {
21875 Main.tile[i + 1, k].frameX = 66;
21876 Main.tile[i + 1, k].frameY = 242;
21877 }
21878 }
21879 else
21880 {
21881 if (num4 == 0)
21882 {
21883 Main.tile[i + 1, k].frameX = 88;
21884 Main.tile[i + 1, k].frameY = 66;
21885 }
21886 if (num4 == 1)
21887 {
21888 Main.tile[i + 1, k].frameX = 88;
21889 Main.tile[i + 1, k].frameY = 88;
21890 }
21891 if (num4 == 2)
21892 {
21893 Main.tile[i + 1, k].frameX = 88;
21894 Main.tile[i + 1, k].frameY = 110;
21895 }
21896 }
21897 }
21898 int num6 = genRand.Next(3);
21899 bool flag5 = false;
21900 bool flag6 = false;
21901 if (Main.tile[i - 1, j].nactive() && !Main.tile[i - 1, j].halfBrick() && Main.tile[i - 1, j].slope() == 0 && IsTileTypeFitForTree(Main.tile[i - 1, j].type))
21902 {
21903 flag5 = true;
21904 }
21905 if (Main.tile[i + 1, j].nactive() && !Main.tile[i + 1, j].halfBrick() && Main.tile[i + 1, j].slope() == 0 && IsTileTypeFitForTree(Main.tile[i + 1, j].type))
21906 {
21907 flag6 = true;
21908 }
21909 if (!flag5)
21910 {
21911 if (num6 == 0)
21912 {
21913 num6 = 2;
21914 }
21915 if (num6 == 1)
21916 {
21917 num6 = 3;
21918 }
21919 }
21920 if (!flag6)
21921 {
21922 if (num6 == 0)
21923 {
21924 num6 = 1;
21925 }
21926 if (num6 == 2)
21927 {
21928 num6 = 3;
21929 }
21930 }
21931 if (flag5 && !flag6)
21932 {
21933 num6 = 2;
21934 }
21935 if (flag6 && !flag5)
21936 {
21937 num6 = 1;
21938 }
21939 if (num6 == 0 || num6 == 1)
21940 {
21941 Main.tile[i + 1, j - 1].active(active: true);
21942 Main.tile[i + 1, j - 1].type = 5;
21943 Main.tile[i + 1, j - 1].UseBlockColors(cache);
21944 num4 = genRand.Next(3);
21945 if (num4 == 0)
21946 {
21947 Main.tile[i + 1, j - 1].frameX = 22;
21948 Main.tile[i + 1, j - 1].frameY = 132;
21949 }
21950 if (num4 == 1)
21951 {
21952 Main.tile[i + 1, j - 1].frameX = 22;
21953 Main.tile[i + 1, j - 1].frameY = 154;
21954 }
21955 if (num4 == 2)
21956 {
21957 Main.tile[i + 1, j - 1].frameX = 22;
21958 Main.tile[i + 1, j - 1].frameY = 176;
21959 }
21960 }
21961 if (num6 == 0 || num6 == 2)
21962 {
21963 Main.tile[i - 1, j - 1].active(active: true);
21964 Main.tile[i - 1, j - 1].type = 5;
21965 Main.tile[i - 1, j - 1].UseBlockColors(cache);
21966 num4 = genRand.Next(3);
21967 if (num4 == 0)
21968 {
21969 Main.tile[i - 1, j - 1].frameX = 44;
21970 Main.tile[i - 1, j - 1].frameY = 132;
21971 }
21972 if (num4 == 1)
21973 {
21974 Main.tile[i - 1, j - 1].frameX = 44;
21975 Main.tile[i - 1, j - 1].frameY = 154;
21976 }
21977 if (num4 == 2)
21978 {
21979 Main.tile[i - 1, j - 1].frameX = 44;
21980 Main.tile[i - 1, j - 1].frameY = 176;
21981 }
21982 }
21983 num4 = genRand.Next(3);
21984 switch (num6)
21985 {
21986 case 0:
21987 if (num4 == 0)
21988 {
21989 Main.tile[i, j - 1].frameX = 88;
21990 Main.tile[i, j - 1].frameY = 132;
21991 }
21992 if (num4 == 1)
21993 {
21994 Main.tile[i, j - 1].frameX = 88;
21995 Main.tile[i, j - 1].frameY = 154;
21996 }
21997 if (num4 == 2)
21998 {
21999 Main.tile[i, j - 1].frameX = 88;
22000 Main.tile[i, j - 1].frameY = 176;
22001 }
22002 break;
22003 case 1:
22004 if (num4 == 0)
22005 {
22006 Main.tile[i, j - 1].frameX = 0;
22007 Main.tile[i, j - 1].frameY = 132;
22008 }
22009 if (num4 == 1)
22010 {
22011 Main.tile[i, j - 1].frameX = 0;
22012 Main.tile[i, j - 1].frameY = 154;
22013 }
22014 if (num4 == 2)
22015 {
22016 Main.tile[i, j - 1].frameX = 0;
22017 Main.tile[i, j - 1].frameY = 176;
22018 }
22019 break;
22020 case 2:
22021 if (num4 == 0)
22022 {
22023 Main.tile[i, j - 1].frameX = 66;
22024 Main.tile[i, j - 1].frameY = 132;
22025 }
22026 if (num4 == 1)
22027 {
22028 Main.tile[i, j - 1].frameX = 66;
22029 Main.tile[i, j - 1].frameY = 154;
22030 }
22031 if (num4 == 2)
22032 {
22033 Main.tile[i, j - 1].frameX = 66;
22034 Main.tile[i, j - 1].frameY = 176;
22035 }
22036 break;
22037 }
22038 if (genRand.Next(13) != 0 && !flag2)
22039 {
22040 num4 = genRand.Next(3);
22041 if (num4 == 0)
22042 {
22043 Main.tile[i, j - num2].frameX = 22;
22044 Main.tile[i, j - num2].frameY = 198;
22045 }
22046 if (num4 == 1)
22047 {
22048 Main.tile[i, j - num2].frameX = 22;
22049 Main.tile[i, j - num2].frameY = 220;
22050 }
22051 if (num4 == 2)
22052 {
22053 Main.tile[i, j - num2].frameX = 22;
22054 Main.tile[i, j - num2].frameY = 242;
22055 }
22056 }
22057 else
22058 {
22059 num4 = genRand.Next(3);
22060 if (num4 == 0)
22061 {
22062 Main.tile[i, j - num2].frameX = 0;
22063 Main.tile[i, j - num2].frameY = 198;
22064 }
22065 if (num4 == 1)
22066 {
22067 Main.tile[i, j - num2].frameX = 0;
22068 Main.tile[i, j - num2].frameY = 220;
22069 }
22070 if (num4 == 2)
22071 {
22072 Main.tile[i, j - num2].frameX = 0;
22073 Main.tile[i, j - num2].frameY = 242;
22074 }
22075 }
22076 RangeFrame(i - 2, j - num2 - 1, i + 2, j + 1);
22077 if (Main.netMode == 2)
22078 {
22079 NetMessage.SendTileSquare(-1, i - 1, j - num2, 3, num2);
22080 }
22081 return true;
22082 }
22083 }
22084 return false;
22085 }
22086
22087 public static bool DefaultTreeWallTest(int wallType)
22088 {
22090 {
22091 return true;
22092 }
22093 return false;
22094 }
22095
22096 public static bool GemTreeWallTest(int wallType)
22097 {
22098 if (DefaultTreeWallTest(wallType))
22099 {
22100 return true;
22101 }
22102 switch (wallType)
22103 {
22104 case 2:
22105 case 54:
22106 case 55:
22107 case 56:
22108 case 57:
22109 case 58:
22110 case 59:
22111 case 61:
22112 case 185:
22113 case 196:
22114 case 197:
22115 case 198:
22116 case 199:
22117 case 208:
22118 case 209:
22119 case 210:
22120 case 211:
22121 case 212:
22122 case 213:
22123 case 214:
22124 case 215:
22125 return true;
22126 default:
22127 return false;
22128 }
22129 }
22130
22131 public static bool GemTreeGroundTest(int tileType)
22132 {
22133 if (tileType < 0)
22134 {
22135 return false;
22136 }
22137 if (TileID.Sets.Conversion.Stone[tileType] || TileID.Sets.Conversion.Moss[tileType])
22138 {
22139 return true;
22140 }
22141 return false;
22142 }
22143
22144 public static bool VanityTreeGroundTest(int tileType)
22145 {
22146 if (tileType < 0)
22147 {
22148 return false;
22149 }
22150 if (TileID.Sets.Conversion.Grass[tileType])
22151 {
22152 return true;
22153 }
22154 return false;
22155 }
22156
22157 public static bool AshTreeGroundTest(int tileType)
22158 {
22159 if (tileType < 0)
22160 {
22161 return false;
22162 }
22163 if (tileType == 633)
22164 {
22165 return true;
22166 }
22167 return false;
22168 }
22169
22170 public static bool TryGrowingTreeByType(int treeTileType, int checkedX, int checkedY)
22171 {
22172 bool result = false;
22173 switch (treeTileType)
22174 {
22175 case 5:
22176 result = GrowTree(checkedX, checkedY);
22177 break;
22178 case 587:
22179 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Ruby);
22180 break;
22181 case 588:
22182 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Diamond);
22183 break;
22184 case 583:
22185 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Topaz);
22186 break;
22187 case 584:
22188 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Amethyst);
22189 break;
22190 case 589:
22191 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Amber);
22192 break;
22193 case 586:
22194 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Emerald);
22195 break;
22196 case 585:
22197 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.GemTree_Sappphire);
22198 break;
22199 case 596:
22200 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.VanityTree_Sakura);
22201 break;
22202 case 616:
22203 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.VanityTree_Willow);
22204 break;
22205 case 634:
22206 result = GrowTreeWithSettings(checkedX, checkedY, GrowTreeSettings.Profiles.Tree_Ash);
22207 break;
22208 }
22209 return result;
22210 }
22211
22212 public static bool GrowTreeWithSettings(int checkedX, int checkedY, GrowTreeSettings settings)
22213 {
22214 int i;
22215 for (i = checkedY; Main.tile[checkedX, i].type == settings.SaplingTileType; i++)
22216 {
22217 }
22218 if (Main.tile[checkedX - 1, i - 1].liquid != 0 || Main.tile[checkedX, i - 1].liquid != 0 || Main.tile[checkedX + 1, i - 1].liquid != 0)
22219 {
22220 return false;
22221 }
22222 Tile tile = Main.tile[checkedX, i];
22223 if (!tile.nactive() || tile.halfBrick() || tile.slope() != 0)
22224 {
22225 return false;
22226 }
22227 bool flag = settings.WallTest(Main.tile[checkedX, i - 1].wall);
22228 if (!settings.GroundTest(tile.type) || !flag)
22229 {
22230 return false;
22231 }
22232 if ((!Main.tile[checkedX - 1, i].active() || !settings.GroundTest(Main.tile[checkedX - 1, i].type)) && (!Main.tile[checkedX + 1, i].active() || !settings.GroundTest(Main.tile[checkedX + 1, i].type)))
22233 {
22234 return false;
22235 }
22236 TileColorCache cache = Main.tile[checkedX, i].BlockColorAndCoating();
22237 if (Main.tenthAnniversaryWorld && !gen && (settings.TreeTileType == 596 || settings.TreeTileType == 616))
22238 {
22239 cache.Color = (byte)genRand.Next(1, 13);
22240 }
22241 int num = 2;
22242 int num2 = genRand.Next(settings.TreeHeightMin, settings.TreeHeightMax + 1);
22243 int num3 = num2 + settings.TreeTopPaddingNeeded;
22244 if (!EmptyTileCheck(checkedX - num, checkedX + num, i - num3, i - 1, 20))
22245 {
22246 return false;
22247 }
22248 bool flag2 = false;
22249 bool flag3 = false;
22250 int num4;
22251 for (int j = i - num2; j < i; j++)
22252 {
22254 tile2.frameNumber((byte)genRand.Next(3));
22255 tile2.active(active: true);
22256 tile2.type = settings.TreeTileType;
22257 tile2.UseBlockColors(cache);
22258 num4 = genRand.Next(3);
22259 int num5 = genRand.Next(10);
22260 if (j == i - 1 || j == i - num2)
22261 {
22262 num5 = 0;
22263 }
22264 while (((num5 == 5 || num5 == 7) && flag2) || ((num5 == 6 || num5 == 7) && flag3))
22265 {
22266 num5 = genRand.Next(10);
22267 }
22268 flag2 = false;
22269 flag3 = false;
22270 if (num5 == 5 || num5 == 7)
22271 {
22272 flag2 = true;
22273 }
22274 if (num5 == 6 || num5 == 7)
22275 {
22276 flag3 = true;
22277 }
22278 switch (num5)
22279 {
22280 case 1:
22281 if (num4 == 0)
22282 {
22283 tile2.frameX = 0;
22284 tile2.frameY = 66;
22285 }
22286 if (num4 == 1)
22287 {
22288 tile2.frameX = 0;
22289 tile2.frameY = 88;
22290 }
22291 if (num4 == 2)
22292 {
22293 tile2.frameX = 0;
22294 tile2.frameY = 110;
22295 }
22296 break;
22297 case 2:
22298 if (num4 == 0)
22299 {
22300 tile2.frameX = 22;
22301 tile2.frameY = 0;
22302 }
22303 if (num4 == 1)
22304 {
22305 tile2.frameX = 22;
22306 tile2.frameY = 22;
22307 }
22308 if (num4 == 2)
22309 {
22310 tile2.frameX = 22;
22311 tile2.frameY = 44;
22312 }
22313 break;
22314 case 3:
22315 if (num4 == 0)
22316 {
22317 tile2.frameX = 44;
22318 tile2.frameY = 66;
22319 }
22320 if (num4 == 1)
22321 {
22322 tile2.frameX = 44;
22323 tile2.frameY = 88;
22324 }
22325 if (num4 == 2)
22326 {
22327 tile2.frameX = 44;
22328 tile2.frameY = 110;
22329 }
22330 break;
22331 case 4:
22332 if (num4 == 0)
22333 {
22334 tile2.frameX = 22;
22335 tile2.frameY = 66;
22336 }
22337 if (num4 == 1)
22338 {
22339 tile2.frameX = 22;
22340 tile2.frameY = 88;
22341 }
22342 if (num4 == 2)
22343 {
22344 tile2.frameX = 22;
22345 tile2.frameY = 110;
22346 }
22347 break;
22348 case 5:
22349 if (num4 == 0)
22350 {
22351 tile2.frameX = 88;
22352 tile2.frameY = 0;
22353 }
22354 if (num4 == 1)
22355 {
22356 tile2.frameX = 88;
22357 tile2.frameY = 22;
22358 }
22359 if (num4 == 2)
22360 {
22361 tile2.frameX = 88;
22362 tile2.frameY = 44;
22363 }
22364 break;
22365 case 6:
22366 if (num4 == 0)
22367 {
22368 tile2.frameX = 66;
22369 tile2.frameY = 66;
22370 }
22371 if (num4 == 1)
22372 {
22373 tile2.frameX = 66;
22374 tile2.frameY = 88;
22375 }
22376 if (num4 == 2)
22377 {
22378 tile2.frameX = 66;
22379 tile2.frameY = 110;
22380 }
22381 break;
22382 case 7:
22383 if (num4 == 0)
22384 {
22385 tile2.frameX = 110;
22386 tile2.frameY = 66;
22387 }
22388 if (num4 == 1)
22389 {
22390 tile2.frameX = 110;
22391 tile2.frameY = 88;
22392 }
22393 if (num4 == 2)
22394 {
22395 tile2.frameX = 110;
22396 tile2.frameY = 110;
22397 }
22398 break;
22399 default:
22400 if (num4 == 0)
22401 {
22402 tile2.frameX = 0;
22403 tile2.frameY = 0;
22404 }
22405 if (num4 == 1)
22406 {
22407 tile2.frameX = 0;
22408 tile2.frameY = 22;
22409 }
22410 if (num4 == 2)
22411 {
22412 tile2.frameX = 0;
22413 tile2.frameY = 44;
22414 }
22415 break;
22416 }
22417 if (num5 == 5 || num5 == 7)
22418 {
22419 Tile tile3 = Main.tile[checkedX - 1, j];
22420 tile3.active(active: true);
22421 tile3.type = settings.TreeTileType;
22422 tile3.UseBlockColors(cache);
22423 num4 = genRand.Next(3);
22424 if (genRand.Next(3) < 2)
22425 {
22426 if (num4 == 0)
22427 {
22428 tile3.frameX = 44;
22429 tile3.frameY = 198;
22430 }
22431 if (num4 == 1)
22432 {
22433 tile3.frameX = 44;
22434 tile3.frameY = 220;
22435 }
22436 if (num4 == 2)
22437 {
22438 tile3.frameX = 44;
22439 tile3.frameY = 242;
22440 }
22441 }
22442 else
22443 {
22444 if (num4 == 0)
22445 {
22446 tile3.frameX = 66;
22447 tile3.frameY = 0;
22448 }
22449 if (num4 == 1)
22450 {
22451 tile3.frameX = 66;
22452 tile3.frameY = 22;
22453 }
22454 if (num4 == 2)
22455 {
22456 tile3.frameX = 66;
22457 tile3.frameY = 44;
22458 }
22459 }
22460 }
22461 if (num5 != 6 && num5 != 7)
22462 {
22463 continue;
22464 }
22465 Tile tile4 = Main.tile[checkedX + 1, j];
22466 tile4.active(active: true);
22467 tile4.type = settings.TreeTileType;
22468 tile4.UseBlockColors(cache);
22469 num4 = genRand.Next(3);
22470 if (genRand.Next(3) < 2)
22471 {
22472 if (num4 == 0)
22473 {
22474 tile4.frameX = 66;
22475 tile4.frameY = 198;
22476 }
22477 if (num4 == 1)
22478 {
22479 tile4.frameX = 66;
22480 tile4.frameY = 220;
22481 }
22482 if (num4 == 2)
22483 {
22484 tile4.frameX = 66;
22485 tile4.frameY = 242;
22486 }
22487 }
22488 else
22489 {
22490 if (num4 == 0)
22491 {
22492 tile4.frameX = 88;
22493 tile4.frameY = 66;
22494 }
22495 if (num4 == 1)
22496 {
22497 tile4.frameX = 88;
22498 tile4.frameY = 88;
22499 }
22500 if (num4 == 2)
22501 {
22502 tile4.frameX = 88;
22503 tile4.frameY = 110;
22504 }
22505 }
22506 }
22507 bool flag4 = false;
22508 bool flag5 = false;
22509 if (Main.tile[checkedX - 1, i].nactive() && !Main.tile[checkedX - 1, i].halfBrick() && Main.tile[checkedX - 1, i].slope() == 0 && IsTileTypeFitForTree(Main.tile[checkedX - 1, i].type))
22510 {
22511 flag4 = true;
22512 }
22513 if (Main.tile[checkedX + 1, i].nactive() && !Main.tile[checkedX + 1, i].halfBrick() && Main.tile[checkedX + 1, i].slope() == 0 && IsTileTypeFitForTree(Main.tile[checkedX + 1, i].type))
22514 {
22515 flag5 = true;
22516 }
22517 if (genRand.Next(3) == 0)
22518 {
22519 flag4 = false;
22520 }
22521 if (genRand.Next(3) == 0)
22522 {
22523 flag5 = false;
22524 }
22525 if (flag5)
22526 {
22527 Main.tile[checkedX + 1, i - 1].active(active: true);
22528 Main.tile[checkedX + 1, i - 1].type = settings.TreeTileType;
22529 Main.tile[checkedX + 1, i - 1].UseBlockColors(cache);
22530 num4 = genRand.Next(3);
22531 if (num4 == 0)
22532 {
22533 Main.tile[checkedX + 1, i - 1].frameX = 22;
22534 Main.tile[checkedX + 1, i - 1].frameY = 132;
22535 }
22536 if (num4 == 1)
22537 {
22538 Main.tile[checkedX + 1, i - 1].frameX = 22;
22539 Main.tile[checkedX + 1, i - 1].frameY = 154;
22540 }
22541 if (num4 == 2)
22542 {
22543 Main.tile[checkedX + 1, i - 1].frameX = 22;
22544 Main.tile[checkedX + 1, i - 1].frameY = 176;
22545 }
22546 }
22547 if (flag4)
22548 {
22549 Main.tile[checkedX - 1, i - 1].active(active: true);
22550 Main.tile[checkedX - 1, i - 1].type = settings.TreeTileType;
22551 Main.tile[checkedX - 1, i - 1].UseBlockColors(cache);
22552 num4 = genRand.Next(3);
22553 if (num4 == 0)
22554 {
22555 Main.tile[checkedX - 1, i - 1].frameX = 44;
22556 Main.tile[checkedX - 1, i - 1].frameY = 132;
22557 }
22558 if (num4 == 1)
22559 {
22560 Main.tile[checkedX - 1, i - 1].frameX = 44;
22561 Main.tile[checkedX - 1, i - 1].frameY = 154;
22562 }
22563 if (num4 == 2)
22564 {
22565 Main.tile[checkedX - 1, i - 1].frameX = 44;
22566 Main.tile[checkedX - 1, i - 1].frameY = 176;
22567 }
22568 }
22569 num4 = genRand.Next(3);
22570 if (flag4 && flag5)
22571 {
22572 if (num4 == 0)
22573 {
22574 Main.tile[checkedX, i - 1].frameX = 88;
22575 Main.tile[checkedX, i - 1].frameY = 132;
22576 }
22577 if (num4 == 1)
22578 {
22579 Main.tile[checkedX, i - 1].frameX = 88;
22580 Main.tile[checkedX, i - 1].frameY = 154;
22581 }
22582 if (num4 == 2)
22583 {
22584 Main.tile[checkedX, i - 1].frameX = 88;
22585 Main.tile[checkedX, i - 1].frameY = 176;
22586 }
22587 }
22588 else if (flag4)
22589 {
22590 if (num4 == 0)
22591 {
22592 Main.tile[checkedX, i - 1].frameX = 0;
22593 Main.tile[checkedX, i - 1].frameY = 132;
22594 }
22595 if (num4 == 1)
22596 {
22597 Main.tile[checkedX, i - 1].frameX = 0;
22598 Main.tile[checkedX, i - 1].frameY = 154;
22599 }
22600 if (num4 == 2)
22601 {
22602 Main.tile[checkedX, i - 1].frameX = 0;
22603 Main.tile[checkedX, i - 1].frameY = 176;
22604 }
22605 }
22606 else if (flag5)
22607 {
22608 if (num4 == 0)
22609 {
22610 Main.tile[checkedX, i - 1].frameX = 66;
22611 Main.tile[checkedX, i - 1].frameY = 132;
22612 }
22613 if (num4 == 1)
22614 {
22615 Main.tile[checkedX, i - 1].frameX = 66;
22616 Main.tile[checkedX, i - 1].frameY = 154;
22617 }
22618 if (num4 == 2)
22619 {
22620 Main.tile[checkedX, i - 1].frameX = 66;
22621 Main.tile[checkedX, i - 1].frameY = 176;
22622 }
22623 }
22624 if (genRand.Next(13) != 0)
22625 {
22626 num4 = genRand.Next(3);
22627 if (num4 == 0)
22628 {
22629 Main.tile[checkedX, i - num2].frameX = 22;
22630 Main.tile[checkedX, i - num2].frameY = 198;
22631 }
22632 if (num4 == 1)
22633 {
22634 Main.tile[checkedX, i - num2].frameX = 22;
22635 Main.tile[checkedX, i - num2].frameY = 220;
22636 }
22637 if (num4 == 2)
22638 {
22639 Main.tile[checkedX, i - num2].frameX = 22;
22640 Main.tile[checkedX, i - num2].frameY = 242;
22641 }
22642 }
22643 else
22644 {
22645 num4 = genRand.Next(3);
22646 if (num4 == 0)
22647 {
22648 Main.tile[checkedX, i - num2].frameX = 0;
22649 Main.tile[checkedX, i - num2].frameY = 198;
22650 }
22651 if (num4 == 1)
22652 {
22653 Main.tile[checkedX, i - num2].frameX = 0;
22654 Main.tile[checkedX, i - num2].frameY = 220;
22655 }
22656 if (num4 == 2)
22657 {
22658 Main.tile[checkedX, i - num2].frameX = 0;
22659 Main.tile[checkedX, i - num2].frameY = 242;
22660 }
22661 }
22662 RangeFrame(checkedX - 2, i - num2 - 1, checkedX + 2, i + 1);
22663 if (Main.netMode == 2)
22664 {
22665 NetMessage.SendTileSquare(-1, checkedX - 1, i - num2, 3, num2);
22666 }
22667 return true;
22668 }
22669
22670 public static void GrowUndergroundTree(int i, int y)
22671 {
22672 if (Main.tile[i, y].type != 60 || !Main.tile[i, y].nactive() || Main.tile[i, y].halfBrick() || Main.tile[i, y].slope() != 0 || Main.tile[i, y].type != 60 || ((!Main.tile[i - 1, y].active() || Main.tile[i - 1, y].type != 60) && (!Main.tile[i + 1, y].active() || Main.tile[i + 1, y].type != 60)))
22673 {
22674 return;
22675 }
22676 int num = 1;
22677 int num2 = genRand.Next(5, 15);
22678 int num3 = num2 + 2;
22679 if (Main.tile[i, y].type == 60)
22680 {
22681 num3 += 5;
22682 }
22683 if (!EmptyTileCheck(i - num, i + num, y - num3, y - 1, 20))
22684 {
22685 return;
22686 }
22687 bool flag = false;
22688 bool flag2 = false;
22689 int num4;
22690 for (int j = y - num2; j < y; j++)
22691 {
22692 Main.tile[i, j].frameNumber((byte)genRand.Next(3));
22693 Main.tile[i, j].active(active: true);
22694 Main.tile[i, j].type = 5;
22695 num4 = genRand.Next(3);
22696 int num5 = genRand.Next(10);
22697 if (j == y - 1 || j == y - num2)
22698 {
22699 num5 = 0;
22700 }
22701 while (((num5 == 5 || num5 == 7) && flag) || ((num5 == 6 || num5 == 7) && flag2))
22702 {
22703 num5 = genRand.Next(10);
22704 }
22705 flag = false;
22706 flag2 = false;
22707 if (num5 == 5 || num5 == 7)
22708 {
22709 flag = true;
22710 }
22711 if (num5 == 6 || num5 == 7)
22712 {
22713 flag2 = true;
22714 }
22715 switch (num5)
22716 {
22717 case 1:
22718 if (num4 == 0)
22719 {
22720 Main.tile[i, j].frameX = 0;
22721 Main.tile[i, j].frameY = 66;
22722 }
22723 if (num4 == 1)
22724 {
22725 Main.tile[i, j].frameX = 0;
22726 Main.tile[i, j].frameY = 88;
22727 }
22728 if (num4 == 2)
22729 {
22730 Main.tile[i, j].frameX = 0;
22731 Main.tile[i, j].frameY = 110;
22732 }
22733 break;
22734 case 2:
22735 if (num4 == 0)
22736 {
22737 Main.tile[i, j].frameX = 22;
22738 Main.tile[i, j].frameY = 0;
22739 }
22740 if (num4 == 1)
22741 {
22742 Main.tile[i, j].frameX = 22;
22743 Main.tile[i, j].frameY = 22;
22744 }
22745 if (num4 == 2)
22746 {
22747 Main.tile[i, j].frameX = 22;
22748 Main.tile[i, j].frameY = 44;
22749 }
22750 break;
22751 case 3:
22752 if (num4 == 0)
22753 {
22754 Main.tile[i, j].frameX = 44;
22755 Main.tile[i, j].frameY = 66;
22756 }
22757 if (num4 == 1)
22758 {
22759 Main.tile[i, j].frameX = 44;
22760 Main.tile[i, j].frameY = 88;
22761 }
22762 if (num4 == 2)
22763 {
22764 Main.tile[i, j].frameX = 44;
22765 Main.tile[i, j].frameY = 110;
22766 }
22767 break;
22768 case 4:
22769 if (num4 == 0)
22770 {
22771 Main.tile[i, j].frameX = 22;
22772 Main.tile[i, j].frameY = 66;
22773 }
22774 if (num4 == 1)
22775 {
22776 Main.tile[i, j].frameX = 22;
22777 Main.tile[i, j].frameY = 88;
22778 }
22779 if (num4 == 2)
22780 {
22781 Main.tile[i, j].frameX = 22;
22782 Main.tile[i, j].frameY = 110;
22783 }
22784 break;
22785 case 5:
22786 if (num4 == 0)
22787 {
22788 Main.tile[i, j].frameX = 88;
22789 Main.tile[i, j].frameY = 0;
22790 }
22791 if (num4 == 1)
22792 {
22793 Main.tile[i, j].frameX = 88;
22794 Main.tile[i, j].frameY = 22;
22795 }
22796 if (num4 == 2)
22797 {
22798 Main.tile[i, j].frameX = 88;
22799 Main.tile[i, j].frameY = 44;
22800 }
22801 break;
22802 case 6:
22803 if (num4 == 0)
22804 {
22805 Main.tile[i, j].frameX = 66;
22806 Main.tile[i, j].frameY = 66;
22807 }
22808 if (num4 == 1)
22809 {
22810 Main.tile[i, j].frameX = 66;
22811 Main.tile[i, j].frameY = 88;
22812 }
22813 if (num4 == 2)
22814 {
22815 Main.tile[i, j].frameX = 66;
22816 Main.tile[i, j].frameY = 110;
22817 }
22818 break;
22819 case 7:
22820 if (num4 == 0)
22821 {
22822 Main.tile[i, j].frameX = 110;
22823 Main.tile[i, j].frameY = 66;
22824 }
22825 if (num4 == 1)
22826 {
22827 Main.tile[i, j].frameX = 110;
22828 Main.tile[i, j].frameY = 88;
22829 }
22830 if (num4 == 2)
22831 {
22832 Main.tile[i, j].frameX = 110;
22833 Main.tile[i, j].frameY = 110;
22834 }
22835 break;
22836 default:
22837 if (num4 == 0)
22838 {
22839 Main.tile[i, j].frameX = 0;
22840 Main.tile[i, j].frameY = 0;
22841 }
22842 if (num4 == 1)
22843 {
22844 Main.tile[i, j].frameX = 0;
22845 Main.tile[i, j].frameY = 22;
22846 }
22847 if (num4 == 2)
22848 {
22849 Main.tile[i, j].frameX = 0;
22850 Main.tile[i, j].frameY = 44;
22851 }
22852 break;
22853 }
22854 if (num5 == 5 || num5 == 7)
22855 {
22856 Main.tile[i - 1, j].active(active: true);
22857 Main.tile[i - 1, j].type = 5;
22858 num4 = genRand.Next(3);
22859 if (genRand.Next(3) < 2)
22860 {
22861 if (num4 == 0)
22862 {
22863 Main.tile[i - 1, j].frameX = 44;
22864 Main.tile[i - 1, j].frameY = 198;
22865 }
22866 if (num4 == 1)
22867 {
22868 Main.tile[i - 1, j].frameX = 44;
22869 Main.tile[i - 1, j].frameY = 220;
22870 }
22871 if (num4 == 2)
22872 {
22873 Main.tile[i - 1, j].frameX = 44;
22874 Main.tile[i - 1, j].frameY = 242;
22875 }
22876 }
22877 else
22878 {
22879 if (num4 == 0)
22880 {
22881 Main.tile[i - 1, j].frameX = 66;
22882 Main.tile[i - 1, j].frameY = 0;
22883 }
22884 if (num4 == 1)
22885 {
22886 Main.tile[i - 1, j].frameX = 66;
22887 Main.tile[i - 1, j].frameY = 22;
22888 }
22889 if (num4 == 2)
22890 {
22891 Main.tile[i - 1, j].frameX = 66;
22892 Main.tile[i - 1, j].frameY = 44;
22893 }
22894 }
22895 }
22896 if (num5 != 6 && num5 != 7)
22897 {
22898 continue;
22899 }
22900 Main.tile[i + 1, j].active(active: true);
22901 Main.tile[i + 1, j].type = 5;
22902 num4 = genRand.Next(3);
22903 if (genRand.Next(3) < 2)
22904 {
22905 if (num4 == 0)
22906 {
22907 Main.tile[i + 1, j].frameX = 66;
22908 Main.tile[i + 1, j].frameY = 198;
22909 }
22910 if (num4 == 1)
22911 {
22912 Main.tile[i + 1, j].frameX = 66;
22913 Main.tile[i + 1, j].frameY = 220;
22914 }
22915 if (num4 == 2)
22916 {
22917 Main.tile[i + 1, j].frameX = 66;
22918 Main.tile[i + 1, j].frameY = 242;
22919 }
22920 }
22921 else
22922 {
22923 if (num4 == 0)
22924 {
22925 Main.tile[i + 1, j].frameX = 88;
22926 Main.tile[i + 1, j].frameY = 66;
22927 }
22928 if (num4 == 1)
22929 {
22930 Main.tile[i + 1, j].frameX = 88;
22931 Main.tile[i + 1, j].frameY = 88;
22932 }
22933 if (num4 == 2)
22934 {
22935 Main.tile[i + 1, j].frameX = 88;
22936 Main.tile[i + 1, j].frameY = 110;
22937 }
22938 }
22939 }
22940 int num6 = genRand.Next(3);
22941 bool flag3 = false;
22942 bool flag4 = false;
22943 if (Main.tile[i - 1, y].nactive() && !Main.tile[i - 1, y].halfBrick() && Main.tile[i - 1, y].slope() == 0 && (Main.tile[i - 1, y].type == 2 || Main.tile[i - 1, y].type == 23 || Main.tile[i - 1, y].type == 60 || Main.tile[i - 1, y].type == 109 || Main.tile[i - 1, y].type == 147))
22944 {
22945 flag3 = true;
22946 }
22947 if (Main.tile[i + 1, y].nactive() && !Main.tile[i + 1, y].halfBrick() && Main.tile[i + 1, y].slope() == 0 && (Main.tile[i + 1, y].type == 2 || Main.tile[i + 1, y].type == 23 || Main.tile[i + 1, y].type == 60 || Main.tile[i + 1, y].type == 109 || Main.tile[i + 1, y].type == 147))
22948 {
22949 flag4 = true;
22950 }
22951 if (!flag3)
22952 {
22953 if (num6 == 0)
22954 {
22955 num6 = 2;
22956 }
22957 if (num6 == 1)
22958 {
22959 num6 = 3;
22960 }
22961 }
22962 if (!flag4)
22963 {
22964 if (num6 == 0)
22965 {
22966 num6 = 1;
22967 }
22968 if (num6 == 2)
22969 {
22970 num6 = 3;
22971 }
22972 }
22973 if (flag3 && !flag4)
22974 {
22975 num6 = 2;
22976 }
22977 if (flag4 && !flag3)
22978 {
22979 num6 = 1;
22980 }
22981 if (num6 == 0 || num6 == 1)
22982 {
22983 Main.tile[i + 1, y - 1].active(active: true);
22984 Main.tile[i + 1, y - 1].type = 5;
22985 num4 = genRand.Next(3);
22986 if (num4 == 0)
22987 {
22988 Main.tile[i + 1, y - 1].frameX = 22;
22989 Main.tile[i + 1, y - 1].frameY = 132;
22990 }
22991 if (num4 == 1)
22992 {
22993 Main.tile[i + 1, y - 1].frameX = 22;
22994 Main.tile[i + 1, y - 1].frameY = 154;
22995 }
22996 if (num4 == 2)
22997 {
22998 Main.tile[i + 1, y - 1].frameX = 22;
22999 Main.tile[i + 1, y - 1].frameY = 176;
23000 }
23001 }
23002 if (num6 == 0 || num6 == 2)
23003 {
23004 Main.tile[i - 1, y - 1].active(active: true);
23005 Main.tile[i - 1, y - 1].type = 5;
23006 num4 = genRand.Next(3);
23007 if (num4 == 0)
23008 {
23009 Main.tile[i - 1, y - 1].frameX = 44;
23010 Main.tile[i - 1, y - 1].frameY = 132;
23011 }
23012 if (num4 == 1)
23013 {
23014 Main.tile[i - 1, y - 1].frameX = 44;
23015 Main.tile[i - 1, y - 1].frameY = 154;
23016 }
23017 if (num4 == 2)
23018 {
23019 Main.tile[i - 1, y - 1].frameX = 44;
23020 Main.tile[i - 1, y - 1].frameY = 176;
23021 }
23022 }
23023 num4 = genRand.Next(3);
23024 switch (num6)
23025 {
23026 case 0:
23027 if (num4 == 0)
23028 {
23029 Main.tile[i, y - 1].frameX = 88;
23030 Main.tile[i, y - 1].frameY = 132;
23031 }
23032 if (num4 == 1)
23033 {
23034 Main.tile[i, y - 1].frameX = 88;
23035 Main.tile[i, y - 1].frameY = 154;
23036 }
23037 if (num4 == 2)
23038 {
23039 Main.tile[i, y - 1].frameX = 88;
23040 Main.tile[i, y - 1].frameY = 176;
23041 }
23042 break;
23043 case 1:
23044 if (num4 == 0)
23045 {
23046 Main.tile[i, y - 1].frameX = 0;
23047 Main.tile[i, y - 1].frameY = 132;
23048 }
23049 if (num4 == 1)
23050 {
23051 Main.tile[i, y - 1].frameX = 0;
23052 Main.tile[i, y - 1].frameY = 154;
23053 }
23054 if (num4 == 2)
23055 {
23056 Main.tile[i, y - 1].frameX = 0;
23057 Main.tile[i, y - 1].frameY = 176;
23058 }
23059 break;
23060 case 2:
23061 if (num4 == 0)
23062 {
23063 Main.tile[i, y - 1].frameX = 66;
23064 Main.tile[i, y - 1].frameY = 132;
23065 }
23066 if (num4 == 1)
23067 {
23068 Main.tile[i, y - 1].frameX = 66;
23069 Main.tile[i, y - 1].frameY = 154;
23070 }
23071 if (num4 == 2)
23072 {
23073 Main.tile[i, y - 1].frameX = 66;
23074 Main.tile[i, y - 1].frameY = 176;
23075 }
23076 break;
23077 }
23078 if (genRand.Next(8) != 0)
23079 {
23080 num4 = genRand.Next(3);
23081 if (num4 == 0)
23082 {
23083 Main.tile[i, y - num2].frameX = 22;
23084 Main.tile[i, y - num2].frameY = 198;
23085 }
23086 if (num4 == 1)
23087 {
23088 Main.tile[i, y - num2].frameX = 22;
23089 Main.tile[i, y - num2].frameY = 220;
23090 }
23091 if (num4 == 2)
23092 {
23093 Main.tile[i, y - num2].frameX = 22;
23094 Main.tile[i, y - num2].frameY = 242;
23095 }
23096 }
23097 else
23098 {
23099 num4 = genRand.Next(3);
23100 if (num4 == 0)
23101 {
23102 Main.tile[i, y - num2].frameX = 0;
23103 Main.tile[i, y - num2].frameY = 198;
23104 }
23105 if (num4 == 1)
23106 {
23107 Main.tile[i, y - num2].frameX = 0;
23108 Main.tile[i, y - num2].frameY = 220;
23109 }
23110 if (num4 == 2)
23111 {
23112 Main.tile[i, y - num2].frameX = 0;
23113 Main.tile[i, y - num2].frameY = 242;
23114 }
23115 }
23116 RangeFrame(i - 2, y - num2 - 1, i + 2, y + 1);
23117 if (Main.netMode == 2 && !gen)
23118 {
23119 NetMessage.SendTileSquare(-1, i - 1, y - num2, 3, num2);
23120 }
23121 }
23122
23123 public static bool GrowShroom(int i, int y)
23124 {
23125 if (Main.tile[i - 1, y - 1].lava() || Main.tile[i - 1, y - 1].lava() || Main.tile[i + 1, y - 1].lava())
23126 {
23127 return false;
23128 }
23129 if (Main.tile[i, y].nactive() && Main.tile[i, y].type == 70 && Main.tile[i, y - 1].wall == 0 && Main.tile[i - 1, y].active() && Main.tile[i - 1, y].type == 70 && Main.tile[i + 1, y].active() && Main.tile[i + 1, y].type == 70 && EmptyTileCheck(i - 2, i + 2, y - 13, y - 3, 71) && EmptyTileCheck(i - 1, i + 1, y - 3, y - 1, 71))
23130 {
23131 if (gen && genRand.Next(3) != 0)
23132 {
23133 Main.tile[i, y].halfBrick(halfBrick: false);
23134 Main.tile[i, y].slope(0);
23135 }
23136 if (!Main.tile[i, y].halfBrick() && Main.tile[i, y].slope() == 0)
23137 {
23138 int num = genRand.Next(4, 11);
23139 for (int j = y - num; j < y; j++)
23140 {
23141 Main.tile[i, j].frameNumber((byte)genRand.Next(3));
23142 Main.tile[i, j].active(active: true);
23143 Main.tile[i, j].type = 72;
23144 int num2 = genRand.Next(3);
23145 if (num2 == 0)
23146 {
23147 Main.tile[i, j].frameX = 0;
23148 Main.tile[i, j].frameY = 0;
23149 }
23150 if (num2 == 1)
23151 {
23152 Main.tile[i, j].frameX = 0;
23153 Main.tile[i, j].frameY = 18;
23154 }
23155 if (num2 == 2)
23156 {
23157 Main.tile[i, j].frameX = 0;
23158 Main.tile[i, j].frameY = 36;
23159 }
23160 }
23161 int num3 = genRand.Next(3);
23162 if (num3 == 0)
23163 {
23164 Main.tile[i, y - num].frameX = 36;
23165 Main.tile[i, y - num].frameY = 0;
23166 }
23167 if (num3 == 1)
23168 {
23169 Main.tile[i, y - num].frameX = 36;
23170 Main.tile[i, y - num].frameY = 18;
23171 }
23172 if (num3 == 2)
23173 {
23174 Main.tile[i, y - num].frameX = 36;
23175 Main.tile[i, y - num].frameY = 36;
23176 }
23177 RangeFrame(i - 2, y - num - 1, i + 2, y + 1);
23178 if (Main.netMode == 2)
23179 {
23180 NetMessage.SendTileSquare(-1, i - 1, y - num, 3, num);
23181 }
23182 return true;
23183 }
23184 }
23185 return false;
23186 }
23187
23188 public static void AddTrees(bool undergroundOnly = false)
23189 {
23190 double num = 0.1 + genRand.NextDouble() * 0.35;
23191 double num2 = 0.1 + genRand.NextDouble() * 0.35;
23192 int num3 = 20;
23193 int num4 = (int)Main.worldSurface;
23194 if (!undergroundOnly)
23195 {
23196 for (int i = 1; i < Main.maxTilesX - 1; i++)
23197 {
23198 for (int j = num3; j < num4; j++)
23199 {
23200 if (i < 380)
23201 {
23202 if (genRand.NextDouble() < num && Main.tile[i, j].liquid == 0)
23203 {
23204 GrowPalmTree(i, j);
23205 }
23206 }
23207 else if (i > Main.maxTilesX - 380 && genRand.NextDouble() < num2 && Main.tile[i, j].liquid == 0)
23208 {
23209 GrowPalmTree(i, j);
23210 }
23211 int num5 = 20;
23212 if (drunkWorldGen)
23213 {
23214 num5 /= 3;
23215 }
23216 if (remixWorldGen)
23217 {
23218 num5 /= 2;
23219 }
23220 if (Main.tile[i, j].type == 2 && (Main.tenthAnniversaryWorld || genRand.Next(num5) == 0))
23221 {
23222 if (genRand.Next(2) == 0)
23223 {
23224 GrowTreeWithSettings(i, j, GrowTreeSettings.Profiles.VanityTree_Willow);
23225 }
23226 else
23227 {
23228 GrowTreeWithSettings(i, j, GrowTreeSettings.Profiles.VanityTree_Sakura);
23229 }
23230 }
23231 else
23232 {
23233 GrowTree(i, j);
23234 }
23235 }
23236 if (genRand.Next(3) == 0)
23237 {
23238 i++;
23239 }
23240 if (genRand.Next(4) == 0)
23241 {
23242 i++;
23243 }
23244 }
23245 }
23246 if (!remixWorldGen)
23247 {
23248 return;
23249 }
23250 num3 = (int)Main.worldSurface;
23251 num4 = Main.maxTilesY - 300;
23252 for (int k = 1; k < Main.maxTilesX - 1; k++)
23253 {
23254 for (int l = num3; l < num4; l++)
23255 {
23256 int maxValue = 7;
23257 if (Main.tile[k, l].type == 2 && (Main.tenthAnniversaryWorld || genRand.Next(maxValue) == 0))
23258 {
23259 if (genRand.Next(2) == 0)
23260 {
23261 GrowTreeWithSettings(k, l, GrowTreeSettings.Profiles.VanityTree_Willow);
23262 }
23263 else
23264 {
23265 GrowTreeWithSettings(k, l, GrowTreeSettings.Profiles.VanityTree_Sakura);
23266 }
23267 }
23268 else
23269 {
23270 GrowTree(k, l);
23271 }
23272 }
23273 }
23274 }
23275
23276 public static void ExplodeMine(int i, int j, bool fromWiring)
23277 {
23278 _ = Main.tile[i, j].type;
23279 KillTile(i, j, fail: false, effectOnly: false, noItem: true);
23280 NetMessage.SendTileSquare(-1, i, j);
23281 Projectile.NewProjectile(GetProjectileSource_PlayerOrWires(i, j, fromWiring, Main.LocalPlayer), i * 16 + 8, j * 16 + 8, 0f, 0f, 164, 250, 10f, Main.myPlayer);
23282 }
23283
23284 public static bool EmptyTileCheck(int startX, int endX, int startY, int endY, int ignoreID = -1)
23285 {
23286 if (startX < 0)
23287 {
23288 return false;
23289 }
23290 if (endX >= Main.maxTilesX)
23291 {
23292 return false;
23293 }
23294 if (startY < 0)
23295 {
23296 return false;
23297 }
23298 if (endY >= Main.maxTilesY)
23299 {
23300 return false;
23301 }
23302 bool flag = false;
23304 {
23305 flag = true;
23306 }
23307 for (int i = startX; i < endX + 1; i++)
23308 {
23309 for (int j = startY; j < endY + 1; j++)
23310 {
23311 if (!Main.tile[i, j].active())
23312 {
23313 continue;
23314 }
23315 switch (ignoreID)
23316 {
23317 case -1:
23318 return false;
23319 case 11:
23320 {
23321 ushort type = Main.tile[i, j].type;
23322 if (type == 11)
23323 {
23324 continue;
23325 }
23326 return false;
23327 }
23328 case 71:
23329 {
23330 ushort type = Main.tile[i, j].type;
23331 if (type == 71)
23332 {
23333 continue;
23334 }
23335 return false;
23336 }
23337 }
23338 if (flag)
23339 {
23340 if (TileID.Sets.CommonSapling[Main.tile[i, j].type])
23341 {
23342 break;
23343 }
23344 switch (Main.tile[i, j].type)
23345 {
23346 case 3:
23347 case 24:
23348 case 32:
23349 case 61:
23350 case 62:
23351 case 69:
23352 case 71:
23353 case 73:
23354 case 74:
23355 case 82:
23356 case 83:
23357 case 84:
23358 case 110:
23359 case 113:
23360 case 184:
23361 case 201:
23362 case 233:
23363 case 352:
23364 case 485:
23365 case 529:
23366 case 530:
23367 case 637:
23368 case 655:
23369 continue;
23370 }
23371 return false;
23372 }
23373 }
23374 }
23375 return true;
23376 }
23377
23378 public static void StartHardmode()
23379 {
23380 if (Main.netMode != 1 && !Main.hardMode)
23381 {
23382 Main.hardMode = true;
23383 ThreadPool.QueueUserWorkItem(smCallBack, 1);
23384 }
23385 }
23386
23387 public static void TryProtectingSpawnedItems()
23388 {
23389 for (int i = 0; i < 400; i++)
23390 {
23391 Item item = Main.item[i];
23392 if (EligibleForSpawnProtection(item))
23393 {
23394 item.timeSinceItemSpawned -= 18000;
23395 }
23396 }
23397 }
23398
23400 {
23401 if (item.active)
23402 {
23403 return ItemID.Sets.OverflowProtectionTimeOffset[item.type] == 0;
23404 }
23405 return false;
23406 }
23407
23408 public static void UndoSpawnedItemProtection()
23409 {
23410 for (int i = 0; i < 400; i++)
23411 {
23412 Item item = Main.item[i];
23413 if (EligibleForSpawnProtection(item) && item.timeSinceItemSpawned < 0)
23414 {
23415 item.timeSinceItemSpawned += 18000;
23416 }
23417 }
23418 }
23419
23420 public static void smCallBack(object threadContext)
23421 {
23422 IsGeneratingHardMode = true;
23423 TryProtectingSpawnedItems();
23424 if (Main.rand == null)
23425 {
23426 Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
23427 }
23428 double num = (double)genRand.Next(300, 400) * 0.001;
23429 double num2 = (double)genRand.Next(200, 300) * 0.001;
23430 int num3 = (int)((double)Main.maxTilesX * num);
23431 int num4 = (int)((double)Main.maxTilesX * (1.0 - num));
23432 int num5 = 1;
23433 if (genRand.Next(2) == 0)
23434 {
23435 num4 = (int)((double)Main.maxTilesX * num);
23436 num3 = (int)((double)Main.maxTilesX * (1.0 - num));
23437 num5 = -1;
23438 }
23439 int num6 = 1;
23440 if (GenVars.dungeonX < Main.maxTilesX / 2)
23441 {
23442 num6 = -1;
23443 }
23444 if (num6 < 0)
23445 {
23446 if (num4 < num3)
23447 {
23448 num4 = (int)((double)Main.maxTilesX * num2);
23449 }
23450 else
23451 {
23452 num3 = (int)((double)Main.maxTilesX * num2);
23453 }
23454 }
23455 else if (num4 > num3)
23456 {
23457 num4 = (int)((double)Main.maxTilesX * (1.0 - num2));
23458 }
23459 else
23460 {
23461 num3 = (int)((double)Main.maxTilesX * (1.0 - num2));
23462 }
23463 if (Main.remixWorld)
23464 {
23465 int num7 = Main.maxTilesX / 7;
23466 int num8 = Main.maxTilesX / 14;
23467 if (Main.dungeonX < Main.maxTilesX / 2)
23468 {
23469 for (int i = Main.maxTilesX - num7 - num8; i < Main.maxTilesX; i++)
23470 {
23471 for (int j = (int)Main.worldSurface + genRand.Next(-1, 2); j < Main.maxTilesY - 10; j++)
23472 {
23473 if (i > Main.maxTilesX - num7)
23474 {
23475 Convert(i, j, 2, 1);
23476 }
23477 else if (TileID.Sets.Crimson[Main.tile[i, j].type] || TileID.Sets.Corrupt[Main.tile[i, j].type])
23478 {
23479 Convert(i, j, 2, 1);
23480 }
23481 }
23482 }
23483 }
23484 else
23485 {
23486 for (int k = 0; k < num7 + num8; k++)
23487 {
23488 for (int l = (int)Main.worldSurface + genRand.Next(-1, 2); l < Main.maxTilesY - 10; l++)
23489 {
23490 if (k < num7)
23491 {
23492 Convert(k, l, 2, 1);
23493 }
23494 else if (TileID.Sets.Crimson[Main.tile[k, l].type] || TileID.Sets.Corrupt[Main.tile[k, l].type])
23495 {
23496 Convert(k, l, 2, 1);
23497 }
23498 }
23499 }
23500 }
23501 }
23502 else
23503 {
23504 GERunner(num3, 0, 3 * num5, 5.0);
23505 GERunner(num4, 0, 3 * -num5, 5.0, good: false);
23506 }
23507 double num9 = (double)Main.maxTilesX / 4200.0;
23508 int num10 = (int)(25.0 * num9);
23510 int num11 = 0;
23511 while (num10 > 0)
23512 {
23513 if (++num11 % 15000 == 0)
23514 {
23515 num10--;
23516 }
23517 Point point = RandomWorldPoint((int)Main.worldSurface - 100, 1, 190, 1);
23518 Tile tile = Main.tile[point.X, point.Y];
23519 Tile tile2 = Main.tile[point.X, point.Y - 1];
23520 ushort num12 = 0;
23521 if (TileID.Sets.Crimson[tile.type])
23522 {
23523 num12 = (ushort)(192 + genRand.Next(4));
23524 }
23525 else if (TileID.Sets.Corrupt[tile.type])
23526 {
23527 num12 = (ushort)(188 + genRand.Next(4));
23528 }
23529 else if (TileID.Sets.Hallow[tile.type])
23530 {
23531 num12 = (ushort)(200 + genRand.Next(4));
23532 }
23533 if (tile.active() && num12 != 0 && !tile2.active())
23534 {
23535 bool flag = WorldUtils.Gen(new Point(point.X, point.Y - 1), new ShapeFloodFill(1000), Actions.Chain(new Modifiers.IsNotSolid(), new Modifiers.OnlyWalls(0, 54, 55, 56, 57, 58, 59, 61, 185, 212, 213, 214, 215, 2, 196, 197, 198, 199, 15, 40, 71, 64, 204, 205, 206, 207, 208, 209, 210, 211, 71), new Actions.Blank().Output(shapeData)));
23536 if (shapeData.Count > 50 && flag)
23537 {
23538 WorldUtils.Gen(new Point(point.X, point.Y), new ModShapes.OuterOutline(shapeData, useDiagonals: true, useInterior: true), new Actions.PlaceWall(num12));
23539 num10--;
23540 }
23541 shapeData.Clear();
23542 }
23543 }
23544 if (Main.netMode == 0)
23545 {
23546 Main.NewText(Lang.misc[15].Value, 50, byte.MaxValue, 130);
23547 }
23548 else if (Main.netMode == 2)
23549 {
23550 ChatHelper.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[15].Key), new Color(50, 255, 130));
23551 }
23553 if (Main.netMode == 2)
23554 {
23556 }
23557 UndoSpawnedItemProtection();
23558 IsGeneratingHardMode = false;
23559 }
23560
23561 public static bool PlaceDoor(int i, int j, int type, int style = 0)
23562 {
23563 int num = style / 36;
23564 int num2 = style % 36;
23565 int num3 = 54 * num;
23566 int num4 = 54 * num2;
23567 try
23568 {
23569 if (Main.tile[i, j - 2].nactive() && Main.tileSolid[Main.tile[i, j - 2].type] && SolidTile(i, j + 2))
23570 {
23571 Main.tile[i, j - 1].active(active: true);
23572 Main.tile[i, j - 1].type = 10;
23573 Main.tile[i, j - 1].frameY = (short)num4;
23574 Main.tile[i, j - 1].frameX = (short)(num3 + genRand.Next(3) * 18);
23575 Main.tile[i, j].active(active: true);
23576 Main.tile[i, j].type = 10;
23577 Main.tile[i, j].frameY = (short)(num4 + 18);
23578 Main.tile[i, j].frameX = (short)(num3 + genRand.Next(3) * 18);
23579 Main.tile[i, j + 1].active(active: true);
23580 Main.tile[i, j + 1].type = 10;
23581 Main.tile[i, j + 1].frameY = (short)(num4 + 36);
23582 Main.tile[i, j + 1].frameX = (short)(num3 + genRand.Next(3) * 18);
23583 return true;
23584 }
23585 return false;
23586 }
23587 catch
23588 {
23589 return false;
23590 }
23591 }
23592
23593 public static bool CloseDoor(int i, int j, bool forced = false)
23594 {
23595 int num = 0;
23596 int num2 = i;
23597 int num3 = j;
23598 if (Main.tile[i, j] == null)
23599 {
23600 Main.tile[i, j] = new Tile();
23601 }
23602 int frameX = Main.tile[i, j].frameX;
23603 Tile tile = Main.tile[i, j];
23604 if (tile.type != 11)
23605 {
23606 return false;
23607 }
23608 int num4 = tile.frameY;
23609 int num5 = 0;
23610 int num6 = 0;
23611 while (num4 >= 54)
23612 {
23613 num4 -= 54;
23614 num5++;
23615 }
23616 if (frameX >= 72)
23617 {
23618 num5 += 36 * (frameX / 72);
23619 num6 += 54 * (frameX / 72);
23620 }
23621 num3 = j - num4 / 18;
23622 switch (frameX % 72)
23623 {
23624 case 0:
23625 num2 = i;
23626 num = 1;
23627 break;
23628 case 18:
23629 num2 = i - 1;
23630 num = 1;
23631 break;
23632 case 36:
23633 num2 = i + 1;
23634 num = -1;
23635 break;
23636 case 54:
23637 num2 = i;
23638 num = -1;
23639 break;
23640 }
23641 int num7 = num2;
23642 if (num == -1)
23643 {
23644 num7 = num2 - 1;
23645 }
23646 if (!forced)
23647 {
23648 for (int k = num3; k < num3 + 3; k++)
23649 {
23650 if (!Collision.EmptyTile(num2, k, ignoreTiles: true))
23651 {
23652 return false;
23653 }
23654 }
23655 }
23656 for (int l = num7; l < num7 + 2; l++)
23657 {
23658 for (int m = num3; m < num3 + 3; m++)
23659 {
23660 if (l == num2)
23661 {
23662 if (Main.tile[l, m] == null)
23663 {
23664 Main.tile[l, m] = new Tile();
23665 }
23666 Main.tile[l, m].type = 10;
23667 Main.tile[l, m].frameX = (short)(genRand.Next(3) * 18 + num6);
23668 }
23669 else
23670 {
23671 if (Main.tile[l, m] == null)
23672 {
23673 Main.tile[l, m] = new Tile();
23674 }
23675 Main.tile[l, m].active(active: false);
23676 }
23677 }
23678 }
23679 if (Main.netMode != 1 && Wiring.running)
23680 {
23682 Wiring.SkipWire(num2, num3 + 1);
23683 Wiring.SkipWire(num2, num3 + 2);
23684 }
23685 for (int n = num2 - 1; n <= num2 + 1; n++)
23686 {
23687 for (int num8 = num3 - 1; num8 <= num3 + 2; num8++)
23688 {
23689 TileFrame(n, num8);
23690 }
23691 }
23692 SoundEngine.PlaySound(9, i * 16, j * 16);
23693 return true;
23694 }
23695
23696 public static bool AddLifeCrystal(int i, int j)
23697 {
23698 for (int k = j; k < Main.maxTilesY; k++)
23699 {
23700 if (Main.tile[i, k].active() && Main.tileSolid[Main.tile[i, k].type])
23701 {
23702 int num = k - 1;
23703 if (Main.tile[i, num - 1].lava() || Main.tile[i - 1, num - 1].lava())
23704 {
23705 return false;
23706 }
23707 if (Main.tile[i, num - 1].shimmer())
23708 {
23709 return false;
23710 }
23711 if (!EmptyTileCheck(i - 1, i, num - 1, num))
23712 {
23713 return false;
23714 }
23715 if (Main.wallDungeon[Main.tile[i, num].wall])
23716 {
23717 return false;
23718 }
23719 Tile tile = Main.tile[i - 1, num + 1];
23720 Tile tile2 = Main.tile[i, num + 1];
23721 if (!tile.nactive() || !Main.tileSolid[tile.type])
23722 {
23723 return false;
23724 }
23725 if (!tile2.nactive() || !Main.tileSolid[tile2.type])
23726 {
23727 return false;
23728 }
23729 if (tile.blockType() != 0)
23730 {
23731 tile.slope(0);
23732 tile.halfBrick(halfBrick: false);
23733 }
23734 if (tile2.blockType() != 0)
23735 {
23736 tile2.slope(0);
23737 tile2.halfBrick(halfBrick: false);
23738 }
23739 Main.tile[i - 1, num - 1].active(active: true);
23740 Main.tile[i - 1, num - 1].type = 12;
23741 Main.tile[i - 1, num - 1].frameX = 0;
23742 Main.tile[i - 1, num - 1].frameY = 0;
23743 Main.tile[i, num - 1].active(active: true);
23744 Main.tile[i, num - 1].type = 12;
23745 Main.tile[i, num - 1].frameX = 18;
23746 Main.tile[i, num - 1].frameY = 0;
23747 Main.tile[i - 1, num].active(active: true);
23748 Main.tile[i - 1, num].type = 12;
23749 Main.tile[i - 1, num].frameX = 0;
23750 Main.tile[i - 1, num].frameY = 18;
23751 Main.tile[i, num].active(active: true);
23752 Main.tile[i, num].type = 12;
23753 Main.tile[i, num].frameX = 18;
23754 Main.tile[i, num].frameY = 18;
23755 return true;
23756 }
23757 }
23758 return false;
23759 }
23760
23761 public static void AddShadowOrb(int x, int y)
23762 {
23764 {
23765 return;
23766 }
23767 for (int i = x - 1; i < x + 1; i++)
23768 {
23769 for (int j = y - 1; j < y + 1; j++)
23770 {
23771 if (Main.tile[i, j].active() && Main.tile[i, j].type == 31)
23772 {
23773 return;
23774 }
23775 }
23776 }
23777 short num = 0;
23778 if (crimson)
23779 {
23780 num += 36;
23781 }
23782 Main.tile[x - 1, y - 1].active(active: true);
23783 Main.tile[x - 1, y - 1].type = 31;
23784 Main.tile[x - 1, y - 1].frameX = num;
23785 Main.tile[x - 1, y - 1].frameY = 0;
23786 Main.tile[x, y - 1].active(active: true);
23787 Main.tile[x, y - 1].type = 31;
23788 Main.tile[x, y - 1].frameX = (short)(18 + num);
23789 Main.tile[x, y - 1].frameY = 0;
23790 Main.tile[x - 1, y].active(active: true);
23791 Main.tile[x - 1, y].type = 31;
23792 Main.tile[x - 1, y].frameX = num;
23793 Main.tile[x - 1, y].frameY = 18;
23794 Main.tile[x, y].active(active: true);
23795 Main.tile[x, y].type = 31;
23796 Main.tile[x, y].frameX = (short)(18 + num);
23797 Main.tile[x, y].frameY = 18;
23798 }
23799
23800 public static void AddHellHouses()
23801 {
23802 int num = (int)((double)Main.maxTilesX * 0.25);
23803 for (int i = 100; i < Main.maxTilesX - 100; i++)
23804 {
23805 if (((drunkWorldGen || remixWorldGen) && i > num && i < Main.maxTilesX - num) || (!drunkWorldGen && !remixWorldGen && (i < num || i > Main.maxTilesX - num)))
23806 {
23807 continue;
23808 }
23809 int num2 = Main.maxTilesY - 40;
23810 while (Main.tile[i, num2].active() || Main.tile[i, num2].liquid > 0)
23811 {
23812 num2--;
23813 }
23814 if (Main.tile[i, num2 + 1].active())
23815 {
23816 ushort num3 = (ushort)genRand.Next(75, 77);
23817 byte wallType = 13;
23818 if (genRand.Next(5) > 0)
23819 {
23820 num3 = 75;
23821 }
23822 if (num3 == 75)
23823 {
23824 wallType = 14;
23825 }
23826 if (getGoodWorldGen)
23827 {
23828 num3 = 76;
23829 }
23830 HellFort(i, num2, num3, wallType);
23831 i += genRand.Next(30, 130);
23832 if (genRand.Next(10) == 0)
23833 {
23834 i += genRand.Next(0, 200);
23835 }
23836 }
23837 }
23838 float num4 = Main.maxTilesX / 4200;
23839 for (int j = 0; (float)j < 200f * num4; j++)
23840 {
23841 int num5 = 0;
23842 bool flag = false;
23843 while (!flag)
23844 {
23845 num5++;
23846 int num6 = genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8));
23847 int num7 = genRand.Next(Main.maxTilesY - 300, Main.maxTilesY - 20);
23848 if (Main.tile[num6, num7].active() && (Main.tile[num6, num7].type == 75 || Main.tile[num6, num7].type == 76))
23849 {
23850 int num8 = 0;
23851 if (Main.tile[num6 - 1, num7].wall > 0)
23852 {
23853 num8 = -1;
23854 }
23855 else if (Main.tile[num6 + 1, num7].wall > 0)
23856 {
23857 num8 = 1;
23858 }
23859 if (!Main.tile[num6 + num8, num7].active() && !Main.tile[num6 + num8, num7 + 1].active())
23860 {
23861 bool flag2 = false;
23862 for (int k = num6 - 8; k < num6 + 8; k++)
23863 {
23864 for (int l = num7 - 8; l < num7 + 8; l++)
23865 {
23866 if (Main.tile[k, l].active() && Main.tile[k, l].type == 4)
23867 {
23868 flag2 = true;
23869 break;
23870 }
23871 }
23872 }
23873 if (!flag2)
23874 {
23875 PlaceTile(num6 + num8, num7, 4, mute: true, forced: true, -1, 7);
23876 flag = true;
23877 }
23878 }
23879 }
23880 if (num5 > 1000)
23881 {
23882 flag = true;
23883 }
23884 }
23885 }
23886 double num9 = 4200000.0 / (double)Main.maxTilesX;
23887 for (int m = 0; (double)m < num9; m++)
23888 {
23889 int num10 = 0;
23890 int num11 = genRand.Next(num, Main.maxTilesX - num);
23891 int n = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
23892 while ((Main.tile[num11, n].wall != 13 && Main.tile[num11, n].wall != 14) || Main.tile[num11, n].active())
23893 {
23894 num11 = genRand.Next(num, Main.maxTilesX - num);
23895 n = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
23896 if (drunkWorldGen || remixWorldGen)
23897 {
23898 num11 = ((genRand.Next(2) != 0) ? genRand.Next(Main.maxTilesX - num, Main.maxTilesX - 50) : genRand.Next(50, num));
23899 }
23900 num10++;
23901 if (num10 > 100000)
23902 {
23903 break;
23904 }
23905 }
23906 if (num10 > 100000 || (Main.tile[num11, n].wall != 13 && Main.tile[num11, n].wall != 14) || Main.tile[num11, n].active())
23907 {
23908 continue;
23909 }
23910 for (; !SolidTile(num11, n) && n < Main.maxTilesY - 20; n++)
23911 {
23912 }
23913 n--;
23914 int num12 = num11;
23915 int num13 = num11;
23916 while (!Main.tile[num12, n].active() && SolidTile(num12, n + 1))
23917 {
23918 num12--;
23919 }
23920 num12++;
23921 for (; !Main.tile[num13, n].active() && SolidTile(num13, n + 1); num13++)
23922 {
23923 }
23924 num13--;
23925 int num14 = num13 - num12;
23926 int num15 = (num13 + num12) / 2;
23927 if (Main.tile[num15, n].active() || (Main.tile[num15, n].wall != 13 && Main.tile[num15, n].wall != 14) || !SolidTile(num15, n + 1))
23928 {
23929 continue;
23930 }
23931 int style = 16;
23932 int style2 = 13;
23933 int style3 = 14;
23934 int style4 = 49;
23935 int style5 = 4;
23936 int style6 = 8;
23937 int style7 = 15;
23938 int style8 = 9;
23939 int style9 = 10;
23940 int style10 = 17;
23941 int style11 = 25;
23942 int style12 = 25;
23943 int style13 = 23;
23944 int style14 = 25;
23945 int num16 = genRand.Next(13);
23946 int num17 = 0;
23947 int num18 = 0;
23948 if (num16 == 0)
23949 {
23950 num17 = 5;
23951 num18 = 4;
23952 }
23953 if (num16 == 1)
23954 {
23955 num17 = 4;
23956 num18 = 3;
23957 }
23958 if (num16 == 2)
23959 {
23960 num17 = 3;
23961 num18 = 5;
23962 }
23963 if (num16 == 3)
23964 {
23965 num17 = 4;
23966 num18 = 6;
23967 }
23968 if (num16 == 4)
23969 {
23970 num17 = 3;
23971 num18 = 3;
23972 }
23973 if (num16 == 5)
23974 {
23975 num17 = 5;
23976 num18 = 3;
23977 }
23978 if (num16 == 6)
23979 {
23980 num17 = 5;
23981 num18 = 4;
23982 }
23983 if (num16 == 7)
23984 {
23985 num17 = 5;
23986 num18 = 4;
23987 }
23988 if (num16 == 8)
23989 {
23990 num17 = 5;
23991 num18 = 4;
23992 }
23993 if (num16 == 9)
23994 {
23995 num17 = 3;
23996 num18 = 5;
23997 }
23998 if (num16 == 10)
23999 {
24000 num17 = 5;
24001 num18 = 3;
24002 }
24003 if (num16 == 11)
24004 {
24005 num17 = 2;
24006 num18 = 4;
24007 }
24008 if (num16 == 12)
24009 {
24010 num17 = 3;
24011 num18 = 3;
24012 }
24013 for (int num19 = num15 - num17; num19 <= num15 + num17; num19++)
24014 {
24015 for (int num20 = n - num18; num20 <= n; num20++)
24016 {
24017 if (Main.tile[num19, num20].active())
24018 {
24019 num16 = -1;
24020 break;
24021 }
24022 }
24023 }
24024 if ((double)num14 < (double)num17 * 1.75)
24025 {
24026 num16 = -1;
24027 }
24028 switch (num16)
24029 {
24030 case 0:
24031 {
24032 PlaceTile(num15, n, 14, mute: true, forced: false, -1, style2);
24033 int num22 = genRand.Next(6);
24034 if (num22 < 3)
24035 {
24036 PlaceTile(num15 + num22, n - 2, 33, mute: true, forced: false, -1, style12);
24037 }
24038 if (!Main.tile[num15, n].active())
24039 {
24040 break;
24041 }
24042 if (!Main.tile[num15 - 2, n].active())
24043 {
24044 PlaceTile(num15 - 2, n, 15, mute: true, forced: false, -1, style);
24045 if (Main.tile[num15 - 2, n].active())
24046 {
24047 Main.tile[num15 - 2, n].frameX += 18;
24048 Main.tile[num15 - 2, n - 1].frameX += 18;
24049 }
24050 }
24051 if (!Main.tile[num15 + 2, n].active())
24052 {
24053 PlaceTile(num15 + 2, n, 15, mute: true, forced: false, -1, style);
24054 }
24055 break;
24056 }
24057 case 1:
24058 {
24059 PlaceTile(num15, n, 18, mute: true, forced: false, -1, style3);
24060 int num21 = genRand.Next(4);
24061 if (num21 < 2)
24062 {
24063 PlaceTile(num15 + num21, n - 1, 33, mute: true, forced: false, -1, style12);
24064 }
24065 if (!Main.tile[num15, n].active())
24066 {
24067 break;
24068 }
24069 if (genRand.Next(2) == 0)
24070 {
24071 if (!Main.tile[num15 - 1, n].active())
24072 {
24073 PlaceTile(num15 - 1, n, 15, mute: true, forced: false, -1, style);
24074 if (Main.tile[num15 - 1, n].active())
24075 {
24076 Main.tile[num15 - 1, n].frameX += 18;
24077 Main.tile[num15 - 1, n - 1].frameX += 18;
24078 }
24079 }
24080 }
24081 else if (!Main.tile[num15 + 2, n].active())
24082 {
24083 PlaceTile(num15 + 2, n, 15, mute: true, forced: false, -1, style);
24084 }
24085 break;
24086 }
24087 case 2:
24088 PlaceTile(num15, n, 105, mute: true, forced: false, -1, style4);
24089 break;
24090 case 3:
24091 PlaceTile(num15, n, 101, mute: true, forced: false, -1, style5);
24092 break;
24093 case 4:
24094 if (genRand.Next(2) == 0)
24095 {
24096 PlaceTile(num15, n, 15, mute: true, forced: false, -1, style);
24097 Main.tile[num15, n].frameX += 18;
24098 Main.tile[num15, n - 1].frameX += 18;
24099 }
24100 else
24101 {
24102 PlaceTile(num15, n, 15, mute: true, forced: false, -1, style);
24103 }
24104 break;
24105 case 5:
24106 if (genRand.Next(2) == 0)
24107 {
24108 Place4x2(num15, n, 79, 1, style6);
24109 }
24110 else
24111 {
24112 Place4x2(num15, n, 79, -1, style6);
24113 }
24114 break;
24115 case 6:
24116 PlaceTile(num15, n, 87, mute: true, forced: false, -1, style7);
24117 break;
24118 case 7:
24119 PlaceTile(num15, n, 88, mute: true, forced: false, -1, style8);
24120 break;
24121 case 8:
24122 PlaceTile(num15, n, 89, mute: true, forced: false, -1, style9);
24123 break;
24124 case 9:
24125 PlaceTile(num15, n, 104, mute: true, forced: false, -1, style10);
24126 break;
24127 case 10:
24128 if (genRand.Next(2) == 0)
24129 {
24130 Place4x2(num15, n, 90, 1, style14);
24131 }
24132 else
24133 {
24134 Place4x2(num15, n, 90, -1, style14);
24135 }
24136 break;
24137 case 11:
24138 PlaceTile(num15, n, 93, mute: true, forced: false, -1, style13);
24139 break;
24140 case 12:
24141 PlaceTile(num15, n, 100, mute: true, forced: false, -1, style11);
24142 break;
24143 }
24144 }
24145 num9 = 420000.0 / (double)Main.maxTilesX;
24146 for (int num23 = 0; (double)num23 < num9; num23++)
24147 {
24148 int num24 = 0;
24149 int num25 = genRand.Next(num, Main.maxTilesX - num);
24150 int num26 = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
24151 while ((Main.tile[num25, num26].wall != 13 && Main.tile[num25, num26].wall != 14) || Main.tile[num25, num26].active())
24152 {
24153 num25 = genRand.Next(num, Main.maxTilesX - num);
24154 num26 = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
24155 if (drunkWorldGen || remixWorldGen)
24156 {
24157 num25 = ((genRand.Next(2) != 0) ? genRand.Next(Main.maxTilesX - num, Main.maxTilesX - 50) : genRand.Next(50, num));
24158 }
24159 num24++;
24160 if (num24 > 100000)
24161 {
24162 break;
24163 }
24164 }
24165 if (num24 > 100000)
24166 {
24167 continue;
24168 }
24169 int num27 = num25;
24170 int num28 = num25;
24171 int num29 = num26;
24172 int num30 = num26;
24173 int num31 = 0;
24174 for (int num32 = 0; num32 < 2; num32++)
24175 {
24176 num27 = num25;
24177 num28 = num25;
24178 while (!Main.tile[num27, num26].active() && (Main.tile[num27, num26].wall == 13 || Main.tile[num27, num26].wall == 14))
24179 {
24180 num27--;
24181 }
24182 num27++;
24183 for (; !Main.tile[num28, num26].active() && (Main.tile[num28, num26].wall == 13 || Main.tile[num28, num26].wall == 14); num28++)
24184 {
24185 }
24186 num28--;
24187 num25 = (num27 + num28) / 2;
24188 num29 = num26;
24189 num30 = num26;
24190 while (!Main.tile[num25, num29].active() && (Main.tile[num25, num29].wall == 13 || Main.tile[num25, num29].wall == 14))
24191 {
24192 num29--;
24193 }
24194 num29++;
24195 for (; !Main.tile[num25, num30].active() && (Main.tile[num25, num30].wall == 13 || Main.tile[num25, num30].wall == 14); num30++)
24196 {
24197 }
24198 num30--;
24199 num26 = (num29 + num30) / 2;
24200 }
24201 num27 = num25;
24202 num28 = num25;
24203 while (!Main.tile[num27, num26].active() && !Main.tile[num27, num26 - 1].active() && !Main.tile[num27, num26 + 1].active())
24204 {
24205 num27--;
24206 }
24207 num27++;
24208 for (; !Main.tile[num28, num26].active() && !Main.tile[num28, num26 - 1].active() && !Main.tile[num28, num26 + 1].active(); num28++)
24209 {
24210 }
24211 num28--;
24212 num29 = num26;
24213 num30 = num26;
24214 while (!Main.tile[num25, num29].active() && !Main.tile[num25 - 1, num29].active() && !Main.tile[num25 + 1, num29].active())
24215 {
24216 num29--;
24217 }
24218 num29++;
24219 for (; !Main.tile[num25, num30].active() && !Main.tile[num25 - 1, num30].active() && !Main.tile[num25 + 1, num30].active(); num30++)
24220 {
24221 }
24222 num30--;
24223 num25 = (num27 + num28) / 2;
24224 num26 = (num29 + num30) / 2;
24225 int num33 = num28 - num27;
24226 num31 = num30 - num29;
24227 if (num33 <= 7 || num31 <= 5)
24228 {
24229 continue;
24230 }
24231 int num34 = 0;
24232 if (nearPicture2(num25, num26))
24233 {
24234 num34 = -1;
24235 }
24236 if (num34 == 0)
24237 {
24238 PaintingEntry paintingEntry = RandHellPicture();
24239 if (!nearPicture(num25, num26))
24240 {
24241 PlaceTile(num25, num26, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style);
24242 }
24243 }
24244 }
24245 int[] array = new int[3]
24246 {
24247 genRand.Next(16, 22),
24248 genRand.Next(16, 22),
24249 genRand.Next(16, 22)
24250 };
24251 while (array[1] == array[0])
24252 {
24253 array[1] = genRand.Next(16, 22);
24254 }
24255 while (array[2] == array[0] || array[2] == array[1])
24256 {
24257 array[2] = genRand.Next(16, 22);
24258 }
24259 num9 = 420000.0 / (double)Main.maxTilesX;
24260 for (int num35 = 0; (double)num35 < num9; num35++)
24261 {
24262 int num36 = 0;
24263 int num37;
24264 int num38;
24265 do
24266 {
24267 num37 = genRand.Next(num, Main.maxTilesX - num);
24268 num38 = genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
24269 if (drunkWorldGen || remixWorldGen)
24270 {
24271 num37 = ((genRand.Next(2) != 0) ? genRand.Next(Main.maxTilesX - num, Main.maxTilesX - 50) : genRand.Next(50, num));
24272 }
24273 num36++;
24274 }
24275 while (num36 <= 100000 && ((Main.tile[num37, num38].wall != 13 && Main.tile[num37, num38].wall != 14) || Main.tile[num37, num38].active()));
24276 if (num36 > 100000)
24277 {
24278 continue;
24279 }
24280 while (!SolidTile(num37, num38) && num38 > 10)
24281 {
24282 num38--;
24283 }
24284 num38++;
24285 if (Main.tile[num37, num38].wall != 13 && Main.tile[num37, num38].wall != 14)
24286 {
24287 continue;
24288 }
24289 int num39 = genRand.Next(3);
24290 int style15 = 32;
24291 int style16 = 32;
24292 int num40;
24293 int num41;
24294 switch (num39)
24295 {
24296 default:
24297 num40 = 1;
24298 num41 = 3;
24299 break;
24300 case 1:
24301 num40 = 3;
24302 num41 = 3;
24303 break;
24304 case 2:
24305 num40 = 1;
24306 num41 = 2;
24307 break;
24308 }
24309 for (int num42 = num37 - 1; num42 <= num37 + num40; num42++)
24310 {
24311 for (int num43 = num38; num43 <= num38 + num41; num43++)
24312 {
24313 Tile tile = Main.tile[num37, num38];
24314 if (num42 < num37 || num42 == num37 + num40)
24315 {
24316 if (tile.active())
24317 {
24318 switch (tile.type)
24319 {
24320 case 10:
24321 case 11:
24322 case 34:
24323 case 42:
24324 case 91:
24325 num39 = -1;
24326 break;
24327 }
24328 }
24329 }
24330 else if (tile.active())
24331 {
24332 num39 = -1;
24333 }
24334 }
24335 }
24336 switch (num39)
24337 {
24338 case 0:
24339 PlaceTile(num37, num38, 91, mute: true, forced: false, -1, array[genRand.Next(3)]);
24340 break;
24341 case 1:
24342 PlaceTile(num37, num38, 34, mute: true, forced: false, -1, style15);
24343 break;
24344 case 2:
24345 PlaceTile(num37, num38, 42, mute: true, forced: false, -1, style16);
24346 break;
24347 }
24348 }
24349 }
24350
24351 public static void HellFort(int i, int j, ushort tileType = 75, byte wallType = 14)
24352 {
24353 int[] array = new int[5];
24354 int[] array2 = new int[5];
24355 int[] array3 = new int[10];
24356 int[] array4 = new int[10];
24357 int num = 8;
24358 int num2 = 20;
24359 if (drunkWorldGen)
24360 {
24361 num /= 2;
24362 num2 *= 2;
24363 }
24364 array[2] = i - genRand.Next(num / 2, num2 / 2);
24365 array2[2] = i + genRand.Next(num / 2, num2 / 2);
24366 array[3] = array2[2];
24367 array2[3] = array[3] + genRand.Next(num, num2);
24368 array[4] = array2[3];
24369 array2[4] = array[4] + genRand.Next(num, num2);
24370 array2[1] = array[2];
24371 array[1] = array2[1] - genRand.Next(num, num2);
24372 array2[0] = array[1];
24373 array[0] = array2[0] - genRand.Next(num, num2);
24374 num = 6;
24375 num2 = 12;
24376 array3[3] = j - genRand.Next(num, num2);
24377 array4[3] = j;
24378 for (int k = 4; k < 10; k++)
24379 {
24380 array3[k] = array4[k - 1];
24381 array4[k] = array3[k] + genRand.Next(num, num2);
24382 }
24383 for (int num3 = 2; num3 >= 0; num3--)
24384 {
24385 array4[num3] = array3[num3 + 1];
24386 array3[num3] = array4[num3] - genRand.Next(num, num2);
24387 }
24388 bool flag = false;
24389 bool flag2 = false;
24390 bool[,] array5 = new bool[5, 10];
24391 int num4 = 3;
24392 int num5 = 3;
24393 for (int l = 0; l < 2; l++)
24394 {
24395 if (genRand.Next(3) == 0 || drunkWorldGen)
24396 {
24397 flag = true;
24398 int num6 = genRand.Next(10);
24399 if (num6 < num4)
24400 {
24401 num4 = num6;
24402 }
24403 if (num6 > num5)
24404 {
24405 num5 = num6;
24406 }
24407 int num7 = 1;
24408 if (genRand.Next(2) == 0 || drunkWorldGen)
24409 {
24410 array5[0, num6] = true;
24411 array5[1, num6] = true;
24412 num7 = 0;
24413 }
24414 else
24415 {
24416 array5[1, num6] = true;
24417 }
24418 int num8 = genRand.Next(2);
24419 if (num8 == 0)
24420 {
24421 num8 = -1;
24422 }
24423 int num9 = genRand.Next(10);
24424 while (num9 > 0 && num6 >= 0 && num6 < 10)
24425 {
24426 array5[num7, num6] = true;
24427 num6 += num8;
24428 }
24429 }
24430 if (genRand.Next(3) == 0 || drunkWorldGen)
24431 {
24432 flag2 = true;
24433 int num10 = genRand.Next(10);
24434 if (num10 < num4)
24435 {
24436 num4 = num10;
24437 }
24438 if (num10 > num5)
24439 {
24440 num5 = num10;
24441 }
24442 int num11 = 3;
24443 if (genRand.Next(2) == 0 || drunkWorldGen)
24444 {
24445 array5[3, num10] = true;
24446 array5[4, num10] = true;
24447 num11 = 4;
24448 }
24449 else
24450 {
24451 array5[3, num10] = true;
24452 }
24453 int num12 = genRand.Next(2);
24454 if (num12 == 0)
24455 {
24456 num12 = -1;
24457 }
24458 int num13 = genRand.Next(10);
24459 while (num13 > 0 && num10 >= 0 && num10 < 10)
24460 {
24461 array5[num11, num10] = true;
24462 num10 += num12;
24463 }
24464 }
24465 }
24466 for (int m = 0; m < 5; m++)
24467 {
24468 int num14 = array[m];
24469 bool flag3 = false;
24471 {
24472 flag3 = true;
24473 }
24474 else
24475 {
24476 for (int n = Main.UnderworldLayer; n < Main.maxTilesY; n++)
24477 {
24478 if (Main.tile[num14, n].wall > 0)
24479 {
24480 flag3 = true;
24481 }
24482 }
24483 }
24484 if (flag3)
24485 {
24486 for (int num15 = 0; num15 < 10; num15++)
24487 {
24488 array5[m, num15] = false;
24489 }
24490 }
24491 }
24492 int num16 = genRand.Next(10);
24493 if (num16 < num4)
24494 {
24495 num4 = num16;
24496 }
24497 num16 = genRand.Next(10);
24498 if (num16 > num5)
24499 {
24500 num5 = num16;
24501 }
24502 if (!flag && !flag2)
24503 {
24504 while (num5 - num4 < 5)
24505 {
24506 num16 = genRand.Next(10);
24507 if (num16 < num4)
24508 {
24509 num4 = num16;
24510 }
24511 num16 = genRand.Next(10);
24512 if (num16 > num5)
24513 {
24514 num5 = num16;
24515 }
24516 }
24517 }
24518 for (int num17 = num4; num17 <= num5; num17++)
24519 {
24520 array5[2, num17] = true;
24521 }
24522 for (int num18 = 0; num18 < 5; num18++)
24523 {
24524 for (int num19 = 0; num19 < 10; num19++)
24525 {
24527 {
24528 array5[num18, num19] = false;
24529 }
24530 }
24531 }
24532 for (int num20 = 0; num20 < 5; num20++)
24533 {
24534 for (int num21 = 0; num21 < 10; num21++)
24535 {
24536 if (!array5[num20, num21])
24537 {
24538 continue;
24539 }
24540 for (int num22 = array[num20]; num22 <= array2[num20]; num22++)
24541 {
24542 for (int num23 = array3[num21]; num23 <= array4[num21]; num23++)
24543 {
24544 if (num22 < 10)
24545 {
24546 break;
24547 }
24548 if (num22 > Main.maxTilesX - 10)
24549 {
24550 break;
24551 }
24552 Main.tile[num22, num23].liquid = 0;
24553 if (num22 == array[num20] || num22 == array2[num20] || num23 == array3[num21] || num23 == array4[num21])
24554 {
24555 Main.tile[num22, num23].active(active: true);
24556 Main.tile[num22, num23].type = tileType;
24557 Main.tile[num22, num23].halfBrick(halfBrick: false);
24558 Main.tile[num22, num23].slope(0);
24559 }
24560 else
24561 {
24562 Main.tile[num22, num23].wall = wallType;
24563 Main.tile[num22, num23].active(active: false);
24564 }
24565 }
24566 }
24567 }
24568 }
24569 int style = 19;
24570 int style2 = 13;
24571 for (int num24 = 0; num24 < 4; num24++)
24572 {
24573 bool[] array6 = new bool[10];
24574 bool flag4 = false;
24575 for (int num25 = 0; num25 < 10; num25++)
24576 {
24577 if (array5[num24, num25] && array5[num24 + 1, num25])
24578 {
24579 array6[num25] = true;
24580 flag4 = true;
24581 }
24582 }
24583 while (flag4)
24584 {
24585 int num26 = genRand.Next(10);
24586 if (array6[num26])
24587 {
24588 flag4 = false;
24589 Main.tile[array2[num24], array4[num26] - 1].active(active: false);
24590 Main.tile[array2[num24], array4[num26] - 2].active(active: false);
24591 Main.tile[array2[num24], array4[num26] - 3].active(active: false);
24592 Main.tile[array2[num24], array4[num26] - 1].wall = wallType;
24593 Main.tile[array2[num24], array4[num26] - 2].wall = wallType;
24594 Main.tile[array2[num24], array4[num26] - 3].wall = wallType;
24595 PlaceTile(array2[num24], array4[num26] - 1, 10, mute: true, forced: false, -1, style);
24596 }
24597 }
24598 }
24599 for (int num27 = 0; num27 < 5; num27++)
24600 {
24601 for (int num28 = 0; num28 < 10; num28++)
24602 {
24603 if (!array5[num27, num28])
24604 {
24605 continue;
24606 }
24607 if (num28 > 0 && array5[num27, num28 - 1])
24608 {
24609 int num29 = genRand.Next(array[num27] + 2, array2[num27] - 1);
24610 int num30 = genRand.Next(array[num27] + 2, array2[num27] - 1);
24611 int num31 = 0;
24613 {
24614 num29 = genRand.Next(array[num27] + 2, array2[num27] - 1);
24615 num30 = genRand.Next(array[num27] + 2, array2[num27] - 1);
24616 num31++;
24617 if (num31 > 10000)
24618 {
24619 break;
24620 }
24621 }
24622 if (num31 > 10000)
24623 {
24624 break;
24625 }
24626 for (int num32 = num29; num32 <= num30 && num32 >= 20 && num32 <= Main.maxTilesX - 20; num32++)
24627 {
24628 Main.tile[num32, array3[num28]].active(active: false);
24629 PlaceTile(num32, array3[num28], 19, mute: true, forced: true, -1, style2);
24630 Main.tile[num32, array3[num28]].wall = wallType;
24631 }
24632 }
24633 if (num27 < 4 && array5[num27 + 1, num28] && genRand.Next(3) == 0)
24634 {
24635 Main.tile[array2[num27], array4[num28] - 1].active(active: false);
24636 Main.tile[array2[num27], array4[num28] - 2].active(active: false);
24637 Main.tile[array2[num27], array4[num28] - 3].active(active: false);
24638 Main.tile[array2[num27], array4[num28] - 1].wall = wallType;
24639 Main.tile[array2[num27], array4[num28] - 2].wall = wallType;
24640 Main.tile[array2[num27], array4[num28] - 3].wall = wallType;
24641 PlaceTile(array2[num27], array4[num28] - 1, 10, mute: true, forced: false, -1, style);
24642 }
24643 }
24644 }
24645 bool flag5 = false;
24646 for (int num33 = 0; num33 < 5; num33++)
24647 {
24648 bool[] array7 = new bool[10];
24649 for (int num34 = 0; num34 < 10; num34++)
24650 {
24651 if (array5[num33, num34])
24652 {
24653 flag5 = true;
24654 array7[num34] = true;
24655 }
24656 }
24657 if (!flag5)
24658 {
24659 continue;
24660 }
24661 bool flag6 = false;
24662 for (int num35 = 0; num35 < 10; num35++)
24663 {
24664 if (array7[num35])
24665 {
24666 if (!Main.tile[array[num33] - 1, array4[num35] - 1].active() && !Main.tile[array[num33] - 1, array4[num35] - 2].active() && !Main.tile[array[num33] - 1, array4[num35] - 3].active() && Main.tile[array[num33] - 1, array4[num35] - 1].liquid == 0 && Main.tile[array[num33] - 1, array4[num35] - 2].liquid == 0 && Main.tile[array[num33] - 1, array4[num35] - 3].liquid == 0)
24667 {
24668 flag6 = true;
24669 }
24670 else
24671 {
24672 array7[num35] = false;
24673 }
24674 }
24675 }
24676 while (flag6)
24677 {
24678 int num36 = genRand.Next(10);
24679 if (array7[num36])
24680 {
24681 flag6 = false;
24682 Main.tile[array[num33], array4[num36] - 1].active(active: false);
24683 Main.tile[array[num33], array4[num36] - 2].active(active: false);
24684 Main.tile[array[num33], array4[num36] - 3].active(active: false);
24685 PlaceTile(array[num33], array4[num36] - 1, 10, mute: true, forced: false, -1, style);
24686 }
24687 }
24688 break;
24689 }
24690 bool flag7 = false;
24691 for (int num37 = 4; num37 >= 0; num37--)
24692 {
24693 bool[] array8 = new bool[10];
24694 for (int num38 = 0; num38 < 10; num38++)
24695 {
24696 if (array5[num37, num38])
24697 {
24698 flag7 = true;
24699 array8[num38] = true;
24700 }
24701 }
24702 if (flag7)
24703 {
24704 bool flag8 = false;
24705 for (int num39 = 0; num39 < 10; num39++)
24706 {
24707 if (array8[num39])
24708 {
24710 {
24711 break;
24712 }
24713 if (!Main.tile[array2[num37] + 1, array4[num39] - 1].active() && !Main.tile[array2[num37] + 1, array4[num39] - 2].active() && !Main.tile[array2[num37] + 1, array4[num39] - 3].active() && Main.tile[array2[num37] + 1, array4[num39] - 1].liquid == 0 && Main.tile[array2[num37] + 1, array4[num39] - 2].liquid == 0 && Main.tile[array2[num37] + 1, array4[num39] - 3].liquid == 0)
24714 {
24715 flag8 = true;
24716 }
24717 else
24718 {
24719 array8[num39] = false;
24720 }
24721 }
24722 }
24723 while (flag8)
24724 {
24725 int num40 = genRand.Next(10);
24726 if (array8[num40])
24727 {
24728 flag8 = false;
24729 Main.tile[array2[num37], array4[num40] - 1].active(active: false);
24730 Main.tile[array2[num37], array4[num40] - 2].active(active: false);
24731 Main.tile[array2[num37], array4[num40] - 3].active(active: false);
24732 PlaceTile(array2[num37], array4[num40] - 1, 10, mute: true, forced: false, -1, style);
24733 }
24734 }
24735 break;
24736 }
24737 }
24738 bool flag9 = false;
24739 for (int num41 = 0; num41 < 10; num41++)
24740 {
24741 bool[] array9 = new bool[10];
24742 for (int num42 = 0; num42 < 5; num42++)
24743 {
24744 if (array5[num42, num41])
24745 {
24746 flag9 = true;
24747 array9[num42] = true;
24748 }
24749 }
24750 if (!flag9)
24751 {
24752 continue;
24753 }
24754 bool flag10 = true;
24755 while (flag10)
24756 {
24757 int num43 = genRand.Next(5);
24758 if (!array9[num43])
24759 {
24760 continue;
24761 }
24762 int num44 = genRand.Next(array[num43] + 2, array2[num43] - 1);
24763 int num45 = genRand.Next(array[num43] + 2, array2[num43] - 1);
24764 int num46 = 0;
24766 {
24767 num44 = genRand.Next(array[num43] + 2, array2[num43] - 1);
24768 num45 = genRand.Next(array[num43] + 2, array2[num43] - 1);
24769 num46++;
24770 if (num46 > 10000)
24771 {
24772 break;
24773 }
24774 }
24775 if (num46 > 10000)
24776 {
24777 break;
24778 }
24779 for (int num47 = num44; num47 <= num45 && num47 >= 10 && num47 <= Main.maxTilesX - 10; num47++)
24780 {
24781 if (Main.tile[num47, array3[num41] - 1].active() || Main.tile[num47, array3[num41] - 1].liquid > 0)
24782 {
24783 flag10 = false;
24784 }
24785 }
24786 if (flag10)
24787 {
24788 for (int num48 = num44; num48 <= num45 && num48 >= 10 && num48 <= Main.maxTilesX - 10; num48++)
24789 {
24790 Main.tile[num48, array3[num41]].active(active: false);
24791 PlaceTile(num48, array3[num41], 19, mute: true, forced: true, -1, style2);
24792 }
24793 }
24794 flag10 = false;
24795 }
24796 break;
24797 }
24798 }
24799
24800 public static void HellHouse(int i, int j, byte type = 76, byte wall = 13)
24801 {
24802 int num = genRand.Next(8, 20);
24803 int num2 = genRand.Next(1, 3);
24804 int num3 = genRand.Next(4, 13);
24805 int num4 = j;
24806 for (int k = 0; k < num2; k++)
24807 {
24808 int num5 = genRand.Next(5, 9);
24809 HellRoom(i, num4, num, num5, type, wall);
24810 num4 -= num5;
24811 }
24812 num4 = j;
24813 for (int l = 0; l < num3; l++)
24814 {
24815 int num6 = genRand.Next(5, 9);
24816 num4 += num6;
24817 HellRoom(i, num4, num, num6, type, wall);
24818 }
24819 for (int m = i - num / 2; m <= i + num / 2; m++)
24820 {
24821 for (num4 = j; num4 < Main.maxTilesY && ((Main.tile[m, num4].active() && (Main.tile[m, num4].type == 76 || Main.tile[m, num4].type == 75)) || Main.tile[i, num4].wall == 13 || Main.tile[i, num4].wall == 14); num4++)
24822 {
24823 }
24824 int num7 = 6 + genRand.Next(3);
24825 while (num4 < Main.maxTilesY && !Main.tile[m, num4].active())
24826 {
24827 num7--;
24828 Main.tile[m, num4].active(active: true);
24829 Main.tile[m, num4].type = 57;
24830 num4++;
24831 if (num7 <= 0)
24832 {
24833 break;
24834 }
24835 }
24836 }
24837 int num8 = 0;
24838 int num9 = 0;
24839 for (num4 = j; num4 < Main.maxTilesY && ((Main.tile[i, num4].active() && (Main.tile[i, num4].type == 76 || Main.tile[i, num4].type == 75)) || Main.tile[i, num4].wall == 13 || Main.tile[i, num4].wall == 14); num4++)
24840 {
24841 }
24842 num4--;
24843 num9 = num4;
24844 while ((Main.tile[i, num4].active() && (Main.tile[i, num4].type == 76 || Main.tile[i, num4].type == 75)) || Main.tile[i, num4].wall == 13 || Main.tile[i, num4].wall == 14)
24845 {
24846 num4--;
24847 if (!Main.tile[i, num4].active() || (Main.tile[i, num4].type != 76 && Main.tile[i, num4].type != 75))
24848 {
24849 continue;
24850 }
24851 int num10 = genRand.Next(i - num / 2 + 1, i + num / 2 - 1);
24852 int num11 = genRand.Next(i - num / 2 + 1, i + num / 2 - 1);
24853 if (num10 > num11)
24854 {
24855 int num12 = num10;
24856 num10 = num11;
24857 num11 = num12;
24858 }
24859 if (num10 == num11)
24860 {
24861 if (num10 < i)
24862 {
24863 num11++;
24864 }
24865 else
24866 {
24867 num10--;
24868 }
24869 }
24870 for (int n = num10; n <= num11; n++)
24871 {
24872 if (Main.tile[n, num4 - 1].wall == 13)
24873 {
24874 Main.tile[n, num4].wall = 13;
24875 }
24876 if (Main.tile[n, num4 - 1].wall == 14)
24877 {
24878 Main.tile[n, num4].wall = 14;
24879 }
24880 Main.tile[n, num4].type = 19;
24881 Main.tile[n, num4].active(active: true);
24882 }
24883 num4--;
24884 }
24885 num8 = num4;
24886 double num13 = (double)((num9 - num8) * num) * 0.02;
24887 for (int num14 = 0; (double)num14 < num13; num14++)
24888 {
24889 int num15 = genRand.Next(i - num / 2, i + num / 2 + 1);
24890 int num16 = genRand.Next(num8, num9);
24891 int num17 = genRand.Next(3, 8);
24892 for (int num18 = num15 - num17; num18 <= num15 + num17; num18++)
24893 {
24894 for (int num19 = num16 - num17; num19 <= num16 + num17; num19++)
24895 {
24896 double num20 = Math.Abs(num18 - num15);
24897 double num21 = Math.Abs(num19 - num16);
24898 if (!(Math.Sqrt(num20 * num20 + num21 * num21) < (double)num17 * 0.4))
24899 {
24900 continue;
24901 }
24902 try
24903 {
24904 if (Main.tile[num18, num19].type == 76 || Main.tile[num18, num19].type == 19)
24905 {
24906 Main.tile[num18, num19].active(active: false);
24907 }
24908 Main.tile[num18, num19].wall = 0;
24909 }
24910 catch
24911 {
24912 }
24913 }
24914 }
24915 }
24916 }
24917
24918 public static void HellRoom(int i, int j, int width, int height, byte type = 76, byte wall = 13)
24919 {
24920 if (j > Main.maxTilesY - 40)
24921 {
24922 return;
24923 }
24924 for (int k = i - width / 2; k <= i + width / 2; k++)
24925 {
24926 for (int l = j - height; l <= j; l++)
24927 {
24928 try
24929 {
24930 Main.tile[k, l].active(active: true);
24931 Main.tile[k, l].type = type;
24932 Main.tile[k, l].liquid = 0;
24933 Main.tile[k, l].lava(lava: false);
24934 }
24935 catch
24936 {
24937 }
24938 }
24939 }
24940 for (int m = i - width / 2 + 1; m <= i + width / 2 - 1; m++)
24941 {
24942 for (int n = j - height + 1; n <= j - 1; n++)
24943 {
24944 try
24945 {
24946 Main.tile[m, n].active(active: false);
24947 Main.tile[m, n].wall = wall;
24948 Main.tile[m, n].liquid = 0;
24949 Main.tile[m, n].lava(lava: false);
24950 }
24951 catch
24952 {
24953 }
24954 }
24955 }
24956 }
24957
24958 public static void templeCleaner(int x, int y)
24959 {
24960 int num = 0;
24961 if (Main.tile[x + 1, y].active() && Main.tile[x + 1, y].type == 226)
24962 {
24963 num++;
24964 }
24965 if (Main.tile[x - 1, y].active() && Main.tile[x - 1, y].type == 226)
24966 {
24967 num++;
24968 }
24969 if (Main.tile[x, y + 1].active() && Main.tile[x, y + 1].type == 226)
24970 {
24971 num++;
24972 }
24973 if (Main.tile[x, y - 1].active() && Main.tile[x, y - 1].type == 226)
24974 {
24975 num++;
24976 }
24977 if (Main.tile[x, y].active() && Main.tile[x, y].type == 226)
24978 {
24979 if (num <= 1)
24980 {
24981 Main.tile[x, y].active(active: false);
24982 Main.tile[x, y].wall = 87;
24983 }
24984 }
24985 else if (!Main.tile[x, y].active() && num == 3)
24986 {
24987 Main.tile[x, y].active(active: true);
24988 Main.tile[x, y].type = 226;
24989 Main.tile[x, y].liquid = 0;
24990 Main.tile[x, y].slope(0);
24991 Main.tile[x, y].halfBrick(halfBrick: false);
24992 }
24993 }
24994
24996 {
24997 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
24998 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
24999 //IL_00b5: Unknown result type (might be due to invalid IL or missing references)
25000 int num = (int)templePath.X;
25001 int num2 = (int)templePath.Y;
25002 int num3 = genRand.Next(5, 20);
25003 int num4 = genRand.Next(2, 5);
25004 while (num3 > 0 && (num != destX || num2 != destY))
25005 {
25006 num3--;
25007 if (num > destX)
25008 {
25009 num--;
25010 }
25011 if (num < destX)
25012 {
25013 num++;
25014 }
25015 if (num2 > destY)
25016 {
25017 num2--;
25018 }
25019 if (num2 < destY)
25020 {
25021 num2++;
25022 }
25023 for (int i = num - num4; i < num + num4; i++)
25024 {
25025 for (int j = num2 - num4; j < num2 + num4; j++)
25026 {
25027 Main.tile[i, j].active(active: false);
25028 Main.tile[i, j].wall = 87;
25029 }
25030 }
25031 }
25032 return new Vector2D((double)num, (double)num2);
25033 }
25034
25035 public static void outerTempled(int x, int y)
25036 {
25037 if ((Main.tile[x, y].active() & (Main.tile[x, y].type == 226)) || Main.tile[x, y].wall == 87)
25038 {
25039 return;
25040 }
25041 int num = 6;
25042 for (int i = x - num; i <= x + num; i++)
25043 {
25044 for (int j = y - num; j <= y + num; j++)
25045 {
25046 if (!Main.tile[i, j].active() && Main.tile[i, j].wall == 87)
25047 {
25048 i = x;
25049 j = y;
25050 Main.tile[i, j].active(active: true);
25051 Main.tile[i, j].type = 226;
25052 Main.tile[i, j].liquid = 0;
25053 Main.tile[i, j].slope(0);
25054 Main.tile[i, j].halfBrick(halfBrick: false);
25055 return;
25056 }
25057 }
25058 }
25059 }
25060
25061 public static void makeTemple(int x, int y)
25062 {
25063 //IL_0940: Unknown result type (might be due to invalid IL or missing references)
25064 //IL_0946: Unknown result type (might be due to invalid IL or missing references)
25065 //IL_094b: Unknown result type (might be due to invalid IL or missing references)
25066 //IL_094d: Unknown result type (might be due to invalid IL or missing references)
25067 //IL_0959: Unknown result type (might be due to invalid IL or missing references)
25068 //IL_0c37: Unknown result type (might be due to invalid IL or missing references)
25069 //IL_0c3d: Unknown result type (might be due to invalid IL or missing references)
25070 //IL_0c42: Unknown result type (might be due to invalid IL or missing references)
25071 //IL_0c44: Unknown result type (might be due to invalid IL or missing references)
25072 //IL_0c50: Unknown result type (might be due to invalid IL or missing references)
25073 //IL_0b55: Unknown result type (might be due to invalid IL or missing references)
25074 //IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
25075 //IL_0b60: Unknown result type (might be due to invalid IL or missing references)
25076 //IL_0b62: Unknown result type (might be due to invalid IL or missing references)
25077 //IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
25078 //IL_0e9b: Unknown result type (might be due to invalid IL or missing references)
25079 //IL_0ea8: Unknown result type (might be due to invalid IL or missing references)
25080 //IL_0f6e: Unknown result type (might be due to invalid IL or missing references)
25081 Rectangle[] array = new Rectangle[100];
25082 double num = (double)Main.maxTilesX / 4200.0;
25083 int num2 = genRand.Next((int)(num * 10.0), (int)(num * 16.0));
25084 if (drunkWorldGen)
25085 {
25086 num2 *= 3;
25087 }
25088 else if (getGoodWorldGen)
25089 {
25090 num2 *= 3;
25091 }
25092 else if (remixWorldGen)
25093 {
25094 num2 *= 2;
25095 }
25096 int num3 = 1;
25097 if (genRand.Next(2) == 0)
25098 {
25099 num3 = -1;
25100 }
25101 int num4 = num3;
25102 int num5 = x;
25103 int num6 = y;
25104 int num7 = x;
25105 int num8 = y;
25106 int num9 = genRand.Next(1, 3);
25107 int num10 = 0;
25108 for (int i = 0; i < num2; i++)
25109 {
25110 num10++;
25111 int num11 = num3;
25112 int num12 = num7;
25113 int num13 = num8;
25114 bool flag = true;
25115 int num14 = 0;
25116 int num15 = 0;
25117 int num16 = -10;
25119 while (flag)
25120 {
25121 num12 = num7;
25122 num13 = num8;
25123 num14 = genRand.Next(25, 50);
25124 num15 = genRand.Next(20, 35);
25125 if (num15 > num14)
25126 {
25127 num15 = num14;
25128 }
25129 if (i == num2 - 1)
25130 {
25131 num14 = genRand.Next(55, 65);
25132 num15 = genRand.Next(45, 50);
25133 if (num15 > num14)
25134 {
25135 num15 = num14;
25136 }
25137 num14 = (int)((double)num14 * 1.6);
25138 num15 = (int)((double)num15 * 1.35);
25139 num13 += genRand.Next(5, 10);
25140 }
25141 if (num10 > num9)
25142 {
25143 num13 += genRand.Next(num15 + 1, num15 + 3) + num16;
25144 num12 += genRand.Next(-5, 6);
25145 num11 = num3 * -1;
25146 }
25147 else
25148 {
25149 num12 += (genRand.Next(num14 + 1, num14 + 3) + num16) * num11;
25150 num13 += genRand.Next(-5, 6);
25151 }
25152 flag = false;
25153 rectangle = new Rectangle(num12 - num14 / 2, num13 - num15 / 2, num14, num15);
25154 for (int j = 0; j < i; j++)
25155 {
25156 if (rectangle.Intersects(array[j]))
25157 {
25158 flag = true;
25159 }
25160 if (genRand.Next(100) == 0)
25161 {
25162 num16++;
25163 }
25164 }
25165 }
25166 if (num10 > num9)
25167 {
25168 num9++;
25169 num10 = 1;
25170 }
25171 array[i] = rectangle;
25172 num3 = num11;
25173 num7 = num12;
25174 num8 = num13;
25175 }
25176 for (int k = 0; k < num2; k++)
25177 {
25178 for (int l = 0; l < 2; l++)
25179 {
25180 for (int m = 0; m < num2; m++)
25181 {
25182 for (int n = 0; n < 2; n++)
25183 {
25184 int num17 = array[k].X;
25185 if (l == 1)
25186 {
25187 num17 += array[k].Width - 1;
25188 }
25189 int num18 = array[k].Y;
25190 int num19 = num18 + array[k].Height;
25191 int num20 = array[m].X;
25192 if (n == 1)
25193 {
25194 num20 += array[m].Width - 1;
25195 }
25196 int y2 = array[m].Y;
25197 int num21 = y2 + array[m].Height;
25198 while (num17 != num20 || num18 != y2 || num19 != num21)
25199 {
25200 if (num17 < num20)
25201 {
25202 num17++;
25203 }
25204 if (num17 > num20)
25205 {
25206 num17--;
25207 }
25208 if (num18 < y2)
25209 {
25210 num18++;
25211 }
25212 if (num18 > y2)
25213 {
25214 num18--;
25215 }
25216 if (num19 < num21)
25217 {
25218 num19++;
25219 }
25220 if (num19 > num21)
25221 {
25222 num19--;
25223 }
25224 int num22 = num17;
25225 for (int num23 = num18; num23 < num19; num23++)
25226 {
25227 Main.tile[num22, num23].active(active: true);
25228 Main.tile[num22, num23].type = 226;
25229 Main.tile[num22, num23].liquid = 0;
25230 Main.tile[num22, num23].slope(0);
25231 Main.tile[num22, num23].halfBrick(halfBrick: false);
25232 }
25233 }
25234 }
25235 }
25236 }
25237 }
25238 for (int num24 = 0; num24 < num2; num24++)
25239 {
25240 if (false)
25241 {
25242 continue;
25243 }
25244 for (int num25 = array[num24].X; num25 < array[num24].X + array[num24].Width; num25++)
25245 {
25246 for (int num26 = array[num24].Y; num26 < array[num24].Y + array[num24].Height; num26++)
25247 {
25248 Main.tile[num25, num26].active(active: true);
25249 Main.tile[num25, num26].type = 226;
25250 Main.tile[num25, num26].liquid = 0;
25251 Main.tile[num25, num26].slope(0);
25252 Main.tile[num25, num26].halfBrick(halfBrick: false);
25253 }
25254 }
25255 int x2 = array[num24].X;
25256 int num27 = x2 + array[num24].Width;
25257 int y3 = array[num24].Y;
25258 int num28 = y3 + array[num24].Height;
25259 x2 += genRand.Next(3, 8);
25260 num27 -= genRand.Next(3, 8);
25261 y3 += genRand.Next(3, 8);
25262 num28 -= genRand.Next(3, 8);
25263 int num29 = x2;
25264 int num30 = num27;
25265 int num31 = y3;
25266 int num32 = num28;
25267 int num33 = (x2 + num27) / 2;
25268 int num34 = (y3 + num28) / 2;
25269 for (int num35 = x2; num35 < num27; num35++)
25270 {
25271 for (int num36 = y3; num36 < num28; num36++)
25272 {
25273 if (genRand.Next(20) == 0)
25274 {
25275 num31 += genRand.Next(-1, 2);
25276 }
25277 if (genRand.Next(20) == 0)
25278 {
25279 num32 += genRand.Next(-1, 2);
25280 }
25281 if (genRand.Next(20) == 0)
25282 {
25283 num29 += genRand.Next(-1, 2);
25284 }
25285 if (genRand.Next(20) == 0)
25286 {
25287 num30 += genRand.Next(-1, 2);
25288 }
25289 if (num29 < x2)
25290 {
25291 num29 = x2;
25292 }
25293 if (num30 > num27)
25294 {
25295 num30 = num27;
25296 }
25297 if (num31 < y3)
25298 {
25299 num31 = y3;
25300 }
25301 if (num32 > num28)
25302 {
25303 num32 = num28;
25304 }
25305 if (num29 > num33)
25306 {
25307 num29 = num33;
25308 }
25309 if (num30 < num33)
25310 {
25311 num30 = num33;
25312 }
25313 if (num31 > num34)
25314 {
25315 num31 = num34;
25316 }
25317 if (num32 < num34)
25318 {
25319 num32 = num34;
25320 }
25322 {
25323 Main.tile[num35, num36].active(active: false);
25324 Main.tile[num35, num36].wall = 87;
25325 }
25326 }
25327 }
25328 for (int num37 = num28; num37 > y3; num37--)
25329 {
25330 for (int num38 = num27; num38 > x2; num38--)
25331 {
25332 if (genRand.Next(20) == 0)
25333 {
25334 num31 += genRand.Next(-1, 2);
25335 }
25336 if (genRand.Next(20) == 0)
25337 {
25338 num32 += genRand.Next(-1, 2);
25339 }
25340 if (genRand.Next(20) == 0)
25341 {
25342 num29 += genRand.Next(-1, 2);
25343 }
25344 if (genRand.Next(20) == 0)
25345 {
25346 num30 += genRand.Next(-1, 2);
25347 }
25348 if (num29 < x2)
25349 {
25350 num29 = x2;
25351 }
25352 if (num30 > num27)
25353 {
25354 num30 = num27;
25355 }
25356 if (num31 < y3)
25357 {
25358 num31 = y3;
25359 }
25360 if (num32 > num28)
25361 {
25362 num32 = num28;
25363 }
25364 if (num29 > num33)
25365 {
25366 num29 = num33;
25367 }
25368 if (num30 < num33)
25369 {
25370 num30 = num33;
25371 }
25372 if (num31 > num34)
25373 {
25374 num31 = num34;
25375 }
25376 if (num32 < num34)
25377 {
25378 num32 = num34;
25379 }
25381 {
25382 Main.tile[num38, num37].active(active: false);
25383 Main.tile[num38, num37].wall = 87;
25384 }
25385 }
25386 }
25387 }
25388 Vector2D val = default(Vector2D);
25389 ((Vector2D)(ref val))._002Ector((double)num5, (double)num6);
25390 for (int num39 = 0; num39 < num2; num39++)
25391 {
25393 rectangle2.X += 8;
25394 rectangle2.Y += 8;
25395 rectangle2.Width -= 16;
25396 rectangle2.Height -= 16;
25397 bool flag2 = true;
25398 while (flag2)
25399 {
25400 int num40 = genRand.Next(rectangle2.X, rectangle2.X + rectangle2.Width);
25401 int num41 = genRand.Next(rectangle2.Y, rectangle2.Y + rectangle2.Height);
25402 if (num39 == num2 - 1)
25403 {
25404 num40 = rectangle2.X + rectangle2.Width / 2 + genRand.Next(-10, 10);
25405 num41 = rectangle2.Y + rectangle2.Height / 2 + genRand.Next(-10, 10);
25406 }
25407 val = templePather(val, num40, num41);
25408 if (val.X == (double)num40 && val.Y == (double)num41)
25409 {
25410 flag2 = false;
25411 }
25412 }
25413 if (num39 >= num2 - 1)
25414 {
25415 continue;
25416 }
25417 if (genRand.Next(3) != 0)
25418 {
25419 int num42 = num39 + 1;
25420 if (array[num42].Y >= array[num39].Y + array[num39].Height)
25421 {
25422 rectangle2.X = array[num42].X;
25423 if (num39 == 0)
25424 {
25425 if (num3 > 0)
25426 {
25427 rectangle2.X += (int)((double)array[num42].Width * 0.8);
25428 }
25429 else
25430 {
25431 rectangle2.X += (int)((double)array[num42].Width * 0.2);
25432 }
25433 }
25434 else if (array[num42].X < array[num39].X)
25435 {
25436 rectangle2.X += (int)((double)array[num42].Width * 0.2);
25437 }
25438 else
25439 {
25440 rectangle2.X += (int)((double)array[num42].Width * 0.8);
25441 }
25442 rectangle2.Y = array[num42].Y;
25443 }
25444 else
25445 {
25446 rectangle2.X = (array[num39].X + array[num39].Width / 2 + array[num42].X + array[num42].Width / 2) / 2;
25447 rectangle2.Y = (int)((double)array[num42].Y + (double)array[num42].Height * 0.8);
25448 }
25449 int x3 = rectangle2.X;
25450 int y4 = rectangle2.Y;
25451 flag2 = true;
25452 while (flag2)
25453 {
25454 int num43 = genRand.Next(x3 - 6, x3 + 7);
25455 int num44 = genRand.Next(y4 - 6, y4 + 7);
25456 val = templePather(val, num43, num44);
25457 if (val.X == (double)num43 && val.Y == (double)num44)
25458 {
25459 flag2 = false;
25460 }
25461 }
25462 continue;
25463 }
25464 int num45 = num39 + 1;
25465 int num46 = (array[num39].X + array[num39].Width / 2 + array[num45].X + array[num45].Width / 2) / 2;
25466 int num47 = (array[num39].Y + array[num39].Height / 2 + array[num45].Y + array[num45].Height / 2) / 2;
25467 flag2 = true;
25468 while (flag2)
25469 {
25470 int num48 = genRand.Next(num46 - 6, num46 + 7);
25471 int num49 = genRand.Next(num47 - 6, num47 + 7);
25472 val = templePather(val, num48, num49);
25473 if (val.X == (double)num48 && val.Y == (double)num49)
25474 {
25475 flag2 = false;
25476 }
25477 }
25478 }
25479 int num50 = Main.maxTilesX - 20;
25480 int num51 = 20;
25481 int num52 = Main.maxTilesY - 20;
25482 int num53 = 20;
25483 for (int num54 = 0; num54 < num2; num54++)
25484 {
25485 if (array[num54].X < num50)
25486 {
25487 num50 = array[num54].X;
25488 }
25489 if (array[num54].X + array[num54].Width > num51)
25490 {
25491 num51 = array[num54].X + array[num54].Width;
25492 }
25493 if (array[num54].Y < num52)
25494 {
25495 num52 = array[num54].Y;
25496 }
25497 if (array[num54].Y + array[num54].Height > num53)
25498 {
25499 num53 = array[num54].Y + array[num54].Height;
25500 }
25501 }
25502 num50 -= 10;
25503 num51 += 10;
25504 num52 -= 10;
25505 num53 += 10;
25506 for (int num55 = num50; num55 < num51; num55++)
25507 {
25508 for (int num56 = num52; num56 < num53; num56++)
25509 {
25510 outerTempled(num55, num56);
25511 }
25512 }
25513 for (int num57 = num51; num57 >= num50; num57--)
25514 {
25515 for (int num58 = num52; num58 < num53 / 2; num58++)
25516 {
25517 outerTempled(num57, num58);
25518 }
25519 }
25520 for (int num59 = num52; num59 < num53; num59++)
25521 {
25522 for (int num60 = num50; num60 < num51; num60++)
25523 {
25524 outerTempled(num60, num59);
25525 }
25526 }
25527 for (int num61 = num53; num61 >= num52; num61--)
25528 {
25529 for (int num62 = num50; num62 < num51; num62++)
25530 {
25531 outerTempled(num62, num61);
25532 }
25533 }
25534 int num63 = num6;
25535 num3 = -num4;
25536 Vector2D val2 = default(Vector2D);
25537 ((Vector2D)(ref val2))._002Ector((double)num5, (double)num6);
25538 int num64 = genRand.Next(2, 5);
25539 bool flag3 = true;
25540 int num65 = 0;
25541 int num66 = genRand.Next(9, 14);
25542 while (flag3)
25543 {
25544 num65++;
25545 if (num65 >= num66)
25546 {
25547 num65 = 0;
25548 val2.Y -= 1.0;
25549 }
25550 val2.X += num3;
25551 int num67 = (int)val2.X;
25552 flag3 = false;
25553 for (int num68 = (int)val2.Y - num64; (double)num68 < val2.Y + (double)num64; num68++)
25554 {
25555 if (Main.tile[num67, num68].wall == 87 || (Main.tile[num67, num68].active() && Main.tile[num67, num68].type == 226))
25556 {
25557 flag3 = true;
25558 }
25559 if (Main.tile[num67, num68].active() && Main.tile[num67, num68].type == 226)
25560 {
25561 if (num68 > num63)
25562 {
25563 num63 = num68;
25564 }
25565 Main.tile[num67, num68].active(active: false);
25566 Main.tile[num67, num68].wall = 87;
25567 }
25568 }
25569 }
25570 num63 += 2;
25571 int num69 = num5;
25572 int num70 = num6;
25573 while (!Main.tile[num69, num70].active())
25574 {
25575 num70++;
25576 if (num70 >= num63)
25577 {
25578 num70 = num63;
25579 Main.tile[num69, num70].ClearEverything();
25580 Main.tile[num69, num70].active(active: true);
25581 Main.tile[num69, num70].type = 226;
25582 break;
25583 }
25584 }
25585 num70 -= 4;
25586 int num71 = num70;
25587 while ((Main.tile[num69, num71].active() && Main.tile[num69, num71].type == 226) || Main.tile[num69, num71].wall == 87)
25588 {
25589 num71--;
25590 }
25591 num71 += 2;
25592 for (int num72 = num69 - 1; num72 <= num69 + 1; num72++)
25593 {
25594 for (int num73 = num71; num73 <= num70; num73++)
25595 {
25596 Main.tile[num72, num73].active(active: true);
25597 Main.tile[num72, num73].type = 226;
25598 Main.tile[num72, num73].liquid = 0;
25599 Main.tile[num72, num73].slope(0);
25600 Main.tile[num72, num73].halfBrick(halfBrick: false);
25601 }
25602 }
25603 for (int num74 = num69 - 4; num74 <= num69 + 4; num74++)
25604 {
25605 for (int num75 = num70 - 1; num75 < num70 + 3; num75++)
25606 {
25607 Main.tile[num74, num75].active(active: false);
25608 Main.tile[num74, num75].wall = 87;
25609 }
25610 }
25611 for (int num76 = num69 - 1; num76 <= num69 + 1; num76++)
25612 {
25613 for (int num77 = num70 - 5; num77 <= num70 + 8; num77++)
25614 {
25615 Main.tile[num76, num77].active(active: true);
25616 Main.tile[num76, num77].type = 226;
25617 Main.tile[num76, num77].liquid = 0;
25618 Main.tile[num76, num77].slope(0);
25619 Main.tile[num76, num77].halfBrick(halfBrick: false);
25620 }
25621 }
25622 for (int num78 = num69 - 3; num78 <= num69 + 3; num78++)
25623 {
25624 for (int num79 = num70 - 2; num79 < num70 + 3; num79++)
25625 {
25627 {
25628 Main.tile[num78, num79].active(active: false);
25629 Main.tile[num78, num79].wall = 87;
25630 }
25631 }
25632 }
25633 PlaceTile(num69, num70, 10, mute: true, forced: false, -1, 11);
25634 for (int num80 = num50; num80 < num51; num80++)
25635 {
25636 for (int num81 = num52; num81 < num53; num81++)
25637 {
25638 templeCleaner(num80, num81);
25639 }
25640 }
25641 for (int num82 = num53; num82 >= num52; num82--)
25642 {
25643 for (int num83 = num51; num83 >= num50; num83--)
25644 {
25645 templeCleaner(num83, num82);
25646 }
25647 }
25648 for (int num84 = num50; num84 < num51; num84++)
25649 {
25650 for (int num85 = num52; num85 < num53; num85++)
25651 {
25652 bool flag4 = true;
25653 for (int num86 = num84 - 1; num86 <= num84 + 1; num86++)
25654 {
25655 for (int num87 = num85 - 1; num87 <= num85 + 1; num87++)
25656 {
25657 if ((!Main.tile[num86, num87].active() || Main.tile[num86, num87].type != 226) && Main.tile[num86, num87].wall != 87)
25658 {
25659 flag4 = false;
25660 break;
25661 }
25662 }
25663 }
25664 if (flag4)
25665 {
25666 Main.tile[num84, num85].wall = 87;
25667 }
25668 }
25669 }
25670 int num88 = 0;
25672 int num89 = rectangle3.Width / 2;
25673 int num90 = rectangle3.Height / 2;
25674 while (true)
25675 {
25676 num88++;
25677 int num91 = rectangle3.X + num89 + 15 - genRand.Next(30);
25678 int num92 = rectangle3.Y + num90 + 15 - genRand.Next(30);
25679 PlaceTile(num91, num92, 237);
25680 if (Main.tile[num91, num92].type == 237)
25681 {
25682 GenVars.lAltarX = num91 - Main.tile[num91, num92].frameX / 18;
25683 GenVars.lAltarY = num92 - Main.tile[num91, num92].frameY / 18;
25684 break;
25685 }
25686 if (num88 < 1000)
25687 {
25688 continue;
25689 }
25690 num91 = rectangle3.X + num89;
25691 num92 = rectangle3.Y + num90;
25692 num91 += genRand.Next(-10, 11);
25693 for (num92 += genRand.Next(-10, 11); !Main.tile[num91, num92].active(); num92++)
25694 {
25695 }
25696 Main.tile[num91 - 1, num92].active(active: true);
25697 Main.tile[num91 - 1, num92].slope(0);
25698 Main.tile[num91 - 1, num92].halfBrick(halfBrick: false);
25699 Main.tile[num91 - 1, num92].type = 226;
25700 Main.tile[num91, num92].active(active: true);
25701 Main.tile[num91, num92].slope(0);
25702 Main.tile[num91, num92].halfBrick(halfBrick: false);
25703 Main.tile[num91, num92].type = 226;
25704 Main.tile[num91 + 1, num92].active(active: true);
25705 Main.tile[num91 + 1, num92].slope(0);
25706 Main.tile[num91 + 1, num92].halfBrick(halfBrick: false);
25707 Main.tile[num91 + 1, num92].type = 226;
25708 num92 -= 2;
25709 num91--;
25710 for (int num93 = -1; num93 <= 3; num93++)
25711 {
25712 for (int num94 = -1; num94 <= 1; num94++)
25713 {
25714 x = num91 + num93;
25715 y = num92 + num94;
25716 Main.tile[x, y].active(active: false);
25717 }
25718 }
25719 GenVars.lAltarX = num91;
25720 GenVars.lAltarY = num92;
25721 for (int num95 = 0; num95 <= 2; num95++)
25722 {
25723 for (int num96 = 0; num96 <= 1; num96++)
25724 {
25725 x = num91 + num95;
25726 y = num92 + num96;
25727 Main.tile[x, y].active(active: true);
25728 Main.tile[x, y].type = 237;
25729 Main.tile[x, y].frameX = (short)(num95 * 18);
25730 Main.tile[x, y].frameY = (short)(num96 * 18);
25731 }
25732 }
25733 for (int num97 = 0; num97 <= 2; num97++)
25734 {
25735 for (int num98 = 0; num98 <= 1; num98++)
25736 {
25737 x = num91 + num97;
25738 y = num92 + num98;
25739 SquareTileFrame(x, y);
25740 }
25741 }
25742 break;
25743 }
25744 double num99 = (double)num2 * 1.1;
25745 num99 *= 1.0 + (double)genRand.Next(-25, 26) * 0.01;
25746 if (drunkWorldGen)
25747 {
25748 num99 *= 1.5;
25749 }
25750 int num100 = 0;
25751 while (num99 > 0.0)
25752 {
25753 num100++;
25754 int num101 = genRand.Next(num2);
25755 int num102 = genRand.Next(array[num101].X, array[num101].X + array[num101].Width);
25756 int num103 = genRand.Next(array[num101].Y, array[num101].Y + array[num101].Height);
25757 if (Main.tile[num102, num103].wall == 87 && !Main.tile[num102, num103].active())
25758 {
25759 bool flag5 = false;
25760 if (genRand.Next(2) == 0)
25761 {
25762 int num104 = 1;
25763 if (genRand.Next(2) == 0)
25764 {
25765 num104 = -1;
25766 }
25767 for (; !Main.tile[num102, num103].active(); num103 += num104)
25768 {
25769 }
25770 num103 -= num104;
25771 int num105 = genRand.Next(2);
25772 int num106 = genRand.Next(3, 10);
25773 bool flag6 = true;
25774 for (int num107 = num102 - num106; num107 < num102 + num106; num107++)
25775 {
25776 for (int num108 = num103 - num106; num108 < num103 + num106; num108++)
25777 {
25778 if (Main.tile[num107, num108].active() && (Main.tile[num107, num108].type == 10 || Main.tile[num107, num108].type == 237))
25779 {
25780 flag6 = false;
25781 break;
25782 }
25783 }
25784 }
25785 if (flag6)
25786 {
25787 for (int num109 = num102 - num106; num109 < num102 + num106; num109++)
25788 {
25789 for (int num110 = num103 - num106; num110 < num103 + num106; num110++)
25790 {
25791 if (!SolidTile(num109, num110) || Main.tile[num109, num110].type == 232 || SolidTile(num109, num110 - num104))
25792 {
25793 continue;
25794 }
25795 Main.tile[num109, num110].type = 232;
25796 flag5 = true;
25797 if (num105 == 0)
25798 {
25799 Main.tile[num109, num110 - 1].type = 232;
25800 Main.tile[num109, num110 - 1].active(active: true);
25801 if (drunkWorldGen)
25802 {
25803 Main.tile[num109, num110 - 2].type = 232;
25804 Main.tile[num109, num110 - 2].active(active: true);
25805 }
25806 }
25807 else
25808 {
25809 Main.tile[num109, num110 + 1].type = 232;
25810 Main.tile[num109, num110 + 1].active(active: true);
25811 if (drunkWorldGen)
25812 {
25813 Main.tile[num109, num110 + 2].type = 232;
25814 Main.tile[num109, num110 + 2].active(active: true);
25815 }
25816 }
25817 num105++;
25818 if (num105 > 1)
25819 {
25820 num105 = 0;
25821 }
25822 }
25823 }
25824 }
25825 if (flag5)
25826 {
25827 num100 = 0;
25828 num99 -= 1.0;
25829 }
25830 }
25831 else
25832 {
25833 int num111 = 1;
25834 if (genRand.Next(2) == 0)
25835 {
25836 num111 = -1;
25837 }
25838 for (; !Main.tile[num102, num103].active(); num102 += num111)
25839 {
25840 }
25841 num102 -= num111;
25842 int num112 = genRand.Next(2);
25843 int num113 = genRand.Next(3, 10);
25844 bool flag7 = true;
25845 for (int num114 = num102 - num113; num114 < num102 + num113; num114++)
25846 {
25847 for (int num115 = num103 - num113; num115 < num103 + num113; num115++)
25848 {
25849 if (Main.tile[num114, num115].active() && Main.tile[num114, num115].type == 10)
25850 {
25851 flag7 = false;
25852 break;
25853 }
25854 }
25855 }
25856 if (flag7)
25857 {
25858 for (int num116 = num102 - num113; num116 < num102 + num113; num116++)
25859 {
25860 for (int num117 = num103 - num113; num117 < num103 + num113; num117++)
25861 {
25862 if (!SolidTile(num116, num117) || Main.tile[num116, num117].type == 232 || SolidTile(num116 - num111, num117))
25863 {
25864 continue;
25865 }
25866 Main.tile[num116, num117].type = 232;
25867 flag5 = true;
25868 if (num112 == 0)
25869 {
25870 Main.tile[num116 - 1, num117].type = 232;
25871 Main.tile[num116 - 1, num117].active(active: true);
25872 if (drunkWorldGen)
25873 {
25874 Main.tile[num116 - 2, num117].type = 232;
25875 Main.tile[num116 - 2, num117].active(active: true);
25876 }
25877 }
25878 else
25879 {
25880 Main.tile[num116 + 1, num117].type = 232;
25881 Main.tile[num116 + 1, num117].active(active: true);
25882 if (drunkWorldGen)
25883 {
25884 Main.tile[num116 - 2, num117].type = 232;
25885 Main.tile[num116 - 2, num117].active(active: true);
25886 }
25887 }
25888 num112++;
25889 if (num112 > 1)
25890 {
25891 num112 = 0;
25892 }
25893 }
25894 }
25895 }
25896 if (flag5)
25897 {
25898 num100 = 0;
25899 num99 -= 1.0;
25900 }
25901 }
25902 }
25903 if (num100 > 1000)
25904 {
25905 num100 = 0;
25906 num99 -= 1.0;
25907 }
25908 }
25909 GenVars.tLeft = num50;
25910 GenVars.tRight = num51;
25911 GenVars.tTop = num52;
25912 GenVars.tBottom = num53;
25913 GenVars.tRooms = num2;
25914 }
25915
25916 public static void templePart2()
25917 {
25918 int tLeft = GenVars.tLeft;
25919 int tRight = GenVars.tRight;
25920 int tTop = GenVars.tTop;
25921 int tBottom = GenVars.tBottom;
25922 int tRooms = GenVars.tRooms;
25923 double num = (double)tRooms * 1.9;
25924 num *= 1.0 + (double)genRand.Next(-15, 16) * 0.01;
25925 int num2 = 0;
25926 while (num > 0.0)
25927 {
25928 int num3 = genRand.Next(tLeft, tRight);
25929 int num4 = genRand.Next(tTop, tBottom);
25930 if (Main.tile[num3, num4].wall == 87 && !Main.tile[num3, num4].active())
25931 {
25932 if (mayanTrap(num3, num4))
25933 {
25934 num -= 1.0;
25935 num2 = 0;
25936 }
25937 else
25938 {
25939 num2++;
25940 }
25941 }
25942 else
25943 {
25944 num2++;
25945 }
25946 if (num2 > 100)
25947 {
25948 num2 = 0;
25949 num -= 1.0;
25950 }
25951 }
25952 Main.tileSolid[232] = false;
25953 double num5 = (double)tRooms * 0.35;
25954 num5 *= 1.0 + (double)genRand.Next(-15, 16) * 0.01;
25955 int contain = 1293;
25956 num2 = 0;
25957 while (num5 > 0.0)
25958 {
25959 int num6 = genRand.Next(tLeft, tRight);
25960 int num7 = genRand.Next(tTop, tBottom);
25961 if (Main.tile[num6, num7].wall == 87 && !Main.tile[num6, num7].active() && AddBuriedChest(num6, num7, contain, notNearOtherChests: true, 16, trySlope: false, 0))
25962 {
25963 num5 -= 1.0;
25964 num2 = 0;
25965 }
25966 num2++;
25967 if (num2 > 10000)
25968 {
25969 break;
25970 }
25971 }
25972 double num8 = (double)tRooms * 1.25;
25973 num8 *= 1.0 + (double)genRand.Next(-25, 36) * 0.01;
25974 num2 = 0;
25975 while (num8 > 0.0)
25976 {
25977 num2++;
25978 int num9 = genRand.Next(tLeft, tRight);
25979 int num10 = genRand.Next(tTop, tBottom);
25980 if (Main.tile[num9, num10].wall != 87 || Main.tile[num9, num10].active())
25981 {
25982 continue;
25983 }
25984 int num11 = num9;
25985 int num12 = num10;
25986 while (!Main.tile[num11, num12].active())
25987 {
25988 num12++;
25989 if (num12 > tBottom)
25990 {
25991 break;
25992 }
25993 }
25994 num12--;
25995 if (num12 <= tBottom)
25996 {
25997 PlaceTile(num11, num12, 105, mute: true, forced: false, -1, genRand.Next(43, 46));
25998 if (Main.tile[num11, num12].type == 105)
25999 {
26000 num8 -= 1.0;
26001 }
26002 }
26003 }
26004 double num13 = (double)tRooms * 1.35;
26005 num13 *= 1.0 + (double)genRand.Next(-15, 26) * 0.01;
26006 num2 = 0;
26007 while (num13 > 0.0)
26008 {
26009 num2++;
26010 int num14 = genRand.Next(tLeft, tRight);
26011 int num15 = genRand.Next(tTop, tBottom);
26012 if (Main.tile[num14, num15].wall == 87 && !Main.tile[num14, num15].active())
26013 {
26014 int num16 = num14;
26015 int num17 = num15;
26016 while (!Main.tile[num16, num17].active())
26017 {
26018 num17++;
26019 if (num17 > tBottom)
26020 {
26021 break;
26022 }
26023 }
26024 num17--;
26025 if (num17 <= tBottom)
26026 {
26027 switch (genRand.Next(3))
26028 {
26029 case 0:
26030 PlaceTile(num16, num17, 18, mute: true, forced: false, -1, 10);
26031 if (Main.tile[num16, num17].type == 18)
26032 {
26033 num13 -= 1.0;
26034 }
26035 break;
26036 case 1:
26037 PlaceTile(num16, num17, 14, mute: true, forced: false, -1, 9);
26038 if (Main.tile[num16, num17].type == 14)
26039 {
26040 num13 -= 1.0;
26041 }
26042 break;
26043 case 2:
26044 PlaceTile(num16, num17, 15, mute: true, forced: false, -1, 12);
26045 if (Main.tile[num16, num17].type == 15)
26046 {
26047 num13 -= 1.0;
26048 }
26049 break;
26050 }
26051 }
26052 }
26053 if (num2 > 10000)
26054 {
26055 break;
26056 }
26057 }
26058 int num18 = 1;
26059 if (Main.maxTilesX > 4200)
26060 {
26061 num18++;
26062 }
26063 if (Main.maxTilesX > 6400)
26064 {
26065 num18 += genRand.Next(2);
26066 }
26067 num2 = 0;
26068 while (num18 > 0)
26069 {
26070 num2++;
26071 int num19 = genRand.Next(tLeft, tRight);
26072 int num20 = genRand.Next(tTop, tBottom);
26073 if (Main.tile[num19, num20].wall == 87 && !Main.tile[num19, num20].active())
26074 {
26075 bool flag = false;
26076 for (int i = -70; i <= 70; i++)
26077 {
26078 for (int j = -70; j <= 70; j++)
26079 {
26080 int num21 = i + num19;
26081 int num22 = j + num20;
26082 if (!InWorld(num21, num22, 5))
26083 {
26084 continue;
26085 }
26086 Tile tile = Main.tile[num21, num22];
26087 if (tile.active())
26088 {
26089 if (tile.type == 240)
26090 {
26091 flag = true;
26092 break;
26093 }
26094 if (i >= -4 && i <= 4 && j >= -4 && j <= 4 && tile.type == 226)
26095 {
26096 flag = true;
26097 break;
26098 }
26099 }
26100 }
26101 if (flag)
26102 {
26103 break;
26104 }
26105 }
26106 if (flag)
26107 {
26108 continue;
26109 }
26110 if (PlaceTile(num19, num20, 240, mute: true, forced: false, -1, 88))
26111 {
26112 num18--;
26113 }
26114 }
26115 if (num2 > 10000)
26116 {
26117 break;
26118 }
26119 }
26120 Main.tileSolid[232] = true;
26121 }
26122
26123 public static bool nearPicture(int x, int y)
26124 {
26125 for (int i = x - 4; i <= x + 3; i++)
26126 {
26127 for (int j = y - 3; j <= y + 2; j++)
26128 {
26129 if (Main.tile[i, j].active())
26130 {
26131 return true;
26132 }
26133 }
26134 }
26135 return false;
26136 }
26137
26138 public static bool nearPicture2(int x, int y)
26139 {
26140 if (Main.tile[x, y].wall != 7 && Main.tile[x, y].wall != 8 && Main.tile[x, y].wall != 9)
26141 {
26142 for (int i = x - 8; i <= x + 8; i++)
26143 {
26144 for (int j = y - 5; j <= y + 5; j++)
26145 {
26146 if (Main.tile[i, j].active() && (Main.tile[i, j].type == 240 || Main.tile[i, j].type == 241 || Main.tile[i, j].type == 242))
26147 {
26148 return true;
26149 }
26150 }
26151 }
26152 }
26153 else
26154 {
26155 for (int k = x - 15; k <= x + 15; k++)
26156 {
26157 for (int l = y - 10; l <= y + 10; l++)
26158 {
26159 if (Main.tile[k, l].active() && (Main.tile[k, l].type == 240 || Main.tile[k, l].type == 241 || Main.tile[k, l].type == 242))
26160 {
26161 return true;
26162 }
26163 }
26164 }
26165 }
26166 return false;
26167 }
26168
26169 private static void ShimmerCleanUp()
26170 {
26171 ShimmerRemoveWater();
26172 int num = 120;
26173 int num2 = 90;
26174 int num3 = (int)GenVars.shimmerPosition.X - num;
26175 int num4 = (int)GenVars.shimmerPosition.X + num;
26176 int num5 = (int)GenVars.shimmerPosition.Y - num;
26177 int num6 = (int)GenVars.shimmerPosition.Y + num;
26178 _ = num / 4;
26179 for (int i = num5; i <= num6; i++)
26180 {
26181 for (int j = num3; j <= num4; j++)
26182 {
26183 int num7 = (int)Math.Sqrt(Math.Pow(Math.Abs((double)j - GenVars.shimmerPosition.X), 2.0) + Math.Pow(Math.Abs((double)i - GenVars.shimmerPosition.Y), 2.0));
26184 if (num7 < num)
26185 {
26186 if (Main.tile[j, i].type == 22 || Main.tile[j, i].type == 204)
26187 {
26188 Main.tile[j, i].type = 1;
26189 }
26190 if (Main.tile[j, i].type == 51 || Main.tile[j, i].type == 56 || Main.tile[j, i].type == 229 || Main.tile[j, i].type == 230 || Main.tile[j, i].type == 659)
26191 {
26192 Main.tile[j, i].active(active: false);
26193 }
26194 if (TileID.Sets.Conversion.Moss[Main.tile[j, i].type])
26195 {
26196 Main.tile[j, i].type = 1;
26197 }
26198 if (Main.tile[j, i].type == 184)
26199 {
26200 Main.tile[j, i].active(active: false);
26201 }
26202 }
26203 num7 = ((!((double)i > GenVars.shimmerPosition.Y)) ? ((int)Math.Sqrt(Math.Pow(Math.Abs((double)j - GenVars.shimmerPosition.X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow(Math.Abs((double)i - GenVars.shimmerPosition.Y) * 1.4 * (1.0 + genRand.NextDouble() * 0.02), 2.0))) : ((int)Math.Sqrt(Math.Pow(Math.Abs((double)j - GenVars.shimmerPosition.X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow(Math.Abs((double)i - GenVars.shimmerPosition.Y) * 1.2 * (1.0 + genRand.NextDouble() * 0.02), 2.0))));
26204 if (num7 < num2)
26205 {
26206 Convert(j, i, 0, 3);
26207 }
26208 }
26209 }
26210 int num8 = (int)GenVars.shimmerPosition.X;
26211 int num9 = (int)GenVars.shimmerPosition.Y;
26212 byte b = 127;
26214 while (Main.tile[num8, num9].liquid <= b || !Main.tile[num8, num9].shimmer())
26215 {
26216 while (!Main.tile[num8, num9].active())
26217 {
26218 Main.tile[num8, num9].liquid = b;
26219 Main.tile[num8, num9].shimmer(shimmer: true);
26220 num8--;
26221 }
26222 for (num8 = (int)GenVars.shimmerPosition.X; !Main.tile[num8, num9].active(); num8++)
26223 {
26224 Main.tile[num8, num9].liquid = b;
26225 Main.tile[num8, num9].shimmer(shimmer: true);
26226 }
26227 num8 = (int)GenVars.shimmerPosition.X;
26228 num9++;
26229 b = byte.MaxValue;
26230 if (Main.tile[num8, num9].active())
26231 {
26232 break;
26233 }
26234 }
26235 if (tenthAnniversaryWorldGen)
26236 {
26237 int num10 = 170;
26238 for (int k = (int)GenVars.shimmerPosition.X - num10; (double)k <= GenVars.shimmerPosition.X + (double)num10; k++)
26239 {
26240 for (int l = (int)GenVars.shimmerPosition.Y + 40; l < Main.maxTilesY - 330 - 100; l++)
26241 {
26242 if (InWorld(k, l))
26243 {
26244 if (Main.tile[k, l].type == 375 || Main.tile[k, l].type == 374 || Main.tile[k, l].type == 373)
26245 {
26246 Main.tile[k, l].active(active: false);
26247 }
26248 if (Main.tile[k, l].liquid > 0 && !Main.tile[k, l].shimmer())
26249 {
26250 Shimmerator(k, l);
26251 }
26252 }
26253 }
26254 }
26255 }
26257 for (int m = 10; m < Main.maxTilesX - 10; m++)
26258 {
26259 for (int n = 10; n < Main.maxTilesY - 10; n++)
26260 {
26261 if (Main.tile[m, n].liquid > 0 && Main.tile[m, n].shimmer() && Main.tile[m, n].type == 5)
26262 {
26263 KillTile(m, n);
26264 }
26265 }
26266 }
26267 }
26268
26269 public static void ShimmerRemoveWater()
26270 {
26271 if (!generatingWorld)
26272 {
26273 return;
26274 }
26275 int num = 150;
26276 int num2 = (int)GenVars.shimmerPosition.X - num;
26277 int num3 = (int)GenVars.shimmerPosition.X + num;
26278 int num4 = (int)GenVars.shimmerPosition.Y - num;
26279 int num5 = (int)GenVars.shimmerPosition.Y + num / 2;
26280 for (int i = num4; i <= num5; i++)
26281 {
26282 for (int j = num2; j <= num3; j++)
26283 {
26284 if (InWorld(j, i) && (int)Math.Sqrt(Math.Pow(Math.Abs(j - (int)GenVars.shimmerPosition.X), 2.0) + Math.Pow(Math.Abs(i - (int)GenVars.shimmerPosition.Y), 2.0)) < num && !Main.tile[j, i].shimmer())
26285 {
26286 Main.tile[j, i].liquid = 0;
26287 }
26288 }
26289 }
26290 }
26291
26292 public static bool ShimmerMakeBiome(int X, int Y)
26293 {
26294 int num = genRand.Next(2);
26295 double num2 = 0.6;
26296 double num3 = 1.3;
26297 double num4 = 0.3;
26298 if (num == 0)
26299 {
26300 num2 = 0.55;
26301 num3 = 2.0;
26302 }
26303 num2 *= 1.05 - genRand.NextDouble() * 0.1;
26304 num3 *= 1.05 - genRand.NextDouble() * 0.1;
26305 num4 *= 1.0 - genRand.NextDouble() * 0.1;
26306 int num5 = genRand.Next(105, 125);
26307 int num6 = (int)((double)num5 * num4);
26308 int num7 = (int)((double)num5 * num2);
26309 int num8 = genRand.Next(9, 13);
26310 int num9 = X - num5;
26311 int num10 = X + num5;
26312 int num11 = Y - num5;
26313 int num12 = Y + num5;
26314 for (int i = num11; i <= num12; i++)
26315 {
26316 for (int j = num9; j <= num10; j++)
26317 {
26318 if (!InWorld(j, i, 50))
26319 {
26320 return false;
26321 }
26322 if (Main.tile[j, i].type == 203 || Main.tile[j, i].type == 25)
26323 {
26324 return false;
26325 }
26326 }
26327 }
26328 int num13 = Y;
26329 if (genRand.Next(4) == 0)
26330 {
26331 num13 = Y - genRand.Next(2);
26332 }
26333 int num14 = Y - num8;
26334 if (genRand.Next(4) == 0)
26335 {
26336 num14 = Y - num8 - genRand.Next(2);
26337 }
26338 for (int k = num11; k <= num12; k++)
26339 {
26340 for (int l = num9; l <= num10; l++)
26341 {
26342 Main.tile[l, k].liquid = 0;
26343 if (genRand.Next(4) == 0)
26344 {
26345 num13 = Y - genRand.Next(2);
26346 }
26347 if (genRand.Next(4) == 0)
26348 {
26349 num14 = Y - num8 + genRand.Next(2);
26350 }
26351 int num15 = ((k <= Y) ? ((int)Math.Sqrt(Math.Pow((double)Math.Abs(l - X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow((double)Math.Abs(k - Y) * 1.4 * (1.0 + genRand.NextDouble() * 0.02), 2.0))) : ((int)Math.Sqrt(Math.Pow((double)Math.Abs(l - X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow((double)Math.Abs(k - Y) * 1.2 * (1.0 + genRand.NextDouble() * 0.02), 2.0))));
26352 if (num15 < num5)
26353 {
26354 Main.tile[l, k].color(0);
26355 Main.tile[l, k].wallColor(0);
26356 Main.tile[l, k].slope(0);
26357 Main.tile[l, k].halfBrick(halfBrick: false);
26358 Main.tile[l, k].type = 1;
26359 if (l > num9 + 5 + genRand.Next(2) && l < num10 - 5 - genRand.Next(2))
26360 {
26361 Main.tile[l, k].active(active: true);
26362 }
26363 if ((double)num15 < (double)num5 * 0.9)
26364 {
26365 Main.tile[l, k].wall = 0;
26366 }
26367 }
26368 num15 = (int)Math.Sqrt(Math.Pow((double)Math.Abs(l - X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow((double)Math.Abs(k - Y) * num3 * (1.0 + genRand.NextDouble() * 0.02), 2.0));
26369 if (k > num14 && k < num13)
26370 {
26371 Main.tile[l, k].active(active: false);
26372 }
26373 if (k < num13 && num15 < (int)((double)num7 * (1.0 + genRand.NextDouble() * 0.02)))
26374 {
26375 Main.tile[l, k].active(active: false);
26376 }
26377 num15 = (int)Math.Sqrt(Math.Pow((double)Math.Abs(l - X) * (1.0 + genRand.NextDouble() * 0.02), 2.0) + Math.Pow((double)(Math.Abs(k - Y) * 2) * (1.0 + genRand.NextDouble() * 0.02), 2.0));
26378 if (k < Y - 1 || num15 >= (int)((double)num6 * (1.0 + genRand.NextDouble() * 0.025)))
26379 {
26380 continue;
26381 }
26382 if (k <= Y + 2 || num15 != num6 - 1 || genRand.Next(2) != 0)
26383 {
26384 Main.tile[l, k].active(active: false);
26385 }
26386 if (k >= Y)
26387 {
26388 if (k == Y)
26389 {
26390 Main.tile[l, k].liquid = 127;
26391 }
26392 else
26393 {
26394 Main.tile[l, k].liquid = byte.MaxValue;
26395 }
26396 Main.tile[l, k].shimmer(shimmer: true);
26397 }
26398 }
26399 }
26400 if (num == 0)
26401 {
26402 num9 = (int)((double)X - (double)num5 * num4) - genRand.Next(-15, 1) - 5;
26403 num10 = (int)((double)X + (double)num5 * num4) + genRand.Next(0, 16);
26404 int m = num9;
26405 int num16 = 0;
26406 for (; m < num10; m += genRand.Next(9, 14))
26407 {
26408 int num17 = Y - 3;
26409 while (!Main.tile[m, num17].active())
26410 {
26411 num17--;
26412 }
26413 num17 -= 4;
26414 int num18 = genRand.Next(5, 10);
26415 int num19 = genRand.Next(15, 21);
26416 int n = m - num18;
26417 while (num18 > 0)
26418 {
26419 for (n = m - num18; n < m + num18; n++)
26420 {
26421 Main.tile[n, num17].active(active: true);
26422 Main.tile[n, num17].type = 1;
26423 }
26424 num16++;
26425 if (genRand.Next(3) < num16)
26426 {
26427 num16 = 0;
26428 num18--;
26429 m += genRand.Next(-1, 2);
26430 }
26431 if (num19 <= 0)
26432 {
26433 num18--;
26434 }
26435 num19--;
26436 num17++;
26437 }
26438 n -= genRand.Next(1, 3);
26439 Main.tile[n, num17 - 2].active(active: true);
26440 Main.tile[n, num17 - 2].type = 1;
26441 Main.tile[n, num17 - 1].active(active: true);
26442 Main.tile[n, num17 - 1].type = 1;
26443 Main.tile[n, num17].active(active: true);
26444 Main.tile[n, num17].type = 1;
26445 if (genRand.Next(2) == 0)
26446 {
26447 Main.tile[n, num17 + 1].active(active: true);
26448 Main.tile[n, num17 + 1].type = 1;
26449 PlaceTight(n, num17 + 2);
26450 }
26451 else
26452 {
26453 PlaceTight(n, num17 + 1);
26454 }
26455 }
26456 }
26457 ShimmerMakeBiomeOpening(-1, X - num5, Y, num8);
26458 ShimmerMakeBiomeOpening(1, X + num5, Y, num8);
26459 int num20 = 70;
26460 for (int num21 = 0; num21 < 500; num21++)
26461 {
26462 int num22 = genRand.Next(X - num20, X + num20);
26463 int num23 = genRand.Next(Y - 2, Y + 3);
26464 int num24 = genRand.Next(7);
26465 int treeTileType = 0;
26466 switch (num24)
26467 {
26468 case 0:
26469 treeTileType = 583;
26470 break;
26471 case 1:
26472 treeTileType = 584;
26473 break;
26474 case 2:
26475 treeTileType = 585;
26476 break;
26477 case 3:
26478 treeTileType = 586;
26479 break;
26480 case 4:
26481 treeTileType = 587;
26482 break;
26483 case 5:
26484 treeTileType = 588;
26485 break;
26486 case 6:
26487 treeTileType = 589;
26488 break;
26489 }
26490 if (SolidTile(num22 - 1, num23) && SolidTile(num22 + 1, num23))
26491 {
26492 TryGrowingTreeByType(treeTileType, num22, num23);
26493 }
26494 }
26495 return true;
26496 }
26497
26498 private static void ShimmerMakeBiomeOpening(int direction, int X, int Y, int caveOpenningSize)
26499 {
26500 int num = X;
26502 bool flag;
26503 do
26504 {
26505 num += direction;
26506 flag = true;
26507 for (int i = Y - caveOpenningSize + 1; i < Y - 1; i++)
26508 {
26509 if (SolidTile(num, i))
26510 {
26511 flag = false;
26512 }
26513 if (SolidTile(num + direction, i))
26514 {
26515 flag = false;
26516 }
26517 if (SolidTile(num + direction * 2, i))
26518 {
26519 flag = false;
26520 }
26521 Main.tile[num, i].active(active: false);
26522 }
26523 for (int j = Y - caveOpenningSize; j < Y; j++)
26524 {
26525 Main.tile[num - direction, j].active(active: false);
26526 }
26527 if (SolidTile(num - direction, Y - caveOpenningSize - 1))
26528 {
26529 Main.tile[num - direction, Y - caveOpenningSize - 1].wall = 0;
26530 }
26531 if (SolidTile(num - direction, Y))
26532 {
26533 Main.tile[num - direction, Y].wall = 0;
26534 }
26535 if (genRand.Next(2) == 0)
26536 {
26537 Y += genRand.Next(-1, 2);
26538 }
26539 }
26540 while (!flag && num >= 50 && num <= Main.maxTilesX - 50 && Math.Abs(num - X) <= 100);
26541 }
26542
26543 private static void Shimminate()
26544 {
26545 foreach (KeyValuePair<Point, bool> countedTile in CountedTiles)
26546 {
26547 Point key = countedTile.Key;
26548 Main.tile[key.X, key.Y].shimmer(shimmer: true);
26549 Main.tile[key.X, key.Y].liquid = byte.MaxValue;
26550 if (Main.tile[key.X, key.Y].type == 5 || Main.tile[key.X, key.Y].type == 56 || (Main.tileCut[Main.tile[key.X, key.Y].type] && Main.tile[key.X, key.Y].type != 28))
26551 {
26552 KillTile(key.X, key.Y);
26553 }
26554 }
26555 }
26556
26557 public static void Shimmerator(int x, int y, bool jungle = false, bool lavaOk = false)
26558 {
26559 numTileCount = 0;
26560 CountedTiles.Clear();
26561 ShimmeratorNext(x, y);
26562 if (numTileCount > 0 && numTileCount < maxTileCount)
26563 {
26564 Shimminate();
26565 }
26566 }
26567
26568 private static void ShimmeratorNext(int x, int y)
26569 {
26570 if (numTileCount < maxTileCount)
26571 {
26573 {
26574 numTileCount = maxTileCount;
26575 }
26576 else if (!CountedTiles.ContainsKey(new Point(x, y)) && ((!SolidTile(x, y) && !Main.tile[x, y].shimmer() && Main.tile[x, y].liquid > 0) || (Main.tile[x, y].active() && Main.tile[x, y].type == 56)))
26577 {
26578 CountedTiles.Add(new Point(x, y), value: true);
26579 numTileCount++;
26580 ShimmeratorNext(x - 1, y);
26581 ShimmeratorNext(x + 1, y);
26582 ShimmeratorNext(x, y - 1);
26583 ShimmeratorNext(x, y + 1);
26584 }
26585 }
26586 }
26587
26588 public static void MakeDungeon(int x, int y)
26589 {
26590 GenVars.dEnteranceX = 0;
26591 GenVars.numDRooms = 0;
26592 GenVars.numDDoors = 0;
26593 GenVars.numDungeonPlatforms = 0;
26594 int num = genRand.Next(3);
26595 genRand.Next(3);
26596 if (remixWorldGen)
26597 {
26598 num = (crimson ? 2 : 0);
26599 }
26600 ushort num2;
26601 int num3;
26602 switch (num)
26603 {
26604 case 0:
26605 num2 = 41;
26606 num3 = 7;
26607 GenVars.crackedType = 481;
26608 break;
26609 case 1:
26610 num2 = 43;
26611 num3 = 8;
26612 GenVars.crackedType = 482;
26613 break;
26614 default:
26615 num2 = 44;
26616 num3 = 9;
26617 GenVars.crackedType = 483;
26618 break;
26619 }
26621 GenVars.dungeonLake = true;
26622 GenVars.numDDoors = 0;
26623 GenVars.numDungeonPlatforms = 0;
26624 GenVars.numDRooms = 0;
26625 GenVars.dungeonX = x;
26626 GenVars.dungeonY = y;
26627 GenVars.dMinX = x;
26628 GenVars.dMaxX = x;
26629 GenVars.dMinY = y;
26630 GenVars.dMaxY = y;
26631 GenVars.dxStrength1 = genRand.Next(25, 30);
26632 GenVars.dyStrength1 = genRand.Next(20, 25);
26633 GenVars.dxStrength2 = genRand.Next(35, 50);
26634 GenVars.dyStrength2 = genRand.Next(10, 15);
26635 double num4 = Main.maxTilesX / 60;
26636 num4 += (double)genRand.Next(0, (int)(num4 / 3.0));
26637 double num5 = num4;
26638 int num6 = 5;
26639 DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26640 while (num4 > 0.0)
26641 {
26643 {
26644 GenVars.dMinX = GenVars.dungeonX;
26645 }
26647 {
26648 GenVars.dMaxX = GenVars.dungeonX;
26649 }
26651 {
26652 GenVars.dMaxY = GenVars.dungeonY;
26653 }
26654 num4 -= 1.0;
26655 Main.statusText = Lang.gen[58].Value + " " + (int)((num5 - num4) / num5 * 60.0) + "%";
26656 if (num6 > 0)
26657 {
26658 num6--;
26659 }
26660 if ((num6 == 0) & (genRand.Next(3) == 0))
26661 {
26662 num6 = 5;
26663 if (genRand.Next(2) == 0)
26664 {
26665 int dungeonX = GenVars.dungeonX;
26666 int dungeonY = GenVars.dungeonY;
26667 DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26668 if (genRand.Next(2) == 0)
26669 {
26670 DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26671 }
26672 DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26673 GenVars.dungeonX = dungeonX;
26674 GenVars.dungeonY = dungeonY;
26675 }
26676 else
26677 {
26678 DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26679 }
26680 }
26681 else
26682 {
26683 DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26684 }
26685 }
26686 DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26687 int num7 = GenVars.dRoomX[0];
26688 int num8 = GenVars.dRoomY[0];
26689 for (int i = 0; i < GenVars.numDRooms; i++)
26690 {
26691 if (GenVars.dRoomY[i] < num8)
26692 {
26693 num7 = GenVars.dRoomX[i];
26694 num8 = GenVars.dRoomY[i];
26695 }
26696 }
26697 GenVars.dungeonX = num7;
26698 GenVars.dungeonY = num8;
26699 GenVars.dEnteranceX = num7;
26700 GenVars.dSurface = false;
26701 num6 = 5;
26702 if (drunkWorldGen)
26703 {
26704 GenVars.dSurface = true;
26705 }
26706 while (!GenVars.dSurface)
26707 {
26708 if (num6 > 0)
26709 {
26710 num6--;
26711 }
26712 if (num6 == 0 && genRand.Next(5) == 0 && (double)GenVars.dungeonY > Main.worldSurface + 100.0)
26713 {
26714 num6 = 10;
26717 DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3, forceX: true);
26718 DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26719 GenVars.dungeonX = dungeonX2;
26720 GenVars.dungeonY = dungeonY2;
26721 }
26722 DungeonStairs(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26723 }
26724 DungeonEnt(GenVars.dungeonX, GenVars.dungeonY, num2, num3);
26725 Main.statusText = Lang.gen[58].Value + " 65%";
26726 int num9 = Main.maxTilesX * 2;
26727 int num10;
26728 for (num10 = 0; num10 < num9; num10++)
26729 {
26730 int i2 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
26731 int num11 = GenVars.dMinY;
26732 if ((double)num11 < Main.worldSurface)
26733 {
26734 num11 = (int)Main.worldSurface;
26735 }
26736 int j = genRand.Next(num11, GenVars.dMaxY);
26737 num10 = ((!DungeonPitTrap(i2, j, num2, num3)) ? (num10 + 1) : (num10 + 1500));
26738 }
26739 for (int k = 0; k < GenVars.numDRooms; k++)
26740 {
26741 for (int l = GenVars.dRoomL[k]; l <= GenVars.dRoomR[k]; l++)
26742 {
26743 if (!Main.tile[l, GenVars.dRoomT[k] - 1].active())
26744 {
26748 break;
26749 }
26750 }
26751 for (int m = GenVars.dRoomL[k]; m <= GenVars.dRoomR[k]; m++)
26752 {
26753 if (!Main.tile[m, GenVars.dRoomB[k] + 1].active())
26754 {
26758 break;
26759 }
26760 }
26761 for (int n = GenVars.dRoomT[k]; n <= GenVars.dRoomB[k]; n++)
26762 {
26763 if (!Main.tile[GenVars.dRoomL[k] - 1, n].active())
26764 {
26769 break;
26770 }
26771 }
26772 for (int num12 = GenVars.dRoomT[k]; num12 <= GenVars.dRoomB[k]; num12++)
26773 {
26774 if (!Main.tile[GenVars.dRoomR[k] + 1, num12].active())
26775 {
26780 break;
26781 }
26782 }
26783 }
26784 Main.statusText = Lang.gen[58].Value + " 70%";
26785 int num13 = 0;
26786 int num14 = 1000;
26787 int num15 = 0;
26788 int num16 = Main.maxTilesX / 100;
26789 if (getGoodWorldGen)
26790 {
26791 num16 *= 3;
26792 }
26793 while (num15 < num16)
26794 {
26795 num13++;
26796 int num17 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
26797 int num18 = genRand.Next((int)Main.worldSurface + 25, GenVars.dMaxY);
26798 if (drunkWorldGen)
26799 {
26800 num18 = genRand.Next(GenVars.dungeonY + 25, GenVars.dMaxY);
26801 }
26802 int num19 = num17;
26803 if (Main.tile[num17, num18].wall == num3 && !Main.tile[num17, num18].active())
26804 {
26805 int num20 = 1;
26806 if (genRand.Next(2) == 0)
26807 {
26808 num20 = -1;
26809 }
26810 for (; !Main.tile[num17, num18].active(); num18 += num20)
26811 {
26812 }
26813 if (Main.tile[num17 - 1, num18].active() && Main.tile[num17 + 1, num18].active() && Main.tile[num17 - 1, num18].type != GenVars.crackedType && !Main.tile[num17 - 1, num18 - num20].active() && !Main.tile[num17 + 1, num18 - num20].active())
26814 {
26815 num15++;
26816 int num21 = genRand.Next(5, 13);
26817 while (Main.tile[num17 - 1, num18].active() && Main.tile[num17 - 1, num18].type != GenVars.crackedType && Main.tile[num17, num18 + num20].active() && Main.tile[num17, num18].active() && !Main.tile[num17, num18 - num20].active() && num21 > 0)
26818 {
26819 Main.tile[num17, num18].type = 48;
26820 if (!Main.tile[num17 - 1, num18 - num20].active() && !Main.tile[num17 + 1, num18 - num20].active())
26821 {
26822 Main.tile[num17, num18 - num20].Clear(TileDataType.Slope);
26823 Main.tile[num17, num18 - num20].type = 48;
26824 Main.tile[num17, num18 - num20].active(active: true);
26825 Main.tile[num17, num18 - num20 * 2].Clear(TileDataType.Slope);
26826 Main.tile[num17, num18 - num20 * 2].type = 48;
26827 Main.tile[num17, num18 - num20 * 2].active(active: true);
26828 }
26829 num17--;
26830 num21--;
26831 }
26832 num21 = genRand.Next(5, 13);
26833 num17 = num19 + 1;
26834 while (Main.tile[num17 + 1, num18].active() && Main.tile[num17 + 1, num18].type != GenVars.crackedType && Main.tile[num17, num18 + num20].active() && Main.tile[num17, num18].active() && !Main.tile[num17, num18 - num20].active() && num21 > 0)
26835 {
26836 Main.tile[num17, num18].type = 48;
26837 if (!Main.tile[num17 - 1, num18 - num20].active() && !Main.tile[num17 + 1, num18 - num20].active())
26838 {
26839 Main.tile[num17, num18 - num20].Clear(TileDataType.Slope);
26840 Main.tile[num17, num18 - num20].type = 48;
26841 Main.tile[num17, num18 - num20].active(active: true);
26842 Main.tile[num17, num18 - num20 * 2].Clear(TileDataType.Slope);
26843 Main.tile[num17, num18 - num20 * 2].type = 48;
26844 Main.tile[num17, num18 - num20 * 2].active(active: true);
26845 }
26846 num17++;
26847 num21--;
26848 }
26849 }
26850 }
26851 if (num13 > num14)
26852 {
26853 num13 = 0;
26854 num15++;
26855 }
26856 }
26857 num13 = 0;
26858 num14 = 1000;
26859 num15 = 0;
26860 Main.statusText = Lang.gen[58].Value + " 75%";
26861 while (num15 < num16)
26862 {
26863 num13++;
26864 int num22 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
26865 int num23 = genRand.Next((int)Main.worldSurface + 25, GenVars.dMaxY);
26866 int num24 = num23;
26867 if (Main.tile[num22, num23].wall == num3 && !Main.tile[num22, num23].active())
26868 {
26869 int num25 = 1;
26870 if (genRand.Next(2) == 0)
26871 {
26872 num25 = -1;
26873 }
26874 for (; num22 > 5 && num22 < Main.maxTilesX - 5 && !Main.tile[num22, num23].active(); num22 += num25)
26875 {
26876 }
26877 if (Main.tile[num22, num23 - 1].active() && Main.tile[num22, num23 + 1].active() && Main.tile[num22, num23 - 1].type != GenVars.crackedType && !Main.tile[num22 - num25, num23 - 1].active() && !Main.tile[num22 - num25, num23 + 1].active())
26878 {
26879 num15++;
26880 int num26 = genRand.Next(5, 13);
26881 while (Main.tile[num22, num23 - 1].active() && Main.tile[num22, num23 - 1].type != GenVars.crackedType && Main.tile[num22 + num25, num23].active() && Main.tile[num22, num23].active() && !Main.tile[num22 - num25, num23].active() && num26 > 0)
26882 {
26883 Main.tile[num22, num23].type = 48;
26884 if (!Main.tile[num22 - num25, num23 - 1].active() && !Main.tile[num22 - num25, num23 + 1].active())
26885 {
26886 Main.tile[num22 - num25, num23].type = 48;
26887 Main.tile[num22 - num25, num23].active(active: true);
26888 Main.tile[num22 - num25, num23].Clear(TileDataType.Slope);
26889 Main.tile[num22 - num25 * 2, num23].type = 48;
26890 Main.tile[num22 - num25 * 2, num23].active(active: true);
26891 Main.tile[num22 - num25 * 2, num23].Clear(TileDataType.Slope);
26892 }
26893 num23--;
26894 num26--;
26895 }
26896 num26 = genRand.Next(5, 13);
26897 num23 = num24 + 1;
26898 while (Main.tile[num22, num23 + 1].active() && Main.tile[num22, num23 + 1].type != GenVars.crackedType && Main.tile[num22 + num25, num23].active() && Main.tile[num22, num23].active() && !Main.tile[num22 - num25, num23].active() && num26 > 0)
26899 {
26900 Main.tile[num22, num23].type = 48;
26901 if (!Main.tile[num22 - num25, num23 - 1].active() && !Main.tile[num22 - num25, num23 + 1].active())
26902 {
26903 Main.tile[num22 - num25, num23].type = 48;
26904 Main.tile[num22 - num25, num23].active(active: true);
26905 Main.tile[num22 - num25, num23].Clear(TileDataType.Slope);
26906 Main.tile[num22 - num25 * 2, num23].type = 48;
26907 Main.tile[num22 - num25 * 2, num23].active(active: true);
26908 Main.tile[num22 - num25 * 2, num23].Clear(TileDataType.Slope);
26909 }
26910 num23++;
26911 num26--;
26912 }
26913 }
26914 }
26915 if (num13 > num14)
26916 {
26917 num13 = 0;
26918 num15++;
26919 }
26920 }
26921 Main.statusText = Lang.gen[58].Value + " 80%";
26922 for (int num27 = 0; num27 < GenVars.numDDoors; num27++)
26923 {
26924 int num28 = GenVars.DDoorX[num27] - 10;
26925 int num29 = GenVars.DDoorX[num27] + 10;
26926 int num30 = 100;
26927 int num31 = 0;
26928 int num32 = 0;
26929 int num33 = 0;
26930 for (int num34 = num28; num34 < num29; num34++)
26931 {
26932 bool flag = true;
26933 int num35 = GenVars.DDoorY[num27];
26934 while (num35 > 10 && !Main.tile[num34, num35].active())
26935 {
26936 num35--;
26937 }
26938 if (!Main.tileDungeon[Main.tile[num34, num35].type])
26939 {
26940 flag = false;
26941 }
26942 num32 = num35;
26943 for (num35 = GenVars.DDoorY[num27]; !Main.tile[num34, num35].active(); num35++)
26944 {
26945 }
26946 if (!Main.tileDungeon[Main.tile[num34, num35].type])
26947 {
26948 flag = false;
26949 }
26950 num33 = num35;
26951 if (num33 - num32 < 3)
26952 {
26953 continue;
26954 }
26955 int num36 = num34 - 20;
26956 int num37 = num34 + 20;
26957 int num38 = num33 - 10;
26958 int num39 = num33 + 10;
26959 for (int num40 = num36; num40 < num37; num40++)
26960 {
26961 for (int num41 = num38; num41 < num39; num41++)
26962 {
26963 if (Main.tile[num40, num41].active() && Main.tile[num40, num41].type == 10)
26964 {
26965 flag = false;
26966 break;
26967 }
26968 }
26969 }
26970 if (flag)
26971 {
26972 for (int num42 = num33 - 3; num42 < num33; num42++)
26973 {
26974 for (int num43 = num34 - 3; num43 <= num34 + 3; num43++)
26975 {
26976 if (Main.tile[num43, num42].active())
26977 {
26978 flag = false;
26979 break;
26980 }
26981 }
26982 }
26983 }
26984 if (flag && num33 - num32 < 20)
26985 {
26986 bool flag2 = false;
26987 if (GenVars.DDoorPos[num27] == 0 && num33 - num32 < num30)
26988 {
26989 flag2 = true;
26990 }
26991 if (GenVars.DDoorPos[num27] == -1 && num34 > num31)
26992 {
26993 flag2 = true;
26994 }
26995 if (GenVars.DDoorPos[num27] == 1 && (num34 < num31 || num31 == 0))
26996 {
26997 flag2 = true;
26998 }
26999 if (flag2)
27000 {
27001 num31 = num34;
27002 num30 = num33 - num32;
27003 }
27004 }
27005 }
27006 if (num30 >= 20)
27007 {
27008 continue;
27009 }
27010 int num44 = num31;
27011 int num45 = GenVars.DDoorY[num27];
27012 int num46 = num45;
27013 for (; !Main.tile[num44, num45].active(); num45++)
27014 {
27015 Main.tile[num44, num45].active(active: false);
27016 }
27017 while (!Main.tile[num44, num46].active())
27018 {
27019 num46--;
27020 }
27021 num45--;
27022 num46++;
27023 for (int num47 = num46; num47 < num45 - 2; num47++)
27024 {
27025 Main.tile[num44, num47].Clear(TileDataType.Slope);
27026 Main.tile[num44, num47].active(active: true);
27027 Main.tile[num44, num47].type = num2;
27028 if (Main.tile[num44 - 1, num47].type == num2)
27029 {
27030 Main.tile[num44 - 1, num47].active(active: false);
27031 Main.tile[num44 - 1, num47].ClearEverything();
27032 Main.tile[num44 - 1, num47].wall = (ushort)num3;
27033 }
27034 if (Main.tile[num44 - 2, num47].type == num2)
27035 {
27036 Main.tile[num44 - 2, num47].active(active: false);
27037 Main.tile[num44 - 2, num47].ClearEverything();
27038 Main.tile[num44 - 2, num47].wall = (ushort)num3;
27039 }
27040 if (Main.tile[num44 + 1, num47].type == num2)
27041 {
27042 Main.tile[num44 + 1, num47].active(active: false);
27043 Main.tile[num44 + 1, num47].ClearEverything();
27044 Main.tile[num44 + 1, num47].wall = (ushort)num3;
27045 }
27046 if (Main.tile[num44 + 2, num47].type == num2)
27047 {
27048 Main.tile[num44 + 2, num47].active(active: false);
27049 Main.tile[num44 + 2, num47].ClearEverything();
27050 Main.tile[num44 + 2, num47].wall = (ushort)num3;
27051 }
27052 }
27053 int style = 13;
27054 if (genRand.Next(3) == 0)
27055 {
27056 switch (num3)
27057 {
27058 case 7:
27059 style = 16;
27060 break;
27061 case 8:
27062 style = 17;
27063 break;
27064 case 9:
27065 style = 18;
27066 break;
27067 }
27068 }
27069 PlaceTile(num44, num45, 10, mute: true, forced: false, -1, style);
27070 num44--;
27071 int num48 = num45 - 3;
27072 while (!Main.tile[num44, num48].active())
27073 {
27074 num48--;
27075 }
27076 if (num45 - num48 < num45 - num46 + 5 && Main.tileDungeon[Main.tile[num44, num48].type])
27077 {
27078 for (int num49 = num45 - 4 - genRand.Next(3); num49 > num48; num49--)
27079 {
27080 Main.tile[num44, num49].Clear(TileDataType.Slope);
27081 Main.tile[num44, num49].active(active: true);
27082 Main.tile[num44, num49].type = num2;
27083 if (Main.tile[num44 - 1, num49].type == num2)
27084 {
27085 Main.tile[num44 - 1, num49].active(active: false);
27086 Main.tile[num44 - 1, num49].ClearEverything();
27087 Main.tile[num44 - 1, num49].wall = (ushort)num3;
27088 }
27089 if (Main.tile[num44 - 2, num49].type == num2)
27090 {
27091 Main.tile[num44 - 2, num49].active(active: false);
27092 Main.tile[num44 - 2, num49].ClearEverything();
27093 Main.tile[num44 - 2, num49].wall = (ushort)num3;
27094 }
27095 }
27096 }
27097 num44 += 2;
27098 num48 = num45 - 3;
27099 while (!Main.tile[num44, num48].active())
27100 {
27101 num48--;
27102 }
27103 if (num45 - num48 < num45 - num46 + 5 && Main.tileDungeon[Main.tile[num44, num48].type])
27104 {
27105 for (int num50 = num45 - 4 - genRand.Next(3); num50 > num48; num50--)
27106 {
27107 Main.tile[num44, num50].active(active: true);
27108 Main.tile[num44, num50].Clear(TileDataType.Slope);
27109 Main.tile[num44, num50].type = num2;
27110 if (Main.tile[num44 + 1, num50].type == num2)
27111 {
27112 Main.tile[num44 + 1, num50].active(active: false);
27113 Main.tile[num44 + 1, num50].ClearEverything();
27114 Main.tile[num44 + 1, num50].wall = (ushort)num3;
27115 }
27116 if (Main.tile[num44 + 2, num50].type == num2)
27117 {
27118 Main.tile[num44 + 2, num50].active(active: false);
27119 Main.tile[num44 + 2, num50].ClearEverything();
27120 Main.tile[num44 + 2, num50].wall = (ushort)num3;
27121 }
27122 }
27123 }
27124 num45++;
27125 num44--;
27126 for (int num51 = num45 - 8; num51 < num45; num51++)
27127 {
27128 if (Main.tile[num44 + 2, num51].type == num2)
27129 {
27130 Main.tile[num44 + 2, num51].active(active: false);
27131 Main.tile[num44 + 2, num51].ClearEverything();
27132 Main.tile[num44 + 2, num51].wall = (ushort)num3;
27133 }
27134 if (Main.tile[num44 + 3, num51].type == num2)
27135 {
27136 Main.tile[num44 + 3, num51].active(active: false);
27137 Main.tile[num44 + 3, num51].ClearEverything();
27138 Main.tile[num44 + 3, num51].wall = (ushort)num3;
27139 }
27140 if (Main.tile[num44 - 2, num51].type == num2)
27141 {
27142 Main.tile[num44 - 2, num51].active(active: false);
27143 Main.tile[num44 - 2, num51].ClearEverything();
27144 Main.tile[num44 - 2, num51].wall = (ushort)num3;
27145 }
27146 if (Main.tile[num44 - 3, num51].type == num2)
27147 {
27148 Main.tile[num44 - 3, num51].active(active: false);
27149 Main.tile[num44 - 3, num51].ClearEverything();
27150 Main.tile[num44 - 3, num51].wall = (ushort)num3;
27151 }
27152 }
27153 Main.tile[num44 - 1, num45].active(active: true);
27154 Main.tile[num44 - 1, num45].type = num2;
27155 Main.tile[num44 - 1, num45].Clear(TileDataType.Slope);
27156 Main.tile[num44 + 1, num45].active(active: true);
27157 Main.tile[num44 + 1, num45].type = num2;
27158 Main.tile[num44 + 1, num45].Clear(TileDataType.Slope);
27159 }
27160 int[] array = new int[3];
27161 switch (num3)
27162 {
27163 case 7:
27164 array[0] = 7;
27165 array[1] = 94;
27166 array[2] = 95;
27167 break;
27168 case 9:
27169 array[0] = 9;
27170 array[1] = 96;
27171 array[2] = 97;
27172 break;
27173 default:
27174 array[0] = 8;
27175 array[1] = 98;
27176 array[2] = 99;
27177 break;
27178 }
27179 for (int num52 = 0; num52 < 5; num52++)
27180 {
27181 for (int num53 = 0; num53 < 3; num53++)
27182 {
27183 int num54 = genRand.Next(40, 240);
27184 int num55 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27185 int num56 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27186 for (int num57 = num55 - num54; num57 < num55 + num54; num57++)
27187 {
27188 for (int num58 = num56 - num54; num58 < num56 + num54; num58++)
27189 {
27190 if ((double)num58 > Main.worldSurface)
27191 {
27192 double num59 = Math.Abs(num55 - num57);
27193 double num60 = Math.Abs(num56 - num58);
27194 if (Math.Sqrt(num59 * num59 + num60 * num60) < (double)num54 * 0.4 && Main.wallDungeon[Main.tile[num57, num58].wall])
27195 {
27197 }
27198 }
27199 }
27200 }
27201 }
27202 }
27203 Main.statusText = Lang.gen[58].Value + " 85%";
27204 for (int num61 = 0; num61 < GenVars.numDungeonPlatforms; num61++)
27205 {
27208 int num64 = Main.maxTilesX;
27209 int num65 = 10;
27210 if ((double)num63 < Main.worldSurface + 50.0)
27211 {
27212 num65 = 20;
27213 }
27214 for (int num66 = num63 - 5; num66 <= num63 + 5; num66++)
27215 {
27216 int num67 = num62;
27217 int num68 = num62;
27218 bool flag3 = false;
27219 if (Main.tile[num67, num66].active())
27220 {
27221 flag3 = true;
27222 }
27223 else
27224 {
27225 while (!Main.tile[num67, num66].active())
27226 {
27227 num67--;
27228 if (!Main.tileDungeon[Main.tile[num67, num66].type] || num67 == 0)
27229 {
27230 flag3 = true;
27231 break;
27232 }
27233 }
27234 while (!Main.tile[num68, num66].active())
27235 {
27236 num68++;
27237 if (!Main.tileDungeon[Main.tile[num68, num66].type] || num68 == Main.maxTilesX - 1)
27238 {
27239 flag3 = true;
27240 break;
27241 }
27242 }
27243 }
27244 if (flag3 || num68 - num67 > num65)
27245 {
27246 continue;
27247 }
27248 bool flag4 = true;
27249 int num69 = num62 - num65 / 2 - 2;
27250 int num70 = num62 + num65 / 2 + 2;
27251 int num71 = num66 - 5;
27252 int num72 = num66 + 5;
27253 for (int num73 = num69; num73 <= num70; num73++)
27254 {
27255 for (int num74 = num71; num74 <= num72; num74++)
27256 {
27257 if (Main.tile[num73, num74].active() && Main.tile[num73, num74].type == 19)
27258 {
27259 flag4 = false;
27260 break;
27261 }
27262 }
27263 }
27264 for (int num75 = num66 + 3; num75 >= num66 - 5; num75--)
27265 {
27266 if (Main.tile[num62, num75].active())
27267 {
27268 flag4 = false;
27269 break;
27270 }
27271 }
27272 if (flag4)
27273 {
27274 num64 = num66;
27275 break;
27276 }
27277 }
27279 {
27280 continue;
27281 }
27282 int num76 = num62;
27283 int num77 = num64;
27284 int num78 = num62 + 1;
27285 while (!Main.tile[num76, num77].active())
27286 {
27287 Main.tile[num76, num77].active(active: true);
27288 Main.tile[num76, num77].type = 19;
27289 Main.tile[num76, num77].Clear(TileDataType.Slope);
27290 switch (num3)
27291 {
27292 case 7:
27293 Main.tile[num76, num77].frameY = 108;
27294 break;
27295 case 8:
27296 Main.tile[num76, num77].frameY = 144;
27297 break;
27298 default:
27299 Main.tile[num76, num77].frameY = 126;
27300 break;
27301 }
27302 TileFrame(num76, num77);
27303 num76--;
27304 }
27305 for (; !Main.tile[num78, num77].active(); num78++)
27306 {
27307 Main.tile[num78, num77].active(active: true);
27308 Main.tile[num78, num77].type = 19;
27309 Main.tile[num78, num77].Clear(TileDataType.Slope);
27310 switch (num3)
27311 {
27312 case 7:
27313 Main.tile[num78, num77].frameY = 108;
27314 break;
27315 case 8:
27316 Main.tile[num78, num77].frameY = 144;
27317 break;
27318 default:
27319 Main.tile[num78, num77].frameY = 126;
27320 break;
27321 }
27322 TileFrame(num78, num77);
27323 }
27324 }
27325 int num79 = 5;
27326 if (drunkWorldGen)
27327 {
27328 num79 = 6;
27329 }
27330 for (int num80 = 0; num80 < num79; num80++)
27331 {
27332 bool flag5 = false;
27333 while (!flag5)
27334 {
27335 int num81 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27336 int num82 = genRand.Next((int)Main.worldSurface, GenVars.dMaxY);
27337 if (!Main.wallDungeon[Main.tile[num81, num82].wall] || Main.tile[num81, num82].active())
27338 {
27339 continue;
27340 }
27341 ushort chestTileType = 21;
27342 int contain = 0;
27343 int style2 = 0;
27344 switch (num80)
27345 {
27346 case 0:
27347 style2 = 23;
27348 contain = 1156;
27349 break;
27350 case 1:
27351 if (!crimson)
27352 {
27353 style2 = 24;
27354 contain = 1571;
27355 }
27356 else
27357 {
27358 style2 = 25;
27359 contain = 1569;
27360 }
27361 break;
27362 case 5:
27363 if (crimson)
27364 {
27365 style2 = 24;
27366 contain = 1571;
27367 }
27368 else
27369 {
27370 style2 = 25;
27371 contain = 1569;
27372 }
27373 break;
27374 case 2:
27375 style2 = 26;
27376 contain = 1260;
27377 break;
27378 case 3:
27379 style2 = 27;
27380 contain = 1572;
27381 break;
27382 case 4:
27383 chestTileType = 467;
27384 style2 = 13;
27385 contain = 4607;
27386 break;
27387 }
27388 flag5 = AddBuriedChest(num81, num82, contain, notNearOtherChests: false, style2, trySlope: false, chestTileType);
27389 }
27390 }
27391 int[] array2 = new int[3]
27392 {
27393 genRand.Next(9, 13),
27394 genRand.Next(9, 13),
27395 0
27396 };
27397 while (array2[1] == array2[0])
27398 {
27399 array2[1] = genRand.Next(9, 13);
27400 }
27401 array2[2] = genRand.Next(9, 13);
27402 while (array2[2] == array2[0] || array2[2] == array2[1])
27403 {
27404 array2[2] = genRand.Next(9, 13);
27405 }
27406 Main.statusText = Lang.gen[58].Value + " 90%";
27407 num13 = 0;
27408 num14 = 1000;
27409 num15 = 0;
27410 while (num15 < Main.maxTilesX / 20)
27411 {
27412 num13++;
27413 int num83 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27414 int num84 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27415 bool flag6 = true;
27416 if (Main.wallDungeon[Main.tile[num83, num84].wall] && !Main.tile[num83, num84].active())
27417 {
27418 int num85 = 1;
27419 if (genRand.Next(2) == 0)
27420 {
27421 num85 = -1;
27422 }
27423 while (flag6 && !Main.tile[num83, num84].active())
27424 {
27425 num83 -= num85;
27427 {
27428 flag6 = false;
27429 }
27430 else if (Main.tile[num83, num84].active() && !Main.tileDungeon[Main.tile[num83, num84].type])
27431 {
27432 flag6 = false;
27433 }
27434 }
27435 if (flag6 && Main.tile[num83, num84].active() && Main.tileDungeon[Main.tile[num83, num84].type] && Main.tile[num83, num84 - 1].active() && Main.tileDungeon[Main.tile[num83, num84 - 1].type] && Main.tile[num83, num84 + 1].active() && Main.tileDungeon[Main.tile[num83, num84 + 1].type])
27436 {
27437 num83 += num85;
27438 for (int num86 = num83 - 3; num86 <= num83 + 3; num86++)
27439 {
27440 for (int num87 = num84 - 3; num87 <= num84 + 3; num87++)
27441 {
27442 if (Main.tile[num86, num87].active() && Main.tile[num86, num87].type == 19)
27443 {
27444 flag6 = false;
27445 break;
27446 }
27447 }
27448 }
27449 if (flag6 && (!Main.tile[num83, num84 - 1].active() & !Main.tile[num83, num84 - 2].active() & !Main.tile[num83, num84 - 3].active()))
27450 {
27451 int num88 = num83;
27452 int num89 = num83;
27453 for (; num88 > GenVars.dMinX && num88 < GenVars.dMaxX && !Main.tile[num88, num84].active() && !Main.tile[num88, num84 - 1].active() && !Main.tile[num88, num84 + 1].active(); num88 += num85)
27454 {
27455 }
27456 num88 = Math.Abs(num83 - num88);
27457 bool flag7 = false;
27458 if (genRand.Next(2) == 0)
27459 {
27460 flag7 = true;
27461 }
27462 if (num88 > 5)
27463 {
27464 for (int num90 = genRand.Next(1, 4); num90 > 0; num90--)
27465 {
27466 Main.tile[num83, num84].active(active: true);
27467 Main.tile[num83, num84].Clear(TileDataType.Slope);
27468 Main.tile[num83, num84].type = 19;
27469 if (Main.tile[num83, num84].wall == array[0])
27470 {
27471 Main.tile[num83, num84].frameY = (short)(18 * array2[0]);
27472 }
27473 else if (Main.tile[num83, num84].wall == array[1])
27474 {
27475 Main.tile[num83, num84].frameY = (short)(18 * array2[1]);
27476 }
27477 else
27478 {
27479 Main.tile[num83, num84].frameY = (short)(18 * array2[2]);
27480 }
27481 TileFrame(num83, num84);
27482 if (flag7)
27483 {
27484 PlaceTile(num83, num84 - 1, 50, mute: true);
27485 if (genRand.Next(50) == 0 && (double)num84 > (Main.worldSurface + Main.rockLayer) / 2.0 && Main.tile[num83, num84 - 1].type == 50)
27486 {
27487 Main.tile[num83, num84 - 1].frameX = 90;
27488 }
27489 }
27490 num83 += num85;
27491 }
27492 num13 = 0;
27493 num15++;
27494 if (!flag7 && genRand.Next(2) == 0)
27495 {
27496 num83 = num89;
27497 num84--;
27498 int num91 = 0;
27499 if (genRand.Next(4) == 0)
27500 {
27501 num91 = 1;
27502 }
27503 switch (num91)
27504 {
27505 case 0:
27506 num91 = 13;
27507 break;
27508 case 1:
27509 num91 = 49;
27510 break;
27511 }
27512 PlaceTile(num83, num84, num91, mute: true);
27513 if (Main.tile[num83, num84].type == 13)
27514 {
27515 if (genRand.Next(2) == 0)
27516 {
27517 Main.tile[num83, num84].frameX = 18;
27518 }
27519 else
27520 {
27521 Main.tile[num83, num84].frameX = 36;
27522 }
27523 }
27524 }
27525 }
27526 }
27527 }
27528 }
27529 if (num13 > num14)
27530 {
27531 num13 = 0;
27532 num15++;
27533 }
27534 }
27535 Main.statusText = Lang.gen[58].Value + " 95%";
27536 int num92 = 1;
27537 for (int num93 = 0; num93 < GenVars.numDRooms; num93++)
27538 {
27539 int num94 = 0;
27540 while (num94 < 1000)
27541 {
27542 int num95 = (int)((double)GenVars.dRoomSize[num93] * 0.4);
27543 int i3 = GenVars.dRoomX[num93] + genRand.Next(-num95, num95 + 1);
27544 int num96 = GenVars.dRoomY[num93] + genRand.Next(-num95, num95 + 1);
27545 int num97 = 0;
27546 int style3 = 2;
27547 if (num92 == 1)
27548 {
27549 num92++;
27550 }
27551 switch (num92)
27552 {
27553 case 2:
27554 num97 = 155;
27555 break;
27556 case 3:
27557 num97 = 156;
27558 break;
27559 case 4:
27560 num97 = ((!remixWorldGen) ? 157 : 2623);
27561 break;
27562 case 5:
27563 num97 = 163;
27564 break;
27565 case 6:
27566 num97 = 113;
27567 break;
27568 case 7:
27569 num97 = 3317;
27570 break;
27571 case 8:
27572 num97 = 327;
27573 style3 = 0;
27574 break;
27575 default:
27576 num97 = 164;
27577 num92 = 0;
27578 break;
27579 }
27580 if ((double)num96 < Main.worldSurface + 50.0)
27581 {
27582 num97 = 327;
27583 style3 = 0;
27584 }
27585 if (num97 == 0 && genRand.Next(2) == 0)
27586 {
27587 num94 = 1000;
27588 continue;
27589 }
27590 if (AddBuriedChest(i3, num96, num97, notNearOtherChests: false, style3, trySlope: false, 0))
27591 {
27592 num94 += 1000;
27593 num92++;
27594 }
27595 num94++;
27596 }
27597 }
27598 GenVars.dMinX -= 25;
27599 GenVars.dMaxX += 25;
27600 GenVars.dMinY -= 25;
27601 GenVars.dMaxY += 25;
27602 if (GenVars.dMinX < 0)
27603 {
27604 GenVars.dMinX = 0;
27605 }
27607 {
27608 GenVars.dMaxX = Main.maxTilesX;
27609 }
27610 if (GenVars.dMinY < 0)
27611 {
27612 GenVars.dMinY = 0;
27613 }
27615 {
27616 GenVars.dMaxY = Main.maxTilesY;
27617 }
27618 num13 = 0;
27619 num14 = 1000;
27620 num15 = 0;
27621 MakeDungeon_Lights(num2, ref num13, num14, ref num15, array);
27622 num13 = 0;
27623 num14 = 1000;
27624 num15 = 0;
27625 MakeDungeon_Traps(ref num13, num14, ref num15);
27626 double count = MakeDungeon_GroundFurniture(num3);
27627 count = MakeDungeon_Pictures(array, count);
27628 count = MakeDungeon_Banners(array, count);
27629 }
27630
27631 private static void MakeDungeon_Traps(ref int failCount, int failMax, ref int numAdd)
27632 {
27633 while (numAdd < Main.maxTilesX / 500)
27634 {
27635 failCount++;
27636 int num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27637 int num2 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27638 while ((double)num2 < Main.worldSurface)
27639 {
27640 num2 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27641 }
27642 if (Main.wallDungeon[Main.tile[num, num2].wall] && placeTrap(num, num2, 0))
27643 {
27645 }
27646 if (failCount > failMax)
27647 {
27648 numAdd++;
27649 failCount = 0;
27650 }
27651 }
27652 }
27653
27654 private static void MakeDungeon_Lights(ushort tileType, ref int failCount, int failMax, ref int numAdd, int[] roomWall)
27655 {
27656 int[] array = new int[3]
27657 {
27658 genRand.Next(7),
27659 genRand.Next(7),
27660 0
27661 };
27662 while (array[1] == array[0])
27663 {
27664 array[1] = genRand.Next(7);
27665 }
27666 array[2] = genRand.Next(7);
27667 while (array[2] == array[0] || array[2] == array[1])
27668 {
27669 array[2] = genRand.Next(7);
27670 }
27671 while (numAdd < Main.maxTilesX / 150)
27672 {
27673 failCount++;
27674 int num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27675 int num2 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27676 if (Main.wallDungeon[Main.tile[num, num2].wall])
27677 {
27678 for (int num3 = num2; num3 > GenVars.dMinY; num3--)
27679 {
27680 if (Main.tile[num, num3 - 1].active() && Main.tile[num, num3 - 1].type == tileType)
27681 {
27682 bool flag = false;
27683 for (int i = num - 15; i < num + 15; i++)
27684 {
27685 for (int j = num3 - 15; j < num3 + 15; j++)
27686 {
27687 if (i > 0 && i < Main.maxTilesX && j > 0 && j < Main.maxTilesY && (Main.tile[i, j].type == 42 || Main.tile[i, j].type == 34))
27688 {
27689 flag = true;
27690 break;
27691 }
27692 }
27693 }
27694 if (Main.tile[num - 1, num3].active() || Main.tile[num + 1, num3].active() || Main.tile[num - 1, num3 + 1].active() || Main.tile[num + 1, num3 + 1].active() || Main.tile[num, num3 + 2].active())
27695 {
27696 flag = true;
27697 }
27698 if (flag)
27699 {
27700 break;
27701 }
27702 bool flag2 = false;
27703 if (!flag2 && genRand.Next(7) == 0)
27704 {
27705 int style = 27;
27706 switch (roomWall[0])
27707 {
27708 case 7:
27709 style = 27;
27710 break;
27711 case 8:
27712 style = 28;
27713 break;
27714 case 9:
27715 style = 29;
27716 break;
27717 }
27718 bool flag3 = false;
27719 for (int k = 0; k < 15; k++)
27720 {
27721 if (SolidTile(num, num3 + k))
27722 {
27723 flag3 = true;
27724 break;
27725 }
27726 }
27727 if (!flag3)
27728 {
27729 PlaceChand(num, num3, 34, style);
27730 }
27731 if (Main.tile[num, num3].type == 34)
27732 {
27733 flag2 = true;
27734 failCount = 0;
27735 numAdd++;
27736 for (int l = 0; l < 1000; l++)
27737 {
27738 int num4 = num + genRand.Next(-12, 13);
27739 int num5 = num3 + genRand.Next(3, 21);
27740 if (Main.tile[num4, num5].active() || Main.tile[num4, num5 + 1].active() || !Main.tileDungeon[Main.tile[num4 - 1, num5].type] || !Main.tileDungeon[Main.tile[num4 + 1, num5].type] || !Collision.CanHit(new Point(num4 * 16, num5 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16))
27741 {
27742 continue;
27743 }
27744 if (((SolidTile(num4 - 1, num5) && Main.tile[num4 - 1, num5].type != 10) || (SolidTile(num4 + 1, num5) && Main.tile[num4 + 1, num5].type != 10) || SolidTile(num4, num5 + 1)) && Main.wallDungeon[Main.tile[num4, num5].wall] && (Main.tileDungeon[Main.tile[num4 - 1, num5].type] || Main.tileDungeon[Main.tile[num4 + 1, num5].type]))
27745 {
27746 PlaceTile(num4, num5, 136, mute: true);
27747 }
27748 if (!Main.tile[num4, num5].active())
27749 {
27750 continue;
27751 }
27752 while (num4 != num || num5 != num3)
27753 {
27754 Main.tile[num4, num5].wire(wire: true);
27755 if (num4 > num)
27756 {
27757 num4--;
27758 }
27759 if (num4 < num)
27760 {
27761 num4++;
27762 }
27763 Main.tile[num4, num5].wire(wire: true);
27764 if (num5 > num3)
27765 {
27766 num5--;
27767 }
27768 if (num5 < num3)
27769 {
27770 num5++;
27771 }
27772 Main.tile[num4, num5].wire(wire: true);
27773 }
27774 if (genRand.Next(3) > 0)
27775 {
27776 Main.tile[num, num3].frameX = 18;
27777 Main.tile[num, num3 + 1].frameX = 18;
27778 }
27779 break;
27780 }
27781 }
27782 }
27783 if (flag2)
27784 {
27785 break;
27786 }
27787 int style2 = array[0];
27788 if (Main.tile[num, num3].wall == roomWall[1])
27789 {
27790 style2 = array[1];
27791 }
27792 if (Main.tile[num, num3].wall == roomWall[2])
27793 {
27794 style2 = array[2];
27795 }
27796 Place1x2Top(num, num3, 42, style2);
27797 if (Main.tile[num, num3].type != 42)
27798 {
27799 break;
27800 }
27801 flag2 = true;
27802 failCount = 0;
27803 numAdd++;
27804 for (int m = 0; m < 1000; m++)
27805 {
27806 int num6 = num + genRand.Next(-12, 13);
27807 int num7 = num3 + genRand.Next(3, 21);
27808 if (Main.tile[num6, num7].active() || Main.tile[num6, num7 + 1].active() || Main.tile[num6 - 1, num7].type == 48 || Main.tile[num6 + 1, num7].type == 48 || !Collision.CanHit(new Point(num6 * 16, num7 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16))
27809 {
27810 continue;
27811 }
27812 if ((SolidTile(num6 - 1, num7) && Main.tile[num6 - 1, num7].type != 10) || (SolidTile(num6 + 1, num7) && Main.tile[num6 + 1, num7].type != 10) || SolidTile(num6, num7 + 1))
27813 {
27814 PlaceTile(num6, num7, 136, mute: true);
27815 }
27816 if (!Main.tile[num6, num7].active())
27817 {
27818 continue;
27819 }
27820 while (num6 != num || num7 != num3)
27821 {
27822 Main.tile[num6, num7].wire(wire: true);
27823 if (num6 > num)
27824 {
27825 num6--;
27826 }
27827 if (num6 < num)
27828 {
27829 num6++;
27830 }
27831 Main.tile[num6, num7].wire(wire: true);
27832 if (num7 > num3)
27833 {
27834 num7--;
27835 }
27836 if (num7 < num3)
27837 {
27838 num7++;
27839 }
27840 Main.tile[num6, num7].wire(wire: true);
27841 }
27842 if (genRand.Next(3) > 0)
27843 {
27844 Main.tile[num, num3].frameX = 18;
27845 Main.tile[num, num3 + 1].frameX = 18;
27846 }
27847 break;
27848 }
27849 break;
27850 }
27851 }
27852 }
27853 if (failCount > failMax)
27854 {
27855 numAdd++;
27856 failCount = 0;
27857 }
27858 }
27859 }
27860
27861 private static double MakeDungeon_Banners(int[] roomWall, double count)
27862 {
27863 count = 840000.0 / (double)Main.maxTilesX;
27864 for (int i = 0; (double)i < count; i++)
27865 {
27866 int num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27867 int num2 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27868 while (!Main.wallDungeon[Main.tile[num, num2].wall] || Main.tile[num, num2].active())
27869 {
27870 num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27871 num2 = genRand.Next(GenVars.dMinY, GenVars.dMaxY);
27872 }
27873 while (!SolidTile(num, num2) && num2 > 10)
27874 {
27875 num2--;
27876 }
27877 num2++;
27878 if (!Main.wallDungeon[Main.tile[num, num2].wall] || Main.tile[num, num2 - 1].type == 48 || Main.tile[num, num2].active() || Main.tile[num, num2 + 1].active() || Main.tile[num, num2 + 2].active() || Main.tile[num, num2 + 3].active())
27879 {
27880 continue;
27881 }
27882 bool flag = true;
27883 for (int j = num - 1; j <= num + 1; j++)
27884 {
27885 for (int k = num2; k <= num2 + 3; k++)
27886 {
27887 if (Main.tile[j, k].active() && (Main.tile[j, k].type == 10 || Main.tile[j, k].type == 11 || Main.tile[j, k].type == 91))
27888 {
27889 flag = false;
27890 }
27891 }
27892 }
27893 if (flag)
27894 {
27895 int num3 = 10;
27896 if (Main.tile[num, num2].wall == roomWall[1])
27897 {
27898 num3 = 12;
27899 }
27900 if (Main.tile[num, num2].wall == roomWall[2])
27901 {
27902 num3 = 14;
27903 }
27904 num3 += genRand.Next(2);
27905 PlaceTile(num, num2, 91, mute: true, forced: false, -1, num3);
27906 }
27907 }
27908 return count;
27909 }
27910
27911 private static double MakeDungeon_Pictures(int[] roomWall, double count)
27912 {
27913 count = 420000.0 / (double)Main.maxTilesX;
27914 for (int i = 0; (double)i < count; i++)
27915 {
27916 int num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27917 int num2 = genRand.Next((int)Main.worldSurface, GenVars.dMaxY);
27918 while (!Main.wallDungeon[Main.tile[num, num2].wall] || Main.tile[num, num2].active())
27919 {
27920 num = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
27921 num2 = genRand.Next((int)Main.worldSurface, GenVars.dMaxY);
27922 }
27923 int num3 = num;
27924 int num4 = num;
27925 int num5 = num2;
27926 int num6 = num2;
27927 int num7 = 0;
27928 int num8 = 0;
27929 for (int j = 0; j < 2; j++)
27930 {
27931 num3 = num;
27932 num4 = num;
27933 while (!Main.tile[num3, num2].active() && Main.wallDungeon[Main.tile[num3, num2].wall])
27934 {
27935 num3--;
27936 }
27937 num3++;
27938 for (; !Main.tile[num4, num2].active() && Main.wallDungeon[Main.tile[num4, num2].wall]; num4++)
27939 {
27940 }
27941 num4--;
27942 num = (num3 + num4) / 2;
27943 num5 = num2;
27944 num6 = num2;
27945 while (!Main.tile[num, num5].active() && Main.wallDungeon[Main.tile[num, num5].wall])
27946 {
27947 num5--;
27948 }
27949 num5++;
27950 for (; !Main.tile[num, num6].active() && Main.wallDungeon[Main.tile[num, num6].wall]; num6++)
27951 {
27952 }
27953 num6--;
27954 num2 = (num5 + num6) / 2;
27955 }
27956 num3 = num;
27957 num4 = num;
27958 while (!Main.tile[num3, num2].active() && !Main.tile[num3, num2 - 1].active() && !Main.tile[num3, num2 + 1].active())
27959 {
27960 num3--;
27961 }
27962 num3++;
27963 for (; !Main.tile[num4, num2].active() && !Main.tile[num4, num2 - 1].active() && !Main.tile[num4, num2 + 1].active(); num4++)
27964 {
27965 }
27966 num4--;
27967 num5 = num2;
27968 num6 = num2;
27969 while (!Main.tile[num, num5].active() && !Main.tile[num - 1, num5].active() && !Main.tile[num + 1, num5].active())
27970 {
27971 num5--;
27972 }
27973 num5++;
27974 for (; !Main.tile[num, num6].active() && !Main.tile[num - 1, num6].active() && !Main.tile[num + 1, num6].active(); num6++)
27975 {
27976 }
27977 num6--;
27978 num = (num3 + num4) / 2;
27979 num2 = (num5 + num6) / 2;
27980 num7 = num4 - num3;
27981 num8 = num6 - num5;
27982 if (num7 <= 7 || num8 <= 5)
27983 {
27984 continue;
27985 }
27986 bool[] array = new bool[3] { true, false, false };
27987 if (num7 > num8 * 3 && num7 > 21)
27988 {
27989 array[1] = true;
27990 }
27991 if (num8 > num7 * 3 && num8 > 21)
27992 {
27993 array[2] = true;
27994 }
27995 int num9 = genRand.Next(3);
27996 if (Main.tile[num, num2].wall == roomWall[0])
27997 {
27998 num9 = 0;
27999 }
28000 while (!array[num9])
28001 {
28002 num9 = genRand.Next(3);
28003 }
28004 if (nearPicture2(num, num2))
28005 {
28006 num9 = -1;
28007 }
28008 switch (num9)
28009 {
28010 case 0:
28011 {
28012 PaintingEntry paintingEntry2 = RandPictureTile();
28013 if (Main.tile[num, num2].wall != roomWall[0])
28014 {
28015 paintingEntry2 = RandBonePicture();
28016 }
28017 if (!nearPicture(num, num2))
28018 {
28019 PlaceTile(num, num2, paintingEntry2.tileType, mute: true, forced: false, -1, paintingEntry2.style);
28020 }
28021 break;
28022 }
28023 case 1:
28024 {
28025 PaintingEntry paintingEntry3 = RandPictureTile();
28026 if (Main.tile[num, num2].wall != roomWall[0])
28027 {
28028 paintingEntry3 = RandBonePicture();
28029 }
28030 if (!Main.tile[num, num2].active())
28031 {
28032 PlaceTile(num, num2, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style);
28033 }
28034 int num13 = num;
28035 int num14 = num2;
28036 int num15 = num2;
28037 for (int m = 0; m < 2; m++)
28038 {
28039 num += 7;
28040 num5 = num15;
28041 num6 = num15;
28042 while (!Main.tile[num, num5].active() && !Main.tile[num - 1, num5].active() && !Main.tile[num + 1, num5].active())
28043 {
28044 num5--;
28045 }
28046 num5++;
28047 for (; !Main.tile[num, num6].active() && !Main.tile[num - 1, num6].active() && !Main.tile[num + 1, num6].active(); num6++)
28048 {
28049 }
28050 num6--;
28051 num15 = (num5 + num6) / 2;
28052 paintingEntry3 = RandPictureTile();
28053 if (Main.tile[num, num15].wall != roomWall[0])
28054 {
28055 paintingEntry3 = RandBonePicture();
28056 }
28057 if (Math.Abs(num14 - num15) >= 4 || nearPicture(num, num15))
28058 {
28059 break;
28060 }
28061 PlaceTile(num, num15, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style);
28062 }
28063 num15 = num2;
28064 num = num13;
28065 for (int n = 0; n < 2; n++)
28066 {
28067 num -= 7;
28068 num5 = num15;
28069 num6 = num15;
28070 while (!Main.tile[num, num5].active() && !Main.tile[num - 1, num5].active() && !Main.tile[num + 1, num5].active())
28071 {
28072 num5--;
28073 }
28074 num5++;
28075 for (; !Main.tile[num, num6].active() && !Main.tile[num - 1, num6].active() && !Main.tile[num + 1, num6].active(); num6++)
28076 {
28077 }
28078 num6--;
28079 num15 = (num5 + num6) / 2;
28080 paintingEntry3 = RandPictureTile();
28081 if (Main.tile[num, num15].wall != roomWall[0])
28082 {
28083 paintingEntry3 = RandBonePicture();
28084 }
28085 if (Math.Abs(num14 - num15) >= 4 || nearPicture(num, num15))
28086 {
28087 break;
28088 }
28089 PlaceTile(num, num15, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style);
28090 }
28091 break;
28092 }
28093 case 2:
28094 {
28095 PaintingEntry paintingEntry = RandPictureTile();
28096 if (Main.tile[num, num2].wall != roomWall[0])
28097 {
28098 paintingEntry = RandBonePicture();
28099 }
28100 if (!Main.tile[num, num2].active())
28101 {
28102 PlaceTile(num, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style);
28103 }
28104 int num10 = num2;
28105 int num11 = num;
28106 int num12 = num;
28107 for (int k = 0; k < 3; k++)
28108 {
28109 num2 += 7;
28110 num3 = num12;
28111 num4 = num12;
28112 while (!Main.tile[num3, num2].active() && !Main.tile[num3, num2 - 1].active() && !Main.tile[num3, num2 + 1].active())
28113 {
28114 num3--;
28115 }
28116 num3++;
28117 for (; !Main.tile[num4, num2].active() && !Main.tile[num4, num2 - 1].active() && !Main.tile[num4, num2 + 1].active(); num4++)
28118 {
28119 }
28120 num4--;
28121 num12 = (num3 + num4) / 2;
28122 paintingEntry = RandPictureTile();
28123 if (Main.tile[num12, num2].wall != roomWall[0])
28124 {
28125 paintingEntry = RandBonePicture();
28126 }
28127 if (Math.Abs(num11 - num12) >= 4 || nearPicture(num12, num2))
28128 {
28129 break;
28130 }
28131 PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style);
28132 }
28133 num12 = num;
28134 num2 = num10;
28135 for (int l = 0; l < 3; l++)
28136 {
28137 num2 -= 7;
28138 num3 = num12;
28139 num4 = num12;
28140 while (!Main.tile[num3, num2].active() && !Main.tile[num3, num2 - 1].active() && !Main.tile[num3, num2 + 1].active())
28141 {
28142 num3--;
28143 }
28144 num3++;
28145 for (; !Main.tile[num4, num2].active() && !Main.tile[num4, num2 - 1].active() && !Main.tile[num4, num2 + 1].active(); num4++)
28146 {
28147 }
28148 num4--;
28149 num12 = (num3 + num4) / 2;
28150 paintingEntry = RandPictureTile();
28151 if (Main.tile[num12, num2].wall != roomWall[0])
28152 {
28153 paintingEntry = RandBonePicture();
28154 }
28155 if (Math.Abs(num11 - num12) >= 4 || nearPicture(num12, num2))
28156 {
28157 break;
28158 }
28159 PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style);
28160 }
28161 break;
28162 }
28163 }
28164 }
28165 return count;
28166 }
28167
28168 private static double MakeDungeon_GroundFurniture(int wallType)
28169 {
28170 double num = (double)(2000 * Main.maxTilesX) / 4200.0;
28171 int num2 = 1 + (int)((double)Main.maxTilesX / 4200.0);
28172 int num3 = 1 + (int)((double)Main.maxTilesX / 4200.0);
28173 for (int i = 0; (double)i < num; i++)
28174 {
28175 if (num2 > 0 || num3 > 0)
28176 {
28177 i--;
28178 }
28179 int num4 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
28180 int j = genRand.Next((int)Main.worldSurface + 10, GenVars.dMaxY);
28181 while (!Main.wallDungeon[Main.tile[num4, j].wall] || Main.tile[num4, j].active())
28182 {
28183 num4 = genRand.Next(GenVars.dMinX, GenVars.dMaxX);
28184 j = genRand.Next((int)Main.worldSurface + 10, GenVars.dMaxY);
28185 }
28186 if (!Main.wallDungeon[Main.tile[num4, j].wall] || Main.tile[num4, j].active())
28187 {
28188 continue;
28189 }
28190 for (; !SolidTile(num4, j) && j < Main.UnderworldLayer; j++)
28191 {
28192 }
28193 j--;
28194 int num5 = num4;
28195 int k = num4;
28196 while (!Main.tile[num5, j].active() && SolidTile(num5, j + 1))
28197 {
28198 num5--;
28199 }
28200 num5++;
28201 for (; !Main.tile[k, j].active() && SolidTile(k, j + 1); k++)
28202 {
28203 }
28204 k--;
28205 int num6 = k - num5;
28206 int num7 = (k + num5) / 2;
28207 if (Main.tile[num7, j].active() || !Main.wallDungeon[Main.tile[num7, j].wall] || !SolidTile(num7, j + 1) || Main.tile[num7, j + 1].type == 48)
28208 {
28209 continue;
28210 }
28211 int style = 13;
28212 int style2 = 10;
28213 int style3 = 11;
28214 int num8 = 1;
28215 int num9 = 46;
28216 int style4 = 1;
28217 int num10 = 5;
28218 int num11 = 11;
28219 int num12 = 5;
28220 int num13 = 6;
28221 int num14 = 21;
28222 int num15 = 22;
28223 int num16 = 24;
28224 int num17 = 30;
28225 switch (wallType)
28226 {
28227 case 8:
28228 style = 14;
28229 style2 = 11;
28230 style3 = 12;
28231 num8 = 2;
28232 num9 = 47;
28233 style4 = 2;
28234 num10 = 6;
28235 num11 = 12;
28236 num12 = 6;
28237 num13 = 7;
28238 num14 = 22;
28239 num15 = 23;
28240 num16 = 25;
28241 num17 = 31;
28242 break;
28243 case 9:
28244 style = 15;
28245 style2 = 12;
28246 style3 = 13;
28247 num8 = 3;
28248 num9 = 48;
28249 style4 = 3;
28250 num10 = 7;
28251 num11 = 13;
28252 num12 = 7;
28253 num13 = 8;
28254 num14 = 23;
28255 num15 = 24;
28256 num16 = 26;
28257 num17 = 32;
28258 break;
28259 }
28260 if (Main.tile[num7, j].wall >= 94 && Main.tile[num7, j].wall <= 105)
28261 {
28262 style = 17;
28263 style2 = 14;
28264 style3 = 15;
28265 num8 = -1;
28266 num9 = -1;
28267 style4 = 5;
28268 num10 = -1;
28269 num11 = -1;
28270 num12 = -1;
28271 num13 = -1;
28272 num14 = -1;
28273 num15 = -1;
28274 num16 = -1;
28275 num17 = -1;
28276 }
28277 int num18 = genRand.Next(13);
28278 if ((num18 == 10 || num18 == 11 || num18 == 12) && genRand.Next(4) != 0)
28279 {
28280 num18 = genRand.Next(13);
28281 }
28282 while ((num18 == 2 && num9 == -1) || (num18 == 5 && num10 == -1) || (num18 == 6 && num11 == -1) || (num18 == 7 && num12 == -1) || (num18 == 8 && num13 == -1) || (num18 == 9 && num14 == -1) || (num18 == 10 && num15 == -1) || (num18 == 11 && num16 == -1) || (num18 == 12 && num17 == -1))
28283 {
28284 num18 = genRand.Next(13);
28285 }
28286 int num19 = 0;
28287 int num20 = 0;
28288 if (num18 == 0)
28289 {
28290 num19 = 5;
28291 num20 = 4;
28292 }
28293 if (num18 == 1)
28294 {
28295 num19 = 4;
28296 num20 = 3;
28297 }
28298 if (num18 == 2)
28299 {
28300 num19 = 3;
28301 num20 = 5;
28302 }
28303 if (num18 == 3)
28304 {
28305 num19 = 4;
28306 num20 = 6;
28307 }
28308 if (num18 == 4)
28309 {
28310 num19 = 3;
28311 num20 = 3;
28312 }
28313 if (num18 == 5)
28314 {
28315 num19 = 5;
28316 num20 = 3;
28317 }
28318 if (num18 == 6)
28319 {
28320 num19 = 5;
28321 num20 = 4;
28322 }
28323 if (num18 == 7)
28324 {
28325 num19 = 5;
28326 num20 = 4;
28327 }
28328 if (num18 == 8)
28329 {
28330 num19 = 5;
28331 num20 = 4;
28332 }
28333 if (num18 == 9)
28334 {
28335 num19 = 5;
28336 num20 = 3;
28337 }
28338 if (num18 == 10)
28339 {
28340 num19 = 2;
28341 num20 = 4;
28342 }
28343 if (num18 == 11)
28344 {
28345 num19 = 3;
28346 num20 = 3;
28347 }
28348 if (num18 == 12)
28349 {
28350 num19 = 2;
28351 num20 = 5;
28352 }
28353 for (int l = num7 - num19; l <= num7 + num19; l++)
28354 {
28355 for (int m = j - num20; m <= j; m++)
28356 {
28357 if (Main.tile[l, m].active())
28358 {
28359 num18 = -1;
28360 break;
28361 }
28362 }
28363 }
28364 if ((double)num6 < (double)num19 * 1.75)
28365 {
28366 num18 = -1;
28367 }
28368 if (num2 > 0 || num3 > 0)
28369 {
28370 if (num2 > 0)
28371 {
28372 PlaceTile(num7, j, 355, mute: true);
28373 if (Main.tile[num7, j].type == 355)
28374 {
28375 num2--;
28376 }
28377 }
28378 else if (num3 > 0)
28379 {
28380 PlaceTile(num7, j, 354, mute: true);
28381 if (Main.tile[num7, j].type == 354)
28382 {
28383 num3--;
28384 }
28385 }
28386 continue;
28387 }
28388 switch (num18)
28389 {
28390 case 0:
28391 {
28392 PlaceTile(num7, j, 14, mute: true, forced: false, -1, style2);
28393 if (Main.tile[num7, j].active())
28394 {
28395 if (!Main.tile[num7 - 2, j].active())
28396 {
28397 PlaceTile(num7 - 2, j, 15, mute: true, forced: false, -1, style);
28398 if (Main.tile[num7 - 2, j].active())
28399 {
28400 Main.tile[num7 - 2, j].frameX += 18;
28401 Main.tile[num7 - 2, j - 1].frameX += 18;
28402 }
28403 }
28404 if (!Main.tile[num7 + 2, j].active())
28405 {
28406 PlaceTile(num7 + 2, j, 15, mute: true, forced: false, -1, style);
28407 }
28408 }
28409 for (int num22 = num7 - 1; num22 <= num7 + 1; num22++)
28410 {
28411 if (genRand.Next(2) == 0 && !Main.tile[num22, j - 2].active())
28412 {
28413 int num23 = genRand.Next(5);
28414 if (num8 != -1 && num23 <= 1 && !Main.tileLighted[Main.tile[num22 - 1, j - 2].type])
28415 {
28416 PlaceTile(num22, j - 2, 33, mute: true, forced: false, -1, num8);
28417 }
28418 if (num23 == 2 && !Main.tileLighted[Main.tile[num22 - 1, j - 2].type])
28419 {
28420 PlaceTile(num22, j - 2, 49, mute: true);
28421 }
28422 if (num23 == 3)
28423 {
28424 PlaceTile(num22, j - 2, 50, mute: true);
28425 }
28426 if (num23 == 4)
28427 {
28428 PlaceTile(num22, j - 2, 103, mute: true);
28429 }
28430 }
28431 }
28432 break;
28433 }
28434 case 1:
28435 {
28436 PlaceTile(num7, j, 18, mute: true, forced: false, -1, style3);
28437 if (!Main.tile[num7, j].active())
28438 {
28439 break;
28440 }
28441 if (genRand.Next(2) == 0)
28442 {
28443 if (!Main.tile[num7 - 1, j].active())
28444 {
28445 PlaceTile(num7 - 1, j, 15, mute: true, forced: false, -1, style);
28446 if (Main.tile[num7 - 1, j].active())
28447 {
28448 Main.tile[num7 - 1, j].frameX += 18;
28449 Main.tile[num7 - 1, j - 1].frameX += 18;
28450 }
28451 }
28452 }
28453 else if (!Main.tile[num7 + 2, j].active())
28454 {
28455 PlaceTile(num7 + 2, j, 15, mute: true, forced: false, -1, style);
28456 }
28457 for (int n = num7; n <= num7 + 1; n++)
28458 {
28459 if (genRand.Next(2) == 0 && !Main.tile[n, j - 1].active())
28460 {
28461 int num21 = genRand.Next(5);
28462 if (num8 != -1 && num21 <= 1 && !Main.tileLighted[Main.tile[n - 1, j - 1].type])
28463 {
28464 PlaceTile(n, j - 1, 33, mute: true, forced: false, -1, num8);
28465 }
28466 if (num21 == 2 && !Main.tileLighted[Main.tile[n - 1, j - 1].type])
28467 {
28468 PlaceTile(n, j - 1, 49, mute: true);
28469 }
28470 if (num21 == 3)
28471 {
28472 PlaceTile(n, j - 1, 50, mute: true);
28473 }
28474 if (num21 == 4)
28475 {
28476 PlaceTile(n, j - 1, 103, mute: true);
28477 }
28478 }
28479 }
28480 break;
28481 }
28482 case 2:
28483 PlaceTile(num7, j, 105, mute: true, forced: false, -1, num9);
28484 break;
28485 case 3:
28486 PlaceTile(num7, j, 101, mute: true, forced: false, -1, style4);
28487 break;
28488 case 4:
28489 if (genRand.Next(2) == 0)
28490 {
28491 PlaceTile(num7, j, 15, mute: true, forced: false, -1, style);
28492 Main.tile[num7, j].frameX += 18;
28493 Main.tile[num7, j - 1].frameX += 18;
28494 }
28495 else
28496 {
28497 PlaceTile(num7, j, 15, mute: true, forced: false, -1, style);
28498 }
28499 break;
28500 case 5:
28501 if (genRand.Next(2) == 0)
28502 {
28503 Place4x2(num7, j, 79, 1, num10);
28504 }
28505 else
28506 {
28507 Place4x2(num7, j, 79, -1, num10);
28508 }
28509 break;
28510 case 6:
28511 PlaceTile(num7, j, 87, mute: true, forced: false, -1, num11);
28512 break;
28513 case 7:
28514 PlaceTile(num7, j, 88, mute: true, forced: false, -1, num12);
28515 break;
28516 case 8:
28517 PlaceTile(num7, j, 89, mute: true, forced: false, -1, num13);
28518 break;
28519 case 9:
28520 if (genRand.Next(2) == 0)
28521 {
28522 Place4x2(num7, j, 90, 1, num14);
28523 }
28524 else
28525 {
28526 Place4x2(num7, j, 90, -1, num14);
28527 }
28528 break;
28529 case 10:
28530 PlaceTile(num7, j, 93, mute: true, forced: false, -1, num16);
28531 break;
28532 case 11:
28533 PlaceTile(num7, j, 100, mute: true, forced: false, -1, num15);
28534 break;
28535 case 12:
28536 PlaceTile(num7, j, 104, mute: true, forced: false, -1, num17);
28537 break;
28538 }
28539 }
28540 return num;
28541 }
28542
28544 {
28545 int num = genRand.Next(2);
28546 int num2 = 0;
28547 switch (num)
28548 {
28549 case 0:
28550 num = 240;
28551 num2 = genRand.Next(2);
28552 switch (num2)
28553 {
28554 case 0:
28555 num2 = 16;
28556 break;
28557 case 1:
28558 num2 = 17;
28559 break;
28560 }
28561 break;
28562 case 1:
28563 num = 241;
28564 num2 = genRand.Next(9);
28565 break;
28566 }
28567 PaintingEntry result = default(PaintingEntry);
28568 result.tileType = num;
28569 result.style = num2;
28570 return result;
28571 }
28572
28574 {
28575 int num = genRand.Next(4);
28576 int num2 = 0;
28577 if (num == 1)
28578 {
28579 num = genRand.Next(4);
28580 }
28581 switch (num)
28582 {
28583 case 0:
28584 num = 240;
28585 num2 = genRand.Next(5);
28586 switch (num2)
28587 {
28588 case 0:
28589 num2 = 27;
28590 break;
28591 case 1:
28592 num2 = 29;
28593 break;
28594 case 2:
28595 num2 = 30;
28596 break;
28597 case 3:
28598 num2 = 31;
28599 break;
28600 case 4:
28601 num2 = 32;
28602 break;
28603 }
28604 break;
28605 case 1:
28606 num = 242;
28607 num2 = 14;
28608 break;
28609 case 2:
28610 num = 245;
28611 num2 = genRand.Next(3);
28612 switch (num2)
28613 {
28614 case 0:
28615 num2 = 1;
28616 break;
28617 case 1:
28618 num2 = 2;
28619 break;
28620 case 2:
28621 num2 = 4;
28622 break;
28623 }
28624 break;
28625 default:
28626 num = 246;
28627 num2 = genRand.Next(3);
28628 switch (num2)
28629 {
28630 case 0:
28631 num2 = 0;
28632 break;
28633 case 1:
28634 num2 = 16;
28635 break;
28636 case 2:
28637 num2 = 17;
28638 break;
28639 }
28640 break;
28641 }
28642 PaintingEntry result = default(PaintingEntry);
28643 result.tileType = num;
28644 result.style = num2;
28645 return result;
28646 }
28647
28649 {
28650 int num = genRand.Next(4);
28651 int num2 = 0;
28652 if (num <= 1)
28653 {
28654 num = 240;
28655 int maxValue = 6;
28656 num2 = 63 + genRand.Next(maxValue);
28657 }
28658 else if (num == 2)
28659 {
28660 num = 245;
28661 int maxValue2 = 2;
28662 num2 = 7 + genRand.Next(maxValue2);
28663 }
28664 else
28665 {
28666 num = 242;
28667 int maxValue3 = 6;
28668 num2 = 37 + genRand.Next(maxValue3);
28669 }
28670 PaintingEntry result = default(PaintingEntry);
28671 result.tileType = num;
28672 result.style = num2;
28673 return result;
28674 }
28675
28677 {
28678 int num = genRand.Next(4);
28679 int num2 = 0;
28680 if (num >= 3 && genRand.Next(2) != 0)
28681 {
28682 num = genRand.Next(3);
28683 }
28684 if (num <= 1)
28685 {
28686 num = 240;
28687 int maxValue = 15;
28688 num2 = genRand.Next(maxValue);
28689 switch (num2)
28690 {
28691 case 0:
28692 num2 = 26;
28693 break;
28694 case 1:
28695 num2 = 28;
28696 break;
28697 case 2:
28698 num2 = 20;
28699 break;
28700 case 3:
28701 num2 = 21;
28702 break;
28703 case 4:
28704 num2 = 22;
28705 break;
28706 case 5:
28707 num2 = 24;
28708 break;
28709 case 6:
28710 num2 = 25;
28711 break;
28712 case 7:
28713 num2 = 33;
28714 break;
28715 case 8:
28716 num2 = 34;
28717 break;
28718 case 9:
28719 num2 = 35;
28720 break;
28721 case 10:
28722 num2 = 76;
28723 break;
28724 case 11:
28725 num2 = 77;
28726 break;
28727 case 12:
28728 num2 = 78;
28729 break;
28730 case 13:
28731 num2 = 79;
28732 break;
28733 case 14:
28734 num2 = 82;
28735 break;
28736 }
28737 }
28738 else if (num == 2)
28739 {
28740 int maxValue2 = 9;
28741 num = 245;
28742 num2 = genRand.Next(maxValue2);
28743 if (num2 == 0 && genRand.Next(3) != 0)
28744 {
28745 num2 = genRand.Next(maxValue2);
28746 }
28747 switch (num2)
28748 {
28749 case 0:
28750 num2 = 0;
28751 break;
28752 case 1:
28753 num2 = 3;
28754 break;
28755 case 2:
28756 num2 = 5;
28757 break;
28758 case 3:
28759 num2 = 6;
28760 break;
28761 case 4:
28762 num2 = 14;
28763 break;
28764 case 5:
28765 {
28766 int num3 = genRand.Next(4);
28767 if (num3 == 0)
28768 {
28769 num2 = 15;
28770 }
28771 if (num3 == 1)
28772 {
28773 num2 = 16;
28774 }
28775 if (num3 == 2)
28776 {
28777 num2 = 17;
28778 }
28779 if (num3 == 3)
28780 {
28781 num2 = 18;
28782 }
28783 break;
28784 }
28785 case 6:
28786 num2 = 19;
28787 break;
28788 case 7:
28789 num2 = 20;
28790 break;
28791 case 8:
28792 num2 = 21;
28793 break;
28794 }
28795 }
28796 else
28797 {
28798 num = 246;
28799 int maxValue3 = 8;
28800 num2 = genRand.Next(maxValue3);
28801 switch (num2)
28802 {
28803 case 0:
28804 num2 = 1;
28805 break;
28806 case 1:
28807 num2 = 30;
28808 break;
28809 case 2:
28810 num2 = 31;
28811 break;
28812 case 3:
28813 num2 = 32;
28814 break;
28815 case 4:
28816 num2 = 33;
28817 break;
28818 case 5:
28819 num2 = 34;
28820 break;
28821 case 6:
28822 num2 = 35;
28823 break;
28824 case 7:
28825 num2 = 36;
28826 break;
28827 }
28828 }
28829 PaintingEntry result = default(PaintingEntry);
28830 result.tileType = num;
28831 result.style = num2;
28832 return result;
28833 }
28834
28836 {
28837 int num = genRand.Next(3);
28838 int num2 = 0;
28839 if (num <= 1)
28840 {
28841 int maxValue = 7;
28842 num = 240;
28843 num2 = genRand.Next(maxValue);
28844 if (num2 == 6)
28845 {
28846 num2 = genRand.Next(maxValue);
28847 }
28848 switch (num2)
28849 {
28850 case 0:
28851 num2 = 12;
28852 break;
28853 case 1:
28854 num2 = 13;
28855 break;
28856 case 2:
28857 num2 = 14;
28858 break;
28859 case 3:
28860 num2 = 15;
28861 break;
28862 case 4:
28863 num2 = 18;
28864 break;
28865 case 5:
28866 num2 = 19;
28867 break;
28868 case 6:
28869 num2 = 23;
28870 break;
28871 }
28872 }
28873 else if (num == 2)
28874 {
28875 num = 242;
28876 int maxValue2 = 17;
28877 num2 = genRand.Next(maxValue2);
28878 switch (num2)
28879 {
28880 case 14:
28881 num2 = 15;
28882 break;
28883 case 15:
28884 num2 = 16;
28885 break;
28886 case 16:
28887 num2 = 30;
28888 break;
28889 }
28890 }
28891 PaintingEntry result = default(PaintingEntry);
28892 result.tileType = num;
28893 result.style = num2;
28894 return result;
28895 }
28896
28897 public static void DungeonStairs(int i, int j, ushort tileType, int wallType)
28898 {
28899 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
28900 //IL_0005: Unknown result type (might be due to invalid IL or missing references)
28901 //IL_0124: Unknown result type (might be due to invalid IL or missing references)
28902 //IL_0164: Unknown result type (might be due to invalid IL or missing references)
28903 //IL_0135: Unknown result type (might be due to invalid IL or missing references)
28904 //IL_0175: Unknown result type (might be due to invalid IL or missing references)
28905 //IL_01c5: Unknown result type (might be due to invalid IL or missing references)
28906 //IL_01e7: Unknown result type (might be due to invalid IL or missing references)
28907 //IL_020a: Unknown result type (might be due to invalid IL or missing references)
28908 //IL_021f: Unknown result type (might be due to invalid IL or missing references)
28909 //IL_05b9: Unknown result type (might be due to invalid IL or missing references)
28910 //IL_05c5: Unknown result type (might be due to invalid IL or missing references)
28911 //IL_0271: Unknown result type (might be due to invalid IL or missing references)
28912 //IL_0284: Unknown result type (might be due to invalid IL or missing references)
28913 //IL_02bf: Unknown result type (might be due to invalid IL or missing references)
28914 //IL_02e0: Unknown result type (might be due to invalid IL or missing references)
28915 //IL_030e: Unknown result type (might be due to invalid IL or missing references)
28916 //IL_033c: Unknown result type (might be due to invalid IL or missing references)
28917 //IL_0368: Unknown result type (might be due to invalid IL or missing references)
28918 //IL_04ab: Unknown result type (might be due to invalid IL or missing references)
28919 //IL_04c4: Unknown result type (might be due to invalid IL or missing references)
28920 //IL_04de: Unknown result type (might be due to invalid IL or missing references)
28921 //IL_04f7: Unknown result type (might be due to invalid IL or missing references)
28922 //IL_0588: Unknown result type (might be due to invalid IL or missing references)
28923 //IL_0589: Unknown result type (might be due to invalid IL or missing references)
28924 //IL_058a: Unknown result type (might be due to invalid IL or missing references)
28925 //IL_058f: Unknown result type (might be due to invalid IL or missing references)
28926 //IL_0590: Unknown result type (might be due to invalid IL or missing references)
28928 double num = genRand.Next(5, 9);
28929 int num2 = 1;
28930 Vector2D val = default(Vector2D);
28931 val.X = i;
28932 val.Y = j;
28933 int num3 = genRand.Next(10, 30);
28934 num2 = ((i <= GenVars.dEnteranceX) ? 1 : (-1));
28935 if (i > Main.maxTilesX - 400)
28936 {
28937 num2 = -1;
28938 }
28939 else if (i < 400)
28940 {
28941 num2 = 1;
28942 }
28943 zero.Y = -1.0;
28944 zero.X = num2;
28945 if (genRand.Next(3) != 0)
28946 {
28947 zero.X *= 1.0 + (double)genRand.Next(0, 200) * 0.01;
28948 }
28949 else if (genRand.Next(3) == 0)
28950 {
28951 zero.X *= (double)genRand.Next(50, 76) * 0.01;
28952 }
28953 else if (genRand.Next(6) == 0)
28954 {
28955 zero.Y *= 2.0;
28956 }
28957 if (GenVars.dungeonX < Main.maxTilesX / 2 && zero.X < 0.0 && zero.X < 0.5)
28958 {
28959 zero.X = -0.5;
28960 }
28961 if (GenVars.dungeonX > Main.maxTilesX / 2 && zero.X > 0.0 && zero.X > 0.5)
28962 {
28963 zero.X = -0.5;
28964 }
28965 if (drunkWorldGen)
28966 {
28967 num2 *= -1;
28968 zero.X *= -1.0;
28969 }
28970 while (num3 > 0)
28971 {
28972 num3--;
28973 int num4 = (int)(val.X - num - 4.0 - (double)genRand.Next(6));
28974 int num5 = (int)(val.X + num + 4.0 + (double)genRand.Next(6));
28975 int num6 = (int)(val.Y - num - 4.0);
28976 int num7 = (int)(val.Y + num + 4.0 + (double)genRand.Next(6));
28977 if (num4 < 0)
28978 {
28979 num4 = 0;
28980 }
28981 if (num5 > Main.maxTilesX)
28982 {
28984 }
28985 if (num6 < 0)
28986 {
28987 num6 = 0;
28988 }
28989 if (num7 > Main.maxTilesY)
28990 {
28992 }
28993 int num8 = 1;
28994 if (val.X > (double)(Main.maxTilesX / 2))
28995 {
28996 num8 = -1;
28997 }
28998 int num9 = (int)(val.X + GenVars.dxStrength1 * 0.6 * (double)num8 + GenVars.dxStrength2 * (double)num8);
28999 int num10 = (int)(GenVars.dyStrength2 * 0.5);
29000 if (val.Y < Main.worldSurface - 5.0 && Main.tile[num9, (int)(val.Y - num - 6.0 + (double)num10)].wall == 0 && Main.tile[num9, (int)(val.Y - num - 7.0 + (double)num10)].wall == 0 && Main.tile[num9, (int)(val.Y - num - 8.0 + (double)num10)].wall == 0)
29001 {
29002 GenVars.dSurface = true;
29003 TileRunner(num9, (int)(val.Y - num - 6.0 + (double)num10), genRand.Next(25, 35), genRand.Next(10, 20), -1, addTile: false, 0.0, -1.0);
29004 }
29005 for (int k = num4; k < num5; k++)
29006 {
29007 for (int l = num6; l < num7; l++)
29008 {
29009 Main.tile[k, l].liquid = 0;
29010 if (!Main.wallDungeon[Main.tile[k, l].wall])
29011 {
29012 Main.tile[k, l].wall = 0;
29013 Main.tile[k, l].active(active: true);
29014 Main.tile[k, l].type = tileType;
29015 }
29016 }
29017 }
29018 for (int m = num4 + 1; m < num5 - 1; m++)
29019 {
29020 for (int n = num6 + 1; n < num7 - 1; n++)
29021 {
29022 Main.tile[m, n].wall = (ushort)wallType;
29023 }
29024 }
29025 int num11 = 0;
29026 if (genRand.Next((int)num) == 0)
29027 {
29028 num11 = genRand.Next(1, 3);
29029 }
29030 num4 = (int)(val.X - num * 0.5 - (double)num11);
29031 num5 = (int)(val.X + num * 0.5 + (double)num11);
29032 num6 = (int)(val.Y - num * 0.5 - (double)num11);
29033 num7 = (int)(val.Y + num * 0.5 + (double)num11);
29034 if (num4 < 0)
29035 {
29036 num4 = 0;
29037 }
29038 if (num5 > Main.maxTilesX)
29039 {
29041 }
29042 if (num6 < 0)
29043 {
29044 num6 = 0;
29045 }
29046 if (num7 > Main.maxTilesY)
29047 {
29049 }
29050 for (int num12 = num4; num12 < num5; num12++)
29051 {
29052 for (int num13 = num6; num13 < num7; num13++)
29053 {
29054 Main.tile[num12, num13].active(active: false);
29055 PlaceWall(num12, num13, wallType, mute: true);
29056 }
29057 }
29058 if (GenVars.dSurface)
29059 {
29060 num3 = 0;
29061 }
29062 val += zero;
29063 if (val.Y < Main.worldSurface)
29064 {
29065 zero.Y *= 0.98;
29066 }
29067 }
29068 GenVars.dungeonX = (int)val.X;
29069 GenVars.dungeonY = (int)val.Y;
29070 }
29071
29072 public static bool PlaceSandTrap(int i, int j)
29073 {
29074 int num = 6;
29075 int num2 = 4;
29076 int num3 = 25;
29077 int k;
29078 for (k = j; !Main.tile[i, k].active() && k < Main.UnderworldLayer; k++)
29079 {
29080 }
29081 if (!Main.tileSolid[Main.tile[i, k].type] || Main.tile[i, k].halfBrick() || Main.tile[i, k].topSlope())
29082 {
29083 return false;
29084 }
29085 if ((Main.tile[i, k].type != 53 && Main.tile[i, k].type != 397 && Main.tile[i, k].type != 396) || (Main.tile[i, k].wall != 216 && Main.tile[i, k].wall != 187))
29086 {
29087 return false;
29088 }
29089 k--;
29090 int num4 = -1;
29091 int num5 = genRand.Next(6, 12);
29092 int num6 = genRand.Next(6, 14);
29093 for (int l = i - num3; l <= i + num3; l++)
29094 {
29095 for (int m = k - num3; m < k + num3; m++)
29096 {
29097 if (Main.tile[l, m].wire())
29098 {
29099 return false;
29100 }
29101 if (TileID.Sets.BasicChest[Main.tile[l, m].type])
29102 {
29103 return false;
29104 }
29105 if (TileID.Sets.Paintings[Main.tile[l, m].type])
29106 {
29107 return false;
29108 }
29109 if (Main.tile[l, m].type == 10)
29110 {
29111 return false;
29112 }
29113 if (Main.tile[l, m].type == 19)
29114 {
29115 return false;
29116 }
29117 if (Main.tile[l, m].type == 15)
29118 {
29119 return false;
29120 }
29121 if (Main.tile[l, m].type == 219)
29122 {
29123 return false;
29124 }
29125 }
29126 }
29127 for (int n = i - 2; n <= i + 2; n++)
29128 {
29129 for (int num7 = k + 1; num7 <= k + 3; num7++)
29130 {
29131 if (!Main.tile[n, num7].active() || !Main.tileSolid[Main.tile[n, num7].type])
29132 {
29133 return false;
29134 }
29135 }
29136 }
29137 if (Main.tile[i, k + 1].type == 162)
29138 {
29139 return false;
29140 }
29141 for (int num8 = k; num8 > k - 30; num8--)
29142 {
29143 if (Main.tile[i, num8].active())
29144 {
29145 if (Main.tile[i, num8].type == 396)
29146 {
29147 num4 = num8;
29148 break;
29149 }
29150 return false;
29151 }
29152 }
29153 if (num4 <= -1)
29154 {
29155 return false;
29156 }
29157 if (k - num4 < num6 + num2)
29158 {
29159 return false;
29160 }
29161 int num9 = 0;
29162 int num10 = (k + num4) / 2;
29163 for (int num11 = i - num5; num11 <= i + num5; num11++)
29164 {
29165 if (Main.tile[num11, num10].active() && Main.tileSolid[Main.tile[num11, num10].type])
29166 {
29167 return false;
29168 }
29169 for (int num12 = num4 - num6; num12 <= num4; num12++)
29170 {
29171 if (Main.tile[num11, num12].active())
29172 {
29173 if (TileID.Sets.Ore[Main.tile[num11, num12].type] || Main.tile[num11, num12].type == 404)
29174 {
29175 return false;
29176 }
29177 if (Main.tileSolid[Main.tile[num11, num12].type])
29178 {
29179 num9++;
29180 }
29181 }
29182 }
29183 }
29184 double num13 = (double)((num5 * 2 + 1) * (num6 + 1)) * 0.75;
29185 if ((double)num9 < num13)
29186 {
29187 return false;
29188 }
29189 for (int num14 = i - num5 - 1; num14 <= i + num5 + 1; num14++)
29190 {
29191 for (int num15 = num4 - num6; num15 <= num4; num15++)
29192 {
29193 bool flag = false;
29194 if (Main.tile[num14, num15].active() && Main.tileSolid[Main.tile[num14, num15].type])
29195 {
29196 flag = true;
29197 }
29198 if (num15 == num4)
29199 {
29200 Main.tile[num14, num15].slope(0);
29201 Main.tile[num14, num15].halfBrick(halfBrick: false);
29202 if (!flag)
29203 {
29204 Main.tile[num14, num15].active(active: true);
29205 Main.tile[num14, num15].type = 396;
29206 }
29207 }
29208 else if (num15 == num4 - num6)
29209 {
29210 Main.tile[num14, num15].ClearTile();
29211 Main.tile[num14, num15].active(active: true);
29212 if (flag && Main.tile[num14, num15 - 1].active() && Main.tileSolid[Main.tile[num14, num15 - 1].type])
29213 {
29214 Main.tile[num14, num15].type = 397;
29215 }
29216 else
29217 {
29218 Main.tile[num14, num15].type = 396;
29219 }
29220 }
29221 else if (num14 == i - num5 - 1 || num14 == i + num5 + 1)
29222 {
29223 if (!flag)
29224 {
29225 Main.tile[num14, num15].ClearTile();
29226 Main.tile[num14, num15].active(active: true);
29227 Main.tile[num14, num15].type = 396;
29228 }
29229 else
29230 {
29231 Main.tile[num14, num15].slope(0);
29232 Main.tile[num14, num15].halfBrick(halfBrick: false);
29233 }
29234 }
29235 else
29236 {
29237 Main.tile[num14, num15].ClearTile();
29238 Main.tile[num14, num15].active(active: true);
29239 Main.tile[num14, num15].type = 53;
29240 }
29241 }
29242 }
29243 for (int num16 = (int)((double)num4 - (double)num6 * 0.666); (double)num16 <= (double)num4 - (double)num6 * 0.333; num16++)
29244 {
29245 if ((double)num16 < (double)num4 - (double)num6 * 0.4)
29246 {
29247 if (Main.tile[i - num5 - 2, num16].bottomSlope())
29248 {
29249 Main.tile[i - num5 - 2, num16].slope(0);
29250 }
29251 }
29252 else if ((double)num16 > (double)num4 - (double)num6 * 0.6)
29253 {
29254 if (Main.tile[i - num5 - 2, num16].topSlope())
29255 {
29256 Main.tile[i - num5 - 2, num16].slope(0);
29257 }
29258 Main.tile[i - num5 - 2, num16].halfBrick(halfBrick: false);
29259 }
29260 else
29261 {
29262 Main.tile[i - num5 - 2, num16].halfBrick(halfBrick: false);
29263 Main.tile[i - num5 - 2, num16].slope(0);
29264 }
29265 if (!Main.tile[i - num5 - 2, num16].active() || !Main.tileSolid[Main.tile[i - num5 - 2, num16].type])
29266 {
29267 Main.tile[i - num5 - 2, num16].active(active: true);
29268 Main.tile[i - num5 - 2, num16].type = 396;
29269 }
29270 if (!Main.tile[i + num5 + 2, num16].active() || !Main.tileSolid[Main.tile[i + num5 + 2, num16].type])
29271 {
29272 Main.tile[i + num5 + 2, num16].active(active: true);
29273 Main.tile[i + num5 + 2, num16].type = 396;
29274 }
29275 }
29276 for (int num17 = num4 - num6; num17 <= num4; num17++)
29277 {
29278 Main.tile[i - num5 - 2, num17].slope(0);
29279 Main.tile[i - num5 - 2, num17].halfBrick(halfBrick: false);
29280 Main.tile[i - num5 - 1, num17].slope(0);
29281 Main.tile[i - num5 - 1, num17].halfBrick(halfBrick: false);
29282 Main.tile[i - num5 + 1, num17].slope(0);
29283 Main.tile[i - num5 + 1, num17].halfBrick(halfBrick: false);
29284 Main.tile[i - num5 + 2, num17].slope(0);
29285 Main.tile[i - num5 + 2, num17].halfBrick(halfBrick: false);
29286 }
29287 for (int num18 = i - num5 - 1; num18 < i + num5 + 1; num18++)
29288 {
29289 int num19 = k - num6 - 1;
29290 if (Main.tile[num18, num19].bottomSlope())
29291 {
29292 Main.tile[num18, num19].slope(0);
29293 }
29294 Main.tile[num18, num19].halfBrick(halfBrick: false);
29295 }
29296 KillTile(i - 2, k);
29297 KillTile(i - 1, k);
29298 KillTile(i + 1, k);
29299 KillTile(i + 2, k);
29300 PlaceTile(i, k, 135, mute: true, forced: false, -1, 7);
29301 for (int num20 = i - num5; num20 <= i + num5; num20++)
29302 {
29303 int num21 = k;
29304 if ((double)num20 < (double)i - (double)num5 * 0.8 || (double)num20 > (double)i + (double)num5 * 0.8)
29305 {
29306 num21 = k - 3;
29307 }
29308 else if ((double)num20 < (double)i - (double)num5 * 0.6 || (double)num20 > (double)i + (double)num5 * 0.6)
29309 {
29310 num21 = k - 2;
29311 }
29312 else if ((double)num20 < (double)i - (double)num5 * 0.4 || (double)num20 > (double)i + (double)num5 * 0.4)
29313 {
29314 num21 = k - 1;
29315 }
29316 for (int num22 = num4; num22 <= k; num22++)
29317 {
29318 if (num20 == i && num22 <= k)
29319 {
29320 Main.tile[i, num22].wire(wire: true);
29321 }
29322 if (Main.tile[num20, num22].active() && Main.tileSolid[Main.tile[num20, num22].type])
29323 {
29324 if (num22 < num4 + num - 4)
29325 {
29326 Main.tile[num20, num22].actuator(actuator: true);
29327 Main.tile[num20, num22].wire(wire: true);
29328 }
29329 else if (num22 < num21)
29330 {
29331 KillTile(num20, num22);
29332 }
29333 }
29334 }
29335 }
29336 return true;
29337 }
29338
29339 public static bool DungeonPitTrap(int i, int j, ushort tileType, int wallType)
29340 {
29341 int num = 30;
29342 int num2 = j;
29343 int num3 = num2;
29344 int num4 = genRand.Next(8, 19);
29345 int num5 = genRand.Next(19, 46);
29346 int num6 = num4 + genRand.Next(6, 10);
29347 int num7 = num5 + genRand.Next(6, 10);
29348 if (!Main.wallDungeon[Main.tile[i, num2].wall])
29349 {
29350 return false;
29351 }
29352 if (Main.tile[i, num2].active())
29353 {
29354 return false;
29355 }
29356 for (int k = num2; k < Main.maxTilesY; k++)
29357 {
29358 if (k > Main.maxTilesY - 300)
29359 {
29360 return false;
29361 }
29362 if (Main.tile[i, k].active() && SolidTile(i, k))
29363 {
29364 if (Main.tile[i, k].type == 48)
29365 {
29366 return false;
29367 }
29368 num2 = k;
29369 break;
29370 }
29371 }
29372 if (!Main.wallDungeon[Main.tile[i - num4, num2].wall] || !Main.wallDungeon[Main.tile[i + num4, num2].wall])
29373 {
29374 return false;
29375 }
29376 bool flag = true;
29377 for (int l = num2; l < num2 + num; l++)
29378 {
29379 flag = true;
29380 for (int m = i - num4; m <= i + num4; m++)
29381 {
29382 Tile tile = Main.tile[m, l];
29383 if (tile.active() && Main.tileDungeon[tile.type])
29384 {
29385 flag = false;
29386 }
29387 }
29388 if (flag)
29389 {
29390 num2 = l;
29391 break;
29392 }
29393 }
29394 for (int n = i - num4; n <= i + num4; n++)
29395 {
29396 for (int num8 = num2; num8 <= num2 + num5; num8++)
29397 {
29398 Tile tile2 = Main.tile[n, num8];
29399 if (tile2.active() && (Main.tileDungeon[tile2.type] || tile2.type == GenVars.crackedType))
29400 {
29401 return false;
29402 }
29403 }
29404 }
29405 bool flag2 = false;
29406 if (GenVars.dungeonLake)
29407 {
29408 flag2 = true;
29409 GenVars.dungeonLake = false;
29410 }
29411 else if (genRand.Next(8) == 0)
29412 {
29413 flag2 = true;
29414 }
29415 for (int num9 = i - num4; num9 <= i + num4; num9++)
29416 {
29417 for (int num10 = num3; num10 <= num2 + num5; num10++)
29418 {
29419 if (Main.tileDungeon[Main.tile[num9, num10].type])
29420 {
29422 Main.tile[num9, num10].wall = (ushort)wallType;
29423 }
29424 }
29425 }
29426 for (int num11 = i - num6; num11 <= i + num6; num11++)
29427 {
29428 for (int num12 = num3; num12 <= num2 + num7; num12++)
29429 {
29430 Main.tile[num11, num12].lava(lava: false);
29431 Main.tile[num11, num12].liquid = 0;
29433 {
29434 Main.tile[num11, num12].Clear(TileDataType.Slope);
29435 Main.tile[num11, num12].type = tileType;
29436 Main.tile[num11, num12].active(active: true);
29437 if (num11 > i - num6 && num11 < i + num6 && num12 < num2 + num7)
29438 {
29439 Main.tile[num11, num12].wall = (ushort)wallType;
29440 }
29441 }
29442 }
29443 }
29444 for (int num13 = i - num4; num13 <= i + num4; num13++)
29445 {
29446 for (int num14 = num3; num14 <= num2 + num5; num14++)
29447 {
29448 if (Main.tile[num13, num14].type != GenVars.crackedType)
29449 {
29450 if (flag2)
29451 {
29452 Main.tile[num13, num14].liquid = byte.MaxValue;
29453 }
29454 if (num13 == i - num4 || num13 == i + num4 || num14 == num2 + num5)
29455 {
29456 Main.tile[num13, num14].type = 48;
29457 }
29458 else if ((num13 == i - num4 + 1 && num14 % 2 == 0) || (num13 == i + num4 - 1 && num14 % 2 == 0) || (num14 == num2 + num5 - 1 && num13 % 2 == 0))
29459 {
29460 Main.tile[num13, num14].type = 48;
29461 }
29462 else
29463 {
29464 Main.tile[num13, num14].active(active: false);
29465 }
29466 }
29467 }
29468 }
29469 return true;
29470 }
29471
29472 public static void DungeonHalls(int i, int j, ushort tileType, int wallType, bool forceX = false)
29473 {
29474 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
29475 //IL_0005: Unknown result type (might be due to invalid IL or missing references)
29476 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
29477 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
29478 //IL_0020: Unknown result type (might be due to invalid IL or missing references)
29479 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
29480 //IL_006a: Unknown result type (might be due to invalid IL or missing references)
29481 //IL_006f: Unknown result type (might be due to invalid IL or missing references)
29482 //IL_0467: Unknown result type (might be due to invalid IL or missing references)
29483 //IL_0487: Unknown result type (might be due to invalid IL or missing references)
29484 //IL_08ee: Unknown result type (might be due to invalid IL or missing references)
29485 //IL_04a7: Unknown result type (might be due to invalid IL or missing references)
29486 //IL_0948: Unknown result type (might be due to invalid IL or missing references)
29487 //IL_095a: Unknown result type (might be due to invalid IL or missing references)
29488 //IL_090a: Unknown result type (might be due to invalid IL or missing references)
29489 //IL_091c: Unknown result type (might be due to invalid IL or missing references)
29490 //IL_0539: Unknown result type (might be due to invalid IL or missing references)
29491 //IL_096e: Unknown result type (might be due to invalid IL or missing references)
29492 //IL_0970: Unknown result type (might be due to invalid IL or missing references)
29493 //IL_0975: Unknown result type (might be due to invalid IL or missing references)
29494 //IL_0980: Unknown result type (might be due to invalid IL or missing references)
29495 //IL_05c8: Unknown result type (might be due to invalid IL or missing references)
29496 //IL_09ce: Unknown result type (might be due to invalid IL or missing references)
29497 //IL_0ebb: Unknown result type (might be due to invalid IL or missing references)
29498 //IL_0ec7: Unknown result type (might be due to invalid IL or missing references)
29499 //IL_0ed3: Unknown result type (might be due to invalid IL or missing references)
29500 //IL_07a7: Unknown result type (might be due to invalid IL or missing references)
29501 //IL_044c: Unknown result type (might be due to invalid IL or missing references)
29502 //IL_0451: Unknown result type (might be due to invalid IL or missing references)
29503 //IL_09f9: Unknown result type (might be due to invalid IL or missing references)
29504 //IL_09e0: Unknown result type (might be due to invalid IL or missing references)
29505 //IL_0f2c: Unknown result type (might be due to invalid IL or missing references)
29506 //IL_0f3e: Unknown result type (might be due to invalid IL or missing references)
29507 //IL_0eef: Unknown result type (might be due to invalid IL or missing references)
29508 //IL_0f01: Unknown result type (might be due to invalid IL or missing references)
29509 //IL_0850: Unknown result type (might be due to invalid IL or missing references)
29510 //IL_07ba: Unknown result type (might be due to invalid IL or missing references)
29511 //IL_0a24: Unknown result type (might be due to invalid IL or missing references)
29512 //IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
29513 //IL_0863: Unknown result type (might be due to invalid IL or missing references)
29514 //IL_0a36: Unknown result type (might be due to invalid IL or missing references)
29515 //IL_0ac0: Unknown result type (might be due to invalid IL or missing references)
29516 //IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
29517 //IL_0b05: Unknown result type (might be due to invalid IL or missing references)
29518 //IL_0b27: Unknown result type (might be due to invalid IL or missing references)
29519 //IL_0a53: Unknown result type (might be due to invalid IL or missing references)
29520 //IL_0a8e: Unknown result type (might be due to invalid IL or missing references)
29521 //IL_0a65: Unknown result type (might be due to invalid IL or missing references)
29522 //IL_0aa0: Unknown result type (might be due to invalid IL or missing references)
29523 //IL_0c85: Unknown result type (might be due to invalid IL or missing references)
29524 //IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
29525 //IL_0d08: Unknown result type (might be due to invalid IL or missing references)
29526 //IL_0d21: Unknown result type (might be due to invalid IL or missing references)
29527 //IL_0d3b: Unknown result type (might be due to invalid IL or missing references)
29528 //IL_0d54: Unknown result type (might be due to invalid IL or missing references)
29529 //IL_0e7e: Unknown result type (might be due to invalid IL or missing references)
29530 //IL_0e7f: Unknown result type (might be due to invalid IL or missing references)
29531 //IL_0e80: Unknown result type (might be due to invalid IL or missing references)
29532 //IL_0e85: Unknown result type (might be due to invalid IL or missing references)
29534 double num = genRand.Next(4, 6);
29535 double num2 = num;
29538 int num3 = 1;
29539 Vector2D val = default(Vector2D);
29540 val.X = i;
29541 val.Y = j;
29542 int num4 = genRand.Next(35, 80);
29543 bool flag = false;
29544 if (genRand.Next(6) == 0)
29545 {
29546 flag = true;
29547 }
29548 if (forceX)
29549 {
29550 num4 += 20;
29551 GenVars.lastDungeonHall = Vector2D.Zero;
29552 }
29553 else if (genRand.Next(5) == 0)
29554 {
29555 num *= 2.0;
29556 num4 /= 2;
29557 }
29558 bool flag2 = false;
29559 bool flag3 = false;
29560 bool flag4 = true;
29561 bool flag5 = false;
29562 while (!flag2)
29563 {
29564 flag5 = false;
29565 if (flag4 && !forceX)
29566 {
29567 bool flag6 = true;
29568 bool flag7 = true;
29569 bool flag8 = true;
29570 bool flag9 = true;
29571 int num5 = num4;
29572 bool flag10 = false;
29573 for (int num6 = j; num6 > j - num5; num6--)
29574 {
29575 if (Main.tile[i, num6].wall == wallType)
29576 {
29577 if (flag10)
29578 {
29579 flag6 = false;
29580 break;
29581 }
29582 }
29583 else
29584 {
29585 flag10 = true;
29586 }
29587 }
29588 flag10 = false;
29589 for (int k = j; k < j + num5; k++)
29590 {
29591 if (Main.tile[i, k].wall == wallType)
29592 {
29593 if (flag10)
29594 {
29595 flag7 = false;
29596 break;
29597 }
29598 }
29599 else
29600 {
29601 flag10 = true;
29602 }
29603 }
29604 flag10 = false;
29605 for (int num7 = i; num7 > i - num5; num7--)
29606 {
29607 if (Main.tile[num7, j].wall == wallType)
29608 {
29609 if (flag10)
29610 {
29611 flag8 = false;
29612 break;
29613 }
29614 }
29615 else
29616 {
29617 flag10 = true;
29618 }
29619 }
29620 flag10 = false;
29621 for (int l = i; l < i + num5; l++)
29622 {
29623 if (Main.tile[l, j].wall == wallType)
29624 {
29625 if (flag10)
29626 {
29627 flag9 = false;
29628 break;
29629 }
29630 }
29631 else
29632 {
29633 flag10 = true;
29634 }
29635 }
29636 if (!flag8 && !flag9 && !flag6 && !flag7)
29637 {
29638 num3 = ((genRand.Next(2) != 0) ? 1 : (-1));
29639 if (genRand.Next(2) == 0)
29640 {
29641 flag5 = true;
29642 }
29643 }
29644 else
29645 {
29646 int num8 = genRand.Next(4);
29647 do
29648 {
29649 num8 = genRand.Next(4);
29650 }
29651 while (!(num8 == 0 && flag6) && !(num8 == 1 && flag7) && !(num8 == 2 && flag8) && !(num8 == 3 && flag9));
29652 switch (num8)
29653 {
29654 case 0:
29655 num3 = -1;
29656 break;
29657 case 1:
29658 num3 = 1;
29659 break;
29660 default:
29661 flag5 = true;
29662 num3 = ((num8 != 2) ? 1 : (-1));
29663 break;
29664 }
29665 }
29666 }
29667 else
29668 {
29669 num3 = ((genRand.Next(2) != 0) ? 1 : (-1));
29670 if (genRand.Next(2) == 0)
29671 {
29672 flag5 = true;
29673 }
29674 }
29675 flag4 = false;
29676 if (forceX)
29677 {
29678 flag5 = true;
29679 }
29680 if (flag5)
29681 {
29682 zero2.Y = 0.0;
29683 zero2.X = num3;
29684 zero3.Y = 0.0;
29685 zero3.X = -num3;
29686 zero.Y = 0.0;
29687 zero.X = num3;
29688 if (genRand.Next(3) == 0)
29689 {
29690 if (genRand.Next(2) == 0)
29691 {
29692 zero.Y = -0.2;
29693 }
29694 else
29695 {
29696 zero.Y = 0.2;
29697 }
29698 }
29699 }
29700 else
29701 {
29702 num += 1.0;
29703 zero.Y = num3;
29704 zero.X = 0.0;
29705 zero2.X = 0.0;
29706 zero2.Y = num3;
29707 zero3.X = 0.0;
29708 zero3.Y = -num3;
29709 if (genRand.Next(3) != 0)
29710 {
29711 flag3 = true;
29712 if (genRand.Next(2) == 0)
29713 {
29714 zero.X = (double)genRand.Next(10, 20) * 0.1;
29715 }
29716 else
29717 {
29718 zero.X = (double)(-genRand.Next(10, 20)) * 0.1;
29719 }
29720 }
29721 else if (genRand.Next(2) == 0)
29722 {
29723 if (genRand.Next(2) == 0)
29724 {
29725 zero.X = (double)genRand.Next(20, 40) * 0.01;
29726 }
29727 else
29728 {
29729 zero.X = (double)(-genRand.Next(20, 40)) * 0.01;
29730 }
29731 }
29732 else
29733 {
29734 num4 /= 2;
29735 }
29736 }
29738 {
29739 flag2 = true;
29740 }
29741 }
29742 int num9 = 0;
29743 bool flag11 = val.Y < Main.rockLayer + 100.0;
29744 if (remixWorldGen)
29745 {
29746 flag11 = val.Y < Main.worldSurface + 100.0;
29747 }
29748 if (!forceX)
29749 {
29750 if (val.X > (double)(lastMaxTilesX - 200))
29751 {
29752 num3 = -1;
29753 zero2.Y = 0.0;
29754 zero2.X = num3;
29755 zero.Y = 0.0;
29756 zero.X = num3;
29757 if (genRand.Next(3) == 0)
29758 {
29759 if (genRand.Next(2) == 0)
29760 {
29761 zero.Y = -0.2;
29762 }
29763 else
29764 {
29765 zero.Y = 0.2;
29766 }
29767 }
29768 }
29769 else if (val.X < 200.0)
29770 {
29771 num3 = 1;
29772 zero2.Y = 0.0;
29773 zero2.X = num3;
29774 zero.Y = 0.0;
29775 zero.X = num3;
29776 if (genRand.Next(3) == 0)
29777 {
29778 if (genRand.Next(2) == 0)
29779 {
29780 zero.Y = -0.2;
29781 }
29782 else
29783 {
29784 zero.Y = 0.2;
29785 }
29786 }
29787 }
29788 else if (val.Y > (double)(lastMaxTilesY - 300))
29789 {
29790 num3 = -1;
29791 num += 1.0;
29792 zero.Y = num3;
29793 zero.X = 0.0;
29794 zero2.X = 0.0;
29795 zero2.Y = num3;
29796 if (genRand.Next(2) == 0)
29797 {
29798 if (genRand.Next(2) == 0)
29799 {
29800 zero.X = (double)genRand.Next(20, 50) * 0.01;
29801 }
29802 else
29803 {
29804 zero.X = (double)(-genRand.Next(20, 50)) * 0.01;
29805 }
29806 }
29807 }
29808 else if (flag11)
29809 {
29810 num3 = 1;
29811 num += 1.0;
29812 zero.Y = num3;
29813 zero.X = 0.0;
29814 zero2.X = 0.0;
29815 zero2.Y = num3;
29816 if (genRand.Next(3) != 0)
29817 {
29818 flag3 = true;
29819 if (genRand.Next(2) == 0)
29820 {
29821 zero.X = (double)genRand.Next(10, 20) * 0.1;
29822 }
29823 else
29824 {
29825 zero.X = (double)(-genRand.Next(10, 20)) * 0.1;
29826 }
29827 }
29828 else if (genRand.Next(2) == 0)
29829 {
29830 if (genRand.Next(2) == 0)
29831 {
29832 zero.X = (double)genRand.Next(20, 50) * 0.01;
29833 }
29834 else
29835 {
29836 zero.X = (double)genRand.Next(20, 50) * 0.01;
29837 }
29838 }
29839 }
29840 else if (val.X < (double)(Main.maxTilesX / 2) && val.X > (double)Main.maxTilesX * 0.25)
29841 {
29842 num3 = -1;
29843 zero2.Y = 0.0;
29844 zero2.X = num3;
29845 zero.Y = 0.0;
29846 zero.X = num3;
29847 if (genRand.Next(3) == 0)
29848 {
29849 if (genRand.Next(2) == 0)
29850 {
29851 zero.Y = -0.2;
29852 }
29853 else
29854 {
29855 zero.Y = 0.2;
29856 }
29857 }
29858 }
29859 else if (val.X > (double)(Main.maxTilesX / 2) && val.X < (double)Main.maxTilesX * 0.75)
29860 {
29861 num3 = 1;
29862 zero2.Y = 0.0;
29863 zero2.X = num3;
29864 zero.Y = 0.0;
29865 zero.X = num3;
29866 if (genRand.Next(3) == 0)
29867 {
29868 if (genRand.Next(2) == 0)
29869 {
29870 zero.Y = -0.2;
29871 }
29872 else
29873 {
29874 zero.Y = 0.2;
29875 }
29876 }
29877 }
29878 }
29879 if (zero2.Y == 0.0)
29880 {
29881 GenVars.DDoorX[GenVars.numDDoors] = (int)val.X;
29882 GenVars.DDoorY[GenVars.numDDoors] = (int)val.Y;
29885 }
29886 else
29887 {
29891 }
29892 GenVars.lastDungeonHall = zero2;
29893 if (Math.Abs(zero.X) > Math.Abs(zero.Y) && genRand.Next(3) != 0)
29894 {
29895 num = (int)(num2 * ((double)genRand.Next(110, 150) * 0.01));
29896 }
29897 while (num4 > 0)
29898 {
29899 num9++;
29900 if (zero2.X > 0.0 && val.X > (double)(Main.maxTilesX - 100))
29901 {
29902 num4 = 0;
29903 }
29904 else if (zero2.X < 0.0 && val.X < 100.0)
29905 {
29906 num4 = 0;
29907 }
29908 else if (zero2.Y > 0.0 && val.Y > (double)(Main.maxTilesY - 100))
29909 {
29910 num4 = 0;
29911 }
29912 else if (remixWorldGen && zero2.Y < 0.0 && val.Y < (Main.rockLayer + Main.worldSurface) / 2.0)
29913 {
29914 num4 = 0;
29915 }
29916 else if (!remixWorldGen && zero2.Y < 0.0 && val.Y < Main.rockLayer + 50.0)
29917 {
29918 num4 = 0;
29919 }
29920 num4--;
29921 int num10 = (int)(val.X - num - 4.0 - (double)genRand.Next(6));
29922 int num11 = (int)(val.X + num + 4.0 + (double)genRand.Next(6));
29923 int num12 = (int)(val.Y - num - 4.0 - (double)genRand.Next(6));
29924 int num13 = (int)(val.Y + num + 4.0 + (double)genRand.Next(6));
29925 if (num10 < 0)
29926 {
29927 num10 = 0;
29928 }
29929 if (num11 > Main.maxTilesX)
29930 {
29932 }
29933 if (num12 < 0)
29934 {
29935 num12 = 0;
29936 }
29937 if (num13 > Main.maxTilesY)
29938 {
29940 }
29941 for (int m = num10; m < num11; m++)
29942 {
29943 for (int n = num12; n < num13; n++)
29944 {
29945 if (m < GenVars.dMinX)
29946 {
29947 GenVars.dMinX = m;
29948 }
29949 if (m > GenVars.dMaxX)
29950 {
29951 GenVars.dMaxX = m;
29952 }
29953 if (n > GenVars.dMaxY)
29954 {
29955 GenVars.dMaxY = n;
29956 }
29957 Main.tile[m, n].liquid = 0;
29958 if (!Main.wallDungeon[Main.tile[m, n].wall])
29959 {
29960 Main.tile[m, n].active(active: true);
29961 Main.tile[m, n].type = tileType;
29962 Main.tile[m, n].Clear(TileDataType.Slope);
29963 }
29964 }
29965 }
29966 for (int num14 = num10 + 1; num14 < num11 - 1; num14++)
29967 {
29968 for (int num15 = num12 + 1; num15 < num13 - 1; num15++)
29969 {
29970 Main.tile[num14, num15].wall = (ushort)wallType;
29971 }
29972 }
29973 int num16 = 0;
29974 if (zero.Y == 0.0 && genRand.Next((int)num + 1) == 0)
29975 {
29976 num16 = genRand.Next(1, 3);
29977 }
29978 else if (zero.X == 0.0 && genRand.Next((int)num - 1) == 0)
29979 {
29980 num16 = genRand.Next(1, 3);
29981 }
29982 else if (genRand.Next((int)num * 3) == 0)
29983 {
29984 num16 = genRand.Next(1, 3);
29985 }
29986 num10 = (int)(val.X - num * 0.5 - (double)num16);
29987 num11 = (int)(val.X + num * 0.5 + (double)num16);
29988 num12 = (int)(val.Y - num * 0.5 - (double)num16);
29989 num13 = (int)(val.Y + num * 0.5 + (double)num16);
29990 if (num10 < 0)
29991 {
29992 num10 = 0;
29993 }
29994 if (num11 > Main.maxTilesX)
29995 {
29997 }
29998 if (num12 < 0)
29999 {
30000 num12 = 0;
30001 }
30002 if (num13 > Main.maxTilesY)
30003 {
30005 }
30006 for (int num17 = num10; num17 < num11; num17++)
30007 {
30008 for (int num18 = num12; num18 < num13; num18++)
30009 {
30010 Main.tile[num17, num18].Clear(TileDataType.Slope);
30011 if (flag)
30012 {
30013 if (Main.tile[num17, num18].active() || Main.tile[num17, num18].wall != wallType)
30014 {
30015 Main.tile[num17, num18].active(active: true);
30017 }
30018 }
30019 else
30020 {
30021 Main.tile[num17, num18].active(active: false);
30022 }
30023 Main.tile[num17, num18].Clear(TileDataType.Slope);
30024 Main.tile[num17, num18].wall = (ushort)wallType;
30025 }
30026 }
30027 val += zero;
30028 if (flag3 && num9 > genRand.Next(10, 20))
30029 {
30030 num9 = 0;
30031 zero.X *= -1.0;
30032 }
30033 }
30034 GenVars.dungeonX = (int)val.X;
30035 GenVars.dungeonY = (int)val.Y;
30036 if (zero2.Y == 0.0)
30037 {
30038 GenVars.DDoorX[GenVars.numDDoors] = (int)val.X;
30039 GenVars.DDoorY[GenVars.numDDoors] = (int)val.Y;
30042 }
30043 else
30044 {
30048 }
30049 }
30050
30051 public static void DungeonRoom(int i, int j, ushort tileType, int wallType)
30052 {
30053 //IL_0081: Unknown result type (might be due to invalid IL or missing references)
30054 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
30055 //IL_0091: Unknown result type (might be due to invalid IL or missing references)
30056 //IL_0099: Unknown result type (might be due to invalid IL or missing references)
30057 //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
30058 //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
30059 //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
30060 //IL_010a: Unknown result type (might be due to invalid IL or missing references)
30061 //IL_0441: Unknown result type (might be due to invalid IL or missing references)
30062 //IL_0453: Unknown result type (might be due to invalid IL or missing references)
30063 //IL_0262: Unknown result type (might be due to invalid IL or missing references)
30064 //IL_0277: Unknown result type (might be due to invalid IL or missing references)
30065 //IL_028d: Unknown result type (might be due to invalid IL or missing references)
30066 //IL_02a2: Unknown result type (might be due to invalid IL or missing references)
30067 //IL_035b: Unknown result type (might be due to invalid IL or missing references)
30068 //IL_035c: Unknown result type (might be due to invalid IL or missing references)
30069 //IL_035d: Unknown result type (might be due to invalid IL or missing references)
30070 //IL_0362: Unknown result type (might be due to invalid IL or missing references)
30071 //IL_03ab: Unknown result type (might be due to invalid IL or missing references)
30072 //IL_03cc: Unknown result type (might be due to invalid IL or missing references)
30073 //IL_03ed: Unknown result type (might be due to invalid IL or missing references)
30074 //IL_040e: Unknown result type (might be due to invalid IL or missing references)
30075 double num = genRand.Next(15, 30);
30076 Vector2D val = default(Vector2D);
30077 val.X = (double)genRand.Next(-10, 11) * 0.1;
30078 val.Y = (double)genRand.Next(-10, 11) * 0.1;
30079 Vector2D val2 = default(Vector2D);
30080 val2.X = i;
30081 val2.Y = (double)j - num / 2.0;
30082 int num2 = genRand.Next(10, 20);
30083 double num3 = val2.X;
30084 double num4 = val2.X;
30085 double num5 = val2.Y;
30086 double num6 = val2.Y;
30087 while (num2 > 0)
30088 {
30089 num2--;
30090 int num7 = (int)(val2.X - num * 0.8 - 5.0);
30091 int num8 = (int)(val2.X + num * 0.8 + 5.0);
30092 int num9 = (int)(val2.Y - num * 0.8 - 5.0);
30093 int num10 = (int)(val2.Y + num * 0.8 + 5.0);
30094 if (num7 < 0)
30095 {
30096 num7 = 0;
30097 }
30098 if (num8 > Main.maxTilesX)
30099 {
30101 }
30102 if (num9 < 0)
30103 {
30104 num9 = 0;
30105 }
30106 if (num10 > Main.maxTilesY)
30107 {
30109 }
30110 for (int k = num7; k < num8; k++)
30111 {
30112 for (int l = num9; l < num10; l++)
30113 {
30114 if (k < GenVars.dMinX)
30115 {
30116 GenVars.dMinX = k;
30117 }
30118 if (k > GenVars.dMaxX)
30119 {
30120 GenVars.dMaxX = k;
30121 }
30122 if (l > GenVars.dMaxY)
30123 {
30124 GenVars.dMaxY = l;
30125 }
30126 Main.tile[k, l].liquid = 0;
30127 if (!Main.wallDungeon[Main.tile[k, l].wall])
30128 {
30129 Main.tile[k, l].Clear(TileDataType.Slope);
30130 Main.tile[k, l].active(active: true);
30131 Main.tile[k, l].type = tileType;
30132 }
30133 }
30134 }
30135 for (int m = num7 + 1; m < num8 - 1; m++)
30136 {
30137 for (int n = num9 + 1; n < num10 - 1; n++)
30138 {
30139 Main.tile[m, n].wall = (ushort)wallType;
30140 }
30141 }
30142 num7 = (int)(val2.X - num * 0.5);
30143 num8 = (int)(val2.X + num * 0.5);
30144 num9 = (int)(val2.Y - num * 0.5);
30145 num10 = (int)(val2.Y + num * 0.5);
30146 if (num7 < 0)
30147 {
30148 num7 = 0;
30149 }
30150 if (num8 > Main.maxTilesX)
30151 {
30153 }
30154 if (num9 < 0)
30155 {
30156 num9 = 0;
30157 }
30158 if (num10 > Main.maxTilesY)
30159 {
30161 }
30162 if ((double)num7 < num3)
30163 {
30164 num3 = num7;
30165 }
30166 if ((double)num8 > num4)
30167 {
30168 num4 = num8;
30169 }
30170 if ((double)num9 < num5)
30171 {
30172 num5 = num9;
30173 }
30174 if ((double)num10 > num6)
30175 {
30176 num6 = num10;
30177 }
30178 for (int num11 = num7; num11 < num8; num11++)
30179 {
30180 for (int num12 = num9; num12 < num10; num12++)
30181 {
30182 Main.tile[num11, num12].active(active: false);
30183 Main.tile[num11, num12].wall = (ushort)wallType;
30184 }
30185 }
30186 val2 += val;
30187 val.X += (double)genRand.Next(-10, 11) * 0.05;
30188 val.Y += (double)genRand.Next(-10, 11) * 0.05;
30189 if (val.X > 1.0)
30190 {
30191 val.X = 1.0;
30192 }
30193 if (val.X < -1.0)
30194 {
30195 val.X = -1.0;
30196 }
30197 if (val.Y > 1.0)
30198 {
30199 val.Y = 1.0;
30200 }
30201 if (val.Y < -1.0)
30202 {
30203 val.Y = -1.0;
30204 }
30205 }
30208 GenVars.dRoomSize[GenVars.numDRooms] = (int)num;
30215 }
30216
30217 public static void DungeonEnt(int i, int j, ushort tileType, int wallType)
30218 {
30219 //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
30220 //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
30221 //IL_00f8: Unknown result type (might be due to invalid IL or missing references)
30222 //IL_011c: Unknown result type (might be due to invalid IL or missing references)
30223 //IL_013f: Unknown result type (might be due to invalid IL or missing references)
30224 //IL_057b: Unknown result type (might be due to invalid IL or missing references)
30225 //IL_0590: Unknown result type (might be due to invalid IL or missing references)
30226 //IL_05a6: Unknown result type (might be due to invalid IL or missing references)
30227 //IL_05bb: Unknown result type (might be due to invalid IL or missing references)
30228 //IL_0660: Unknown result type (might be due to invalid IL or missing references)
30229 //IL_067f: Unknown result type (might be due to invalid IL or missing references)
30230 //IL_069f: Unknown result type (might be due to invalid IL or missing references)
30231 //IL_06be: Unknown result type (might be due to invalid IL or missing references)
30232 //IL_0778: Unknown result type (might be due to invalid IL or missing references)
30233 //IL_078d: Unknown result type (might be due to invalid IL or missing references)
30234 //IL_07a3: Unknown result type (might be due to invalid IL or missing references)
30235 //IL_07b8: Unknown result type (might be due to invalid IL or missing references)
30236 //IL_0859: Unknown result type (might be due to invalid IL or missing references)
30237 //IL_086e: Unknown result type (might be due to invalid IL or missing references)
30238 //IL_09bb: Unknown result type (might be due to invalid IL or missing references)
30239 //IL_09de: Unknown result type (might be due to invalid IL or missing references)
30240 //IL_0a02: Unknown result type (might be due to invalid IL or missing references)
30241 //IL_0a25: Unknown result type (might be due to invalid IL or missing references)
30242 //IL_08d2: Unknown result type (might be due to invalid IL or missing references)
30243 //IL_0c2a: Unknown result type (might be due to invalid IL or missing references)
30244 //IL_0c3f: Unknown result type (might be due to invalid IL or missing references)
30245 //IL_0adb: Unknown result type (might be due to invalid IL or missing references)
30246 //IL_0abe: Unknown result type (might be due to invalid IL or missing references)
30247 //IL_0f8b: Unknown result type (might be due to invalid IL or missing references)
30248 //IL_0fa0: Unknown result type (might be due to invalid IL or missing references)
30249 //IL_0fb6: Unknown result type (might be due to invalid IL or missing references)
30250 //IL_0fcb: Unknown result type (might be due to invalid IL or missing references)
30251 //IL_0ebf: Unknown result type (might be due to invalid IL or missing references)
30252 //IL_0ed4: Unknown result type (might be due to invalid IL or missing references)
30253 //IL_0eea: Unknown result type (might be due to invalid IL or missing references)
30254 //IL_0eff: Unknown result type (might be due to invalid IL or missing references)
30255 //IL_106b: Unknown result type (might be due to invalid IL or missing references)
30256 //IL_14b2: Unknown result type (might be due to invalid IL or missing references)
30257 //IL_14c7: Unknown result type (might be due to invalid IL or missing references)
30258 //IL_1665: Unknown result type (might be due to invalid IL or missing references)
30259 //IL_167a: Unknown result type (might be due to invalid IL or missing references)
30260 //IL_1690: Unknown result type (might be due to invalid IL or missing references)
30261 //IL_16a5: Unknown result type (might be due to invalid IL or missing references)
30262 //IL_1563: Unknown result type (might be due to invalid IL or missing references)
30263 //IL_1578: Unknown result type (might be due to invalid IL or missing references)
30264 //IL_1736: Unknown result type (might be due to invalid IL or missing references)
30265 //IL_173d: Unknown result type (might be due to invalid IL or missing references)
30266 int num = 60;
30267 for (int k = i - num; k < i + num; k++)
30268 {
30269 for (int l = j - num; l < j + num; l++)
30270 {
30271 if (InWorld(k, l))
30272 {
30273 Main.tile[k, l].liquid = 0;
30274 Main.tile[k, l].lava(lava: false);
30275 Main.tile[k, l].Clear(TileDataType.Slope);
30276 }
30277 }
30278 }
30281 Vector2D val = default(Vector2D);
30282 val.X = i;
30283 val.Y = (double)j - dyStrength / 2.0;
30284 GenVars.dMinY = (int)val.Y;
30285 int num2 = 1;
30286 if (i > Main.maxTilesX / 2)
30287 {
30288 num2 = -1;
30289 }
30290 if (drunkWorldGen || getGoodWorldGen)
30291 {
30292 num2 *= -1;
30293 }
30294 int num3 = (int)(val.X - dxStrength * 0.6 - (double)genRand.Next(2, 5));
30295 int num4 = (int)(val.X + dxStrength * 0.6 + (double)genRand.Next(2, 5));
30296 int num5 = (int)(val.Y - dyStrength * 0.6 - (double)genRand.Next(2, 5));
30297 int num6 = (int)(val.Y + dyStrength * 0.6 + (double)genRand.Next(8, 16));
30298 if (num3 < 0)
30299 {
30300 num3 = 0;
30301 }
30302 if (num4 > Main.maxTilesX)
30303 {
30305 }
30306 if (num5 < 0)
30307 {
30308 num5 = 0;
30309 }
30310 if (num6 > Main.maxTilesY)
30311 {
30313 }
30314 for (int m = num3; m < num4; m++)
30315 {
30316 for (int n = num5; n < num6; n++)
30317 {
30318 Main.tile[m, n].liquid = 0;
30319 if (Main.tile[m, n].wall != wallType)
30320 {
30321 Main.tile[m, n].wall = 0;
30322 if (m > num3 + 1 && m < num4 - 2 && n > num5 + 1 && n < num6 - 2)
30323 {
30324 Main.tile[m, n].wall = (ushort)wallType;
30325 }
30326 Main.tile[m, n].active(active: true);
30327 Main.tile[m, n].type = tileType;
30328 Main.tile[m, n].Clear(TileDataType.Slope);
30329 }
30330 }
30331 }
30332 int num7 = num3;
30333 int num8 = num3 + 5 + genRand.Next(4);
30334 int num9 = num5 - 3 - genRand.Next(3);
30335 int num10 = num5;
30336 for (int num11 = num7; num11 < num8; num11++)
30337 {
30338 for (int num12 = num9; num12 < num10; num12++)
30339 {
30340 Main.tile[num11, num12].liquid = 0;
30341 if (Main.tile[num11, num12].wall != wallType)
30342 {
30343 Main.tile[num11, num12].active(active: true);
30344 Main.tile[num11, num12].type = tileType;
30345 Main.tile[num11, num12].Clear(TileDataType.Slope);
30346 }
30347 }
30348 }
30349 num7 = num4 - 5 - genRand.Next(4);
30350 num8 = num4;
30351 num9 = num5 - 3 - genRand.Next(3);
30352 num10 = num5;
30353 for (int num13 = num7; num13 < num8; num13++)
30354 {
30355 for (int num14 = num9; num14 < num10; num14++)
30356 {
30357 Main.tile[num13, num14].liquid = 0;
30358 if (Main.tile[num13, num14].wall != wallType)
30359 {
30360 Main.tile[num13, num14].active(active: true);
30361 Main.tile[num13, num14].type = tileType;
30362 Main.tile[num13, num14].Clear(TileDataType.Slope);
30363 }
30364 }
30365 }
30366 int num15 = 1 + genRand.Next(2);
30367 int num16 = 2 + genRand.Next(4);
30368 int num17 = 0;
30369 for (int num18 = num3; num18 < num4; num18++)
30370 {
30371 for (int num19 = num5 - num15; num19 < num5; num19++)
30372 {
30373 Main.tile[num18, num19].liquid = 0;
30374 if (Main.tile[num18, num19].wall != wallType)
30375 {
30376 Main.tile[num18, num19].active(active: true);
30377 Main.tile[num18, num19].type = tileType;
30378 Main.tile[num18, num19].Clear(TileDataType.Slope);
30379 }
30380 }
30381 num17++;
30382 if (num17 >= num16)
30383 {
30384 num18 += num16;
30385 num17 = 0;
30386 }
30387 }
30388 for (int num20 = num3; num20 < num4; num20++)
30389 {
30390 for (int num21 = num6; (double)num21 < Main.worldSurface; num21++)
30391 {
30392 Main.tile[num20, num21].liquid = 0;
30393 if (!Main.wallDungeon[Main.tile[num20, num21].wall])
30394 {
30395 Main.tile[num20, num21].active(active: true);
30396 Main.tile[num20, num21].type = tileType;
30397 }
30398 if (num20 > num3 && num20 < num4 - 1)
30399 {
30400 Main.tile[num20, num21].wall = (ushort)wallType;
30401 }
30402 Main.tile[num20, num21].Clear(TileDataType.Slope);
30403 }
30404 }
30405 num3 = (int)(val.X - dxStrength * 0.6);
30406 num4 = (int)(val.X + dxStrength * 0.6);
30407 num5 = (int)(val.Y - dyStrength * 0.6);
30408 num6 = (int)(val.Y + dyStrength * 0.6);
30409 if (num3 < 0)
30410 {
30411 num3 = 0;
30412 }
30413 if (num4 > Main.maxTilesX)
30414 {
30416 }
30417 if (num5 < 0)
30418 {
30419 num5 = 0;
30420 }
30421 if (num6 > Main.maxTilesY)
30422 {
30424 }
30425 for (int num22 = num3; num22 < num4; num22++)
30426 {
30427 for (int num23 = num5; num23 < num6; num23++)
30428 {
30429 Main.tile[num22, num23].liquid = 0;
30430 Main.tile[num22, num23].wall = (ushort)wallType;
30431 Main.tile[num22, num23].Clear(TileDataType.Slope);
30432 }
30433 }
30434 num3 = (int)(val.X - dxStrength * 0.6 - 1.0);
30435 num4 = (int)(val.X + dxStrength * 0.6 + 1.0);
30436 num5 = (int)(val.Y - dyStrength * 0.6 - 1.0);
30437 num6 = (int)(val.Y + dyStrength * 0.6 + 1.0);
30438 if (num3 < 0)
30439 {
30440 num3 = 0;
30441 }
30442 if (num4 > Main.maxTilesX)
30443 {
30445 }
30446 if (num5 < 0)
30447 {
30448 num5 = 0;
30449 }
30450 if (num6 > Main.maxTilesY)
30451 {
30453 }
30454 if (drunkWorldGen)
30455 {
30456 num3 -= 4;
30457 }
30458 for (int num24 = num3; num24 < num4; num24++)
30459 {
30460 for (int num25 = num5; num25 < num6; num25++)
30461 {
30462 Main.tile[num24, num25].liquid = 0;
30463 Main.tile[num24, num25].wall = (ushort)wallType;
30464 Main.tile[num24, num25].Clear(TileDataType.Slope);
30465 }
30466 }
30467 num3 = (int)(val.X - dxStrength * 0.5);
30468 num4 = (int)(val.X + dxStrength * 0.5);
30469 num5 = (int)(val.Y - dyStrength * 0.5);
30470 num6 = (int)(val.Y + dyStrength * 0.5);
30471 if (num3 < 0)
30472 {
30473 num3 = 0;
30474 }
30475 if (num4 > Main.maxTilesX)
30476 {
30478 }
30479 if (num5 < 0)
30480 {
30481 num5 = 0;
30482 }
30483 if (num6 > Main.maxTilesY)
30484 {
30486 }
30487 for (int num26 = num3; num26 < num4; num26++)
30488 {
30489 for (int num27 = num5; num27 < num6; num27++)
30490 {
30491 Main.tile[num26, num27].liquid = 0;
30492 Main.tile[num26, num27].active(active: false);
30493 Main.tile[num26, num27].wall = (ushort)wallType;
30494 }
30495 }
30496 int num28 = (int)val.X;
30497 int num29 = num6;
30498 for (int num30 = 0; num30 < 20; num30++)
30499 {
30500 num28 = (int)val.X - num30;
30501 if (!Main.tile[num28, num29].active() && Main.wallDungeon[Main.tile[num28, num29].wall])
30502 {
30506 break;
30507 }
30508 num28 = (int)val.X + num30;
30509 if (!Main.tile[num28, num29].active() && Main.wallDungeon[Main.tile[num28, num29].wall])
30510 {
30514 break;
30515 }
30516 }
30517 val.X += dxStrength * 0.6 * (double)num2;
30518 val.Y += dyStrength * 0.5;
30521 val.X += dxStrength * 0.55 * (double)num2;
30522 val.Y -= dyStrength * 0.5;
30523 num3 = (int)(val.X - dxStrength * 0.6 - (double)genRand.Next(1, 3));
30524 num4 = (int)(val.X + dxStrength * 0.6 + (double)genRand.Next(1, 3));
30525 num5 = (int)(val.Y - dyStrength * 0.6 - (double)genRand.Next(1, 3));
30526 num6 = (int)(val.Y + dyStrength * 0.6 + (double)genRand.Next(6, 16));
30527 if (num3 < 0)
30528 {
30529 num3 = 0;
30530 }
30531 if (num4 > Main.maxTilesX)
30532 {
30534 }
30535 if (num5 < 0)
30536 {
30537 num5 = 0;
30538 }
30539 if (num6 > Main.maxTilesY)
30540 {
30542 }
30543 for (int num31 = num3; num31 < num4; num31++)
30544 {
30545 for (int num32 = num5; num32 < num6; num32++)
30546 {
30547 Main.tile[num31, num32].liquid = 0;
30548 if (Main.tile[num31, num32].wall == wallType)
30549 {
30550 continue;
30551 }
30552 bool flag = true;
30553 if (num2 < 0)
30554 {
30555 if ((double)num31 < val.X - dxStrength * 0.5)
30556 {
30557 flag = false;
30558 }
30559 }
30560 else if ((double)num31 > val.X + dxStrength * 0.5 - 1.0)
30561 {
30562 flag = false;
30563 }
30564 if (flag)
30565 {
30566 Main.tile[num31, num32].wall = 0;
30567 Main.tile[num31, num32].active(active: true);
30568 Main.tile[num31, num32].type = tileType;
30569 Main.tile[num31, num32].Clear(TileDataType.Slope);
30570 }
30571 }
30572 }
30573 for (int num33 = num3; num33 < num4; num33++)
30574 {
30575 for (int num34 = num6; (double)num34 < Main.worldSurface; num34++)
30576 {
30577 Main.tile[num33, num34].liquid = 0;
30578 if (!Main.wallDungeon[Main.tile[num33, num34].wall])
30579 {
30580 Main.tile[num33, num34].active(active: true);
30581 Main.tile[num33, num34].type = tileType;
30582 }
30583 Main.tile[num33, num34].wall = (ushort)wallType;
30584 Main.tile[num33, num34].Clear(TileDataType.Slope);
30585 }
30586 }
30587 num3 = (int)(val.X - dxStrength * 0.5);
30588 num4 = (int)(val.X + dxStrength * 0.5);
30589 num7 = num3;
30590 if (num2 < 0)
30591 {
30592 num7++;
30593 }
30594 num8 = num7 + 5 + genRand.Next(4);
30595 num9 = num5 - 3 - genRand.Next(3);
30596 num10 = num5;
30597 for (int num35 = num7; num35 < num8; num35++)
30598 {
30599 for (int num36 = num9; num36 < num10; num36++)
30600 {
30601 Main.tile[num35, num36].liquid = 0;
30602 if (Main.tile[num35, num36].wall != wallType)
30603 {
30604 Main.tile[num35, num36].active(active: true);
30605 Main.tile[num35, num36].type = tileType;
30606 Main.tile[num35, num36].Clear(TileDataType.Slope);
30607 }
30608 }
30609 }
30610 num7 = num4 - 5 - genRand.Next(4);
30611 num8 = num4;
30612 num9 = num5 - 3 - genRand.Next(3);
30613 num10 = num5;
30614 for (int num37 = num7; num37 < num8; num37++)
30615 {
30616 for (int num38 = num9; num38 < num10; num38++)
30617 {
30618 Main.tile[num37, num38].liquid = 0;
30619 if (Main.tile[num37, num38].wall != wallType)
30620 {
30621 Main.tile[num37, num38].active(active: true);
30622 Main.tile[num37, num38].type = tileType;
30623 Main.tile[num37, num38].Clear(TileDataType.Slope);
30624 }
30625 }
30626 }
30627 num15 = 1 + genRand.Next(2);
30628 num16 = 2 + genRand.Next(4);
30629 num17 = 0;
30630 if (num2 < 0)
30631 {
30632 num4++;
30633 }
30634 for (int num39 = num3 + 1; num39 < num4 - 1; num39++)
30635 {
30636 for (int num40 = num5 - num15; num40 < num5; num40++)
30637 {
30638 Main.tile[num39, num40].liquid = 0;
30639 if (Main.tile[num39, num40].wall != wallType)
30640 {
30641 Main.tile[num39, num40].active(active: true);
30642 Main.tile[num39, num40].type = tileType;
30643 Main.tile[num39, num40].Clear(TileDataType.Slope);
30644 }
30645 }
30646 num17++;
30647 if (num17 >= num16)
30648 {
30649 num39 += num16;
30650 num17 = 0;
30651 }
30652 }
30653 if (!drunkWorldGen)
30654 {
30655 num3 = (int)(val.X - dxStrength * 0.6);
30656 num4 = (int)(val.X + dxStrength * 0.6);
30657 num5 = (int)(val.Y - dyStrength * 0.6);
30658 num6 = (int)(val.Y + dyStrength * 0.6);
30659 if (num3 < 0)
30660 {
30661 num3 = 0;
30662 }
30663 if (num4 > Main.maxTilesX)
30664 {
30666 }
30667 if (num5 < 0)
30668 {
30669 num5 = 0;
30670 }
30671 if (num6 > Main.maxTilesY)
30672 {
30674 }
30675 for (int num41 = num3; num41 < num4; num41++)
30676 {
30677 for (int num42 = num5; num42 < num6; num42++)
30678 {
30679 Main.tile[num41, num42].liquid = 0;
30680 Main.tile[num41, num42].wall = 0;
30681 }
30682 }
30683 }
30684 num3 = (int)(val.X - dxStrength * 0.5);
30685 num4 = (int)(val.X + dxStrength * 0.5);
30686 num5 = (int)(val.Y - dyStrength * 0.5);
30687 num6 = (int)(val.Y + dyStrength * 0.5);
30688 if (num3 < 0)
30689 {
30690 num3 = 0;
30691 }
30692 if (num4 > Main.maxTilesX)
30693 {
30695 }
30696 if (num5 < 0)
30697 {
30698 num5 = 0;
30699 }
30700 if (num6 > Main.maxTilesY)
30701 {
30703 }
30704 for (int num43 = num3; num43 < num4; num43++)
30705 {
30706 for (int num44 = num5; num44 < num6; num44++)
30707 {
30708 Main.tile[num43, num44].liquid = 0;
30709 Main.tile[num43, num44].active(active: false);
30710 Main.tile[num43, num44].wall = 0;
30711 }
30712 }
30713 Main.dungeonX = (int)val.X;
30714 Main.dungeonY = num6;
30715 int num45 = NPC.NewNPC(new EntitySource_WorldGen(), Main.dungeonX * 16 + 8, Main.dungeonY * 16, 37);
30716 Main.npc[num45].homeless = false;
30717 Main.npc[num45].homeTileX = Main.dungeonX;
30718 Main.npc[num45].homeTileY = Main.dungeonY;
30719 if (drunkWorldGen)
30720 {
30721 int num46 = (int)Main.worldSurface;
30722 while (Main.tile[GenVars.dungeonX, num46].active() || Main.tile[GenVars.dungeonX, num46].wall > 0 || Main.tile[GenVars.dungeonX, num46 - 1].active() || Main.tile[GenVars.dungeonX, num46 - 1].wall > 0 || Main.tile[GenVars.dungeonX, num46 - 2].active() || Main.tile[GenVars.dungeonX, num46 - 2].wall > 0 || Main.tile[GenVars.dungeonX, num46 - 3].active() || Main.tile[GenVars.dungeonX, num46 - 3].wall > 0 || Main.tile[GenVars.dungeonX, num46 - 4].active() || Main.tile[GenVars.dungeonX, num46 - 4].wall > 0)
30723 {
30724 num46--;
30725 if (num46 < 50)
30726 {
30727 break;
30728 }
30729 }
30730 if (num46 > 50)
30731 {
30732 GrowDungeonTree(GenVars.dungeonX, num46);
30733 }
30734 }
30735 if (!drunkWorldGen)
30736 {
30737 int num47 = 100;
30738 if (num2 == 1)
30739 {
30740 int num48 = 0;
30741 for (int num49 = num4; num49 < num4 + num47; num49++)
30742 {
30743 num48++;
30744 for (int num50 = num6 + num48; num50 < num6 + num47; num50++)
30745 {
30746 Main.tile[num49, num50].liquid = 0;
30747 Main.tile[num49, num50 - 1].liquid = 0;
30748 Main.tile[num49, num50 - 2].liquid = 0;
30749 Main.tile[num49, num50 - 3].liquid = 0;
30750 if (!Main.wallDungeon[Main.tile[num49, num50].wall] && Main.tile[num49, num50].wall != 3 && Main.tile[num49, num50].wall != 83)
30751 {
30752 Main.tile[num49, num50].active(active: true);
30753 Main.tile[num49, num50].type = tileType;
30754 Main.tile[num49, num50].Clear(TileDataType.Slope);
30755 }
30756 }
30757 }
30758 }
30759 else
30760 {
30761 int num51 = 0;
30762 for (int num52 = num3; num52 > num3 - num47; num52--)
30763 {
30764 num51++;
30765 for (int num53 = num6 + num51; num53 < num6 + num47; num53++)
30766 {
30767 Main.tile[num52, num53].liquid = 0;
30768 Main.tile[num52, num53 - 1].liquid = 0;
30769 Main.tile[num52, num53 - 2].liquid = 0;
30770 Main.tile[num52, num53 - 3].liquid = 0;
30771 if (!Main.wallDungeon[Main.tile[num52, num53].wall] && Main.tile[num52, num53].wall != 3 && Main.tile[num52, num53].wall != 83)
30772 {
30773 Main.tile[num52, num53].active(active: true);
30774 Main.tile[num52, num53].type = tileType;
30775 Main.tile[num52, num53].Clear(TileDataType.Slope);
30776 }
30777 }
30778 }
30779 }
30780 }
30781 num15 = 1 + genRand.Next(2);
30782 num16 = 2 + genRand.Next(4);
30783 num17 = 0;
30784 num3 = (int)(val.X - dxStrength * 0.5);
30785 num4 = (int)(val.X + dxStrength * 0.5);
30786 if (drunkWorldGen)
30787 {
30788 if (num2 == 1)
30789 {
30790 num4--;
30791 num3--;
30792 }
30793 else
30794 {
30795 num3++;
30796 num4++;
30797 }
30798 }
30799 else
30800 {
30801 num3 += 2;
30802 num4 -= 2;
30803 }
30804 for (int num54 = num3; num54 < num4; num54++)
30805 {
30806 for (int num55 = num5; num55 < num6 + 1; num55++)
30807 {
30808 PlaceWall(num54, num55, wallType, mute: true);
30809 }
30810 if (!drunkWorldGen)
30811 {
30812 num17++;
30813 if (num17 >= num16)
30814 {
30815 num54 += num16 * 2;
30816 num17 = 0;
30817 }
30818 }
30819 }
30820 if (drunkWorldGen)
30821 {
30822 num3 = (int)(val.X - dxStrength * 0.5);
30823 num4 = (int)(val.X + dxStrength * 0.5);
30824 if (num2 == 1)
30825 {
30826 num3 = num4 - 3;
30827 }
30828 else
30829 {
30830 num4 = num3 + 3;
30831 }
30832 for (int num56 = num3; num56 < num4; num56++)
30833 {
30834 for (int num57 = num5; num57 < num6 + 1; num57++)
30835 {
30836 Main.tile[num56, num57].active(active: true);
30837 Main.tile[num56, num57].type = tileType;
30838 Main.tile[num56, num57].Clear(TileDataType.Slope);
30839 }
30840 }
30841 }
30842 val.X -= dxStrength * 0.6 * (double)num2;
30843 val.Y += dyStrength * 0.5;
30844 dxStrength = 15.0;
30845 dyStrength = 3.0;
30846 val.Y -= dyStrength * 0.5;
30847 num3 = (int)(val.X - dxStrength * 0.5);
30848 num4 = (int)(val.X + dxStrength * 0.5);
30849 num5 = (int)(val.Y - dyStrength * 0.5);
30850 num6 = (int)(val.Y + dyStrength * 0.5);
30851 if (num3 < 0)
30852 {
30853 num3 = 0;
30854 }
30855 if (num4 > Main.maxTilesX)
30856 {
30858 }
30859 if (num5 < 0)
30860 {
30861 num5 = 0;
30862 }
30863 if (num6 > Main.maxTilesY)
30864 {
30866 }
30867 for (int num58 = num3; num58 < num4; num58++)
30868 {
30869 for (int num59 = num5; num59 < num6; num59++)
30870 {
30871 Main.tile[num58, num59].active(active: false);
30872 }
30873 }
30874 if (num2 < 0)
30875 {
30876 val.X -= 1.0;
30877 }
30878 PlaceTile((int)val.X, (int)val.Y + 1, 10, mute: true, forced: false, -1, 13);
30879 }
30880
30881 public static bool AddBuriedChest(Point point, int contain = 0, bool notNearOtherChests = false, int Style = -1)
30882 {
30883 return AddBuriedChest(point.X, point.Y, contain, notNearOtherChests, Style, trySlope: false, 0);
30884 }
30885
30886 public static bool IsChestRigged(int x, int y)
30887 {
30888 if (Main.tile[x, y].type == 467)
30889 {
30890 return Main.tile[x, y].frameX / 36 == 4;
30891 }
30892 return false;
30893 }
30894
30895 private static bool IsUndergroundDesert(int x, int y)
30896 {
30897 if ((double)y < Main.worldSurface)
30898 {
30899 return false;
30900 }
30901 if ((double)x < (double)Main.maxTilesX * 0.15 || (double)x > (double)Main.maxTilesX * 0.85)
30902 {
30903 return false;
30904 }
30905 if (remixWorldGen && (double)y > Main.rockLayer)
30906 {
30907 return false;
30908 }
30909 int num = 15;
30910 for (int i = x - num; i <= x + num; i++)
30911 {
30912 for (int j = y - num; j <= y + num; j++)
30913 {
30914 if (Main.tile[i, j].wall == 187 || Main.tile[i, j].wall == 216)
30915 {
30916 return true;
30917 }
30918 }
30919 }
30920 return false;
30921 }
30922
30923 private static bool IsDungeon(int x, int y)
30924 {
30925 if ((double)y < Main.worldSurface)
30926 {
30927 return false;
30928 }
30930 {
30931 return false;
30932 }
30933 if (Main.wallDungeon[Main.tile[x, y].wall])
30934 {
30935 return true;
30936 }
30937 return false;
30938 }
30939
30940 public static bool AddBuriedChest(int i, int j, int contain = 0, bool notNearOtherChests = false, int Style = -1, bool trySlope = false, ushort chestTileType = 0)
30941 {
30942 if (chestTileType == 0)
30943 {
30944 chestTileType = 21;
30945 }
30946 bool flag = false;
30947 bool flag2 = false;
30948 bool flag3 = false;
30949 bool flag4 = false;
30950 bool flag5 = false;
30951 bool flag6 = false;
30952 bool flag7 = false;
30953 bool flag8 = false;
30954 bool flag9 = false;
30955 bool flag10 = false;
30956 int num = 15;
30957 if (tenthAnniversaryWorldGen)
30958 {
30959 num *= 3;
30960 }
30961 for (int k = j; k < Main.maxTilesY - 10; k++)
30962 {
30963 int num2 = -1;
30964 int num3 = -1;
30965 if (Main.tile[i, k].shimmer())
30966 {
30967 return false;
30968 }
30969 if (trySlope && Main.tile[i, k].active() && Main.tileSolid[Main.tile[i, k].type] && !Main.tileSolidTop[Main.tile[i, k].type])
30970 {
30971 if (Style == 17)
30972 {
30973 int num4 = 30;
30974 for (int l = i - num4; l <= i + num4; l++)
30975 {
30976 for (int m = k - num4; m <= k + num4; m++)
30977 {
30978 if (!InWorld(l, m, 5))
30979 {
30980 return false;
30981 }
30982 if (Main.tile[l, m].active() && (Main.tile[l, m].type == 21 || Main.tile[l, m].type == 467))
30983 {
30984 return false;
30985 }
30986 }
30987 }
30988 }
30989 if (Main.tile[i - 1, k].topSlope())
30990 {
30991 num2 = Main.tile[i - 1, k].slope();
30992 Main.tile[i - 1, k].slope(0);
30993 }
30994 if (Main.tile[i, k].topSlope())
30995 {
30996 num3 = Main.tile[i, k].slope();
30997 Main.tile[i, k].slope(0);
30998 }
30999 }
31000 if (remixWorldGen && (double)i > (double)Main.maxTilesX * 0.37 && (double)i < (double)Main.maxTilesX * 0.63 && k > Main.maxTilesY - 250)
31001 {
31002 return false;
31003 }
31004 int num5 = 2;
31005 for (int n = i - num5; n <= i + num5; n++)
31006 {
31007 for (int num6 = k - num5; num6 <= k + num5; num6++)
31008 {
31009 if (Main.tile[n, num6].active() && (TileID.Sets.Boulders[Main.tile[n, num6].type] || Main.tile[n, num6].type == 26 || Main.tile[n, num6].type == 237))
31010 {
31011 return false;
31012 }
31013 }
31014 }
31015 if (!SolidTile(i, k))
31016 {
31017 continue;
31018 }
31019 bool flag11 = false;
31020 int num7 = k;
31021 int num8 = -1;
31022 int num9 = 0;
31023 bool flag12 = (double)num7 >= Main.worldSurface + 25.0;
31024 if (remixWorldGen)
31025 {
31026 flag12 = num7 < Main.maxTilesY - 400;
31027 }
31028 if (flag12 || contain > 0)
31029 {
31030 num9 = 1;
31031 }
31032 if (Style >= 0)
31033 {
31034 num9 = Style;
31035 }
31036 if ((chestTileType == 467 && num9 == 10) || (contain == 0 && num7 <= Main.maxTilesY - 205 && IsUndergroundDesert(i, k)))
31037 {
31038 flag2 = true;
31039 num9 = 10;
31040 chestTileType = 467;
31041 contain = ((num7 <= (GenVars.desertHiveHigh * 3 + GenVars.desertHiveLow * 4) / 7) ? Utils.SelectRandom(genRand, new short[4] { 4056, 4055, 4262, 4263 }) : Utils.SelectRandom(genRand, new short[3] { 4061, 4062, 4276 }));
31042 if (getGoodWorldGen && genRand.Next(num) == 0)
31043 {
31044 contain = 52;
31045 }
31046 }
31047 if (chestTileType == 21 && (num9 == 11 || (contain == 0 && (double)num7 >= Main.worldSurface + 25.0 && num7 <= Main.maxTilesY - 205 && (Main.tile[i, k].type == 147 || Main.tile[i, k].type == 161 || Main.tile[i, k].type == 162))))
31048 {
31049 flag = true;
31050 num9 = 11;
31051 contain = genRand.Next(6) switch
31052 {
31053 0 => 670,
31054 1 => 724,
31055 2 => 950,
31056 3 => (!remixWorldGen) ? 1319 : 725,
31057 4 => 987,
31058 _ => 1579,
31059 };
31060 if (genRand.Next(20) == 0)
31061 {
31062 contain = 997;
31063 }
31064 if (genRand.Next(50) == 0)
31065 {
31066 contain = 669;
31067 }
31068 if (getGoodWorldGen && genRand.Next(num) == 0)
31069 {
31070 contain = 52;
31071 }
31072 }
31073 if (chestTileType == 21 && (Style == 10 || contain == 211 || contain == 212 || contain == 213 || contain == 753))
31074 {
31075 flag3 = true;
31076 num9 = 10;
31077 if (getGoodWorldGen && genRand.Next(num) == 0)
31078 {
31079 contain = 52;
31080 }
31081 }
31082 if (chestTileType == 21 && num7 > Main.maxTilesY - 205 && contain == 0)
31083 {
31084 flag7 = true;
31086 num9 = 4;
31087 flag11 = true;
31088 if (getGoodWorldGen && genRand.Next(num) == 0)
31089 {
31090 contain = 52;
31091 }
31092 }
31093 if (chestTileType == 21 && num9 == 17)
31094 {
31095 flag4 = true;
31096 if (getGoodWorldGen && genRand.Next(num) == 0)
31097 {
31098 contain = 52;
31099 }
31100 }
31101 if (chestTileType == 21 && num9 == 12)
31102 {
31103 flag5 = true;
31104 if (getGoodWorldGen && genRand.Next(num) == 0)
31105 {
31106 contain = 52;
31107 }
31108 }
31109 if (chestTileType == 21 && num9 == 32)
31110 {
31111 flag6 = true;
31112 if (getGoodWorldGen && genRand.Next(num) == 0)
31113 {
31114 contain = 52;
31115 }
31116 }
31117 if (chestTileType == 21 && num9 != 0 && IsDungeon(i, k))
31118 {
31119 flag8 = true;
31120 }
31121 if (chestTileType == 21 && num9 != 0 && (contain == 848 || contain == 857 || contain == 934))
31122 {
31123 flag9 = true;
31124 }
31125 if (chestTileType == 21 && (num9 == 13 || contain == 159 || contain == 65 || contain == 158 || contain == 2219))
31126 {
31127 flag10 = true;
31128 if (remixWorldGen && !getGoodWorldGen)
31129 {
31130 if (crimson)
31131 {
31132 num9 = 43;
31133 }
31134 else
31135 {
31136 chestTileType = 467;
31137 num9 = 3;
31138 }
31139 }
31140 }
31141 if (noTrapsWorldGen && num9 == 1 && chestTileType == 21 && (!remixWorldGen || genRand.Next(3) == 0))
31142 {
31143 num9 = 4;
31144 chestTileType = 467;
31145 }
31146 num8 = ((chestTileType != 467) ? PlaceChest(i - 1, num7 - 1, chestTileType, notNearOtherChests, num9) : PlaceChest(i - 1, num7 - 1, chestTileType, notNearOtherChests, num9));
31147 if (num8 >= 0)
31148 {
31149 if (flag11)
31150 {
31152 if (GenVars.hellChest >= GenVars.hellChestItem.Length)
31153 {
31154 GenVars.hellChest = 0;
31155 }
31156 }
31157 Chest chest = Main.chest[num8];
31158 int num10 = 0;
31159 while (num10 == 0)
31160 {
31161 bool flag13 = (double)num7 < Main.worldSurface + 25.0;
31162 if (remixWorldGen)
31163 {
31164 flag13 = (double)num7 >= (Main.rockLayer + (double)((Main.maxTilesY - 350) * 2)) / 3.0;
31165 }
31166 if ((num9 == 0 && flag13) || flag9)
31167 {
31168 if (contain > 0)
31169 {
31170 chest.item[num10].SetDefaults(contain);
31171 chest.item[num10].Prefix(-1);
31172 num10++;
31173 switch (contain)
31174 {
31175 case 848:
31176 chest.item[num10].SetDefaults(866);
31177 num10++;
31178 break;
31179 case 832:
31180 chest.item[num10].SetDefaults(933);
31181 num10++;
31182 if (genRand.Next(6) == 0)
31183 {
31184 int num11 = genRand.Next(2);
31185 switch (num11)
31186 {
31187 case 0:
31188 num11 = 4429;
31189 break;
31190 case 1:
31191 num11 = 4427;
31192 break;
31193 }
31194 chest.item[num10].SetDefaults(num11);
31195 num10++;
31196 }
31197 break;
31198 }
31200 {
31201 chest.item[num10++].SetDefaults(848);
31202 chest.item[num10++].SetDefaults(866);
31203 }
31204 }
31205 else
31206 {
31207 int num12 = genRand.Next(10);
31208 if (num12 == 0)
31209 {
31210 chest.item[num10].SetDefaults(280);
31211 chest.item[num10].Prefix(-1);
31212 }
31213 if (num12 == 1)
31214 {
31215 chest.item[num10].SetDefaults(281);
31216 chest.item[num10].Prefix(-1);
31217 }
31218 if (num12 == 2)
31219 {
31220 chest.item[num10].SetDefaults(284);
31221 chest.item[num10].Prefix(-1);
31222 }
31223 if (num12 == 3)
31224 {
31225 chest.item[num10].SetDefaults(285);
31226 chest.item[num10].Prefix(-1);
31227 }
31228 if (num12 == 4)
31229 {
31230 chest.item[num10].SetDefaults(953);
31231 chest.item[num10].Prefix(-1);
31232 }
31233 if (num12 == 5)
31234 {
31235 chest.item[num10].SetDefaults(946);
31236 chest.item[num10].Prefix(-1);
31237 }
31238 if (num12 == 6)
31239 {
31240 chest.item[num10].SetDefaults(3068);
31241 chest.item[num10].Prefix(-1);
31242 }
31243 if (num12 == 7)
31244 {
31245 if (remixWorldGen)
31246 {
31247 chest.item[num10].SetDefaults(517);
31248 chest.item[num10].Prefix(-1);
31249 }
31250 else
31251 {
31252 chest.item[num10].SetDefaults(3069);
31253 chest.item[num10].Prefix(-1);
31254 }
31255 }
31256 if (num12 == 8)
31257 {
31258 chest.item[num10].SetDefaults(3084);
31259 chest.item[num10].Prefix(-1);
31260 }
31261 if (num12 == 9)
31262 {
31263 chest.item[num10].SetDefaults(4341);
31264 chest.item[num10].Prefix(-1);
31265 }
31266 num10++;
31267 }
31268 if (genRand.Next(6) == 0)
31269 {
31270 int stack = genRand.Next(40, 76);
31271 chest.item[num10].SetDefaults(282);
31272 chest.item[num10].stack = stack;
31273 num10++;
31274 }
31275 if (genRand.Next(6) == 0)
31276 {
31277 int stack2 = genRand.Next(150, 301);
31278 chest.item[num10].SetDefaults(279);
31279 chest.item[num10].stack = stack2;
31280 num10++;
31281 }
31282 if (genRand.Next(6) == 0)
31283 {
31284 chest.item[num10].SetDefaults(3093);
31285 chest.item[num10].stack = 1;
31286 if (genRand.Next(5) == 0)
31287 {
31288 chest.item[num10].stack += genRand.Next(2);
31289 }
31290 if (genRand.Next(10) == 0)
31291 {
31292 chest.item[num10].stack += genRand.Next(3);
31293 }
31294 num10++;
31295 }
31296 if (genRand.Next(6) == 0)
31297 {
31298 chest.item[num10].SetDefaults(4345);
31299 chest.item[num10].stack = 1;
31300 if (genRand.Next(5) == 0)
31301 {
31302 chest.item[num10].stack += genRand.Next(2);
31303 }
31304 if (genRand.Next(10) == 0)
31305 {
31306 chest.item[num10].stack += genRand.Next(3);
31307 }
31308 num10++;
31309 }
31310 if (genRand.Next(3) == 0)
31311 {
31312 chest.item[num10].SetDefaults(168);
31313 chest.item[num10].stack = genRand.Next(3, 6);
31314 num10++;
31315 }
31316 if (genRand.Next(2) == 0)
31317 {
31318 int num13 = genRand.Next(2);
31319 int stack3 = genRand.Next(8) + 3;
31320 if (num13 == 0)
31321 {
31323 }
31324 if (num13 == 1)
31325 {
31327 }
31328 chest.item[num10].stack = stack3;
31329 num10++;
31330 }
31331 if (genRand.Next(2) == 0)
31332 {
31333 int stack4 = genRand.Next(50, 101);
31334 chest.item[num10].SetDefaults(965);
31335 chest.item[num10].stack = stack4;
31336 num10++;
31337 }
31338 if (genRand.Next(3) != 0)
31339 {
31340 int num14 = genRand.Next(2);
31341 int stack5 = genRand.Next(26) + 25;
31342 if (num14 == 0)
31343 {
31344 chest.item[num10].SetDefaults(40);
31345 }
31346 if (num14 == 1)
31347 {
31348 chest.item[num10].SetDefaults(42);
31349 }
31350 chest.item[num10].stack = stack5;
31351 num10++;
31352 }
31353 if (genRand.Next(2) == 0)
31354 {
31355 int stack6 = genRand.Next(3) + 3;
31356 chest.item[num10].SetDefaults(28);
31357 chest.item[num10].stack = stack6;
31358 num10++;
31359 }
31360 if (genRand.Next(3) != 0)
31361 {
31362 chest.item[num10].SetDefaults(2350);
31363 chest.item[num10].stack = genRand.Next(3, 6);
31364 num10++;
31365 }
31366 if (genRand.Next(3) > 0)
31367 {
31368 int num15 = genRand.Next(6);
31369 int stack7 = genRand.Next(1, 3);
31370 if (num15 == 0)
31371 {
31372 chest.item[num10].SetDefaults(292);
31373 }
31374 if (num15 == 1)
31375 {
31376 chest.item[num10].SetDefaults(298);
31377 }
31378 if (num15 == 2)
31379 {
31380 chest.item[num10].SetDefaults(299);
31381 }
31382 if (num15 == 3)
31383 {
31384 chest.item[num10].SetDefaults(290);
31385 }
31386 if (num15 == 4)
31387 {
31388 chest.item[num10].SetDefaults(2322);
31389 }
31390 if (num15 == 5)
31391 {
31392 chest.item[num10].SetDefaults(2325);
31393 }
31394 chest.item[num10].stack = stack7;
31395 num10++;
31396 }
31397 if (genRand.Next(2) == 0)
31398 {
31399 int num16 = genRand.Next(2);
31400 int stack8 = genRand.Next(11) + 10;
31401 if (num16 == 0)
31402 {
31403 chest.item[num10].SetDefaults(8);
31404 }
31405 if (num16 == 1)
31406 {
31407 chest.item[num10].SetDefaults(31);
31408 }
31409 chest.item[num10].stack = stack8;
31410 num10++;
31411 }
31412 if (genRand.Next(2) == 0)
31413 {
31414 chest.item[num10].SetDefaults(72);
31415 chest.item[num10].stack = genRand.Next(10, 30);
31416 num10++;
31417 }
31418 if (genRand.Next(2) == 0)
31419 {
31420 chest.item[num10].SetDefaults(9);
31421 chest.item[num10].stack = genRand.Next(50, 100);
31422 num10++;
31423 }
31424 }
31425 else if ((!remixWorldGen && (double)num7 < Main.rockLayer) || (remixWorldGen && (double)num7 > Main.rockLayer && num7 < Main.maxTilesY - 250))
31426 {
31427 if (contain > 0)
31428 {
31429 if (contain == 832)
31430 {
31431 chest.item[num10].SetDefaults(933);
31432 num10++;
31433 }
31434 chest.item[num10].SetDefaults(contain);
31435 chest.item[num10].Prefix(-1);
31436 num10++;
31437 if (flag4)
31438 {
31439 if (genRand.Next(2) == 0)
31440 {
31441 chest.item[num10++].SetDefaults(4425);
31442 }
31443 if (genRand.Next(2) == 0)
31444 {
31445 chest.item[num10++].SetDefaults(4460);
31446 }
31447 }
31448 if (flag10 && genRand.Next(40) == 0)
31449 {
31450 chest.item[num10++].SetDefaults(4978);
31451 }
31452 if (flag5 && genRand.Next(10) == 0)
31453 {
31454 int num17 = genRand.Next(2);
31455 switch (num17)
31456 {
31457 case 0:
31458 num17 = 4429;
31459 break;
31460 case 1:
31461 num17 = 4427;
31462 break;
31463 }
31464 chest.item[num10].SetDefaults(num17);
31465 num10++;
31466 }
31467 if (flag8 && (!GenVars.generatedShadowKey || genRand.Next(3) == 0))
31468 {
31469 GenVars.generatedShadowKey = true;
31470 chest.item[num10].SetDefaults(329);
31471 num10++;
31472 }
31473 }
31474 else
31475 {
31476 switch (genRand.Next(6))
31477 {
31478 case 0:
31479 chest.item[num10].SetDefaults(49);
31480 chest.item[num10].Prefix(-1);
31481 break;
31482 case 1:
31483 chest.item[num10].SetDefaults(50);
31484 chest.item[num10].Prefix(-1);
31485 break;
31486 case 2:
31487 chest.item[num10].SetDefaults(53);
31488 chest.item[num10].Prefix(-1);
31489 break;
31490 case 3:
31491 chest.item[num10].SetDefaults(54);
31492 chest.item[num10].Prefix(-1);
31493 break;
31494 case 4:
31495 chest.item[num10].SetDefaults(5011);
31496 chest.item[num10].Prefix(-1);
31497 break;
31498 default:
31499 chest.item[num10].SetDefaults(975);
31500 chest.item[num10].Prefix(-1);
31501 break;
31502 }
31503 num10++;
31504 if (genRand.Next(20) == 0)
31505 {
31506 chest.item[num10].SetDefaults(997);
31507 chest.item[num10].Prefix(-1);
31508 num10++;
31509 }
31510 else if (genRand.Next(20) == 0)
31511 {
31512 chest.item[num10].SetDefaults(930);
31513 chest.item[num10].Prefix(-1);
31514 num10++;
31515 chest.item[num10].SetDefaults(931);
31516 chest.item[num10].stack = genRand.Next(26) + 25;
31517 num10++;
31518 }
31519 if (flag6 && genRand.Next(2) == 0)
31520 {
31521 chest.item[num10].SetDefaults(4450);
31522 num10++;
31523 }
31524 if (flag6 && genRand.Next(3) == 0)
31525 {
31526 chest.item[num10].SetDefaults(4779);
31527 num10++;
31528 chest.item[num10].SetDefaults(4780);
31529 num10++;
31530 chest.item[num10].SetDefaults(4781);
31531 num10++;
31532 }
31533 }
31534 if (flag2)
31535 {
31536 if (genRand.Next(3) == 0)
31537 {
31538 chest.item[num10].SetDefaults(4423);
31539 chest.item[num10].stack = genRand.Next(10, 20);
31540 num10++;
31541 }
31542 }
31543 else if (genRand.Next(3) == 0)
31544 {
31545 chest.item[num10].SetDefaults(166);
31546 chest.item[num10].stack = genRand.Next(10, 20);
31547 num10++;
31548 }
31549 if (genRand.Next(5) == 0)
31550 {
31551 chest.item[num10].SetDefaults(52);
31552 num10++;
31553 }
31554 if (genRand.Next(3) == 0)
31555 {
31556 int stack9 = genRand.Next(50, 101);
31557 chest.item[num10].SetDefaults(965);
31558 chest.item[num10].stack = stack9;
31559 num10++;
31560 }
31561 if (genRand.Next(2) == 0)
31562 {
31563 int num18 = genRand.Next(2);
31564 int stack10 = genRand.Next(10) + 5;
31565 if (num18 == 0)
31566 {
31568 }
31569 if (num18 == 1)
31570 {
31572 }
31573 chest.item[num10].stack = stack10;
31574 num10++;
31575 }
31576 if (genRand.Next(2) == 0)
31577 {
31578 int num19 = genRand.Next(2);
31579 int stack11 = genRand.Next(25) + 25;
31580 if (num19 == 0)
31581 {
31582 chest.item[num10].SetDefaults(40);
31583 }
31584 if (num19 == 1)
31585 {
31586 chest.item[num10].SetDefaults(42);
31587 }
31588 chest.item[num10].stack = stack11;
31589 num10++;
31590 }
31591 if (genRand.Next(2) == 0)
31592 {
31593 int stack12 = genRand.Next(3) + 3;
31594 chest.item[num10].SetDefaults(28);
31595 chest.item[num10].stack = stack12;
31596 num10++;
31597 }
31598 if (genRand.Next(3) > 0)
31599 {
31600 int num20 = genRand.Next(9);
31601 int stack13 = genRand.Next(1, 3);
31602 if (num20 == 0)
31603 {
31604 chest.item[num10].SetDefaults(289);
31605 }
31606 if (num20 == 1)
31607 {
31608 chest.item[num10].SetDefaults(298);
31609 }
31610 if (num20 == 2)
31611 {
31612 chest.item[num10].SetDefaults(299);
31613 }
31614 if (num20 == 3)
31615 {
31616 chest.item[num10].SetDefaults(290);
31617 }
31618 if (num20 == 4)
31619 {
31620 chest.item[num10].SetDefaults(303);
31621 }
31622 if (num20 == 5)
31623 {
31624 chest.item[num10].SetDefaults(291);
31625 }
31626 if (num20 == 6)
31627 {
31628 chest.item[num10].SetDefaults(304);
31629 }
31630 if (num20 == 7)
31631 {
31632 chest.item[num10].SetDefaults(2322);
31633 }
31634 if (num20 == 8)
31635 {
31636 chest.item[num10].SetDefaults(2329);
31637 }
31638 chest.item[num10].stack = stack13;
31639 num10++;
31640 }
31641 if (genRand.Next(3) != 0)
31642 {
31643 int stack14 = genRand.Next(2, 5);
31644 chest.item[num10].SetDefaults(2350);
31645 chest.item[num10].stack = stack14;
31646 num10++;
31647 }
31648 if (genRand.Next(2) == 0)
31649 {
31650 int stack15 = genRand.Next(11) + 10;
31651 if (num9 == 11)
31652 {
31653 chest.item[num10].SetDefaults(974);
31654 }
31655 else
31656 {
31657 chest.item[num10].SetDefaults(8);
31658 }
31659 chest.item[num10].stack = stack15;
31660 num10++;
31661 }
31662 if (genRand.Next(2) == 0)
31663 {
31664 chest.item[num10].SetDefaults(72);
31665 chest.item[num10].stack = genRand.Next(50, 90);
31666 num10++;
31667 }
31668 }
31669 else if (num7 < Main.maxTilesY - 250 || (remixWorldGen && (Style == 7 || Style == 14)))
31670 {
31671 if (contain > 0)
31672 {
31673 chest.item[num10].SetDefaults(contain);
31674 chest.item[num10].Prefix(-1);
31675 num10++;
31676 if (flag && genRand.Next(5) == 0)
31677 {
31678 chest.item[num10].SetDefaults(3199);
31679 num10++;
31680 }
31681 if (flag2)
31682 {
31683 if (genRand.Next(7) == 0)
31684 {
31685 chest.item[num10].SetDefaults(4346);
31686 num10++;
31687 }
31688 if (genRand.Next(15) == 0)
31689 {
31690 chest.item[num10].SetDefaults(4066);
31691 num10++;
31692 }
31693 }
31694 if (flag3 && genRand.Next(6) == 0)
31695 {
31696 chest.item[num10++].SetDefaults(3360);
31697 chest.item[num10++].SetDefaults(3361);
31698 }
31699 if (flag3 && genRand.Next(10) == 0)
31700 {
31701 chest.item[num10++].SetDefaults(4426);
31702 }
31703 if (flag4)
31704 {
31705 if (genRand.Next(2) == 0)
31706 {
31707 chest.item[num10++].SetDefaults(4425);
31708 }
31709 if (genRand.Next(2) == 0)
31710 {
31711 chest.item[num10++].SetDefaults(4460);
31712 }
31713 }
31714 if (flag8 && (!GenVars.generatedShadowKey || genRand.Next(3) == 0))
31715 {
31716 GenVars.generatedShadowKey = true;
31717 chest.item[num10].SetDefaults(329);
31718 num10++;
31719 }
31720 }
31721 else
31722 {
31723 int num21 = genRand.Next(7);
31724 bool flag14 = num7 > GenVars.lavaLine;
31725 if (remixWorldGen)
31726 {
31727 flag14 = (double)num7 > Main.worldSurface && (double)num7 < Main.rockLayer;
31728 }
31729 int maxValue = 20;
31730 if (tenthAnniversaryWorldGen)
31731 {
31732 maxValue = 15;
31733 }
31734 if (genRand.Next(maxValue) == 0 && flag14)
31735 {
31736 chest.item[num10].SetDefaults(906);
31737 chest.item[num10].Prefix(-1);
31738 }
31739 else if (genRand.Next(15) == 0)
31740 {
31741 chest.item[num10].SetDefaults(997);
31742 chest.item[num10].Prefix(-1);
31743 }
31744 else
31745 {
31746 if (num21 == 0)
31747 {
31748 chest.item[num10].SetDefaults(49);
31749 chest.item[num10].Prefix(-1);
31750 }
31751 if (num21 == 1)
31752 {
31753 chest.item[num10].SetDefaults(50);
31754 chest.item[num10].Prefix(-1);
31755 }
31756 if (num21 == 2)
31757 {
31758 chest.item[num10].SetDefaults(53);
31759 chest.item[num10].Prefix(-1);
31760 }
31761 if (num21 == 3)
31762 {
31763 chest.item[num10].SetDefaults(54);
31764 chest.item[num10].Prefix(-1);
31765 }
31766 if (num21 == 4)
31767 {
31768 chest.item[num10].SetDefaults(5011);
31769 chest.item[num10].Prefix(-1);
31770 }
31771 if (num21 == 5)
31772 {
31773 chest.item[num10].SetDefaults(975);
31774 chest.item[num10].Prefix(-1);
31775 }
31776 if (num21 == 6)
31777 {
31778 chest.item[num10].SetDefaults(930);
31779 chest.item[num10].Prefix(-1);
31780 num10++;
31781 chest.item[num10].SetDefaults(931);
31782 chest.item[num10].stack = genRand.Next(26) + 25;
31783 }
31784 }
31785 num10++;
31786 if (flag6)
31787 {
31788 if (genRand.Next(2) == 0)
31789 {
31790 chest.item[num10].SetDefaults(4450);
31791 num10++;
31792 }
31793 else
31794 {
31795 chest.item[num10].SetDefaults(4779);
31796 num10++;
31797 chest.item[num10].SetDefaults(4780);
31798 num10++;
31799 chest.item[num10].SetDefaults(4781);
31800 num10++;
31801 }
31802 }
31803 }
31804 if (genRand.Next(5) == 0)
31805 {
31806 chest.item[num10].SetDefaults(43);
31807 num10++;
31808 }
31809 if (genRand.Next(3) == 0)
31810 {
31811 chest.item[num10].SetDefaults(167);
31812 num10++;
31813 }
31814 if (genRand.Next(4) == 0)
31815 {
31816 chest.item[num10].SetDefaults(51);
31817 chest.item[num10].stack = genRand.Next(26) + 25;
31818 num10++;
31819 }
31820 if (genRand.Next(2) == 0)
31821 {
31822 int num22 = genRand.Next(2);
31823 int stack16 = genRand.Next(8) + 3;
31824 if (num22 == 0)
31825 {
31827 }
31828 if (num22 == 1)
31829 {
31831 }
31832 chest.item[num10].stack = stack16;
31833 num10++;
31834 }
31835 if (genRand.Next(2) == 0)
31836 {
31837 int num23 = genRand.Next(2);
31838 int stack17 = genRand.Next(26) + 25;
31839 if (num23 == 0)
31840 {
31841 chest.item[num10].SetDefaults(41);
31842 }
31843 if (num23 == 1)
31844 {
31845 chest.item[num10].SetDefaults(279);
31846 }
31847 chest.item[num10].stack = stack17;
31848 num10++;
31849 }
31850 if (genRand.Next(2) == 0)
31851 {
31852 int stack18 = genRand.Next(3) + 3;
31853 chest.item[num10].SetDefaults(188);
31854 chest.item[num10].stack = stack18;
31855 num10++;
31856 }
31857 if (genRand.Next(3) > 0)
31858 {
31859 int num24 = genRand.Next(6);
31860 int stack19 = genRand.Next(1, 3);
31861 if (num24 == 0)
31862 {
31863 chest.item[num10].SetDefaults(296);
31864 }
31865 if (num24 == 1)
31866 {
31867 chest.item[num10].SetDefaults(295);
31868 }
31869 if (num24 == 2)
31870 {
31871 chest.item[num10].SetDefaults(299);
31872 }
31873 if (num24 == 3)
31874 {
31875 chest.item[num10].SetDefaults(302);
31876 }
31877 if (num24 == 4)
31878 {
31879 chest.item[num10].SetDefaults(303);
31880 }
31881 if (num24 == 5)
31882 {
31883 chest.item[num10].SetDefaults(305);
31884 }
31885 chest.item[num10].stack = stack19;
31886 num10++;
31887 }
31888 if (genRand.Next(3) > 1)
31889 {
31890 int num25 = genRand.Next(6);
31891 int stack20 = genRand.Next(1, 3);
31892 if (num25 == 0)
31893 {
31894 chest.item[num10].SetDefaults(301);
31895 }
31896 if (num25 == 1)
31897 {
31898 chest.item[num10].SetDefaults(297);
31899 }
31900 if (num25 == 2)
31901 {
31902 chest.item[num10].SetDefaults(304);
31903 }
31904 if (num25 == 3)
31905 {
31906 chest.item[num10].SetDefaults(2329);
31907 }
31908 if (num25 == 4)
31909 {
31910 chest.item[num10].SetDefaults(2351);
31911 }
31912 if (num25 == 5)
31913 {
31914 chest.item[num10].SetDefaults(2326);
31915 }
31916 chest.item[num10].stack = stack20;
31917 num10++;
31918 }
31919 if (genRand.Next(2) == 0)
31920 {
31921 int stack21 = genRand.Next(2, 5);
31922 chest.item[num10].SetDefaults(2350);
31923 chest.item[num10].stack = stack21;
31924 num10++;
31925 }
31926 if (genRand.Next(2) == 0)
31927 {
31928 int num26 = genRand.Next(2);
31929 int stack22 = genRand.Next(15) + 15;
31930 if (num26 == 0)
31931 {
31932 if (num9 == 11)
31933 {
31934 chest.item[num10].SetDefaults(974);
31935 }
31936 else
31937 {
31938 chest.item[num10].SetDefaults(8);
31939 }
31940 }
31941 if (num26 == 1)
31942 {
31943 chest.item[num10].SetDefaults(282);
31944 }
31945 chest.item[num10].stack = stack22;
31946 num10++;
31947 }
31948 if (genRand.Next(2) == 0)
31949 {
31950 chest.item[num10].SetDefaults(73);
31951 chest.item[num10].stack = genRand.Next(1, 3);
31952 num10++;
31953 }
31954 }
31955 else
31956 {
31957 if (contain > 0)
31958 {
31959 chest.item[num10].SetDefaults(contain);
31960 chest.item[num10].Prefix(-1);
31961 num10++;
31962 if (flag7 && genRand.Next(5) == 0)
31963 {
31964 chest.item[num10].SetDefaults(5010);
31965 num10++;
31966 }
31967 if (flag7 && genRand.Next(10) == 0)
31968 {
31969 chest.item[num10].SetDefaults(4443);
31970 num10++;
31971 }
31972 if (flag7 && genRand.Next(10) == 0)
31973 {
31974 chest.item[num10].SetDefaults(4737);
31975 num10++;
31976 }
31977 if (flag7 && genRand.Next(10) == 0)
31978 {
31979 chest.item[num10].SetDefaults(4551);
31980 num10++;
31981 }
31982 }
31983 else
31984 {
31985 int num27 = genRand.Next(4);
31986 if (num27 == 0)
31987 {
31988 chest.item[num10].SetDefaults(49);
31989 chest.item[num10].Prefix(-1);
31990 }
31991 if (num27 == 1)
31992 {
31993 chest.item[num10].SetDefaults(50);
31994 chest.item[num10].Prefix(-1);
31995 }
31996 if (num27 == 2)
31997 {
31998 chest.item[num10].SetDefaults(53);
31999 chest.item[num10].Prefix(-1);
32000 }
32001 if (num27 == 3)
32002 {
32003 chest.item[num10].SetDefaults(54);
32004 chest.item[num10].Prefix(-1);
32005 }
32006 num10++;
32007 }
32008 if (genRand.Next(3) == 0)
32009 {
32010 chest.item[num10].SetDefaults(167);
32011 num10++;
32012 }
32013 if (genRand.Next(2) == 0)
32014 {
32015 int num28 = genRand.Next(2);
32016 int stack23 = genRand.Next(15) + 15;
32017 if (num28 == 0)
32018 {
32019 chest.item[num10].SetDefaults(117);
32020 }
32021 if (num28 == 1)
32022 {
32024 }
32025 chest.item[num10].stack = stack23;
32026 num10++;
32027 }
32028 if (genRand.Next(2) == 0)
32029 {
32030 int num29 = genRand.Next(2);
32031 int stack24 = genRand.Next(25) + 50;
32032 if (num29 == 0)
32033 {
32034 chest.item[num10].SetDefaults(265);
32035 }
32036 if (num29 == 1)
32037 {
32038 if (SavedOreTiers.Silver == 168)
32039 {
32040 chest.item[num10].SetDefaults(4915);
32041 }
32042 else
32043 {
32044 chest.item[num10].SetDefaults(278);
32045 }
32046 }
32047 chest.item[num10].stack = stack24;
32048 num10++;
32049 }
32050 if (genRand.Next(2) == 0)
32051 {
32052 int stack25 = genRand.Next(6) + 15;
32053 chest.item[num10].SetDefaults(227);
32054 chest.item[num10].stack = stack25;
32055 num10++;
32056 }
32057 if (genRand.Next(4) > 0)
32058 {
32059 int num30 = genRand.Next(8);
32060 int stack26 = genRand.Next(1, 3);
32061 if (num30 == 0)
32062 {
32063 chest.item[num10].SetDefaults(296);
32064 }
32065 if (num30 == 1)
32066 {
32067 chest.item[num10].SetDefaults(295);
32068 }
32069 if (num30 == 2)
32070 {
32071 chest.item[num10].SetDefaults(293);
32072 }
32073 if (num30 == 3)
32074 {
32075 chest.item[num10].SetDefaults(288);
32076 }
32077 if (num30 == 4)
32078 {
32079 chest.item[num10].SetDefaults(294);
32080 }
32081 if (num30 == 5)
32082 {
32083 chest.item[num10].SetDefaults(297);
32084 }
32085 if (num30 == 6)
32086 {
32087 chest.item[num10].SetDefaults(304);
32088 }
32089 if (num30 == 7)
32090 {
32091 chest.item[num10].SetDefaults(2323);
32092 }
32093 chest.item[num10].stack = stack26;
32094 num10++;
32095 }
32096 if (genRand.Next(3) > 0)
32097 {
32098 int num31 = genRand.Next(8);
32099 int stack27 = genRand.Next(1, 3);
32100 if (num31 == 0)
32101 {
32102 chest.item[num10].SetDefaults(305);
32103 }
32104 if (num31 == 1)
32105 {
32106 chest.item[num10].SetDefaults(301);
32107 }
32108 if (num31 == 2)
32109 {
32110 chest.item[num10].SetDefaults(302);
32111 }
32112 if (num31 == 3)
32113 {
32114 chest.item[num10].SetDefaults(288);
32115 }
32116 if (num31 == 4)
32117 {
32118 chest.item[num10].SetDefaults(300);
32119 }
32120 if (num31 == 5)
32121 {
32122 chest.item[num10].SetDefaults(2351);
32123 }
32124 if (num31 == 6)
32125 {
32126 chest.item[num10].SetDefaults(2348);
32127 }
32128 if (num31 == 7)
32129 {
32130 chest.item[num10].SetDefaults(2345);
32131 }
32132 chest.item[num10].stack = stack27;
32133 num10++;
32134 }
32135 if (genRand.Next(3) == 0)
32136 {
32137 int stack28 = genRand.Next(1, 3);
32138 if (genRand.Next(2) == 0)
32139 {
32140 chest.item[num10].SetDefaults(2350);
32141 }
32142 else
32143 {
32144 chest.item[num10].SetDefaults(4870);
32145 }
32146 chest.item[num10].stack = stack28;
32147 num10++;
32148 }
32149 if (genRand.Next(2) == 0)
32150 {
32151 int num32 = genRand.Next(2);
32152 int stack29 = genRand.Next(15) + 15;
32153 if (num32 == 0)
32154 {
32155 chest.item[num10].SetDefaults(8);
32156 }
32157 if (num32 == 1)
32158 {
32159 chest.item[num10].SetDefaults(282);
32160 }
32161 chest.item[num10].stack = stack29;
32162 num10++;
32163 }
32164 if (genRand.Next(2) == 0)
32165 {
32166 chest.item[num10].SetDefaults(73);
32167 chest.item[num10].stack = genRand.Next(2, 5);
32168 num10++;
32169 }
32170 }
32171 if (num10 > 0 && chestTileType == 21)
32172 {
32173 if (num9 == 10 && genRand.Next(4) == 0)
32174 {
32175 chest.item[num10].SetDefaults(2204);
32176 num10++;
32177 }
32178 if (num9 == 11 && genRand.Next(7) == 0)
32179 {
32180 chest.item[num10].SetDefaults(2198);
32181 num10++;
32182 }
32183 if (flag10 && genRand.Next(3) == 0)
32184 {
32185 chest.item[num10].SetDefaults(2197);
32186 num10++;
32187 }
32188 if (flag10)
32189 {
32190 int num33 = genRand.Next(6);
32191 if (num33 == 0)
32192 {
32193 chest.item[num10].SetDefaults(5258);
32194 }
32195 if (num33 == 1)
32196 {
32197 chest.item[num10].SetDefaults(5226);
32198 }
32199 if (num33 == 2)
32200 {
32201 chest.item[num10].SetDefaults(5254);
32202 }
32203 if (num33 == 3)
32204 {
32205 chest.item[num10].SetDefaults(5238);
32206 }
32207 if (num33 == 4)
32208 {
32209 chest.item[num10].SetDefaults(5255);
32210 }
32211 if (num33 == 5)
32212 {
32213 chest.item[num10].SetDefaults(5388);
32214 }
32215 num10++;
32216 }
32217 if (flag10)
32218 {
32219 chest.item[num10].SetDefaults(751);
32220 chest.item[num10].stack = genRand.Next(50, 101);
32221 num10++;
32222 }
32223 if (num9 == 16)
32224 {
32225 chest.item[num10].SetDefaults(2195);
32226 num10++;
32227 }
32228 if (Main.wallDungeon[Main.tile[i, k].wall] && genRand.Next(8) == 0)
32229 {
32230 chest.item[num10].SetDefaults(2192);
32231 num10++;
32232 }
32233 if ((num9 == 23 || num9 == 24 || num9 == 25 || num9 == 26 || num9 == 27) && genRand.Next(2) == 0)
32234 {
32235 chest.item[num10].SetDefaults(5234);
32236 num10++;
32237 }
32238 if (num9 == 16)
32239 {
32240 if (genRand.Next(5) == 0)
32241 {
32242 chest.item[num10].SetDefaults(2767);
32243 num10++;
32244 }
32245 else
32246 {
32247 chest.item[num10].SetDefaults(2766);
32248 chest.item[num10].stack = genRand.Next(3, 8);
32249 num10++;
32250 }
32251 }
32252 }
32253 if (num10 <= 0 || chestTileType != 467)
32254 {
32255 continue;
32256 }
32257 if (flag10 && genRand.Next(3) == 0)
32258 {
32259 chest.item[num10].SetDefaults(2197);
32260 num10++;
32261 }
32262 if (flag10)
32263 {
32264 int num34 = genRand.Next(5);
32265 if (num34 == 0)
32266 {
32267 chest.item[num10].SetDefaults(5258);
32268 }
32269 if (num34 == 1)
32270 {
32271 chest.item[num10].SetDefaults(5226);
32272 }
32273 if (num34 == 2)
32274 {
32275 chest.item[num10].SetDefaults(5254);
32276 }
32277 if (num34 == 3)
32278 {
32279 chest.item[num10].SetDefaults(5238);
32280 }
32281 if (num34 == 4)
32282 {
32283 chest.item[num10].SetDefaults(5255);
32284 }
32285 num10++;
32286 }
32287 if (flag10)
32288 {
32289 chest.item[num10].SetDefaults(751);
32290 chest.item[num10].stack = genRand.Next(50, 101);
32291 num10++;
32292 }
32293 if (num9 == 13 && genRand.Next(2) == 0)
32294 {
32295 chest.item[num10].SetDefaults(5234);
32296 num10++;
32297 }
32298 }
32299 return true;
32300 }
32301 if (trySlope)
32302 {
32303 if (num2 > -1)
32304 {
32305 Main.tile[i - 1, k].slope((byte)num2);
32306 }
32307 if (num3 > -1)
32308 {
32309 Main.tile[i, k].slope((byte)num3);
32310 }
32311 }
32312 return false;
32313 }
32314 return false;
32315 }
32316
32317 public static void UnlockDoor(int i, int j)
32318 {
32319 int num = j;
32320 if (Main.tile[i, num] == null)
32321 {
32322 return;
32323 }
32324 while (Main.tile[i, num].frameY != 594)
32325 {
32326 num--;
32327 if (Main.tile[i, num].frameY < 594 || num <= 0)
32328 {
32329 return;
32330 }
32331 }
32332 SoundEngine.PlaySound(22, i * 16, num * 16 + 16);
32333 for (int k = num; k <= num + 2; k++)
32334 {
32335 if (Main.tile[i, k] == null)
32336 {
32337 Main.tile[i, k] = new Tile();
32338 }
32339 Main.tile[i, k].frameY += 54;
32340 for (int l = 0; l < 4; l++)
32341 {
32342 Dust.NewDust(new Vector2(i * 16, k * 16), 16, 16, 11);
32343 }
32344 }
32346 }
32347
32348 public static bool OpenDoor(int i, int j, int direction)
32349 {
32350 int num = 0;
32351 if (Main.tile[i, j - 1] == null)
32352 {
32353 Main.tile[i, j - 1] = new Tile();
32354 }
32355 if (Main.tile[i, j - 2] == null)
32356 {
32357 Main.tile[i, j - 2] = new Tile();
32358 }
32359 if (Main.tile[i, j + 1] == null)
32360 {
32361 Main.tile[i, j + 1] = new Tile();
32362 }
32363 if (Main.tile[i, j] == null)
32364 {
32365 Main.tile[i, j] = new Tile();
32366 }
32367 Tile tile = Main.tile[i, j];
32368 if (tile.type != 10)
32369 {
32370 return false;
32371 }
32372 if (IsLockedDoor(tile))
32373 {
32374 return false;
32375 }
32376 short num2 = 0;
32377 int num3 = tile.frameY;
32378 int num4 = 0;
32379 while (num3 >= 54)
32380 {
32381 num3 -= 54;
32382 num4++;
32383 }
32384 if (tile.frameX >= 54)
32385 {
32386 int num5 = tile.frameX / 54;
32387 num4 += 36 * num5;
32388 num2 += (short)(72 * num5);
32389 }
32390 num = j - num3 / 18;
32391 int num6 = i;
32392 TileColorCache cache = Main.tile[num6, num].BlockColorAndCoating();
32393 if (Main.tile[num6, num + 1] == null)
32394 {
32395 Main.tile[num6, num + 1] = new Tile();
32396 }
32397 TileColorCache cache2 = Main.tile[num6, num + 1].BlockColorAndCoating();
32398 if (Main.tile[num6, num + 2] == null)
32399 {
32400 Main.tile[num6, num + 2] = new Tile();
32401 }
32402 TileColorCache cache3 = Main.tile[num6, num + 2].BlockColorAndCoating();
32403 int num7;
32404 if (direction == -1)
32405 {
32406 num6 = i - 1;
32407 num2 += 36;
32408 num7 = i - 1;
32409 }
32410 else
32411 {
32412 num6 = i;
32413 num7 = i + 1;
32414 }
32415 for (int k = num; k < num + 3; k++)
32416 {
32417 if (Main.tile[num7, k] == null)
32418 {
32419 Main.tile[num7, k] = new Tile();
32420 }
32421 if (Main.tile[num7, k].active())
32422 {
32423 if (!Main.tileCut[Main.tile[num7, k].type] && Main.tile[num7, k].type != 3 && Main.tile[num7, k].type != 24 && Main.tile[num7, k].type != 52 && Main.tile[num7, k].type != 61 && Main.tile[num7, k].type != 62 && Main.tile[num7, k].type != 69 && Main.tile[num7, k].type != 655 && Main.tile[num7, k].type != 71 && Main.tile[num7, k].type != 73 && Main.tile[num7, k].type != 74 && Main.tile[num7, k].type != 110 && Main.tile[num7, k].type != 113 && Main.tile[num7, k].type != 115 && Main.tile[num7, k].type != 165)
32424 {
32425 return false;
32426 }
32427 KillTile(num7, k);
32428 }
32429 }
32430 if (Main.netMode != 1 && Wiring.running)
32431 {
32432 Wiring.SkipWire(num6, num);
32433 Wiring.SkipWire(num6, num + 1);
32434 Wiring.SkipWire(num6, num + 2);
32435 Wiring.SkipWire(num6 + 1, num);
32436 Wiring.SkipWire(num6 + 1, num + 1);
32437 Wiring.SkipWire(num6 + 1, num + 2);
32438 }
32439 int num8 = num4 % 36 * 54;
32440 SoundEngine.PlaySound(8, i * 16, j * 16);
32441 Main.tile[num6, num].active(active: true);
32442 Main.tile[num6, num].type = 11;
32443 Main.tile[num6, num].frameY = (short)num8;
32444 Main.tile[num6, num].frameX = num2;
32445 Main.tile[num6, num].UseBlockColors(cache);
32446 if (Main.tile[num6 + 1, num] == null)
32447 {
32448 Main.tile[num6 + 1, num] = new Tile();
32449 }
32450 Main.tile[num6 + 1, num].active(active: true);
32451 Main.tile[num6 + 1, num].type = 11;
32452 Main.tile[num6 + 1, num].frameY = (short)num8;
32453 Main.tile[num6 + 1, num].frameX = (short)(num2 + 18);
32454 Main.tile[num6 + 1, num].UseBlockColors(cache);
32455 if (Main.tile[num6, num + 1] == null)
32456 {
32457 Main.tile[num6, num + 1] = new Tile();
32458 }
32459 Main.tile[num6, num + 1].active(active: true);
32460 Main.tile[num6, num + 1].type = 11;
32461 Main.tile[num6, num + 1].frameY = (short)(num8 + 18);
32462 Main.tile[num6, num + 1].frameX = num2;
32463 Main.tile[num6, num + 1].UseBlockColors(cache2);
32464 if (Main.tile[num6 + 1, num + 1] == null)
32465 {
32466 Main.tile[num6 + 1, num + 1] = new Tile();
32467 }
32468 Main.tile[num6 + 1, num + 1].active(active: true);
32469 Main.tile[num6 + 1, num + 1].type = 11;
32470 Main.tile[num6 + 1, num + 1].frameY = (short)(num8 + 18);
32471 Main.tile[num6 + 1, num + 1].frameX = (short)(num2 + 18);
32472 Main.tile[num6 + 1, num + 1].UseBlockColors(cache2);
32473 if (Main.tile[num6, num + 2] == null)
32474 {
32475 Main.tile[num6, num + 2] = new Tile();
32476 }
32477 Main.tile[num6, num + 2].active(active: true);
32478 Main.tile[num6, num + 2].type = 11;
32479 Main.tile[num6, num + 2].frameY = (short)(num8 + 36);
32480 Main.tile[num6, num + 2].frameX = num2;
32481 Main.tile[num6, num + 2].UseBlockColors(cache3);
32482 if (Main.tile[num6 + 1, num + 2] == null)
32483 {
32484 Main.tile[num6 + 1, num + 2] = new Tile();
32485 }
32486 Main.tile[num6 + 1, num + 2].active(active: true);
32487 Main.tile[num6 + 1, num + 2].type = 11;
32488 Main.tile[num6 + 1, num + 2].frameY = (short)(num8 + 36);
32489 Main.tile[num6 + 1, num + 2].frameX = (short)(num2 + 18);
32490 Main.tile[num6 + 1, num + 2].UseBlockColors(cache3);
32491 for (int l = num6 - 1; l <= num6 + 2; l++)
32492 {
32493 for (int m = num - 1; m <= num + 2; m++)
32494 {
32495 TileFrame(l, m);
32496 }
32497 }
32498 return true;
32499 }
32500
32501 public static void Check1xX(int x, int j, short type)
32502 {
32503 if (destroyObject)
32504 {
32505 return;
32506 }
32507 int frameX = Main.tile[x, j].frameX;
32508 int num = 3;
32509 if (type == 92)
32510 {
32511 num = 6;
32512 }
32513 int num2 = Main.tile[x, j].frameY;
32514 int num3 = 0;
32515 while (num2 >= 18 * num)
32516 {
32517 num2 -= 18 * num;
32518 num3++;
32519 }
32520 int num4 = Main.tile[x, j].frameX / 18;
32521 int num5 = j - num2 / 18;
32522 bool flag = false;
32523 for (int i = 0; i < num; i++)
32524 {
32525 if (Main.tile[x, num5 + i] == null)
32526 {
32527 Main.tile[x, num5 + i] = new Tile();
32528 }
32529 if (!Main.tile[x, num5 + i].active())
32530 {
32531 flag = true;
32532 }
32533 else if (Main.tile[x, num5 + i].type != type)
32534 {
32535 flag = true;
32536 }
32537 else if (Main.tile[x, num5 + i].frameY != i * 18 + num3 * num * 18)
32538 {
32539 flag = true;
32540 }
32541 else if (Main.tile[x, num5 + i].frameX != frameX)
32542 {
32543 flag = true;
32544 }
32545 }
32546 if (Main.tile[x, num5 + num] == null)
32547 {
32548 Main.tile[x, num5 + num] = new Tile();
32549 }
32550 if (!SolidTileAllowBottomSlope(x, num5 + num))
32551 {
32552 flag = true;
32553 }
32554 if (!flag)
32555 {
32556 return;
32557 }
32558 destroyObject = true;
32559 for (int k = 0; k < num; k++)
32560 {
32561 if (Main.tile[x, num5 + k].type == type)
32562 {
32563 KillTile(x, num5 + k);
32564 }
32565 }
32566 if (type == 92)
32567 {
32568 Item.NewItem(GetItemSource_FromTileBreak(x, j), x * 16, j * 16, 32, 32, 341);
32569 }
32570 if (type == 453)
32571 {
32572 int num6 = 0;
32573 num6 = ((num4 < 2) ? 3744 : ((num4 >= 4) ? 3743 : 3745));
32574 Item.NewItem(GetItemSource_FromTileBreak(x, j), x * 16, j * 16, 16, 32, num6);
32575 }
32576 if (type == 93)
32577 {
32578 int type2 = 0;
32579 switch (num3)
32580 {
32581 case 0:
32582 type2 = 342;
32583 break;
32584 case 1:
32585 case 2:
32586 case 3:
32587 case 4:
32588 case 5:
32589 case 6:
32590 case 7:
32591 case 8:
32592 case 9:
32593 case 10:
32594 type2 = 2082 + num3 - 1;
32595 break;
32596 default:
32597 if (num3 >= 11 && num3 <= 16)
32598 {
32599 type2 = 2129 + num3 - 11;
32600 break;
32601 }
32602 switch (num3)
32603 {
32604 case 17:
32605 type2 = 2225;
32606 break;
32607 case 18:
32608 type2 = 2533;
32609 break;
32610 case 19:
32611 type2 = 2547;
32612 break;
32613 case 20:
32614 type2 = 2563;
32615 break;
32616 case 21:
32617 type2 = 2578;
32618 break;
32619 case 22:
32620 type2 = 2643;
32621 break;
32622 case 23:
32623 type2 = 2644;
32624 break;
32625 case 24:
32626 type2 = 2645;
32627 break;
32628 case 25:
32629 type2 = 2646;
32630 break;
32631 case 26:
32632 type2 = 2647;
32633 break;
32634 case 27:
32635 type2 = 2819;
32636 break;
32637 case 28:
32638 type2 = 3135;
32639 break;
32640 case 29:
32641 type2 = 3137;
32642 break;
32643 case 30:
32644 type2 = 3136;
32645 break;
32646 case 31:
32647 type2 = 3892;
32648 break;
32649 case 32:
32650 type2 = 3942;
32651 break;
32652 case 33:
32653 type2 = 3969;
32654 break;
32655 case 34:
32656 type2 = 4156;
32657 break;
32658 case 35:
32659 type2 = 4177;
32660 break;
32661 case 36:
32662 type2 = 4198;
32663 break;
32664 case 37:
32665 type2 = 4219;
32666 break;
32667 case 38:
32668 type2 = 4308;
32669 break;
32670 case 39:
32671 type2 = 4577;
32672 break;
32673 case 40:
32674 type2 = 5159;
32675 break;
32676 case 41:
32677 type2 = 5180;
32678 break;
32679 case 42:
32680 type2 = 5201;
32681 break;
32682 }
32683 break;
32684 }
32685 Item.NewItem(GetItemSource_FromTileBreak(x, j), x * 16, j * 16, 32, 32, type2);
32686 }
32687 destroyObject = false;
32688 }
32689
32690 public static void Check2xX(int i, int j, ushort type)
32691 {
32692 if (destroyObject)
32693 {
32694 return;
32695 }
32696 int num = i;
32697 int num2;
32698 for (num2 = Main.tile[i, j].frameX; num2 >= 36; num2 -= 36)
32699 {
32700 }
32701 if (num2 == 18)
32702 {
32703 num--;
32704 }
32705 if (Main.tile[num, j] == null)
32706 {
32707 Main.tile[num, j] = new Tile();
32708 }
32709 int num3 = Main.tile[num, j].frameY / 18;
32710 int num4 = 3;
32711 if (type == 104)
32712 {
32713 num4 = 5;
32714 }
32715 if (type == 207)
32716 {
32717 num4 = 4;
32718 }
32719 int num5 = 0;
32720 while (num3 >= num4)
32721 {
32722 num3 -= num4;
32723 num5 += num4 * 18;
32724 }
32725 int num6 = j - num3;
32726 if (type == 410 && num5 != 0)
32727 {
32728 num5 += 2;
32729 }
32730 if (Main.tile[num, num6] == null)
32731 {
32732 Main.tile[num, num6] = new Tile();
32733 }
32734 int frameX = Main.tile[num, j].frameX;
32735 int frameY = Main.tile[num, j].frameY;
32736 bool flag = false;
32737 for (int k = 0; k < num4; k++)
32738 {
32739 if (Main.tile[num, num6 + k] == null)
32740 {
32741 Main.tile[num, num6 + k] = new Tile();
32742 }
32743 if (!Main.tile[num, num6 + k].active())
32744 {
32745 flag = true;
32746 }
32747 else if (Main.tile[num, num6 + k].type != type)
32748 {
32749 flag = true;
32750 }
32751 else if (Main.tile[num, num6 + k].frameY != k * 18 + num5)
32752 {
32753 flag = true;
32754 }
32755 else if (Main.tile[num, num6 + k].frameX != frameX)
32756 {
32757 flag = true;
32758 }
32759 if (Main.tile[num + 1, num6 + k] == null)
32760 {
32761 Main.tile[num + 1, num6 + k] = new Tile();
32762 }
32763 if (!Main.tile[num + 1, num6 + k].active())
32764 {
32765 flag = true;
32766 }
32767 else if (Main.tile[num + 1, num6 + k].type != type)
32768 {
32769 flag = true;
32770 }
32771 else if (Main.tile[num + 1, num6 + k].frameY != k * 18 + num5)
32772 {
32773 flag = true;
32774 }
32775 else if (Main.tile[num + 1, num6 + k].frameX != frameX + 18)
32776 {
32777 flag = true;
32778 }
32779 }
32780 if (type == 465 || type == 531 || type == 591 || type == 592)
32781 {
32782 bool flag2 = false;
32783 for (int l = 0; l < 2; l++)
32784 {
32785 bool flag3 = false;
32786 Tile tileSafely = Framing.GetTileSafely(num + l, num6 - 1);
32787 if (type != 531 && tileSafely.type == 380)
32788 {
32789 flag3 = true;
32790 }
32791 else if (type != 531 && TileID.Sets.Platforms[tileSafely.type])
32792 {
32793 if (l == 0)
32794 {
32795 flag2 = IsBelowANonHammeredPlatform(num + l, num6);
32796 flag3 = true;
32797 }
32798 else if (flag2 == IsBelowANonHammeredPlatform(num + l, num6))
32799 {
32800 flag3 = true;
32801 }
32802 }
32803 else
32804 {
32805 flag3 = SolidTileAllowTopSlope(num + l, num6 - 1);
32806 }
32807 if (!flag3)
32808 {
32809 flag = true;
32810 break;
32811 }
32812 }
32813 }
32814 else
32815 {
32816 if (!SolidTileAllowBottomSlope(num, num6 + num4))
32817 {
32818 flag = true;
32819 }
32820 if (!SolidTileAllowBottomSlope(num + 1, num6 + num4))
32821 {
32822 flag = true;
32823 }
32824 }
32825 if (!flag)
32826 {
32827 return;
32828 }
32829 destroyObject = true;
32830 for (int m = 0; m < num4; m++)
32831 {
32832 if (Main.tile[num, num6 + m].type == type)
32833 {
32834 KillTile(num, num6 + m);
32835 }
32836 if (Main.tile[num + 1, num6 + m].type == type)
32837 {
32838 KillTile(num + 1, num6 + m);
32839 }
32840 }
32841 if (type == 104)
32842 {
32843 int num7 = frameX / 36;
32844 int num8 = 0;
32845 if (num7 >= 1 && num7 <= 5)
32846 {
32847 num8 = 2237 + num7 - 1;
32848 }
32849 else
32850 {
32851 switch (num7)
32852 {
32853 case 6:
32854 num8 = 2560;
32855 break;
32856 case 7:
32857 num8 = 2575;
32858 break;
32859 case 8:
32860 case 9:
32861 case 10:
32862 case 11:
32863 case 12:
32864 case 13:
32865 case 14:
32866 case 15:
32867 case 16:
32868 case 17:
32869 case 18:
32870 case 19:
32871 case 20:
32872 case 21:
32873 case 22:
32874 case 23:
32875 num8 = 2591 + num7 - 8;
32876 break;
32877 default:
32878 num8 = num7 switch
32879 {
32880 24 => 2809,
32881 25 => 3126,
32882 26 => 3128,
32883 27 => 3127,
32884 28 => 3898,
32885 29 => 3899,
32886 30 => 3900,
32887 31 => 3901,
32888 32 => 3902,
32889 33 => 3940,
32890 34 => 3966,
32891 35 => 4154,
32892 36 => 4175,
32893 37 => 4196,
32894 38 => 4217,
32895 39 => 4306,
32896 40 => 4575,
32897 41 => 5157,
32898 42 => 5178,
32899 43 => 5199,
32900 _ => 359,
32901 };
32902 break;
32903 }
32904 }
32905 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num8);
32906 }
32907 if (type == 105)
32908 {
32909 int num9 = frameX / 36;
32910 int num10 = frameY / 54;
32911 num10 %= 3;
32912 num9 += num10 * 55;
32913 switch (num9)
32914 {
32915 case 0:
32916 num9 = 360;
32917 break;
32918 case 1:
32919 num9 = 52;
32920 break;
32921 case 43:
32922 num9 = 1152;
32923 break;
32924 case 44:
32925 num9 = 1153;
32926 break;
32927 case 45:
32928 num9 = 1154;
32929 break;
32930 case 46:
32931 num9 = 1408;
32932 break;
32933 case 47:
32934 num9 = 1409;
32935 break;
32936 case 48:
32937 num9 = 1410;
32938 break;
32939 case 49:
32940 num9 = 1462;
32941 break;
32942 case 50:
32943 num9 = 2672;
32944 break;
32945 case 51:
32946 case 52:
32947 case 53:
32948 case 54:
32949 case 55:
32950 case 56:
32951 case 57:
32952 case 58:
32953 case 59:
32954 case 60:
32955 case 61:
32956 case 62:
32957 num9 = 3651 + num9 - 51;
32958 break;
32959 default:
32960 num9 = ((num9 >= 63 && num9 <= 75) ? (3708 + num9 - 63) : (num9 switch
32961 {
32962 76 => 4397,
32963 77 => 4360,
32964 78 => 4342,
32965 79 => 4466,
32966 80 => 5317,
32967 81 => 5318,
32968 82 => 5319,
32969 _ => 438 + num9 - 2,
32970 }));
32971 break;
32972 }
32973 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num9);
32974 }
32975 if (type == 356)
32976 {
32977 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 3064);
32978 }
32979 if (type == 663)
32980 {
32981 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 5381);
32982 }
32983 if (type == 456)
32984 {
32985 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 3748);
32986 }
32987 if (type == 337)
32988 {
32989 int num11 = frameX / 36;
32990 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 2702 + num11);
32991 }
32992 if (type == 207)
32993 {
32994 int num12 = frameX / 36;
32995 switch (num12)
32996 {
32997 case 0:
32998 num12 = 909;
32999 break;
33000 case 1:
33001 num12 = 910;
33002 break;
33003 case 2:
33004 case 3:
33005 case 4:
33006 case 5:
33007 case 6:
33008 case 7:
33009 num12 = 938 + num12;
33010 break;
33011 default:
33012 switch (num12)
33013 {
33014 case 8:
33015 num12 = 4922;
33016 break;
33017 case 9:
33018 num12 = 4417;
33019 break;
33020 }
33021 break;
33022 }
33023 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num12);
33024 }
33025 if (type == 410)
33026 {
33027 int num13 = frameX / 36;
33028 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num13 + 3536);
33029 }
33030 if (type == 480)
33031 {
33032 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4054);
33033 }
33034 if (type == 509)
33035 {
33036 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4318);
33037 }
33038 if (type == 657)
33039 {
33040 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 5345);
33041 }
33042 if (type == 658)
33043 {
33044 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 5347);
33045 }
33046 if (type == 489)
33047 {
33048 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4074);
33049 }
33050 if (type == 320)
33051 {
33052 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 2496);
33053 }
33054 if (type == 349)
33055 {
33056 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 470);
33057 }
33058 if (type == 506)
33059 {
33060 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4276);
33061 }
33062 if (type == 545)
33063 {
33064 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4420);
33065 }
33066 if (type == 465)
33067 {
33068 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 3815);
33069 }
33070 if (type == 531)
33071 {
33072 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4355);
33073 }
33074 if (type == 378)
33075 {
33076 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 48, 3202);
33078 }
33079 if (type == 560)
33080 {
33081 int num14 = frameX / 36;
33082 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num14 + 4599);
33083 }
33084 if (type == 591)
33085 {
33086 int num15 = frameX / 36;
33087 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, num15 + 4858);
33088 }
33089 if (type == 592)
33090 {
33091 Item.NewItem(GetItemSource_FromTileBreak(num, j), num * 16, j * 16, 32, 32, 4867);
33092 }
33093 destroyObject = false;
33094 }
33095
33096 public static bool IsBelowANonHammeredPlatform(int x, int y)
33097 {
33098 if (y < 1)
33099 {
33100 return false;
33101 }
33102 Tile tile = Main.tile[x, y - 1];
33103 if (tile == null || !tile.active() || !TileID.Sets.Platforms[tile.type] || tile.halfBrick() || tile.slope() != 0)
33104 {
33105 return false;
33106 }
33107 return true;
33108 }
33109
33110 public static void PlaceTight(int x, int y, bool spiders = false)
33111 {
33112 if (Main.tile[x, y - 1] == null)
33113 {
33114 Main.tile[x, y - 1] = new Tile();
33115 }
33116 if (Main.tile[x, y] == null)
33117 {
33118 Main.tile[x, y] = new Tile();
33119 }
33120 if (Main.tile[x, y + 1] == null)
33121 {
33122 Main.tile[x, y + 1] = new Tile();
33123 }
33124 if (!Main.tile[x, y].shimmer())
33125 {
33126 PlaceUncheckedStalactite(x, y, genRand.Next(2) == 0, genRand.Next(3), spiders);
33127 if (Main.tile[x, y].type == 165)
33128 {
33129 CheckTight(x, y);
33130 }
33131 }
33132 }
33133
33134 public static void PlaceUncheckedStalactite(int x, int y, bool preferSmall, int variation, bool spiders)
33135 {
33136 ushort type = 165;
33137 variation = Utils.Clamp(variation, 0, 2);
33138 if (SolidTile(x, y - 1) && !Main.tile[x, y].active() && !Main.tile[x, y + 1].active())
33139 {
33140 if (spiders)
33141 {
33142 int num = 108 + variation * 18;
33143 Main.tile[x, y].type = type;
33144 Main.tile[x, y].active(active: true);
33145 Main.tile[x, y].frameX = (short)num;
33146 Main.tile[x, y].frameY = 0;
33147 Main.tile[x, y + 1].type = type;
33148 Main.tile[x, y + 1].active(active: true);
33149 Main.tile[x, y + 1].frameX = (short)num;
33150 Main.tile[x, y + 1].frameY = 18;
33151 return;
33152 }
33153 if (Main.tile[x, y - 1].type == 147 || Main.tile[x, y - 1].type == 161 || Main.tile[x, y - 1].type == 163 || Main.tile[x, y - 1].type == 164 || Main.tile[x, y - 1].type == 200)
33154 {
33155 if (preferSmall)
33156 {
33157 int num2 = variation * 18;
33158 Main.tile[x, y].type = type;
33159 Main.tile[x, y].active(active: true);
33160 Main.tile[x, y].frameX = (short)num2;
33161 Main.tile[x, y].frameY = 72;
33162 }
33163 else
33164 {
33165 int num3 = variation * 18;
33166 Main.tile[x, y].type = type;
33167 Main.tile[x, y].active(active: true);
33168 Main.tile[x, y].frameX = (short)num3;
33169 Main.tile[x, y].frameY = 0;
33170 Main.tile[x, y + 1].type = type;
33171 Main.tile[x, y + 1].active(active: true);
33172 Main.tile[x, y + 1].frameX = (short)num3;
33173 Main.tile[x, y + 1].frameY = 18;
33174 }
33175 }
33176 if (Main.tile[x, y - 1].type == 1 || Main.tileMoss[Main.tile[x, y - 1].type] || Main.tile[x, y - 1].type == 117 || Main.tile[x, y - 1].type == 25 || Main.tile[x, y - 1].type == 203)
33177 {
33178 if (preferSmall)
33179 {
33180 int num4 = 54 + variation * 18;
33181 Main.tile[x, y].type = type;
33182 Main.tile[x, y].active(active: true);
33183 Main.tile[x, y].frameX = (short)num4;
33184 Main.tile[x, y].frameY = 72;
33185 }
33186 else
33187 {
33188 int num5 = 54 + variation * 18;
33189 Main.tile[x, y].type = type;
33190 Main.tile[x, y].active(active: true);
33191 Main.tile[x, y].frameX = (short)num5;
33192 Main.tile[x, y].frameY = 0;
33193 Main.tile[x, y + 1].type = type;
33194 Main.tile[x, y + 1].active(active: true);
33195 Main.tile[x, y + 1].frameX = (short)num5;
33196 Main.tile[x, y + 1].frameY = 18;
33197 }
33198 }
33199 if (Main.tile[x, y - 1].type == 225)
33200 {
33201 int num6 = 162 + variation * 18;
33202 Main.tile[x, y].type = type;
33203 Main.tile[x, y].active(active: true);
33204 Main.tile[x, y].frameX = (short)num6;
33205 Main.tile[x, y].frameY = 72;
33206 }
33207 if (Main.tile[x, y - 1].type == 396 || Main.tile[x, y - 1].type == 397)
33208 {
33209 if (preferSmall)
33210 {
33211 int num7 = 378 + variation * 18;
33212 Main.tile[x, y].type = type;
33213 Main.tile[x, y].active(active: true);
33214 Main.tile[x, y].frameX = (short)num7;
33215 Main.tile[x, y].frameY = 72;
33216 }
33217 else
33218 {
33219 int num8 = 378 + variation * 18;
33220 Main.tile[x, y].type = type;
33221 Main.tile[x, y].active(active: true);
33222 Main.tile[x, y].frameX = (short)num8;
33223 Main.tile[x, y].frameY = 0;
33224 Main.tile[x, y + 1].type = type;
33225 Main.tile[x, y + 1].active(active: true);
33226 Main.tile[x, y + 1].frameX = (short)num8;
33227 Main.tile[x, y + 1].frameY = 18;
33228 }
33229 }
33230 if (Main.tile[x, y - 1].type == 368)
33231 {
33232 if (preferSmall)
33233 {
33234 int num9 = 432 + variation * 18;
33235 Main.tile[x, y].type = type;
33236 Main.tile[x, y].active(active: true);
33237 Main.tile[x, y].frameX = (short)num9;
33238 Main.tile[x, y].frameY = 72;
33239 }
33240 else
33241 {
33242 int num10 = 432 + variation * 18;
33243 Main.tile[x, y].type = type;
33244 Main.tile[x, y].active(active: true);
33245 Main.tile[x, y].frameX = (short)num10;
33246 Main.tile[x, y].frameY = 0;
33247 Main.tile[x, y + 1].type = type;
33248 Main.tile[x, y + 1].active(active: true);
33249 Main.tile[x, y + 1].frameX = (short)num10;
33250 Main.tile[x, y + 1].frameY = 18;
33251 }
33252 }
33253 if (Main.tile[x, y - 1].type == 367)
33254 {
33255 if (preferSmall)
33256 {
33257 int num11 = 486 + variation * 18;
33258 Main.tile[x, y].type = type;
33259 Main.tile[x, y].active(active: true);
33260 Main.tile[x, y].frameX = (short)num11;
33261 Main.tile[x, y].frameY = 72;
33262 }
33263 else
33264 {
33265 int num12 = 486 + variation * 18;
33266 Main.tile[x, y].type = type;
33267 Main.tile[x, y].active(active: true);
33268 Main.tile[x, y].frameX = (short)num12;
33269 Main.tile[x, y].frameY = 0;
33270 Main.tile[x, y + 1].type = type;
33271 Main.tile[x, y + 1].active(active: true);
33272 Main.tile[x, y + 1].frameX = (short)num12;
33273 Main.tile[x, y + 1].frameY = 18;
33274 }
33275 }
33276 }
33277 else
33278 {
33279 if (spiders || !SolidTile(x, y + 1) || Main.tile[x, y].active() || Main.tile[x, y - 1].active())
33280 {
33281 return;
33282 }
33283 if (Main.tile[x, y + 1].type == 1 || Main.tileMoss[Main.tile[x, y + 1].type] || Main.tile[x, y - 1].type == 117 || Main.tile[x, y - 1].type == 25 || Main.tile[x, y - 1].type == 203)
33284 {
33285 if (preferSmall)
33286 {
33287 int num13 = 54 + variation * 18;
33288 Main.tile[x, y].type = type;
33289 Main.tile[x, y].active(active: true);
33290 Main.tile[x, y].frameX = (short)num13;
33291 Main.tile[x, y].frameY = 90;
33292 }
33293 else
33294 {
33295 int num14 = 54 + variation * 18;
33296 Main.tile[x, y - 1].type = type;
33297 Main.tile[x, y - 1].active(active: true);
33298 Main.tile[x, y - 1].frameX = (short)num14;
33299 Main.tile[x, y - 1].frameY = 36;
33300 Main.tile[x, y].type = type;
33301 Main.tile[x, y].active(active: true);
33302 Main.tile[x, y].frameX = (short)num14;
33303 Main.tile[x, y].frameY = 54;
33304 }
33305 }
33306 if (Main.tile[x, y + 1].type == 225)
33307 {
33308 int num15 = 162 + variation * 18;
33309 Main.tile[x, y].type = type;
33310 Main.tile[x, y].active(active: true);
33311 Main.tile[x, y].frameX = (short)num15;
33312 Main.tile[x, y].frameY = 90;
33313 }
33314 if (Main.tile[x, y + 1].type == 396 || Main.tile[x, y + 1].type == 397)
33315 {
33316 if (preferSmall)
33317 {
33318 int num16 = 378 + variation * 18;
33319 Main.tile[x, y].type = type;
33320 Main.tile[x, y].active(active: true);
33321 Main.tile[x, y].frameX = (short)num16;
33322 Main.tile[x, y].frameY = 90;
33323 }
33324 else
33325 {
33326 int num17 = 378 + variation * 18;
33327 Main.tile[x, y - 1].type = type;
33328 Main.tile[x, y - 1].active(active: true);
33329 Main.tile[x, y - 1].frameX = (short)num17;
33330 Main.tile[x, y - 1].frameY = 36;
33331 Main.tile[x, y].type = type;
33332 Main.tile[x, y].active(active: true);
33333 Main.tile[x, y].frameX = (short)num17;
33334 Main.tile[x, y].frameY = 54;
33335 }
33336 }
33337 if (Main.tile[x, y + 1].type == 368)
33338 {
33339 if (preferSmall)
33340 {
33341 int num18 = 432 + variation * 18;
33342 Main.tile[x, y].type = type;
33343 Main.tile[x, y].active(active: true);
33344 Main.tile[x, y].frameX = (short)num18;
33345 Main.tile[x, y].frameY = 90;
33346 }
33347 else
33348 {
33349 int num19 = 432 + variation * 18;
33350 Main.tile[x, y - 1].type = type;
33351 Main.tile[x, y - 1].active(active: true);
33352 Main.tile[x, y - 1].frameX = (short)num19;
33353 Main.tile[x, y - 1].frameY = 36;
33354 Main.tile[x, y].type = type;
33355 Main.tile[x, y].active(active: true);
33356 Main.tile[x, y].frameX = (short)num19;
33357 Main.tile[x, y].frameY = 54;
33358 }
33359 }
33360 if (Main.tile[x, y + 1].type == 367)
33361 {
33362 if (preferSmall)
33363 {
33364 int num20 = 486 + variation * 18;
33365 Main.tile[x, y].type = type;
33366 Main.tile[x, y].active(active: true);
33367 Main.tile[x, y].frameX = (short)num20;
33368 Main.tile[x, y].frameY = 90;
33369 }
33370 else
33371 {
33372 int num21 = 486 + variation * 18;
33373 Main.tile[x, y - 1].type = type;
33374 Main.tile[x, y - 1].active(active: true);
33375 Main.tile[x, y - 1].frameX = (short)num21;
33376 Main.tile[x, y - 1].frameY = 36;
33377 Main.tile[x, y].type = type;
33378 Main.tile[x, y].active(active: true);
33379 Main.tile[x, y].frameX = (short)num21;
33380 Main.tile[x, y].frameY = 54;
33381 }
33382 }
33383 }
33384 }
33385
33386 public static bool UpdateStalagtiteStyle(int x, int j)
33387 {
33388 if (Main.netMode == 1)
33389 {
33390 return true;
33391 }
33392 if (Main.tile[x, j] == null)
33393 {
33394 return true;
33395 }
33396 GetStalagtiteStyle(x, j, out var style, out var fail);
33397 if (fail)
33398 {
33399 return false;
33400 }
33401 GetDesiredStalagtiteStyle(x, j, out var fail2, out var desiredStyle, out var height, out var y);
33402 if (fail2)
33403 {
33404 return false;
33405 }
33406 if (style != desiredStyle)
33407 {
33408 int num = genRand.Next(3) * 18;
33409 switch (desiredStyle)
33410 {
33411 case 0:
33412 num += 54;
33413 break;
33414 case 1:
33415 num += 216;
33416 break;
33417 case 2:
33418 num += 270;
33419 break;
33420 case 3:
33421 num += 324;
33422 break;
33423 case 4:
33424 num += 378;
33425 break;
33426 case 5:
33427 num += 432;
33428 break;
33429 case 6:
33430 num += 486;
33431 break;
33432 case 7:
33433 num = num;
33434 break;
33435 case 8:
33436 num += 540;
33437 break;
33438 case 9:
33439 num += 594;
33440 break;
33441 case 10:
33442 num += 648;
33443 break;
33444 }
33445 for (int i = y; i < y + height; i++)
33446 {
33447 Main.tile[x, i].frameX = (short)num;
33448 }
33449 if (Main.netMode == 2)
33450 {
33451 NetMessage.SendTileSquare(-1, x, y, 1, 2);
33452 }
33453 }
33454 return true;
33455 }
33456
33457 private static void GetDesiredStalagtiteStyle(int x, int j, out bool fail, out int desiredStyle, out int height, out int y)
33458 {
33459 fail = false;
33460 desiredStyle = 0;
33461 height = 1;
33462 y = j;
33463 if (Main.tile[x, y].frameY == 72)
33464 {
33465 desiredStyle = Main.tile[x, y - 1].type;
33466 }
33467 else if (Main.tile[x, y].frameY == 90)
33468 {
33469 desiredStyle = Main.tile[x, y + 1].type;
33470 }
33471 else if (Main.tile[x, y].frameY >= 36)
33472 {
33473 if (Main.tile[x, y].frameY == 54)
33474 {
33475 y--;
33476 }
33477 height = 2;
33478 desiredStyle = Main.tile[x, y + 2].type;
33479 }
33480 else
33481 {
33482 if (Main.tile[x, y].frameY == 18)
33483 {
33484 y--;
33485 }
33486 height = 2;
33487 desiredStyle = Main.tile[x, y - 1].type;
33488 }
33490 {
33491 desiredStyle = 0;
33492 }
33493 else if (desiredStyle == 200)
33494 {
33495 desiredStyle = 10;
33496 }
33497 else if (desiredStyle == 164)
33498 {
33499 desiredStyle = 8;
33500 }
33501 else if (desiredStyle == 163)
33502 {
33503 desiredStyle = 9;
33504 }
33505 else if (desiredStyle == 117 || desiredStyle == 402 || desiredStyle == 403)
33506 {
33507 desiredStyle = 1;
33508 }
33509 else if (desiredStyle == 25 || desiredStyle == 398 || desiredStyle == 400)
33510 {
33511 desiredStyle = 2;
33512 }
33513 else if (desiredStyle == 203 || desiredStyle == 399 || desiredStyle == 401)
33514 {
33515 desiredStyle = 3;
33516 }
33517 else if (desiredStyle == 396 || desiredStyle == 397)
33518 {
33519 desiredStyle = 4;
33520 }
33521 else if (desiredStyle == 367)
33522 {
33523 desiredStyle = 6;
33524 }
33525 else if (desiredStyle == 368)
33526 {
33527 desiredStyle = 5;
33528 }
33529 else if (desiredStyle == 161 || desiredStyle == 147)
33530 {
33531 desiredStyle = 7;
33532 }
33533 else
33534 {
33535 fail = true;
33536 }
33537 }
33538
33539 private static void GetStalagtiteStyle(int x, int y, out int style, out bool fail)
33540 {
33541 style = 0;
33542 fail = false;
33543 switch (Main.tile[x, y].frameX / 54)
33544 {
33545 default:
33546 fail = true;
33547 break;
33548 case 0:
33549 style = 7;
33550 break;
33551 case 1:
33552 style = 0;
33553 break;
33554 case 4:
33555 style = 1;
33556 break;
33557 case 5:
33558 style = 2;
33559 break;
33560 case 6:
33561 style = 3;
33562 break;
33563 case 7:
33564 style = 4;
33565 break;
33566 case 8:
33567 style = 5;
33568 break;
33569 case 9:
33570 style = 6;
33571 break;
33572 case 10:
33573 style = 8;
33574 break;
33575 case 11:
33576 style = 9;
33577 break;
33578 case 12:
33579 style = 10;
33580 break;
33581 }
33582 }
33583
33584 public static void CheckTight(int x, int j)
33585 {
33586 if (Main.tile[x, j] == null)
33587 {
33588 return;
33589 }
33590 int num = j;
33591 if (Main.tile[x, num].frameY == 72)
33592 {
33593 if (Main.tile[x, num - 1] == null)
33594 {
33595 Main.tile[x, num - 1] = new Tile();
33596 }
33597 if (Main.tile[x, num] == null)
33598 {
33599 Main.tile[x, num] = new Tile();
33600 }
33601 if (Main.tile[x, num + 1] == null)
33602 {
33603 Main.tile[x, num + 1] = new Tile();
33604 }
33605 bool flag = false;
33606 if (!SolidTile(x, num - 1))
33607 {
33608 flag = true;
33609 }
33610 if (!flag && !UpdateStalagtiteStyle(x, num))
33611 {
33612 flag = true;
33613 }
33614 if (flag)
33615 {
33616 destroyObject = true;
33617 if (Main.tile[x, num].type == Main.tile[x, j].type)
33618 {
33619 KillTile(x, num);
33620 }
33621 destroyObject = false;
33622 }
33623 return;
33624 }
33625 if (Main.tile[x, num].frameY == 90)
33626 {
33627 if (Main.tile[x, num - 1] == null)
33628 {
33629 Main.tile[x, num - 1] = new Tile();
33630 }
33631 if (Main.tile[x, num] == null)
33632 {
33633 Main.tile[x, num] = new Tile();
33634 }
33635 if (Main.tile[x, num + 1] == null)
33636 {
33637 Main.tile[x, num + 1] = new Tile();
33638 }
33639 bool flag2 = false;
33640 if (!SolidTile(x, num + 1))
33641 {
33642 flag2 = true;
33643 }
33644 if (!flag2 && !UpdateStalagtiteStyle(x, num))
33645 {
33646 flag2 = true;
33647 }
33648 if (flag2)
33649 {
33650 destroyObject = true;
33651 if (Main.tile[x, num].type == Main.tile[x, j].type)
33652 {
33653 KillTile(x, num);
33654 }
33655 destroyObject = false;
33656 }
33657 return;
33658 }
33659 if (Main.tile[x, num].frameY >= 36)
33660 {
33661 if (Main.tile[x, num].frameY == 54)
33662 {
33663 num--;
33664 }
33665 if (Main.tile[x, num] == null)
33666 {
33667 Main.tile[x, num] = new Tile();
33668 }
33669 if (Main.tile[x, num + 1] == null)
33670 {
33671 Main.tile[x, num + 1] = new Tile();
33672 }
33673 if (Main.tile[x, num + 2] == null)
33674 {
33675 Main.tile[x, num + 2] = new Tile();
33676 }
33677 bool flag3 = false;
33678 if (!SolidTile(x, num + 2))
33679 {
33680 flag3 = true;
33681 }
33682 if (Main.tile[x, num + 1].type != Main.tile[x, num].type)
33683 {
33684 flag3 = true;
33685 }
33686 if (Main.tile[x, num + 1].frameX != Main.tile[x, num].frameX)
33687 {
33688 flag3 = true;
33689 }
33690 if (!flag3 && !UpdateStalagtiteStyle(x, num))
33691 {
33692 flag3 = true;
33693 }
33694 if (flag3)
33695 {
33696 destroyObject = true;
33697 if (Main.tile[x, num].type == Main.tile[x, j].type)
33698 {
33699 KillTile(x, num);
33700 }
33701 if (Main.tile[x, num + 1].type == Main.tile[x, j].type)
33702 {
33703 KillTile(x, num + 1);
33704 }
33705 destroyObject = false;
33706 }
33707 return;
33708 }
33709 if (Main.tile[x, num].frameY == 18)
33710 {
33711 num--;
33712 }
33713 if (Main.tile[x, num - 1] == null)
33714 {
33715 Main.tile[x, num - 1] = new Tile();
33716 }
33717 if (Main.tile[x, num] == null)
33718 {
33719 Main.tile[x, num] = new Tile();
33720 }
33721 if (Main.tile[x, num + 1] == null)
33722 {
33723 Main.tile[x, num + 1] = new Tile();
33724 }
33725 bool flag4 = false;
33726 if (!SolidTile(x, num - 1))
33727 {
33728 flag4 = true;
33729 }
33730 if (Main.tile[x, num + 1].type != Main.tile[x, num].type)
33731 {
33732 flag4 = true;
33733 }
33734 if (Main.tile[x, num + 1].frameX != Main.tile[x, num].frameX)
33735 {
33736 flag4 = true;
33737 }
33738 if (!flag4 && !UpdateStalagtiteStyle(x, num))
33739 {
33740 flag4 = true;
33741 }
33742 if (flag4)
33743 {
33744 destroyObject = true;
33745 if (Main.tile[x, num].type == Main.tile[x, j].type)
33746 {
33747 KillTile(x, num);
33748 }
33749 if (Main.tile[x, num + 1].type == Main.tile[x, j].type)
33750 {
33751 KillTile(x, num + 1);
33752 }
33753 destroyObject = false;
33754 }
33755 }
33756
33757 public static void Place1xX(int x, int y, ushort type, int style = 0)
33758 {
33759 int num = style * 18;
33760 int num2 = 3;
33761 if (type == 92)
33762 {
33763 num2 = 6;
33764 }
33765 bool flag = true;
33766 for (int i = y - num2 + 1; i < y + 1; i++)
33767 {
33768 if (Main.tile[x, i] == null)
33769 {
33770 Main.tile[x, i] = new Tile();
33771 }
33772 if (Main.tile[x, i].active())
33773 {
33774 flag = false;
33775 }
33776 if (type == 93 && Main.tile[x, i].liquid > 0)
33777 {
33778 flag = false;
33779 }
33780 }
33781 if (flag && SolidTile2(x, y + 1))
33782 {
33783 for (int j = 0; j < num2; j++)
33784 {
33785 Main.tile[x, y - num2 + 1 + j].active(active: true);
33786 Main.tile[x, y - num2 + 1 + j].frameY = (short)(j * 18 + num2 * num);
33787 Main.tile[x, y - num2 + 1 + j].frameX = 0;
33788 Main.tile[x, y - num2 + 1 + j].type = type;
33789 }
33790 }
33791 }
33792
33793 public static int checkXmasTreeDrop(int x, int y, int obj)
33794 {
33795 int num = x;
33796 int num2 = y;
33797 if (Main.tile[x, y].frameX < 10)
33798 {
33799 num -= Main.tile[x, y].frameX;
33800 num2 -= Main.tile[x, y].frameY;
33801 }
33802 int num3 = 0;
33803 if ((Main.tile[num, num2].frameY & 1) == 1)
33804 {
33805 num3++;
33806 }
33807 if ((Main.tile[num, num2].frameY & 2) == 2)
33808 {
33809 num3 += 2;
33810 }
33811 if ((Main.tile[num, num2].frameY & 4) == 4)
33812 {
33813 num3 += 4;
33814 }
33815 int num4 = 0;
33816 if ((Main.tile[num, num2].frameY & 8) == 8)
33817 {
33818 num4++;
33819 }
33820 if ((Main.tile[num, num2].frameY & 0x10) == 16)
33821 {
33822 num4 += 2;
33823 }
33824 if ((Main.tile[num, num2].frameY & 0x20) == 32)
33825 {
33826 num4 += 4;
33827 }
33828 int num5 = 0;
33829 if ((Main.tile[num, num2].frameY & 0x40) == 64)
33830 {
33831 num5++;
33832 }
33833 if ((Main.tile[num, num2].frameY & 0x80) == 128)
33834 {
33835 num5 += 2;
33836 }
33837 if ((Main.tile[num, num2].frameY & 0x100) == 256)
33838 {
33839 num5 += 4;
33840 }
33841 if ((Main.tile[num, num2].frameY & 0x200) == 512)
33842 {
33843 num5 += 8;
33844 }
33845 int num6 = 0;
33846 if ((Main.tile[num, num2].frameY & 0x400) == 1024)
33847 {
33848 num6++;
33849 }
33850 if ((Main.tile[num, num2].frameY & 0x800) == 2048)
33851 {
33852 num6 += 2;
33853 }
33854 if ((Main.tile[num, num2].frameY & 0x1000) == 4096)
33855 {
33856 num6 += 4;
33857 }
33858 if ((Main.tile[num, num2].frameY & 0x2000) == 8192)
33859 {
33860 num6 += 8;
33861 }
33862 if (obj == 0 && num3 > 0)
33863 {
33864 return num3;
33865 }
33866 if (obj == 1 && num4 > 0)
33867 {
33868 return num4;
33869 }
33870 if (obj == 2 && num5 > 0)
33871 {
33872 return num5;
33873 }
33874 if (obj == 3 && num6 > 0)
33875 {
33876 return num6;
33877 }
33878 return -1;
33879 }
33880
33881 public static void dropXmasTree(int x, int y, int obj)
33882 {
33883 int num = x;
33884 int num2 = y;
33885 if (Main.tile[x, y].frameX < 10)
33886 {
33887 num -= Main.tile[x, y].frameX;
33888 num2 -= Main.tile[x, y].frameY;
33889 }
33890 int num3 = 0;
33891 if ((Main.tile[num, num2].frameY & 1) == 1)
33892 {
33893 num3++;
33894 }
33895 if ((Main.tile[num, num2].frameY & 2) == 2)
33896 {
33897 num3 += 2;
33898 }
33899 if ((Main.tile[num, num2].frameY & 4) == 4)
33900 {
33901 num3 += 4;
33902 }
33903 int num4 = 0;
33904 if ((Main.tile[num, num2].frameY & 8) == 8)
33905 {
33906 num4++;
33907 }
33908 if ((Main.tile[num, num2].frameY & 0x10) == 16)
33909 {
33910 num4 += 2;
33911 }
33912 if ((Main.tile[num, num2].frameY & 0x20) == 32)
33913 {
33914 num4 += 4;
33915 }
33916 int num5 = 0;
33917 if ((Main.tile[num, num2].frameY & 0x40) == 64)
33918 {
33919 num5++;
33920 }
33921 if ((Main.tile[num, num2].frameY & 0x80) == 128)
33922 {
33923 num5 += 2;
33924 }
33925 if ((Main.tile[num, num2].frameY & 0x100) == 256)
33926 {
33927 num5 += 4;
33928 }
33929 if ((Main.tile[num, num2].frameY & 0x200) == 512)
33930 {
33931 num5 += 8;
33932 }
33933 int num6 = 0;
33934 if ((Main.tile[num, num2].frameY & 0x400) == 1024)
33935 {
33936 num6++;
33937 }
33938 if ((Main.tile[num, num2].frameY & 0x800) == 2048)
33939 {
33940 num6 += 2;
33941 }
33942 if ((Main.tile[num, num2].frameY & 0x1000) == 4096)
33943 {
33944 num6 += 4;
33945 }
33946 if ((Main.tile[num, num2].frameY & 0x2000) == 8192)
33947 {
33948 num6 += 8;
33949 }
33950 if (obj == 0 && num3 > 0)
33951 {
33952 int number = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, 1874 + num3 - 1);
33953 if (Main.netMode == 1)
33954 {
33955 NetMessage.SendData(21, -1, -1, null, number, 1f);
33956 }
33957 }
33958 else if (obj == 1 && num4 > 0)
33959 {
33960 int number2 = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, 1878 + num4 - 1);
33961 if (Main.netMode == 1)
33962 {
33963 NetMessage.SendData(21, -1, -1, null, number2, 1f);
33964 }
33965 }
33966 else if (obj == 2 && num5 > 0)
33967 {
33968 int number3 = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, 1884 + num5 - 1);
33969 if (Main.netMode == 1)
33970 {
33971 NetMessage.SendData(21, -1, -1, null, number3, 1f);
33972 }
33973 }
33974 else if (obj == 3 && num6 > 0)
33975 {
33976 int number4 = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, 1895 + num6 - 1);
33977 if (Main.netMode == 1)
33978 {
33979 NetMessage.SendData(21, -1, -1, null, number4, 1f);
33980 }
33981 }
33982 }
33983
33984 public static void setXmasTree(int x, int y, int obj, int style)
33985 {
33986 int num = x;
33987 int num2 = y;
33988 if (Main.tile[x, y].frameX < 10)
33989 {
33990 num -= Main.tile[x, y].frameX;
33991 num2 -= Main.tile[x, y].frameY;
33992 }
33993 if (obj == 0)
33994 {
33995 if ((style & 1) == 1)
33996 {
33997 Main.tile[num, num2].frameY |= 1;
33998 }
33999 else
34000 {
34001 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -2);
34002 }
34003 if ((style & 2) == 2)
34004 {
34005 Main.tile[num, num2].frameY |= 2;
34006 }
34007 else
34008 {
34009 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -3);
34010 }
34011 if ((style & 4) == 4)
34012 {
34013 Main.tile[num, num2].frameY |= 4;
34014 }
34015 else
34016 {
34017 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -5);
34018 }
34019 }
34020 if (obj == 1)
34021 {
34022 if ((style & 1) == 1)
34023 {
34024 Main.tile[num, num2].frameY |= 8;
34025 }
34026 else
34027 {
34028 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -9);
34029 }
34030 if ((style & 2) == 2)
34031 {
34032 Main.tile[num, num2].frameY |= 16;
34033 }
34034 else
34035 {
34036 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -17);
34037 }
34038 if ((style & 4) == 4)
34039 {
34040 Main.tile[num, num2].frameY |= 32;
34041 }
34042 else
34043 {
34044 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -33);
34045 }
34046 }
34047 if (obj == 2)
34048 {
34049 if ((style & 1) == 1)
34050 {
34051 Main.tile[num, num2].frameY |= 64;
34052 }
34053 else
34054 {
34055 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -65);
34056 }
34057 if ((style & 2) == 2)
34058 {
34059 Main.tile[num, num2].frameY |= 128;
34060 }
34061 else
34062 {
34063 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -129);
34064 }
34065 if ((style & 4) == 4)
34066 {
34067 Main.tile[num, num2].frameY |= 256;
34068 }
34069 else
34070 {
34071 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -257);
34072 }
34073 if ((style & 8) == 8)
34074 {
34075 Main.tile[num, num2].frameY |= 512;
34076 }
34077 else
34078 {
34079 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -513);
34080 }
34081 }
34082 if (obj == 3)
34083 {
34084 if ((style & 1) == 1)
34085 {
34086 Main.tile[num, num2].frameY |= 1024;
34087 }
34088 else
34089 {
34090 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -1025);
34091 }
34092 if ((style & 2) == 2)
34093 {
34094 Main.tile[num, num2].frameY |= 2048;
34095 }
34096 else
34097 {
34098 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -2049);
34099 }
34100 if ((style & 4) == 4)
34101 {
34102 Main.tile[num, num2].frameY |= 4096;
34103 }
34104 else
34105 {
34106 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -4097);
34107 }
34108 if ((style & 8) == 8)
34109 {
34110 Main.tile[num, num2].frameY |= 8192;
34111 }
34112 else
34113 {
34114 Main.tile[num, num2].frameY = (short)(Main.tile[num, num2].frameY & -8193);
34115 }
34116 }
34117 }
34118
34119 public static int PlaceXmasTree_Direct(int x, int y, int type, int style, int dir, int alternate)
34120 {
34121 for (short num = 0; num < 4; num++)
34122 {
34123 for (short num2 = 0; num2 < 8; num2++)
34124 {
34125 Tile tile = Main.tile[x + num, y + num2];
34126 tile.active(active: true);
34127 tile.type = (ushort)type;
34128 if (num == 0 && num2 == 0)
34129 {
34130 tile.frameX = 10;
34131 tile.frameY = 0;
34132 }
34133 else
34134 {
34135 tile.frameX = num;
34136 tile.frameY = num2;
34137 }
34138 }
34139 }
34140 return 0;
34141 }
34142
34143 public static void PlaceXmasTree(int x, int y, ushort type = 171)
34144 {
34145 bool flag = true;
34146 int num = x - 1;
34147 int num2 = y - 7;
34148 for (int i = num; i < num + 4; i++)
34149 {
34150 for (int j = num2; j < num2 + 8; j++)
34151 {
34152 if (Main.tile[i, j].active())
34153 {
34154 flag = false;
34155 }
34156 }
34157 if (i > num && i < num + 3 && !SolidTile(i, num2 + 8))
34158 {
34159 flag = false;
34160 }
34161 }
34162 if (!flag)
34163 {
34164 return;
34165 }
34166 int num3 = 0;
34167 for (int k = num; k < num + 4; k++)
34168 {
34169 int num4 = 0;
34170 for (int l = num2; l < num2 + 8; l++)
34171 {
34172 Main.tile[k, l].active(active: true);
34173 if (num3 == 0 && num4 == 0)
34174 {
34175 Main.tile[k, l].frameX = 10;
34176 Main.tile[k, l].frameY = 0;
34177 }
34178 else
34179 {
34180 Main.tile[k, l].frameX = (short)num3;
34181 Main.tile[k, l].frameY = (short)num4;
34182 }
34183 Main.tile[k, l].type = type;
34184 Main.tile[k, l].active(active: true);
34185 num4++;
34186 }
34187 num3++;
34188 }
34189 }
34190
34191 public static void CheckXmasTree(int x, int y)
34192 {
34193 if (destroyObject)
34194 {
34195 return;
34196 }
34197 int num = x;
34198 int num2 = y;
34199 if (Main.tile[x, y].frameX < 10)
34200 {
34201 num -= Main.tile[x, y].frameX;
34202 num2 -= Main.tile[x, y].frameY;
34203 }
34204 bool flag = false;
34205 int num3 = 0;
34206 for (int i = num; i < num + 4; i++)
34207 {
34208 int num4 = 0;
34209 for (int j = num2; j < num2 + 8; j++)
34210 {
34211 if (Main.tile[i, j].active() && Main.tile[i, j].type == 171)
34212 {
34213 if (num3 != 0 && num4 != 0 && Main.tile[i, j].frameX != num3 && Main.tile[i, j].frameY != num4)
34214 {
34215 flag = true;
34216 }
34217 }
34218 else
34219 {
34220 flag = true;
34221 }
34222 num4++;
34223 }
34224 num3++;
34225 if (i > num && i < num + 3 && !SolidTile2(i, num2 + 8))
34226 {
34227 flag = true;
34228 }
34229 }
34230 if (!flag)
34231 {
34232 return;
34233 }
34234 destroyObject = true;
34235 for (int k = num; k < num + 4; k++)
34236 {
34237 for (int l = num2; l < num2 + 8; l++)
34238 {
34239 if (Main.tile[k, l].type == 171)
34240 {
34241 KillTile(k, l);
34242 }
34243 }
34244 }
34245 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1873);
34246 destroyObject = false;
34247 }
34248
34249 public static void Place2xX(int x, int y, ushort type, int style = 0)
34250 {
34251 int num = style * 36;
34252 int num2 = 0;
34253 int num3 = 3;
34254 if (type == 105 && style == 34)
34255 {
34256 type = 349;
34257 style = 0;
34258 num = 0;
34259 }
34260 if (type == 105)
34261 {
34262 int num4 = style / 55;
34263 num -= 1980 * num4;
34264 num2 += 54 * num4;
34265 }
34266 if (type == 104)
34267 {
34268 num3 = 5;
34269 }
34270 if (type == 207)
34271 {
34272 num3 = 4;
34273 }
34274 bool flag = true;
34275 for (int i = y - num3 + 1; i < y + 1; i++)
34276 {
34277 if (Main.tile[x, i] == null)
34278 {
34279 Main.tile[x, i] = new Tile();
34280 }
34281 if (Main.tile[x, i].active())
34282 {
34283 flag = false;
34284 }
34285 if (Main.tile[x + 1, i] == null)
34286 {
34287 Main.tile[x + 1, i] = new Tile();
34288 }
34289 if (Main.tile[x + 1, i].active())
34290 {
34291 flag = false;
34292 }
34293 }
34294 if (flag && SolidTile2(x, y + 1) && SolidTile2(x + 1, y + 1))
34295 {
34296 for (int j = 0; j < num3; j++)
34297 {
34298 Main.tile[x, y - num3 + 1 + j].active(active: true);
34299 Main.tile[x, y - num3 + 1 + j].frameY = (short)(num2 + j * 18);
34300 Main.tile[x, y - num3 + 1 + j].frameX = (short)num;
34301 Main.tile[x, y - num3 + 1 + j].type = type;
34302 Main.tile[x + 1, y - num3 + 1 + j].active(active: true);
34303 Main.tile[x + 1, y - num3 + 1 + j].frameY = (short)(num2 + j * 18);
34304 Main.tile[x + 1, y - num3 + 1 + j].frameX = (short)(num + 18);
34305 Main.tile[x + 1, y - num3 + 1 + j].type = type;
34306 }
34307 }
34308 }
34309
34310 public static int GetItemDrop_Benches(int style)
34311 {
34312 return style switch
34313 {
34314 1 => 2397,
34315 2 => 2398,
34316 3 => 2399,
34317 4 => 2400,
34318 5 => 2401,
34319 6 => 2402,
34320 7 => 2403,
34321 8 => 2404,
34322 9 => 2405,
34323 10 => 2406,
34324 11 => 2407,
34325 12 => 2408,
34326 13 => 2409,
34327 14 => 2410,
34328 15 => 2411,
34329 16 => 2412,
34330 17 => 2413,
34331 18 => 2414,
34332 19 => 2415,
34333 20 => 2416,
34334 21 => 2521,
34335 22 => 2527,
34336 23 => 2539,
34337 24 => 858,
34338 25 => 2582,
34339 26 => 2634,
34340 27 => 2635,
34341 28 => 2636,
34342 29 => 2823,
34343 30 => 3150,
34344 31 => 3152,
34345 32 => 3151,
34346 33 => 3918,
34347 34 => 3919,
34348 35 => 3947,
34349 36 => 3973,
34350 37 => 4161,
34351 38 => 4182,
34352 39 => 4203,
34353 40 => 4224,
34354 41 => 4313,
34355 42 => 4582,
34356 43 => 4993,
34357 44 => 5164,
34358 45 => 5185,
34359 46 => 5206,
34360 _ => 335,
34361 };
34362 }
34363
34364 public static int GetItemDrop_PicnicTables(int style)
34365 {
34366 if (style == 0 || style != 1)
34367 {
34368 return 4064;
34369 }
34370 return 4065;
34371 }
34372
34373 public static int GetItemDrop_Chair(int style)
34374 {
34375 switch (style)
34376 {
34377 default:
34378 return 34;
34379 case 1:
34380 return 358;
34381 case 2:
34382 return 628;
34383 case 3:
34384 return 629;
34385 case 4:
34386 return 630;
34387 case 5:
34388 return 806;
34389 case 6:
34390 return 807;
34391 case 7:
34392 return 808;
34393 case 8:
34394 return 809;
34395 case 9:
34396 return 810;
34397 case 10:
34398 return 826;
34399 case 11:
34400 return 915;
34401 case 12:
34402 return 1143;
34403 case 13:
34404 return 1396;
34405 case 14:
34406 return 1399;
34407 case 15:
34408 return 1402;
34409 case 16:
34410 return 1459;
34411 case 17:
34412 return 1509;
34413 case 18:
34414 case 19:
34415 case 20:
34416 case 21:
34417 case 22:
34418 case 23:
34419 return 1703 + style - 18;
34420 case 24:
34421 return 1792;
34422 case 25:
34423 return 1814;
34424 case 26:
34425 return 1925;
34426 case 27:
34427 return 2228;
34428 case 28:
34429 return 2288;
34430 case 29:
34431 return 2524;
34432 case 30:
34433 return 2557;
34434 case 31:
34435 return 2572;
34436 case 32:
34437 return 2812;
34438 case 33:
34439 return 3174;
34440 case 34:
34441 return 3176;
34442 case 35:
34443 return 3175;
34444 case 36:
34445 return 3889;
34446 case 37:
34447 return 3937;
34448 case 38:
34449 return 3963;
34450 case 39:
34451 return 4151;
34452 case 40:
34453 return 4172;
34454 case 41:
34455 return 4193;
34456 case 42:
34457 return 4214;
34458 case 43:
34459 return 4304;
34460 case 44:
34461 return 4572;
34462 case 45:
34463 return 5154;
34464 case 46:
34465 return 5175;
34466 case 47:
34467 return 5196;
34468 }
34469 }
34470
34471 public static int GetItemDrop_Toilet(int style)
34472 {
34473 int num = 4096 + style;
34474 switch (style)
34475 {
34476 case 32:
34477 num = 4141;
34478 break;
34479 case 33:
34480 num = 4165;
34481 break;
34482 case 34:
34483 num = 4186;
34484 break;
34485 case 35:
34486 num = 4207;
34487 break;
34488 case 36:
34489 num = 4228;
34490 break;
34491 case 37:
34492 num = 4316;
34493 break;
34494 case 38:
34495 num = 4586;
34496 break;
34497 case 39:
34498 num = 4731;
34499 break;
34500 case 40:
34501 num = 5168;
34502 break;
34503 case 41:
34504 num = 5189;
34505 break;
34506 case 42:
34507 num = 5210;
34508 break;
34509 }
34510 if (num > 5210)
34511 {
34512 num = 5210;
34513 }
34514 return num;
34515 }
34516
34517 public static void Check1x2(int x, int j, ushort type)
34518 {
34519 if (destroyObject)
34520 {
34521 return;
34522 }
34523 int num = j;
34524 bool flag = true;
34525 if (Main.tile[x, num] == null)
34526 {
34527 Main.tile[x, num] = new Tile();
34528 }
34529 if (Main.tile[x, num + 1] == null)
34530 {
34531 Main.tile[x, num + 1] = new Tile();
34532 }
34533 int num2 = Main.tile[x, num].frameY;
34534 int num3 = 0;
34535 while (num2 >= 40)
34536 {
34537 num2 -= 40;
34538 num3++;
34539 }
34540 if (num2 == 18)
34541 {
34542 num--;
34543 }
34544 int num4 = Main.tile[x, num].frameX / 18;
34545 if (Main.tile[x, num].frameX == -1)
34546 {
34547 num4 = Main.tile[x, num + 1].frameX / 18;
34548 }
34549 if (Main.tile[x, num] == null)
34550 {
34551 Main.tile[x, num] = new Tile();
34552 }
34553 if (Main.tile[x, num].frameY == 40 * num3 && Main.tile[x, num + 1].frameY == 40 * num3 + 18 && Main.tile[x, num].type == type && Main.tile[x, num + 1].type == type)
34554 {
34555 flag = false;
34556 }
34557 if (Main.tile[x, num + 2] == null)
34558 {
34559 Main.tile[x, num + 2] = new Tile();
34560 }
34561 if (!SolidTileAllowBottomSlope(x, num + 2) && !TileID.Sets.Platforms[Main.tile[x, num + 2].type])
34562 {
34563 flag = true;
34564 }
34565 if (Main.tile[x, num].type == 20)
34566 {
34567 int num5 = Main.tile[x, num].frameX / 54;
34568 int type2 = Main.tile[x, num + 2].type;
34569 int num6 = -1;
34570 switch (type2)
34571 {
34572 case 2:
34573 case 477:
34574 num6 = 0;
34575 break;
34576 case 147:
34577 num6 = 1;
34578 break;
34579 case 60:
34580 num6 = 2;
34581 break;
34582 case 23:
34583 case 661:
34584 num6 = 3;
34585 break;
34586 case 199:
34587 case 662:
34588 num6 = 4;
34589 break;
34590 case 109:
34591 case 492:
34592 num6 = 5;
34593 break;
34594 case 53:
34595 num6 = 6;
34596 break;
34597 case 116:
34598 num6 = 7;
34599 break;
34600 case 234:
34601 num6 = 8;
34602 break;
34603 case 112:
34604 num6 = 9;
34605 break;
34606 case 633:
34607 num6 = 10;
34608 break;
34609 default:
34610 flag = true;
34611 break;
34612 }
34613 if (!flag && num5 != num6)
34614 {
34615 int num7 = 54 * num6;
34616 num7 += genRand.Next(3) * 18;
34617 Main.tile[x, num].frameX = (short)num7;
34618 Main.tile[x, num + 1].frameX = (short)num7;
34619 }
34620 }
34621 if (!flag)
34622 {
34623 return;
34624 }
34625 destroyObject = true;
34626 if (Main.tile[x, num].type == type)
34627 {
34628 KillTile(x, num);
34629 }
34630 if (Main.tile[x, num + 1].type == type)
34631 {
34632 KillTile(x, num + 1);
34633 }
34634 if (type == 216)
34635 {
34636 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 970 + num3);
34637 }
34638 if (type == 338)
34639 {
34640 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 2738);
34641 }
34642 if (type == 390)
34643 {
34644 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 16, 32, 3253);
34645 }
34646 if (type == 493)
34647 {
34648 int num8 = 0;
34649 switch (num4)
34650 {
34651 case 0:
34652 num8 = 4083;
34653 break;
34654 case 1:
34655 num8 = 4084;
34656 break;
34657 case 2:
34658 num8 = 4085;
34659 break;
34660 case 3:
34661 num8 = 4086;
34662 break;
34663 case 4:
34664 num8 = 4087;
34665 break;
34666 case 5:
34667 num8 = 4088;
34668 break;
34669 }
34670 if (num8 > 0)
34671 {
34672 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, num8);
34673 }
34674 }
34675 if (type == 15)
34676 {
34677 int itemDrop_Chair = GetItemDrop_Chair(num3);
34678 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, itemDrop_Chair);
34679 }
34680 switch (type)
34681 {
34682 case 497:
34683 {
34684 int itemDrop_Toilet = GetItemDrop_Toilet(num3);
34685 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, itemDrop_Toilet);
34686 break;
34687 }
34688 case 134:
34689 if (num3 == 1)
34690 {
34691 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 1220);
34692 }
34693 else
34694 {
34695 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 525);
34696 }
34697 break;
34698 }
34699 destroyObject = false;
34700 }
34701
34702 public static void CheckOnTable1x1(int x, int y, int type)
34703 {
34704 if (Main.tile[x, y + 1] == null)
34705 {
34706 return;
34707 }
34708 if (Main.tile[x, y + 1].topSlope())
34709 {
34710 if (TileID.Sets.Platforms[Main.tile[x, y + 1].type])
34711 {
34712 if ((Main.tile[x, y + 1].blockType() != 3 || !Main.tile[x - 1, y + 1].active() || Main.tile[x - 1, y + 1].blockType() != 0 || !TileID.Sets.Platforms[Main.tile[x - 1, y + 1].type]) && (Main.tile[x, y + 1].blockType() != 2 || !Main.tile[x + 1, y + 1].active() || Main.tile[x + 1, y + 1].blockType() != 0 || !TileID.Sets.Platforms[Main.tile[x + 1, y + 1].type]))
34713 {
34714 KillTile(x, y);
34715 }
34716 }
34717 else
34718 {
34719 KillTile(x, y);
34720 }
34721 }
34722 else
34723 {
34724 if (Main.tile[x, y + 1].active() && Main.tileTable[Main.tile[x, y + 1].type] && !Main.tile[x, y + 1].halfBrick())
34725 {
34726 return;
34727 }
34728 if (type == 78)
34729 {
34730 if (!SolidTileAllowBottomSlope(x, y + 1))
34731 {
34732 KillTile(x, y);
34733 }
34734 }
34735 else
34736 {
34737 KillTile(x, y);
34738 }
34739 }
34740 }
34741
34742 public static void CheckSign(int x, int y, ushort type)
34743 {
34744 if (destroyObject)
34745 {
34746 return;
34747 }
34748 int num = x - 2;
34749 int num2 = x + 3;
34750 int num3 = y - 2;
34751 int num4 = y + 3;
34753 {
34754 return;
34755 }
34756 bool flag = false;
34757 for (int i = num; i < num2; i++)
34758 {
34759 for (int j = num3; j < num4; j++)
34760 {
34761 if (Main.tile[i, j] == null)
34762 {
34763 Main.tile[i, j] = new Tile();
34764 }
34765 }
34766 }
34767 int num5 = Main.tile[x, y].frameX / 18;
34768 int num6 = Main.tile[x, y].frameY / 18;
34769 num5 %= 2;
34770 num6 %= 2;
34771 int num7 = x - num5;
34772 int num8 = y - num6;
34773 int num9 = Main.tile[num7, num8].frameX / 18 / 2;
34774 int num10 = Main.tile[num7, num8].frameY / 18 / 2;
34775 int num11 = Main.tile[x, y].frameX / 18;
34776 int num12 = 0;
34777 while (num11 > 1)
34778 {
34779 num11 -= 2;
34780 num12++;
34781 }
34782 num = num7;
34783 num2 = num7 + 2;
34784 num3 = num8;
34785 num4 = num8 + 2;
34786 num5 = 0;
34787 for (int k = num; k < num2; k++)
34788 {
34789 num6 = 0;
34790 for (int l = num3; l < num4; l++)
34791 {
34792 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type)
34793 {
34794 flag = true;
34795 break;
34796 }
34797 if (Main.tile[k, l].frameX / 18 != num5 + num9 * 2 || Main.tile[k, l].frameY / 18 != num6 + num10 * 2)
34798 {
34799 flag = true;
34800 break;
34801 }
34802 num6++;
34803 }
34804 num5++;
34805 }
34806 if (!flag)
34807 {
34808 if (type == 85)
34809 {
34810 if (SolidTileAllowBottomSlope(num7, num8 + 2) && SolidTileAllowBottomSlope(num7 + 1, num8 + 2))
34811 {
34812 num9 = num12;
34813 }
34814 else
34815 {
34816 flag = true;
34817 }
34818 }
34819 else if (TopEdgeCanBeAttachedTo(num7, num8 + 2) && TopEdgeCanBeAttachedTo(num7 + 1, num8 + 2))
34820 {
34821 num9 = 0;
34822 }
34823 else if (BottomEdgeCanBeAttachedTo(num7, num8 - 1) && BottomEdgeCanBeAttachedTo(num7 + 1, num8 - 1))
34824 {
34825 num9 = 1;
34826 }
34827 else if (RightEdgeCanBeAttachedTo(num7 - 1, num8) && RightEdgeCanBeAttachedTo(num7 - 1, num8 + 1))
34828 {
34829 num9 = 2;
34830 }
34831 else if (LeftEdgeCanBeAttachedTo(num7 + 2, num8) && LeftEdgeCanBeAttachedTo(num7 + 2, num8 + 1))
34832 {
34833 num9 = 3;
34834 }
34835 else if (Main.tile[num7, num8].wall > 0 && Main.tile[num7 + 1, num8].wall > 0 && Main.tile[num7, num8 + 1].wall > 0 && Main.tile[num7 + 1, num8 + 1].wall > 0)
34836 {
34837 num9 = 4;
34838 }
34839 else
34840 {
34841 flag = true;
34842 }
34843 }
34844 if (flag)
34845 {
34846 if (type == 395)
34847 {
34848 int num13 = TEItemFrame.Find(num7, num8);
34849 if (num13 != -1 && ((TEItemFrame)TileEntity.ByID[num13]).item.stack > 0)
34850 {
34851 ((TEItemFrame)TileEntity.ByID[num13]).DropItem();
34852 if (Main.netMode != 2)
34853 {
34854 Main.LocalPlayer.InterruptItemUsageIfOverTile(395);
34855 }
34856 }
34857 }
34858 destroyObject = true;
34859 for (int m = num; m < num2; m++)
34860 {
34861 for (int n = num3; n < num4; n++)
34862 {
34863 if (Main.tile[m, n].type == type)
34864 {
34865 KillTile(m, n);
34866 }
34867 }
34868 }
34869 if (type != 395)
34870 {
34872 }
34873 switch (type)
34874 {
34875 case 85:
34876 {
34877 int type2 = 321;
34878 if (num12 >= 6 && num12 <= 10)
34879 {
34880 type2 = 3229 + num12 - 6;
34881 }
34882 else if (num12 >= 1 && num12 <= 5)
34883 {
34884 type2 = 1173 + num12 - 1;
34885 }
34886 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, type2);
34887 if (Main.netMode != 1 && genRand.Next(2) == 0 && NPC.CountNPCS(316) < 2)
34888 {
34889 int num14 = Player.FindClosest(new Vector2(x * 16, y * 16), 16, 16);
34890 if (Main.player[num14].ZoneGraveyard || !Main.dayTime || (double)y > Main.worldSurface)
34891 {
34892 NPC.SpawnOnPlayer(num14, 316);
34893 }
34894 }
34895 break;
34896 }
34897 case 395:
34898 Item.NewItem(GetItemSource_FromTileBreak(num7, num8), num7 * 16, num8 * 16, 32, 32, 3270);
34900 break;
34901 case 425:
34902 Item.NewItem(GetItemSource_FromTileBreak(num7, num8), num7 * 16, num8 * 16, 32, 32, 3617);
34903 break;
34904 case 573:
34905 Item.NewItem(GetItemSource_FromTileBreak(num7, num8), num7 * 16, num8 * 16, 32, 32, 4710);
34906 break;
34907 case 511:
34908 Item.NewItem(GetItemSource_FromTileBreak(num7, num8), num7 * 16, num8 * 16, 32, 32, 4320);
34909 break;
34910 case 510:
34911 Item.NewItem(GetItemSource_FromTileBreak(num7, num8), num7 * 16, num8 * 16, 32, 32, 4319);
34912 break;
34913 default:
34914 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 171);
34915 break;
34916 }
34917 destroyObject = false;
34918 return;
34919 }
34920 int num15 = 36 * num9;
34921 for (int num16 = 0; num16 < 2; num16++)
34922 {
34923 for (int num17 = 0; num17 < 2; num17++)
34924 {
34925 Main.tile[num7 + num16, num8 + num17].active(active: true);
34926 Main.tile[num7 + num16, num8 + num17].type = type;
34927 Main.tile[num7 + num16, num8 + num17].frameX = (short)(num15 + 18 * num16);
34928 Main.tile[num7 + num16, num8 + num17].frameY = (short)(18 * num17 + num10 * 36);
34929 }
34930 }
34931 }
34932
34933 public static bool PlaceSign(int x, int y, ushort type, int Style = 0)
34934 {
34935 int num = x - 2;
34936 int num2 = x + 3;
34937 int num3 = y - 2;
34938 int num4 = y + 3;
34939 if (num < 0)
34940 {
34941 return false;
34942 }
34943 if (num2 > Main.maxTilesX)
34944 {
34945 return false;
34946 }
34947 if (num3 < 0)
34948 {
34949 return false;
34950 }
34951 if (num4 > Main.maxTilesY)
34952 {
34953 return false;
34954 }
34955 for (int i = num; i < num2; i++)
34956 {
34957 for (int j = num3; j < num4; j++)
34958 {
34959 if (Main.tile[i, j] == null)
34960 {
34961 Main.tile[i, j] = new Tile();
34962 }
34963 }
34964 }
34965 int num5 = x;
34966 int num6 = y;
34967 int num7 = 0;
34968 if (type == 55 || type == 425 || type == 510 || type == 511)
34969 {
34970 if (SolidTile2(x, y + 1) && SolidTile2(x + 1, y + 1))
34971 {
34972 num6--;
34973 num7 = 0;
34974 }
34975 else if (Main.tile[x, y - 1].nactive() && Main.tileSolid[Main.tile[x, y - 1].type] && !Main.tileSolidTop[Main.tile[x, y - 1].type] && Main.tile[x + 1, y - 1].nactive() && Main.tileSolid[Main.tile[x + 1, y - 1].type] && !Main.tileSolidTop[Main.tile[x + 1, y - 1].type])
34976 {
34977 num7 = 1;
34978 }
34979 else if (Main.tile[x - 1, y].nactive() && Main.tileSolid[Main.tile[x - 1, y].type] && !Main.tileSolidTop[Main.tile[x - 1, y].type] && !Main.tileNoAttach[Main.tile[x - 1, y].type] && Main.tile[x - 1, y + 1].nactive() && Main.tileSolid[Main.tile[x - 1, y + 1].type] && !Main.tileSolidTop[Main.tile[x - 1, y + 1].type] && !Main.tileNoAttach[Main.tile[x - 1, y + 1].type])
34980 {
34981 num7 = 2;
34982 }
34983 else if (Main.tile[x + 1, y].nactive() && Main.tileSolid[Main.tile[x + 1, y].type] && !Main.tileSolidTop[Main.tile[x + 1, y].type] && !Main.tileNoAttach[Main.tile[x + 1, y].type] && Main.tile[x + 1, y + 1].nactive() && Main.tileSolid[Main.tile[x + 1, y + 1].type] && !Main.tileSolidTop[Main.tile[x + 1, y + 1].type] && !Main.tileNoAttach[Main.tile[x + 1, y + 1].type])
34984 {
34985 num5--;
34986 num7 = 3;
34987 }
34988 else
34989 {
34990 if (Main.tile[num5, num6].wall <= 0 || Main.tile[num5 + 1, num6].wall <= 0 || Main.tile[num5, num6 + 1].wall <= 0 || Main.tile[num5 + 1, num6 + 1].wall <= 0)
34991 {
34992 return false;
34993 }
34994 num7 = 4;
34995 }
34996 }
34997 if (Main.tile[num5, num6].active() || Main.tile[num5 + 1, num6].active() || Main.tile[num5, num6 + 1].active() || Main.tile[num5 + 1, num6 + 1].active())
34998 {
34999 return false;
35000 }
35001 int num8 = 36 * num7;
35002 for (int k = 0; k < 2; k++)
35003 {
35004 for (int l = 0; l < 2; l++)
35005 {
35006 Main.tile[num5 + k, num6 + l].active(active: true);
35007 Main.tile[num5 + k, num6 + l].type = type;
35008 Main.tile[num5 + k, num6 + l].frameX = (short)(num8 + 18 * k);
35009 Main.tile[num5 + k, num6 + l].frameY = (short)(18 * l);
35010 }
35011 }
35012 return true;
35013 }
35014
35015 public static bool Place2x2Horizontal(int x, int y, ushort type, int Style = 0)
35016 {
35017 int num = x - 2;
35018 int num2 = x + 3;
35019 int num3 = y - 2;
35020 int num4 = y + 3;
35021 if (num < 0)
35022 {
35023 return false;
35024 }
35025 if (num2 > Main.maxTilesX)
35026 {
35027 return false;
35028 }
35029 if (num3 < 0)
35030 {
35031 return false;
35032 }
35033 if (num4 > Main.maxTilesY)
35034 {
35035 return false;
35036 }
35037 for (int i = num; i < num2; i++)
35038 {
35039 for (int j = num3; j < num4; j++)
35040 {
35041 if (Main.tile[i, j] == null)
35042 {
35043 Main.tile[i, j] = new Tile();
35044 }
35045 }
35046 }
35047 int num5 = y;
35048 int num6 = 0;
35049 if (SolidTile2(x, y + 1) && SolidTile2(x + 1, y + 1))
35050 {
35051 num5--;
35052 num6 = Style;
35053 if (Main.tile[x, num5].active() || Main.tile[x + 1, num5].active() || Main.tile[x, num5 + 1].active() || Main.tile[x + 1, num5 + 1].active())
35054 {
35055 return false;
35056 }
35057 int num7 = 36 * num6;
35058 for (int k = 0; k < 2; k++)
35059 {
35060 for (int l = 0; l < 2; l++)
35061 {
35062 Main.tile[x + k, num5 + l].active(active: true);
35063 Main.tile[x + k, num5 + l].type = type;
35064 Main.tile[x + k, num5 + l].frameX = (short)(num7 + 18 * k);
35065 Main.tile[x + k, num5 + l].frameY = (short)(18 * l);
35066 }
35067 }
35068 return true;
35069 }
35070 return false;
35071 }
35072
35073 public static Color paintColor(int color)
35074 {
35076 if (color == 1 || color == 13)
35077 {
35078 white.R = byte.MaxValue;
35079 white.G = 0;
35080 white.B = 0;
35081 }
35082 if (color == 2 || color == 14)
35083 {
35084 white.R = byte.MaxValue;
35085 white.G = 127;
35086 white.B = 0;
35087 }
35088 if (color == 3 || color == 15)
35089 {
35090 white.R = byte.MaxValue;
35091 white.G = byte.MaxValue;
35092 white.B = 0;
35093 }
35094 if (color == 4 || color == 16)
35095 {
35096 white.R = 127;
35097 white.G = byte.MaxValue;
35098 white.B = 0;
35099 }
35100 if (color == 5 || color == 17)
35101 {
35102 white.R = 0;
35103 white.G = byte.MaxValue;
35104 white.B = 0;
35105 }
35106 if (color == 6 || color == 18)
35107 {
35108 white.R = 0;
35109 white.G = byte.MaxValue;
35110 white.B = 127;
35111 }
35112 if (color == 7 || color == 19)
35113 {
35114 white.R = 0;
35115 white.G = byte.MaxValue;
35116 white.B = byte.MaxValue;
35117 }
35118 if (color == 8 || color == 20)
35119 {
35120 white.R = 0;
35121 white.G = 127;
35122 white.B = byte.MaxValue;
35123 }
35124 if (color == 9 || color == 21)
35125 {
35126 white.R = 0;
35127 white.G = 0;
35128 white.B = byte.MaxValue;
35129 }
35130 if (color == 10 || color == 22)
35131 {
35132 white.R = 127;
35133 white.G = 0;
35134 white.B = byte.MaxValue;
35135 }
35136 if (color == 11 || color == 23)
35137 {
35138 white.R = byte.MaxValue;
35139 white.G = 0;
35140 white.B = byte.MaxValue;
35141 }
35142 if (color == 12 || color == 24)
35143 {
35144 white.R = byte.MaxValue;
35145 white.G = 0;
35146 white.B = 127;
35147 }
35148 if (color == 25)
35149 {
35150 white.R = 75;
35151 white.G = 75;
35152 white.B = 75;
35153 }
35154 if (color == 26)
35155 {
35156 white.R = byte.MaxValue;
35157 white.G = byte.MaxValue;
35158 white.B = byte.MaxValue;
35159 }
35160 if (color == 27)
35161 {
35162 white.R = 175;
35163 white.G = 175;
35164 white.B = 175;
35165 }
35166 if (color == 28)
35167 {
35168 white.R = byte.MaxValue;
35169 white.G = 178;
35170 white.B = 125;
35171 }
35172 if (color == 29)
35173 {
35174 white.R = 25;
35175 white.G = 25;
35176 white.B = 25;
35177 }
35178 if (color == 30)
35179 {
35180 white.R = 200;
35181 white.G = 200;
35182 white.B = 200;
35183 white.A = 150;
35184 }
35185 return white;
35186 }
35187
35188 public static Color coatingColor(int coating)
35189 {
35190 return coating switch
35191 {
35192 1 => new Color(235, 170, 255, 255),
35193 2 => new Color(180, 245, 255, 255),
35194 _ => Color.Transparent,
35195 };
35196 }
35197
35198 public static List<Color> coatingColors(Tile tile, bool block)
35199 {
35200 _coatingColors.Clear();
35201 if (tile == null)
35202 {
35203 return _coatingColors;
35204 }
35205 if ((block && tile.fullbrightBlock()) || (!block && tile.fullbrightWall()))
35206 {
35207 _coatingColors.Add(coatingColor(1));
35208 }
35209 if ((block && tile.invisibleBlock()) || (!block && tile.invisibleWall()))
35210 {
35211 _coatingColors.Add(coatingColor(2));
35212 }
35213 return _coatingColors;
35214 }
35215
35216 public static void paintEffect(int x, int y, byte color, byte oldColor)
35217 {
35218 int color2 = color;
35219 if (color == 0)
35220 {
35221 color2 = oldColor;
35222 }
35223 Color newColor = paintColor(color2);
35224 for (int i = 0; i < 10; i++)
35225 {
35226 int num = Dust.NewDust(new Vector2(x * 16, y * 16), 16, 16, 143, 0f, 0f, 50, newColor);
35227 if (genRand.Next(2) == 0)
35228 {
35229 Main.dust[num].noGravity = true;
35230 Main.dust[num].scale *= 1.2f;
35231 }
35232 else
35233 {
35234 Main.dust[num].scale *= 0.5f;
35235 }
35236 }
35237 }
35238
35239 public static void paintCoatEffect(int x, int y, byte paintCoatId, List<Color> oldColors)
35240 {
35241 Color color = coatingColor(paintCoatId);
35242 for (int i = 0; i < 10; i++)
35243 {
35244 Color newColor = color;
35245 if (paintCoatId == 0 && oldColors.Count > 0)
35246 {
35248 }
35249 int num = Dust.NewDust(new Vector2(x * 16, y * 16), 16, 16, 143, 0f, 0f, 50, newColor);
35250 if (genRand.Next(2) == 0)
35251 {
35252 Main.dust[num].noGravity = true;
35253 Main.dust[num].scale *= 1.2f;
35254 }
35255 else
35256 {
35257 Main.dust[num].scale *= 0.5f;
35258 }
35259 }
35260 }
35261
35262 public static bool paintTile(int x, int y, byte color, bool broadCast = false)
35263 {
35264 Tile tile = Main.tile[x, y];
35265 if (tile == null || !tile.active())
35266 {
35267 return false;
35268 }
35269 byte b = tile.color();
35270 if (b == color)
35271 {
35272 return false;
35273 }
35274 paintEffect(x, y, color, b);
35275 tile.color(color);
35276 if (broadCast)
35277 {
35278 NetMessage.SendData(63, -1, -1, null, x, y, (int)color);
35279 }
35280 return true;
35281 }
35282
35283 public static bool paintCoatTile(int x, int y, byte paintCoatId, bool broadcast = false)
35284 {
35285 Tile tile = Main.tile[x, y];
35286 if (tile == null || !tile.active())
35287 {
35288 return false;
35289 }
35290 List<Color> oldColors = coatingColors(tile, block: true);
35291 switch (paintCoatId)
35292 {
35293 default:
35294 return false;
35295 case 0:
35296 if (!tile.fullbrightBlock() && !tile.invisibleBlock())
35297 {
35298 return false;
35299 }
35300 tile.fullbrightBlock(fullbrightBlock: false);
35301 tile.invisibleBlock(invisibleBlock: false);
35302 SquareTileFrame(x, y, resetFrame: false);
35303 break;
35304 case 1:
35305 if (tile.fullbrightBlock())
35306 {
35307 return false;
35308 }
35309 tile.fullbrightBlock(fullbrightBlock: true);
35310 break;
35311 case 2:
35312 if (tile.invisibleBlock())
35313 {
35314 return false;
35315 }
35316 tile.invisibleBlock(invisibleBlock: true);
35317 SquareTileFrame(x, y, resetFrame: false);
35318 break;
35319 }
35320 if (broadcast)
35321 {
35322 NetMessage.SendData(63, -1, -1, null, x, y, (int)paintCoatId, 1f);
35323 }
35324 paintCoatEffect(x, y, paintCoatId, oldColors);
35325 return true;
35326 }
35327
35328 public static bool paintCoatWall(int x, int y, byte paintCoatId, bool broadcast = false)
35329 {
35330 Tile tile = Main.tile[x, y];
35331 if (tile == null || tile.wall == 0)
35332 {
35333 return false;
35334 }
35335 List<Color> oldColors = coatingColors(tile, block: false);
35336 switch (paintCoatId)
35337 {
35338 default:
35339 return false;
35340 case 0:
35341 if (!tile.fullbrightWall() && !tile.invisibleWall())
35342 {
35343 return false;
35344 }
35345 tile.fullbrightWall(fullbrightWall: false);
35346 tile.invisibleWall(invisibleWall: false);
35347 SquareWallFrame(x, y, resetFrame: false);
35348 break;
35349 case 1:
35350 if (tile.fullbrightWall())
35351 {
35352 return false;
35353 }
35354 tile.fullbrightWall(fullbrightWall: true);
35355 break;
35356 case 2:
35357 if (tile.invisibleWall())
35358 {
35359 return false;
35360 }
35361 tile.invisibleWall(invisibleWall: true);
35362 SquareWallFrame(x, y, resetFrame: false);
35363 break;
35364 }
35365 if (broadcast)
35366 {
35367 NetMessage.SendData(64, -1, -1, null, x, y, (int)paintCoatId, 1f);
35368 }
35369 paintCoatEffect(x, y, paintCoatId, oldColors);
35370 return true;
35371 }
35372
35373 public static bool paintWall(int x, int y, byte color, bool broadCast = false)
35374 {
35375 Tile tile = Main.tile[x, y];
35376 if (tile == null || tile.wall == 0)
35377 {
35378 return false;
35379 }
35380 byte b = tile.wallColor();
35381 if (b == color)
35382 {
35383 return false;
35384 }
35385 tile.wallColor(color);
35386 if (broadCast)
35387 {
35388 NetMessage.SendData(64, -1, -1, null, x, y, (int)color);
35389 }
35390 paintEffect(x, y, color, b);
35391 return true;
35392 }
35393
35394 public static void Place3x3Wall(int x, int y, ushort type, int style)
35395 {
35396 int num = x - 1;
35397 int num2 = y - 1;
35398 bool flag = true;
35399 for (int i = num; i < num + 3; i++)
35400 {
35401 for (int j = num2; j < num2 + 3; j++)
35402 {
35403 if (Main.tile[i, j].active() || Main.tile[i, j].wall == 0)
35404 {
35405 flag = false;
35406 break;
35407 }
35408 }
35409 }
35410 if (!flag)
35411 {
35412 return;
35413 }
35414 int num3 = 0;
35415 while (style > 35)
35416 {
35417 num3++;
35418 style -= 36;
35419 }
35420 int num4 = style * 54;
35421 int num5 = num3 * 54;
35422 for (int k = num; k < num + 3; k++)
35423 {
35424 for (int l = num2; l < num2 + 3; l++)
35425 {
35426 Main.tile[k, l].active(active: true);
35427 Main.tile[k, l].type = type;
35428 Main.tile[k, l].frameX = (short)(num4 + 18 * (k - num));
35429 Main.tile[k, l].frameY = (short)(num5 + 18 * (l - num2));
35430 }
35431 }
35432 }
35433
35434 public static void Check3x3Wall(int x, int y)
35435 {
35436 if (destroyObject)
35437 {
35438 return;
35439 }
35440 bool flag = false;
35441 Tile tile = Main.tile[x, y];
35442 if (tile == null)
35443 {
35444 return;
35445 }
35446 int type = tile.type;
35447 int num = 0;
35448 int num2 = 0;
35449 int num3 = tile.frameX / 18;
35450 while (num3 >= 3)
35451 {
35452 num3 -= 3;
35453 num++;
35454 }
35455 int num4 = x - num3;
35456 int num5 = tile.frameY / 18;
35457 while (num5 >= 3)
35458 {
35459 num5 -= 3;
35460 num2++;
35461 }
35462 int num6 = y - num5;
35463 num5 = num2 * 54;
35464 num3 = num * 54;
35465 for (int i = num4; i < num4 + 3; i++)
35466 {
35467 for (int j = num6; j < num6 + 3; j++)
35468 {
35469 Tile tile2 = Main.tile[i, j];
35470 if (tile2 != null && (tile2.type != type || !tile2.active() || tile2.wall <= 0 || tile2.frameX != num3 + (i - num4) * 18 || tile2.frameY != num5 + (j - num6) * 18))
35471 {
35472 flag = true;
35473 break;
35474 }
35475 }
35476 }
35477 if (!flag)
35478 {
35479 return;
35480 }
35481 destroyObject = true;
35482 for (int k = num4; k < num4 + 3; k++)
35483 {
35484 for (int l = num6; l < num6 + 3; l++)
35485 {
35486 if (Main.tile[k, l] != null && Main.tile[k, l].type == type && Main.tile[k, l].active())
35487 {
35488 KillTile(k, l);
35489 }
35490 }
35491 }
35492 switch (type)
35493 {
35494 case 240:
35495 num += num2 * 36;
35496 switch (num)
35497 {
35498 case 37:
35499 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1856);
35500 break;
35501 case 36:
35502 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1855);
35503 break;
35504 case 38:
35505 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1960);
35506 break;
35507 case 39:
35508 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1961);
35509 break;
35510 case 40:
35511 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1962);
35512 break;
35513 case 33:
35514 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1574);
35515 break;
35516 case 34:
35517 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1575);
35518 break;
35519 case 35:
35520 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1576);
35521 break;
35522 case 18:
35523 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1419);
35524 break;
35525 case 19:
35526 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1420);
35527 break;
35528 case 20:
35529 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1427);
35530 break;
35531 case 21:
35532 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1428);
35533 break;
35534 case 54:
35535 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2489);
35536 break;
35537 case 55:
35538 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2589);
35539 break;
35540 case 56:
35541 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3357);
35542 break;
35543 case 57:
35544 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3358);
35545 break;
35546 case 58:
35547 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3359);
35548 break;
35549 case 59:
35550 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3595);
35551 break;
35552 case 60:
35553 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3867);
35554 break;
35555 case 61:
35556 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3866);
35557 break;
35558 case 62:
35559 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3868);
35560 break;
35561 case 69:
35562 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4660);
35563 break;
35564 case 70:
35565 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4723);
35566 break;
35567 case 71:
35568 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4724);
35569 break;
35570 case 72:
35571 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4783);
35572 break;
35573 case 73:
35574 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4958);
35575 break;
35576 case 74:
35577 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5087);
35578 break;
35579 case 75:
35580 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5108);
35581 break;
35582 case 92:
35583 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5388);
35584 break;
35585 case 76:
35586 case 77:
35587 case 78:
35588 case 79:
35589 case 80:
35590 case 81:
35591 case 82:
35592 case 83:
35593 case 84:
35594 case 85:
35595 case 86:
35596 case 87:
35597 case 88:
35598 case 89:
35599 case 90:
35600 case 91:
35601 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5218 + num - 76);
35602 break;
35603 default:
35604 if (num >= 63 && num <= 68)
35605 {
35606 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4626 + num - 63);
35607 }
35608 else if (num >= 41 && num <= 45)
35609 {
35610 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2114 + num - 41);
35611 }
35612 else if (num >= 46 && num <= 53)
35613 {
35614 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2442 + num - 46);
35615 }
35616 else if (num >= 22 && num <= 25)
35617 {
35618 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1440 + num - 22);
35619 }
35620 else if (num >= 26 && num <= 29)
35621 {
35622 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1496 + num - 26);
35623 }
35624 else if (num >= 30 && num <= 32)
35625 {
35626 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1538 + num - 30);
35627 }
35628 else
35629 {
35630 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1360 + num);
35631 }
35632 break;
35633 }
35634 break;
35635 case 440:
35636 {
35637 int num7 = -1;
35638 int num8 = -1;
35639 switch (num)
35640 {
35641 case 0:
35642 num7 = 3644;
35643 num8 = 1526;
35644 break;
35645 case 1:
35646 num7 = 3645;
35647 num8 = 1524;
35648 break;
35649 case 2:
35650 num7 = 3646;
35651 num8 = 1525;
35652 break;
35653 case 3:
35654 num7 = 3647;
35655 num8 = 1523;
35656 break;
35657 case 4:
35658 num7 = 3648;
35659 num8 = 1522;
35660 break;
35661 case 5:
35662 num7 = 3649;
35663 num8 = 1527;
35664 break;
35665 case 6:
35666 num7 = 3650;
35667 num8 = 3643;
35668 break;
35669 }
35670 if (num7 != -1)
35671 {
35672 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, num7);
35673 }
35674 if (num8 != -1 && num2 == 1)
35675 {
35676 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, num8);
35677 }
35678 break;
35679 }
35680 }
35681 destroyObject = false;
35682 }
35683
35684 public static void Place2x3Wall(int x, int y, ushort type, int style)
35685 {
35686 int num = y - 1;
35687 bool flag = true;
35688 for (int i = x; i < x + 2; i++)
35689 {
35690 for (int j = num; j < num + 3; j++)
35691 {
35692 if (Main.tile[i, j].active() || Main.tile[i, j].wall == 0)
35693 {
35694 flag = false;
35695 break;
35696 }
35697 }
35698 }
35699 if (!flag)
35700 {
35701 return;
35702 }
35703 int num2 = style * 36;
35704 int num3 = 0;
35705 for (int k = x; k < x + 2; k++)
35706 {
35707 for (int l = num; l < num + 3; l++)
35708 {
35709 Main.tile[k, l].active(active: true);
35710 Main.tile[k, l].type = type;
35711 Main.tile[k, l].frameX = (short)(num2 + 18 * (k - x));
35712 Main.tile[k, l].frameY = (short)(num3 + 18 * (l - num));
35713 }
35714 }
35715 }
35716
35717 public static void Check2x3Wall(int x, int y)
35718 {
35719 if (destroyObject)
35720 {
35721 return;
35722 }
35723 bool flag = false;
35724 int type = Main.tile[x, y].type;
35725 int num = 0;
35726 int num2 = Main.tile[x, y].frameX / 18;
35727 while (num2 >= 2)
35728 {
35729 num2 -= 2;
35730 num++;
35731 }
35732 int num3 = x - num2;
35733 int num4 = y - Main.tile[x, y].frameY / 18;
35734 num2 = num * 36;
35735 for (int i = num3; i < num3 + 2; i++)
35736 {
35737 for (int j = num4; j < num4 + 3; j++)
35738 {
35739 if (Main.tile[i, j].type != type || !Main.tile[i, j].active() || Main.tile[i, j].wall <= 0 || Main.tile[i, j].frameX != num2 + (i - num3) * 18 || Main.tile[i, j].frameY != (j - num4) * 18)
35740 {
35741 flag = true;
35742 break;
35743 }
35744 }
35745 }
35746 if (!flag)
35747 {
35748 return;
35749 }
35750 destroyObject = true;
35751 for (int k = num3; k < num3 + 2; k++)
35752 {
35753 for (int l = num4; l < num4 + 3; l++)
35754 {
35755 if (Main.tile[k, l].type == type && Main.tile[k, l].active())
35756 {
35757 KillTile(k, l);
35758 }
35759 }
35760 }
35761 if (type == 245)
35762 {
35763 if (num >= 19 && num <= 28)
35764 {
35765 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5248 + num - 19);
35766 }
35767 else if (num >= 15 && num <= 18)
35768 {
35769 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5247);
35770 }
35771 else
35772 {
35773 switch (num)
35774 {
35775 case 14:
35776 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5246);
35777 break;
35778 case 13:
35779 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5086);
35780 break;
35781 case 12:
35782 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4728);
35783 break;
35784 case 11:
35785 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4727);
35786 break;
35787 case 10:
35788 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4726);
35789 break;
35790 case 9:
35791 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4659);
35792 break;
35793 case 8:
35794 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4639);
35795 break;
35796 case 7:
35797 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4638);
35798 break;
35799 case 6:
35800 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1577);
35801 break;
35802 case 5:
35803 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1495);
35804 break;
35805 default:
35806 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1474 + num);
35807 break;
35808 }
35809 }
35810 }
35811 destroyObject = false;
35812 }
35813
35814 public static void Place3x2Wall(int x, int y, ushort type, int style)
35815 {
35816 int num = x - 1;
35817 bool flag = true;
35818 for (int i = num; i < num + 3; i++)
35819 {
35820 for (int j = y; j < y + 2; j++)
35821 {
35822 if (Main.tile[i, j].active() || Main.tile[i, j].wall == 0)
35823 {
35824 flag = false;
35825 break;
35826 }
35827 }
35828 }
35829 if (!flag)
35830 {
35831 return;
35832 }
35833 int num2 = 0;
35834 int num3 = style * 36;
35835 for (int k = num; k < num + 3; k++)
35836 {
35837 for (int l = y; l < y + 2; l++)
35838 {
35839 Main.tile[k, l].active(active: true);
35840 Main.tile[k, l].type = type;
35841 Main.tile[k, l].frameX = (short)(num2 + 18 * (k - num));
35842 Main.tile[k, l].frameY = (short)(num3 + 18 * (l - y));
35843 }
35844 }
35845 }
35846
35847 public static void Check3x2Wall(int x, int y)
35848 {
35849 if (destroyObject)
35850 {
35851 return;
35852 }
35853 bool flag = false;
35854 int type = Main.tile[x, y].type;
35855 int num = 0;
35856 int num2 = Main.tile[x, y].frameY / 18;
35857 while (num2 >= 2)
35858 {
35859 num2 -= 2;
35860 num++;
35861 }
35862 int num3 = y - num2;
35863 int num4 = x - Main.tile[x, y].frameX / 18;
35864 num2 = num * 36;
35865 for (int i = num4; i < num4 + 3; i++)
35866 {
35867 for (int j = num3; j < num3 + 2; j++)
35868 {
35869 if (Main.tile[i, j].type != type || !Main.tile[i, j].active() || Main.tile[i, j].wall <= 0 || Main.tile[i, j].frameY != num2 + (j - num3) * 18 || Main.tile[i, j].frameX != (i - num4) * 18)
35870 {
35871 flag = true;
35872 break;
35873 }
35874 }
35875 }
35876 if (!flag)
35877 {
35878 return;
35879 }
35880 destroyObject = true;
35881 for (int k = num4; k < num4 + 3; k++)
35882 {
35883 for (int l = num3; l < num3 + 2; l++)
35884 {
35885 if (Main.tile[k, l].type == type && Main.tile[k, l].active())
35886 {
35887 KillTile(k, l);
35888 }
35889 }
35890 }
35891 if (type == 246)
35892 {
35893 switch (num)
35894 {
35895 case 16:
35896 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1541);
35897 break;
35898 case 17:
35899 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1542);
35900 break;
35901 case 18:
35902 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1908);
35903 break;
35904 case 19:
35905 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4661);
35906 break;
35907 case 20:
35908 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4729);
35909 break;
35910 case 21:
35911 case 22:
35912 case 23:
35913 case 24:
35914 case 25:
35915 case 26:
35916 case 27:
35917 case 28:
35918 case 29:
35919 case 30:
35920 case 31:
35921 case 32:
35922 case 33:
35923 case 34:
35924 case 35:
35925 case 36:
35926 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5258 + num - 21);
35927 break;
35928 default:
35929 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1479 + num);
35930 break;
35931 }
35932 }
35933 destroyObject = false;
35934 }
35935
35936 public static void Place4x3Wall(int x, int y, ushort type, int style)
35937 {
35938 int num = x - 1;
35939 int num2 = y - 1;
35940 bool flag = true;
35941 for (int i = num; i < num + 4; i++)
35942 {
35943 for (int j = num2; j < num2 + 3; j++)
35944 {
35945 if (Main.tile[i, j].active() || Main.tile[i, j].wall == 0)
35946 {
35947 flag = false;
35948 break;
35949 }
35950 }
35951 }
35952 if (!flag)
35953 {
35954 return;
35955 }
35956 int num3 = 0;
35957 int num4 = style * 54;
35958 for (int k = num; k < num + 4; k++)
35959 {
35960 for (int l = num2; l < num2 + 3; l++)
35961 {
35962 Main.tile[k, l].active(active: true);
35963 Main.tile[k, l].type = type;
35964 Main.tile[k, l].frameX = (short)(num3 + 18 * (k - num));
35965 Main.tile[k, l].frameY = (short)(num4 + 18 * (l - num2));
35966 }
35967 }
35968 }
35969
35970 public static void Check4x3Wall(int x, int y)
35971 {
35972 if (destroyObject)
35973 {
35974 return;
35975 }
35976 bool flag = false;
35977 int type = Main.tile[x, y].type;
35978 int num = 0;
35979 int num2 = Main.tile[x, y].frameY / 18;
35980 while (num2 >= 3)
35981 {
35982 num2 -= 3;
35983 num++;
35984 }
35985 int num3 = y - num2;
35986 int num4 = x - Main.tile[x, y].frameX / 18;
35987 num2 = num * 54;
35988 for (int i = num4; i < num4 + 4; i++)
35989 {
35990 for (int j = num3; j < num3 + 3; j++)
35991 {
35992 if (Main.tile[i, j].type != type || !Main.tile[i, j].active() || Main.tile[i, j].wall <= 0 || Main.tile[i, j].frameY != num2 + (j - num3) * 18 || Main.tile[i, j].frameX != (i - num4) * 18)
35993 {
35994 flag = true;
35995 break;
35996 }
35997 }
35998 }
35999 if (!flag)
36000 {
36001 return;
36002 }
36003 destroyObject = true;
36004 for (int k = num4; k < num4 + 4; k++)
36005 {
36006 for (int l = num3; l < num3 + 3; l++)
36007 {
36008 if (Main.tile[k, l].type == type && Main.tile[k, l].active())
36009 {
36010 KillTile(k, l);
36011 }
36012 }
36013 }
36014 if (type == 241)
36015 {
36016 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1417);
36017 }
36018 destroyObject = false;
36019 }
36020
36021 public static void Place6x4Wall(int x, int y, ushort type, int style)
36022 {
36023 int num = x - 2;
36024 int num2 = y - 2;
36025 bool flag = true;
36026 for (int i = num; i < num + 6; i++)
36027 {
36028 for (int j = num2; j < num2 + 4; j++)
36029 {
36030 if (Main.tile[i, j].active() || Main.tile[i, j].wall == 0)
36031 {
36032 flag = false;
36033 break;
36034 }
36035 }
36036 }
36037 if (!flag)
36038 {
36039 return;
36040 }
36041 int num3 = 27;
36042 int num4 = style / num3 * 108;
36043 int num5 = style % num3 * 72;
36044 for (int k = num; k < num + 6; k++)
36045 {
36046 for (int l = num2; l < num2 + 4; l++)
36047 {
36048 Main.tile[k, l].active(active: true);
36049 Main.tile[k, l].type = type;
36050 Main.tile[k, l].frameX = (short)(num4 + 18 * (k - num));
36051 Main.tile[k, l].frameY = (short)(num5 + 18 * (l - num2));
36052 }
36053 }
36054 }
36055
36056 public static void Check6x4Wall(int x, int y)
36057 {
36058 if (destroyObject)
36059 {
36060 return;
36061 }
36062 bool flag = false;
36063 int type = Main.tile[x, y].type;
36064 int num = 0;
36065 int num2 = Main.tile[x, y].frameY / 18;
36066 int num3 = Main.tile[x, y].frameX / 18;
36067 num = 27 * (num3 / 6) + (num2 >> 2);
36068 num2 %= 4;
36069 num3 %= 6;
36070 int num4 = y - num2;
36071 int num5 = x - Main.tile[x, y].frameX / 18 % 6;
36072 num2 = num % 27 * 72;
36073 num3 = num / 27 * 108;
36074 for (int i = num5; i < num5 + 6; i++)
36075 {
36076 for (int j = num4; j < num4 + 4; j++)
36077 {
36078 if (Main.tile[i, j].type != type || !Main.tile[i, j].active() || Main.tile[i, j].wall <= 0 || Main.tile[i, j].frameY != num2 + (j - num4) * 18 || Main.tile[i, j].frameX != num3 + (i - num5) * 18)
36079 {
36080 flag = true;
36081 break;
36082 }
36083 }
36084 }
36085 if (!flag)
36086 {
36087 return;
36088 }
36089 destroyObject = true;
36090 for (int k = num5; k < num5 + 6; k++)
36091 {
36092 for (int l = num4; l < num4 + 4; l++)
36093 {
36094 if (Main.tile[k, l].type == type && Main.tile[k, l].active())
36095 {
36096 KillTile(k, l);
36097 }
36098 }
36099 }
36100 if (type == 242)
36101 {
36102 switch (num)
36103 {
36104 case 30:
36105 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2995);
36106 break;
36107 case 65:
36108 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5389);
36109 break;
36110 case 64:
36111 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5310);
36112 break;
36113 case 63:
36114 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5308);
36115 break;
36116 case 62:
36117 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5274);
36118 break;
36119 case 50:
36120 case 51:
36121 case 52:
36122 case 53:
36123 case 54:
36124 case 55:
36125 case 56:
36126 case 57:
36127 case 58:
36128 case 59:
36129 case 60:
36130 case 61:
36131 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5234 + num - 50);
36132 break;
36133 default:
36134 if (num >= 46 && num <= 49)
36135 {
36136 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5121 + num - 46);
36137 break;
36138 }
36139 switch (num)
36140 {
36141 case 45:
36142 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 5085);
36143 break;
36144 case 44:
36145 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4725);
36146 break;
36147 case 43:
36148 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4658);
36149 break;
36150 case 37:
36151 case 38:
36152 case 39:
36153 case 40:
36154 case 41:
36155 case 42:
36156 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 4632 + num - 37);
36157 break;
36158 default:
36159 if (num >= 31 && num <= 35)
36160 {
36161 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3055 + num - 31);
36162 }
36163 else if (num >= 27 && num <= 29)
36164 {
36165 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2865 + num - 27);
36166 }
36167 else if (num == 36)
36168 {
36169 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 3596);
36170 }
36171 else if (num == 26)
36172 {
36173 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2497);
36174 }
36175 else if (num == 25)
36176 {
36177 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2495);
36178 }
36179 else if (num >= 22)
36180 {
36181 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 2281 + num - 22);
36182 }
36183 else if (num >= 17)
36184 {
36185 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1846 + num - 17);
36186 }
36187 else if (num == 16)
36188 {
36189 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1573);
36190 }
36191 else if (num >= 13)
36192 {
36193 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1500 + num - 13);
36194 }
36195 else if (num >= 6)
36196 {
36197 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1433 + num - 6);
36198 }
36199 else
36200 {
36201 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 32, 32, 1421 + num);
36202 }
36203 break;
36204 }
36205 break;
36206 }
36207 }
36208 destroyObject = false;
36209 }
36210
36211 private static int RollRandomSeaShellStyle()
36212 {
36213 int result = genRand.Next(2);
36214 if (genRand.Next(10) == 0)
36215 {
36216 result = 2;
36217 }
36218 if (genRand.Next(10) == 0)
36219 {
36220 result = 3;
36221 }
36222 if (genRand.Next(50) == 0)
36223 {
36224 result = 4;
36225 }
36226 return result;
36227 }
36228
36229 public static void Place1x1(int x, int y, int type, int style = 0)
36230 {
36231 Tile tile = Main.tile[x, y];
36232 if (Main.tile[x, y] == null)
36233 {
36234 tile = new Tile();
36235 Main.tile[x, y] = tile;
36236 }
36237 if (Main.tile[x, y + 1] == null)
36238 {
36239 Main.tile[x, y + 1] = new Tile();
36240 }
36241 if (type == 324)
36242 {
36243 if (SolidTile2(x, y + 1) || (Main.tile[x, y + 1].nactive() && Main.tileTable[Main.tile[x, y + 1].type]))
36244 {
36245 tile.active(active: true);
36246 tile.type = (ushort)type;
36247 tile.frameX = (short)(22 * genRand.Next(3));
36248 tile.frameY = (short)(22 * style);
36249 }
36250 }
36251 else if (SolidTile2(x, y + 1) && !tile.active())
36252 {
36253 tile.active(active: true);
36254 tile.type = (ushort)type;
36255 switch (type)
36256 {
36257 case 324:
36258 tile.frameX = (short)(22 * RollRandomSeaShellStyle());
36259 tile.frameY = (short)(22 * style);
36260 break;
36261 case 36:
36262 case 144:
36263 case 239:
36264 tile.frameX = (short)(style * 18);
36265 tile.frameY = 0;
36266 break;
36267 default:
36268 tile.frameY = (short)(style * 18);
36269 break;
36270 }
36271 }
36272 }
36273
36274 public static void Check1x1(int x, int y, int type)
36275 {
36276 if (Main.tile[x, y + 1] != null)
36277 {
36278 if (!SolidTileAllowBottomSlope(x, y + 1))
36279 {
36280 KillTile(x, y);
36281 }
36282 if (type == 624 && !HasValidGroundForAbigailsFlowerBelowSpot(x, y))
36283 {
36284 KillTile(x, y);
36285 }
36286 }
36287 }
36288
36289 public static void CheckGolf1x1(int x, int y, int type)
36290 {
36291 Tile tile = Main.tile[x, y];
36292 bool flag = false;
36293 if (tile.frameX % 18 != 0)
36294 {
36295 flag = true;
36296 }
36297 if (tile.frameY % 18 != 0)
36298 {
36299 flag = true;
36300 }
36301 if (!SolidTileAllowBottomSlope(x, y + 1))
36302 {
36303 flag = true;
36304 }
36305 if (flag)
36306 {
36307 KillTile(x, y);
36308 }
36309 }
36310
36311 public static void CheckLogicTiles(int x, int y, int type)
36312 {
36313 if (type == 419)
36314 {
36315 Tile tile = Main.tile[x, y + 1];
36316 if (tile != null && (!tile.active() || (tile.type != 420 && tile.type != 419)))
36317 {
36318 KillTile(x, y);
36319 return;
36320 }
36321 }
36322 Tile tile2 = Main.tile[x, y];
36323 bool flag = false;
36324 if (tile2.frameX % 18 != 0)
36325 {
36326 flag = true;
36327 }
36328 if (tile2.frameY % 18 != 0)
36329 {
36330 flag = true;
36331 }
36332 if (flag)
36333 {
36334 KillTile(x, y);
36335 }
36336 }
36337
36338 public static void PlaceLogicTiles(int x, int y, int type, int style = 0)
36339 {
36340 Tile tile = Main.tile[x, y];
36341 if (Main.tile[x, y] == null)
36342 {
36343 tile = new Tile();
36344 Main.tile[x, y] = tile;
36345 }
36346 if (Main.tile[x, y + 1] == null)
36347 {
36348 Main.tile[x, y + 1] = new Tile();
36349 }
36350 if (type == 419)
36351 {
36352 if (Main.tile[x, y + 1].active() && (Main.tile[x, y + 1].type == 419 || Main.tile[x, y + 1].type == 420))
36353 {
36354 tile.active(active: true);
36355 tile.type = (ushort)type;
36356 tile.frameX = (short)(style * 18);
36357 tile.frameY = 0;
36358 }
36359 }
36360 else if (!tile.active())
36361 {
36362 tile.active(active: true);
36363 tile.type = (ushort)type;
36364 tile.frameX = 0;
36365 tile.frameY = (short)(18 * style);
36366 }
36367 }
36368
36369 public static void PlaceOnTable1x1(int x, int y, int type, int style = 0)
36370 {
36371 bool flag = false;
36372 if (Main.tile[x, y] == null)
36373 {
36374 Main.tile[x, y] = new Tile();
36375 }
36376 if (Main.tile[x, y + 1] == null)
36377 {
36378 Main.tile[x, y + 1] = new Tile();
36379 }
36380 if (!Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && Main.tileTable[Main.tile[x, y + 1].type])
36381 {
36382 flag = true;
36383 }
36384 if (type == 78 && !Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && Main.tileSolid[Main.tile[x, y + 1].type] && !Main.tile[x, y + 1].halfBrick() && Main.tile[x, y + 1].slope() == 0)
36385 {
36386 flag = true;
36387 }
36388 if (flag)
36389 {
36390 Main.tile[x, y].active(active: true);
36391 Main.tile[x, y].type = (ushort)type;
36392 if (type == 33)
36393 {
36394 Main.tile[x, y].frameX = 0;
36395 Main.tile[x, y].frameY = (short)(style * 22);
36396 }
36397 else
36398 {
36399 Main.tile[x, y].frameX = (short)(style * 18);
36400 Main.tile[x, y].frameY = 0;
36401 }
36402 if (type == 50)
36403 {
36404 Main.tile[x, y].frameX = (short)(18 * genRand.Next(5));
36405 }
36406 }
36407 }
36408
36409 public static bool PlaceAlch(int x, int y, int style)
36410 {
36411 if (Main.tile[x, y] == null)
36412 {
36413 Main.tile[x, y] = new Tile();
36414 }
36415 if (Main.tile[x, y + 1] == null)
36416 {
36417 Main.tile[x, y + 1] = new Tile();
36418 }
36419 if (!Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && !Main.tile[x, y + 1].halfBrick() && Main.tile[x, y + 1].slope() == 0)
36420 {
36421 bool flag = false;
36422 switch (style)
36423 {
36424 case 0:
36425 if (Main.tile[x, y + 1].type != 2 && Main.tile[x, y + 1].type != 477 && Main.tile[x, y + 1].type != 492 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 109)
36426 {
36427 flag = true;
36428 }
36429 if (Main.tile[x, y].liquid > 0)
36430 {
36431 flag = true;
36432 }
36433 break;
36434 case 1:
36435 if (Main.tile[x, y + 1].type != 60 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36436 {
36437 flag = true;
36438 }
36439 if (Main.tile[x, y].liquid > 0)
36440 {
36441 flag = true;
36442 }
36443 break;
36444 case 2:
36445 if (Main.tile[x, y + 1].type != 0 && Main.tile[x, y + 1].type != 59 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36446 {
36447 flag = true;
36448 }
36449 if (Main.tile[x, y].liquid > 0)
36450 {
36451 flag = true;
36452 }
36453 break;
36454 case 3:
36455 if (Main.tile[x, y + 1].type != 661 && Main.tile[x, y + 1].type != 662 && Main.tile[x, y + 1].type != 203 && Main.tile[x, y + 1].type != 199 && Main.tile[x, y + 1].type != 23 && Main.tile[x, y + 1].type != 25 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36456 {
36457 flag = true;
36458 }
36459 if (Main.tile[x, y].liquid > 0)
36460 {
36461 flag = true;
36462 }
36463 break;
36464 case 4:
36465 if (Main.tile[x, y + 1].type != 53 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 116)
36466 {
36467 flag = true;
36468 }
36469 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36470 {
36471 flag = true;
36472 }
36473 break;
36474 case 5:
36475 if (Main.tile[x, y + 1].type != 57 && Main.tile[x, y + 1].type != 633 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36476 {
36477 flag = true;
36478 }
36479 if (Main.tile[x, y].liquid > 0 && !Main.tile[x, y].lava())
36480 {
36481 flag = true;
36482 }
36483 break;
36484 case 6:
36485 if (Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 147 && Main.tile[x, y + 1].type != 161 && Main.tile[x, y + 1].type != 163 && Main.tile[x, y + 1].type != 164 && Main.tile[x, y + 1].type != 200)
36486 {
36487 flag = true;
36488 }
36489 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36490 {
36491 flag = true;
36492 }
36493 break;
36494 }
36495 if (!flag)
36496 {
36497 Main.tile[x, y].active(active: true);
36498 Main.tile[x, y].type = 82;
36499 Main.tile[x, y].frameX = (short)(18 * style);
36500 Main.tile[x, y].frameY = 0;
36501 return true;
36502 }
36503 }
36504 return false;
36505 }
36506
36507 public static void GrowSpike(int i, int j, ushort spikeType, ushort landType)
36508 {
36509 int num = -1;
36510 switch (landType)
36511 {
36512 case 23:
36513 num = 661;
36514 break;
36515 case 199:
36516 num = 662;
36517 break;
36518 }
36519 int num2 = i;
36520 int num3 = j;
36521 int num4 = 0;
36522 if (Main.tile[num2 + 1, num3].active() && Main.tile[num2 + 1, num3].type == spikeType)
36523 {
36524 num4++;
36525 }
36526 if (Main.tile[num2 - 1, num3].active() && Main.tile[num2 - 1, num3].type == spikeType)
36527 {
36528 num4++;
36529 }
36530 if (Main.tile[num2, num3 + 1].active() && Main.tile[num2, num3 + 1].type == spikeType)
36531 {
36532 num4++;
36533 }
36534 if (Main.tile[num2, num3 - 1].active() && Main.tile[num2, num3 - 1].type == spikeType)
36535 {
36536 num4++;
36537 }
36538 if (num4 >= 3 && Main.tile[i, j].type != landType && Main.tile[i, j].type != num)
36539 {
36540 return;
36541 }
36542 switch (genRand.Next(4))
36543 {
36544 case 0:
36545 num3--;
36546 break;
36547 case 1:
36548 num3++;
36549 break;
36550 case 2:
36551 num2--;
36552 break;
36553 case 3:
36554 num2++;
36555 break;
36556 }
36557 if (Main.tile[num2, num3].active())
36558 {
36559 return;
36560 }
36561 num4 = 0;
36562 if (Main.tile[num2 + 1, num3].active() && Main.tile[num2 + 1, num3].type == spikeType)
36563 {
36564 num4++;
36565 }
36566 if (Main.tile[num2 - 1, num3].active() && Main.tile[num2 - 1, num3].type == spikeType)
36567 {
36568 num4++;
36569 }
36570 if (Main.tile[num2, num3 + 1].active() && Main.tile[num2, num3 + 1].type == spikeType)
36571 {
36572 num4++;
36573 }
36574 if (Main.tile[num2, num3 - 1].active() && Main.tile[num2, num3 - 1].type == spikeType)
36575 {
36576 num4++;
36577 }
36578 if (num4 >= 2)
36579 {
36580 return;
36581 }
36582 int num5 = 7;
36583 int num6 = num2 - num5;
36584 int num7 = num2 + num5;
36585 int num8 = num3 - num5;
36586 int num9 = num3 + num5;
36587 bool flag = false;
36588 for (int k = num6; k < num7; k++)
36589 {
36590 for (int l = num8; l < num9; l++)
36591 {
36592 if (Math.Abs(k - num2) * 2 + Math.Abs(l - num3) < 9 && Main.tile[k, l].active() && (Main.tile[k, l].type == landType || Main.tile[k, l].type == num) && Main.tile[k, l - 1].active() && Main.tile[k, l - 1].type == spikeType && Main.tile[k, l - 1].liquid == 0)
36593 {
36594 flag = true;
36595 break;
36596 }
36597 }
36598 }
36599 if (flag)
36600 {
36601 Main.tile[num2, num3].type = spikeType;
36602 Main.tile[num2, num3].active(active: true);
36603 Main.tile[num2, num3].CopyPaintAndCoating(Main.tile[i, j]);
36604 SquareTileFrame(num2, num3);
36605 if (Main.netMode == 2)
36606 {
36608 }
36609 }
36610 }
36611
36612 private static bool GrowMoreVines(int x, int y)
36613 {
36614 if (!InWorld(x, y, 30))
36615 {
36616 return false;
36617 }
36618 int num = 4;
36619 int num2 = 6;
36620 int num3 = 10;
36621 int num4 = 60;
36622 int num5 = 0;
36623 if (Main.tile[x, y].type == 528)
36624 {
36625 num4 /= 5;
36626 }
36627 for (int i = x - num; i <= x + num; i++)
36628 {
36629 for (int j = y - num2; j <= y + num3; j++)
36630 {
36631 if (TileID.Sets.IsVine[Main.tile[i, j].type])
36632 {
36633 num5++;
36634 if (j > y && Collision.CanHitLine(new Vector2(x * 16, y * 16), 1, 1, new Vector2(i * 16, j * 16), 1, 1))
36635 {
36636 num5 = ((Main.tile[i, j].type != 528) ? (num5 + (j - y) * 2) : (num5 + (j - y) * 20));
36637 }
36638 if (num5 > num4)
36639 {
36640 return false;
36641 }
36642 }
36643 }
36644 }
36645 return true;
36646 }
36647
36648 private static void GrowGlowTulips()
36649 {
36650 int num = ((Main.maxTilesX > 4200) ? ((Main.maxTilesX <= 6400) ? 1 : 2) : 0);
36651 int num2 = 100;
36652 int num3 = 300;
36653 int num4 = 2;
36654 num4 = num switch
36655 {
36656 1 => 4,
36657 2 => 6,
36658 _ => 2,
36659 };
36660 int num5 = 0;
36661 int num6 = 10000;
36662 int num7 = (int)((double)num6 * 0.75);
36663 while (num5 < num4)
36664 {
36665 num6--;
36666 if (num6 <= 0)
36667 {
36668 break;
36669 }
36670 int i = ((num5 >= num4 / 2 && (num6 <= num7 || genRand.Next(2) != 0)) ? genRand.Next(Main.maxTilesX - num3, Main.maxTilesX - num2) : genRand.Next(num2, num3));
36671 int j = ((!remixWorldGen) ? genRand.Next((int)Main.worldSurface, Main.maxTilesY - 200) : genRand.Next((int)Main.worldSurface, Main.maxTilesY - 350));
36672 if (TryGrowingGlowTulip(i, j))
36673 {
36674 num5++;
36675 }
36676 }
36677 }
36678
36679 private static void MatureTheHerbPlants()
36680 {
36681 for (int i = 10; i < Main.maxTilesX - 10; i++)
36682 {
36683 for (int j = 10; j < Main.maxTilesY - 10; j++)
36684 {
36685 if ((double)j > Main.rockLayer && (Main.tile[i, j + 1].type == 59 || Main.tile[i, j + 1].type == 0) && SolidTile(i, j + 1) && !Main.tile[i, j].active() && Main.tile[i, j].liquid == 0 && genRand.Next(25) == 0)
36686 {
36687 Main.tile[i, j].active(active: true);
36688 Main.tile[i, j].type = 82;
36689 Main.tile[i, j].frameX = 36;
36690 Main.tile[i, j].frameY = 0;
36691 }
36692 if (Main.tile[i, j].type == 82 && genRand.Next(3) == 0)
36693 {
36694 Main.tile[i, j].type = 83;
36695 if (Main.tile[i, j].frameX == 36 && genRand.Next(2) == 0)
36696 {
36697 Main.tile[i, j].type = 84;
36698 }
36699 if (Main.tile[i, j].frameX == 108 && genRand.Next(3) == 0)
36700 {
36701 Main.tile[i, j].type = 84;
36702 }
36703 }
36704 }
36705 }
36706 }
36707
36708 public static void GrowAlch(int x, int y)
36709 {
36710 if (!Main.tile[x, y].active())
36711 {
36712 return;
36713 }
36714 if (Main.tile[x, y].liquid > 0)
36715 {
36716 int num = Main.tile[x, y].frameX / 18;
36717 if ((!Main.tile[x, y].lava() || num != 5) && (Main.tile[x, y].liquidType() != 0 || (num != 1 && num != 4)))
36718 {
36719 KillTile(x, y);
36720 if (Main.netMode == 2)
36721 {
36722 NetMessage.SendTileSquare(-1, x, y);
36723 }
36724 SquareTileFrame(x, y);
36725 }
36726 }
36727 if (Main.tile[x, y].type == 82)
36728 {
36729 if (genRand.Next(50) == 0)
36730 {
36731 bool flag = false;
36732 if (Main.tile[x, y].frameX == 108)
36733 {
36734 if (genRand.Next(2) == 0)
36735 {
36736 flag = true;
36737 }
36738 }
36739 else
36740 {
36741 flag = true;
36742 }
36743 if (flag)
36744 {
36745 Main.tile[x, y].type = 83;
36746 if (Main.netMode == 2)
36747 {
36748 NetMessage.SendTileSquare(-1, x, y);
36749 }
36750 SquareTileFrame(x, y);
36751 }
36752 }
36753 else if (Main.dayTime && Main.tile[x, y].type == 82 && Main.tile[x, y].frameX == 0 && genRand.Next(50) == 0)
36754 {
36755 Main.tile[x, y].type = 83;
36756 if (Main.netMode == 2)
36757 {
36758 NetMessage.SendTileSquare(-1, x, y);
36759 }
36760 SquareTileFrame(x, y);
36761 }
36762 else if (!Main.dayTime && Main.tile[x, y].type == 82 && Main.tile[x, y].frameX == 18 && genRand.Next(50) == 0)
36763 {
36764 Main.tile[x, y].type = 83;
36765 if (Main.netMode == 2)
36766 {
36767 NetMessage.SendTileSquare(-1, x, y);
36768 }
36769 SquareTileFrame(x, y);
36770 }
36771 else if (Main.raining && Main.tile[x, y].type == 82 && Main.tile[x, y].frameX == 72 && genRand.Next(50) == 0)
36772 {
36773 Main.tile[x, y].type = 83;
36774 if (Main.netMode == 2)
36775 {
36776 NetMessage.SendTileSquare(-1, x, y);
36777 }
36778 SquareTileFrame(x, y);
36779 }
36780 else if ((double)y > Main.worldSurface && Main.tile[x, y].type == 82 && Main.tile[x, y].frameX == 36 && genRand.Next(50) == 0)
36781 {
36782 Main.tile[x, y].type = 83;
36783 if (Main.netMode == 2)
36784 {
36785 NetMessage.SendTileSquare(-1, x, y);
36786 }
36787 SquareTileFrame(x, y);
36788 }
36789 else if (y > Main.maxTilesY - 200 && Main.tile[x, y].type == 82 && Main.tile[x, y].frameX == 90 && genRand.Next(50) == 0)
36790 {
36791 Main.tile[x, y].type = 83;
36792 if (Main.netMode == 2)
36793 {
36794 NetMessage.SendTileSquare(-1, x, y);
36795 }
36796 SquareTileFrame(x, y);
36797 }
36798 }
36799 else if (Main.tile[x, y].frameX == 36 && genRand.Next(3) != 0)
36800 {
36801 if (Main.tile[x, y].type == 83)
36802 {
36803 if (genRand.Next(2) == 0)
36804 {
36805 Main.tile[x, y].type = 84;
36806 if (Main.netMode == 2)
36807 {
36808 NetMessage.SendTileSquare(-1, x, y);
36809 }
36810 }
36811 }
36812 else if (Main.tile[x, y].type == 84 || genRand.Next(5) == 0)
36813 {
36814 Main.tile[x, y].type = 83;
36815 if (Main.netMode == 2)
36816 {
36817 NetMessage.SendTileSquare(-1, x, y);
36818 }
36819 }
36820 }
36821 else if (Main.tile[x, y].frameX == 108 && Main.tile[x, y].type == 83 && genRand.Next(30) == 0)
36822 {
36823 Main.tile[x, y].type = 84;
36824 if (Main.netMode == 2)
36825 {
36826 NetMessage.SendTileSquare(-1, x, y);
36827 }
36828 SquareTileFrame(x, y);
36829 }
36830 }
36831
36832 public static void PlantAlch()
36833 {
36834 int num = genRand.Next(20, Main.maxTilesX - 20);
36835 int num2 = 0;
36836 for (num2 = (Main.remixWorld ? genRand.Next(20, Main.maxTilesY - 20) : ((genRand.Next(40) == 0) ? genRand.Next((int)(Main.rockLayer + (double)Main.maxTilesY) / 2, Main.maxTilesY - 20) : ((genRand.Next(10) != 0) ? genRand.Next((int)Main.worldSurface, Main.maxTilesY - 20) : genRand.Next(20, Main.maxTilesY - 20)))); num2 < Main.maxTilesY - 20 && !Main.tile[num, num2].active(); num2++)
36837 {
36838 }
36839 if (!Main.tile[num, num2].nactive() || Main.tile[num, num2 - 1].active() || Main.tile[num, num2 - 1].liquid != 0)
36840 {
36841 return;
36842 }
36843 int num3 = 15;
36844 int num4 = 5;
36845 int num5 = 0;
36846 num3 = (int)((double)num3 * ((double)Main.maxTilesX / 4200.0));
36847 int num6 = Utils.Clamp(num - num3, 4, Main.maxTilesX - 4);
36848 int num7 = Utils.Clamp(num + num3, 4, Main.maxTilesX - 4);
36849 int num8 = Utils.Clamp(num2 - num3, 4, Main.maxTilesY - 4);
36850 int num9 = Utils.Clamp(num2 + num3, 4, Main.maxTilesY - 4);
36851 for (int i = num6; i <= num7; i++)
36852 {
36853 for (int j = num8; j <= num9; j++)
36854 {
36855 if (Main.tileAlch[Main.tile[i, j].type])
36856 {
36857 num5++;
36858 }
36859 }
36860 }
36861 if (num5 < num4)
36862 {
36863 if (Main.tile[num, num2].type == 2 || Main.tile[num, num2].type == 109)
36864 {
36865 PlaceAlch(num, num2 - 1, 0);
36866 }
36867 if (Main.tile[num, num2].type == 60)
36868 {
36869 PlaceAlch(num, num2 - 1, 1);
36870 }
36871 if (Main.tile[num, num2].type == 0 || Main.tile[num, num2].type == 59)
36872 {
36873 PlaceAlch(num, num2 - 1, 2);
36874 }
36875 if (Main.tile[num, num2].type == 23 || Main.tile[num, num2].type == 661 || Main.tile[num, num2].type == 25 || Main.tile[num, num2].type == 203 || Main.tile[num, num2].type == 199 || Main.tile[num, num2].type == 662)
36876 {
36877 PlaceAlch(num, num2 - 1, 3);
36878 }
36879 if ((Main.tile[num, num2].type == 53 || Main.tile[num, num2].type == 116) && num >= beachDistance && num <= Main.maxTilesX - beachDistance)
36880 {
36881 PlaceAlch(num, num2 - 1, 4);
36882 }
36883 if (Main.tile[num, num2].type == 57 || Main.tile[num, num2].type == 633)
36884 {
36885 PlaceAlch(num, num2 - 1, 5);
36886 }
36887 if (Main.tile[num, num2].type == 147 || Main.tile[num, num2].type == 163 || Main.tile[num, num2].type == 164 || Main.tile[num, num2].type == 161 || Main.tile[num, num2].type == 200)
36888 {
36889 PlaceAlch(num, num2 - 1, 6);
36890 }
36891 if (Main.tile[num, num2 - 1].active() && Main.netMode == 2)
36892 {
36893 NetMessage.SendTileSquare(-1, num, num2 - 1);
36894 }
36895 }
36896 }
36897
36898 public static void CheckAlch(int x, int y)
36899 {
36900 if (Main.tile[x, y] == null)
36901 {
36902 Main.tile[x, y] = new Tile();
36903 }
36904 if (Main.tile[x, y + 1] == null)
36905 {
36906 Main.tile[x, y + 1] = new Tile();
36907 }
36908 bool flag = false;
36909 if (!Main.tile[x, y + 1].nactive())
36910 {
36911 flag = true;
36912 }
36913 if (Main.tile[x, y + 1].halfBrick())
36914 {
36915 flag = true;
36916 }
36917 int num = Main.tile[x, y].frameX / 18;
36918 Main.tile[x, y].frameY = 0;
36919 if (!flag)
36920 {
36921 switch (num)
36922 {
36923 case 0:
36924 if (Main.tile[x, y + 1].type != 109 && Main.tile[x, y + 1].type != 2 && Main.tile[x, y + 1].type != 477 && Main.tile[x, y + 1].type != 492 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36925 {
36926 flag = true;
36927 }
36928 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36929 {
36930 flag = true;
36931 }
36932 break;
36933 case 1:
36934 if (Main.tile[x, y + 1].type != 60 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36935 {
36936 flag = true;
36937 }
36938 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36939 {
36940 flag = true;
36941 }
36942 break;
36943 case 2:
36944 if (Main.tile[x, y + 1].type != 0 && Main.tile[x, y + 1].type != 59 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36945 {
36946 flag = true;
36947 }
36948 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36949 {
36950 flag = true;
36951 }
36952 break;
36953 case 3:
36954 if (Main.tile[x, y + 1].type != 661 && Main.tile[x, y + 1].type != 662 && Main.tile[x, y + 1].type != 199 && Main.tile[x, y + 1].type != 203 && Main.tile[x, y + 1].type != 23 && Main.tile[x, y + 1].type != 25 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36955 {
36956 flag = true;
36957 }
36958 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36959 {
36960 flag = true;
36961 }
36962 break;
36963 case 4:
36964 if (Main.tile[x, y + 1].type != 53 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 116)
36965 {
36966 flag = true;
36967 }
36968 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
36969 {
36970 flag = true;
36971 }
36972 break;
36973 case 5:
36974 if (Main.tile[x, y + 1].type != 57 && Main.tile[x, y + 1].type != 633 && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380)
36975 {
36976 flag = true;
36977 }
36978 if (Main.tile[x, y].type == 82 || !Main.tile[x, y].lava() || Main.netMode == 1)
36979 {
36980 break;
36981 }
36982 if (Main.tile[x, y].liquid > 16)
36983 {
36984 if (Main.tile[x, y].type == 83)
36985 {
36986 Main.tile[x, y].type = 84;
36987 if (Main.netMode == 2)
36988 {
36989 NetMessage.SendTileSquare(-1, x, y);
36990 }
36991 }
36992 }
36993 else if (Main.tile[x, y].type == 84)
36994 {
36995 Main.tile[x, y].type = 83;
36996 if (Main.netMode == 2)
36997 {
36998 NetMessage.SendTileSquare(-1, x, y);
36999 }
37000 }
37001 break;
37002 case 6:
37003 if (Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 147 && Main.tile[x, y + 1].type != 161 && Main.tile[x, y + 1].type != 163 && Main.tile[x, y + 1].type != 164 && Main.tile[x, y + 1].type != 200)
37004 {
37005 flag = true;
37006 }
37007 if (Main.tile[x, y].liquid > 0 && Main.tile[x, y].lava())
37008 {
37009 flag = true;
37010 }
37011 break;
37012 }
37013 }
37014 if (flag)
37015 {
37016 KillTile(x, y);
37017 }
37018 }
37019
37020 public static void CheckBanner(int x, int j, byte type)
37021 {
37022 if (destroyObject)
37023 {
37024 return;
37025 }
37026 int num = Main.tile[x, j].frameY / 18;
37027 int num2 = 0;
37028 while (num >= 3)
37029 {
37030 num -= 3;
37031 num2++;
37032 }
37033 num = j - num;
37034 int frameX = Main.tile[x, j].frameX;
37035 bool flag = false;
37036 for (int i = 0; i < 3; i++)
37037 {
37038 if (Main.tile[x, num + i] == null)
37039 {
37040 Main.tile[x, num + i] = new Tile();
37041 }
37042 if (!Main.tile[x, num + i].active())
37043 {
37044 flag = true;
37045 }
37046 else if (Main.tile[x, num + i].type != type)
37047 {
37048 flag = true;
37049 }
37050 else if (Main.tile[x, num + i].frameY != i * 18 + num2 * 18 * 3)
37051 {
37052 flag = true;
37053 }
37054 else if (Main.tile[x, num + i].frameX != frameX)
37055 {
37056 flag = true;
37057 }
37058 }
37059 if (Main.tile[x, num - 1] == null)
37060 {
37061 Main.tile[x, num - 1] = new Tile();
37062 }
37063 Tile tile = Main.tile[x, num - 1];
37064 if (!tile.nactive())
37065 {
37066 flag = true;
37067 }
37068 bool num3 = tile.topSlope() || tile.halfBrick() || Main.tileSolid[tile.type];
37069 bool flag2 = !Main.tileSolidTop[tile.type] || (TileID.Sets.Platforms[tile.type] && (tile.halfBrick() || tile.topSlope()));
37070 bool flag3 = num3 && flag2 && !TileID.Sets.NotReallySolid[tile.type] && !tile.bottomSlope();
37071 if (TileID.Sets.Platforms[tile.type] || tile.type == 380)
37072 {
37073 flag3 = true;
37074 }
37075 if (!flag3)
37076 {
37077 flag = true;
37078 }
37079 if (!flag)
37080 {
37081 return;
37082 }
37083 destroyObject = true;
37084 for (int k = 0; k < 3; k++)
37085 {
37086 if (Main.tile[x, num + k].type == type)
37087 {
37088 KillTile(x, num + k);
37089 }
37090 }
37091 if (type == 91)
37092 {
37093 int num4 = frameX / 18;
37094 num4 += num2 * 111;
37095 if (num4 == 310)
37096 {
37097 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 5352);
37098 }
37099 else if (num4 >= 297)
37100 {
37101 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 4668 + num4);
37102 }
37103 else if (num4 >= 295)
37104 {
37105 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 4392 + num4);
37106 }
37107 else if (num4 >= 294)
37108 {
37109 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 4602);
37110 }
37111 else if (num4 >= 288)
37112 {
37113 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 4253 + num4);
37114 }
37115 else if (num4 >= 278)
37116 {
37117 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 3559 + num4);
37118 }
37119 else if (num4 >= 273)
37120 {
37121 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 3516 + num4);
37122 }
37123 else if (num4 >= 272)
37124 {
37125 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 3780);
37126 }
37127 else if (num4 >= 270)
37128 {
37129 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 3323 + num4);
37130 }
37131 else if (num4 >= 207)
37132 {
37133 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 3183 + num4);
37134 }
37135 else if (num4 >= 109)
37136 {
37137 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 2788 + num4);
37138 }
37139 else if (num4 >= 22)
37140 {
37141 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 1593 + num4);
37142 }
37143 else if (num4 >= 10 && num4 <= 15)
37144 {
37145 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 1441 + num4);
37146 }
37147 else if (num4 >= 16 && num4 <= 21)
37148 {
37149 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 1448 + num4);
37150 }
37151 else if (num4 >= 7 && num4 <= 9)
37152 {
37153 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 838 + num4);
37154 }
37155 else if (num4 >= 4 && num4 <= 6)
37156 {
37157 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 785 + num4);
37158 }
37159 else
37160 {
37161 Item.NewItem(GetItemSource_FromTileBreak(x, num + 1), x * 16, (num + 1) * 16, 32, 32, 337 + num4);
37162 }
37163 }
37164 destroyObject = false;
37165 }
37166
37167 public static void PlaceBanner(int x, int y, ushort type, int style = 0)
37168 {
37169 int num = style * 18;
37170 int num2 = 0;
37171 if (style >= 90)
37172 {
37173 num -= 1620;
37174 num2 += 54;
37175 }
37176 if (Main.tile[x, y - 1] == null)
37177 {
37178 Main.tile[x, y - 1] = new Tile();
37179 }
37180 if (Main.tile[x, y] == null)
37181 {
37182 Main.tile[x, y] = new Tile();
37183 }
37184 if (Main.tile[x, y + 1] == null)
37185 {
37186 Main.tile[x, y + 1] = new Tile();
37187 }
37188 if (Main.tile[x, y + 2] == null)
37189 {
37190 Main.tile[x, y + 2] = new Tile();
37191 }
37192 if (Main.tile[x, y - 1].nactive() && Main.tileSolid[Main.tile[x, y - 1].type] && !Main.tileSolidTop[Main.tile[x, y - 1].type] && !Main.tile[x, y].active() && !Main.tile[x, y + 1].active() && !Main.tile[x, y + 2].active())
37193 {
37194 Main.tile[x, y].active(active: true);
37195 Main.tile[x, y].frameY = (short)num2;
37196 Main.tile[x, y].frameX = (short)num;
37197 Main.tile[x, y].type = type;
37198 Main.tile[x, y + 1].active(active: true);
37199 Main.tile[x, y + 1].frameY = (short)(num2 + 18);
37200 Main.tile[x, y + 1].frameX = (short)num;
37201 Main.tile[x, y + 1].type = type;
37202 Main.tile[x, y + 2].active(active: true);
37203 Main.tile[x, y + 2].frameY = (short)(num2 + 36);
37204 Main.tile[x, y + 2].frameX = (short)num;
37205 Main.tile[x, y + 2].type = type;
37206 }
37207 }
37208
37209 public static void PlaceMan(int i, int j, int dir)
37210 {
37211 for (int k = i; k <= i + 1; k++)
37212 {
37213 for (int l = j - 2; l <= j; l++)
37214 {
37215 if (Main.tile[k, l].active())
37216 {
37217 return;
37218 }
37219 }
37220 }
37221 if (SolidTile2(i, j + 1) && SolidTile2(i + 1, j + 1))
37222 {
37223 byte b = 0;
37224 if (dir == 1)
37225 {
37226 b = 36;
37227 }
37228 Main.tile[i, j - 2].active(active: true);
37229 Main.tile[i, j - 2].frameY = 0;
37230 Main.tile[i, j - 2].frameX = b;
37231 Main.tile[i, j - 2].type = 128;
37232 Main.tile[i, j - 1].active(active: true);
37233 Main.tile[i, j - 1].frameY = 18;
37234 Main.tile[i, j - 1].frameX = b;
37235 Main.tile[i, j - 1].type = 128;
37236 Main.tile[i, j].active(active: true);
37237 Main.tile[i, j].frameY = 36;
37238 Main.tile[i, j].frameX = b;
37239 Main.tile[i, j].type = 128;
37240 Main.tile[i + 1, j - 2].active(active: true);
37241 Main.tile[i + 1, j - 2].frameY = 0;
37242 Main.tile[i + 1, j - 2].frameX = (byte)(18 + b);
37243 Main.tile[i + 1, j - 2].type = 128;
37244 Main.tile[i + 1, j - 1].active(active: true);
37245 Main.tile[i + 1, j - 1].frameY = 18;
37246 Main.tile[i + 1, j - 1].frameX = (byte)(18 + b);
37247 Main.tile[i + 1, j - 1].type = 128;
37248 Main.tile[i + 1, j].active(active: true);
37249 Main.tile[i + 1, j].frameY = 36;
37250 Main.tile[i + 1, j].frameX = (byte)(18 + b);
37251 Main.tile[i + 1, j].type = 128;
37252 }
37253 }
37254
37255 public static void PlaceWoman(int i, int j, int dir)
37256 {
37257 for (int k = i; k <= i + 1; k++)
37258 {
37259 for (int l = j - 2; l <= j; l++)
37260 {
37261 if (Main.tile[k, l].active())
37262 {
37263 return;
37264 }
37265 }
37266 }
37267 if (SolidTile2(i, j + 1) && SolidTile2(i + 1, j + 1))
37268 {
37269 byte b = 0;
37270 if (dir == 1)
37271 {
37272 b = 36;
37273 }
37274 Main.tile[i, j - 2].active(active: true);
37275 Main.tile[i, j - 2].frameY = 0;
37276 Main.tile[i, j - 2].frameX = b;
37277 Main.tile[i, j - 2].type = 269;
37278 Main.tile[i, j - 1].active(active: true);
37279 Main.tile[i, j - 1].frameY = 18;
37280 Main.tile[i, j - 1].frameX = b;
37281 Main.tile[i, j - 1].type = 269;
37282 Main.tile[i, j].active(active: true);
37283 Main.tile[i, j].frameY = 36;
37284 Main.tile[i, j].frameX = b;
37285 Main.tile[i, j].type = 269;
37286 Main.tile[i + 1, j - 2].active(active: true);
37287 Main.tile[i + 1, j - 2].frameY = 0;
37288 Main.tile[i + 1, j - 2].frameX = (byte)(18 + b);
37289 Main.tile[i + 1, j - 2].type = 269;
37290 Main.tile[i + 1, j - 1].active(active: true);
37291 Main.tile[i + 1, j - 1].frameY = 18;
37292 Main.tile[i + 1, j - 1].frameX = (byte)(18 + b);
37293 Main.tile[i + 1, j - 1].type = 269;
37294 Main.tile[i + 1, j].active(active: true);
37295 Main.tile[i + 1, j].frameY = 36;
37296 Main.tile[i + 1, j].frameX = (byte)(18 + b);
37297 Main.tile[i + 1, j].type = 269;
37298 }
37299 }
37300
37301 public static void CheckWeaponsRack(int i, int j)
37302 {
37303 if (destroyObject)
37304 {
37305 return;
37306 }
37307 int num = i;
37308 int num2 = j - Main.tile[i, j].frameY / 18;
37309 int num3 = Main.tile[i, j].frameX;
37310 int num4 = 0;
37311 while (num3 >= 5000)
37312 {
37313 num3 -= 5000;
37314 num4++;
37315 }
37316 if (num4 != 0)
37317 {
37318 num3 = (num4 - 1) * 18;
37319 }
37320 num3 %= 54;
37321 num -= num3 / 18;
37322 bool flag = false;
37323 for (int k = 0; k < 3; k++)
37324 {
37325 for (int l = 0; l < 3; l++)
37326 {
37327 int num5 = num + k;
37328 int num6 = num2 + l;
37329 int num7 = Main.tile[num5, num6].frameX;
37330 int num8 = 0;
37331 while (num7 >= 5000)
37332 {
37333 num7 -= 5000;
37334 num8++;
37335 }
37336 if (num8 != 0)
37337 {
37338 num7 = (num8 - 1) * 18;
37339 }
37340 num7 %= 54;
37341 if (!Main.tile[num5, num6].active() || Main.tile[num5, num6].type != 334 || Main.tile[num5, num6].wall <= 0 || Main.tile[num5, num6].frameY != l * 18 || num7 != k * 18)
37342 {
37343 flag = true;
37344 }
37345 }
37346 }
37347 if (!flag)
37348 {
37349 return;
37350 }
37351 int num9 = TEWeaponsRack.Find(num, num2);
37352 if (num9 != -1 && ((TEWeaponsRack)TileEntity.ByID[num9]).item.stack > 0)
37353 {
37354 ((TEWeaponsRack)TileEntity.ByID[num9]).DropItem();
37355 if (Main.netMode != 2)
37356 {
37357 Main.LocalPlayer.InterruptItemUsageIfOverTile(471);
37358 }
37359 }
37360 destroyObject = true;
37361 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 48, 48, 2699);
37362 TEWeaponsRack.Kill(num, num2);
37363 for (int m = 0; m < 3; m++)
37364 {
37365 for (int n = 0; n < 3; n++)
37366 {
37367 int num10 = num + m;
37368 int num11 = num2 + n;
37369 if (Main.tile[num10, num11].active() && Main.tile[num10, num11].type == 334)
37370 {
37371 KillTile(num10, num11);
37372 }
37373 }
37374 }
37375 destroyObject = false;
37376 }
37377
37378 public static void ToggleGemLock(int i, int j, bool on)
37379 {
37381 if (!tileSafely.active() || tileSafely.type != 440 || (tileSafely.frameY < 54 && !on))
37382 {
37383 return;
37384 }
37385 bool flag = false;
37386 int num = -1;
37387 if (tileSafely.frameY >= 54)
37388 {
37389 flag = true;
37390 }
37391 int num2 = Main.tile[i, j].frameX / 54;
37392 int num3 = Main.tile[i, j].frameX % 54 / 18;
37393 int num4 = Main.tile[i, j].frameY % 54 / 18;
37394 switch (num2)
37395 {
37396 case 0:
37397 num = 1526;
37398 break;
37399 case 1:
37400 num = 1524;
37401 break;
37402 case 2:
37403 num = 1525;
37404 break;
37405 case 3:
37406 num = 1523;
37407 break;
37408 case 4:
37409 num = 1522;
37410 break;
37411 case 5:
37412 num = 1527;
37413 break;
37414 case 6:
37415 num = 3643;
37416 break;
37417 }
37418 for (int k = i - num3; k < i - num3 + 3; k++)
37419 {
37420 for (int l = j - num4; l < j - num4 + 3; l++)
37421 {
37422 Main.tile[k, l].frameY = (short)((on ? 54 : 0) + (l - j + num4) * 18);
37423 }
37424 }
37425 if (num != -1 && flag)
37426 {
37427 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num);
37428 }
37429 SquareTileFrame(i, j);
37430 NetMessage.SendTileSquare(-1, i - num3, j - num4, 3, 3);
37431 Wiring.HitSwitch(i - num3, j - num4);
37432 NetMessage.SendData(59, -1, -1, null, i - num3, j - num4);
37433 }
37434
37435 public static void CheckMan(int i, int j)
37436 {
37437 if (destroyObject)
37438 {
37439 return;
37440 }
37441 int num = i;
37442 int num2 = j - Main.tile[i, j].frameY / 18;
37443 int num3;
37444 for (num3 = Main.tile[i, j].frameX; num3 >= 100; num3 -= 100)
37445 {
37446 }
37447 while (num3 >= 36)
37448 {
37449 num3 -= 36;
37450 }
37451 num -= num3 / 18;
37452 bool flag = false;
37453 for (int k = 0; k <= 1; k++)
37454 {
37455 for (int l = 0; l <= 2; l++)
37456 {
37457 int num4 = num + k;
37458 int num5 = num2 + l;
37459 int num6;
37460 for (num6 = Main.tile[num4, num5].frameX; num6 >= 100; num6 -= 100)
37461 {
37462 }
37463 if (num6 >= 36)
37464 {
37465 num6 -= 36;
37466 }
37467 if (!Main.tile[num4, num5].active() || Main.tile[num4, num5].type != 128 || Main.tile[num4, num5].frameY != l * 18 || num6 != k * 18)
37468 {
37469 flag = true;
37470 }
37471 }
37472 }
37473 if (!SolidTileAllowBottomSlope(num, num2 + 3) || !SolidTileAllowBottomSlope(num + 1, num2 + 3))
37474 {
37475 flag = true;
37476 }
37477 if (!flag)
37478 {
37479 return;
37480 }
37481 destroyObject = true;
37482 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 498);
37483 for (int m = 0; m <= 1; m++)
37484 {
37485 for (int n = 0; n <= 2; n++)
37486 {
37487 int num7 = num + m;
37488 int num8 = num2 + n;
37489 if (Main.tile[num7, num8].active() && Main.tile[num7, num8].type == 128)
37490 {
37491 KillTile(num7, num8);
37492 }
37493 }
37494 }
37495 destroyObject = false;
37496 }
37497
37498 public static void CheckWoman(int i, int j)
37499 {
37500 if (destroyObject)
37501 {
37502 return;
37503 }
37504 int num = i;
37505 int num2 = j - Main.tile[i, j].frameY / 18;
37506 int num3;
37507 for (num3 = Main.tile[i, j].frameX; num3 >= 100; num3 -= 100)
37508 {
37509 }
37510 while (num3 >= 36)
37511 {
37512 num3 -= 36;
37513 }
37514 num -= num3 / 18;
37515 bool flag = false;
37516 for (int k = 0; k <= 1; k++)
37517 {
37518 for (int l = 0; l <= 2; l++)
37519 {
37520 int num4 = num + k;
37521 int num5 = num2 + l;
37522 int num6;
37523 for (num6 = Main.tile[num4, num5].frameX; num6 >= 100; num6 -= 100)
37524 {
37525 }
37526 if (num6 >= 36)
37527 {
37528 num6 -= 36;
37529 }
37530 if (!Main.tile[num4, num5].active() || Main.tile[num4, num5].type != 269 || Main.tile[num4, num5].frameY != l * 18 || num6 != k * 18)
37531 {
37532 flag = true;
37533 }
37534 }
37535 }
37536 if (!SolidTileAllowBottomSlope(num, num2 + 3) || !SolidTileAllowBottomSlope(num + 1, num2 + 3))
37537 {
37538 flag = true;
37539 }
37540 if (!flag)
37541 {
37542 return;
37543 }
37544 destroyObject = true;
37545 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1989);
37546 for (int m = 0; m <= 1; m++)
37547 {
37548 for (int n = 0; n <= 2; n++)
37549 {
37550 int num7 = num + m;
37551 int num8 = num2 + n;
37552 if (Main.tile[num7, num8].active() && Main.tile[num7, num8].type == 269)
37553 {
37554 KillTile(num7, num8);
37555 }
37556 }
37557 }
37558 destroyObject = false;
37559 }
37560
37561 public static void Place1x2(int x, int y, ushort type, int style)
37562 {
37563 short frameX = 0;
37564 if (type == 20)
37565 {
37566 frameX = (short)(genRand.Next(3) * 18);
37567 }
37568 if (Main.tile[x, y - 1] == null)
37569 {
37570 Main.tile[x, y - 1] = new Tile();
37571 }
37572 if (Main.tile[x, y + 1] == null)
37573 {
37574 Main.tile[x, y + 1] = new Tile();
37575 }
37576 if (SolidTile2(x, y + 1) & !Main.tile[x, y - 1].active())
37577 {
37578 short num = (short)(style * 40);
37579 Main.tile[x, y - 1].active(active: true);
37580 Main.tile[x, y - 1].frameY = num;
37581 Main.tile[x, y - 1].frameX = frameX;
37582 Main.tile[x, y - 1].type = type;
37583 Main.tile[x, y].active(active: true);
37584 Main.tile[x, y].frameY = (short)(num + 18);
37585 Main.tile[x, y].frameX = frameX;
37586 Main.tile[x, y].type = type;
37587 }
37588 }
37589
37590 public static void Place1x2Top(int x, int y, ushort type, int style)
37591 {
37592 short frameX = 0;
37593 if (Main.tile[x, y - 1] == null)
37594 {
37595 Main.tile[x, y - 1] = new Tile();
37596 }
37597 if (Main.tile[x, y + 1] == null)
37598 {
37599 Main.tile[x, y + 1] = new Tile();
37600 }
37601 if (Main.tile[x, y - 1].nactive() && Main.tileSolid[Main.tile[x, y - 1].type] && !Main.tileSolidTop[Main.tile[x, y - 1].type] && !Main.tile[x, y + 1].active())
37602 {
37603 short num = (short)(style * 36);
37604 Main.tile[x, y].active(active: true);
37605 Main.tile[x, y].frameY = num;
37606 Main.tile[x, y].frameX = frameX;
37607 Main.tile[x, y].type = type;
37608 Main.tile[x, y + 1].active(active: true);
37609 Main.tile[x, y + 1].frameY = (short)(num + 18);
37610 Main.tile[x, y + 1].frameX = frameX;
37611 Main.tile[x, y + 1].type = type;
37612 }
37613 }
37614
37615 public static void Check1x2Top(int x, int j, ushort type)
37616 {
37617 if (destroyObject)
37618 {
37619 return;
37620 }
37621 int num = j;
37622 bool flag = true;
37623 int num2 = Main.tile[x, num].frameY / 18;
37624 int num3 = 0;
37625 while (num2 >= 2)
37626 {
37627 num2 -= 2;
37628 num3++;
37629 }
37630 num -= num2;
37631 num2 = num3 * 36;
37632 if (Main.tile[x, num] == null)
37633 {
37634 Main.tile[x, num] = new Tile();
37635 }
37636 if (Main.tile[x, num + 1] == null)
37637 {
37638 Main.tile[x, num + 1] = new Tile();
37639 }
37640 if (Main.tile[x, num] == null)
37641 {
37642 Main.tile[x, num] = new Tile();
37643 }
37644 if (Main.tile[x, num].frameY == num2 && Main.tile[x, num + 1].frameY == num2 + 18 && Main.tile[x, num].type == type && Main.tile[x, num + 1].type == type)
37645 {
37646 flag = false;
37647 }
37648 if (Main.tile[x, num - 1] == null)
37649 {
37650 Main.tile[x, num - 1] = new Tile();
37651 }
37652 bool flag2 = false;
37653 switch (type)
37654 {
37655 case 42:
37656 case 270:
37657 case 271:
37658 case 572:
37659 case 581:
37660 case 660:
37661 flag2 = true;
37662 break;
37663 }
37664 bool flag3 = Main.tile[x, num - 1].active() && (TileID.Sets.Platforms[Main.tile[x, num - 1].type] || Main.tile[x, num - 1].type == 380);
37665 if ((!flag2 || !flag3) && (!Main.tile[x, num - 1].nactive() || !Main.tileSolid[Main.tile[x, num - 1].type] || Main.tileSolidTop[Main.tile[x, num - 1].type]))
37666 {
37667 flag = true;
37668 }
37669 if (!flag)
37670 {
37671 return;
37672 }
37673 destroyObject = true;
37674 if (Main.tile[x, num].type == type)
37675 {
37676 KillTile(x, num);
37677 }
37678 if (Main.tile[x, num + 1].type == type)
37679 {
37680 KillTile(x, num + 1);
37681 }
37682 switch (type)
37683 {
37684 case 42:
37685 {
37686 int type2 = 0;
37687 if (num3 == 0)
37688 {
37689 type2 = 136;
37690 }
37691 else if (num3 == 7)
37692 {
37693 type2 = 1431;
37694 }
37695 else if (num3 == 8)
37696 {
37697 type2 = 1808;
37698 }
37699 else if (num3 == 9)
37700 {
37701 type2 = 1859;
37702 }
37703 else if (num3 < 10)
37704 {
37705 type2 = 1389 + num3;
37706 }
37707 else
37708 {
37709 switch (num3)
37710 {
37711 case 10:
37712 type2 = 2032;
37713 break;
37714 case 11:
37715 type2 = 2033;
37716 break;
37717 case 12:
37718 type2 = 2034;
37719 break;
37720 case 13:
37721 type2 = 2035;
37722 break;
37723 case 14:
37724 type2 = 2036;
37725 break;
37726 case 15:
37727 type2 = 2037;
37728 break;
37729 case 16:
37730 type2 = 2038;
37731 break;
37732 case 17:
37733 type2 = 2039;
37734 break;
37735 case 18:
37736 type2 = 2040;
37737 break;
37738 case 19:
37739 type2 = 2041;
37740 break;
37741 case 20:
37742 type2 = 2042;
37743 break;
37744 case 21:
37745 type2 = 2043;
37746 break;
37747 case 22:
37748 case 23:
37749 case 24:
37750 case 25:
37751 type2 = 2145 + num3 - 22;
37752 break;
37753 default:
37754 switch (num3)
37755 {
37756 case 26:
37757 type2 = 2226;
37758 break;
37759 case 27:
37760 type2 = 2530;
37761 break;
37762 case 28:
37763 type2 = 2546;
37764 break;
37765 case 29:
37766 type2 = 2564;
37767 break;
37768 case 30:
37769 type2 = 2579;
37770 break;
37771 case 31:
37772 type2 = 2641;
37773 break;
37774 case 32:
37775 type2 = 2642;
37776 break;
37777 case 33:
37778 type2 = 2820;
37779 break;
37780 case 34:
37781 type2 = 3138;
37782 break;
37783 case 35:
37784 type2 = 3140;
37785 break;
37786 case 36:
37787 type2 = 3139;
37788 break;
37789 case 37:
37790 type2 = 3891;
37791 break;
37792 case 38:
37793 type2 = 3943;
37794 break;
37795 case 39:
37796 type2 = 3970;
37797 break;
37798 case 40:
37799 type2 = 4157;
37800 break;
37801 case 41:
37802 type2 = 4178;
37803 break;
37804 case 42:
37805 type2 = 4199;
37806 break;
37807 case 43:
37808 type2 = 4220;
37809 break;
37810 case 44:
37811 type2 = 4309;
37812 break;
37813 case 45:
37814 type2 = 4578;
37815 break;
37816 case 46:
37817 type2 = 5160;
37818 break;
37819 case 47:
37820 type2 = 5181;
37821 break;
37822 case 48:
37823 type2 = 5202;
37824 break;
37825 }
37826 break;
37827 }
37828 }
37829 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, type2);
37830 break;
37831 }
37832 case 270:
37833 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 1993);
37834 break;
37835 case 271:
37836 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 2005);
37837 break;
37838 case 581:
37839 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 4848);
37840 break;
37841 case 660:
37842 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 5351);
37843 break;
37844 case 572:
37845 Item.NewItem(GetItemSource_FromTileBreak(x, num), x * 16, num * 16, 32, 32, 4695 + num3);
37846 break;
37847 }
37848 destroyObject = false;
37849 }
37850
37851 public static bool PlaceSmallPile(int i, int j, int X, int Y, ushort type = 185)
37852 {
37853 short frameY = (short)(Y * 18);
37854 short frameX = (short)(X * 18);
37855 if (Main.tile[i, j] == null)
37856 {
37857 Main.tile[i, j] = new Tile();
37858 }
37859 if (Main.tile[i + 1, j] == null)
37860 {
37861 Main.tile[i + 1, j] = new Tile();
37862 }
37863 if (Main.tile[i, j + 1] == null)
37864 {
37865 Main.tile[i, j + 1] = new Tile();
37866 }
37867 if (Main.tile[i + 1, j + 1] == null)
37868 {
37869 Main.tile[i + 1, j + 1] = new Tile();
37870 }
37871 if (Main.tile[i, j].lava())
37872 {
37873 return false;
37874 }
37875 if (Y == 1)
37876 {
37877 frameX = (short)(X * 36);
37878 bool flag = false;
37879 if (SolidTile2(i, j + 1) && SolidTile2(i + 1, j + 1) && !Main.tile[i, j].active() && !Main.tile[i + 1, j].active())
37880 {
37881 flag = true;
37882 }
37883 if (flag)
37884 {
37885 Main.tile[i, j].active(active: true);
37886 Main.tile[i, j].frameY = frameY;
37887 Main.tile[i, j].frameX = frameX;
37888 Main.tile[i, j].type = type;
37889 Main.tile[i + 1, j].active(active: true);
37890 Main.tile[i + 1, j].frameY = frameY;
37891 Main.tile[i + 1, j].frameX = (short)(frameX + 18);
37892 Main.tile[i + 1, j].type = type;
37893 return true;
37894 }
37895 }
37896 else if (SolidTile2(i, j + 1) && !Main.tile[i, j].active())
37897 {
37898 Main.tile[i, j].active(active: true);
37899 Main.tile[i, j].frameY = frameY;
37900 Main.tile[i, j].frameX = frameX;
37901 Main.tile[i, j].type = type;
37902 return true;
37903 }
37904 return false;
37905 }
37906
37907 public static void CheckPile(int i, int y)
37908 {
37909 if (Main.tile[i, y] == null)
37910 {
37911 Main.tile[i, y] = new Tile();
37912 }
37913 if (Main.tile[i + 1, y] == null)
37914 {
37915 Main.tile[i + 1, y] = new Tile();
37916 }
37917 if (Main.tile[i, y + 1] == null)
37918 {
37919 Main.tile[i, y + 1] = new Tile();
37920 }
37921 if (Main.tile[i + 1, y + 1] == null)
37922 {
37923 Main.tile[i + 1, y + 1] = new Tile();
37924 }
37925 Tile tile = Main.tile[i, y];
37926 if (tile.frameY == 18 || tile.type == 649)
37927 {
37928 Check2x1(i, y, tile.type);
37929 }
37930 else if (!SolidTileAllowBottomSlope(i, y + 1))
37931 {
37932 KillTile(i, y);
37933 }
37934 else
37935 {
37936 if (tile.type != 185)
37937 {
37938 return;
37939 }
37940 int num = tile.frameX / 18;
37941 Tile tile2 = Main.tile[i, y + 1];
37942 if (tile2 == null || !tile2.active() || tile2.type < 0 || tile2.type >= TileID.Count)
37943 {
37944 return;
37945 }
37946 ushort type = tile2.type;
37947 switch (num)
37948 {
37949 case 36:
37950 case 37:
37951 case 38:
37952 case 39:
37953 case 40:
37954 case 41:
37955 case 42:
37956 case 43:
37957 case 44:
37958 case 45:
37959 case 46:
37960 case 47:
37961 if (!TileID.Sets.Snow[type] && !TileID.Sets.Conversion.Ice[type] && type != 162 && type != 224)
37962 {
37963 KillTile(i, y);
37964 }
37965 break;
37966 case 54:
37967 case 55:
37968 case 56:
37969 case 57:
37970 case 58:
37971 case 59:
37972 case 73:
37973 case 74:
37974 case 75:
37975 case 76:
37977 {
37978 KillTile(i, y);
37979 }
37980 break;
37981 case 48:
37982 case 49:
37983 case 50:
37984 case 51:
37985 case 52:
37986 case 53:
37987 case 60:
37988 case 61:
37989 case 62:
37990 case 63:
37991 case 64:
37992 case 65:
37993 case 66:
37994 case 67:
37995 case 68:
37996 case 69:
37997 case 70:
37998 case 71:
37999 case 72:
38000 break;
38001 }
38002 }
38003 }
38004
38005 public static void Check2x1(int i, int y, ushort type)
38006 {
38007 if (destroyObject)
38008 {
38009 return;
38010 }
38011 int num = i;
38012 bool flag = true;
38013 if (Main.tile[num, y] == null)
38014 {
38015 Main.tile[num, y] = new Tile();
38016 }
38017 int num2 = Main.tile[num, y].frameX / 18;
38018 int num3 = num2 >> 1;
38019 int num4 = Main.tile[num, y].frameY / 18;
38020 num2 %= 2;
38021 num -= num2;
38022 if (Main.tile[num, y] == null)
38023 {
38024 Main.tile[num, y] = new Tile();
38025 }
38026 if (Main.tile[num + 1, y] == null)
38027 {
38028 Main.tile[num + 1, y] = new Tile();
38029 }
38030 if (Main.tile[num, y + 1] == null)
38031 {
38032 Main.tile[num, y + 1] = new Tile();
38033 }
38034 if (Main.tile[num + 1, y + 1] == null)
38035 {
38036 Main.tile[num + 1, y + 1] = new Tile();
38037 }
38038 if (Main.tile[num + 1, y].frameX == Main.tile[num, y].frameX + 18 && Main.tile[num, y].type == type && Main.tile[num + 1, y].type == type)
38039 {
38040 flag = false;
38041 }
38042 if (type == 29 || type == 103 || type == 462)
38043 {
38044 if (!Main.tile[num, y + 1].active() || !Main.tileTable[Main.tile[num, y + 1].type] || Main.tile[num, y + 1].halfBrick() || Main.tile[num, y + 1].topSlope())
38045 {
38046 flag = true;
38047 }
38048 if (!Main.tile[num + 1, y + 1].active() || !Main.tileTable[Main.tile[num + 1, y + 1].type] || Main.tile[num + 1, y + 1].halfBrick() || Main.tile[num + 1, y + 1].topSlope())
38049 {
38050 flag = true;
38051 }
38052 }
38053 else
38054 {
38055 if (!SolidTileAllowBottomSlope(num, y + 1))
38056 {
38057 flag = true;
38058 }
38059 if (!SolidTileAllowBottomSlope(num + 1, y + 1))
38060 {
38061 flag = true;
38062 }
38063 }
38064 if (type == 185)
38065 {
38066 if (Main.tile[num, y].frameX >= 1368 && Main.tile[num, y].frameX <= 1458 && Main.tile[num, y + 1].type != 2 && Main.tile[num + 1, y + 1].type != 2 && Main.tile[num, y + 1].type != 477 && Main.tile[num + 1, y + 1].type != 477 && Main.tile[num, y + 1].type != 492 && Main.tile[num + 1, y + 1].type != 492)
38067 {
38068 Main.tile[num, y].frameX -= 1368;
38069 Main.tile[num + 1, y].frameX -= 1368;
38070 }
38071 Tile tile = Main.tile[num, y];
38072 int num5 = tile.frameX / 36;
38073 num5 += (tile.frameY / 18 - 1) * 52;
38074 for (int j = num; j < num + 2; j++)
38075 {
38076 Tile tile2 = Main.tile[j, y + 1];
38077 if (tile2 == null || !tile2.active() || tile2.type < 0 || tile2.type >= TileID.Count)
38078 {
38079 continue;
38080 }
38081 ushort type2 = tile2.type;
38082 switch (num5)
38083 {
38084 case 25:
38085 case 26:
38086 case 27:
38087 case 28:
38088 case 29:
38089 case 30:
38090 if (!TileID.Sets.Snow[type2] && !TileID.Sets.Conversion.Ice[type2] && type2 != 162 && type2 != 224)
38091 {
38092 flag = true;
38093 }
38094 break;
38095 case 41:
38096 case 42:
38097 case 43:
38098 case 44:
38099 case 45:
38100 case 46:
38101 case 62:
38102 case 63:
38103 case 64:
38105 {
38106 flag = true;
38107 }
38108 break;
38109 }
38110 }
38111 }
38112 if (!flag)
38113 {
38114 return;
38115 }
38116 int frameX = Main.tile[num, y].frameX;
38117 if (!Main.tile[num, y].active())
38118 {
38119 frameX = Main.tile[num + 1, y].frameX;
38120 }
38121 destroyObject = true;
38122 if (Main.tile[num, y].type == type)
38123 {
38124 KillTile(num, y);
38125 }
38126 if (Main.tile[num + 1, y].type == type)
38127 {
38128 KillTile(num + 1, y);
38129 }
38130 if (type == 16)
38131 {
38132 if (num3 == 1)
38133 {
38134 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 716);
38135 }
38136 else
38137 {
38138 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 35);
38139 }
38140 }
38141 if (type == 18)
38142 {
38143 int type3 = 36;
38144 if (num3 >= 1 && num3 <= 3)
38145 {
38146 type3 = 634 + num3;
38147 }
38148 else if (num3 >= 4 && num3 <= 8)
38149 {
38150 type3 = 807 + num3;
38151 }
38152 else
38153 {
38154 switch (num3)
38155 {
38156 case 9:
38157 type3 = 916;
38158 break;
38159 case 10:
38160 type3 = 1145;
38161 break;
38162 case 11:
38163 type3 = 1398;
38164 break;
38165 case 12:
38166 type3 = 1401;
38167 break;
38168 case 13:
38169 type3 = 1404;
38170 break;
38171 case 14:
38172 type3 = 1461;
38173 break;
38174 case 15:
38175 type3 = 1511;
38176 break;
38177 case 16:
38178 type3 = 1795;
38179 break;
38180 case 17:
38181 type3 = 1817;
38182 break;
38183 case 18:
38184 type3 = 2229;
38185 break;
38186 case 19:
38187 type3 = 2251;
38188 break;
38189 case 20:
38190 type3 = 2252;
38191 break;
38192 case 21:
38193 type3 = 2253;
38194 break;
38195 case 22:
38196 type3 = 2534;
38197 break;
38198 case 23:
38199 type3 = 673;
38200 break;
38201 case 24:
38202 type3 = 2631;
38203 break;
38204 case 25:
38205 type3 = 2632;
38206 break;
38207 case 26:
38208 type3 = 2633;
38209 break;
38210 case 27:
38211 type3 = 2826;
38212 break;
38213 case 28:
38214 type3 = 3156;
38215 break;
38216 case 29:
38217 type3 = 3158;
38218 break;
38219 case 30:
38220 type3 = 3157;
38221 break;
38222 case 31:
38223 type3 = 3909;
38224 break;
38225 case 32:
38226 type3 = 3910;
38227 break;
38228 case 33:
38229 type3 = 3949;
38230 break;
38231 case 34:
38232 type3 = 3975;
38233 break;
38234 case 35:
38235 type3 = 4163;
38236 break;
38237 case 36:
38238 type3 = 4184;
38239 break;
38240 case 37:
38241 type3 = 4205;
38242 break;
38243 case 38:
38244 type3 = 4226;
38245 break;
38246 case 39:
38247 type3 = 4315;
38248 break;
38249 case 40:
38250 type3 = 4584;
38251 break;
38252 case 41:
38253 type3 = 5166;
38254 break;
38255 case 42:
38256 type3 = 5187;
38257 break;
38258 case 43:
38259 type3 = 5208;
38260 break;
38261 }
38262 }
38263 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, type3);
38264 }
38265 if (type == 185)
38266 {
38267 if (frameX >= 576 && frameX <= 610)
38268 {
38269 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38270 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38271 if (genRand.Next(3) != 0)
38272 {
38273 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38274 }
38275 if (genRand.Next(3) != 0)
38276 {
38277 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38278 }
38279 if (genRand.Next(2) == 0)
38280 {
38281 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38282 }
38283 if (genRand.Next(2) == 0)
38284 {
38285 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38286 }
38287 if (genRand.Next(3) == 0)
38288 {
38289 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38290 }
38291 if (genRand.Next(3) == 0)
38292 {
38293 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38294 }
38295 if (genRand.Next(4) == 0)
38296 {
38297 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38298 }
38299 if (genRand.Next(4) == 0)
38300 {
38301 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38302 }
38303 if (genRand.Next(5) == 0)
38304 {
38305 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(10, 100));
38306 }
38307 if (genRand.Next(5) == 0)
38308 {
38309 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 71, genRand.Next(20, 100));
38310 }
38311 }
38312 if (frameX >= 612 && frameX <= 646)
38313 {
38314 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 72, genRand.Next(10, 100));
38315 if (genRand.Next(2) == 0)
38316 {
38317 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 72, genRand.Next(20, 100));
38318 }
38319 if (genRand.Next(3) == 0)
38320 {
38321 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 72, genRand.Next(30, 100));
38322 }
38323 }
38324 if (frameX >= 648 && frameX <= 682)
38325 {
38326 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 73, genRand.Next(1, 6));
38327 if (genRand.Next(2) == 0)
38328 {
38329 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 73, genRand.Next(2, 6));
38330 }
38331 if (genRand.Next(3) == 0)
38332 {
38333 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 73, genRand.Next(3, 6));
38334 }
38335 }
38336 if (frameX >= 684 && frameX <= 718)
38337 {
38338 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 181, genRand.Next(1, 4));
38339 }
38340 if (frameX >= 720 && frameX <= 754)
38341 {
38342 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 180, genRand.Next(1, 4));
38343 }
38344 if (frameX >= 756 && frameX <= 790)
38345 {
38346 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 177, genRand.Next(1, 4));
38347 }
38348 if (frameX >= 792 && frameX <= 826)
38349 {
38350 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 179, genRand.Next(1, 4));
38351 }
38352 if (frameX >= 828 && frameX <= 862)
38353 {
38354 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 178, genRand.Next(1, 4));
38355 }
38356 if (frameX >= 864 && frameX <= 898)
38357 {
38358 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 182, genRand.Next(1, 4));
38359 }
38360 }
38361 if (type == 462)
38362 {
38363 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 3795);
38364 }
38365 if (type == 29)
38366 {
38367 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 87);
38368 SoundEngine.PlaySound(13, i * 16, y * 16);
38369 }
38370 switch (type)
38371 {
38372 case 103:
38373 {
38374 int type4 = 356;
38375 if (num3 == 1)
38376 {
38377 type4 = 2235;
38378 }
38379 if (num3 == 2)
38380 {
38381 type4 = 2242;
38382 }
38383 if (num3 == 3)
38384 {
38385 type4 = 2243;
38386 }
38387 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, type4);
38388 SoundEngine.PlaySound(13, i * 16, y * 16);
38389 break;
38390 }
38391 case 134:
38392 if (num3 == 1)
38393 {
38394 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 1220);
38395 }
38396 else
38397 {
38398 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, 525);
38399 }
38400 break;
38401 case 649:
38402 {
38403 num3 += num4 * 53;
38404 int num6 = 0;
38405 if (num3 < 6)
38406 {
38407 num6 = 3;
38408 }
38409 else if (num3 < 16)
38410 {
38411 num6 = 154;
38412 }
38413 else if (num3 < 17)
38414 {
38415 num6 = 71;
38416 }
38417 else if (num3 < 18)
38418 {
38419 num6 = 72;
38420 }
38421 else if (num3 < 19)
38422 {
38423 num6 = 73;
38424 }
38425 else if (num3 < 20)
38426 {
38427 num6 = 181;
38428 }
38429 else if (num3 < 21)
38430 {
38431 num6 = 180;
38432 }
38433 else if (num3 < 22)
38434 {
38435 num6 = 177;
38436 }
38437 else if (num3 < 23)
38438 {
38439 num6 = 179;
38440 }
38441 else if (num3 < 24)
38442 {
38443 num6 = 178;
38444 }
38445 else if (num3 < 25)
38446 {
38447 num6 = 182;
38448 }
38449 else if (num3 < 31)
38450 {
38451 num6 = 593;
38452 }
38453 else if (num3 < 34)
38454 {
38455 num6 = 9;
38456 }
38457 else if (num3 < 38)
38458 {
38459 num6 = 150;
38460 }
38461 else if (num3 < 41)
38462 {
38463 num6 = 3;
38464 }
38465 else if (num3 < 47)
38466 {
38467 num6 = 3271;
38468 }
38469 else if (num3 < 53)
38470 {
38471 num6 = 3086;
38472 }
38473 else if (num3 < 59)
38474 {
38475 num6 = 3081;
38476 }
38477 else if (num3 < 62)
38478 {
38479 num6 = 62;
38480 }
38481 else if (num3 < 65)
38482 {
38483 num6 = 169;
38484 }
38485 if (num6 != 0)
38486 {
38487 Item.NewItem(GetItemSource_FromTileBreak(num, y), num * 16, y * 16, 32, 32, num6);
38488 }
38489 break;
38490 }
38491 }
38492 destroyObject = false;
38493 SquareTileFrame(num, y);
38494 SquareTileFrame(num + 1, y);
38495 }
38496
38497 public static void Place2x1(int x, int y, ushort type, int style = 0)
38498 {
38499 if (Main.tile[x, y] == null)
38500 {
38501 Main.tile[x, y] = new Tile();
38502 }
38503 if (Main.tile[x + 1, y] == null)
38504 {
38505 Main.tile[x + 1, y] = new Tile();
38506 }
38507 if (Main.tile[x, y + 1] == null)
38508 {
38509 Main.tile[x, y + 1] = new Tile();
38510 }
38511 if (Main.tile[x + 1, y + 1] == null)
38512 {
38513 Main.tile[x + 1, y + 1] = new Tile();
38514 }
38515 bool flag = false;
38516 if (type != 29 && type != 103 && SolidTile2(x, y + 1) && SolidTile2(x + 1, y + 1) && !Main.tile[x, y].active() && !Main.tile[x + 1, y].active())
38517 {
38518 flag = true;
38519 }
38520 else if ((type == 29 || type == 103) && Main.tile[x, y + 1].active() && Main.tile[x + 1, y + 1].active() && Main.tileTable[Main.tile[x, y + 1].type] && Main.tileTable[Main.tile[x + 1, y + 1].type] && !Main.tile[x, y].active() && !Main.tile[x + 1, y].active())
38521 {
38522 flag = true;
38523 }
38524 if (flag)
38525 {
38526 Main.tile[x, y].active(active: true);
38527 Main.tile[x, y].frameY = 0;
38528 Main.tile[x, y].frameX = (short)(36 * style);
38529 Main.tile[x, y].type = type;
38530 Main.tile[x + 1, y].active(active: true);
38531 Main.tile[x + 1, y].frameY = 0;
38532 Main.tile[x + 1, y].frameX = (short)(36 * style + 18);
38533 Main.tile[x + 1, y].type = type;
38534 }
38535 }
38536
38537 public static void Check4x2(int i, int j, int type)
38538 {
38539 if (destroyObject)
38540 {
38541 return;
38542 }
38543 bool flag = false;
38544 int num = i;
38545 num = ((type != 487) ? (num + Main.tile[i, j].frameX / 18 * -1) : (num + Main.tile[i, j].frameX / 18 % 4 * -1));
38546 if ((type == 79 || type == 90) && Main.tile[i, j].frameX >= 72)
38547 {
38548 num += 4;
38549 }
38550 int num2 = Main.tile[i, j].frameY / 18;
38551 int num3 = 0;
38552 while (num2 > 1)
38553 {
38554 num2 -= 2;
38555 num3++;
38556 }
38557 num2 = j - num2;
38558 if (type == 487)
38559 {
38560 num3 = Main.tile[i, j].frameX / 72;
38561 }
38562 for (int k = num; k < num + 4; k++)
38563 {
38564 for (int l = num2; l < num2 + 2; l++)
38565 {
38566 int num4 = (k - num) * 18;
38567 int num5 = (l - num2) * 18;
38568 if ((type == 79 || type == 90) && Main.tile[i, j].frameX >= 72)
38569 {
38570 num4 = (k - num + 4) * 18;
38571 }
38572 if (type == 487)
38573 {
38574 num4 += num3 * 72;
38575 }
38576 else
38577 {
38578 num5 += num3 * 36;
38579 }
38580 if (Main.tile[k, l] == null)
38581 {
38582 Main.tile[k, l] = new Tile();
38583 }
38584 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != num4 || Main.tile[k, l].frameY != num5)
38585 {
38586 flag = true;
38587 }
38588 }
38589 if (Main.tile[k, num2 + 2] == null)
38590 {
38591 Main.tile[k, num2 + 2] = new Tile();
38592 }
38593 if (!SolidTileAllowBottomSlope(k, num2 + 2) && (!Main.tile[k, num2 + 2].active() || !TileID.Sets.Platforms[Main.tile[k, num2 + 2].type]))
38594 {
38595 flag = true;
38596 }
38597 }
38598 if (!flag)
38599 {
38600 return;
38601 }
38602 destroyObject = true;
38603 for (int m = num; m < num + 4; m++)
38604 {
38605 for (int n = num2; n < num2 + 3; n++)
38606 {
38607 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
38608 {
38609 KillTile(m, n);
38610 }
38611 }
38612 }
38613 if (type == 79)
38614 {
38615 int num6 = 0;
38616 switch (num3)
38617 {
38618 case 0:
38619 num6 = 224;
38620 break;
38621 case 4:
38622 num6 = 920;
38623 break;
38624 case 9:
38625 case 10:
38626 case 11:
38627 case 12:
38628 num6 = 1710 + num3;
38629 break;
38630 default:
38631 num6 = ((num3 >= 5 && num3 <= 8) ? (1465 + num3) : ((num3 >= 13 && num3 <= 18) ? (2066 + num3 - 13) : (num3 switch
38632 {
38633 19 => 2139,
38634 20 => 2140,
38635 21 => 2231,
38636 22 => 2520,
38637 23 => 2538,
38638 24 => 2553,
38639 25 => 2568,
38640 26 => 2669,
38641 27 => 2811,
38642 28 => 3162,
38643 29 => 3164,
38644 30 => 3163,
38645 31 => 3897,
38646 32 => 3932,
38647 33 => 3959,
38648 34 => 4146,
38649 35 => 4167,
38650 36 => 4188,
38651 37 => 4209,
38652 38 => 4299,
38653 39 => 4567,
38654 40 => 5149,
38655 41 => 5170,
38656 42 => 5191,
38657 _ => num3 + 643,
38658 })));
38659 break;
38660 }
38661 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num6);
38662 }
38663 if (type == 487)
38664 {
38665 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, GetItemDrop_PicnicTables(num3));
38666 }
38667 if (type == 90)
38668 {
38669 int type2 = 0;
38670 switch (num3)
38671 {
38672 case 0:
38673 type2 = 336;
38674 break;
38675 case 1:
38676 case 2:
38677 case 3:
38678 case 4:
38679 case 5:
38680 case 6:
38681 case 7:
38682 case 8:
38683 case 9:
38684 case 10:
38685 type2 = 2072 + num3 - 1;
38686 break;
38687 default:
38688 if (num3 >= 11 && num3 <= 15)
38689 {
38690 type2 = 2124 + num3 - 11;
38691 break;
38692 }
38693 switch (num3)
38694 {
38695 case 16:
38696 type2 = 2232;
38697 break;
38698 case 17:
38699 type2 = 2519;
38700 break;
38701 case 18:
38702 type2 = 2537;
38703 break;
38704 case 19:
38705 type2 = 2552;
38706 break;
38707 case 20:
38708 type2 = 2567;
38709 break;
38710 case 21:
38711 type2 = 2658;
38712 break;
38713 case 22:
38714 type2 = 2659;
38715 break;
38716 case 23:
38717 type2 = 2660;
38718 break;
38719 case 24:
38720 type2 = 2661;
38721 break;
38722 case 25:
38723 type2 = 2662;
38724 break;
38725 case 26:
38726 type2 = 2663;
38727 break;
38728 case 27:
38729 type2 = 2810;
38730 break;
38731 case 28:
38732 type2 = 3159;
38733 break;
38734 case 29:
38735 type2 = 3161;
38736 break;
38737 case 30:
38738 type2 = 3160;
38739 break;
38740 case 31:
38741 type2 = 3895;
38742 break;
38743 case 32:
38744 type2 = 3931;
38745 break;
38746 case 33:
38747 type2 = 3958;
38748 break;
38749 case 34:
38750 type2 = 4145;
38751 break;
38752 case 35:
38753 type2 = 4166;
38754 break;
38755 case 36:
38756 type2 = 4187;
38757 break;
38758 case 37:
38759 type2 = 4208;
38760 break;
38761 case 38:
38762 type2 = 4298;
38763 break;
38764 case 39:
38765 type2 = 4566;
38766 break;
38767 case 40:
38768 type2 = 5148;
38769 break;
38770 case 41:
38771 type2 = 5169;
38772 break;
38773 case 42:
38774 type2 = 5190;
38775 break;
38776 }
38777 break;
38778 }
38779 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type2);
38780 }
38781 destroyObject = false;
38782 for (int num7 = num - 1; num7 < num + 4; num7++)
38783 {
38784 for (int num8 = num2 - 1; num8 < num2 + 4; num8++)
38785 {
38786 TileFrame(num7, num8);
38787 }
38788 }
38789 }
38790
38791 private static bool OasisPlantWaterCheck(int x, int y, bool boost = false)
38792 {
38793 int num = 45;
38794 int num2 = 20;
38795 if (boost)
38796 {
38797 num += 4;
38798 num2 += 3;
38799 }
38800 int num3 = 20;
38801 int num4 = 0;
38802 for (int i = x - num; i <= x + num; i++)
38803 {
38804 if (x <= beachDistance || x >= Main.maxTilesX - beachDistance)
38805 {
38806 continue;
38807 }
38808 for (int j = y - num2; j <= y + num2; j++)
38809 {
38810 if (InWorld(i, j) && !SolidTile(i, j))
38811 {
38812 num4 += Main.tile[i, j].liquid;
38813 }
38814 }
38815 }
38816 if (num4 / 255 >= num3)
38817 {
38818 return true;
38819 }
38820 return false;
38821 }
38822
38823 public static void PlaceOasisPlant(int X, int Y, ushort type = 530)
38824 {
38825 int num = genRand.Next(9);
38826 int num2 = 0;
38828 {
38829 return;
38830 }
38831 bool flag = true;
38832 for (int i = X - 1; i < X + 2; i++)
38833 {
38834 for (int j = Y - 1; j < Y + 1; j++)
38835 {
38836 if (Main.tile[i, j] == null)
38837 {
38838 Main.tile[i, j] = new Tile();
38839 }
38840 if (Main.tile[i, j].active() && Main.tile[i, j].type != 529)
38841 {
38842 flag = false;
38843 }
38844 if (Main.tile[i, j].liquid > 0)
38845 {
38846 flag = false;
38847 }
38848 }
38849 if (Main.tile[i, Y + 1] == null)
38850 {
38851 Main.tile[i, Y + 1] = new Tile();
38852 }
38853 if (!SolidTile(i, Y + 1) || !TileID.Sets.Conversion.Sand[Main.tile[i, Y + 1].type])
38854 {
38855 flag = false;
38856 }
38857 }
38858 if (flag && OasisPlantWaterCheck(X, Y))
38859 {
38860 short num3 = (short)(54 * num);
38861 short num4 = (short)(36 * num2);
38862 Main.tile[X - 1, Y - 1].active(active: true);
38863 Main.tile[X - 1, Y - 1].frameY = num4;
38864 Main.tile[X - 1, Y - 1].frameX = num3;
38865 Main.tile[X - 1, Y - 1].type = type;
38866 Main.tile[X, Y - 1].active(active: true);
38867 Main.tile[X, Y - 1].frameY = num4;
38868 Main.tile[X, Y - 1].frameX = (short)(num3 + 18);
38869 Main.tile[X, Y - 1].type = type;
38870 Main.tile[X + 1, Y - 1].active(active: true);
38871 Main.tile[X + 1, Y - 1].frameY = num4;
38872 Main.tile[X + 1, Y - 1].frameX = (short)(num3 + 36);
38873 Main.tile[X + 1, Y - 1].type = type;
38874 Main.tile[X - 1, Y].active(active: true);
38875 Main.tile[X - 1, Y].frameY = (short)(num4 + 18);
38876 Main.tile[X - 1, Y].frameX = num3;
38877 Main.tile[X - 1, Y].type = type;
38878 Main.tile[X, Y].active(active: true);
38879 Main.tile[X, Y].frameY = (short)(num4 + 18);
38880 Main.tile[X, Y].frameX = (short)(num3 + 18);
38881 Main.tile[X, Y].type = type;
38882 Main.tile[X + 1, Y].active(active: true);
38883 Main.tile[X + 1, Y].frameY = (short)(num4 + 18);
38884 Main.tile[X + 1, Y].frameX = (short)(num3 + 36);
38885 Main.tile[X + 1, Y].type = type;
38886 }
38887 }
38888
38889 public static void CheckOasisPlant(int i, int j, int type = 530)
38890 {
38891 if (destroyObject)
38892 {
38893 return;
38894 }
38895 bool flag = false;
38896 int num = j;
38898 int num2 = tileSafely.frameY % 36;
38899 num += num2 / 18 * -1;
38900 int num3 = tileSafely.frameX / 18;
38901 int num4 = 0;
38902 _ = Framing.GetTileSafely(num3, num).frameY / 36;
38903 while (num3 > 2)
38904 {
38905 num3 -= 3;
38906 num4++;
38907 }
38908 num3 = i - num3;
38909 int num5 = num4 * 54;
38910 for (int k = num3; k < num3 + 3; k++)
38911 {
38912 for (int l = num; l < num + 2; l++)
38913 {
38914 if (Main.tile[k, l] == null)
38915 {
38916 Main.tile[k, l] = new Tile();
38917 }
38918 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num3) * 18 + num5 || Main.tile[k, l].frameY != (l - num) * 18)
38919 {
38920 flag = true;
38921 }
38922 }
38923 if (Main.tile[k, num + 2] == null)
38924 {
38925 Main.tile[k, num + 2] = new Tile();
38926 }
38927 if (!SolidTile(k, num + 2) || !TileID.Sets.Conversion.Sand[Main.tile[k, num + 2].type])
38928 {
38929 flag = true;
38930 }
38931 }
38932 if (!flag)
38933 {
38934 return;
38935 }
38936 _ = Main.tile[i, j].frameX;
38937 destroyObject = true;
38938 for (int m = num3; m < num3 + 3; m++)
38939 {
38940 for (int n = num; n < num + 2; n++)
38941 {
38942 if (Main.tile[m, n] == null)
38943 {
38944 Main.tile[m, n] = new Tile();
38945 }
38946 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
38947 {
38948 KillTile(m, n);
38949 }
38950 }
38951 }
38952 destroyObject = false;
38953 for (int num6 = num3 - 1; num6 < num3 + 4; num6++)
38954 {
38955 for (int num7 = num - 1; num7 < num + 3; num7++)
38956 {
38957 TileFrame(num6, num7);
38958 }
38959 }
38960 }
38961
38962 public static void GetCactusType(int tileX, int tileY, int frameX, int frameY, out bool evil, out bool good, out bool crimson)
38963 {
38964 evil = false;
38965 good = false;
38966 crimson = false;
38967 int num = tileX;
38968 if (frameX == 36)
38969 {
38970 num--;
38971 }
38972 if (frameX == 54)
38973 {
38974 num++;
38975 }
38976 if (frameX == 108)
38977 {
38978 num = ((frameY != 18) ? (num + 1) : (num - 1));
38979 }
38980 int num2 = tileY;
38981 bool flag = false;
38982 Tile tile = Main.tile[num, num2];
38983 if (tile == null)
38984 {
38985 return;
38986 }
38987 if (tile.type == 80 && tile.active())
38988 {
38989 flag = true;
38990 }
38991 while (tile != null && (!tile.active() || !Main.tileSolid[tile.type] || !flag))
38992 {
38993 if (tile.type == 80 && tile.active())
38994 {
38995 flag = true;
38996 }
38997 num2++;
38998 if (num2 > tileY + 20)
38999 {
39000 break;
39001 }
39002 tile = Main.tile[num, num2];
39003 }
39004 if (tile.type == 112)
39005 {
39006 evil = true;
39007 }
39008 if (tile.type == 116)
39009 {
39010 good = true;
39011 }
39012 if (tile.type == 234)
39013 {
39014 crimson = true;
39015 }
39016 }
39017
39018 public static void GetBiomeInfluence(int startX, int endX, int startY, int endY, out int corruptCount, out int crimsonCount, out int hallowedCount)
39019 {
39020 corruptCount = 0;
39021 crimsonCount = 0;
39022 hallowedCount = 0;
39023 for (int i = startX; i <= endX; i++)
39024 {
39025 for (int j = startY; j <= endY; j++)
39026 {
39027 Tile tile = Main.tile[i, j];
39028 if (tile != null)
39029 {
39030 if (TileID.Sets.Corrupt[tile.type])
39031 {
39032 corruptCount++;
39033 }
39034 if (TileID.Sets.Crimson[tile.type])
39035 {
39036 crimsonCount++;
39037 }
39038 if (TileID.Sets.Hallow[tile.type])
39039 {
39040 hallowedCount++;
39041 }
39042 }
39043 }
39044 }
39045 }
39046
39047 public static void PlaceJunglePlant(int X2, int Y2, ushort type, int styleX, int styleY)
39048 {
39049 if (styleY > 0 || type == 236 || type == 238)
39050 {
39051 int num = Y2;
39052 if (type == 95 || type == 126)
39053 {
39054 num++;
39055 }
39057 {
39058 return;
39059 }
39060 bool flag = true;
39061 for (int i = X2 - 1; i < X2 + 1; i++)
39062 {
39063 for (int j = num - 1; j < num + 1; j++)
39064 {
39065 if (Main.tile[i, j] == null)
39066 {
39067 Main.tile[i, j] = new Tile();
39068 }
39069 Tile tile = Main.tile[i, j];
39070 if (tile.active() && tile.type != 61 && tile.type != 62 && tile.type != 655 && tile.type != 69 && tile.type != 74 && (type != 236 || tile.type != 233) && (type != 238 || tile.type != 233) && (tile.type != 185 || tile.frameY != 0))
39071 {
39072 flag = false;
39073 }
39074 if (type == 98 && tile.liquid > 0)
39075 {
39076 flag = false;
39077 }
39078 }
39079 if (Main.tile[i, num + 1] == null)
39080 {
39081 Main.tile[i, num + 1] = new Tile();
39082 }
39083 if (!SolidTile(i, num + 1) || Main.tile[i, num + 1].type != 60)
39084 {
39085 flag = false;
39086 }
39087 }
39088 if (!flag)
39089 {
39090 return;
39091 }
39092 for (int k = X2 - 1; k < X2 + 1; k++)
39093 {
39094 for (int l = num - 1; l < num + 1; l++)
39095 {
39096 if (Main.tile[k, l] != null && Main.tile[k, l].active())
39097 {
39098 KillTile(k, l, fail: false, effectOnly: false, noItem: true);
39099 }
39100 }
39101 }
39102 short num2 = 36;
39103 if (type == 236 || type == 238)
39104 {
39105 num2 = 0;
39106 }
39107 short num3 = (short)(36 * styleX);
39108 Main.tile[X2 - 1, num - 1].active(active: true);
39109 Main.tile[X2 - 1, num - 1].frameY = num2;
39110 Main.tile[X2 - 1, num - 1].frameX = num3;
39111 Main.tile[X2 - 1, num - 1].type = type;
39112 Main.tile[X2, num - 1].active(active: true);
39113 Main.tile[X2, num - 1].frameY = num2;
39114 Main.tile[X2, num - 1].frameX = (short)(18 + num3);
39115 Main.tile[X2, num - 1].type = type;
39116 Main.tile[X2 - 1, num].active(active: true);
39117 Main.tile[X2 - 1, num].frameY = (short)(num2 + 18);
39118 Main.tile[X2 - 1, num].frameX = num3;
39119 Main.tile[X2 - 1, num].type = type;
39120 Main.tile[X2, num].active(active: true);
39121 Main.tile[X2, num].frameY = (short)(num2 + 18);
39122 Main.tile[X2, num].frameX = (short)(18 + num3);
39123 Main.tile[X2, num].type = type;
39124 }
39125 else
39126 {
39128 {
39129 return;
39130 }
39131 bool flag2 = true;
39132 for (int m = X2 - 1; m < X2 + 2; m++)
39133 {
39134 for (int n = Y2 - 1; n < Y2 + 1; n++)
39135 {
39136 if (Main.tile[m, n] == null)
39137 {
39138 Main.tile[m, n] = new Tile();
39139 }
39140 if (Main.tile[m, n].active() && Main.tile[m, n].type != 61 && Main.tile[m, n].type != 62 && Main.tile[m, n].type != 69 && Main.tile[m, n].type != 655 && Main.tile[m, n].type != 74 && (Main.tile[m, n].type != 185 || Main.tile[m, n].frameY != 0))
39141 {
39142 flag2 = false;
39143 }
39144 }
39145 if (Main.tile[m, Y2 + 1] == null)
39146 {
39147 Main.tile[m, Y2 + 1] = new Tile();
39148 }
39149 if (!SolidTile(m, Y2 + 1) || Main.tile[m, Y2 + 1].type != 60)
39150 {
39151 flag2 = false;
39152 }
39153 }
39154 if (!flag2)
39155 {
39156 return;
39157 }
39158 for (int num4 = X2 - 1; num4 < X2 + 2; num4++)
39159 {
39160 for (int num5 = Y2 - 1; num5 < Y2 + 1; num5++)
39161 {
39162 if (Main.tile[num4, num5] != null && Main.tile[num4, num5].active())
39163 {
39164 KillTile(num4, num5, fail: false, effectOnly: false, noItem: true);
39165 }
39166 }
39167 }
39168 short num6 = (short)(54 * styleX);
39169 Main.tile[X2 - 1, Y2 - 1].active(active: true);
39170 Main.tile[X2 - 1, Y2 - 1].frameY = 0;
39171 Main.tile[X2 - 1, Y2 - 1].frameX = num6;
39172 Main.tile[X2 - 1, Y2 - 1].type = type;
39173 Main.tile[X2, Y2 - 1].active(active: true);
39174 Main.tile[X2, Y2 - 1].frameY = 0;
39175 Main.tile[X2, Y2 - 1].frameX = (short)(num6 + 18);
39176 Main.tile[X2, Y2 - 1].type = type;
39177 Main.tile[X2 + 1, Y2 - 1].active(active: true);
39178 Main.tile[X2 + 1, Y2 - 1].frameY = 0;
39179 Main.tile[X2 + 1, Y2 - 1].frameX = (short)(num6 + 36);
39180 Main.tile[X2 + 1, Y2 - 1].type = type;
39181 Main.tile[X2 - 1, Y2].active(active: true);
39182 Main.tile[X2 - 1, Y2].frameY = 18;
39183 Main.tile[X2 - 1, Y2].frameX = num6;
39184 Main.tile[X2 - 1, Y2].type = type;
39185 Main.tile[X2, Y2].active(active: true);
39186 Main.tile[X2, Y2].frameY = 18;
39187 Main.tile[X2, Y2].frameX = (short)(num6 + 18);
39188 Main.tile[X2, Y2].type = type;
39189 Main.tile[X2 + 1, Y2].active(active: true);
39190 Main.tile[X2 + 1, Y2].frameY = 18;
39191 Main.tile[X2 + 1, Y2].frameX = (short)(num6 + 36);
39192 Main.tile[X2 + 1, Y2].type = type;
39193 }
39194 }
39195
39196 public static void CheckJunglePlant(int i, int j, int type)
39197 {
39198 if (destroyObject)
39199 {
39200 return;
39201 }
39202 if (Main.tile[i, j].frameY >= 36 || Main.tile[i, j].type == 236 || Main.tile[i, j].type == 238)
39203 {
39204 bool flag = false;
39205 int num = Main.tile[i, j].frameX / 18;
39206 int num2 = 0;
39207 while (num > 1)
39208 {
39209 num -= 2;
39210 num2++;
39211 }
39212 num = i - num;
39213 int num3 = 36;
39214 if (type == 236 || type == 238)
39215 {
39216 num3 = 0;
39217 }
39218 int num4;
39219 for (num4 = Main.tile[i, j].frameY / 18; num4 > 1; num4 -= 2)
39220 {
39221 }
39222 num4 = j - num4;
39223 int num5 = num2 * 36;
39224 for (int k = num; k < num + 2; k++)
39225 {
39226 for (int l = num4; l < num4 + 2; l++)
39227 {
39228 if (Main.tile[k, l] == null)
39229 {
39230 Main.tile[k, l] = new Tile();
39231 }
39232 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num) * 18 + num5 || Main.tile[k, l].frameY != (l - num4) * 18 + num3)
39233 {
39234 flag = true;
39235 }
39236 }
39237 if (Main.tile[k, num4 + 2] == null)
39238 {
39239 Main.tile[k, num4 + 2] = new Tile();
39240 }
39241 if (!SolidTile(k, num4 + 2) || Main.tile[k, num4 + 2].type != 60)
39242 {
39243 flag = true;
39244 }
39245 }
39246 if (!flag)
39247 {
39248 return;
39249 }
39250 if (type == 238)
39251 {
39252 float num6 = i * 16;
39253 float num7 = j * 16;
39254 float num8 = -1f;
39255 int plr = 0;
39256 for (int m = 0; m < 255; m++)
39257 {
39258 float num9 = Math.Abs(Main.player[m].position.X - num6) + Math.Abs(Main.player[m].position.Y - num7);
39259 if (num9 < num8 || num8 == -1f)
39260 {
39261 plr = m;
39262 num8 = num9;
39263 }
39264 }
39265 if (num8 / 16f < 50f)
39266 {
39267 NPC.SpawnOnPlayer(plr, 262);
39268 }
39269 }
39270 if (type == 236)
39271 {
39272 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1291);
39273 }
39274 _ = Main.tile[i, j].frameX;
39275 destroyObject = true;
39276 for (int n = num; n < num + 2; n++)
39277 {
39278 for (int num10 = num4; num10 < num4 + 2; num10++)
39279 {
39280 if (Main.tile[n, num10] == null)
39281 {
39282 Main.tile[n, num10] = new Tile();
39283 }
39284 if (Main.tile[n, num10].type == type && Main.tile[n, num10].active())
39285 {
39286 KillTile(n, num10);
39287 }
39288 }
39289 }
39290 destroyObject = false;
39291 return;
39292 }
39293 bool flag2 = false;
39294 int num11 = j;
39295 num11 += Main.tile[i, j].frameY / 18 * -1;
39296 int num12 = Main.tile[i, j].frameX / 18;
39297 int num13 = 0;
39298 while (num12 > 2)
39299 {
39300 num12 -= 3;
39301 num13++;
39302 }
39303 num12 = i - num12;
39304 int num14 = num13 * 54;
39305 for (int num15 = num12; num15 < num12 + 3; num15++)
39306 {
39307 for (int num16 = num11; num16 < num11 + 2; num16++)
39308 {
39309 if (Main.tile[num15, num16] == null)
39310 {
39311 Main.tile[num15, num16] = new Tile();
39312 }
39313 if (!Main.tile[num15, num16].active() || Main.tile[num15, num16].type != type || Main.tile[num15, num16].frameX != (num15 - num12) * 18 + num14 || Main.tile[num15, num16].frameY != (num16 - num11) * 18)
39314 {
39315 flag2 = true;
39316 }
39317 }
39318 if (Main.tile[num15, num11 + 2] == null)
39319 {
39320 Main.tile[num15, num11 + 2] = new Tile();
39321 }
39322 if (!SolidTile(num15, num11 + 2) || Main.tile[num15, num11 + 2].type != 60)
39323 {
39324 flag2 = true;
39325 }
39326 }
39327 if (!flag2)
39328 {
39329 return;
39330 }
39331 _ = Main.tile[i, j].frameX;
39332 destroyObject = true;
39333 for (int num17 = num12; num17 < num12 + 3; num17++)
39334 {
39335 for (int num18 = num11; num18 < num11 + 3; num18++)
39336 {
39337 if (Main.tile[num17, num18] == null)
39338 {
39339 Main.tile[num17, num18] = new Tile();
39340 }
39341 if (Main.tile[num17, num18].type == type && Main.tile[num17, num18].active())
39342 {
39343 KillTile(num17, num18);
39344 }
39345 }
39346 }
39347 destroyObject = false;
39348 }
39349
39350 public static void CheckSuper(int x, int y, int type)
39351 {
39352 if (destroyObject)
39353 {
39354 return;
39355 }
39356 Tile tile = Main.tile[x, y];
39357 int num = 0;
39358 if (type == 376)
39359 {
39360 num = tile.frameX / 36;
39361 }
39362 if (type == 443)
39363 {
39364 num = tile.frameX / 36;
39365 }
39366 if (type == 485)
39367 {
39368 num = tile.frameX / 36;
39369 }
39370 bool flag = type == 376;
39371 bool flag2 = type == 443;
39372 bool flag3 = type == 444;
39373 bool flag4 = type == 485;
39375 bool styleHorizontal = tileData.StyleHorizontal;
39376 int width = tileData.Width;
39377 int height = tileData.Height;
39378 int num2 = x;
39379 int num3 = y;
39380 num2 -= tile.frameX / 18 % width;
39381 num3 -= tile.frameY / 18 % height;
39382 int num4 = 0;
39383 int num5 = 0;
39384 if (styleHorizontal)
39385 {
39386 num4 = tile.frameX / tileData.CoordinateFullWidth;
39387 }
39388 else
39389 {
39390 num5 = tile.frameY / tileData.CoordinateFullHeight;
39391 }
39392 bool flag5 = false;
39393 bool flag6 = false;
39394 for (int i = 0; i < width; i++)
39395 {
39396 for (int j = 0; j < height; j++)
39397 {
39399 if (!tileSafely.active() || tileSafely.type != type || tileSafely.frameX != num4 * tileData.CoordinateFullWidth + i * (tileData.CoordinateWidth + 2) || tileSafely.frameY != num5 * tileData.CoordinateFullHeight + j * (tileData.CoordinateHeights[0] + 2))
39400 {
39401 flag5 = true;
39402 }
39403 }
39404 }
39405 if (flag)
39406 {
39407 for (int k = 0; k < width; k++)
39408 {
39410 if (!tileSafely.active() || (!Main.tileSolid[tileSafely.type] && !Main.tileTable[tileSafely.type]))
39411 {
39412 flag5 = true;
39413 }
39414 if (tileSafely.halfBrick())
39415 {
39416 flag5 = true;
39417 }
39418 }
39419 }
39420 if (flag2)
39421 {
39422 bool flag7 = true;
39423 bool flag8 = true;
39424 for (int l = 0; l < width; l++)
39425 {
39426 if (!AnchorValid(Framing.GetTileSafely(num2 + l, num3 + height), AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide))
39427 {
39428 flag8 = false;
39429 }
39430 if (!AnchorValid(Framing.GetTileSafely(num2 + l, num3 - 1), AnchorType.SolidBottom))
39431 {
39432 flag7 = false;
39433 }
39434 }
39435 if (!flag7 && !flag8)
39436 {
39437 flag5 = true;
39438 }
39439 if (!flag5)
39440 {
39441 int num6 = 0;
39442 if (flag8)
39443 {
39444 for (int m = 0; m < width; m++)
39445 {
39446 Framing.GetTileSafely(num2 + m, num3).frameX = (short)(m * 18 + num / 2 * 36 + num6 * 36);
39447 }
39448 }
39449 else
39450 {
39451 for (int n = 0; n < width; n++)
39452 {
39453 Framing.GetTileSafely(num2 + n, num3).frameX = (short)(n * 18 + (num - 2) / 2 * 36 + 72 + num6 * 36);
39454 }
39455 }
39456 }
39457 }
39458 if (flag3)
39459 {
39460 bool flag9 = true;
39461 for (int num7 = 0; num7 < width; num7++)
39462 {
39463 if (!AnchorValid(Framing.GetTileSafely(num2 + num7, num3 - 1), AnchorType.SolidTile))
39464 {
39465 flag9 = false;
39466 }
39467 }
39468 if (!flag9)
39469 {
39470 flag5 = true;
39471 }
39472 for (int num8 = 0; num8 < width; num8++)
39473 {
39474 for (int num9 = 0; num9 < height; num9++)
39475 {
39477 if (tileSafely.liquid > 0)
39478 {
39479 flag5 = true;
39480 flag6 = true;
39481 }
39482 }
39483 }
39484 }
39485 if (flag4)
39486 {
39487 bool flag10 = true;
39488 for (int num10 = 0; num10 < width; num10++)
39489 {
39490 if (!AnchorValid(Framing.GetTileSafely(num2 + num10, num3 + height), AnchorType.SolidTile))
39491 {
39492 flag10 = false;
39493 }
39494 }
39495 if (!flag10)
39496 {
39497 flag5 = true;
39498 }
39499 }
39500 if (!flag5)
39501 {
39502 return;
39503 }
39504 destroyObject = true;
39505 for (int num11 = 0; num11 < width; num11++)
39506 {
39507 for (int num12 = 0; num12 < height; num12++)
39508 {
39509 if (Main.tile[num2 + num11, num3 + num12].type == type && Main.tile[num2 + num11, num3 + num12].active())
39510 {
39511 KillTile(num2 + num11, num3 + num12);
39512 }
39513 }
39514 }
39515 int num13 = 0;
39516 if (type == 376)
39517 {
39518 switch (num)
39519 {
39520 case 0:
39521 num13 = 2334;
39522 break;
39523 case 1:
39524 num13 = 2335;
39525 break;
39526 case 2:
39527 num13 = 2336;
39528 break;
39529 case 3:
39530 num13 = 3203;
39531 break;
39532 case 4:
39533 num13 = 3204;
39534 break;
39535 case 5:
39536 num13 = 3205;
39537 break;
39538 case 6:
39539 num13 = 3206;
39540 break;
39541 case 7:
39542 num13 = 3207;
39543 break;
39544 case 8:
39545 num13 = 3208;
39546 break;
39547 case 9:
39548 num13 = 3979;
39549 break;
39550 case 10:
39551 num13 = 3980;
39552 break;
39553 case 11:
39554 num13 = 3981;
39555 break;
39556 case 12:
39557 num13 = 3982;
39558 break;
39559 case 13:
39560 num13 = 3983;
39561 break;
39562 case 14:
39563 num13 = 3984;
39564 break;
39565 case 15:
39566 num13 = 3985;
39567 break;
39568 case 16:
39569 num13 = 3986;
39570 break;
39571 case 17:
39572 num13 = 3987;
39573 break;
39574 case 18:
39575 num13 = 4405;
39576 break;
39577 case 19:
39578 num13 = 4406;
39579 break;
39580 case 20:
39581 num13 = 4407;
39582 break;
39583 case 21:
39584 num13 = 4408;
39585 break;
39586 case 22:
39587 num13 = 4877;
39588 break;
39589 case 23:
39590 num13 = 4878;
39591 break;
39592 case 24:
39593 num13 = 5002;
39594 break;
39595 case 25:
39596 num13 = 5003;
39597 break;
39598 }
39599 }
39600 if (type == 443)
39601 {
39602 num13 = 3722;
39603 }
39604 if (type == 485 && !gen && Main.netMode != 1)
39605 {
39608 {
39609 int num15 = NPC.NewNPC(GetNPCSource_TileBreak(num2, num3), num2 * 16, num3 * 16 + 32, 582);
39610 Main.npc[num15].TargetClosest();
39611 Main.npc[num15].velocity = new Vector2((float)Main.npc[num15].direction * 1.5f, -5f);
39612 NetMessage.SendData(23, -1, -1, null, num15);
39613 int num16 = 20;
39614 int num17 = -1;
39615 Main.npc[num15].GetImmuneTime(num17, num16);
39616 NetMessage.SendData(131, -1, -1, null, num15, 1f, num17, num16);
39617 }
39618 }
39619 if (type == 444 && Main.netMode != 1 && !flag6)
39620 {
39621 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num3), num2 * 16 + 16, num3 * 16 + 16, 0f, 0f, 655, 0, 0f, Main.myPlayer);
39622 }
39623 if (num13 != 0)
39624 {
39625 Item.NewItem(GetItemSource_FromTileBreak(num2, num3), num2 * 16, num3 * 16, tileData.CoordinateFullWidth, tileData.CoordinateFullHeight, num13);
39626 }
39627 destroyObject = false;
39628 for (int num18 = -1; num18 < width + 1; num18++)
39629 {
39630 for (int num19 = -1; num19 < height + 1; num19++)
39631 {
39632 TileFrame(num2 + num18, num3 + num19);
39633 }
39634 }
39635 }
39636
39637 public static void Check2x2(int i, int j, int type)
39638 {
39639 if (destroyObject)
39640 {
39641 return;
39642 }
39643 bool flag = false;
39644 int num = 0;
39645 int num2 = Main.tile[i, j].frameX / 18 * -1;
39646 if (num2 < -1)
39647 {
39648 num2 += 2;
39649 num = 36;
39650 }
39651 num2 += i;
39652 int num3 = ((type == 172) ? 38 : 36);
39653 int num4 = Main.tile[i, j].frameY;
39654 int num5 = 0;
39655 while (num4 >= num3)
39656 {
39657 num4 -= num3;
39658 num5++;
39659 }
39660 int num6 = j - num4 / 18;
39661 int num7 = 0;
39662 if (type == 652)
39663 {
39664 num7 = Main.tile[i, j].frameX / 36;
39665 num2 = Main.tile[i, j].frameX % 36 / 18 * -1 + i;
39666 num = num7 * 36;
39667 }
39668 for (int k = num2; k < num2 + 2; k++)
39669 {
39670 for (int l = num6; l < num6 + 2; l++)
39671 {
39673 if (!tileSafely.active() || tileSafely.type != type || tileSafely.frameX != (k - num2) * 18 + num || tileSafely.frameY != (l - num6) * 18 + num5 * num3)
39674 {
39675 flag = true;
39676 break;
39677 }
39678 }
39679 if (type == 95 || type == 126)
39680 {
39682 if (!Main.tile[k, num6 - 1].active() || !Main.tileSolid[Main.tile[k, num6 - 1].type] || Main.tileSolidTop[Main.tile[k, num6 - 1].type])
39683 {
39684 flag = true;
39685 }
39686 }
39687 else if (!TileID.Sets.Boulders[type] && type != 132)
39688 {
39690 if (!tileSafely2.active() || (!Main.tileSolid[tileSafely2.type] && !Main.tileTable[tileSafely2.type]))
39691 {
39692 flag = true;
39693 }
39694 if (tileSafely2.halfBrick())
39695 {
39696 flag = true;
39697 }
39698 }
39699 }
39700 if (TileID.Sets.Boulders[type])
39701 {
39702 if (Main.tile[num2, num6 - 1] == null)
39703 {
39704 Main.tile[num2, num6 - 1] = new Tile();
39705 }
39706 if (Main.tile[num2 + 1, num6 - 1] == null)
39707 {
39708 Main.tile[num2 + 1, num6 - 1] = new Tile();
39709 }
39710 ushort type2 = Main.tile[num2, num6 - 1].type;
39711 ushort type3 = Main.tile[num2 + 1, num6 - 1].type;
39712 if (!TileID.Sets.BasicChest[type2] && !TileID.Sets.BasicChest[type3] && type2 != 88 && type3 != 88 && !TileID.Sets.BasicChestFake[type2] && !TileID.Sets.BasicChestFake[type3] && type2 != 470 && type3 != 470 && type2 != 475 && type3 != 475 && !SolidTileAllowBottomSlope(num2, num6 + 2) && !SolidTileAllowBottomSlope(num2 + 1, num6 + 2))
39713 {
39714 flag = true;
39715 }
39716 }
39717 else if (type == 132)
39718 {
39719 flag = false;
39720 num6 = Main.tile[i, j].frameY / 18 * -1;
39721 num6 += j;
39722 num = 0;
39723 num2 = Main.tile[i, j].frameX / 18 * -1;
39724 while (num2 < -1)
39725 {
39726 num2 += 2;
39727 num += 36;
39728 }
39729 num2 += i;
39730 for (int m = num2; m < num2 + 2; m++)
39731 {
39732 for (int n = num6; n < num6 + 2; n++)
39733 {
39734 if (Main.tile[m, n] == null)
39735 {
39736 Main.tile[m, n] = new Tile();
39737 }
39738 if (!Main.tile[m, n].active() || Main.tile[m, n].type != type || Main.tile[m, n].frameX != (m - num2) * 18 + num || Main.tile[m, n].frameY != (n - num6) * 18)
39739 {
39740 flag = true;
39741 }
39742 }
39743 }
39744 if (Main.tile[num2, num6 + 2] == null)
39745 {
39746 Main.tile[num2, num6 + 2] = new Tile();
39747 }
39748 if (Main.tile[num2 + 1, num6 + 2] == null)
39749 {
39750 Main.tile[num2 + 1, num6 + 2] = new Tile();
39751 }
39752 bool flag2 = false;
39753 ushort type4 = Main.tile[num2, num6 + 2].type;
39754 ushort type5 = Main.tile[num2 + 1, num6 + 2].type;
39755 if (!Main.tile[num2, num6 + 2].active() || (!Main.tileSolid[type4] && !Main.tileSolidTop[type4]) || Main.tile[num2, num6 + 2].halfBrick() || (Main.tile[num2, num6 + 2].slope() != 0 && !Main.tile[num2, num6 + 2].bottomSlope()))
39756 {
39757 flag2 = true;
39758 }
39759 if (!Main.tile[num2 + 1, num6 + 2].active() || (!Main.tileSolid[type5] && !Main.tileSolidTop[type5]) || Main.tile[num2 + 1, num6 + 2].halfBrick() || (Main.tile[num2 + 1, num6 + 2].slope() != 0 && !Main.tile[num2 + 1, num6 + 2].bottomSlope()))
39760 {
39761 flag2 = true;
39762 }
39763 if (flag2)
39764 {
39765 if (Main.tile[num2, num6].wall < 1 || Main.tile[num2 + 1, num6].wall < 1 || Main.tile[num2, num6 + 1].wall < 1 || Main.tile[num2 + 1, num6 + 1].wall < 1)
39766 {
39767 flag = true;
39768 }
39769 else if (num < 72)
39770 {
39771 for (int num8 = num2; num8 < num2 + 2; num8++)
39772 {
39773 for (int num9 = num6; num9 < num6 + 2; num9++)
39774 {
39775 Main.tile[num8, num9].frameX += 72;
39776 }
39777 }
39778 }
39779 }
39780 else if (num >= 72)
39781 {
39782 for (int num10 = num2; num10 < num2 + 2; num10++)
39783 {
39784 for (int num11 = num6; num11 < num6 + 2; num11++)
39785 {
39786 Main.tile[num10, num11].frameX -= 72;
39787 }
39788 }
39789 }
39790 }
39791 if (!flag)
39792 {
39793 return;
39794 }
39795 destroyObject = true;
39796 for (int num12 = num2; num12 < num2 + 2; num12++)
39797 {
39798 for (int num13 = num6; num13 < num6 + 2; num13++)
39799 {
39800 if (Main.tile[num12, num13].type == type && Main.tile[num12, num13].active())
39801 {
39802 KillTile(num12, num13);
39803 }
39804 }
39805 }
39806 int num14 = 0;
39807 switch (type)
39808 {
39809 case 521:
39810 num14 = 4327;
39811 break;
39812 case 522:
39813 num14 = 4328;
39814 break;
39815 case 523:
39816 num14 = 4329;
39817 break;
39818 case 524:
39819 num14 = 4330;
39820 break;
39821 case 525:
39822 num14 = 4331;
39823 break;
39824 case 526:
39825 num14 = 4332;
39826 break;
39827 case 527:
39828 num14 = 4333;
39829 break;
39830 case 564:
39831 num14 = 4553;
39832 break;
39833 case 565:
39834 num14 = 4552;
39835 break;
39836 case 594:
39837 num14 = 4869;
39838 break;
39839 case 621:
39840 num14 = 3750;
39841 break;
39842 case 622:
39843 num14 = 5008;
39844 break;
39845 }
39846 if (type == 598)
39847 {
39848 num14 = 4880;
39849 }
39850 if (type == 360)
39851 {
39852 num14 = 3072;
39853 }
39854 if (type == 580)
39855 {
39856 num14 = 4846;
39857 }
39858 if (type == 620)
39859 {
39860 num14 = 4964;
39861 }
39862 if (type == 505)
39863 {
39864 num14 = 4275;
39865 }
39866 if (type == 543)
39867 {
39868 num14 = 4398;
39869 }
39870 if (type == 568)
39871 {
39872 num14 = 4655;
39873 }
39874 if (type == 569)
39875 {
39876 num14 = 4656;
39877 }
39878 if (type == 570)
39879 {
39880 num14 = 4657;
39881 }
39882 if (type >= 288 && type <= 295)
39883 {
39884 num14 = 2178 + type - 288;
39885 }
39886 if (type >= 316 && type <= 318)
39887 {
39888 num14 = 2439 + type - 316;
39889 }
39890 if (type == 85)
39891 {
39892 num14 = 321;
39893 }
39894 if (type == 94)
39895 {
39896 num14 = 352;
39897 }
39898 if (type == 95)
39899 {
39900 num14 = 344;
39901 }
39902 if (type == 96)
39903 {
39904 num14 = 345;
39905 }
39906 if (type == 97)
39907 {
39908 num14 = 346;
39909 }
39910 if (type == 98)
39911 {
39912 num14 = 347;
39913 }
39914 if (type == 99)
39915 {
39916 num14 = 348;
39917 }
39918 if (type == 335)
39919 {
39920 num14 = 2700;
39921 }
39922 if (type == 411)
39923 {
39924 num14 = 3545;
39925 }
39926 if (type == 652)
39927 {
39928 num14 = ((num7 < 3) ? 195 : ((num7 >= 6) ? 331 : 62));
39929 }
39930 if (type == 100)
39931 {
39932 switch (num5)
39933 {
39934 case 0:
39935 num14 = 349;
39936 break;
39937 case 1:
39938 case 2:
39939 case 3:
39940 case 4:
39941 case 5:
39942 case 6:
39943 case 7:
39944 case 8:
39945 case 9:
39946 case 10:
39947 case 11:
39948 case 12:
39949 num14 = 2092 + num5 - 1;
39950 break;
39951 default:
39952 if (num5 >= 13 && num5 <= 16)
39953 {
39954 num14 = 2149 + num5 - 13;
39955 break;
39956 }
39957 switch (num5)
39958 {
39959 case 17:
39960 num14 = 2227;
39961 break;
39962 case 18:
39963 num14 = 2522;
39964 break;
39965 case 19:
39966 num14 = 2541;
39967 break;
39968 case 20:
39969 num14 = 2555;
39970 break;
39971 case 21:
39972 num14 = 2570;
39973 break;
39974 case 22:
39975 num14 = 2664;
39976 break;
39977 case 23:
39978 num14 = 2665;
39979 break;
39980 case 24:
39981 num14 = 2666;
39982 break;
39983 case 25:
39984 num14 = 2667;
39985 break;
39986 case 26:
39987 num14 = 2668;
39988 break;
39989 case 27:
39990 num14 = 2825;
39991 break;
39992 case 28:
39993 num14 = 3168;
39994 break;
39995 case 29:
39996 num14 = 3170;
39997 break;
39998 case 30:
39999 num14 = 3169;
40000 break;
40001 case 31:
40002 num14 = 3893;
40003 break;
40004 case 32:
40005 num14 = 3935;
40006 break;
40007 case 33:
40008 num14 = 3961;
40009 break;
40010 case 34:
40011 num14 = 4149;
40012 break;
40013 case 35:
40014 num14 = 4170;
40015 break;
40016 case 36:
40017 num14 = 4191;
40018 break;
40019 case 37:
40020 num14 = 4212;
40021 break;
40022 case 38:
40023 num14 = 4302;
40024 break;
40025 case 39:
40026 num14 = 4570;
40027 break;
40028 case 40:
40029 num14 = 5152;
40030 break;
40031 case 41:
40032 num14 = 5173;
40033 break;
40034 case 42:
40035 num14 = 5194;
40036 break;
40037 }
40038 break;
40039 }
40040 }
40041 if (type == 173)
40042 {
40043 num14 = 714;
40044 }
40045 if (type == 125)
40046 {
40047 num14 = 487;
40048 }
40049 if (type == 287)
40050 {
40051 num14 = 2177;
40052 }
40053 if (type == 126)
40054 {
40055 num14 = 488;
40056 }
40057 if (type == 132)
40058 {
40059 num14 = 513;
40060 }
40061 if (type == 142)
40062 {
40063 num14 = 581;
40064 }
40065 if (type == 143)
40066 {
40067 num14 = 582;
40068 }
40069 if (type == 282)
40070 {
40071 num14 = 250;
40072 }
40073 if (type == 319)
40074 {
40075 num14 = 2490;
40076 }
40077 if (type == 490)
40078 {
40079 num14 = 4075;
40080 }
40081 if (type == 172)
40082 {
40083 num14 = 2827 + num5;
40084 switch (num5)
40085 {
40086 case 29:
40087 num14 = 3147;
40088 break;
40089 case 30:
40090 num14 = 3149;
40091 break;
40092 case 31:
40093 num14 = 3148;
40094 break;
40095 case 32:
40096 num14 = 3896;
40097 break;
40098 case 33:
40099 num14 = 3946;
40100 break;
40101 case 34:
40102 num14 = 3972;
40103 break;
40104 case 35:
40105 num14 = 4160;
40106 break;
40107 case 36:
40108 num14 = 4181;
40109 break;
40110 case 37:
40111 num14 = 4202;
40112 break;
40113 case 38:
40114 num14 = 4223;
40115 break;
40116 case 39:
40117 num14 = 4312;
40118 break;
40119 case 40:
40120 num14 = 4581;
40121 break;
40122 case 41:
40123 num14 = 5163;
40124 break;
40125 case 42:
40126 num14 = 5184;
40127 break;
40128 case 43:
40129 num14 = 5205;
40130 break;
40131 }
40132 }
40133 if (num14 != 0)
40134 {
40135 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num14);
40136 }
40137 if (!gen && Main.netMode != 1)
40138 {
40139 switch (type)
40140 {
40141 case 138:
40142 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num6), (float)(num2 * 16) + 15.5f, num6 * 16 + 16, 0f, 0f, 99, 70, 10f, Main.myPlayer);
40143 break;
40144 case 484:
40145 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num6), (float)(num2 * 16) + 15.5f, num6 * 16 + 16, 0f, 0f, 727, 35, 10f, Main.myPlayer);
40146 break;
40147 case 654:
40148 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num6), num2 * 16 + 8, num6 * 16 + 8, 0f, 0f, 1002, 400, 10f, Main.myPlayer);
40149 break;
40150 case 664:
40151 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num6), (float)(num2 * 16) + 15.5f, num6 * 16 + 16, 0f, 0f, 1013, 70, 10f, Main.myPlayer);
40152 break;
40153 case 665:
40154 Projectile.NewProjectile(GetProjectileSource_TileBreak(num2, num6), (float)(num2 * 16) + 15.5f, num6 * 16 + 16, 0f, 0f, 1014, 70, 10f, Main.myPlayer);
40155 break;
40156 }
40157 }
40158 destroyObject = false;
40159 for (int num15 = num2 - 1; num15 < num2 + 3; num15++)
40160 {
40161 for (int num16 = num6 - 1; num16 < num6 + 3; num16++)
40162 {
40163 TileFrame(num15, num16);
40164 }
40165 }
40166 }
40167
40168 public static bool CheckBoulderChest(int i, int j)
40169 {
40170 int num = Main.tile[i, j].frameX / 18 * -1;
40171 if (num < -1)
40172 {
40173 num += 2;
40174 }
40175 num += i;
40176 int num2;
40177 for (num2 = Main.tile[i, j].frameY; num2 >= 36; num2 -= 36)
40178 {
40179 }
40180 num2 = j - num2 / 18;
40181 if (IsAContainer(Main.tile[num, num2 - 1]) || IsAContainer(Main.tile[num + 1, num2 - 1]))
40182 {
40183 return true;
40184 }
40185 return false;
40186 }
40187
40188 public static bool IsAContainer(Tile t)
40189 {
40190 if (!TileID.Sets.BasicDresser[t.type] && t.type != 470 && t.type != 475 && !TileID.Sets.BasicChest[t.type])
40191 {
40192 return TileID.Sets.BasicChestFake[t.type];
40193 }
40194 return true;
40195 }
40196
40197 public static void OreRunner(int i, int j, double strength, int steps, ushort type)
40198 {
40199 //IL_005e: Unknown result type (might be due to invalid IL or missing references)
40200 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
40201 //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
40202 //IL_00cf: Unknown result type (might be due to invalid IL or missing references)
40203 //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
40204 //IL_05a7: Unknown result type (might be due to invalid IL or missing references)
40205 //IL_05a8: Unknown result type (might be due to invalid IL or missing references)
40206 //IL_05a9: Unknown result type (might be due to invalid IL or missing references)
40207 //IL_05ae: Unknown result type (might be due to invalid IL or missing references)
40208 //IL_05d3: Unknown result type (might be due to invalid IL or missing references)
40209 //IL_05f4: Unknown result type (might be due to invalid IL or missing references)
40210 //IL_0139: Unknown result type (might be due to invalid IL or missing references)
40211 //IL_0148: Unknown result type (might be due to invalid IL or missing references)
40212 double num = strength;
40213 double num2 = steps;
40214 Vector2D val = default(Vector2D);
40215 val.X = i;
40216 val.Y = j;
40217 Vector2D val2 = default(Vector2D);
40218 val2.X = (double)genRand.Next(-10, 11) * 0.1;
40219 val2.Y = (double)genRand.Next(-10, 11) * 0.1;
40220 while (num > 0.0 && num2 > 0.0)
40221 {
40222 if (val.Y < 0.0 && num2 > 0.0 && type == 59)
40223 {
40224 num2 = 0.0;
40225 }
40226 num = strength * (num2 / (double)steps);
40227 num2 -= 1.0;
40228 int num3 = (int)(val.X - num * 0.5);
40229 int num4 = (int)(val.X + num * 0.5);
40230 int num5 = (int)(val.Y - num * 0.5);
40231 int num6 = (int)(val.Y + num * 0.5);
40232 if (num3 < 0)
40233 {
40234 num3 = 0;
40235 }
40236 if (num4 > Main.maxTilesX)
40237 {
40239 }
40240 if (num5 < 0)
40241 {
40242 num5 = 0;
40243 }
40244 if (num6 > Main.maxTilesY)
40245 {
40247 }
40248 for (int k = num3; k < num4; k++)
40249 {
40250 for (int l = num5; l < num6; l++)
40251 {
40252 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < strength * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[k, l].active() && (Main.tile[k, l].type == 0 || Main.tile[k, l].type == 1 || Main.tile[k, l].type == 23 || Main.tile[k, l].type == 25 || Main.tile[k, l].type == 40 || Main.tile[k, l].type == 53 || Main.tile[k, l].type == 57 || Main.tile[k, l].type == 59 || Main.tile[k, l].type == 60 || Main.tile[k, l].type == 70 || Main.tile[k, l].type == 109 || Main.tile[k, l].type == 112 || Main.tile[k, l].type == 116 || Main.tile[k, l].type == 117 || Main.tile[k, l].type == 147 || Main.tile[k, l].type == 161 || Main.tile[k, l].type == 163 || Main.tile[k, l].type == 164 || Main.tileMoss[Main.tile[k, l].type] || Main.tile[k, l].type == 199 || Main.tile[k, l].type == 200 || Main.tile[k, l].type == 203 || Main.tile[k, l].type == 234 || Main.tile[k, l].type == 396 || Main.tile[k, l].type == 397 || Main.tile[k, l].type == 401 || Main.tile[k, l].type == 403 || Main.tile[k, l].type == 400 || Main.tile[k, l].type == 398 || Main.tile[k, l].type == 399 || Main.tile[k, l].type == 402 || (Main.remixWorld && Main.tile[k, l].type == 230) || (Main.tile[k, l].type == 225 && Main.tile[k, l].wall != 108)))
40253 {
40254 Main.tile[k, l].type = type;
40255 Main.tile[k, l].ClearBlockPaintAndCoating();
40256 SquareTileFrame(k, l);
40257 if (Main.netMode == 2)
40258 {
40260 }
40261 }
40262 }
40263 }
40264 val += val2;
40265 val2.X += (double)genRand.Next(-10, 11) * 0.05;
40266 if (val2.X > 1.0)
40267 {
40268 val2.X = 1.0;
40269 }
40270 if (val2.X < -1.0)
40271 {
40272 val2.X = -1.0;
40273 }
40274 }
40275 }
40276
40277 public static void SmashAltar(int i, int j)
40278 {
40279 if (Main.netMode == 1 || !Main.hardMode || noTileActions || gen)
40280 {
40281 return;
40282 }
40283 int num = altarCount % 3;
40284 int num2 = altarCount / 3 + 1;
40285 double num3 = (double)Main.maxTilesX / 4200.0;
40286 int num4 = 1 - num;
40287 num3 = num3 * 310.0 - (double)(85 * num);
40288 num3 *= 0.85;
40289 num3 /= (double)num2;
40290 bool flag = false;
40291 if (Main.drunkWorld)
40292 {
40293 if (SavedOreTiers.Adamantite == 111)
40294 {
40295 SavedOreTiers.Adamantite = 223;
40296 }
40297 else if (SavedOreTiers.Adamantite == 223)
40298 {
40299 SavedOreTiers.Adamantite = 111;
40300 }
40301 }
40302 switch (num)
40303 {
40304 case 0:
40305 {
40306 if (SavedOreTiers.Cobalt == -1)
40307 {
40308 flag = true;
40309 SavedOreTiers.Cobalt = 107;
40310 if (genRand.Next(2) == 0)
40311 {
40312 SavedOreTiers.Cobalt = 221;
40313 }
40314 }
40315 int num6 = 12;
40316 if (SavedOreTiers.Cobalt == 221)
40317 {
40318 num6 += 9;
40319 num3 *= 0.8999999761581421;
40320 }
40321 if (Main.netMode == 0)
40322 {
40323 Main.NewText(Lang.misc[num6].Value, 50, byte.MaxValue, 130);
40324 }
40325 else if (Main.netMode == 2)
40326 {
40328 }
40329 num = SavedOreTiers.Cobalt;
40330 num3 *= 1.0499999523162842;
40331 break;
40332 }
40333 case 1:
40334 {
40335 if (Main.drunkWorld)
40336 {
40337 if (SavedOreTiers.Mythril == 108)
40338 {
40339 SavedOreTiers.Mythril = 222;
40340 }
40341 else if (SavedOreTiers.Mythril == 222)
40342 {
40343 SavedOreTiers.Mythril = 108;
40344 }
40345 }
40346 if (SavedOreTiers.Mythril == -1)
40347 {
40348 flag = true;
40349 SavedOreTiers.Mythril = 108;
40350 if (genRand.Next(2) == 0)
40351 {
40352 SavedOreTiers.Mythril = 222;
40353 }
40354 }
40355 int num7 = 13;
40356 if (SavedOreTiers.Mythril == 222)
40357 {
40358 num7 += 9;
40359 num3 *= 0.8999999761581421;
40360 }
40361 if (Main.netMode == 0)
40362 {
40363 Main.NewText(Lang.misc[num7].Value, 50, byte.MaxValue, 130);
40364 }
40365 else if (Main.netMode == 2)
40366 {
40368 }
40369 num = SavedOreTiers.Mythril;
40370 break;
40371 }
40372 default:
40373 {
40374 if (Main.drunkWorld)
40375 {
40376 if (SavedOreTiers.Cobalt == 107)
40377 {
40378 SavedOreTiers.Cobalt = 221;
40379 }
40380 else if (SavedOreTiers.Cobalt == 221)
40381 {
40382 SavedOreTiers.Cobalt = 107;
40383 }
40384 }
40385 if (SavedOreTiers.Adamantite == -1)
40386 {
40387 flag = true;
40388 SavedOreTiers.Adamantite = 111;
40389 if (genRand.Next(2) == 0)
40390 {
40391 SavedOreTiers.Adamantite = 223;
40392 }
40393 }
40394 int num5 = 14;
40395 if (SavedOreTiers.Adamantite == 223)
40396 {
40397 num5 += 9;
40398 num3 *= 0.8999999761581421;
40399 }
40400 if (Main.netMode == 0)
40401 {
40402 Main.NewText(Lang.misc[num5].Value, 50, byte.MaxValue, 130);
40403 }
40404 else if (Main.netMode == 2)
40405 {
40407 }
40409 break;
40410 }
40411 }
40412 if (flag)
40413 {
40415 }
40416 for (int k = 0; (double)k < num3; k++)
40417 {
40418 int i2 = genRand.Next(100, Main.maxTilesX - 100);
40419 double num8 = Main.worldSurface;
40420 if (num == 108 || num == 222)
40421 {
40423 }
40424 if (num == 111 || num == 223)
40425 {
40426 num8 = (Main.rockLayer + Main.rockLayer + (double)Main.maxTilesY) / 3.0;
40427 }
40428 int j2 = genRand.Next((int)num8, Main.maxTilesY - 150);
40429 if (Main.remixWorld)
40430 {
40431 double num9 = Main.maxTilesX - 350;
40432 if (num == 108 || num == 222)
40433 {
40434 num9 = (Main.rockLayer + Main.rockLayer + (double)Main.maxTilesY - 350.0) / 3.0;
40435 }
40436 if (num == 111 || num == 223)
40437 {
40438 num9 = Main.rockLayer - 25.0;
40439 }
40440 j2 = genRand.Next((int)Main.worldSurface + 15, (int)num9);
40441 }
40443 {
40444 OreRunner(i2, j2, genRand.Next(5, 11 + num4), genRand.Next(5, 11 + num4), (ushort)num);
40445 }
40446 else
40447 {
40448 OreRunner(i2, j2, genRand.Next(5, 9 + num4), genRand.Next(5, 9 + num4), (ushort)num);
40449 }
40450 }
40451 if (Main.netMode != 1)
40452 {
40453 int num10 = Main.rand.Next(2) + 1;
40454 for (int l = 0; l < num10; l++)
40455 {
40456 NPC.SpawnOnPlayer(Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16), 82);
40457 }
40458 }
40459 altarCount++;
40461 }
40462
40463 public static void Check3x1(int i, int j, int type)
40464 {
40465 if (destroyObject)
40466 {
40467 return;
40468 }
40469 bool flag = false;
40470 if (Main.tile[i, j] == null)
40471 {
40472 Main.tile[i, j] = new Tile();
40473 }
40474 int num = Main.tile[i, j].frameX / 18;
40475 int num2 = 0;
40476 while (num > 2)
40477 {
40478 num -= 3;
40479 num2++;
40480 }
40481 num = i - num;
40482 int num3 = num2 * 54;
40483 for (int k = num; k < num + 3; k++)
40484 {
40485 if (Main.tile[k, j] == null)
40486 {
40487 Main.tile[k, j] = new Tile();
40488 }
40489 if (!Main.tile[k, j].active() || Main.tile[k, j].type != type || Main.tile[k, j].frameX != (k - num) * 18 + num3 || Main.tile[k, j].frameY != 0)
40490 {
40491 flag = true;
40492 }
40493 if (Main.tile[k, j - 1] == null)
40494 {
40495 Main.tile[k, j - 1] = new Tile();
40496 }
40497 if (Main.tile[k, j - 1].active() && (TileID.Sets.BasicChest[Main.tile[k, j - 1].type] || TileID.Sets.BasicChestFake[Main.tile[k, j - 1].type] || Main.tile[k, j - 1].type == 88 || Main.tile[k, j - 1].type == 470 || Main.tile[k, j - 1].type == 475 || Main.tile[k, j - 1].type == 597))
40498 {
40499 return;
40500 }
40501 if (!SolidTileAllowBottomSlope(k, j + 1))
40502 {
40503 flag = true;
40504 }
40505 }
40506 if (!flag)
40507 {
40508 return;
40509 }
40510 _ = Main.tile[i, j].frameX;
40511 destroyObject = true;
40512 if (type == 235)
40513 {
40514 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1263);
40515 }
40516 for (int l = num; l < num + 3; l++)
40517 {
40518 if (Main.tile[l, j] == null)
40519 {
40520 Main.tile[l, j] = new Tile();
40521 }
40522 if (Main.tile[l, j].type == type && Main.tile[l, j].active())
40523 {
40524 KillTile(l, j);
40525 }
40526 }
40527 destroyObject = false;
40528 for (int m = num - 1; m < num + 4; m++)
40529 {
40530 TileFrame(m, j);
40531 }
40532 }
40533
40534 public static void Check3x2(int i, int j, int type)
40535 {
40536 if (destroyObject)
40537 {
40538 return;
40539 }
40540 bool flag = false;
40541 bool flag2 = false;
40542 int num = j;
40543 if (Main.tile[i, j] == null)
40544 {
40545 Main.tile[i, j] = new Tile();
40546 }
40547 int num2 = 36;
40548 int num3 = Main.tile[i, j].frameY / num2;
40549 int num4 = Main.tile[i, j].frameY % num2;
40550 num -= num4 / 18;
40551 int num5 = Main.tile[i, j].frameX / 18;
40552 int num6 = 0;
40553 while (num5 > 2)
40554 {
40555 num5 -= 3;
40556 num6++;
40557 }
40558 num5 = i - num5;
40559 int num7 = num6 * 54;
40560 if (type == 14 && num6 == 25)
40561 {
40562 flag2 = true;
40563 }
40564 int num8 = num + 2;
40565 if (flag2)
40566 {
40567 num8--;
40568 }
40569 for (int k = num5; k < num5 + 3; k++)
40570 {
40571 for (int l = num; l < num8; l++)
40572 {
40573 if (Main.tile[k, l] == null)
40574 {
40575 Main.tile[k, l] = new Tile();
40576 }
40577 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num5) * 18 + num7 || Main.tile[k, l].frameY != (l - num) * 18 + num3 * 36)
40578 {
40579 flag = true;
40580 }
40581 }
40582 if (type == 285 || type == 286 || type == 298 || type == 299 || type == 310 || type == 339 || type == 538 || (type >= 361 && type <= 364) || type == 532 || type == 544 || type == 533 || type == 555 || type == 556 || type == 582 || type == 619 || type == 629)
40583 {
40584 if (!SolidTileAllowBottomSlope(k, num8) && (Main.tile[k, num8] == null || !Main.tile[k, num8].nactive() || !Main.tileSolidTop[Main.tile[k, num8].type] || Main.tile[k, num8].frameY != 0) && (Main.tile[k, num8] == null || !Main.tile[k, num8].active() || !TileID.Sets.Platforms[Main.tile[k, num8].type]))
40585 {
40586 flag = true;
40587 }
40588 }
40589 else
40590 {
40591 switch (type)
40592 {
40593 case 488:
40594 {
40595 int num9 = 0;
40596 if (Main.tile[k, num8] != null && Main.tile[k, num8].active())
40597 {
40598 num9 = Main.tile[k, num8].type;
40599 }
40600 if (num9 != 2 && num9 != 477 && num9 != 109 && num9 != 492)
40601 {
40602 flag = true;
40603 }
40604 break;
40605 }
40606 case 26:
40607 {
40608 Tile tile2 = Main.tile[k, num8];
40609 if (!SolidTileAllowBottomSlope(k, num8) || (tile2 != null && tile2.active() && TileID.Sets.Boulders[tile2.type]))
40610 {
40611 flag = true;
40612 }
40613 break;
40614 }
40615 case 186:
40616 {
40617 if (!SolidTileAllowBottomSlope(k, num8))
40618 {
40619 flag = true;
40620 break;
40621 }
40622 Tile tile = Main.tile[k, num8];
40623 if (tile == null || !tile.active())
40624 {
40625 break;
40626 }
40627 switch (num6)
40628 {
40629 case 26:
40630 case 27:
40631 case 28:
40632 case 29:
40633 case 30:
40634 case 31:
40635 if (!TileID.Sets.Snow[tile.type] && !TileID.Sets.Conversion.Ice[tile.type] && tile.type != 162 && tile.type != 224)
40636 {
40637 flag = true;
40638 }
40639 break;
40640 case 32:
40641 case 33:
40642 case 34:
40643 if (!TileID.Sets.Mud[tile.type] && tile.type != 70)
40644 {
40645 flag = true;
40646 }
40647 break;
40648 }
40649 break;
40650 }
40651 }
40652 }
40653 if (type == 187)
40654 {
40655 if (!SolidTileAllowBottomSlope(k, num8))
40656 {
40657 flag = true;
40658 continue;
40659 }
40660 Tile tile3 = Main.tile[k, num8];
40661 if (tile3 == null || !tile3.active())
40662 {
40663 continue;
40664 }
40665 switch (num6)
40666 {
40667 case 0:
40668 case 1:
40669 case 2:
40670 case 3:
40671 case 4:
40672 case 5:
40673 if (!TileID.Sets.Mud[tile3.type] && tile3.type != 60 && tile3.type != 226)
40674 {
40675 flag = true;
40676 }
40677 break;
40678 case 6:
40679 case 7:
40680 case 8:
40681 if (tile3.type != 57 && tile3.type != 58 && tile3.type != 75 && tile3.type != 76)
40682 {
40683 flag = true;
40684 }
40685 break;
40686 case 29:
40687 case 30:
40688 case 31:
40689 case 32:
40690 case 33:
40691 case 34:
40693 {
40694 flag = true;
40695 }
40696 break;
40697 }
40698 }
40699 else if (!SolidTileAllowBottomSlope(k, num8))
40700 {
40701 flag = true;
40702 }
40703 }
40704 if (type == 187 && Main.tile[num5, num] != null && Main.tile[num5, num].frameX >= 756 && Main.tile[num5, num].frameX <= 900 && Main.tile[num5, num + 2].type != 2 && Main.tile[num5 + 1, num + 2].type != 2 && Main.tile[num5 + 2, num + 2].type != 2 && Main.tile[num5, num + 2].type != 477 && Main.tile[num5 + 1, num + 2].type != 477 && Main.tile[num5 + 2, num + 2].type != 477 && Main.tile[num5, num + 2].type != 492 && Main.tile[num5 + 1, num + 2].type != 492 && Main.tile[num5 + 2, num + 2].type != 492)
40705 {
40706 Main.tile[num5, num].frameX -= 378;
40707 Main.tile[num5 + 1, num].frameX -= 378;
40708 Main.tile[num5 + 2, num].frameX -= 378;
40709 Main.tile[num5, num + 1].frameX -= 378;
40710 Main.tile[num5 + 1, num + 1].frameX -= 378;
40711 Main.tile[num5 + 2, num + 1].frameX -= 378;
40712 Main.tile[num5, num].type = 186;
40713 Main.tile[num5 + 1, num].type = 186;
40714 Main.tile[num5 + 2, num].type = 186;
40715 Main.tile[num5, num + 1].type = 186;
40716 Main.tile[num5 + 1, num + 1].type = 186;
40717 Main.tile[num5 + 2, num + 1].type = 186;
40718 }
40719 if (flag && type == 488 && gen)
40720 {
40721 for (int m = num5; m < num5 + 3; m++)
40722 {
40723 for (int n = num; n < num + 2; n++)
40724 {
40725 Main.tile[m, n].active(active: true);
40726 Main.tile[m, n].type = 488;
40727 Main.tile[m, n].frameX = (short)((m - num5) * 18);
40728 Main.tile[m, n].frameY = (short)((n - num) * 18);
40729 }
40730 Main.tile[m, num + 2].active(active: true);
40731 Main.tile[m, num + 2].type = 2;
40732 Main.tile[m, num + 2].slope(0);
40733 Main.tile[m, num + 2].halfBrick(halfBrick: false);
40734 }
40735 flag = false;
40736 }
40737 if (!flag)
40738 {
40739 return;
40740 }
40741 int frameX = Main.tile[i, j].frameX;
40742 destroyObject = true;
40743 num8 = num + 3;
40744 if (flag2)
40745 {
40746 num8--;
40747 }
40748 for (int num10 = num5; num10 < num5 + 3; num10++)
40749 {
40750 for (int num11 = num; num11 < num + 3; num11++)
40751 {
40752 if (Main.tile[num10, num11] == null)
40753 {
40754 Main.tile[num10, num11] = new Tile();
40755 }
40756 if (Main.tile[num10, num11].type == type && Main.tile[num10, num11].active())
40757 {
40758 KillTile(num10, num11);
40759 }
40760 }
40761 }
40762 if (type == 14)
40763 {
40764 int type2 = ((num6 >= 1 && num6 <= 3) ? (637 + num6) : ((num6 >= 15 && num6 <= 20) ? (1698 + num6) : ((num6 >= 4 && num6 <= 7) ? (823 + num6) : (num6 switch
40765 {
40766 8 => 917,
40767 9 => 1144,
40768 10 => 1397,
40769 11 => 1400,
40770 12 => 1403,
40771 13 => 1460,
40772 14 => 1510,
40773 23 => 1926,
40774 21 => 1794,
40775 22 => 1816,
40776 24 => 2248,
40777 25 => 2259,
40778 26 => 2532,
40779 27 => 2550,
40780 28 => 677,
40781 29 => 2583,
40782 30 => 2743,
40783 31 => 2824,
40784 32 => 3153,
40785 33 => 3155,
40786 34 => 3154,
40787 _ => 32,
40788 }))));
40789 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type2);
40790 }
40791 switch (type)
40792 {
40793 case 469:
40794 {
40795 int type4 = 3920;
40796 if (num6 == 1)
40797 {
40798 type4 = 3948;
40799 }
40800 if (num6 == 2)
40801 {
40802 type4 = 3974;
40803 }
40804 if (num6 == 3)
40805 {
40806 type4 = 4162;
40807 }
40808 if (num6 == 4)
40809 {
40810 type4 = 4183;
40811 }
40812 if (num6 == 5)
40813 {
40814 type4 = 4204;
40815 }
40816 if (num6 == 6)
40817 {
40818 type4 = 4225;
40819 }
40820 if (num6 == 7)
40821 {
40822 type4 = 4314;
40823 }
40824 if (num6 == 8)
40825 {
40826 type4 = 4583;
40827 }
40828 if (num6 == 9)
40829 {
40830 type4 = 5165;
40831 }
40832 if (num6 == 10)
40833 {
40834 type4 = 5186;
40835 }
40836 if (num6 == 11)
40837 {
40838 type4 = 5207;
40839 }
40840 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type4);
40841 break;
40842 }
40843 case 114:
40844 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 398);
40845 break;
40846 case 26:
40847 if (!noTileActions && !IsGeneratingHardMode)
40848 {
40849 SmashAltar(i, j);
40850 }
40851 break;
40852 case 298:
40853 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2190);
40854 break;
40855 case 299:
40856 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2191);
40857 break;
40858 case 361:
40859 case 362:
40860 case 363:
40861 case 364:
40862 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3073 + type - 361);
40863 break;
40864 default:
40865 if (type >= 391 && type <= 394)
40866 {
40867 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 48, 32, 3254 + type - 391);
40868 break;
40869 }
40870 switch (type)
40871 {
40872 case 285:
40873 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2174);
40874 break;
40875 case 286:
40876 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2175);
40877 break;
40878 case 582:
40879 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4850);
40880 break;
40881 case 619:
40882 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4963);
40883 break;
40884 case 310:
40885 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2207);
40886 break;
40887 case 339:
40888 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2741);
40889 break;
40890 case 538:
40891 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4380);
40892 break;
40893 case 544:
40894 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4399);
40895 break;
40896 case 532:
40897 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4364);
40898 break;
40899 case 533:
40900 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4376);
40901 break;
40902 case 555:
40903 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4475);
40904 break;
40905 case 556:
40906 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4476);
40907 break;
40908 case 629:
40909 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5133);
40910 break;
40911 case 217:
40912 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 995);
40913 break;
40914 case 218:
40915 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 996);
40916 break;
40917 case 219:
40918 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 997);
40919 break;
40920 case 642:
40921 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5296);
40922 break;
40923 case 220:
40924 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 998);
40925 break;
40926 case 377:
40927 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3198);
40928 break;
40929 case 228:
40930 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1120);
40931 break;
40932 case 405:
40933 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3364);
40934 break;
40935 case 486:
40936 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4063);
40937 break;
40938 case 488:
40939 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 9, genRand.Next(10, 21));
40940 break;
40941 case 215:
40942 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, GetCampfireItemDrop(num6));
40943 break;
40944 case 244:
40945 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1449);
40946 break;
40947 case 647:
40948 {
40949 int num13 = 0;
40950 if (num6 < 7)
40951 {
40952 num13 = 154;
40953 }
40954 else if (num6 < 13)
40955 {
40956 num13 = 3;
40957 }
40958 else if (num6 < 16)
40959 {
40960 num13 = 3;
40961 }
40962 else if (num6 < 18)
40963 {
40964 num13 = 71;
40965 }
40966 else if (num6 < 20)
40967 {
40968 num13 = 72;
40969 }
40970 else if (num6 < 22)
40971 {
40972 num13 = 73;
40973 }
40974 else if (num6 < 26)
40975 {
40976 num13 = 9;
40977 }
40978 else if (num6 < 32)
40979 {
40980 num13 = 593;
40981 }
40982 else if (num6 < 35)
40983 {
40984 num13 = 183;
40985 }
40986 if (num13 != 0)
40987 {
40988 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num13);
40989 }
40990 break;
40991 }
40992 case 648:
40993 {
40994 num6 += num3 * 35;
40995 int num12 = 0;
40996 if (num6 < 6)
40997 {
40998 num12 = 195;
40999 }
41000 else if (num6 < 9)
41001 {
41002 num12 = 174;
41003 }
41004 else if (num6 < 14)
41005 {
41006 num12 = 150;
41007 }
41008 else if (num6 < 17)
41009 {
41010 num12 = 3;
41011 }
41012 else if (num6 < 18)
41013 {
41014 num12 = 989;
41015 }
41016 else if (num6 < 21)
41017 {
41018 num12 = 1101;
41019 }
41020 else if (num6 < 29)
41021 {
41022 num12 = 9;
41023 }
41024 else if (num6 < 35)
41025 {
41026 num12 = 3271;
41027 }
41028 else if (num6 < 41)
41029 {
41030 num12 = 3086;
41031 }
41032 else if (num6 < 47)
41033 {
41034 num12 = 3081;
41035 }
41036 else if (num6 < 52)
41037 {
41038 num12 = 62;
41039 }
41040 else if (num6 < 55)
41041 {
41042 num12 = 154;
41043 }
41044 if (num12 != 0)
41045 {
41046 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num12);
41047 }
41048 break;
41049 }
41050 case 651:
41051 {
41052 int num14 = 0;
41053 num14 = ((num6 < 3) ? 195 : ((num6 >= 6) ? 331 : 62));
41054 if (num14 != 0)
41055 {
41056 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num14);
41057 }
41058 break;
41059 }
41060 case 17:
41061 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 33);
41062 break;
41063 case 77:
41064 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 221);
41065 break;
41066 case 86:
41067 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 332);
41068 break;
41069 case 237:
41070 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1292);
41071 break;
41072 case 87:
41073 {
41074 int type3;
41075 if (num6 >= 1 && num6 <= 3)
41076 {
41077 type3 = 640 + num6;
41078 }
41079 else
41080 {
41081 switch (num6)
41082 {
41083 case 4:
41084 type3 = 919;
41085 break;
41086 case 5:
41087 case 6:
41088 case 7:
41089 type3 = 2245 + num6 - 5;
41090 break;
41091 default:
41092 type3 = ((num6 >= 8 && num6 <= 10) ? (2254 + num6 - 8) : ((num6 >= 11 && num6 <= 20) ? (2376 + num6 - 11) : (num6 switch
41093 {
41094 21 => 2531,
41095 22 => 2548,
41096 23 => 2565,
41097 24 => 2580,
41098 25 => 2671,
41099 26 => 2821,
41100 27 => 3141,
41101 28 => 3143,
41102 29 => 3142,
41103 30 => 3915,
41104 31 => 3916,
41105 32 => 3944,
41106 33 => 3971,
41107 34 => 4158,
41108 35 => 4179,
41109 36 => 4200,
41110 37 => 4221,
41111 38 => 4310,
41112 39 => 4579,
41113 40 => 5161,
41114 41 => 5182,
41115 42 => 5203,
41116 _ => 333,
41117 })));
41118 break;
41119 }
41120 }
41121 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type3);
41122 break;
41123 }
41124 case 88:
41125 {
41126 int dresserItemDrop = GetDresserItemDrop(num6);
41127 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, dresserItemDrop);
41128 break;
41129 }
41130 case 89:
41131 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, GetItemDrop_Benches(num6));
41132 break;
41133 case 133:
41134 if (frameX >= 54)
41135 {
41136 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1221);
41137 }
41138 else
41139 {
41140 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 524);
41141 }
41142 break;
41143 case 186:
41144 if (frameX < 864)
41145 {
41146 break;
41147 }
41148 if (frameX <= 954)
41149 {
41150 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41151 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41152 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41153 if (genRand.Next(3) != 0)
41154 {
41155 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41156 }
41157 if (genRand.Next(3) != 0)
41158 {
41159 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41160 }
41161 if (genRand.Next(3) != 0)
41162 {
41163 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41164 }
41165 if (genRand.Next(2) == 0)
41166 {
41167 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41168 }
41169 if (genRand.Next(2) == 0)
41170 {
41171 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41172 }
41173 if (genRand.Next(2) == 0)
41174 {
41175 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41176 }
41177 if (genRand.Next(3) == 0)
41178 {
41179 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41180 }
41181 if (genRand.Next(3) == 0)
41182 {
41183 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41184 }
41185 if (genRand.Next(3) == 0)
41186 {
41187 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41188 }
41189 if (genRand.Next(4) == 0)
41190 {
41191 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41192 }
41193 if (genRand.Next(4) == 0)
41194 {
41195 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41196 }
41197 if (genRand.Next(4) == 0)
41198 {
41199 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41200 }
41201 if (genRand.Next(5) == 0)
41202 {
41203 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(20, 100));
41204 }
41205 if (genRand.Next(5) == 0)
41206 {
41207 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(30, 100));
41208 }
41209 if (genRand.Next(5) == 0)
41210 {
41211 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 71, genRand.Next(40, 100));
41212 }
41213 }
41214 else if (frameX <= 1062)
41215 {
41216 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, genRand.Next(10, 100));
41217 if (genRand.Next(2) == 0)
41218 {
41219 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, genRand.Next(20, 100));
41220 }
41221 if (genRand.Next(3) == 0)
41222 {
41223 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, genRand.Next(30, 100));
41224 }
41225 if (genRand.Next(4) == 0)
41226 {
41227 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, genRand.Next(40, 100));
41228 }
41229 if (genRand.Next(5) == 0)
41230 {
41231 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, genRand.Next(50, 100));
41232 }
41233 }
41234 else if (frameX <= 1170)
41235 {
41236 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73, genRand.Next(1, 7));
41237 if (genRand.Next(2) == 0)
41238 {
41239 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73, genRand.Next(2, 7));
41240 }
41241 if (genRand.Next(3) == 0)
41242 {
41243 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73, genRand.Next(3, 7));
41244 }
41245 if (genRand.Next(4) == 0)
41246 {
41247 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73, genRand.Next(4, 7));
41248 }
41249 if (genRand.Next(5) == 0)
41250 {
41251 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73, genRand.Next(5, 7));
41252 }
41253 }
41254 break;
41255 case 187:
41256 if (frameX >= 918 && frameX <= 970)
41257 {
41258 if (Main.rand.Next(50) == 0)
41259 {
41260 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4144);
41261 }
41262 else
41263 {
41264 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 989);
41265 }
41266 }
41267 break;
41268 }
41269 break;
41270 }
41271 destroyObject = false;
41272 for (int num15 = num5 - 1; num15 < num5 + 4; num15++)
41273 {
41274 for (int num16 = num - 1; num16 < num + 4; num16++)
41275 {
41276 TileFrame(num15, num16);
41277 }
41278 }
41279 if (type == 488)
41280 {
41281 mysticLogsEvent.FallenLogDestroyed();
41282 }
41283 }
41284
41285 private static int GetDresserItemDrop(int style)
41286 {
41287 if (style >= 1 && style <= 3)
41288 {
41289 return 646 + style;
41290 }
41291 switch (style)
41292 {
41293 case 4:
41294 return 918;
41295 case 5:
41296 case 6:
41297 case 7:
41298 case 8:
41299 case 9:
41300 case 10:
41301 case 11:
41302 case 12:
41303 case 13:
41304 case 14:
41305 case 15:
41306 return 2386 + style - 5;
41307 default:
41308 return style switch
41309 {
41310 16 => 2529,
41311 17 => 2545,
41312 18 => 2562,
41313 19 => 2577,
41314 20 => 2637,
41315 21 => 2638,
41316 22 => 2639,
41317 23 => 2640,
41318 24 => 2816,
41319 25 => 3132,
41320 26 => 3134,
41321 27 => 3133,
41322 28 => 3911,
41323 29 => 3912,
41324 30 => 3913,
41325 31 => 3914,
41326 32 => 3934,
41327 33 => 3968,
41328 34 => 4148,
41329 35 => 4169,
41330 36 => 4190,
41331 37 => 4211,
41332 38 => 4301,
41333 39 => 4569,
41334 40 => 5151,
41335 41 => 5172,
41336 42 => 5193,
41337 _ => 334,
41338 };
41339 }
41340 }
41341
41342 private static int GetCampfireItemDrop(int style)
41343 {
41344 switch (style)
41345 {
41346 case 0:
41347 return 966;
41348 case 1:
41349 case 2:
41350 case 3:
41351 case 4:
41352 case 5:
41353 return 3046 + style - 1;
41354 default:
41355 switch (style)
41356 {
41357 case 6:
41358 return 3723;
41359 case 7:
41360 return 3724;
41361 case 8:
41362 case 9:
41363 case 10:
41364 case 11:
41365 case 12:
41366 case 13:
41367 return 4689 + style - 8;
41368 default:
41369 return style switch
41370 {
41371 14 => 5299,
41372 15 => 5357,
41373 _ => 966,
41374 };
41375 }
41376 }
41377 }
41378
41379 public static void Check3x4(int i, int j, int type)
41380 {
41381 if (destroyObject)
41382 {
41383 return;
41384 }
41385 bool flag = false;
41386 int num = i;
41387 int num2 = j;
41388 int num3 = 0;
41389 int num4 = 0;
41390 int num5 = Main.tile[i, j].frameX / 18;
41391 int num6 = Main.tile[i, j].frameY / 18;
41392 while (num5 >= 3)
41393 {
41394 num3++;
41395 num5 -= 3;
41396 }
41397 while (num6 >= 4)
41398 {
41399 num4++;
41400 num6 -= 4;
41401 }
41402 num -= num5;
41403 num2 -= num6;
41404 for (int k = num; k < num + 3; k++)
41405 {
41406 for (int l = num2; l < num2 + 4; l++)
41407 {
41408 if (Main.tile[k, l] == null)
41409 {
41410 Main.tile[k, l] = new Tile();
41411 }
41412 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != num3 * 54 + (k - num) * 18 || Main.tile[k, l].frameY != num4 * 72 + (l - num2) * 18)
41413 {
41414 flag = true;
41415 }
41416 }
41417 if (Main.tile[k, num2 + 4] == null)
41418 {
41419 Main.tile[k, num2 + 4] = new Tile();
41420 }
41421 if (!SolidTileAllowBottomSlope(k, num2 + 4))
41422 {
41423 flag = true;
41424 }
41425 }
41426 if (!flag)
41427 {
41428 return;
41429 }
41430 destroyObject = true;
41431 for (int m = num; m < num + 3; m++)
41432 {
41433 for (int n = num2; n < num2 + 4; n++)
41434 {
41435 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
41436 {
41437 KillTile(m, n);
41438 }
41439 }
41440 }
41441 switch (type)
41442 {
41443 case 101:
41444 {
41445 int type4;
41446 switch (num3)
41447 {
41448 case 1:
41449 type4 = 1414;
41450 break;
41451 case 2:
41452 type4 = 1415;
41453 break;
41454 case 3:
41455 type4 = 1416;
41456 break;
41457 case 4:
41458 type4 = 1463;
41459 break;
41460 case 5:
41461 type4 = 1512;
41462 break;
41463 case 6:
41464 type4 = 2020;
41465 break;
41466 case 7:
41467 type4 = 2021;
41468 break;
41469 case 8:
41470 type4 = 2022;
41471 break;
41472 case 9:
41473 type4 = 2023;
41474 break;
41475 case 10:
41476 type4 = 2024;
41477 break;
41478 case 11:
41479 type4 = 2025;
41480 break;
41481 case 12:
41482 type4 = 2026;
41483 break;
41484 case 13:
41485 type4 = 2027;
41486 break;
41487 case 14:
41488 type4 = 2028;
41489 break;
41490 case 15:
41491 type4 = 2029;
41492 break;
41493 case 16:
41494 type4 = 2030;
41495 break;
41496 case 17:
41497 type4 = 2031;
41498 break;
41499 case 18:
41500 case 19:
41501 case 20:
41502 case 21:
41503 type4 = 2135 + num3 - 18;
41504 break;
41505 default:
41506 type4 = num3 switch
41507 {
41508 22 => 2233,
41509 23 => 2536,
41510 24 => 2540,
41511 25 => 2554,
41512 26 => 2569,
41513 27 => 2670,
41514 28 => 2817,
41515 29 => 3165,
41516 30 => 3167,
41517 31 => 3166,
41518 32 => 3917,
41519 33 => 3933,
41520 34 => 3960,
41521 35 => 4147,
41522 36 => 4168,
41523 37 => 4189,
41524 38 => 4210,
41525 39 => 4300,
41526 40 => 4568,
41527 41 => 5150,
41528 42 => 5171,
41529 43 => 5192,
41530 _ => 354,
41531 };
41532 break;
41533 }
41534 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type4);
41535 break;
41536 }
41537 case 102:
41538 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 355);
41539 break;
41540 case 463:
41541 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3813);
41542 break;
41543 case 617:
41544 if (num3 == 27)
41545 {
41546 short type2 = 5110;
41547 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type2);
41548 }
41549 else
41550 {
41551 int type3 = 4924 + num3;
41552 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type3);
41553 }
41554 break;
41555 }
41556 destroyObject = false;
41557 for (int num7 = num - 1; num7 < num + 4; num7++)
41558 {
41559 for (int num8 = num2 - 1; num8 < num2 + 4; num8++)
41560 {
41561 TileFrame(num7, num8);
41562 }
41563 }
41564 }
41565
41566 public static void Check5x4(int i, int j, int type)
41567 {
41568 if (destroyObject)
41569 {
41570 return;
41571 }
41572 bool flag = false;
41573 int num = i;
41574 int num2 = j;
41575 int num3 = 0;
41576 int num4;
41577 for (num4 = Main.tile[i, j].frameX / 18; num4 >= 5; num4 -= 5)
41578 {
41579 num3++;
41580 }
41581 num -= num4;
41582 num2 += Main.tile[i, j].frameY / 18 * -1;
41583 for (int k = num; k < num + 5; k++)
41584 {
41585 for (int l = num2; l < num2 + 4; l++)
41586 {
41587 if (Main.tile[k, l] == null)
41588 {
41589 Main.tile[k, l] = new Tile();
41590 }
41591 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != num3 * 90 + (k - num) * 18 || Main.tile[k, l].frameY != (l - num2) * 18)
41592 {
41593 flag = true;
41594 }
41595 }
41596 if (Main.tile[k, num2 + 4] == null)
41597 {
41598 Main.tile[k, num2 + 4] = new Tile();
41599 }
41600 if (!SolidTileAllowBottomSlope(k, num2 + 4))
41601 {
41602 flag = true;
41603 }
41604 }
41605 if (!flag)
41606 {
41607 return;
41608 }
41609 destroyObject = true;
41610 for (int m = num; m < num + 5; m++)
41611 {
41612 for (int n = num2; n < num2 + 4; n++)
41613 {
41614 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
41615 {
41616 KillTile(m, n);
41617 }
41618 }
41619 }
41620 if (type == 464)
41621 {
41622 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3814);
41623 }
41624 if (type == 466)
41625 {
41626 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3816);
41627 }
41628 destroyObject = false;
41629 for (int num5 = num - 1; num5 < num + 6; num5++)
41630 {
41631 for (int num6 = num2 - 1; num6 < num2 + 5; num6++)
41632 {
41633 TileFrame(num5, num6);
41634 }
41635 }
41636 }
41637
41638 public static void Check6x3(int i, int j, int type)
41639 {
41640 if (destroyObject)
41641 {
41642 return;
41643 }
41644 bool flag = false;
41645 int num = i;
41646 int num2 = j;
41647 num += Main.tile[i, j].frameX / 18 * -1;
41648 num2 += Main.tile[i, j].frameY / 18 * -1;
41649 for (int k = num; k < num + 6; k++)
41650 {
41651 for (int l = num2; l < num2 + 3; l++)
41652 {
41653 int num3 = (k - num) * 18;
41654 if (Main.tile[k, l] == null)
41655 {
41656 Main.tile[k, l] = new Tile();
41657 }
41658 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != num3 || Main.tile[k, l].frameY != (l - num2) * 18)
41659 {
41660 flag = true;
41661 }
41662 }
41663 if (Main.tile[k, num2 + 3] == null)
41664 {
41665 Main.tile[k, num2 + 3] = new Tile();
41666 }
41667 if (!SolidTileAllowBottomSlope(k, num2 + 3) && (!Main.tile[k, num2 + 3].nactive() || !Main.tileSolidTop[Main.tile[k, num2 + 3].type] || Main.tile[k, num2 + 3].frameY != 0))
41668 {
41669 flag = true;
41670 }
41671 }
41672 if (!flag)
41673 {
41674 return;
41675 }
41676 destroyObject = true;
41677 for (int m = num; m < num + 6; m++)
41678 {
41679 for (int n = num2; n < num2 + 3; n++)
41680 {
41681 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
41682 {
41683 KillTile(m, n);
41684 }
41685 }
41686 }
41687 if (type == 275)
41688 {
41689 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2162);
41690 }
41691 if (type == 413)
41692 {
41693 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3565);
41694 }
41695 if (type == 414)
41696 {
41697 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3566);
41698 }
41699 if (type == 276)
41700 {
41701 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2163);
41702 }
41703 if (type == 277)
41704 {
41705 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2164);
41706 }
41707 if (type == 278)
41708 {
41709 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2165);
41710 }
41711 if (type == 279)
41712 {
41713 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2166);
41714 }
41715 if (type == 280)
41716 {
41717 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2167);
41718 }
41719 if (type == 281)
41720 {
41721 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2168);
41722 }
41723 if (type == 296)
41724 {
41725 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2186);
41726 }
41727 if (type == 297)
41728 {
41729 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2187);
41730 }
41731 if (type == 309)
41732 {
41733 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2206);
41734 }
41735 if (type == 358)
41736 {
41737 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3070);
41738 }
41739 if (type == 359)
41740 {
41741 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3071);
41742 }
41743 if (type == 542)
41744 {
41745 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4396);
41746 }
41747 if (type == 550)
41748 {
41749 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4461);
41750 }
41751 if (type == 551)
41752 {
41753 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4462);
41754 }
41755 if (type == 553)
41756 {
41757 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4473);
41758 }
41759 if (type == 554)
41760 {
41761 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4474);
41762 }
41763 if (type == 558)
41764 {
41765 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4481);
41766 }
41767 if (type == 559)
41768 {
41769 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4483);
41770 }
41771 if (type == 599)
41772 {
41773 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4882);
41774 }
41775 if (type == 600)
41776 {
41777 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4883);
41778 }
41779 if (type == 601)
41780 {
41781 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4884);
41782 }
41783 if (type == 602)
41784 {
41785 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4885);
41786 }
41787 if (type == 603)
41788 {
41789 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4886);
41790 }
41791 if (type == 604)
41792 {
41793 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4887);
41794 }
41795 if (type == 605)
41796 {
41797 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4888);
41798 }
41799 if (type == 606)
41800 {
41801 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4889);
41802 }
41803 if (type == 607)
41804 {
41805 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4890);
41806 }
41807 if (type == 608)
41808 {
41809 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4891);
41810 }
41811 if (type == 609)
41812 {
41813 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4892);
41814 }
41815 if (type == 610)
41816 {
41817 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4893);
41818 }
41819 if (type == 611)
41820 {
41821 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4894);
41822 }
41823 if (type == 612)
41824 {
41825 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4895);
41826 }
41827 if (type == 632)
41828 {
41829 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5213);
41830 }
41831 if (type == 640)
41832 {
41833 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5301);
41834 }
41835 if (type == 643)
41836 {
41837 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5314);
41838 }
41839 if (type == 644)
41840 {
41841 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5315);
41842 }
41843 if (type == 645)
41844 {
41845 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5316);
41846 }
41847 destroyObject = false;
41848 for (int num4 = num - 1; num4 < num + 7; num4++)
41849 {
41850 for (int num5 = num2 - 1; num5 < num2 + 4; num5++)
41851 {
41852 TileFrame(num4, num5);
41853 }
41854 }
41855 }
41856
41857 public static void Place6x3(int x, int y, ushort type, int direction = -1, int style = 0)
41858 {
41860 {
41861 return;
41862 }
41863 bool flag = true;
41864 for (int i = x - 3; i < x + 3; i++)
41865 {
41866 for (int j = y - 2; j <= y; j++)
41867 {
41868 if (Main.tile[i, j] == null)
41869 {
41870 Main.tile[i, j] = new Tile();
41871 }
41872 if (Main.tile[i, j].active())
41873 {
41874 flag = false;
41875 }
41876 }
41877 if (Main.tile[i, y + 1] == null)
41878 {
41879 Main.tile[i, y + 1] = new Tile();
41880 }
41881 if (!SolidTile2(i, y + 1) && (!Main.tile[i, y + 1].nactive() || !Main.tileSolidTop[Main.tile[i, y + 1].type] || Main.tile[i, y + 1].frameY != 0))
41882 {
41883 flag = false;
41884 }
41885 }
41886 if (!flag)
41887 {
41888 return;
41889 }
41890 int num = 0;
41891 for (int k = x - 3; k < x + 3; k++)
41892 {
41893 int num2 = 0;
41894 for (int l = y - 2; l <= y; l++)
41895 {
41896 Main.tile[k, l].active(active: true);
41897 Main.tile[k, l].frameY = (short)num2;
41898 Main.tile[k, l].frameX = (short)num;
41899 Main.tile[k, l].type = type;
41900 num2 += 18;
41901 }
41902 num += 18;
41903 }
41904 }
41905
41906 public static void Place4x2(int x, int y, ushort type, int direction = -1, int style = 0)
41907 {
41909 {
41910 return;
41911 }
41912 bool flag = true;
41913 for (int i = x - 1; i < x + 3; i++)
41914 {
41915 for (int j = y - 1; j < y + 1; j++)
41916 {
41917 if (Main.tile[i, j] == null)
41918 {
41919 Main.tile[i, j] = new Tile();
41920 }
41921 if (Main.tile[i, j].active())
41922 {
41923 flag = false;
41924 }
41925 }
41926 if (Main.tile[i, y + 1] == null)
41927 {
41928 Main.tile[i, y + 1] = new Tile();
41929 }
41930 if (!SolidTile2(i, y + 1))
41931 {
41932 flag = false;
41933 }
41934 }
41935 short num = 0;
41936 if (direction == 1)
41937 {
41938 num = 72;
41939 }
41940 int num2 = 36 * style;
41941 if (flag)
41942 {
41943 Main.tile[x - 1, y - 1].active(active: true);
41944 Main.tile[x - 1, y - 1].frameY = (short)num2;
41945 Main.tile[x - 1, y - 1].frameX = num;
41946 Main.tile[x - 1, y - 1].type = type;
41947 Main.tile[x, y - 1].active(active: true);
41948 Main.tile[x, y - 1].frameY = (short)num2;
41949 Main.tile[x, y - 1].frameX = (short)(18 + num);
41950 Main.tile[x, y - 1].type = type;
41951 Main.tile[x + 1, y - 1].active(active: true);
41952 Main.tile[x + 1, y - 1].frameY = (short)num2;
41953 Main.tile[x + 1, y - 1].frameX = (short)(36 + num);
41954 Main.tile[x + 1, y - 1].type = type;
41955 Main.tile[x + 2, y - 1].active(active: true);
41956 Main.tile[x + 2, y - 1].frameY = (short)num2;
41957 Main.tile[x + 2, y - 1].frameX = (short)(54 + num);
41958 Main.tile[x + 2, y - 1].type = type;
41959 Main.tile[x - 1, y].active(active: true);
41960 Main.tile[x - 1, y].frameY = (short)(num2 + 18);
41961 Main.tile[x - 1, y].frameX = num;
41962 Main.tile[x - 1, y].type = type;
41963 Main.tile[x, y].active(active: true);
41964 Main.tile[x, y].frameY = (short)(num2 + 18);
41965 Main.tile[x, y].frameX = (short)(18 + num);
41966 Main.tile[x, y].type = type;
41967 Main.tile[x + 1, y].active(active: true);
41968 Main.tile[x + 1, y].frameY = (short)(num2 + 18);
41969 Main.tile[x + 1, y].frameX = (short)(36 + num);
41970 Main.tile[x + 1, y].type = type;
41971 Main.tile[x + 2, y].active(active: true);
41972 Main.tile[x + 2, y].frameY = (short)(num2 + 18);
41973 Main.tile[x + 2, y].frameX = (short)(54 + num);
41974 Main.tile[x + 2, y].type = type;
41975 }
41976 }
41977
41978 public static void ShootFromCannon(int x, int y, int angle, int ammo, int Damage, float KnockBack, int owner, bool fromWire)
41979 {
41980 float num = 14f;
41981 float num2 = 0f;
41982 float num3 = 0f;
41983 int type = 162;
41984 if (ammo == 2)
41985 {
41986 type = 281;
41987 }
41988 if (ammo == 3)
41989 {
41990 type = 178;
41991 }
41992 if (ammo == 4)
41993 {
41994 type = 601;
41995 num = 3f;
41996 }
41997 if (ammo == 5)
41998 {
41999 type = 601;
42000 num = 3f;
42001 }
42002 int num4 = 0;
42003 int num5 = 0;
42004 if (ammo == 5)
42005 {
42006 num4 = 1;
42007 }
42008 if (ammo == 2)
42009 {
42010 num5 = owner + 1;
42011 }
42012 if (angle == 0)
42013 {
42014 num2 = 10f;
42015 num3 = 0f;
42016 }
42017 if (angle == 1)
42018 {
42019 num2 = 7.5f;
42020 num3 = -2.5f;
42021 }
42022 if (angle == 2)
42023 {
42024 num2 = 5f;
42025 num3 = -5f;
42026 }
42027 if (angle == 3)
42028 {
42029 num2 = 2.75f;
42030 num3 = -6f;
42031 }
42032 if (angle == 4)
42033 {
42034 num2 = 0f;
42035 num3 = -10f;
42036 }
42037 if (angle == 5)
42038 {
42039 num2 = -2.75f;
42040 num3 = -6f;
42041 }
42042 if (angle == 6)
42043 {
42044 num2 = -5f;
42045 num3 = -5f;
42046 }
42047 if (angle == 7)
42048 {
42049 num2 = -7.5f;
42050 num3 = -2.5f;
42051 }
42052 if (angle == 8)
42053 {
42054 num2 = -10f;
42055 num3 = 0f;
42056 }
42057 Vector2 vector = new Vector2((x + 2) * 16, (y + 2) * 16);
42058 float num6 = num2;
42059 float num7 = num3;
42060 float num8 = (float)Math.Sqrt(num6 * num6 + num7 * num7);
42061 if (ammo == 4 || ammo == 5)
42062 {
42063 if (angle == 4)
42064 {
42065 vector.X += 5f;
42066 }
42067 vector.Y += 5f;
42068 }
42069 bool flag = true;
42070 if (ammo == 2 && !BunnyCannonCanFire())
42071 {
42072 flag = false;
42073 }
42074 if (!flag)
42075 {
42076 return;
42077 }
42078 num8 = num / num8;
42079 num6 *= num8;
42080 num7 *= num8;
42081 if (Main.myPlayer != owner && Main.netMode == 2 && (ammo == 4 || ammo == 5))
42082 {
42083 NetMessage.SendData(108, owner, -1, null, Damage, KnockBack, x, y, angle, ammo, owner);
42084 return;
42085 }
42086 if (Main.netMode == 2)
42087 {
42088 owner = Main.myPlayer;
42089 }
42090 int num9 = Projectile.NewProjectile(GetProjectileSource_PlayerOrWires(x, y, fromWire, Main.player[owner]), vector.X, vector.Y, num6, num7, type, Damage, KnockBack, owner, num4, num5);
42091 Main.projectile[num9].originatedFromActivableTile = true;
42092 }
42093
42094 public static bool BunnyCannonCanFire()
42095 {
42096 int num = 1;
42097 int num2 = 0;
42098 int num3 = 100;
42099 for (int i = 0; i < num3; i++)
42100 {
42101 NPC nPC = Main.npc[i];
42102 if (nPC == null || !nPC.active)
42103 {
42104 num2++;
42105 }
42106 }
42107 for (int j = 0; j < Main.projectile.Length; j++)
42108 {
42109 Projectile projectile = Main.projectile[j];
42110 if (projectile != null && projectile.active && projectile.type == 281)
42111 {
42112 num2--;
42113 if (num2 <= 0)
42114 {
42115 return false;
42116 }
42117 }
42118 }
42119 return num2 >= num;
42120 }
42121
42122 public static void SwitchCannon(int i, int j)
42123 {
42124 int num;
42125 for (num = Main.tile[i, j].frameX / 18; num >= 4; num -= 4)
42126 {
42127 }
42128 int num2;
42129 for (num2 = Main.tile[i, j].frameY / 18; num2 >= 3; num2 -= 3)
42130 {
42131 }
42132 int num3 = 1;
42133 if (num < 2)
42134 {
42135 num3 = -1;
42136 }
42137 num = i - num;
42138 num2 = j - num2;
42139 if ((num3 == 1 && Main.tile[num, num2].frameY <= 52) || (num3 == -1 && Main.tile[num, num2].frameY >= 432))
42140 {
42141 return;
42142 }
42143 num3 *= -54;
42144 for (int k = num; k < num + 4; k++)
42145 {
42146 for (int l = num2; l < num2 + 3; l++)
42147 {
42148 if (Main.tile[k, l] == null)
42149 {
42150 Main.tile[k, l] = new Tile();
42151 }
42152 if (Main.tile[k, l].active() && Main.tile[k, l].type == 209)
42153 {
42154 Main.tile[k, l].frameY = (short)(Main.tile[k, l].frameY + num3);
42155 }
42156 }
42157 }
42158 NetMessage.SendTileSquare(-1, num, num2, 4, 3);
42159 }
42160
42161 public static void CheckCannon(int i, int j, int type)
42162 {
42163 if (destroyObject)
42164 {
42165 return;
42166 }
42167 bool flag = false;
42168 int num = Main.tile[i, j].frameX / 18;
42169 int num2 = 0;
42170 while (num >= 4)
42171 {
42172 num2++;
42173 num -= 4;
42174 }
42175 num = i - num;
42176 int num3 = Main.tile[i, j].frameY / 18;
42177 int num4 = 0;
42178 while (num3 >= 3)
42179 {
42180 num4 += 54;
42181 num3 -= 3;
42182 }
42183 num3 = j - num3;
42184 int num5 = 72 * num2;
42185 for (int k = num; k < num + 4; k++)
42186 {
42187 int num6 = num4;
42188 for (int l = num3; l < num3 + 3; l++)
42189 {
42190 if (Main.tile[k, l] == null)
42191 {
42192 Main.tile[k, l] = new Tile();
42193 }
42194 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != num5 || Main.tile[k, l].frameY != num6)
42195 {
42196 flag = true;
42197 }
42198 num6 += 18;
42199 }
42200 if (Main.tile[k, num3 + 3] == null)
42201 {
42202 Main.tile[k, num3 + 3] = new Tile();
42203 }
42204 if (!SolidTileAllowBottomSlope(k, num3 + 3) && k != num && k != num + 3)
42205 {
42206 flag = true;
42207 }
42208 num5 += 18;
42209 }
42210 if (!flag)
42211 {
42212 return;
42213 }
42214 destroyObject = true;
42215 for (int m = num; m < num + 4; m++)
42216 {
42217 for (int n = num3; n < num3 + 3; n++)
42218 {
42219 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
42220 {
42221 KillTile(m, n);
42222 }
42223 }
42224 }
42225 int type2 = 928;
42226 switch (num2)
42227 {
42228 case 1:
42229 type2 = 1337;
42230 break;
42231 case 2:
42232 type2 = 3369;
42233 break;
42234 case 3:
42235 case 4:
42236 type2 = 3664;
42237 break;
42238 }
42239 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type2);
42240 destroyObject = false;
42241 for (int num7 = num; num7 < num + 4; num7++)
42242 {
42243 for (int num8 = num3; num8 < num3 + 3; num8++)
42244 {
42245 TileFrame(num7, num8);
42246 }
42247 }
42248 }
42249
42250 public static void PlaceCannon(int x, int y, ushort type, int style = 0)
42251 {
42253 {
42254 return;
42255 }
42256 bool flag = true;
42257 for (int i = x - 1; i < x + 3; i++)
42258 {
42259 for (int j = y - 2; j < y + 1; j++)
42260 {
42261 if (Main.tile[i, j] == null)
42262 {
42263 Main.tile[i, j] = new Tile();
42264 }
42265 if (Main.tile[i, j].active())
42266 {
42267 flag = false;
42268 }
42269 }
42270 if (Main.tile[i, y + 1] == null)
42271 {
42272 Main.tile[i, y + 1] = new Tile();
42273 }
42274 if (!SolidTile2(i, y + 1) && i != x - 1 && i != x + 2)
42275 {
42276 flag = false;
42277 }
42278 }
42279 int num = 72 * style;
42280 int num2 = 0;
42281 if (flag)
42282 {
42283 Main.tile[x - 1, y - 2].active(active: true);
42284 Main.tile[x - 1, y - 2].frameY = (short)num2;
42285 Main.tile[x - 1, y - 2].frameX = (short)num;
42286 Main.tile[x - 1, y - 2].type = type;
42287 Main.tile[x, y - 2].active(active: true);
42288 Main.tile[x, y - 2].frameY = (short)num2;
42289 Main.tile[x, y - 2].frameX = (short)(18 + num);
42290 Main.tile[x, y - 2].type = type;
42291 Main.tile[x + 1, y - 2].active(active: true);
42292 Main.tile[x + 1, y - 2].frameY = (short)num2;
42293 Main.tile[x + 1, y - 2].frameX = (short)(36 + num);
42294 Main.tile[x + 1, y - 2].type = type;
42295 Main.tile[x + 2, y - 2].active(active: true);
42296 Main.tile[x + 2, y - 2].frameY = (short)num2;
42297 Main.tile[x + 2, y - 2].frameX = (short)(54 + num);
42298 Main.tile[x + 2, y - 2].type = type;
42299 Main.tile[x - 1, y - 1].active(active: true);
42300 Main.tile[x - 1, y - 1].frameY = (short)(num2 + 18);
42301 Main.tile[x - 1, y - 1].frameX = (short)num;
42302 Main.tile[x - 1, y - 1].type = type;
42303 Main.tile[x, y - 1].active(active: true);
42304 Main.tile[x, y - 1].frameY = (short)(num2 + 18);
42305 Main.tile[x, y - 1].frameX = (short)(18 + num);
42306 Main.tile[x, y - 1].type = type;
42307 Main.tile[x + 1, y - 1].active(active: true);
42308 Main.tile[x + 1, y - 1].frameY = (short)(num2 + 18);
42309 Main.tile[x + 1, y - 1].frameX = (short)(36 + num);
42310 Main.tile[x + 1, y - 1].type = type;
42311 Main.tile[x + 2, y - 1].active(active: true);
42312 Main.tile[x + 2, y - 1].frameY = (short)(num2 + 18);
42313 Main.tile[x + 2, y - 1].frameX = (short)(54 + num);
42314 Main.tile[x + 2, y - 1].type = type;
42315 Main.tile[x - 1, y].active(active: true);
42316 Main.tile[x - 1, y].frameY = (short)(num2 + 36);
42317 Main.tile[x - 1, y].frameX = (short)num;
42318 Main.tile[x - 1, y].type = type;
42319 Main.tile[x, y].active(active: true);
42320 Main.tile[x, y].frameY = (short)(num2 + 36);
42321 Main.tile[x, y].frameX = (short)(18 + num);
42322 Main.tile[x, y].type = type;
42323 Main.tile[x + 1, y].active(active: true);
42324 Main.tile[x + 1, y].frameY = (short)(num2 + 36);
42325 Main.tile[x + 1, y].frameX = (short)(36 + num);
42326 Main.tile[x + 1, y].type = type;
42327 Main.tile[x + 2, y].active(active: true);
42328 Main.tile[x + 2, y].frameY = (short)(num2 + 36);
42329 Main.tile[x + 2, y].frameX = (short)(54 + num);
42330 Main.tile[x + 2, y].type = type;
42331 }
42332 }
42333
42334 public static void SwitchMB(int i, int j)
42335 {
42336 int num = i;
42337 int num2 = j;
42338 int num3;
42339 for (num3 = Main.tile[i, j].frameY / 18; num3 >= 2; num3 -= 2)
42340 {
42341 }
42342 int num4 = Main.tile[i, j].frameX / 18;
42343 if (num4 >= 2)
42344 {
42345 num4 -= 2;
42346 }
42347 num = i - num4;
42348 num2 = j - num3;
42349 for (int k = num; k < num + 2; k++)
42350 {
42351 for (int l = num2; l < num2 + 2; l++)
42352 {
42353 if (Main.tile[k, l] == null)
42354 {
42355 Main.tile[k, l] = new Tile();
42356 }
42357 if (Main.tile[k, l].active() && (Main.tile[k, l].type == 139 || Main.tile[k, l].type == 35))
42358 {
42359 if (Main.tile[k, l].frameX < 36)
42360 {
42361 Main.tile[k, l].frameX += 36;
42362 }
42363 else
42364 {
42365 Main.tile[k, l].frameX -= 36;
42366 }
42367 }
42368 }
42369 }
42370 if (Wiring.running)
42371 {
42372 Wiring.SkipWire(num, num2);
42373 Wiring.SkipWire(num + 1, num2);
42374 Wiring.SkipWire(num, num2 + 1);
42375 Wiring.SkipWire(num + 1, num2 + 1);
42376 }
42377 NetMessage.SendTileSquare(-1, num, num2, 2, 2);
42378 }
42379
42380 public static void SwitchMonolith(int i, int j)
42381 {
42382 int num = i;
42383 int num2 = j;
42384 int num3;
42385 for (num3 = Main.tile[i, j].frameX / 18; num3 >= 2; num3 -= 2)
42386 {
42387 }
42388 int num4;
42389 for (num4 = Main.tile[i, j].frameY / 18; num4 >= 3; num4 -= 3)
42390 {
42391 }
42392 num = i - num3;
42393 num2 = j - num4;
42394 for (int k = num; k < num + 2; k++)
42395 {
42396 for (int l = num2; l < num2 + 3; l++)
42397 {
42398 if (Main.tile[k, l] == null)
42399 {
42400 Main.tile[k, l] = new Tile();
42401 }
42402 Tile tile = Main.tile[k, l];
42403 if (!tile.active())
42404 {
42405 continue;
42406 }
42407 if (tile.type == 410)
42408 {
42409 if (tile.frameY < 56)
42410 {
42411 tile.frameY += 56;
42412 }
42413 else
42414 {
42415 tile.frameY -= 56;
42416 }
42417 }
42418 else if (tile.type == 480)
42419 {
42420 if (tile.frameY < 54)
42421 {
42422 tile.frameY += 54;
42423 }
42424 else
42425 {
42426 tile.frameY -= 54;
42427 }
42428 }
42429 else if (tile.type == 509)
42430 {
42431 if (tile.frameY < 54)
42432 {
42433 tile.frameY += 54;
42434 }
42435 else
42436 {
42437 tile.frameY -= 54;
42438 }
42439 }
42440 else if (tile.type == 657)
42441 {
42442 if (tile.frameY < 54)
42443 {
42444 tile.frameY += 54;
42445 }
42446 else
42447 {
42448 tile.frameY -= 54;
42449 }
42450 }
42451 else if (tile.type == 658)
42452 {
42453 short num5 = 54;
42454 short num6 = 3;
42455 short num7 = (short)(num5 * num6);
42456 tile.frameY += num5;
42457 if (tile.frameY >= num7)
42458 {
42459 tile.frameY -= num7;
42460 }
42461 }
42462 }
42463 }
42464 if (Wiring.running)
42465 {
42466 Wiring.SkipWire(num, num2);
42467 Wiring.SkipWire(num, num2 + 1);
42468 Wiring.SkipWire(num, num2 + 2);
42469 Wiring.SkipWire(num + 1, num2);
42470 Wiring.SkipWire(num + 1, num2 + 1);
42471 Wiring.SkipWire(num + 1, num2 + 2);
42472 }
42473 NetMessage.SendTileSquare(-1, num, num2, 2, 3);
42474 }
42475
42476 public static void SwitchFountain(int i, int j)
42477 {
42478 int num = i;
42479 int num2 = j;
42480 int num3;
42481 for (num3 = Main.tile[i, j].frameX / 18; num3 >= 2; num3 -= 2)
42482 {
42483 }
42484 int num4 = Main.tile[i, j].frameY / 18;
42485 if (num4 >= 4)
42486 {
42487 num4 -= 4;
42488 }
42489 num = i - num3;
42490 num2 = j - num4;
42491 for (int k = num; k < num + 2; k++)
42492 {
42493 for (int l = num2; l < num2 + 4; l++)
42494 {
42495 if (Main.tile[k, l] == null)
42496 {
42497 Main.tile[k, l] = new Tile();
42498 }
42499 if (Main.tile[k, l].active() && Main.tile[k, l].type == 207)
42500 {
42501 if (Main.tile[k, l].frameY < 72)
42502 {
42503 Main.tile[k, l].frameY += 72;
42504 }
42505 else
42506 {
42507 Main.tile[k, l].frameY -= 72;
42508 }
42509 }
42510 }
42511 }
42512 if (Wiring.running)
42513 {
42514 Wiring.SkipWire(num, num2);
42515 Wiring.SkipWire(num, num2 + 1);
42516 Wiring.SkipWire(num, num2 + 2);
42517 Wiring.SkipWire(num, num2 + 3);
42518 Wiring.SkipWire(num + 1, num2);
42519 Wiring.SkipWire(num + 1, num2 + 1);
42520 Wiring.SkipWire(num + 1, num2 + 2);
42521 Wiring.SkipWire(num + 1, num2 + 3);
42522 }
42523 NetMessage.SendTileSquare(-1, num, num2, 2, 4);
42524 }
42525
42526 public static void CheckMB(int i, int j, int type)
42527 {
42528 if (destroyObject)
42529 {
42530 return;
42531 }
42532 bool flag = false;
42533 int num = i;
42534 int num2 = j;
42535 int num3 = 0;
42536 int num4;
42537 for (num4 = Main.tile[i, j].frameY / 18; num4 >= 2; num4 -= 2)
42538 {
42539 num3++;
42540 }
42541 int num5 = Main.tile[i, j].frameX / 18;
42542 int num6 = 0;
42543 if (num5 >= 2)
42544 {
42545 num5 -= 2;
42546 num6++;
42547 }
42548 num = i - num5;
42549 num2 = j - num4;
42550 for (int k = num; k < num + 2; k++)
42551 {
42552 for (int l = num2; l < num2 + 2; l++)
42553 {
42554 if (Main.tile[k, l] == null)
42555 {
42556 Main.tile[k, l] = new Tile();
42557 }
42558 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num) * 18 + num6 * 36 || Main.tile[k, l].frameY != (l - num2) * 18 + num3 * 36)
42559 {
42560 flag = true;
42561 }
42562 }
42563 if (!Main.tile[k, num2 + 2].nactive())
42564 {
42565 flag = true;
42566 }
42567 else if (!Main.tileSolid[Main.tile[k, num2 + 2].type] && !Main.tileTable[Main.tile[k, num2 + 2].type])
42568 {
42569 flag = true;
42570 }
42571 }
42572 if (!flag)
42573 {
42574 return;
42575 }
42576 destroyObject = true;
42577 for (int m = num; m < num + 2; m++)
42578 {
42579 for (int n = num2; n < num2 + 3; n++)
42580 {
42581 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
42582 {
42583 KillTile(m, n);
42584 }
42585 }
42586 }
42587 if (type == 35)
42588 {
42589 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1813);
42590 }
42591 else if (num3 == 28)
42592 {
42593 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1963);
42594 }
42595 else if (num3 == 29)
42596 {
42597 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1964);
42598 }
42599 else if (num3 == 30)
42600 {
42601 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1965);
42602 }
42603 else if (num3 == 31)
42604 {
42605 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2742);
42606 }
42607 else if (num3 == 32)
42608 {
42609 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3044);
42610 }
42611 else if (num3 == 33)
42612 {
42613 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3235);
42614 }
42615 else if (num3 == 34)
42616 {
42617 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3236);
42618 }
42619 else if (num3 == 35)
42620 {
42621 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3237);
42622 }
42623 else if (num3 == 36)
42624 {
42625 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3370);
42626 }
42627 else if (num3 == 37)
42628 {
42629 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3371);
42630 }
42631 else if (num3 == 38)
42632 {
42633 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3796);
42634 }
42635 else if (num3 == 39)
42636 {
42637 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3869);
42638 }
42639 else if (num3 == 43)
42640 {
42641 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4077);
42642 }
42643 else if (num3 == 41)
42644 {
42645 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4078);
42646 }
42647 else if (num3 == 42)
42648 {
42649 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4079);
42650 }
42651 else if (num3 == 44)
42652 {
42653 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4080);
42654 }
42655 else if (num3 == 45)
42656 {
42657 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4081);
42658 }
42659 else if (num3 == 40)
42660 {
42661 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4082);
42662 }
42663 else if (num3 == 46)
42664 {
42665 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4237);
42666 }
42667 else if (num3 == 47)
42668 {
42669 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4356);
42670 }
42671 else if (num3 == 48)
42672 {
42673 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4357);
42674 }
42675 else if (num3 == 49)
42676 {
42677 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4358);
42678 }
42679 else if (num3 == 50)
42680 {
42681 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4421);
42682 }
42683 else if (num3 == 51)
42684 {
42685 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4606);
42686 }
42687 else if (num3 == 52)
42688 {
42689 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4979);
42690 }
42691 else if (num3 == 53)
42692 {
42693 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4985);
42694 }
42695 else if (num3 == 54)
42696 {
42697 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4990);
42698 }
42699 else if (num3 == 55)
42700 {
42701 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4991);
42702 }
42703 else if (num3 == 56)
42704 {
42705 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4992);
42706 }
42707 else if (num3 == 57)
42708 {
42709 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5006);
42710 }
42711 else if (num3 == 58)
42712 {
42713 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5014);
42714 }
42715 else if (num3 == 59)
42716 {
42717 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5015);
42718 }
42719 else if (num3 == 60)
42720 {
42721 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5016);
42722 }
42723 else if (num3 == 61)
42724 {
42725 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5017);
42726 }
42727 else if (num3 == 62)
42728 {
42729 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5018);
42730 }
42731 else if (num3 == 63)
42732 {
42733 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5019);
42734 }
42735 else if (num3 == 64)
42736 {
42737 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5020);
42738 }
42739 else if (num3 == 65)
42740 {
42741 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5021);
42742 }
42743 else if (num3 == 66)
42744 {
42745 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5022);
42746 }
42747 else if (num3 == 67)
42748 {
42749 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5023);
42750 }
42751 else if (num3 == 68)
42752 {
42753 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5024);
42754 }
42755 else if (num3 == 69)
42756 {
42757 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5025);
42758 }
42759 else if (num3 == 70)
42760 {
42761 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5026);
42762 }
42763 else if (num3 == 71)
42764 {
42765 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5027);
42766 }
42767 else if (num3 == 72)
42768 {
42769 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5028);
42770 }
42771 else if (num3 == 73)
42772 {
42773 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5029);
42774 }
42775 else if (num3 == 74)
42776 {
42777 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5030);
42778 }
42779 else if (num3 == 75)
42780 {
42781 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5031);
42782 }
42783 else if (num3 == 76)
42784 {
42785 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5032);
42786 }
42787 else if (num3 == 77)
42788 {
42789 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5033);
42790 }
42791 else if (num3 == 78)
42792 {
42793 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5034);
42794 }
42795 else if (num3 == 79)
42796 {
42797 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5035);
42798 }
42799 else if (num3 == 80)
42800 {
42801 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5036);
42802 }
42803 else if (num3 == 81)
42804 {
42805 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5037);
42806 }
42807 else if (num3 == 82)
42808 {
42809 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5038);
42810 }
42811 else if (num3 == 83)
42812 {
42813 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5039);
42814 }
42815 else if (num3 == 84)
42816 {
42817 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5040);
42818 }
42819 else if (num3 == 85)
42820 {
42821 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5044);
42822 }
42823 else if (num3 == 86)
42824 {
42825 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5112);
42826 }
42827 else if (num3 == 87)
42828 {
42829 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5362);
42830 }
42831 else if (num3 >= 13)
42832 {
42833 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1596 + num3 - 13);
42834 }
42835 else
42836 {
42837 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 562 + num3);
42838 }
42839 for (int num7 = num - 1; num7 < num + 3; num7++)
42840 {
42841 for (int num8 = num2 - 1; num8 < num2 + 3; num8++)
42842 {
42843 TileFrame(num7, num8);
42844 }
42845 }
42846 destroyObject = false;
42847 }
42848
42849 public static void PlaceMB(int X, int y, ushort type, int style)
42850 {
42851 int num = X + 1;
42853 {
42854 return;
42855 }
42856 bool flag = true;
42857 for (int i = num - 1; i < num + 1; i++)
42858 {
42859 for (int j = y - 1; j < y + 1; j++)
42860 {
42861 if (Main.tile[i, j] == null)
42862 {
42863 Main.tile[i, j] = new Tile();
42864 }
42865 if (Main.tile[i, j].active())
42866 {
42867 flag = false;
42868 }
42869 }
42870 if (Main.tile[i, y + 1] == null)
42871 {
42872 Main.tile[i, y + 1] = new Tile();
42873 }
42874 if (!Main.tile[i, y + 1].active() || Main.tile[i, y + 1].halfBrick() || (!Main.tileSolid[Main.tile[i, y + 1].type] && !Main.tileTable[Main.tile[i, y + 1].type]))
42875 {
42876 flag = false;
42877 }
42878 }
42879 if (flag)
42880 {
42881 Main.tile[num - 1, y - 1].active(active: true);
42882 Main.tile[num - 1, y - 1].frameY = (short)(style * 36);
42883 Main.tile[num - 1, y - 1].frameX = 0;
42884 Main.tile[num - 1, y - 1].type = type;
42885 Main.tile[num, y - 1].active(active: true);
42886 Main.tile[num, y - 1].frameY = (short)(style * 36);
42887 Main.tile[num, y - 1].frameX = 18;
42888 Main.tile[num, y - 1].type = type;
42889 Main.tile[num - 1, y].active(active: true);
42890 Main.tile[num - 1, y].frameY = (short)(style * 36 + 18);
42891 Main.tile[num - 1, y].frameX = 0;
42892 Main.tile[num - 1, y].type = type;
42893 Main.tile[num, y].active(active: true);
42894 Main.tile[num, y].frameY = (short)(style * 36 + 18);
42895 Main.tile[num, y].frameX = 18;
42896 Main.tile[num, y].type = type;
42897 }
42898 }
42899
42900 public static void Place2x2(int x, int y, ushort type, int style)
42901 {
42902 if (type == 95 || type == 126)
42903 {
42904 y++;
42905 }
42907 {
42908 return;
42909 }
42910 if (type == 172)
42911 {
42912 if (!CanPlaceSink(x, y, type, style))
42913 {
42914 return;
42915 }
42916 }
42917 else
42918 {
42919 for (int i = x - 1; i < x + 1; i++)
42920 {
42921 for (int j = y - 1; j < y + 1; j++)
42922 {
42924 if (tileSafely.active() || (type == 98 && tileSafely.liquid > 0))
42925 {
42926 return;
42927 }
42928 }
42929 switch (type)
42930 {
42931 case 95:
42932 case 126:
42933 {
42935 if (!tileSafely.nactive() || !Main.tileSolid[tileSafely.type] || Main.tileSolidTop[tileSafely.type])
42936 {
42937 return;
42938 }
42939 break;
42940 }
42941 default:
42942 {
42944 if (!tileSafely.nactive() || (!SolidTile2(tileSafely) && !Main.tileTable[tileSafely.type]))
42945 {
42946 return;
42947 }
42948 break;
42949 }
42950 case 132:
42951 break;
42952 }
42953 }
42954 }
42955 if (type == 132)
42956 {
42957 bool flag = true;
42958 if (Main.tile[x - 1, y + 1] == null)
42959 {
42960 Main.tile[x - 1, y + 1] = new Tile();
42961 }
42962 if (Main.tile[x, y + 1] == null)
42963 {
42964 Main.tile[x, y + 1] = new Tile();
42965 }
42966 if (!Main.tile[x - 1, y + 1].nactive() || (!SolidTile2(x - 1, y + 1) && !Main.tileTable[Main.tile[x - 1, y + 1].type]))
42967 {
42968 flag = false;
42969 }
42970 if (!Main.tile[x, y + 1].nactive() || (!SolidTile2(x, y + 1) && !Main.tileTable[Main.tile[x, y + 1].type]))
42971 {
42972 flag = false;
42973 }
42974 if (!flag && (Main.tile[x - 1, y - 1].wall < 1 || Main.tile[x, y - 1].wall < 1 || Main.tile[x - 1, y].wall < 1 || Main.tile[x - 1, y].wall < 1))
42975 {
42976 return;
42977 }
42978 }
42979 x--;
42980 y--;
42981 int num = ((type == 172) ? 38 : 36);
42982 for (int k = 0; k < 2; k++)
42983 {
42984 for (int l = 0; l < 2; l++)
42985 {
42986 Tile tileSafely = Main.tile[x + k, y + l];
42987 tileSafely.active(active: true);
42988 tileSafely.frameX = (short)(k * 18);
42989 tileSafely.frameY = (short)(style * num + l * 18);
42990 tileSafely.type = type;
42991 }
42992 }
42993 }
42994
42995 public static bool PlaceObject(int x, int y, int type, bool mute = false, int style = 0, int alternate = 0, int random = -1, int direction = -1)
42996 {
42997 if (type >= TileID.Count)
42998 {
42999 return false;
43000 }
43001 if (!TileObject.CanPlace(x, y, type, style, direction, out var objectData))
43002 {
43003 return false;
43004 }
43005 objectData.random = random;
43007 {
43008 SquareTileFrame(x, y);
43009 if (!mute)
43010 {
43011 SoundEngine.PlaySound(0, x * 16, y * 16);
43012 }
43013 }
43014 return true;
43015 }
43016
43017 public static bool ShiftTrapdoor(int x, int y, bool playerAbove, int onlyCloseOrOpen = -1)
43018 {
43020 if (tileSafely.type == 386 && onlyCloseOrOpen != 1)
43021 {
43022 Point topLeftAndStyles = GetTopLeftAndStyles(ref x, ref y, 2, 2, 18, 18);
43023 if (topLeftAndStyles.X == 0)
43024 {
43025 if (Main.netMode != 1 && Wiring.running)
43026 {
43027 Wiring.SkipWire(x, y);
43028 Wiring.SkipWire(x, y + 1);
43029 Wiring.SkipWire(x + 1, y);
43030 Wiring.SkipWire(x + 1, y + 1);
43031 }
43032 if (!Collision.EmptyTile(x, y + 1, ignoreTiles: true) || !Collision.EmptyTile(x + 1, y + 1, ignoreTiles: true))
43033 {
43034 return false;
43035 }
43036 SoundEngine.PlaySound(8, x * 16 + 16, y * 16 + 16);
43037 for (int i = 0; i < 2; i++)
43038 {
43039 tileSafely = Framing.GetTileSafely(x + i, y);
43040 tileSafely.ClearTile();
43041 }
43042 for (int j = 0; j < 2; j++)
43043 {
43044 tileSafely = Framing.GetTileSafely(x + j, y + 1);
43045 tileSafely.type = 387;
43046 tileSafely.frameX = (short)(j * 18);
43047 tileSafely.frameY = (short)(topLeftAndStyles.Y * 18);
43048 }
43049 for (int k = -1; k < 3; k++)
43050 {
43051 for (int l = 0; l < 3; l++)
43052 {
43053 TileFrame(x + k, y + l);
43054 }
43055 }
43056 return true;
43057 }
43058 if (topLeftAndStyles.X == 1)
43059 {
43060 if (Main.netMode != 1 && Wiring.running)
43061 {
43062 Wiring.SkipWire(x, y - 1);
43063 Wiring.SkipWire(x, y);
43064 Wiring.SkipWire(x + 1, y - 1);
43065 Wiring.SkipWire(x + 1, y);
43066 }
43067 if (!Collision.EmptyTile(x, y, ignoreTiles: true) || !Collision.EmptyTile(x + 1, y, ignoreTiles: true))
43068 {
43069 return false;
43070 }
43071 SoundEngine.PlaySound(8, x * 16 + 16, y * 16);
43072 for (int m = 0; m < 2; m++)
43073 {
43074 tileSafely = Framing.GetTileSafely(x + m, y + 1);
43075 tileSafely.ClearTile();
43076 }
43077 for (int n = 0; n < 2; n++)
43078 {
43080 tileSafely.type = 387;
43081 tileSafely.frameX = (short)(n * 18);
43082 tileSafely.frameY = (short)(topLeftAndStyles.Y * 18);
43083 }
43084 for (int num = -1; num < 3; num++)
43085 {
43086 for (int num2 = -1; num2 < 2; num2++)
43087 {
43088 TileFrame(x + num, y + num2);
43089 }
43090 }
43091 return true;
43092 }
43093 }
43094 if (tileSafely.type == 387 && onlyCloseOrOpen != 0)
43095 {
43096 GetTopLeftAndStyles(ref x, ref y, 2, 1, 18, 18);
43097 int num3 = playerAbove.ToDirectionInt();
43098 for (int num4 = 0; num4 < 2; num4++)
43099 {
43101 if (tileSafely.active() && !Main.tileCut[tileSafely.type])
43102 {
43103 return false;
43104 }
43105 }
43106 if (Main.netMode != 1 && Wiring.running)
43107 {
43108 Wiring.SkipWire(x, y);
43109 Wiring.SkipWire(x, y + num3);
43110 Wiring.SkipWire(x + 1, y);
43111 Wiring.SkipWire(x + 1, y + num3);
43112 }
43113 SoundEngine.PlaySound(8, x * 16 + 16, y * 16);
43114 for (int num5 = 0; num5 < 2; num5++)
43115 {
43117 if (tileSafely.active() && Main.tileCut[tileSafely.type])
43118 {
43119 KillTile(x + num5, y + num3);
43120 }
43121 }
43122 for (int num6 = 0; num6 < 2; num6++)
43123 {
43125 TileColorCache cache = tileSafely.BlockColorAndCoating();
43126 for (int num7 = 0; num7 < 2; num7++)
43127 {
43128 tileSafely = Framing.GetTileSafely(x + num6, y + num7 - (!playerAbove).ToInt());
43129 tileSafely.type = 386;
43130 tileSafely.frameX = (short)(num6 * 18 + playerAbove.ToInt() * 36);
43131 tileSafely.frameY = (short)(num7 * 18);
43132 tileSafely.UseBlockColors(cache);
43133 tileSafely.active(active: true);
43134 }
43135 }
43136 for (int num8 = -1; num8 < 3; num8++)
43137 {
43138 for (int num9 = -1; num9 < 3; num9++)
43139 {
43140 TileFrame(x + num8, y + num9 - (!playerAbove).ToInt() * 2);
43141 }
43142 }
43143 return true;
43144 }
43145 SoundEngine.PlaySound(9, x * 16, y * 16);
43146 return false;
43147 }
43148
43149 public static void CheckTrapDoor(int x, int y, int type)
43150 {
43151 if (destroyObject)
43152 {
43153 return;
43154 }
43155 bool flag = false;
43156 int num = 0;
43157 int num2 = 0;
43158 Point point = default(Point);
43159 if (type == 387)
43160 {
43161 num = 2;
43162 num2 = 1;
43163 point = GetTopLeftAndStyles(ref x, ref y, num, num2, 18, 18);
43164 flag = flag || !CheckTileFrames(type, x, y, num, num2, point.X, 18, point.Y, 18) || !CheckTileAnchors(x, y, num, num2, 1, AnchorType.SolidTile);
43165 }
43166 if (type == 386)
43167 {
43168 num = 2;
43169 num2 = 2;
43170 point = GetTopLeftAndStyles(ref x, ref y, num, num2, 18, 18);
43171 flag = flag || !CheckTileFrames(type, x, y, num, num2, point.X, 18, point.Y, 18);
43172 if (point.X == 0)
43173 {
43174 flag = flag || !CheckTileAnchors(x, y + 1, num, 1, 1, AnchorType.SolidTile);
43175 }
43176 else if (point.X == 1)
43177 {
43178 flag = flag || !CheckTileAnchors(x, y, num, 1, 1, AnchorType.SolidTile);
43179 }
43180 }
43181 if (!flag)
43182 {
43183 return;
43184 }
43185 destroyObject = true;
43186 for (int i = x; i < x + num; i++)
43187 {
43188 for (int j = y; j < y + num2; j++)
43189 {
43190 KillTile(i, j);
43191 }
43192 }
43193 int type2 = 3239;
43194 if (point.Y == 0)
43195 {
43196 type2 = 3239;
43197 }
43198 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, num * 16, num2 * 16, type2);
43199 for (int k = x - 1; k < x + num + 1; k++)
43200 {
43201 for (int l = y - 1; l < y + num2 + 1; l++)
43202 {
43203 TileFrame(k, l);
43204 }
43205 }
43206 destroyObject = false;
43207 }
43208
43209 public static void CheckTallGate(int x, int y, int type)
43210 {
43211 if (destroyObject)
43212 {
43213 return;
43214 }
43215 bool flag = false;
43217 Point point = new Point(tileSafely.frameX / 18, 0);
43219 point.Y = tileSafely.frameY / tileData.CoordinateFullHeight;
43220 int width = tileData.Width;
43221 int height = tileData.Height;
43222 int i = 0;
43223 for (int num = tileSafely.frameY % tileData.CoordinateFullHeight; i < height && num - tileData.CoordinateHeights[i] >= 0; i++)
43224 {
43225 num -= tileData.CoordinateHeights[i];
43226 }
43227 _ = tileData.CoordinateFullHeight;
43228 y -= i;
43229 int num2 = point.Y * tileData.CoordinateFullHeight;
43230 for (int j = 0; j < height; j++)
43231 {
43233 if (tileSafely.frameX != point.X * tileData.CoordinateFullWidth || tileSafely.frameY != num2)
43234 {
43235 flag = true;
43236 break;
43237 }
43238 num2 += tileData.CoordinateHeights[j] + tileData.CoordinatePadding;
43239 }
43240 if (!flag && CheckTileAnchors(x, y, width, height, 2, AnchorType.SolidTile))
43241 {
43242 return;
43243 }
43244 destroyObject = true;
43245 for (int k = x; k < x + width; k++)
43246 {
43247 for (int l = y; l < y + height; l++)
43248 {
43249 KillTile(k, l);
43250 }
43251 }
43252 int type2 = 3240;
43253 if (point.Y == 0)
43254 {
43255 type2 = 3240;
43256 }
43257 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, width * 16, height * 16, type2);
43258 for (int m = x - 1; m < x + width + 1; m++)
43259 {
43260 for (int n = y - 1; n < y + height + 1; n++)
43261 {
43262 TileFrame(m, n);
43263 }
43264 }
43265 destroyObject = false;
43266 }
43267
43268 public static bool ShiftTallGate(int x, int y, bool closing, bool forced = false)
43269 {
43270 ushort type = (ushort)(closing ? 388 : 389);
43271 ushort num = (ushort)(closing ? 389 : 388);
43273 if (tileSafely.type != num)
43274 {
43275 return false;
43276 }
43277 Point point = new Point(tileSafely.frameX / 18, 0);
43279 point.Y = tileSafely.frameY / tileData.CoordinateFullHeight;
43280 _ = tileData.Width;
43281 int height = tileData.Height;
43282 int i = 0;
43283 for (int num2 = tileSafely.frameY % tileData.CoordinateFullHeight; i < height && num2 - tileData.CoordinateHeights[i] >= 0; i++)
43284 {
43285 num2 -= tileData.CoordinateHeights[i];
43286 }
43287 _ = tileData.CoordinateFullHeight;
43288 y -= i;
43289 if (Main.netMode != 1 && Wiring.running)
43290 {
43291 for (int j = 0; j < height; j++)
43292 {
43293 Wiring.SkipWire(x, y + j);
43294 }
43295 }
43296 for (int k = 0; k < height; k++)
43297 {
43298 if (!forced && !Collision.EmptyTile(x, y + k, ignoreTiles: true))
43299 {
43300 return false;
43301 }
43302 }
43303 SoundEngine.PlaySound(8, x * 16 + 16, y * 16 + 16);
43304 for (int l = 0; l < height; l++)
43305 {
43307 tileSafely.type = type;
43308 }
43309 for (int m = -1; m < 2; m++)
43310 {
43311 for (int n = -1; n < height + 1; n++)
43312 {
43313 TileFrame(x + m, y + n);
43314 }
43315 }
43316 return true;
43317 }
43318
43319 public static Point GetTopLeftAndStyles(ref int x, ref int y, int w, int h, int frameXinc, int frameYinc)
43320 {
43322 Point result = new Point(tileSafely.frameX / (w * frameXinc), tileSafely.frameY / (h * frameYinc));
43323 if (frameXinc != 0)
43324 {
43325 x -= tileSafely.frameX / frameXinc % w;
43326 }
43327 if (frameYinc != 0)
43328 {
43329 y -= tileSafely.frameY / frameYinc % h;
43330 }
43331 return result;
43332 }
43333
43334 public static bool CheckTileFrames(int type, int sx, int sy, int w, int h, int styleX, int frameXinc, int styleY, int frameYinc)
43335 {
43336 for (int i = 0; i < w; i++)
43337 {
43338 for (int j = 0; j < h; j++)
43339 {
43341 if (!tileSafely.active() || tileSafely.type != type || tileSafely.frameX != styleX * w * frameXinc + i * frameXinc || tileSafely.frameY != styleY * h * frameYinc + j * frameYinc)
43342 {
43343 return false;
43344 }
43345 }
43346 }
43347 return true;
43348 }
43349
43350 public static bool CheckTileAnchors(int sx, int sy, int w, int h, int mode, AnchorType anchor)
43351 {
43352 if ((mode & 1) == 1)
43353 {
43354 for (int i = sy; i < sy + h; i++)
43355 {
43356 if (!AnchorValid(Framing.GetTileSafely(sx - 1, i), anchor))
43357 {
43358 return false;
43359 }
43360 if (!AnchorValid(Framing.GetTileSafely(sx + w, i), anchor))
43361 {
43362 return false;
43363 }
43364 }
43365 }
43366 if ((mode & 2) == 2)
43367 {
43368 for (int j = sx; j < sx + w; j++)
43369 {
43370 if (!AnchorValid(Framing.GetTileSafely(j, sy - 1), anchor))
43371 {
43372 return false;
43373 }
43374 if (!AnchorValid(Framing.GetTileSafely(j, sy + h), anchor))
43375 {
43376 return false;
43377 }
43378 }
43379 }
43380 return true;
43381 }
43382
43383 public static bool AnchorValid(Tile tileCache, AnchorType anchor)
43384 {
43385 bool flag = false;
43386 if (tileCache.nactive())
43387 {
43388 if ((anchor & AnchorType.SolidTile) == AnchorType.SolidTile && Main.tileSolid[tileCache.type] && !Main.tileSolidTop[tileCache.type] && !Main.tileNoAttach[tileCache.type] && tileCache.blockType() == 0)
43389 {
43390 flag = true;
43391 }
43392 if ((anchor & AnchorType.SolidBottom) == AnchorType.SolidBottom && ((Main.tileSolid[tileCache.type] && (!Main.tileSolidTop[tileCache.type] || (TileID.Sets.Platforms[tileCache.type] && (tileCache.halfBrick() || tileCache.topSlope())))) || tileCache.topSlope() || tileCache.halfBrick()) && !TileID.Sets.NotReallySolid[tileCache.type] && !tileCache.bottomSlope())
43393 {
43394 flag = true;
43395 }
43396 if (!flag && ((anchor & AnchorType.SolidWithTop) == AnchorType.SolidWithTop || (anchor & AnchorType.Table) == AnchorType.Table))
43397 {
43398 if (TileID.Sets.Platforms[tileCache.type])
43399 {
43400 int num = tileCache.frameX / TileObjectData.PlatformFrameWidth();
43401 if ((!tileCache.halfBrick() && num >= 0 && num <= 7) || (num >= 12 && num <= 16) || (num >= 25 && num <= 26))
43402 {
43403 flag = true;
43404 }
43405 }
43406 else if (Main.tileSolid[tileCache.type] && Main.tileSolidTop[tileCache.type])
43407 {
43408 flag = true;
43409 }
43410 }
43411 if (!flag && (anchor & AnchorType.Table) == AnchorType.Table && !TileID.Sets.Platforms[tileCache.type] && Main.tileTable[tileCache.type] && tileCache.blockType() == 0)
43412 {
43413 flag = true;
43414 }
43415 if (!flag && (anchor & AnchorType.SolidSide) == AnchorType.SolidSide && Main.tileSolid[tileCache.type] && !Main.tileSolidTop[tileCache.type])
43416 {
43417 int num2 = tileCache.blockType();
43418 if ((uint)(num2 - 4) <= 1u)
43419 {
43420 flag = true;
43421 }
43422 }
43423 }
43424 else if (!flag && (anchor & AnchorType.EmptyTile) == AnchorType.EmptyTile)
43425 {
43426 flag = true;
43427 }
43428 return flag;
43429 }
43430
43431 public static bool CanPlaceSink(int x, int y, ushort type, int style)
43432 {
43434 {
43435 return false;
43436 }
43437 bool result = true;
43438 x--;
43439 y--;
43440 for (int i = 0; i < 2; i++)
43441 {
43443 for (int j = 0; j < 2; j++)
43444 {
43445 tileSafely = Framing.GetTileSafely(x + i, y + j);
43446 if (tileSafely.active())
43447 {
43448 result = false;
43449 }
43450 }
43451 tileSafely = Framing.GetTileSafely(x + i, y + 2);
43452 if (!tileSafely.nactive() || !SolidTile(tileSafely))
43453 {
43454 result = false;
43455 }
43456 }
43457 return result;
43458 }
43459
43460 public static void Place3x4(int x, int y, ushort type, int style)
43461 {
43463 {
43464 return;
43465 }
43466 bool flag = true;
43467 for (int i = x - 1; i < x + 2; i++)
43468 {
43469 for (int j = y - 3; j < y + 1; j++)
43470 {
43471 if (Main.tile[i, j] == null)
43472 {
43473 Main.tile[i, j] = new Tile();
43474 }
43475 if (Main.tile[i, j].active())
43476 {
43477 flag = false;
43478 }
43479 }
43480 if (Main.tile[i, y + 1] == null)
43481 {
43482 Main.tile[i, y + 1] = new Tile();
43483 }
43484 if (!SolidTile2(i, y + 1))
43485 {
43486 flag = false;
43487 }
43488 }
43489 if (flag)
43490 {
43491 int num = style * 54;
43492 for (int k = -3; k <= 0; k++)
43493 {
43494 short frameY = (short)((3 + k) * 18);
43495 Main.tile[x - 1, y + k].active(active: true);
43496 Main.tile[x - 1, y + k].frameY = frameY;
43497 Main.tile[x - 1, y + k].frameX = (short)num;
43498 Main.tile[x - 1, y + k].type = type;
43499 Main.tile[x, y + k].active(active: true);
43500 Main.tile[x, y + k].frameY = frameY;
43501 Main.tile[x, y + k].frameX = (short)(num + 18);
43502 Main.tile[x, y + k].type = type;
43503 Main.tile[x + 1, y + k].active(active: true);
43504 Main.tile[x + 1, y + k].frameY = frameY;
43505 Main.tile[x + 1, y + k].frameX = (short)(num + 36);
43506 Main.tile[x + 1, y + k].type = type;
43507 }
43508 }
43509 }
43510
43511 public static void Place5x4(int x, int y, ushort type, int style)
43512 {
43514 {
43515 return;
43516 }
43517 bool flag = true;
43518 for (int i = x - 2; i < x + 3; i++)
43519 {
43520 for (int j = y - 3; j < y + 1; j++)
43521 {
43522 if (Main.tile[i, j] == null)
43523 {
43524 Main.tile[i, j] = new Tile();
43525 }
43526 if (Main.tile[i, j].active())
43527 {
43528 flag = false;
43529 }
43530 }
43531 if (Main.tile[i, y + 1] == null)
43532 {
43533 Main.tile[i, y + 1] = new Tile();
43534 }
43535 if (!SolidTile2(i, y + 1))
43536 {
43537 flag = false;
43538 }
43539 }
43540 if (flag)
43541 {
43542 int num = style * 54;
43543 for (int k = -3; k <= 0; k++)
43544 {
43545 short frameY = (short)((3 + k) * 18);
43546 Main.tile[x - 2, y + k].active(active: true);
43547 Main.tile[x - 2, y + k].frameY = frameY;
43548 Main.tile[x - 2, y + k].frameX = (short)(num - 36);
43549 Main.tile[x - 2, y + k].type = type;
43550 Main.tile[x - 1, y + k].active(active: true);
43551 Main.tile[x - 1, y + k].frameY = frameY;
43552 Main.tile[x - 1, y + k].frameX = (short)(num - 18);
43553 Main.tile[x - 1, y + k].type = type;
43554 Main.tile[x, y + k].active(active: true);
43555 Main.tile[x, y + k].frameY = frameY;
43556 Main.tile[x, y + k].frameX = (short)num;
43557 Main.tile[x, y + k].type = type;
43558 Main.tile[x + 1, y + k].active(active: true);
43559 Main.tile[x + 1, y + k].frameY = frameY;
43560 Main.tile[x + 1, y + k].frameX = (short)(num + 18);
43561 Main.tile[x + 1, y + k].type = type;
43562 Main.tile[x + 1, y + k].active(active: true);
43563 Main.tile[x + 1, y + k].frameY = frameY;
43564 Main.tile[x + 1, y + k].frameX = (short)(num + 36);
43565 Main.tile[x + 1, y + k].type = type;
43566 }
43567 }
43568 }
43569
43570 public static void Place3x1(int x, int y, ushort type, int style = 0)
43571 {
43573 {
43574 return;
43575 }
43576 bool flag = true;
43577 for (int i = x - 1; i < x + 2; i++)
43578 {
43579 if (Main.tile[i, y] == null)
43580 {
43581 Main.tile[i, y] = new Tile();
43582 }
43583 if (Main.tile[i, y].active())
43584 {
43585 flag = false;
43586 }
43587 if (Main.tile[i, y + 1] == null)
43588 {
43589 Main.tile[i, y + 1] = new Tile();
43590 }
43591 if (!SolidTile2(i, y + 1))
43592 {
43593 flag = false;
43594 }
43595 }
43596 if (flag)
43597 {
43598 short num = (short)(54 * style);
43599 Main.tile[x - 1, y].active(active: true);
43600 Main.tile[x - 1, y].frameY = 0;
43601 Main.tile[x - 1, y].frameX = num;
43602 Main.tile[x - 1, y].type = type;
43603 Main.tile[x, y].active(active: true);
43604 Main.tile[x, y].frameY = 0;
43605 Main.tile[x, y].frameX = (short)(num + 18);
43606 Main.tile[x, y].type = type;
43607 Main.tile[x + 1, y].active(active: true);
43608 Main.tile[x + 1, y].frameY = 0;
43609 Main.tile[x + 1, y].frameX = (short)(num + 36);
43610 Main.tile[x + 1, y].type = type;
43611 }
43612 }
43613
43614 public static void Place3x2(int x, int y, ushort type, int style = 0)
43615 {
43617 {
43618 return;
43619 }
43620 bool flag = false;
43621 bool flag2 = true;
43622 if (type == 14 && style == 25)
43623 {
43624 flag = true;
43625 }
43626 int num = y - 1;
43627 if (flag)
43628 {
43629 num = y;
43630 }
43631 for (int i = x - 1; i < x + 2; i++)
43632 {
43633 for (int j = num; j < y + 1; j++)
43634 {
43635 if (Main.tile[i, j] == null)
43636 {
43637 Main.tile[i, j] = new Tile();
43638 }
43639 if (Main.tile[i, j].active())
43640 {
43641 flag2 = false;
43642 }
43643 if (type == 215 && Main.tile[i, j].liquid > 0)
43644 {
43645 flag2 = false;
43646 }
43647 }
43648 if (Main.tile[i, y + 1] == null)
43649 {
43650 Main.tile[i, y + 1] = new Tile();
43651 }
43652 switch (type)
43653 {
43654 default:
43655 if (type != 582 && type != 619)
43656 {
43657 if (type == 26 && TileID.Sets.Boulders[Main.tile[i, y + 1].type])
43658 {
43659 flag2 = false;
43660 }
43661 if (!SolidTile2(i, y + 1))
43662 {
43663 flag2 = false;
43664 }
43665 break;
43666 }
43667 goto case 285;
43668 case 285:
43669 case 286:
43670 case 298:
43671 case 299:
43672 case 310:
43673 case 361:
43674 case 362:
43675 case 363:
43676 case 364:
43677 if (!SolidTile2(i, y + 1) && (!Main.tile[i, y + 1].nactive() || !Main.tileSolidTop[Main.tile[i, y + 1].type] || Main.tile[i, y + 1].frameY != 0))
43678 {
43679 flag2 = false;
43680 }
43681 break;
43682 }
43683 }
43684 if (type == 88)
43685 {
43686 if (Chest.CreateChest(x - 1, y - 1) == -1)
43687 {
43688 flag2 = false;
43689 }
43690 else if (Main.netMode == 1)
43691 {
43692 NetMessage.SendData(34, -1, -1, null, 2, x, y, style);
43693 }
43694 }
43695 if (flag2)
43696 {
43697 short num2 = (short)(54 * style);
43698 if (flag)
43699 {
43700 Main.tile[x - 1, y].active(active: true);
43701 Main.tile[x - 1, y].frameY = 0;
43702 Main.tile[x - 1, y].frameX = num2;
43703 Main.tile[x - 1, y].type = type;
43704 Main.tile[x, y].active(active: true);
43705 Main.tile[x, y].frameY = 0;
43706 Main.tile[x, y].frameX = (short)(num2 + 18);
43707 Main.tile[x, y].type = type;
43708 Main.tile[x + 1, y].active(active: true);
43709 Main.tile[x + 1, y].frameY = 0;
43710 Main.tile[x + 1, y].frameX = (short)(num2 + 36);
43711 Main.tile[x + 1, y].type = type;
43712 return;
43713 }
43714 Main.tile[x - 1, y - 1].active(active: true);
43715 Main.tile[x - 1, y - 1].frameY = 0;
43716 Main.tile[x - 1, y - 1].frameX = num2;
43717 Main.tile[x - 1, y - 1].type = type;
43718 Main.tile[x, y - 1].active(active: true);
43719 Main.tile[x, y - 1].frameY = 0;
43720 Main.tile[x, y - 1].frameX = (short)(num2 + 18);
43721 Main.tile[x, y - 1].type = type;
43722 Main.tile[x + 1, y - 1].active(active: true);
43723 Main.tile[x + 1, y - 1].frameY = 0;
43724 Main.tile[x + 1, y - 1].frameX = (short)(num2 + 36);
43725 Main.tile[x + 1, y - 1].type = type;
43726 Main.tile[x - 1, y].active(active: true);
43727 Main.tile[x - 1, y].frameY = 18;
43728 Main.tile[x - 1, y].frameX = num2;
43729 Main.tile[x - 1, y].type = type;
43730 Main.tile[x, y].active(active: true);
43731 Main.tile[x, y].frameY = 18;
43732 Main.tile[x, y].frameX = (short)(num2 + 18);
43733 Main.tile[x, y].type = type;
43734 Main.tile[x + 1, y].active(active: true);
43735 Main.tile[x + 1, y].frameY = 18;
43736 Main.tile[x + 1, y].frameX = (short)(num2 + 36);
43737 Main.tile[x + 1, y].type = type;
43738 }
43739 }
43740
43741 public static void Place2x2Style(int x, int y, ushort type, int style = 0)
43742 {
43744 {
43745 return;
43746 }
43747 short num = 0;
43748 if (type == 254)
43749 {
43750 num = (short)(x % 12 / 2);
43751 num *= 36;
43752 }
43753 bool flag = true;
43754 for (int i = x - 1; i < x + 1; i++)
43755 {
43756 for (int j = y - 1; j < y + 1; j++)
43757 {
43758 if (Main.tile[i, j] == null)
43759 {
43760 Main.tile[i, j] = new Tile();
43761 }
43762 if (Main.tile[i, j].active())
43763 {
43764 flag = false;
43765 }
43766 }
43767 if (Main.tile[i, y + 1] == null)
43768 {
43769 Main.tile[i, y + 1] = new Tile();
43770 }
43771 if (!SolidTile(i, y + 1))
43772 {
43773 flag = false;
43774 }
43775 if (type == 254 && Main.tile[i, y + 1].type != 2 && Main.tile[i, y + 1].type != 477 && Main.tile[i, y + 1].type != 492 && Main.tile[i, y + 1].type != 109)
43776 {
43777 flag = false;
43778 }
43779 }
43780 if (flag)
43781 {
43782 short num2 = (short)(36 * style);
43783 Main.tile[x - 1, y - 1].active(active: true);
43784 Main.tile[x - 1, y - 1].frameY = num;
43785 Main.tile[x - 1, y - 1].frameX = num2;
43786 Main.tile[x - 1, y - 1].type = type;
43787 Main.tile[x, y - 1].active(active: true);
43788 Main.tile[x, y - 1].frameY = num;
43789 Main.tile[x, y - 1].frameX = (short)(num2 + 18);
43790 Main.tile[x, y - 1].type = type;
43791 Main.tile[x - 1, y].active(active: true);
43792 Main.tile[x - 1, y].frameY = (short)(num + 18);
43793 Main.tile[x - 1, y].frameX = num2;
43794 Main.tile[x - 1, y].type = type;
43795 Main.tile[x, y].active(active: true);
43796 Main.tile[x, y].frameY = (short)(num + 18);
43797 Main.tile[x, y].frameX = (short)(num2 + 18);
43798 Main.tile[x, y].type = type;
43799 }
43800 }
43801
43802 public static bool NearFriendlyWall(int x, int y)
43803 {
43804 try
43805 {
43807 {
43808 return true;
43809 }
43810 if (Main.tile[x, y].wall == 0 || Main.wallHouse[Main.tile[x, y].wall])
43811 {
43812 return true;
43813 }
43814 if (Main.tile[x - 1, y].wall == 0 || Main.wallHouse[Main.tile[x - 1, y].wall])
43815 {
43816 return true;
43817 }
43818 if (Main.tile[x + 1, y].wall == 0 || Main.wallHouse[Main.tile[x + 1, y].wall])
43819 {
43820 return true;
43821 }
43822 if (Main.tile[x, y - 1].wall == 0 || Main.wallHouse[Main.tile[x, y - 1].wall])
43823 {
43824 return true;
43825 }
43826 if (Main.tile[x, y + 1].wall == 0 || Main.wallHouse[Main.tile[x, y + 1].wall])
43827 {
43828 return true;
43829 }
43830 }
43831 catch
43832 {
43833 }
43834 return false;
43835 }
43836
43837 public static void Check2x2Style(int i, int j, int type)
43838 {
43839 if (destroyObject)
43840 {
43841 return;
43842 }
43843 bool flag = false;
43844 int num = j;
43845 int num2;
43846 for (num2 = Main.tile[i, j].frameY / 18; num2 > 1; num2 -= 2)
43847 {
43848 }
43849 num -= num2;
43850 int num3 = Main.tile[i, j].frameX / 18;
43851 int num4 = 0;
43852 while (num3 > 1)
43853 {
43854 num3 -= 2;
43855 num4++;
43856 }
43857 num3 = i - num3;
43858 int num5 = num4 * 36;
43859 for (int k = num3; k < num3 + 2; k++)
43860 {
43861 for (int l = num; l < num + 2; l++)
43862 {
43863 if (Main.tile[k, l] == null)
43864 {
43865 Main.tile[k, l] = new Tile();
43866 }
43867 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num3) * 18 + num5)
43868 {
43869 flag = true;
43870 }
43871 }
43872 if (!SolidTileAllowBottomSlope(k, num + 2))
43873 {
43874 flag = true;
43875 }
43876 else
43877 {
43878 if (type != 254)
43879 {
43880 continue;
43881 }
43882 Tile tile = Main.tile[k, num + 2];
43883 if (tile != null && tile.active() && tile.type >= 0 && tile.type < TileID.Count)
43884 {
43885 ushort type2 = tile.type;
43886 if (type2 != 2 && type2 != 109 && type2 != 477 && type2 != 492)
43887 {
43888 flag = true;
43889 }
43890 }
43891 }
43892 }
43893 if (!flag)
43894 {
43895 return;
43896 }
43897 int frameX = Main.tile[i, j].frameX;
43898 destroyObject = true;
43899 for (int m = num3; m < num3 + 2; m++)
43900 {
43901 for (int n = num; n < num + 2; n++)
43902 {
43903 if (Main.tile[m, n] == null)
43904 {
43905 Main.tile[m, n] = new Tile();
43906 }
43907 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
43908 {
43909 KillTile(m, n);
43910 }
43911 }
43912 }
43913 switch (type)
43914 {
43915 case 254:
43916 if (frameX < 72)
43917 {
43918 break;
43919 }
43920 if (frameX < 108)
43921 {
43922 if (genRand.Next(2) == 0)
43923 {
43924 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1725, genRand.Next(1, 3));
43925 }
43926 break;
43927 }
43928 if (frameX < 144)
43929 {
43930 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1725, genRand.Next(2, 6));
43931 break;
43932 }
43933 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1725, genRand.Next(5, 11));
43934 if (Main.halloween && genRand.Next(200) == 0)
43935 {
43936 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1799);
43937 }
43938 break;
43939 case 457:
43940 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3749);
43941 break;
43942 case 96:
43943 if (num4 == 0)
43944 {
43945 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 345);
43946 }
43947 if (num4 == 1)
43948 {
43949 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1791);
43950 }
43951 break;
43952 case 441:
43953 {
43954 int num7 = -1;
43955 switch (num4)
43956 {
43957 case 0:
43958 num7 = 3665;
43959 break;
43960 case 1:
43961 num7 = 3666;
43962 break;
43963 case 3:
43964 num7 = 3667;
43965 break;
43966 case 7:
43967 num7 = 3668;
43968 break;
43969 case 8:
43970 num7 = 3669;
43971 break;
43972 case 9:
43973 num7 = 3670;
43974 break;
43975 case 10:
43976 num7 = 3671;
43977 break;
43978 case 11:
43979 num7 = 3672;
43980 break;
43981 case 12:
43982 num7 = 3673;
43983 break;
43984 case 13:
43985 num7 = 3674;
43986 break;
43987 case 14:
43988 num7 = 3675;
43989 break;
43990 case 15:
43991 num7 = 3676;
43992 break;
43993 case 16:
43994 num7 = 3677;
43995 break;
43996 case 17:
43997 num7 = 3678;
43998 break;
43999 case 18:
44000 num7 = 3679;
44001 break;
44002 case 19:
44003 num7 = 3680;
44004 break;
44005 case 20:
44006 num7 = 3681;
44007 break;
44008 case 21:
44009 num7 = 3682;
44010 break;
44011 case 22:
44012 num7 = 3683;
44013 break;
44014 case 28:
44015 num7 = 3684;
44016 break;
44017 case 29:
44018 num7 = 3685;
44019 break;
44020 case 30:
44021 num7 = 3686;
44022 break;
44023 case 31:
44024 num7 = 3687;
44025 break;
44026 case 32:
44027 num7 = 3688;
44028 break;
44029 case 33:
44030 num7 = 3689;
44031 break;
44032 case 34:
44033 num7 = 3690;
44034 break;
44035 case 35:
44036 num7 = 3691;
44037 break;
44038 case 37:
44039 num7 = 3692;
44040 break;
44041 case 39:
44042 num7 = 3693;
44043 break;
44044 case 41:
44045 num7 = 3694;
44046 break;
44047 case 42:
44048 num7 = 3695;
44049 break;
44050 case 43:
44051 num7 = 3696;
44052 break;
44053 case 44:
44054 num7 = 3697;
44055 break;
44056 case 45:
44057 num7 = 3698;
44058 break;
44059 case 46:
44060 num7 = 3699;
44061 break;
44062 case 47:
44063 num7 = 3700;
44064 break;
44065 case 48:
44066 num7 = 3701;
44067 break;
44068 case 49:
44069 num7 = 3702;
44070 break;
44071 case 50:
44072 num7 = 3703;
44073 break;
44074 case 51:
44075 num7 = 3704;
44076 break;
44077 }
44078 if (num7 != -1)
44079 {
44080 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num7);
44081 }
44082 break;
44083 }
44084 case 468:
44085 {
44086 int num6 = -1;
44087 switch (num4)
44088 {
44089 case 0:
44090 num6 = 3886;
44091 break;
44092 case 1:
44093 num6 = 3887;
44094 break;
44095 case 2:
44096 num6 = 3950;
44097 break;
44098 case 3:
44099 num6 = 3976;
44100 break;
44101 case 4:
44102 num6 = -1;
44103 break;
44104 case 5:
44105 num6 = 4164;
44106 break;
44107 case 6:
44108 num6 = 4185;
44109 break;
44110 case 7:
44111 num6 = 4206;
44112 break;
44113 case 8:
44114 num6 = 4227;
44115 break;
44116 case 9:
44117 num6 = 4266;
44118 break;
44119 case 10:
44120 num6 = 4268;
44121 break;
44122 case 11:
44123 num6 = 4585;
44124 break;
44125 case 12:
44126 num6 = 4713;
44127 break;
44128 case 13:
44129 num6 = -1;
44130 break;
44131 case 14:
44132 num6 = 5167;
44133 break;
44134 case 15:
44135 num6 = 5188;
44136 break;
44137 case 16:
44138 num6 = 5209;
44139 break;
44140 }
44141 if (num6 != -1)
44142 {
44143 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, num6);
44144 }
44145 break;
44146 }
44147 }
44148 destroyObject = false;
44149 for (int num8 = num3 - 1; num8 < num3 + 3; num8++)
44150 {
44151 for (int num9 = num - 1; num9 < num + 3; num9++)
44152 {
44153 TileFrame(num8, num9);
44154 }
44155 }
44156 }
44157
44158 public static void PlacePumpkin(int x, int superY)
44159 {
44160 ushort type = 254;
44161 int num = genRand.Next(6) * 36;
44163 {
44164 return;
44165 }
44166 bool flag = true;
44167 for (int i = x - 1; i < x + 1; i++)
44168 {
44169 for (int j = superY - 1; j < superY + 1; j++)
44170 {
44171 if (Main.tile[i, j] == null)
44172 {
44173 Main.tile[i, j] = new Tile();
44174 }
44175 if (Main.tile[i, j].active() && Main.tile[i, j].type != 3 && Main.tile[i, j].type != 73 && Main.tile[i, j].type != 113 && Main.tile[i, j].type != 110 && (Main.tile[i, j].type != 185 || Main.tile[i, j].frameY != 0))
44176 {
44177 flag = false;
44178 }
44179 if (Main.tile[i, j].liquid > 0)
44180 {
44181 flag = false;
44182 }
44183 }
44184 if (!SolidTile(i, superY + 1) || (Main.tile[i, superY + 1].type != 2 && Main.tile[i, superY + 1].type != 109))
44185 {
44186 flag = false;
44187 }
44188 }
44189 if (flag)
44190 {
44191 Main.tile[x - 1, superY - 1].active(active: true);
44192 Main.tile[x - 1, superY - 1].frameY = (short)num;
44193 Main.tile[x - 1, superY - 1].frameX = 0;
44194 Main.tile[x - 1, superY - 1].type = type;
44195 Main.tile[x, superY - 1].active(active: true);
44196 Main.tile[x, superY - 1].frameY = (short)num;
44197 Main.tile[x, superY - 1].frameX = 18;
44198 Main.tile[x, superY - 1].type = type;
44199 Main.tile[x - 1, superY].active(active: true);
44200 Main.tile[x - 1, superY].frameY = (short)(num + 18);
44201 Main.tile[x - 1, superY].frameX = 0;
44202 Main.tile[x - 1, superY].type = type;
44203 Main.tile[x, superY].active(active: true);
44204 Main.tile[x, superY].frameY = (short)(num + 18);
44205 Main.tile[x, superY].frameX = 18;
44206 Main.tile[x, superY].type = type;
44207 }
44208 }
44209
44210 public static void GrowPumpkin(int i, int j, int type)
44211 {
44212 if (destroyObject)
44213 {
44214 return;
44215 }
44216 bool flag = false;
44217 int num = j;
44218 int num2;
44219 for (num2 = Main.tile[i, j].frameY / 18; num2 > 1; num2 -= 2)
44220 {
44221 }
44222 num -= num2;
44223 int num3 = Main.tile[i, j].frameX / 18;
44224 int num4 = 0;
44225 while (num3 > 1)
44226 {
44227 num3 -= 2;
44228 num4++;
44229 }
44230 num3 = i - num3;
44231 int num5 = num4 * 36;
44232 if (num4 >= 4)
44233 {
44234 return;
44235 }
44236 for (int k = num3; k < num3 + 2; k++)
44237 {
44238 for (int l = num; l < num + 2; l++)
44239 {
44240 if (Main.tile[k, l] == null)
44241 {
44242 Main.tile[k, l] = new Tile();
44243 }
44244 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num3) * 18 + num5)
44245 {
44246 flag = true;
44247 }
44248 }
44249 if (!SolidTile(k, num + 2) || (Main.tile[k, num + 2].type != 2 && Main.tile[k, num + 2].type != 477 && Main.tile[k, num + 2].type != 492 && Main.tile[k, num + 2].type != 109))
44250 {
44251 flag = true;
44252 }
44253 }
44254 if (!flag)
44255 {
44256 for (int m = num3; m < num3 + 2; m++)
44257 {
44258 for (int n = num; n < num + 2; n++)
44259 {
44260 if (Main.tile[m, n] == null)
44261 {
44262 Main.tile[m, n] = new Tile();
44263 }
44264 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
44265 {
44266 Main.tile[m, n].frameX += 36;
44267 }
44268 }
44269 }
44270 }
44271 if (Main.netMode == 2)
44272 {
44273 NetMessage.SendTileSquare(-1, num3, num, 2, 2);
44274 }
44275 }
44276
44277 public static void FixHearts()
44278 {
44279 for (int i = 0; i < Main.maxTilesX; i++)
44280 {
44281 for (int j = 0; j < Main.maxTilesY; j++)
44282 {
44283 Tile tile = Main.tile[i, j];
44284 if (tile.active() && tile.type == 12 && tile.frameX == 0 && tile.frameY == 0)
44285 {
44286 FixHeart(i, j);
44287 }
44288 }
44289 }
44290 }
44291
44292 public static void DestroyHeart(int i, int j)
44293 {
44294 destroyObject = true;
44295 for (int k = i; k < i + 2; k++)
44296 {
44297 for (int l = j; l < j + 2; l++)
44298 {
44299 if (k < Main.maxTilesX && l < Main.maxTilesY)
44300 {
44301 Tile tile = Main.tile[k, l];
44302 if (tile.active() && tile.type == 12)
44303 {
44304 KillTile(k, l);
44305 }
44306 }
44307 }
44308 }
44309 destroyObject = false;
44310 }
44311
44312 public static void FixHeart(int i, int j)
44313 {
44315 {
44316 DestroyHeart(i, j);
44317 return;
44318 }
44319 Tile tile = Main.tile[i, j + 2];
44320 Tile tile2 = Main.tile[i + 1, j + 2];
44321 if (tile.active() && !Main.tileSolid[tile.type] && Main.tileCut[tile.type])
44322 {
44323 KillTile(i, j + 2);
44324 }
44325 if (tile2.active() && !Main.tileSolid[tile2.type] && Main.tileCut[tile2.type])
44326 {
44327 KillTile(i + 1, j + 2);
44328 }
44329 if (!tile.active())
44330 {
44331 if (!tile2.active())
44332 {
44333 DestroyHeart(i, j);
44334 return;
44335 }
44336 if (Main.tileSolid[tile2.type])
44337 {
44338 tile.type = tile2.type;
44339 tile.active(active: true);
44340 }
44341 }
44342 if (!tile2.active() && Main.tileSolid[tile.type])
44343 {
44344 tile2.type = tile.type;
44345 tile2.active(active: true);
44346 }
44347 if (!tile.nactive() || !Main.tileSolid[tile.type] || !tile2.nactive() || !Main.tileSolid[tile2.type])
44348 {
44349 DestroyHeart(i, j);
44350 return;
44351 }
44352 if (tile.blockType() != 0)
44353 {
44354 tile.slope(0);
44355 tile.halfBrick(halfBrick: false);
44356 }
44357 if (tile2.blockType() != 0)
44358 {
44359 tile2.slope(0);
44360 tile2.halfBrick(halfBrick: false);
44361 }
44362 }
44363
44364 public static void FixChands()
44365 {
44366 for (int i = 5; i < Main.maxTilesX - 5; i++)
44367 {
44368 for (int j = 5; j < Main.maxTilesY - 5; j++)
44369 {
44370 if (Main.tile[i, j].active())
44371 {
44372 int type = Main.tile[i, j].type;
44373 if (Main.tile[i, j].active() && (type == 35 || type == 36 || type == 170 || type == 171 || type == 172))
44374 {
44375 FixChand(i, j);
44376 }
44377 }
44378 }
44379 }
44380 }
44381
44382 public static void FixChand(int i, int j)
44383 {
44384 int num = 0;
44385 int type = Main.tile[i, j].type;
44386 if (Main.tile[i, j].active())
44387 {
44388 if (type == 35)
44389 {
44390 num = 1;
44391 }
44392 if (type == 36)
44393 {
44394 num = 2;
44395 }
44396 if (type == 170)
44397 {
44398 num = 3;
44399 }
44400 if (type == 171)
44401 {
44402 num = 4;
44403 }
44404 if (type == 172)
44405 {
44406 num = 5;
44407 }
44408 }
44409 if (num <= 0)
44410 {
44411 return;
44412 }
44413 int num2 = i;
44414 int num3 = j;
44415 for (num2 = Main.tile[i, j].frameX / 18; num2 >= 3; num2 -= 3)
44416 {
44417 }
44418 if (num2 >= 3)
44419 {
44420 num2 -= 3;
44421 }
44422 num2 = i - num2;
44423 num3 += Main.tile[i, j].frameY / 18 * -1;
44424 for (int k = num2; k < num2 + 3; k++)
44425 {
44426 for (int l = num3; l < num3 + 3; l++)
44427 {
44428 if (Main.tile[k, l] == null)
44429 {
44430 Main.tile[k, l] = new Tile();
44431 }
44432 if (Main.tile[k, l].active() && Main.tile[k, l].type == type)
44433 {
44434 Main.tile[k, l].type = 34;
44435 Main.tile[k, l].frameY = (short)(Main.tile[k, l].frameY + num * 54);
44436 }
44437 }
44438 }
44439 }
44440
44441 public static void PlaceChand(int x, int y, ushort type, int style = 0)
44442 {
44443 bool flag = true;
44444 int num = 0;
44445 for (int i = x - 1; i < x + 2; i++)
44446 {
44447 for (int j = y; j < y + 3; j++)
44448 {
44449 if (Main.tile[i, j] == null)
44450 {
44451 Main.tile[i, j] = new Tile();
44452 }
44453 if (Main.tile[i, j].active())
44454 {
44455 flag = false;
44456 }
44457 }
44458 }
44459 if (Main.tile[x, y - 1] == null)
44460 {
44461 Main.tile[x, y - 1] = new Tile();
44462 }
44463 if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[Main.tile[x, y - 1].type] || Main.tileSolidTop[Main.tile[x, y - 1].type])
44464 {
44465 flag = false;
44466 }
44467 if (flag)
44468 {
44469 int num2 = style / 36 * 18 * 6;
44470 int num3 = style * 18 * 3;
44471 Main.tile[x - 1, y + num].active(active: true);
44472 Main.tile[x - 1, y + num].frameY = (short)num3;
44473 Main.tile[x - 1, y + num].frameX = (short)num2;
44474 Main.tile[x - 1, y + num].type = type;
44475 Main.tile[x, y + num].active(active: true);
44476 Main.tile[x, y + num].frameY = (short)num3;
44477 Main.tile[x, y + num].frameX = (short)(num2 + 18);
44478 Main.tile[x, y + num].type = type;
44479 Main.tile[x + 1, y + num].active(active: true);
44480 Main.tile[x + 1, y + num].frameY = (short)num3;
44481 Main.tile[x + 1, y + num].frameX = (short)(num2 + 36);
44482 Main.tile[x + 1, y + num].type = type;
44483 Main.tile[x - 1, y + 1 + num].active(active: true);
44484 Main.tile[x - 1, y + 1 + num].frameY = (short)(num3 + 18);
44485 Main.tile[x - 1, y + 1 + num].frameX = (short)num2;
44486 Main.tile[x - 1, y + 1 + num].type = type;
44487 Main.tile[x, y + 1 + num].active(active: true);
44488 Main.tile[x, y + 1 + num].frameY = (short)(num3 + 18);
44489 Main.tile[x, y + 1 + num].frameX = (short)(num2 + 18);
44490 Main.tile[x, y + 1 + num].type = type;
44491 Main.tile[x + 1, y + 1 + num].active(active: true);
44492 Main.tile[x + 1, y + 1 + num].frameY = (short)(num3 + 18);
44493 Main.tile[x + 1, y + 1 + num].frameX = (short)(num2 + 36);
44494 Main.tile[x + 1, y + 1 + num].type = type;
44495 Main.tile[x - 1, y + 2 + num].active(active: true);
44496 Main.tile[x - 1, y + 2 + num].frameY = (short)(num3 + 36);
44497 Main.tile[x - 1, y + 2 + num].frameX = (short)num2;
44498 Main.tile[x - 1, y + 2 + num].type = type;
44499 Main.tile[x, y + 2 + num].active(active: true);
44500 Main.tile[x, y + 2 + num].frameY = (short)(num3 + 36);
44501 Main.tile[x, y + 2 + num].frameX = (short)(num2 + 18);
44502 Main.tile[x, y + 2 + num].type = type;
44503 Main.tile[x + 1, y + 2 + num].active(active: true);
44504 Main.tile[x + 1, y + 2 + num].frameY = (short)(num3 + 36);
44505 Main.tile[x + 1, y + 2 + num].frameX = (short)(num2 + 36);
44506 Main.tile[x + 1, y + 2 + num].type = type;
44507 }
44508 }
44509
44510 public static void CheckChand(int i, int j, int type)
44511 {
44512 if (destroyObject)
44513 {
44514 return;
44515 }
44516 bool flag = false;
44517 int num = i;
44518 int num2 = j;
44519 int num3 = 3;
44520 if (type == 454)
44521 {
44522 num3 = 4;
44523 }
44524 num = Main.tile[i, j].frameX / 18;
44525 int num4 = 0;
44526 while (num >= num3)
44527 {
44528 num4++;
44529 num -= num3;
44530 }
44531 int num5 = i - num;
44532 int num6 = 18 * num3 * num4;
44533 if (num >= num3)
44534 {
44535 num -= num3;
44536 }
44537 num = i - num;
44538 num2 = Main.tile[i, j].frameY / 18;
44539 int num7 = 0;
44540 while (num2 >= 3)
44541 {
44542 num7++;
44543 num2 -= 3;
44544 }
44545 if (num6 >= 108)
44546 {
44547 num7 += 37 * (num6 / 108);
44548 }
44549 int num8 = 54 * num7;
44550 if (num6 >= 108)
44551 {
44552 num8 -= 54 * (num6 / 108) * 37;
44553 }
44554 if (num2 >= 3)
44555 {
44556 num2 -= 3;
44557 }
44558 num2 = j - num2;
44559 for (int k = num; k < num + num3; k++)
44560 {
44561 for (int l = num2; l < num2 + 3; l++)
44562 {
44563 if (Main.tile[k, l] == null)
44564 {
44565 Main.tile[k, l] = new Tile();
44566 }
44567 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num5) * 18 + num6 || Main.tile[k, l].frameY != (l - num2) * 18 + num8)
44568 {
44569 flag = true;
44570 }
44571 }
44572 }
44573 if (Main.tile[num + 1, num2 - 1] == null)
44574 {
44575 Main.tile[num + 1, num2 - 1] = new Tile();
44576 }
44577 if (!Main.tile[num + 1, num2 - 1].nactive() || !Main.tileSolid[Main.tile[num + 1, num2 - 1].type] || Main.tileSolidTop[Main.tile[num + 1, num2 - 1].type])
44578 {
44579 flag = true;
44580 }
44581 if (!flag)
44582 {
44583 return;
44584 }
44585 destroyObject = true;
44586 for (int m = num; m < num + num3; m++)
44587 {
44588 for (int n = num2; n < num2 + 3; n++)
44589 {
44590 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
44591 {
44592 KillTile(m, n);
44593 }
44594 }
44595 }
44596 if (type == 454)
44597 {
44598 switch (Main.rand.Next(9))
44599 {
44600 case 2:
44601 case 3:
44602 case 4:
44603 {
44604 int num13 = Main.rand.Next(10, 31);
44605 while (num13 > 0)
44606 {
44607 int num14 = Main.rand.Next(2, 11);
44608 if (num14 > num13)
44609 {
44610 num14 = num13;
44611 }
44612 num13 -= num14;
44613 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 72, num14);
44614 }
44615 break;
44616 }
44617 case 5:
44618 case 6:
44619 {
44620 int num17 = Main.rand.Next(60, 80);
44621 while (num17 > 0)
44622 {
44623 int num18 = Main.rand.Next(3, 16);
44624 if (num18 > num17)
44625 {
44626 num18 = num17;
44627 }
44628 num17 -= num18;
44629 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16 - 10, j * 16 - 10, 52, 52, 72, num18);
44630 }
44631 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1358);
44632 break;
44633 }
44634 case 7:
44635 {
44636 int num15 = Main.rand.Next(10, 31);
44637 while (num15 > 0)
44638 {
44639 int num16 = Main.rand.Next(2, 9);
44640 if (num16 > num15)
44641 {
44642 num16 = num15;
44643 }
44644 num15 -= num16;
44645 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16 - 10, j * 16 - 10, 52, 52, 72, num16);
44646 }
44647 if (Main.rand.Next(8) == 0)
44648 {
44649 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3532);
44650 }
44651 if (Main.rand.Next(8) == 0)
44652 {
44653 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3532);
44654 }
44655 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73);
44656 break;
44657 }
44658 case 8:
44659 {
44660 int num9 = 100;
44661 while (num9 > 0)
44662 {
44663 int num10 = Main.rand.Next(3, 16);
44664 if (num10 > num9)
44665 {
44666 num10 = num9;
44667 }
44668 num9 -= num10;
44669 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16 - 10, j * 16 - 10, 52, 52, 72, num10);
44670 }
44671 int num11 = Main.rand.Next(30, 91);
44672 while (num11 > 0)
44673 {
44674 int num12 = Main.rand.Next(7, 14);
44675 if (num12 > num11)
44676 {
44677 num12 = num11;
44678 }
44679 num11 -= num12;
44680 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16 - 10, j * 16 - 10, 52, 52, 1349, num12);
44681 }
44682 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1358);
44683 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 73);
44684 break;
44685 }
44686 }
44687 }
44688 if (type == 34)
44689 {
44690 int type2;
44691 switch (num7)
44692 {
44693 case 1:
44694 type2 = 107;
44695 break;
44696 case 2:
44697 type2 = 108;
44698 break;
44699 case 3:
44700 type2 = 710;
44701 break;
44702 case 4:
44703 type2 = 711;
44704 break;
44705 case 5:
44706 type2 = 712;
44707 break;
44708 case 6:
44709 type2 = 1812;
44710 break;
44711 case 7:
44712 case 8:
44713 case 9:
44714 case 10:
44715 case 11:
44716 case 12:
44717 case 13:
44718 case 14:
44719 case 15:
44720 case 16:
44721 case 17:
44722 type2 = 2055 + num7 - 7;
44723 break;
44724 default:
44725 type2 = ((num7 >= 18 && num7 <= 21) ? (2141 + num7 - 18) : (num7 switch
44726 {
44727 22 => 2224,
44728 23 => 2525,
44729 24 => 2543,
44730 25 => 2558,
44731 26 => 2573,
44732 27 => 2652,
44733 28 => 2653,
44734 29 => 2654,
44735 30 => 2655,
44736 31 => 2656,
44737 32 => 2657,
44738 33 => 2813,
44739 34 => 3177,
44740 35 => 3179,
44741 36 => 3178,
44742 37 => 3894,
44743 38 => 3938,
44744 39 => 3964,
44745 40 => 4152,
44746 41 => 4173,
44747 42 => 4194,
44748 43 => 4215,
44749 44 => 4305,
44750 45 => 4573,
44751 46 => 5155,
44752 47 => 5176,
44753 48 => 5197,
44754 _ => 106,
44755 }));
44756 break;
44757 }
44758 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, type2);
44759 }
44760 destroyObject = false;
44761 for (int num19 = num - 1; num19 < num + num3 + 1; num19++)
44762 {
44763 for (int num20 = num2 - 1; num20 < num2 + 4; num20++)
44764 {
44765 TileFrame(num19, num20);
44766 }
44767 }
44768 }
44769
44770 public static void Check3x3(int i, int j, int type)
44771 {
44772 if (destroyObject)
44773 {
44774 return;
44775 }
44776 bool flag = false;
44777 int num = i;
44778 int num2 = j;
44779 num = Main.tile[i, j].frameX / 18;
44780 int num3 = 0;
44781 while (num >= 3)
44782 {
44783 num3++;
44784 num -= 3;
44785 }
44786 int num4 = i - num;
44787 int num5 = 54 * num3;
44788 int num6 = Main.tile[i, j].frameY / 54;
44789 int num7 = Main.tile[i, j].frameY % 54 / 18;
44790 if (num >= 3)
44791 {
44792 num -= 3;
44793 }
44794 num = i - num;
44795 num2 -= num7;
44796 for (int k = num; k < num + 3; k++)
44797 {
44798 for (int l = num2; l < num2 + 3; l++)
44799 {
44800 if (Main.tile[k, l] == null)
44801 {
44802 Main.tile[k, l] = new Tile();
44803 }
44804 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num4) * 18 + num5 || Main.tile[k, l].frameY != (l - num2) * 18 + num6 * 54)
44805 {
44806 flag = true;
44807 }
44808 }
44809 }
44810 if (type == 106 || type == 212 || type == 219 || type == 220 || type == 228 || type == 231 || type == 243 || type == 247 || type == 283 || (type >= 300 && type <= 308) || type == 354 || type == 355 || type == 499 || type == 406 || type == 412 || type == 452 || type == 455 || type == 491 || type == 642)
44811 {
44812 for (int m = num; m < num + 3; m++)
44813 {
44814 if (Main.tile[m, num2 + 3] == null)
44815 {
44816 Main.tile[m, num2 + 3] = new Tile();
44817 }
44818 if (!SolidTileAllowBottomSlope(m, num2 + 3))
44819 {
44820 flag = true;
44821 break;
44822 }
44823 }
44824 }
44825 else
44826 {
44827 if (Main.tile[num + 1, num2 - 1] == null)
44828 {
44829 Main.tile[num + 1, num2 - 1] = new Tile();
44830 }
44831 if (!Main.tile[num + 1, num2 - 1].nactive() || !Main.tileSolid[Main.tile[num + 1, num2 - 1].type] || Main.tileSolidTop[Main.tile[num + 1, num2 - 1].type])
44832 {
44833 flag = true;
44834 }
44835 }
44836 if (!flag)
44837 {
44838 return;
44839 }
44840 destroyObject = true;
44841 for (int n = num; n < num + 3; n++)
44842 {
44843 for (int num8 = num2; num8 < num2 + 3; num8++)
44844 {
44845 if (Main.tile[n, num8].type == type && Main.tile[n, num8].active())
44846 {
44847 KillTile(n, num8);
44848 }
44849 }
44850 }
44851 switch (type)
44852 {
44853 case 106:
44854 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 363);
44855 break;
44856 case 243:
44857 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1430);
44858 break;
44859 case 212:
44860 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 951);
44861 break;
44862 case 219:
44863 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 997);
44864 break;
44865 case 642:
44866 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5296);
44867 break;
44868 case 220:
44869 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 998);
44870 break;
44871 case 228:
44872 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1120);
44873 break;
44874 case 247:
44875 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 1551);
44876 break;
44877 case 283:
44878 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2172);
44879 break;
44880 case 300:
44881 case 301:
44882 case 302:
44883 case 303:
44884 case 304:
44885 case 305:
44886 case 306:
44887 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2192 + type - 300);
44888 break;
44889 default:
44890 switch (type)
44891 {
44892 case 307:
44893 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2203);
44894 break;
44895 case 308:
44896 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2204);
44897 break;
44898 case 406:
44899 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3365);
44900 break;
44901 case 452:
44902 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3742);
44903 break;
44904 case 354:
44905 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 2999);
44906 break;
44907 case 355:
44908 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3000);
44909 break;
44910 case 499:
44911 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4142);
44912 break;
44913 case 412:
44914 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3549);
44915 break;
44916 case 455:
44917 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 3747);
44918 break;
44919 case 491:
44920 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4076);
44921 break;
44922 case 231:
44923 {
44924 int num9 = (i + 1) * 16 + 8;
44925 int num10 = j * 16;
44926 Gore.NewGore(new Vector2(num9, num10), default(Vector2), 300);
44927 Gore.NewGore(new Vector2(num9, num10 + 8), default(Vector2), 301);
44928 Gore.NewGore(new Vector2(num9, num10 + 16), default(Vector2), 302);
44929 float num11 = i * 16;
44930 float num12 = j * 16;
44931 float num13 = -1f;
44932 int plr = 0;
44933 for (int num14 = 0; num14 < 255; num14++)
44934 {
44935 if (Main.player[num14].active && !Main.player[num14].dead)
44936 {
44937 float num15 = Math.Abs(Main.player[num14].position.X - num11) + Math.Abs(Main.player[num14].position.Y - num12);
44938 if (num15 < num13 || num13 == -1f)
44939 {
44940 plr = num14;
44941 num13 = num15;
44942 }
44943 }
44944 }
44945 if (num13 < 4800f && !Main.gameMenu)
44946 {
44947 NPC.SpawnOnPlayer(plr, 222);
44948 }
44949 break;
44950 }
44951 }
44952 break;
44953 }
44954 destroyObject = false;
44955 for (int num16 = num - 1; num16 < num + 4; num16++)
44956 {
44957 for (int num17 = num2 - 1; num17 < num2 + 4; num17++)
44958 {
44959 TileFrame(num16, num17);
44960 }
44961 }
44962 }
44963
44964 public static void Check2x5(int i, int j, int type)
44965 {
44966 if (destroyObject)
44967 {
44968 return;
44969 }
44970 bool flag = false;
44971 int num = i;
44972 int num2 = j;
44973 num = Main.tile[i, j].frameX / 18;
44974 int num3 = 0;
44975 while (num >= 2)
44976 {
44977 num3++;
44978 num -= 2;
44979 }
44980 int num4 = i - num;
44981 int num5 = 36 * num3;
44982 int num6 = Main.tile[i, j].frameY % 80 / 18;
44983 if (num >= 3)
44984 {
44985 num -= 2;
44986 }
44987 num = i - num;
44988 num2 -= num6;
44989 for (int k = num; k < num + 2; k++)
44990 {
44991 for (int l = num2; l < num2 + 5; l++)
44992 {
44993 if (Main.tile[k, l] == null)
44994 {
44995 Main.tile[k, l] = new Tile();
44996 }
44997 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num4) * 18 + num5 || Main.tile[k, l].frameY != (l - num2) * 18)
44998 {
44999 flag = true;
45000 }
45001 }
45002 }
45003 for (int m = num; m < num + 2; m++)
45004 {
45005 if (Main.tile[m, num2 + 5] == null)
45006 {
45007 Main.tile[m, num2 + 5] = new Tile();
45008 }
45009 if (!SolidTileAllowBottomSlope(m, num2 + 5))
45010 {
45011 flag = true;
45012 break;
45013 }
45014 }
45015 if (!flag)
45016 {
45017 return;
45018 }
45019 destroyObject = true;
45020 for (int n = num; n < num + 2; n++)
45021 {
45022 for (int num7 = num2; num7 < num2 + 5; num7++)
45023 {
45024 if (Main.tile[n, num7].type == type && Main.tile[n, num7].active())
45025 {
45026 KillTile(n, num7);
45027 }
45028 }
45029 }
45030 switch (type)
45031 {
45032 case 547:
45033 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4430 + num3);
45034 break;
45035 case 623:
45036 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 5081 + num3);
45037 break;
45038 }
45039 destroyObject = false;
45040 for (int num8 = num - 1; num8 < num + 3; num8++)
45041 {
45042 for (int num9 = num2 - 1; num9 < num2 + 6; num9++)
45043 {
45044 TileFrame(num8, num9);
45045 }
45046 }
45047 }
45048
45049 public static void Check3x5(int i, int j, int type)
45050 {
45051 if (destroyObject)
45052 {
45053 return;
45054 }
45055 bool flag = false;
45056 int num = i;
45057 int num2 = j;
45058 num = Main.tile[i, j].frameX / 18;
45059 int num3 = 0;
45060 while (num >= 3)
45061 {
45062 num3++;
45063 num -= 3;
45064 }
45065 int num4 = i - num;
45066 int num5 = 54 * num3;
45067 int num6 = Main.tile[i, j].frameY % 90 / 18;
45068 if (num >= 4)
45069 {
45070 num -= 3;
45071 }
45072 num = i - num;
45073 num2 -= num6;
45074 for (int k = num; k < num + 3; k++)
45075 {
45076 for (int l = num2; l < num2 + 5; l++)
45077 {
45078 if (Main.tile[k, l] == null)
45079 {
45080 Main.tile[k, l] = new Tile();
45081 }
45082 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num4) * 18 + num5 || Main.tile[k, l].frameY != (l - num2) * 18)
45083 {
45084 flag = true;
45085 }
45086 }
45087 }
45088 for (int m = num; m < num + 3; m++)
45089 {
45090 if (Main.tile[m, num2 + 5] == null)
45091 {
45092 Main.tile[m, num2 + 5] = new Tile();
45093 }
45094 if (!SolidTileAllowBottomSlope(m, num2 + 5))
45095 {
45096 flag = true;
45097 break;
45098 }
45099 }
45100 if (!flag)
45101 {
45102 return;
45103 }
45104 destroyObject = true;
45105 for (int n = num; n < num + 3; n++)
45106 {
45107 for (int num7 = num2; num7 < num2 + 5; num7++)
45108 {
45109 if (Main.tile[n, num7].type == type && Main.tile[n, num7].active())
45110 {
45111 KillTile(n, num7);
45112 }
45113 }
45114 }
45115 if (type == 613)
45116 {
45117 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4904 + num3);
45118 }
45119 destroyObject = false;
45120 for (int num8 = num - 1; num8 < num + 4; num8++)
45121 {
45122 for (int num9 = num2 - 1; num9 < num2 + 6; num9++)
45123 {
45124 TileFrame(num8, num9);
45125 }
45126 }
45127 }
45128
45129 public static void Check3x6(int i, int j, int type)
45130 {
45131 if (destroyObject)
45132 {
45133 return;
45134 }
45135 bool flag = false;
45136 int num = i;
45137 int num2 = j;
45138 num = Main.tile[i, j].frameX / 18;
45139 int num3 = 0;
45140 while (num >= 3)
45141 {
45142 num3++;
45143 num -= 3;
45144 }
45145 int num4 = i - num;
45146 int num5 = 54 * num3;
45147 int num6 = Main.tile[i, j].frameY % 96 / 18;
45148 if (num >= 4)
45149 {
45150 num -= 3;
45151 }
45152 num = i - num;
45153 num2 -= num6;
45154 for (int k = num; k < num + 3; k++)
45155 {
45156 for (int l = num2; l < num2 + 6; l++)
45157 {
45158 if (Main.tile[k, l] == null)
45159 {
45160 Main.tile[k, l] = new Tile();
45161 }
45162 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || Main.tile[k, l].frameX != (k - num4) * 18 + num5 || Main.tile[k, l].frameY != (l - num2) * 18)
45163 {
45164 flag = true;
45165 }
45166 }
45167 }
45168 for (int m = num; m < num + 3; m++)
45169 {
45170 if (Main.tile[m, num2 + 6] == null)
45171 {
45172 Main.tile[m, num2 + 6] = new Tile();
45173 }
45174 if (!SolidTileAllowBottomSlope(m, num2 + 6))
45175 {
45176 flag = true;
45177 break;
45178 }
45179 }
45180 if (!flag)
45181 {
45182 return;
45183 }
45184 destroyObject = true;
45185 for (int n = num; n < num + 3; n++)
45186 {
45187 for (int num7 = num2; num7 < num2 + 6; num7++)
45188 {
45189 if (Main.tile[n, num7].type == type && Main.tile[n, num7].active())
45190 {
45191 KillTile(n, num7);
45192 }
45193 }
45194 }
45195 if (type == 548)
45196 {
45197 if (num3 >= 7)
45198 {
45199 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4902 + num3 - 7);
45200 }
45201 else
45202 {
45203 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4435 + num3);
45204 }
45205 }
45206 if (type == 614)
45207 {
45208 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 4906);
45209 }
45210 destroyObject = false;
45211 for (int num8 = num - 1; num8 < num + 4; num8++)
45212 {
45213 for (int num9 = num2 - 1; num9 < num2 + 7; num9++)
45214 {
45215 TileFrame(num8, num9);
45216 }
45217 }
45218 }
45219
45220 public static void Place3x3(int x, int y, ushort type, int style = 0)
45221 {
45222 bool flag = true;
45223 int num = 0;
45224 if (type == 106 || type == 212 || type == 219 || type == 220 || type == 228 || type == 231 || type == 243 || type == 247 || type == 283 || (type >= 300 && type <= 308) || type == 354 || type == 355 || type == 642)
45225 {
45226 num = -2;
45227 for (int i = x - 1; i < x + 2; i++)
45228 {
45229 for (int j = y - 2; j < y + 1; j++)
45230 {
45231 if (Main.tile[i, j] == null)
45232 {
45233 Main.tile[i, j] = new Tile();
45234 }
45235 if (Main.tile[i, j].active())
45236 {
45237 flag = false;
45238 }
45239 }
45240 }
45241 for (int k = x - 1; k < x + 2; k++)
45242 {
45243 if (Main.tile[k, y + 1] == null)
45244 {
45245 Main.tile[k, y + 1] = new Tile();
45246 }
45247 if (!SolidTile2(k, y + 1))
45248 {
45249 flag = false;
45250 break;
45251 }
45252 }
45253 }
45254 else
45255 {
45256 for (int l = x - 1; l < x + 2; l++)
45257 {
45258 for (int m = y; m < y + 3; m++)
45259 {
45260 if (Main.tile[l, m] == null)
45261 {
45262 Main.tile[l, m] = new Tile();
45263 }
45264 if (Main.tile[l, m].active())
45265 {
45266 flag = false;
45267 }
45268 }
45269 }
45270 if (Main.tile[x, y - 1] == null)
45271 {
45272 Main.tile[x, y - 1] = new Tile();
45273 }
45274 if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[Main.tile[x, y - 1].type] || Main.tileSolidTop[Main.tile[x, y - 1].type])
45275 {
45276 flag = false;
45277 }
45278 }
45279 if (flag)
45280 {
45281 int num2 = style * 18 * 3;
45282 Main.tile[x - 1, y + num].active(active: true);
45283 Main.tile[x - 1, y + num].frameY = 0;
45284 Main.tile[x - 1, y + num].frameX = (short)num2;
45285 Main.tile[x - 1, y + num].type = type;
45286 Main.tile[x, y + num].active(active: true);
45287 Main.tile[x, y + num].frameY = 0;
45288 Main.tile[x, y + num].frameX = (short)(num2 + 18);
45289 Main.tile[x, y + num].type = type;
45290 Main.tile[x + 1, y + num].active(active: true);
45291 Main.tile[x + 1, y + num].frameY = 0;
45292 Main.tile[x + 1, y + num].frameX = (short)(num2 + 36);
45293 Main.tile[x + 1, y + num].type = type;
45294 Main.tile[x - 1, y + 1 + num].active(active: true);
45295 Main.tile[x - 1, y + 1 + num].frameY = 18;
45296 Main.tile[x - 1, y + 1 + num].frameX = (short)num2;
45297 Main.tile[x - 1, y + 1 + num].type = type;
45298 Main.tile[x, y + 1 + num].active(active: true);
45299 Main.tile[x, y + 1 + num].frameY = 18;
45300 Main.tile[x, y + 1 + num].frameX = (short)(num2 + 18);
45301 Main.tile[x, y + 1 + num].type = type;
45302 Main.tile[x + 1, y + 1 + num].active(active: true);
45303 Main.tile[x + 1, y + 1 + num].frameY = 18;
45304 Main.tile[x + 1, y + 1 + num].frameX = (short)(num2 + 36);
45305 Main.tile[x + 1, y + 1 + num].type = type;
45306 Main.tile[x - 1, y + 2 + num].active(active: true);
45307 Main.tile[x - 1, y + 2 + num].frameY = 36;
45308 Main.tile[x - 1, y + 2 + num].frameX = (short)num2;
45309 Main.tile[x - 1, y + 2 + num].type = type;
45310 Main.tile[x, y + 2 + num].active(active: true);
45311 Main.tile[x, y + 2 + num].frameY = 36;
45312 Main.tile[x, y + 2 + num].frameX = (short)(num2 + 18);
45313 Main.tile[x, y + 2 + num].type = type;
45314 Main.tile[x + 1, y + 2 + num].active(active: true);
45315 Main.tile[x + 1, y + 2 + num].frameY = 36;
45316 Main.tile[x + 1, y + 2 + num].frameX = (short)(num2 + 36);
45317 Main.tile[x + 1, y + 2 + num].type = type;
45318 }
45319 }
45320
45321 public static void PlaceSunflower(int x, int y, ushort type = 27)
45322 {
45323 if ((double)y > Main.worldSurface - 1.0 && !Main.remixWorld)
45324 {
45325 return;
45326 }
45327 bool flag = true;
45328 for (int i = x; i < x + 2; i++)
45329 {
45330 for (int j = y - 3; j < y + 1; j++)
45331 {
45332 if (Main.tile[i, j] == null)
45333 {
45334 Main.tile[i, j] = new Tile();
45335 }
45336 if (Main.tile[i, j].active() || Main.tile[i, j].wall > 0)
45337 {
45338 flag = false;
45339 }
45340 }
45341 if (Main.tile[i, y + 1] == null)
45342 {
45343 Main.tile[i, y + 1] = new Tile();
45344 }
45345 if (!Main.tile[i, y + 1].nactive() || Main.tile[i, y + 1].halfBrick() || Main.tile[i, y + 1].slope() != 0 || (Main.tile[i, y + 1].type != 2 && Main.tile[i, y + 1].type != 109))
45346 {
45347 flag = false;
45348 }
45349 }
45350 if (!flag)
45351 {
45352 return;
45353 }
45354 int num = genRand.Next(3);
45355 for (int k = 0; k < 2; k++)
45356 {
45357 for (int l = -3; l < 1; l++)
45358 {
45359 int num2 = k * 18 + genRand.Next(3) * 36;
45360 if (l <= -2)
45361 {
45362 num2 = k * 18 + num * 36;
45363 }
45364 int num3 = (l + 3) * 18;
45365 Main.tile[x + k, y + l].active(active: true);
45366 Main.tile[x + k, y + l].frameX = (short)num2;
45367 Main.tile[x + k, y + l].frameY = (short)num3;
45368 Main.tile[x + k, y + l].type = type;
45369 }
45370 }
45371 }
45372
45373 public static void FixSunflowers()
45374 {
45375 for (int i = 5; i < Main.maxTilesX - 5; i++)
45376 {
45377 for (int j = 5; (double)j < Main.worldSurface; j++)
45378 {
45379 if (Main.tile[i, j].active() && Main.tile[i, j].type == 27)
45380 {
45381 FixSunflower(i, j);
45382 }
45383 }
45384 }
45385 }
45386
45387 public static void FixSunflower(int i, int j)
45388 {
45389 if (Main.tile[i, j].type != 27)
45390 {
45391 return;
45392 }
45393 int num = 0;
45394 int num2 = j;
45395 num += Main.tile[i, j].frameX / 18;
45396 num2 += Main.tile[i, j].frameY / 18 * -1;
45397 while (num > 1)
45398 {
45399 num -= 2;
45400 }
45401 num *= -1;
45402 num += i;
45403 int num3 = genRand.Next(3) * 36;
45404 int num4 = 0;
45405 for (int k = num; k < num + 2; k++)
45406 {
45407 for (int l = num2; l < num2 + 4; l++)
45408 {
45409 Main.tile[k, l].frameX = (short)(num4 + num3);
45410 }
45411 num4 += 18;
45412 }
45413 }
45414
45415 public static void CheckSunflower(int i, int j, int type = 27)
45416 {
45417 if (destroyObject)
45418 {
45419 return;
45420 }
45421 bool flag = false;
45422 int num = 0;
45423 int num2 = j;
45424 num += Main.tile[i, j].frameX / 18;
45425 num2 += Main.tile[i, j].frameY / 18 * -1;
45426 while (num > 1)
45427 {
45428 num -= 2;
45429 }
45430 num *= -1;
45431 num += i;
45432 for (int k = num; k < num + 2; k++)
45433 {
45434 for (int l = num2; l < num2 + 4; l++)
45435 {
45436 if (Main.tile[k, l] == null)
45437 {
45438 Main.tile[k, l] = new Tile();
45439 }
45440 int num3;
45441 for (num3 = Main.tile[k, l].frameX / 18; num3 > 1; num3 -= 2)
45442 {
45443 }
45444 if (!Main.tile[k, l].nactive() || Main.tile[k, l].type != type || num3 != k - num || Main.tile[k, l].frameY != (l - num2) * 18)
45445 {
45446 flag = true;
45447 }
45448 }
45449 if (Main.tile[k, num2 + 4] == null)
45450 {
45451 Main.tile[k, num2 + 4] = new Tile();
45452 }
45453 if (!Main.tile[k, num2 + 4].nactive() || (Main.tile[k, num2 + 4].type != 2 && Main.tile[k, num2 + 4].type != 477 && Main.tile[k, num2 + 4].type != 492 && Main.tile[k, num2 + 4].type != 109 && Main.tile[k, num2 + 4].type != 60 && Main.tile[k, num2 + 4].type != 633))
45454 {
45455 flag = true;
45456 }
45457 if (!SolidTile(k, num2 + 4))
45458 {
45459 flag = true;
45460 }
45461 }
45462 if (!flag)
45463 {
45464 return;
45465 }
45466 destroyObject = true;
45467 for (int m = num; m < num + 2; m++)
45468 {
45469 for (int n = num2; n < num2 + 4; n++)
45470 {
45471 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
45472 {
45473 KillTile(m, n);
45474 }
45475 }
45476 }
45477 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, 63);
45478 destroyObject = false;
45479 }
45480
45481 public static void CheckDye(int x, int y)
45482 {
45483 switch (Main.tile[x, y].frameX / 34)
45484 {
45485 case 7:
45486 if (!SolidTile(x, y - 1))
45487 {
45488 KillTile(x, y);
45489 }
45490 break;
45491 case 6:
45492 if (!Main.tile[x, y + 1].nactive() || Main.tile[x, y + 1].type != 80)
45493 {
45494 KillTile(x, y);
45495 }
45496 break;
45497 default:
45498 if (!SolidTile(x, y + 1))
45499 {
45500 KillTile(x, y);
45501 }
45502 break;
45503 }
45504 }
45505
45506 public static void CheckRockGolemHead(int x, int y)
45507 {
45508 if (!SolidTileAllowBottomSlope(x, y + 1))
45509 {
45510 KillTile(x, y);
45511 }
45512 }
45513
45514 public static void CheckStinkbugBlocker(int x, int y)
45515 {
45517 int num = tileSafely.frameX / 18;
45518 int style = -1;
45519 if (AttemptReorientingStinkbugBlocker(x, y, tileSafely.wall, ref style))
45520 {
45521 if (style != num)
45522 {
45523 tileSafely.frameX = (short)(style * 18);
45524 }
45525 }
45526 else
45527 {
45528 KillTile(x, y);
45529 }
45530 }
45531
45532 public static bool AttemptReorientingStinkbugBlocker(int x, int y, int wall, ref int style)
45533 {
45534 style = -1;
45535 if (style == -1 && SolidTileAllowBottomSlope(x, y + 1))
45536 {
45537 style = 0;
45538 }
45539 if (style == -1 && SolidTileAllowBottomSlope(x, y - 1))
45540 {
45541 style = 1;
45542 }
45543 if (style == -1 && SolidTileAllowBottomSlope(x + 1, y))
45544 {
45545 style = 2;
45546 }
45547 if (style == -1 && SolidTileAllowBottomSlope(x - 1, y))
45548 {
45549 style = 3;
45550 }
45551 if (style == -1 && wall > 0)
45552 {
45553 style = 4;
45554 }
45555 return style > -1;
45556 }
45557
45558 public static void CheckGnome(int x, int j)
45559 {
45560 if (destroyObject)
45561 {
45562 return;
45563 }
45564 int num = 567;
45565 int num2 = j;
45566 bool flag = true;
45569 if (tileSafely.frameY > 0)
45570 {
45571 num2--;
45574 }
45575 _ = tileSafely.frameX / 28;
45576 if (tileSafely.frameY == 0 && tileSafely2.frameY == 20 && tileSafely.type == num && tileSafely2.type == num)
45577 {
45578 flag = false;
45579 }
45580 if (Main.tile[x, num2 + 2] == null)
45581 {
45582 Main.tile[x, num2 + 2] = new Tile();
45583 }
45584 if (!SolidTileAllowBottomSlope(x, num2 + 2) && !TileID.Sets.Platforms[Main.tile[x, num2 + 2].type])
45585 {
45586 flag = true;
45587 }
45588 if (flag)
45589 {
45590 destroyObject = true;
45591 if (tileSafely.type == num)
45592 {
45593 KillTile(x, num2);
45594 }
45595 if (tileSafely2.type == num)
45596 {
45597 KillTile(x, num2 + 1);
45598 }
45599 Item.NewItem(GetItemSource_FromTileBreak(x, num2), x * 16, num2 * 16, 16, 32, 4609);
45600 destroyObject = false;
45601 }
45602 }
45603
45604 public static void PlaceGnome(int x, int y, int style)
45605 {
45606 PlaceObject(x, y, 567, mute: false, style);
45607 }
45608
45609 public static void PlaceDye(int x, int y, int style)
45610 {
45611 bool flag = false;
45612 if (Main.tile[x, y + 1] == null || Main.tile[x, y - 1] == null)
45613 {
45614 return;
45615 }
45616 if (style == 7)
45617 {
45618 if (Main.tile[x, y + 1].active() && Main.tile[x, y + 1].type != 3 && Main.tile[x, y + 1].type != 51 && Main.tile[x, y + 1].type != 61 && Main.tile[x, y + 1].type != 73 && Main.tile[x, y + 1].type != 74 && Main.tile[x, y + 1].type != 184)
45619 {
45620 return;
45621 }
45622 if (SolidTile(x, y - 1) && !Main.tile[x, y + 1].active())
45623 {
45624 flag = true;
45625 }
45626 }
45627 else
45628 {
45629 if (Main.tile[x, y - 1].active() && Main.tile[x, y - 1].type != 3 && Main.tile[x, y - 1].type != 51 && Main.tile[x, y - 1].type != 61 && Main.tile[x, y - 1].type != 73 && Main.tile[x, y - 1].type != 74 && Main.tile[x, y - 1].type != 184)
45630 {
45631 return;
45632 }
45633 if (style == 6)
45634 {
45635 if (Main.tile[x, y + 1].nactive() && Main.tile[x, y + 1].type == 80 && !Main.tile[x - 1, y + 1].active() && !Main.tile[x + 1, y + 1].active())
45636 {
45637 flag = true;
45638 }
45639 }
45640 else if (SolidTile(x, y + 1) && !Main.tile[x, y - 1].active())
45641 {
45642 switch (style)
45643 {
45644 case 5:
45645 if (Main.tile[x, y].liquid == byte.MaxValue && !Main.tile[x, y].lava() && !Main.tile[x, y].honey() && !Main.tile[x, y].shimmer())
45646 {
45647 flag = true;
45648 }
45649 break;
45650 case 8:
45651 case 9:
45652 case 10:
45653 case 11:
45654 flag = true;
45655 break;
45656 default:
45657 if (Main.tile[x, y].liquid != 0)
45658 {
45659 break;
45660 }
45661 if (style == 3 || style == 4)
45662 {
45663 if (Main.tile[x, y].wall == 0)
45664 {
45665 flag = true;
45666 }
45667 }
45668 else
45669 {
45670 flag = true;
45671 }
45672 break;
45673 }
45674 }
45675 }
45676 if (flag)
45677 {
45678 Main.tile[x, y].type = 227;
45679 Main.tile[x, y].active(active: true);
45680 Main.tile[x, y].halfBrick(halfBrick: false);
45681 Main.tile[x, y].slope(0);
45682 Main.tile[x, y].frameY = 0;
45683 Main.tile[x, y].frameX = (short)(34 * style);
45684 }
45685 }
45686
45687 public static bool PlacePot(int x, int y, ushort type = 28, int style = 0)
45688 {
45689 bool flag = true;
45690 if (remixWorldGen && (double)x > (double)Main.maxTilesX * 0.48 && (double)x < (double)Main.maxTilesX * 0.52 && y > Main.maxTilesY - 220)
45691 {
45692 flag = false;
45693 }
45694 for (int i = x; i < x + 2; i++)
45695 {
45696 for (int j = y - 1; j < y + 1; j++)
45697 {
45698 if (Main.tile[i, j] == null)
45699 {
45700 Main.tile[i, j] = new Tile();
45701 }
45702 if (Main.tile[i, j].active())
45703 {
45704 flag = false;
45705 }
45706 }
45707 if (Main.tile[i, y + 1] == null)
45708 {
45709 Main.tile[i, y + 1] = new Tile();
45710 }
45711 if (!Main.tile[i, y + 1].nactive() || Main.tile[i, y + 1].halfBrick() || Main.tile[i, y + 1].slope() != 0 || !Main.tileSolid[Main.tile[i, y + 1].type])
45712 {
45713 flag = false;
45714 }
45715 }
45716 if (flag)
45717 {
45718 int num = genRand.Next(3) * 36;
45719 for (int k = 0; k < 2; k++)
45720 {
45721 for (int l = -1; l < 1; l++)
45722 {
45723 int num2 = k * 18 + num;
45724 int num3 = (l + 1) * 18;
45725 Main.tile[x + k, y + l].active(active: true);
45726 Main.tile[x + k, y + l].frameX = (short)num2;
45727 Main.tile[x + k, y + l].frameY = (short)(num3 + style * 36);
45728 Main.tile[x + k, y + l].type = type;
45729 Main.tile[x + k, y + l].halfBrick(halfBrick: false);
45730 }
45731 }
45732 return true;
45733 }
45734 return false;
45735 }
45736
45737 public static bool CheckCactus(int i, int j)
45738 {
45739 int num = j;
45740 int num2 = i;
45741 while (Main.tile[num2, num] != null && Main.tile[num2, num].active() && Main.tile[num2, num].type == 80)
45742 {
45743 num++;
45744 if (Main.tile[num2, num] == null)
45745 {
45746 return false;
45747 }
45748 if (!Main.tile[num2, num].active() || Main.tile[num2, num].type != 80)
45749 {
45750 if (Main.tile[num2 - 1, num] != null && Main.tile[num2 - 1, num].active() && Main.tile[num2 - 1, num].type == 80 && Main.tile[num2 - 1, num - 1] != null && Main.tile[num2 - 1, num - 1].active() && Main.tile[num2 - 1, num - 1].type == 80 && num2 >= i)
45751 {
45752 num2--;
45753 }
45754 if (Main.tile[num2 + 1, num] != null && Main.tile[num2 + 1, num].active() && Main.tile[num2 + 1, num].type == 80 && Main.tile[num2 + 1, num - 1] != null && Main.tile[num2 + 1, num - 1].active() && Main.tile[num2 + 1, num - 1].type == 80 && num2 <= i)
45755 {
45756 num2++;
45757 }
45758 }
45759 }
45760 if (!Main.tile[num2, num].nactive() || Main.tile[num2, num].halfBrick() || Main.tile[num2, num].slope() != 0 || (Main.tile[num2, num].type != 53 && Main.tile[num2, num].type != 112 && Main.tile[num2, num].type != 116 && Main.tile[num2, num].type != 234))
45761 {
45762 KillTile(i, j);
45763 return true;
45764 }
45765 if (i != num2)
45766 {
45767 if ((!Main.tile[i, j + 1].active() || Main.tile[i, j + 1].type != 80) && (!Main.tile[i - 1, j].active() || Main.tile[i - 1, j].type != 80) && (!Main.tile[i + 1, j].active() || Main.tile[i + 1, j].type != 80))
45768 {
45769 KillTile(i, j);
45770 return true;
45771 }
45772 }
45773 else if (i == num2 && (!Main.tile[i, j + 1].active() || (Main.tile[i, j + 1].type != 80 && Main.tile[i, j + 1].type != 53 && Main.tile[i, j + 1].type != 112 && Main.tile[i, j + 1].type != 116 && Main.tile[i, j + 1].type != 234)))
45774 {
45775 KillTile(i, j);
45776 return true;
45777 }
45778 return false;
45779 }
45780
45781 public static void PlantCactus(int i, int j)
45782 {
45783 GrowCactus(i, j);
45784 for (int k = 0; k < 150; k++)
45785 {
45786 int i2 = genRand.Next(i - 1, i + 2);
45787 int j2 = genRand.Next(j - 10, j + 2);
45788 GrowCactus(i2, j2);
45789 }
45790 }
45791
45792 public static void CheckOrb(int i, int j, int type)
45793 {
45794 if (Main.tile[i, j] == null)
45795 {
45796 return;
45797 }
45798 short frameX = Main.tile[i, j].frameX;
45799 bool flag = false;
45800 if (frameX >= 36)
45801 {
45802 flag = true;
45803 }
45804 if (destroyObject)
45805 {
45806 return;
45807 }
45808 int num = i;
45809 int num2 = j;
45810 num = ((Main.tile[i, j].frameX != 0 && Main.tile[i, j].frameX != 36) ? (i - 1) : i);
45811 num2 = ((Main.tile[i, j].frameY != 0) ? (j - 1) : j);
45812 for (int k = 0; k < 2; k++)
45813 {
45814 for (int l = 0; l < 2; l++)
45815 {
45816 Tile tile = Main.tile[num + k, num2 + l];
45817 if (tile != null && (!tile.nactive() || tile.type != type))
45818 {
45819 destroyObject = true;
45820 break;
45821 }
45822 }
45823 if (destroyObject)
45824 {
45825 break;
45826 }
45827 if (type == 12 || type == 639)
45828 {
45829 Tile tile = Main.tile[num + k, num2 + 2];
45830 if (tile != null && !SolidTileAllowBottomSlope(num + k, num2 + 2))
45831 {
45832 destroyObject = true;
45833 break;
45834 }
45835 }
45836 }
45837 if (!destroyObject)
45838 {
45839 return;
45840 }
45841 for (int m = num; m < num + 2; m++)
45842 {
45843 for (int n = num2; n < num2 + 2; n++)
45844 {
45845 if (Main.tile[m, n] != null && Main.tile[m, n].type == type)
45846 {
45847 KillTile(m, n);
45848 }
45849 }
45850 }
45851 if (Main.netMode != 1 && !noTileActions)
45852 {
45853 switch (type)
45854 {
45855 case 12:
45856 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 29);
45857 break;
45858 case 639:
45859 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 109);
45860 break;
45861 case 31:
45862 if (flag)
45863 {
45864 int num3 = Main.rand.Next(5);
45865 if (!shadowOrbSmashed)
45866 {
45867 num3 = 0;
45868 }
45869 switch (num3)
45870 {
45871 case 0:
45872 {
45873 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 800, 1, noBroadcast: false, -1);
45874 int stack = genRand.Next(100, 101);
45875 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 97, stack);
45876 break;
45877 }
45878 case 1:
45879 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 1256, 1, noBroadcast: false, -1);
45880 break;
45881 case 2:
45882 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 802, 1, noBroadcast: false, -1);
45883 break;
45884 case 3:
45885 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 3062, 1, noBroadcast: false, -1);
45886 break;
45887 case 4:
45888 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 1290, 1, noBroadcast: false, -1);
45889 break;
45890 }
45891 }
45892 else
45893 {
45894 int num4 = Main.rand.Next(5);
45895 if (!shadowOrbSmashed)
45896 {
45897 num4 = 0;
45898 }
45899 switch (num4)
45900 {
45901 case 0:
45902 {
45903 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 96, 1, noBroadcast: false, -1);
45904 int stack2 = genRand.Next(100, 101);
45905 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 97, stack2);
45906 break;
45907 }
45908 case 1:
45909 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 64, 1, noBroadcast: false, -1);
45910 break;
45911 case 2:
45912 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 162, 1, noBroadcast: false, -1);
45913 break;
45914 case 3:
45915 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 115, 1, noBroadcast: false, -1);
45916 break;
45917 case 4:
45918 Item.NewItem(GetItemSource_FromTileBreak(num, num2), num * 16, num2 * 16, 32, 32, 111, 1, noBroadcast: false, -1);
45919 break;
45920 }
45921 }
45922 shadowOrbSmashed = true;
45923 shadowOrbCount++;
45924 if (shadowOrbCount >= 3)
45925 {
45926 if (!(NPC.AnyNPCs(266) && flag) && (!NPC.AnyNPCs(13) || flag))
45927 {
45928 shadowOrbCount = 0;
45929 float num5 = num * 16;
45930 float num6 = num2 * 16;
45931 float num7 = -1f;
45932 int plr = 0;
45933 for (int num8 = 0; num8 < 255; num8++)
45934 {
45935 float num9 = Math.Abs(Main.player[num8].position.X - num5) + Math.Abs(Main.player[num8].position.Y - num6);
45936 if (num9 < num7 || num7 == -1f)
45937 {
45938 plr = num8;
45939 num7 = num9;
45940 }
45941 }
45942 if (flag)
45943 {
45944 NPC.SpawnOnPlayer(plr, 266);
45945 }
45946 else
45947 {
45948 NPC.SpawnOnPlayer(plr, 13);
45949 }
45950 }
45951 }
45952 else
45953 {
45955 if (shadowOrbCount == 2)
45956 {
45957 localizedText = Lang.misc[11];
45958 }
45959 if (Main.netMode == 0)
45960 {
45961 Main.NewText(localizedText.ToString(), 50, byte.MaxValue, 130);
45962 }
45963 else if (Main.netMode == 2)
45964 {
45966 }
45967 }
45969 break;
45970 }
45971 }
45972 if (flag)
45973 {
45974 SoundEngine.PlaySound(4, i * 16, j * 16);
45975 }
45976 else
45977 {
45978 SoundEngine.PlaySound(13, i * 16, j * 16);
45979 }
45980 destroyObject = false;
45981 }
45982
45983 public static void CheckPalmTree(int i, int j)
45984 {
45985 int num = -1;
45986 int num2 = -1;
45987 int type = Main.tile[i, j].type;
45988 int frameX = Main.tile[i, j].frameX;
45989 int frameY = Main.tile[i, j].frameY;
45990 if (Main.tile[i, j - 1] != null && Main.tile[i, j - 1].active())
45991 {
45992 num = Main.tile[i, j - 1].type;
45993 }
45994 if (Main.tile[i, j + 1] != null && Main.tile[i, j + 1].active())
45995 {
45996 num2 = Main.tile[i, j + 1].type;
45997 }
45998 if (num2 == 53)
45999 {
46000 num2 = 53;
46001 }
46002 if (num2 == 234)
46003 {
46004 num2 = 53;
46005 }
46006 if (num2 == 116)
46007 {
46008 num2 = 53;
46009 }
46010 if (num2 == 112)
46011 {
46012 num2 = 53;
46013 }
46014 if (num2 != 53 && num2 != type)
46015 {
46016 KillTile(i, j);
46017 }
46018 if ((Main.tile[i, j].frameX == 66 || Main.tile[i, j].frameX == 220) && num2 != 53)
46019 {
46020 KillTile(i, j);
46021 }
46022 if (num != type && Main.tile[i, j].frameX <= 44)
46023 {
46024 Main.tile[i, j].frameX = (short)(genRand.Next(7, 10) * 22);
46025 }
46026 else if (num != type && Main.tile[i, j].frameX == 66)
46027 {
46028 Main.tile[i, j].frameX = 220;
46029 }
46030 if (Main.tile[i, j].frameX != frameX && Main.tile[i, j].frameY != frameY && frameX >= 0 && frameY >= 0)
46031 {
46032 TileFrame(i - 1, j);
46033 TileFrame(i + 1, j);
46034 TileFrame(i, j - 1);
46035 TileFrame(i, j + 1);
46036 }
46037 }
46038
46039 public static void CheckTreeWithSettings(int x, int y, CheckTreeSettings settings)
46040 {
46041 int num = -1;
46042 int num2 = -1;
46043 int num3 = -1;
46044 int num4 = -1;
46045 Tile tile = Main.tile[x, y];
46046 int type = tile.type;
46047 int frameX = tile.frameX;
46048 int frameY = tile.frameY;
46049 if (Main.tile[x - 1, y] != null && Main.tile[x - 1, y].active())
46050 {
46051 num2 = Main.tile[x - 1, y].type;
46052 }
46053 if (Main.tile[x + 1, y] != null && Main.tile[x + 1, y].active())
46054 {
46055 num3 = Main.tile[x + 1, y].type;
46056 }
46057 if (Main.tile[x, y - 1] != null && Main.tile[x, y - 1].active())
46058 {
46059 num = Main.tile[x, y - 1].type;
46060 }
46061 if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].active())
46062 {
46063 num4 = Main.tile[x, y + 1].type;
46064 }
46065 bool flag = settings.IsGroundValid(num4);
46066 bool flag2 = num3 == type;
46067 bool flag3 = num2 == type;
46068 if (!flag && num4 != type && ((tile.frameX == 0 && tile.frameY <= 130) || (tile.frameX == 22 && tile.frameY <= 130) || (tile.frameX == 44 && tile.frameY <= 130)))
46069 {
46070 KillTile(x, y);
46071 }
46072 if (tile.frameX >= 22 && tile.frameX <= 44 && tile.frameY >= 132 && tile.frameY <= 176)
46073 {
46074 if (!flag)
46075 {
46076 KillTile(x, y);
46077 }
46078 else if (!(tile.frameX == 22 && flag3) && !(tile.frameX == 44 && flag2))
46079 {
46080 KillTile(x, y);
46081 }
46082 }
46083 else if ((tile.frameX == 88 && tile.frameY >= 0 && tile.frameY <= 44) || (tile.frameX == 66 && tile.frameY >= 66 && tile.frameY <= 130) || (tile.frameX == 110 && tile.frameY >= 66 && tile.frameY <= 110) || (tile.frameX == 132 && tile.frameY >= 0 && tile.frameY <= 176))
46084 {
46085 if (flag3 && flag2)
46086 {
46087 if (tile.frameNumber() == 0)
46088 {
46089 tile.frameX = 110;
46090 tile.frameY = 66;
46091 }
46092 if (tile.frameNumber() == 1)
46093 {
46094 tile.frameX = 110;
46095 tile.frameY = 88;
46096 }
46097 if (tile.frameNumber() == 2)
46098 {
46099 tile.frameX = 110;
46100 tile.frameY = 110;
46101 }
46102 }
46103 else if (flag3)
46104 {
46105 if (tile.frameNumber() == 0)
46106 {
46107 tile.frameX = 88;
46108 tile.frameY = 0;
46109 }
46110 if (tile.frameNumber() == 1)
46111 {
46112 tile.frameX = 88;
46113 tile.frameY = 22;
46114 }
46115 if (tile.frameNumber() == 2)
46116 {
46117 tile.frameX = 88;
46118 tile.frameY = 44;
46119 }
46120 }
46121 else if (flag2)
46122 {
46123 if (tile.frameNumber() == 0)
46124 {
46125 tile.frameX = 66;
46126 tile.frameY = 66;
46127 }
46128 if (tile.frameNumber() == 1)
46129 {
46130 tile.frameX = 66;
46131 tile.frameY = 88;
46132 }
46133 if (tile.frameNumber() == 2)
46134 {
46135 tile.frameX = 66;
46136 tile.frameY = 110;
46137 }
46138 }
46139 else
46140 {
46141 if (tile.frameNumber() == 0)
46142 {
46143 tile.frameX = 0;
46144 tile.frameY = 0;
46145 }
46146 if (tile.frameNumber() == 1)
46147 {
46148 tile.frameX = 0;
46149 tile.frameY = 22;
46150 }
46151 if (tile.frameNumber() == 2)
46152 {
46153 tile.frameX = 0;
46154 tile.frameY = 44;
46155 }
46156 }
46157 }
46158 if (tile.frameY >= 132 && tile.frameY <= 176 && (tile.frameX == 0 || tile.frameX == 66 || tile.frameX == 88))
46159 {
46160 if (!flag)
46161 {
46162 KillTile(x, y);
46163 }
46164 if (!flag3 && !flag2)
46165 {
46166 if (tile.frameNumber() == 0)
46167 {
46168 tile.frameX = 0;
46169 tile.frameY = 0;
46170 }
46171 if (tile.frameNumber() == 1)
46172 {
46173 tile.frameX = 0;
46174 tile.frameY = 22;
46175 }
46176 if (tile.frameNumber() == 2)
46177 {
46178 tile.frameX = 0;
46179 tile.frameY = 44;
46180 }
46181 }
46182 else if (!flag3)
46183 {
46184 if (tile.frameNumber() == 0)
46185 {
46186 tile.frameX = 0;
46187 tile.frameY = 132;
46188 }
46189 if (tile.frameNumber() == 1)
46190 {
46191 tile.frameX = 0;
46192 tile.frameY = 154;
46193 }
46194 if (tile.frameNumber() == 2)
46195 {
46196 tile.frameX = 0;
46197 tile.frameY = 176;
46198 }
46199 }
46200 else if (!flag2)
46201 {
46202 if (tile.frameNumber() == 0)
46203 {
46204 tile.frameX = 66;
46205 tile.frameY = 132;
46206 }
46207 if (tile.frameNumber() == 1)
46208 {
46209 tile.frameX = 66;
46210 tile.frameY = 154;
46211 }
46212 if (tile.frameNumber() == 2)
46213 {
46214 tile.frameX = 66;
46215 tile.frameY = 176;
46216 }
46217 }
46218 else
46219 {
46220 if (tile.frameNumber() == 0)
46221 {
46222 tile.frameX = 88;
46223 tile.frameY = 132;
46224 }
46225 if (tile.frameNumber() == 1)
46226 {
46227 tile.frameX = 88;
46228 tile.frameY = 154;
46229 }
46230 if (tile.frameNumber() == 2)
46231 {
46232 tile.frameX = 88;
46233 tile.frameY = 176;
46234 }
46235 }
46236 }
46237 if ((tile.frameX == 66 && (tile.frameY == 0 || tile.frameY == 22 || tile.frameY == 44)) || (tile.frameX == 44 && (tile.frameY == 198 || tile.frameY == 220 || tile.frameY == 242)))
46238 {
46239 if (!flag2)
46240 {
46241 KillTile(x, y);
46242 }
46243 }
46244 else if ((tile.frameX == 88 && (tile.frameY == 66 || tile.frameY == 88 || tile.frameY == 110)) || (tile.frameX == 66 && (tile.frameY == 198 || tile.frameY == 220 || tile.frameY == 242)))
46245 {
46246 if (!flag3)
46247 {
46248 KillTile(x, y);
46249 }
46250 }
46251 else if (num4 == -1)
46252 {
46253 KillTile(x, y);
46254 }
46255 else if (num != type && tile.frameY < 198 && ((tile.frameX != 22 && tile.frameX != 44) || tile.frameY < 132))
46256 {
46257 if (flag3 || flag2)
46258 {
46259 if (num4 == type)
46260 {
46261 if (flag3 && flag2)
46262 {
46263 if (tile.frameNumber() == 0)
46264 {
46265 tile.frameX = 132;
46266 tile.frameY = 132;
46267 }
46268 if (tile.frameNumber() == 1)
46269 {
46270 tile.frameX = 132;
46271 tile.frameY = 154;
46272 }
46273 if (tile.frameNumber() == 2)
46274 {
46275 tile.frameX = 132;
46276 tile.frameY = 176;
46277 }
46278 }
46279 else if (flag3)
46280 {
46281 if (tile.frameNumber() == 0)
46282 {
46283 tile.frameX = 132;
46284 tile.frameY = 0;
46285 }
46286 if (tile.frameNumber() == 1)
46287 {
46288 tile.frameX = 132;
46289 tile.frameY = 22;
46290 }
46291 if (tile.frameNumber() == 2)
46292 {
46293 tile.frameX = 132;
46294 tile.frameY = 44;
46295 }
46296 }
46297 else if (flag2)
46298 {
46299 if (tile.frameNumber() == 0)
46300 {
46301 tile.frameX = 132;
46302 tile.frameY = 66;
46303 }
46304 if (tile.frameNumber() == 1)
46305 {
46306 tile.frameX = 132;
46307 tile.frameY = 88;
46308 }
46309 if (tile.frameNumber() == 2)
46310 {
46311 tile.frameX = 132;
46312 tile.frameY = 110;
46313 }
46314 }
46315 }
46316 else if (flag3 && flag2)
46317 {
46318 if (tile.frameNumber() == 0)
46319 {
46320 tile.frameX = 154;
46321 tile.frameY = 132;
46322 }
46323 if (tile.frameNumber() == 1)
46324 {
46325 tile.frameX = 154;
46326 tile.frameY = 154;
46327 }
46328 if (tile.frameNumber() == 2)
46329 {
46330 tile.frameX = 154;
46331 tile.frameY = 176;
46332 }
46333 }
46334 else if (flag3)
46335 {
46336 if (tile.frameNumber() == 0)
46337 {
46338 tile.frameX = 154;
46339 tile.frameY = 0;
46340 }
46341 if (tile.frameNumber() == 1)
46342 {
46343 tile.frameX = 154;
46344 tile.frameY = 22;
46345 }
46346 if (tile.frameNumber() == 2)
46347 {
46348 tile.frameX = 154;
46349 tile.frameY = 44;
46350 }
46351 }
46352 else if (flag2)
46353 {
46354 if (tile.frameNumber() == 0)
46355 {
46356 tile.frameX = 154;
46357 tile.frameY = 66;
46358 }
46359 if (tile.frameNumber() == 1)
46360 {
46361 tile.frameX = 154;
46362 tile.frameY = 88;
46363 }
46364 if (tile.frameNumber() == 2)
46365 {
46366 tile.frameX = 154;
46367 tile.frameY = 110;
46368 }
46369 }
46370 }
46371 else
46372 {
46373 if (tile.frameNumber() == 0)
46374 {
46375 tile.frameX = 110;
46376 tile.frameY = 0;
46377 }
46378 if (tile.frameNumber() == 1)
46379 {
46380 tile.frameX = 110;
46381 tile.frameY = 22;
46382 }
46383 if (tile.frameNumber() == 2)
46384 {
46385 tile.frameX = 110;
46386 tile.frameY = 44;
46387 }
46388 }
46389 }
46390 if (tile.frameX != frameX && tile.frameY != frameY && frameX >= 0 && frameY >= 0)
46391 {
46392 TileFrame(x - 1, y);
46393 TileFrame(x + 1, y);
46394 TileFrame(x, y - 1);
46395 TileFrame(x, y + 1);
46396 }
46397 }
46398
46399 public static void CheckTree(int i, int j)
46400 {
46401 int num = -1;
46402 int num2 = -1;
46403 int num3 = -1;
46404 int num4 = -1;
46405 int type = Main.tile[i, j].type;
46406 int frameX = Main.tile[i, j].frameX;
46407 int frameY = Main.tile[i, j].frameY;
46408 if (Main.tile[i - 1, j] != null && Main.tile[i - 1, j].active())
46409 {
46410 num2 = Main.tile[i - 1, j].type;
46411 }
46412 if (Main.tile[i + 1, j] != null && Main.tile[i + 1, j].active())
46413 {
46414 num3 = Main.tile[i + 1, j].type;
46415 }
46416 if (Main.tile[i, j - 1] != null && Main.tile[i, j - 1].active())
46417 {
46418 num = Main.tile[i, j - 1].type;
46419 }
46420 if (Main.tile[i, j + 1] != null && Main.tile[i, j + 1].active())
46421 {
46422 num4 = Main.tile[i, j + 1].type;
46423 }
46424 if (Main.tile[i - 1, j - 1] != null && Main.tile[i - 1, j - 1].active())
46425 {
46426 _ = Main.tile[i - 1, j - 1].type;
46427 }
46428 if (Main.tile[i + 1, j - 1] != null && Main.tile[i + 1, j - 1].active())
46429 {
46430 _ = Main.tile[i + 1, j - 1].type;
46431 }
46432 if (Main.tile[i - 1, j + 1] != null && Main.tile[i - 1, j + 1].active())
46433 {
46434 _ = Main.tile[i - 1, j + 1].type;
46435 }
46436 if (Main.tile[i + 1, j + 1] != null && Main.tile[i + 1, j + 1].active())
46437 {
46438 _ = Main.tile[i + 1, j + 1].type;
46439 }
46440 if (num4 == 23 || num4 == 661)
46441 {
46442 num4 = 2;
46443 }
46444 if (num4 == 477)
46445 {
46446 num4 = 2;
46447 }
46448 if (num4 == 60)
46449 {
46450 num4 = 2;
46451 }
46452 if (num4 == 70)
46453 {
46454 num4 = 2;
46455 }
46456 if (num4 == 109)
46457 {
46458 num4 = 2;
46459 }
46460 if (num4 == 147)
46461 {
46462 num4 = 2;
46463 }
46464 if (num4 == 199 || num4 == 662)
46465 {
46466 num4 = 2;
46467 }
46468 if (num4 == 492)
46469 {
46470 num4 = 2;
46471 }
46472 if (num4 != 2 && num4 != type && ((Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY <= 130) || (Main.tile[i, j].frameX == 22 && Main.tile[i, j].frameY <= 130) || (Main.tile[i, j].frameX == 44 && Main.tile[i, j].frameY <= 130)))
46473 {
46474 KillTile(i, j);
46475 }
46476 if (Main.tile[i, j].frameX >= 22 && Main.tile[i, j].frameX <= 44 && Main.tile[i, j].frameY >= 132 && Main.tile[i, j].frameY <= 176)
46477 {
46478 if (num4 != 2)
46479 {
46480 KillTile(i, j);
46481 }
46482 else if ((Main.tile[i, j].frameX != 22 || num2 != type) && (Main.tile[i, j].frameX != 44 || num3 != type))
46483 {
46484 KillTile(i, j);
46485 }
46486 }
46487 else if ((Main.tile[i, j].frameX == 88 && Main.tile[i, j].frameY >= 0 && Main.tile[i, j].frameY <= 44) || (Main.tile[i, j].frameX == 66 && Main.tile[i, j].frameY >= 66 && Main.tile[i, j].frameY <= 130) || (Main.tile[i, j].frameX == 110 && Main.tile[i, j].frameY >= 66 && Main.tile[i, j].frameY <= 110) || (Main.tile[i, j].frameX == 132 && Main.tile[i, j].frameY >= 0 && Main.tile[i, j].frameY <= 176))
46488 {
46489 if (num2 == type && num3 == type)
46490 {
46491 if (Main.tile[i, j].frameNumber() == 0)
46492 {
46493 Main.tile[i, j].frameX = 110;
46494 Main.tile[i, j].frameY = 66;
46495 }
46496 if (Main.tile[i, j].frameNumber() == 1)
46497 {
46498 Main.tile[i, j].frameX = 110;
46499 Main.tile[i, j].frameY = 88;
46500 }
46501 if (Main.tile[i, j].frameNumber() == 2)
46502 {
46503 Main.tile[i, j].frameX = 110;
46504 Main.tile[i, j].frameY = 110;
46505 }
46506 }
46507 else if (num2 == type)
46508 {
46509 if (Main.tile[i, j].frameNumber() == 0)
46510 {
46511 Main.tile[i, j].frameX = 88;
46512 Main.tile[i, j].frameY = 0;
46513 }
46514 if (Main.tile[i, j].frameNumber() == 1)
46515 {
46516 Main.tile[i, j].frameX = 88;
46517 Main.tile[i, j].frameY = 22;
46518 }
46519 if (Main.tile[i, j].frameNumber() == 2)
46520 {
46521 Main.tile[i, j].frameX = 88;
46522 Main.tile[i, j].frameY = 44;
46523 }
46524 }
46525 else if (num3 == type)
46526 {
46527 if (Main.tile[i, j].frameNumber() == 0)
46528 {
46529 Main.tile[i, j].frameX = 66;
46530 Main.tile[i, j].frameY = 66;
46531 }
46532 if (Main.tile[i, j].frameNumber() == 1)
46533 {
46534 Main.tile[i, j].frameX = 66;
46535 Main.tile[i, j].frameY = 88;
46536 }
46537 if (Main.tile[i, j].frameNumber() == 2)
46538 {
46539 Main.tile[i, j].frameX = 66;
46540 Main.tile[i, j].frameY = 110;
46541 }
46542 }
46543 else
46544 {
46545 if (Main.tile[i, j].frameNumber() == 0)
46546 {
46547 Main.tile[i, j].frameX = 0;
46548 Main.tile[i, j].frameY = 0;
46549 }
46550 if (Main.tile[i, j].frameNumber() == 1)
46551 {
46552 Main.tile[i, j].frameX = 0;
46553 Main.tile[i, j].frameY = 22;
46554 }
46555 if (Main.tile[i, j].frameNumber() == 2)
46556 {
46557 Main.tile[i, j].frameX = 0;
46558 Main.tile[i, j].frameY = 44;
46559 }
46560 }
46561 }
46562 if (Main.tile[i, j].frameY >= 132 && Main.tile[i, j].frameY <= 176 && (Main.tile[i, j].frameX == 0 || Main.tile[i, j].frameX == 66 || Main.tile[i, j].frameX == 88))
46563 {
46564 if (num4 != 2)
46565 {
46566 KillTile(i, j);
46567 }
46568 if (num2 != type && num3 != type)
46569 {
46570 if (Main.tile[i, j].frameNumber() == 0)
46571 {
46572 Main.tile[i, j].frameX = 0;
46573 Main.tile[i, j].frameY = 0;
46574 }
46575 if (Main.tile[i, j].frameNumber() == 1)
46576 {
46577 Main.tile[i, j].frameX = 0;
46578 Main.tile[i, j].frameY = 22;
46579 }
46580 if (Main.tile[i, j].frameNumber() == 2)
46581 {
46582 Main.tile[i, j].frameX = 0;
46583 Main.tile[i, j].frameY = 44;
46584 }
46585 }
46586 else if (num2 != type)
46587 {
46588 if (Main.tile[i, j].frameNumber() == 0)
46589 {
46590 Main.tile[i, j].frameX = 0;
46591 Main.tile[i, j].frameY = 132;
46592 }
46593 if (Main.tile[i, j].frameNumber() == 1)
46594 {
46595 Main.tile[i, j].frameX = 0;
46596 Main.tile[i, j].frameY = 154;
46597 }
46598 if (Main.tile[i, j].frameNumber() == 2)
46599 {
46600 Main.tile[i, j].frameX = 0;
46601 Main.tile[i, j].frameY = 176;
46602 }
46603 }
46604 else if (num3 != type)
46605 {
46606 if (Main.tile[i, j].frameNumber() == 0)
46607 {
46608 Main.tile[i, j].frameX = 66;
46609 Main.tile[i, j].frameY = 132;
46610 }
46611 if (Main.tile[i, j].frameNumber() == 1)
46612 {
46613 Main.tile[i, j].frameX = 66;
46614 Main.tile[i, j].frameY = 154;
46615 }
46616 if (Main.tile[i, j].frameNumber() == 2)
46617 {
46618 Main.tile[i, j].frameX = 66;
46619 Main.tile[i, j].frameY = 176;
46620 }
46621 }
46622 else
46623 {
46624 if (Main.tile[i, j].frameNumber() == 0)
46625 {
46626 Main.tile[i, j].frameX = 88;
46627 Main.tile[i, j].frameY = 132;
46628 }
46629 if (Main.tile[i, j].frameNumber() == 1)
46630 {
46631 Main.tile[i, j].frameX = 88;
46632 Main.tile[i, j].frameY = 154;
46633 }
46634 if (Main.tile[i, j].frameNumber() == 2)
46635 {
46636 Main.tile[i, j].frameX = 88;
46637 Main.tile[i, j].frameY = 176;
46638 }
46639 }
46640 }
46641 if ((Main.tile[i, j].frameX == 66 && (Main.tile[i, j].frameY == 0 || Main.tile[i, j].frameY == 22 || Main.tile[i, j].frameY == 44)) || (Main.tile[i, j].frameX == 44 && (Main.tile[i, j].frameY == 198 || Main.tile[i, j].frameY == 220 || Main.tile[i, j].frameY == 242)))
46642 {
46643 if (num3 != type)
46644 {
46645 KillTile(i, j);
46646 }
46647 }
46648 else if ((Main.tile[i, j].frameX == 88 && (Main.tile[i, j].frameY == 66 || Main.tile[i, j].frameY == 88 || Main.tile[i, j].frameY == 110)) || (Main.tile[i, j].frameX == 66 && (Main.tile[i, j].frameY == 198 || Main.tile[i, j].frameY == 220 || Main.tile[i, j].frameY == 242)))
46649 {
46650 if (num2 != type)
46651 {
46652 KillTile(i, j);
46653 }
46654 }
46655 else if (num4 == -1 || num4 == 23)
46656 {
46657 KillTile(i, j);
46658 }
46659 else if (num != type && Main.tile[i, j].frameY < 198 && ((Main.tile[i, j].frameX != 22 && Main.tile[i, j].frameX != 44) || Main.tile[i, j].frameY < 132))
46660 {
46661 if (num2 == type || num3 == type)
46662 {
46663 if (num4 == type)
46664 {
46665 if (num2 == type && num3 == type)
46666 {
46667 if (Main.tile[i, j].frameNumber() == 0)
46668 {
46669 Main.tile[i, j].frameX = 132;
46670 Main.tile[i, j].frameY = 132;
46671 }
46672 if (Main.tile[i, j].frameNumber() == 1)
46673 {
46674 Main.tile[i, j].frameX = 132;
46675 Main.tile[i, j].frameY = 154;
46676 }
46677 if (Main.tile[i, j].frameNumber() == 2)
46678 {
46679 Main.tile[i, j].frameX = 132;
46680 Main.tile[i, j].frameY = 176;
46681 }
46682 }
46683 else if (num2 == type)
46684 {
46685 if (Main.tile[i, j].frameNumber() == 0)
46686 {
46687 Main.tile[i, j].frameX = 132;
46688 Main.tile[i, j].frameY = 0;
46689 }
46690 if (Main.tile[i, j].frameNumber() == 1)
46691 {
46692 Main.tile[i, j].frameX = 132;
46693 Main.tile[i, j].frameY = 22;
46694 }
46695 if (Main.tile[i, j].frameNumber() == 2)
46696 {
46697 Main.tile[i, j].frameX = 132;
46698 Main.tile[i, j].frameY = 44;
46699 }
46700 }
46701 else if (num3 == type)
46702 {
46703 if (Main.tile[i, j].frameNumber() == 0)
46704 {
46705 Main.tile[i, j].frameX = 132;
46706 Main.tile[i, j].frameY = 66;
46707 }
46708 if (Main.tile[i, j].frameNumber() == 1)
46709 {
46710 Main.tile[i, j].frameX = 132;
46711 Main.tile[i, j].frameY = 88;
46712 }
46713 if (Main.tile[i, j].frameNumber() == 2)
46714 {
46715 Main.tile[i, j].frameX = 132;
46716 Main.tile[i, j].frameY = 110;
46717 }
46718 }
46719 }
46720 else if (num2 == type && num3 == type)
46721 {
46722 if (Main.tile[i, j].frameNumber() == 0)
46723 {
46724 Main.tile[i, j].frameX = 154;
46725 Main.tile[i, j].frameY = 132;
46726 }
46727 if (Main.tile[i, j].frameNumber() == 1)
46728 {
46729 Main.tile[i, j].frameX = 154;
46730 Main.tile[i, j].frameY = 154;
46731 }
46732 if (Main.tile[i, j].frameNumber() == 2)
46733 {
46734 Main.tile[i, j].frameX = 154;
46735 Main.tile[i, j].frameY = 176;
46736 }
46737 }
46738 else if (num2 == type)
46739 {
46740 if (Main.tile[i, j].frameNumber() == 0)
46741 {
46742 Main.tile[i, j].frameX = 154;
46743 Main.tile[i, j].frameY = 0;
46744 }
46745 if (Main.tile[i, j].frameNumber() == 1)
46746 {
46747 Main.tile[i, j].frameX = 154;
46748 Main.tile[i, j].frameY = 22;
46749 }
46750 if (Main.tile[i, j].frameNumber() == 2)
46751 {
46752 Main.tile[i, j].frameX = 154;
46753 Main.tile[i, j].frameY = 44;
46754 }
46755 }
46756 else if (num3 == type)
46757 {
46758 if (Main.tile[i, j].frameNumber() == 0)
46759 {
46760 Main.tile[i, j].frameX = 154;
46761 Main.tile[i, j].frameY = 66;
46762 }
46763 if (Main.tile[i, j].frameNumber() == 1)
46764 {
46765 Main.tile[i, j].frameX = 154;
46766 Main.tile[i, j].frameY = 88;
46767 }
46768 if (Main.tile[i, j].frameNumber() == 2)
46769 {
46770 Main.tile[i, j].frameX = 154;
46771 Main.tile[i, j].frameY = 110;
46772 }
46773 }
46774 }
46775 else
46776 {
46777 if (Main.tile[i, j].frameNumber() == 0)
46778 {
46779 Main.tile[i, j].frameX = 110;
46780 Main.tile[i, j].frameY = 0;
46781 }
46782 if (Main.tile[i, j].frameNumber() == 1)
46783 {
46784 Main.tile[i, j].frameX = 110;
46785 Main.tile[i, j].frameY = 22;
46786 }
46787 if (Main.tile[i, j].frameNumber() == 2)
46788 {
46789 Main.tile[i, j].frameX = 110;
46790 Main.tile[i, j].frameY = 44;
46791 }
46792 }
46793 }
46794 if (Main.tile[i, j].frameX != frameX && Main.tile[i, j].frameY != frameY && frameX >= 0 && frameY >= 0)
46795 {
46796 TileFrame(i - 1, j);
46797 TileFrame(i + 1, j);
46798 TileFrame(i, j - 1);
46799 TileFrame(i, j + 1);
46800 }
46801 }
46802
46803 public static bool TileIsExposedToAir(int x, int y)
46804 {
46805 if (!InWorld(x, y, 2))
46806 {
46807 return false;
46808 }
46809 for (int i = x - 1; i <= x + 1; i++)
46810 {
46811 for (int j = y - 1; j <= y + 1; j++)
46812 {
46813 Tile tile = Main.tile[i, j];
46814 if (tile != null && (!tile.active() || !Main.tileSolid[tile.type] || TileID.Sets.Platforms[tile.type]))
46815 {
46816 return true;
46817 }
46818 }
46819 }
46820 return false;
46821 }
46822
46824 {
46826 {
46827 return false;
46828 }
46829 if (!InWorld(i, j, 2))
46830 {
46831 return false;
46832 }
46833 Tile tile = Main.tile[i, j - 1];
46834 if (tile == null || !tile.active())
46835 {
46836 return false;
46837 }
46838 int type = tile.type;
46839 if (!IsTreeType(tile.type) && tile.type != 323)
46840 {
46841 return false;
46842 }
46843 bool flag = true;
46844 flag = type switch
46845 {
46846 72 => newFloorType == 70,
46849 };
46851 {
46852 flag = profile.GroundTest(newFloorType);
46853 }
46854 if (!flag)
46855 {
46856 KillTile(i, j - 1);
46857 if (Main.netMode == 1)
46858 {
46859 NetMessage.SendData(17, -1, -1, null, 0, i, j - 1);
46860 }
46861 }
46862 return true;
46863 }
46864
46865 public static void Convert(int i, int j, int conversionType, int size = 4)
46866 {
46867 for (int k = i - size; k <= i + size; k++)
46868 {
46869 for (int l = j - size; l <= j + size; l++)
46870 {
46871 if (!InWorld(k, l, 1) || Math.Abs(k - i) + Math.Abs(l - j) >= 6)
46872 {
46873 continue;
46874 }
46875 Tile tile = Main.tile[k, l];
46876 int type = tile.type;
46877 int wall = tile.wall;
46878 switch (conversionType)
46879 {
46880 case 4:
46881 if (type <= TileID.Count && wall <= WallID.Count)
46882 {
46883 if (WallID.Sets.Conversion.Grass[wall] && wall != 81)
46884 {
46885 tile.wall = 81;
46886 SquareWallFrame(k, l);
46888 }
46889 else if (WallID.Sets.Conversion.Stone[wall] && wall != 83)
46890 {
46891 tile.wall = 83;
46892 SquareWallFrame(k, l);
46894 }
46895 else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 218)
46896 {
46897 tile.wall = 218;
46898 SquareWallFrame(k, l);
46900 }
46901 else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 221)
46902 {
46903 tile.wall = 221;
46904 SquareWallFrame(k, l);
46906 }
46907 else if (WallID.Sets.Conversion.NewWall1[wall] && wall != 192)
46908 {
46909 tile.wall = 192;
46910 SquareWallFrame(k, l);
46912 }
46913 else if (WallID.Sets.Conversion.NewWall2[wall] && wall != 193)
46914 {
46915 tile.wall = 193;
46916 SquareWallFrame(k, l);
46918 }
46919 else if (WallID.Sets.Conversion.NewWall3[wall] && wall != 194)
46920 {
46921 tile.wall = 194;
46922 SquareWallFrame(k, l);
46924 }
46925 else if (WallID.Sets.Conversion.NewWall4[wall] && wall != 195)
46926 {
46927 tile.wall = 195;
46928 SquareWallFrame(k, l);
46930 }
46931 if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 203)
46932 {
46933 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 203);
46934 tile.type = 203;
46935 SquareTileFrame(k, l);
46937 }
46938 else if (TileID.Sets.Conversion.JungleGrass[type] && type != 662)
46939 {
46940 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 662);
46941 tile.type = 662;
46942 SquareTileFrame(k, l);
46944 }
46945 else if (TileID.Sets.Conversion.Grass[type] && type != 199)
46946 {
46947 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 199);
46948 tile.type = 199;
46949 SquareTileFrame(k, l);
46951 }
46952 else if (TileID.Sets.Conversion.Ice[type] && type != 200)
46953 {
46954 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 200);
46955 tile.type = 200;
46956 SquareTileFrame(k, l);
46958 }
46959 else if (TileID.Sets.Conversion.Sand[type] && type != 234)
46960 {
46961 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 234);
46962 tile.type = 234;
46963 SquareTileFrame(k, l);
46965 }
46966 else if (TileID.Sets.Conversion.HardenedSand[type] && type != 399)
46967 {
46968 tile.type = 399;
46969 SquareTileFrame(k, l);
46971 }
46972 else if (TileID.Sets.Conversion.Sandstone[type] && type != 401)
46973 {
46974 tile.type = 401;
46975 SquareTileFrame(k, l);
46977 }
46978 else if (TileID.Sets.Conversion.Thorn[type] && type != 352)
46979 {
46980 tile.type = 352;
46981 SquareTileFrame(k, l);
46983 }
46984 }
46985 continue;
46986 case 2:
46987 if (type > TileID.Count || wall > WallID.Count)
46988 {
46989 continue;
46990 }
46991 if (WallID.Sets.Conversion.Grass[wall] && wall != 70)
46992 {
46993 tile.wall = 70;
46994 SquareWallFrame(k, l);
46996 }
46997 else if (WallID.Sets.Conversion.Stone[wall] && wall != 28)
46998 {
46999 tile.wall = 28;
47000 SquareWallFrame(k, l);
47002 }
47003 else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 219)
47004 {
47005 tile.wall = 219;
47006 SquareWallFrame(k, l);
47008 }
47009 else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 222)
47010 {
47011 tile.wall = 222;
47012 SquareWallFrame(k, l);
47014 }
47015 else if (WallID.Sets.Conversion.NewWall1[wall] && wall != 200)
47016 {
47017 tile.wall = 200;
47018 SquareWallFrame(k, l);
47020 }
47021 else if (WallID.Sets.Conversion.NewWall2[wall] && wall != 201)
47022 {
47023 tile.wall = 201;
47024 SquareWallFrame(k, l);
47026 }
47027 else if (WallID.Sets.Conversion.NewWall3[wall] && wall != 202)
47028 {
47029 tile.wall = 202;
47030 SquareWallFrame(k, l);
47032 }
47033 else if (WallID.Sets.Conversion.NewWall4[wall] && wall != 203)
47034 {
47035 tile.wall = 203;
47036 SquareWallFrame(k, l);
47038 }
47039 if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 117)
47040 {
47041 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 117);
47042 tile.type = 117;
47043 SquareTileFrame(k, l);
47045 }
47046 else if (TileID.Sets.Conversion.GolfGrass[type] && type != 492)
47047 {
47048 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 492);
47049 tile.type = 492;
47050 SquareTileFrame(k, l);
47052 }
47053 else if (TileID.Sets.Conversion.Grass[type] && type != 109 && type != 492)
47054 {
47055 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 109);
47056 tile.type = 109;
47057 SquareTileFrame(k, l);
47059 }
47060 else if (TileID.Sets.Conversion.Ice[type] && type != 164)
47061 {
47062 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 164);
47063 tile.type = 164;
47064 SquareTileFrame(k, l);
47066 }
47067 else if (TileID.Sets.Conversion.Sand[type] && type != 116)
47068 {
47069 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 116);
47070 tile.type = 116;
47071 SquareTileFrame(k, l);
47073 }
47074 else if (TileID.Sets.Conversion.HardenedSand[type] && type != 402)
47075 {
47076 tile.type = 402;
47077 SquareTileFrame(k, l);
47079 }
47080 else if (TileID.Sets.Conversion.Sandstone[type] && type != 403)
47081 {
47082 tile.type = 403;
47083 SquareTileFrame(k, l);
47085 }
47086 else if (TileID.Sets.Conversion.Thorn[type])
47087 {
47088 KillTile(k, l);
47089 if (Main.netMode == 1)
47090 {
47091 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47092 }
47093 }
47094 if (type == 59 && (Main.tile[k - 1, l].type == 109 || Main.tile[k + 1, l].type == 109 || Main.tile[k, l - 1].type == 109 || Main.tile[k, l + 1].type == 109))
47095 {
47096 tile.type = 0;
47097 SquareTileFrame(k, l);
47099 }
47100 continue;
47101 case 1:
47102 if (type <= TileID.Count && wall <= WallID.Count)
47103 {
47104 if (WallID.Sets.Conversion.Grass[wall] && wall != 69)
47105 {
47106 tile.wall = 69;
47107 SquareWallFrame(k, l);
47109 }
47110 else if (TileID.Sets.Conversion.JungleGrass[type] && type != 661)
47111 {
47112 tile.type = 661;
47113 SquareTileFrame(k, l);
47115 }
47116 else if (WallID.Sets.Conversion.Stone[wall] && wall != 3)
47117 {
47118 tile.wall = 3;
47119 SquareWallFrame(k, l);
47121 }
47122 else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 217)
47123 {
47124 tile.wall = 217;
47125 SquareWallFrame(k, l);
47127 }
47128 else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 220)
47129 {
47130 tile.wall = 220;
47131 SquareWallFrame(k, l);
47133 }
47134 else if (WallID.Sets.Conversion.NewWall1[wall] && wall != 188)
47135 {
47136 tile.wall = 188;
47137 SquareWallFrame(k, l);
47139 }
47140 else if (WallID.Sets.Conversion.NewWall2[wall] && wall != 189)
47141 {
47142 tile.wall = 189;
47143 SquareWallFrame(k, l);
47145 }
47146 else if (WallID.Sets.Conversion.NewWall3[wall] && wall != 190)
47147 {
47148 tile.wall = 190;
47149 SquareWallFrame(k, l);
47151 }
47152 else if (WallID.Sets.Conversion.NewWall4[wall] && wall != 191)
47153 {
47154 tile.wall = 191;
47155 SquareWallFrame(k, l);
47157 }
47158 if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 25)
47159 {
47160 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 25);
47161 tile.type = 25;
47162 SquareTileFrame(k, l);
47164 }
47165 else if (TileID.Sets.Conversion.Grass[type] && type != 23)
47166 {
47167 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 23);
47168 tile.type = 23;
47169 SquareTileFrame(k, l);
47171 }
47172 else if (TileID.Sets.Conversion.Ice[type] && type != 163)
47173 {
47174 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 163);
47175 tile.type = 163;
47176 SquareTileFrame(k, l);
47178 }
47179 else if (TileID.Sets.Conversion.Sand[type] && type != 112)
47180 {
47181 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 112);
47182 tile.type = 112;
47183 SquareTileFrame(k, l);
47185 }
47186 else if (TileID.Sets.Conversion.HardenedSand[type] && type != 398)
47187 {
47188 tile.type = 398;
47189 SquareTileFrame(k, l);
47191 }
47192 else if (TileID.Sets.Conversion.Sandstone[type] && type != 400)
47193 {
47194 tile.type = 400;
47195 SquareTileFrame(k, l);
47197 }
47198 else if (TileID.Sets.Conversion.Thorn[type] && type != 32)
47199 {
47200 tile.type = 32;
47201 SquareTileFrame(k, l);
47203 }
47204 }
47205 continue;
47206 case 3:
47208 {
47209 tile.wall = 80;
47210 SquareWallFrame(k, l);
47212 }
47213 if (tile.type == 60)
47214 {
47215 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 70);
47216 tile.type = 70;
47217 SquareTileFrame(k, l);
47219 }
47220 else if (TileID.Sets.Conversion.Thorn[type])
47221 {
47222 KillTile(k, l);
47223 if (Main.netMode == 1)
47224 {
47225 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47226 }
47227 }
47228 continue;
47229 case 5:
47231 {
47232 continue;
47233 }
47235 {
47236 tile.wall = 187;
47237 SquareWallFrame(k, l);
47239 }
47240 else if ((WallID.Sets.Conversion.HardenedSand[wall] || WallID.Sets.Conversion.Dirt[wall] || WallID.Sets.Conversion.Snow[wall]) && wall != 216)
47241 {
47242 tile.wall = 216;
47243 SquareWallFrame(k, l);
47245 }
47247 {
47248 int num = 53;
47249 if (BlockBelowMakesSandConvertIntoHardenedSand(k, l))
47250 {
47251 num = 397;
47252 }
47253 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, num);
47254 tile.type = (ushort)num;
47255 SquareTileFrame(k, l);
47257 }
47258 else if (TileID.Sets.Conversion.HardenedSand[type] && type != 397)
47259 {
47260 tile.type = 397;
47261 SquareTileFrame(k, l);
47263 }
47265 {
47266 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 396);
47267 tile.type = 396;
47268 SquareTileFrame(k, l);
47270 }
47271 else if (TileID.Sets.Conversion.Thorn[type] && type != 69)
47272 {
47273 KillTile(k, l);
47274 if (Main.netMode == 1)
47275 {
47276 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47277 }
47278 }
47279 continue;
47280 case 6:
47282 {
47283 continue;
47284 }
47286 {
47287 tile.wall = 71;
47288 SquareWallFrame(k, l);
47290 }
47291 else if ((WallID.Sets.Conversion.HardenedSand[wall] || WallID.Sets.Conversion.Dirt[wall] || WallID.Sets.Conversion.Snow[wall]) && wall != 40)
47292 {
47293 tile.wall = 40;
47294 SquareWallFrame(k, l);
47296 }
47298 {
47299 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 147);
47300 tile.type = 147;
47301 SquareTileFrame(k, l);
47303 }
47305 {
47306 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 161);
47307 tile.type = 161;
47308 SquareTileFrame(k, l);
47310 }
47311 else if (TileID.Sets.Conversion.Thorn[type] && type != 69)
47312 {
47313 KillTile(k, l);
47314 if (Main.netMode == 1)
47315 {
47316 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47317 }
47318 }
47319 continue;
47320 case 7:
47322 {
47323 continue;
47324 }
47325 if ((WallID.Sets.Conversion.Stone[wall] || WallID.Sets.Conversion.Ice[wall] || WallID.Sets.Conversion.Sandstone[wall]) && wall != 1)
47326 {
47327 tile.wall = 1;
47328 SquareWallFrame(k, l);
47330 }
47331 else if ((WallID.Sets.Conversion.HardenedSand[wall] || WallID.Sets.Conversion.Snow[wall] || WallID.Sets.Conversion.Dirt[wall]) && wall != 2)
47332 {
47333 tile.wall = 2;
47334 SquareWallFrame(k, l);
47336 }
47337 else if (WallID.Sets.Conversion.NewWall1[wall] && wall != 196)
47338 {
47339 tile.wall = 196;
47340 SquareWallFrame(k, l);
47342 }
47343 else if (WallID.Sets.Conversion.NewWall2[wall] && wall != 197)
47344 {
47345 tile.wall = 197;
47346 SquareWallFrame(k, l);
47348 }
47349 else if (WallID.Sets.Conversion.NewWall3[wall] && wall != 198)
47350 {
47351 tile.wall = 198;
47352 SquareWallFrame(k, l);
47354 }
47355 else if (WallID.Sets.Conversion.NewWall4[wall] && wall != 199)
47356 {
47357 tile.wall = 199;
47358 SquareWallFrame(k, l);
47360 }
47362 {
47363 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 1);
47364 tile.type = 1;
47365 SquareTileFrame(k, l);
47367 }
47368 else if (TileID.Sets.Conversion.GolfGrass[type] && type != 477)
47369 {
47370 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 477);
47371 tile.type = 477;
47372 SquareTileFrame(k, l);
47374 }
47375 else if (TileID.Sets.Conversion.Grass[type] && type != 2 && type != 477)
47376 {
47377 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 2);
47378 tile.type = 2;
47379 SquareTileFrame(k, l);
47381 }
47383 {
47384 int num2 = 0;
47385 if (TileIsExposedToAir(k, l))
47386 {
47387 num2 = 2;
47388 }
47389 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, num2);
47390 tile.type = (ushort)num2;
47391 SquareTileFrame(k, l);
47393 }
47394 else if (TileID.Sets.Conversion.Thorn[type] && type != 69)
47395 {
47396 KillTile(k, l);
47397 if (Main.netMode == 1)
47398 {
47399 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47400 }
47401 }
47402 continue;
47403 }
47404 if (tile.wall == 69 || tile.wall == 70 || tile.wall == 81)
47405 {
47406 if ((double)l < Main.worldSurface)
47407 {
47408 if (genRand.Next(10) == 0)
47409 {
47410 tile.wall = 65;
47411 }
47412 else
47413 {
47414 tile.wall = 63;
47415 }
47416 }
47417 else
47418 {
47419 tile.wall = 64;
47420 }
47421 SquareWallFrame(k, l);
47423 }
47424 else if (WallID.Sets.Conversion.Stone[wall] && wall != 1 && wall != 262 && wall != 274 && wall != 61 && wall != 185)
47425 {
47426 tile.wall = 1;
47427 SquareWallFrame(k, l);
47429 }
47430 else if (WallID.Sets.Conversion.Stone[wall] && wall == 262)
47431 {
47432 tile.wall = 61;
47433 SquareWallFrame(k, l);
47435 }
47436 else if (WallID.Sets.Conversion.Stone[wall] && wall == 274)
47437 {
47438 tile.wall = 185;
47439 SquareWallFrame(k, l);
47441 }
47442 if (WallID.Sets.Conversion.NewWall1[wall] && wall != 212)
47443 {
47444 tile.wall = 212;
47445 SquareWallFrame(k, l);
47447 }
47448 else if (WallID.Sets.Conversion.NewWall2[wall] && wall != 213)
47449 {
47450 tile.wall = 213;
47451 SquareWallFrame(k, l);
47453 }
47454 else if (WallID.Sets.Conversion.NewWall3[wall] && wall != 214)
47455 {
47456 tile.wall = 214;
47457 SquareWallFrame(k, l);
47459 }
47460 else if (WallID.Sets.Conversion.NewWall4[wall] && wall != 215)
47461 {
47462 tile.wall = 215;
47463 SquareWallFrame(k, l);
47465 }
47466 else if (tile.wall == 80)
47467 {
47468 if ((double)l < Main.worldSurface + 4.0 + (double)genRand.Next(3) || (double)l > ((double)Main.maxTilesY + Main.rockLayer) / 2.0 - 3.0 + (double)genRand.Next(3))
47469 {
47470 tile.wall = 15;
47471 SquareWallFrame(k, l);
47473 }
47474 else
47475 {
47476 tile.wall = 64;
47477 SquareWallFrame(k, l);
47479 }
47480 }
47481 else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 216)
47482 {
47483 tile.wall = 216;
47484 SquareWallFrame(k, l);
47486 }
47487 else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 187)
47488 {
47489 tile.wall = 187;
47490 SquareWallFrame(k, l);
47492 }
47493 if (tile.type == 492)
47494 {
47495 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 477);
47496 tile.type = 477;
47497 SquareTileFrame(k, l);
47499 }
47500 else if (TileID.Sets.Conversion.JungleGrass[type] && type != 60)
47501 {
47502 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 60);
47503 tile.type = 60;
47504 SquareTileFrame(k, l);
47506 }
47507 else if (TileID.Sets.Conversion.Grass[type] && type != 2 && type != 477)
47508 {
47509 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 2);
47510 tile.type = 2;
47511 SquareTileFrame(k, l);
47513 }
47514 else if (TileID.Sets.Conversion.Stone[type] && type != 1)
47515 {
47516 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 1);
47517 tile.type = 1;
47518 SquareTileFrame(k, l);
47520 }
47521 else if (TileID.Sets.Conversion.Sand[type] && type != 53)
47522 {
47523 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 53);
47524 tile.type = 53;
47525 SquareTileFrame(k, l);
47527 }
47528 else if (TileID.Sets.Conversion.HardenedSand[type] && type != 397)
47529 {
47530 tile.type = 397;
47531 SquareTileFrame(k, l);
47533 }
47534 else if (TileID.Sets.Conversion.Sandstone[type] && type != 396)
47535 {
47536 tile.type = 396;
47537 SquareTileFrame(k, l);
47539 }
47540 else if (TileID.Sets.Conversion.Ice[type] && type != 161)
47541 {
47542 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 161);
47543 tile.type = 161;
47544 SquareTileFrame(k, l);
47546 }
47548 {
47549 TryKillingTreesAboveIfTheyWouldBecomeInvalid(k, l, 60);
47550 tile.type = 60;
47551 SquareTileFrame(k, l);
47553 }
47554 else if (tile.type == 32 || Main.tile[k, l].type == 352)
47555 {
47556 KillTile(k, l);
47557 if (Main.netMode == 1)
47558 {
47559 NetMessage.SendData(17, -1, -1, null, 0, k, l);
47560 }
47561 }
47562 }
47563 }
47564 }
47565
47566 public static void CactusFrame(int i, int j)
47567 {
47568 try
47569 {
47570 int num = j;
47571 int num2 = i;
47572 if (CheckCactus(i, j))
47573 {
47574 return;
47575 }
47576 while (Main.tile[num2, num].active() && Main.tile[num2, num].type == 80)
47577 {
47578 num++;
47579 if (Main.tile[num2, num] == null)
47580 {
47581 return;
47582 }
47583 if (!Main.tile[num2, num].active() || Main.tile[num2, num].type != 80)
47584 {
47585 if (Main.tile[num2 - 1, num] != null && Main.tile[num2 - 1, num].active() && Main.tile[num2 - 1, num].type == 80 && Main.tile[num2 - 1, num - 1].active() && Main.tile[num2 - 1, num - 1].type == 80 && num2 >= i)
47586 {
47587 num2--;
47588 }
47589 if (Main.tile[num2 + 1, num] != null && Main.tile[num2 + 1, num].active() && Main.tile[num2 + 1, num].type == 80 && Main.tile[num2 + 1, num - 1].active() && Main.tile[num2 + 1, num - 1].type == 80 && num2 <= i)
47590 {
47591 num2++;
47592 }
47593 }
47594 }
47595 num--;
47596 int num3 = i - num2;
47597 num2 = i;
47598 num = j;
47599 if (Main.tile[i - 2, j] == null)
47600 {
47601 return;
47602 }
47603 int type = Main.tile[i - 2, j].type;
47604 if (Main.tile[i - 1, j] == null)
47605 {
47606 return;
47607 }
47608 int num4 = Main.tile[i - 1, j].type;
47609 if (Main.tile[i + 1, j] == null)
47610 {
47611 return;
47612 }
47613 int num5 = Main.tile[i + 1, j].type;
47614 if (Main.tile[i, j - 1] == null)
47615 {
47616 return;
47617 }
47618 int num6 = Main.tile[i, j - 1].type;
47619 if (num6 == 227)
47620 {
47621 num6 = 80;
47622 }
47623 int num7 = Main.tile[i, j + 1].type;
47624 int num8 = Main.tile[i - 1, j + 1].type;
47625 int num9 = Main.tile[i + 1, j + 1].type;
47626 if (!Main.tile[i - 1, j].active())
47627 {
47628 num4 = -1;
47629 }
47630 if (!Main.tile[i + 1, j].active())
47631 {
47632 num5 = -1;
47633 }
47634 if (!Main.tile[i, j - 1].active())
47635 {
47636 num6 = -1;
47637 }
47638 if (!Main.tile[i, j + 1].active())
47639 {
47640 num7 = -1;
47641 }
47642 if (!Main.tile[i - 1, j + 1].active())
47643 {
47644 num8 = -1;
47645 }
47646 if (!Main.tile[i + 1, j + 1].active())
47647 {
47648 num9 = -1;
47649 }
47650 short num10 = Main.tile[i, j].frameX;
47651 short num11 = Main.tile[i, j].frameY;
47652 switch (num3)
47653 {
47654 case 0:
47655 if (num6 != 80)
47656 {
47657 if (num4 == 80 && num5 == 80 && num8 != 80 && num9 != 80 && type != 80)
47658 {
47659 num10 = 90;
47660 num11 = 0;
47661 }
47662 else if (num4 == 80 && num8 != 80 && type != 80)
47663 {
47664 num10 = 72;
47665 num11 = 0;
47666 }
47667 else if (num5 == 80 && num9 != 80)
47668 {
47669 num10 = 18;
47670 num11 = 0;
47671 }
47672 else
47673 {
47674 num10 = 0;
47675 num11 = 0;
47676 }
47677 }
47678 else if (num4 == 80 && num5 == 80 && num8 != 80 && num9 != 80 && type != 80)
47679 {
47680 num10 = 90;
47681 num11 = 36;
47682 }
47683 else if (num4 == 80 && num8 != 80 && type != 80)
47684 {
47685 num10 = 72;
47686 num11 = 36;
47687 }
47688 else if (num5 == 80 && num9 != 80)
47689 {
47690 num10 = 18;
47691 num11 = 36;
47692 }
47693 else if (num7 >= 0 && Main.tileSolid[num7])
47694 {
47695 num10 = 0;
47696 num11 = 36;
47697 }
47698 else
47699 {
47700 num10 = 0;
47701 num11 = 18;
47702 }
47703 break;
47704 case -1:
47705 if (num5 == 80)
47706 {
47707 if (num6 != 80 && num7 != 80)
47708 {
47709 num10 = 108;
47710 num11 = 36;
47711 }
47712 else if (num7 != 80)
47713 {
47714 num10 = 54;
47715 num11 = 36;
47716 }
47717 else if (num6 != 80)
47718 {
47719 num10 = 54;
47720 num11 = 0;
47721 }
47722 else
47723 {
47724 num10 = 54;
47725 num11 = 18;
47726 }
47727 }
47728 else if (num6 != 80)
47729 {
47730 num10 = 54;
47731 num11 = 0;
47732 }
47733 else
47734 {
47735 num10 = 54;
47736 num11 = 18;
47737 }
47738 break;
47739 case 1:
47740 if (num4 == 80)
47741 {
47742 if (num6 != 80 && num7 != 80)
47743 {
47744 num10 = 108;
47745 num11 = 18;
47746 }
47747 else if (num7 != 80)
47748 {
47749 num10 = 36;
47750 num11 = 36;
47751 }
47752 else if (num6 != 80)
47753 {
47754 num10 = 36;
47755 num11 = 0;
47756 }
47757 else
47758 {
47759 num10 = 36;
47760 num11 = 18;
47761 }
47762 }
47763 else if (num6 != 80)
47764 {
47765 num10 = 36;
47766 num11 = 0;
47767 }
47768 else
47769 {
47770 num10 = 36;
47771 num11 = 18;
47772 }
47773 break;
47774 }
47775 if (num10 != Main.tile[i, j].frameX || num11 != Main.tile[i, j].frameY)
47776 {
47777 Main.tile[i, j].frameX = num10;
47778 Main.tile[i, j].frameY = num11;
47779 DiamondTileFrame(i, j);
47780 }
47781 }
47782 catch
47783 {
47784 Main.tile[i, j].frameX = 0;
47785 Main.tile[i, j].frameY = 0;
47786 }
47787 }
47788
47789 public static void GrowCactus(int i, int j)
47790 {
47791 int num = j;
47792 int num2 = i;
47793 if (!Main.tile[i, j].nactive() || Main.tile[i, j].halfBrick() || (!gen && Main.tile[i, j].slope() != 0) || Main.tile[i, j - 1].liquid > 0 || (Main.tile[i, j].type != 53 && Main.tile[i, j].type != 80 && Main.tile[i, j].type != 234 && Main.tile[i, j].type != 112 && Main.tile[i, j].type != 116))
47794 {
47795 return;
47796 }
47797 int num3 = 0;
47798 for (int k = i - cactusWaterWidth; k < i + cactusWaterWidth; k++)
47799 {
47800 for (int l = j - cactusWaterHeight; l < j + cactusWaterHeight; l++)
47801 {
47802 num3 += Main.tile[k, l].liquid;
47803 }
47804 }
47805 if ((!Main.remixWorld || !((double)j > Main.worldSurface)) && num3 / 255 > cactusWaterLimit)
47806 {
47807 return;
47808 }
47809 if (Main.tile[i, j].type == 53 || Main.tile[i, j].type == 112 || Main.tile[i, j].type == 116 || Main.tile[i, j].type == 234)
47810 {
47811 if (Main.tile[i, j - 1].active() || Main.tile[i - 1, j - 1].active() || Main.tile[i + 1, j - 1].active())
47812 {
47813 return;
47814 }
47815 int num4 = 0;
47816 int num5 = 0;
47817 for (int m = i - 6; m <= i + 6; m++)
47818 {
47819 for (int n = j - 3; n <= j + 1; n++)
47820 {
47821 try
47822 {
47823 if (!Main.tile[m, n].active())
47824 {
47825 continue;
47826 }
47827 if (Main.tile[m, n].type == 80)
47828 {
47829 num4++;
47830 if (num4 >= 4)
47831 {
47832 return;
47833 }
47834 }
47835 if (Main.tile[m, n].type == 53 || Main.tile[m, n].type == 112 || Main.tile[m, n].type == 116 || Main.tile[m, n].type == 234)
47836 {
47837 num5++;
47838 }
47839 }
47840 catch
47841 {
47842 }
47843 }
47844 }
47845 if (num5 > 10)
47846 {
47847 if (gen && genRand.Next(2) == 0)
47848 {
47849 Main.tile[i, j].slope(0);
47850 }
47851 Main.tile[i, j - 1].active(active: true);
47852 Main.tile[i, j - 1].type = 80;
47853 if (Main.netMode == 2)
47854 {
47855 NetMessage.SendTileSquare(-1, i, j - 1);
47856 }
47857 SquareTileFrame(num2, num - 1);
47858 }
47859 }
47860 else
47861 {
47862 if (Main.tile[i, j].type != 80)
47863 {
47864 return;
47865 }
47866 while (Main.tile[num2, num].active() && Main.tile[num2, num].type == 80)
47867 {
47868 num++;
47869 if (!Main.tile[num2, num].active() || Main.tile[num2, num].type != 80)
47870 {
47871 if (Main.tile[num2 - 1, num].active() && Main.tile[num2 - 1, num].type == 80 && Main.tile[num2 - 1, num - 1].active() && Main.tile[num2 - 1, num - 1].type == 80 && num2 >= i)
47872 {
47873 num2--;
47874 }
47875 if (Main.tile[num2 + 1, num].active() && Main.tile[num2 + 1, num].type == 80 && Main.tile[num2 + 1, num - 1].active() && Main.tile[num2 + 1, num - 1].type == 80 && num2 <= i)
47876 {
47877 num2++;
47878 }
47879 }
47880 }
47881 num--;
47882 int num6 = num - j;
47883 int num7 = i - num2;
47884 num2 = i - num7;
47885 num = j;
47886 int num8 = 11 - num6;
47887 int num9 = 0;
47888 for (int num10 = num2 - 2; num10 <= num2 + 2; num10++)
47889 {
47890 for (int num11 = num - num8; num11 <= num + num6; num11++)
47891 {
47892 if (Main.tile[num10, num11].active() && Main.tile[num10, num11].type == 80)
47893 {
47894 num9++;
47895 }
47896 }
47897 }
47898 if (Main.drunkWorld)
47899 {
47900 if (num9 >= genRand.Next(11, 20))
47901 {
47902 return;
47903 }
47904 }
47905 else if (num9 >= genRand.Next(11, 13))
47906 {
47907 return;
47908 }
47909 num2 = i;
47910 num = j;
47911 if (num7 == 0)
47912 {
47913 if (num6 == 0)
47914 {
47915 if (!Main.tile[num2, num - 1].active())
47916 {
47917 Main.tile[num2, num - 1].active(active: true);
47918 Main.tile[num2, num - 1].type = 80;
47919 SquareTileFrame(num2, num - 1);
47920 if (Main.netMode == 2)
47921 {
47922 NetMessage.SendTileSquare(-1, num2, num - 1);
47923 }
47924 }
47925 return;
47926 }
47927 bool flag = false;
47928 bool flag2 = false;
47929 if (Main.tile[num2, num - 1].active() && Main.tile[num2, num - 1].type == 80)
47930 {
47931 if (!Main.tile[num2 - 1, num].active() && !Main.tile[num2 - 2, num + 1].active() && !Main.tile[num2 - 1, num - 1].active() && !Main.tile[num2 - 1, num + 1].active() && !Main.tile[num2 - 2, num].active())
47932 {
47933 flag = true;
47934 }
47935 if (!Main.tile[num2 + 1, num].active() && !Main.tile[num2 + 2, num + 1].active() && !Main.tile[num2 + 1, num - 1].active() && !Main.tile[num2 + 1, num + 1].active() && !Main.tile[num2 + 2, num].active())
47936 {
47937 flag2 = true;
47938 }
47939 }
47940 int num12 = genRand.Next(3);
47941 if (num12 == 0 && flag)
47942 {
47943 Main.tile[num2 - 1, num].active(active: true);
47944 Main.tile[num2 - 1, num].type = 80;
47945 SquareTileFrame(num2 - 1, num);
47946 if (Main.netMode == 2)
47947 {
47948 NetMessage.SendTileSquare(-1, num2 - 1, num);
47949 }
47950 }
47951 else if (num12 == 1 && flag2)
47952 {
47953 Main.tile[num2 + 1, num].active(active: true);
47954 Main.tile[num2 + 1, num].type = 80;
47955 SquareTileFrame(num2 + 1, num);
47956 if (Main.netMode == 2)
47957 {
47958 NetMessage.SendTileSquare(-1, num2 + 1, num);
47959 }
47960 }
47961 else
47962 {
47963 if (num6 >= genRand.Next(2, 8))
47964 {
47965 return;
47966 }
47967 if (Main.tile[num2 - 1, num - 1].active())
47968 {
47969 _ = Main.tile[num2 - 1, num - 1].type;
47970 _ = 80;
47971 }
47972 if ((!Main.tile[num2 + 1, num - 1].active() || Main.tile[num2 + 1, num - 1].type != 80) && !Main.tile[num2, num - 1].active())
47973 {
47974 Main.tile[num2, num - 1].active(active: true);
47975 Main.tile[num2, num - 1].type = 80;
47976 SquareTileFrame(num2, num - 1);
47977 if (Main.netMode == 2)
47978 {
47979 NetMessage.SendTileSquare(-1, num2, num - 1);
47980 }
47981 }
47982 }
47983 }
47984 else if (!Main.tile[num2, num - 1].active() && !Main.tile[num2, num - 2].active() && !Main.tile[num2 + num7, num - 1].active() && Main.tile[num2 - num7, num - 1].active() && Main.tile[num2 - num7, num - 1].type == 80)
47985 {
47986 Main.tile[num2, num - 1].active(active: true);
47987 Main.tile[num2, num - 1].type = 80;
47988 SquareTileFrame(num2, num - 1);
47989 if (Main.netMode == 2)
47990 {
47991 NetMessage.SendTileSquare(-1, num2, num - 1);
47992 }
47993 }
47994 }
47995 }
47996
47997 public static void CheckPot(int i, int j, int type = 28)
47998 {
47999 if (destroyObject)
48000 {
48001 return;
48002 }
48003 bool flag = false;
48004 int num = 0;
48005 int num2 = j;
48006 for (num += Main.tile[i, j].frameX / 18; num > 1; num -= 2)
48007 {
48008 }
48009 num *= -1;
48010 num += i;
48011 int num3 = Main.tile[i, j].frameY / 18;
48012 int num4 = 0;
48013 while (num3 > 1)
48014 {
48015 num3 -= 2;
48016 num4++;
48017 }
48018 num2 -= num3;
48019 for (int k = num; k < num + 2; k++)
48020 {
48021 for (int l = num2; l < num2 + 2; l++)
48022 {
48023 if (Main.tile[k, l] == null)
48024 {
48025 Main.tile[k, l] = new Tile();
48026 }
48027 int num5;
48028 for (num5 = Main.tile[k, l].frameX / 18; num5 > 1; num5 -= 2)
48029 {
48030 }
48031 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || num5 != k - num || Main.tile[k, l].frameY != (l - num2) * 18 + num4 * 36)
48032 {
48033 flag = true;
48034 }
48035 }
48036 if (Main.tile[k, num2 + 2] == null)
48037 {
48038 Main.tile[k, num2 + 2] = new Tile();
48039 }
48040 if (!SolidTile2(k, num2 + 2))
48041 {
48042 flag = true;
48043 }
48044 }
48045 if (!flag)
48046 {
48047 return;
48048 }
48049 destroyObject = true;
48050 if (num4 >= 7 && num4 <= 9)
48051 {
48052 SoundEngine.PlaySound(6, i * 16, j * 16);
48053 }
48054 else if (num4 >= 16 && num4 <= 24)
48055 {
48056 SoundEngine.PlaySound(4, i * 16, j * 16);
48057 }
48058 else
48059 {
48060 SoundEngine.PlaySound(13, i * 16, j * 16);
48061 }
48062 for (int m = num; m < num + 2; m++)
48063 {
48064 for (int n = num2; n < num2 + 2; n++)
48065 {
48066 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
48067 {
48068 KillTile(m, n);
48069 }
48070 }
48071 }
48072 switch (num4)
48073 {
48074 case 0:
48075 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 51);
48076 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 52);
48077 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 53);
48078 break;
48079 case 1:
48080 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 166);
48081 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 167);
48082 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 168);
48083 break;
48084 case 2:
48085 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 169);
48086 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 170);
48087 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 171);
48088 break;
48089 case 3:
48090 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 172);
48091 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 173);
48092 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 174);
48093 break;
48094 case 4:
48095 case 5:
48096 case 6:
48097 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 197);
48098 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 198);
48099 break;
48100 default:
48101 if (num4 >= 7 && num4 <= 9)
48102 {
48103 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 199);
48104 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 200);
48105 }
48106 else if (num4 >= 10 && num4 <= 12)
48107 {
48108 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 201);
48109 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 202);
48110 }
48111 else if (num4 >= 13 && num4 <= 15)
48112 {
48113 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 203);
48114 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 204);
48115 }
48116 else
48117 {
48118 if ((num4 >= 16 && num4 <= 18) || (num4 >= 19 && num4 <= 21) || (num4 >= 22 && num4 <= 24))
48119 {
48120 break;
48121 }
48122 if (num4 >= 25 && num4 <= 27)
48123 {
48124 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), genRand.Next(217, 220));
48125 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), genRand.Next(217, 220));
48126 }
48127 else if (num4 >= 28 && num4 <= 30)
48128 {
48129 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), genRand.Next(315, 317));
48130 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), genRand.Next(315, 317));
48131 }
48132 else if (num4 >= 31 && num4 <= 33)
48133 {
48134 int num6 = genRand.Next(2, 5);
48135 for (int num7 = 0; num7 < num6; num7++)
48136 {
48137 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 698 + genRand.Next(6));
48138 }
48139 }
48140 else if (num4 >= 34 && num4 <= 36)
48141 {
48142 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 1122);
48143 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 1123);
48144 Gore.NewGore(new Vector2(i * 16, j * 16), default(Vector2), 1124);
48145 }
48146 }
48147 break;
48148 }
48149 if (Main.netMode != 1 && type != 653)
48150 {
48151 SpawnThingsFromPot(i, j, num, num2, num4);
48152 }
48153 destroyObject = false;
48154 }
48155
48156 private static void SpawnThingsFromPot(int i, int j, int x2, int y2, int style)
48157 {
48158 bool flag = (double)j < Main.rockLayer;
48159 bool flag2 = j < Main.UnderworldLayer;
48160 if (Main.remixWorld)
48161 {
48162 flag = (double)j > Main.rockLayer && j < Main.UnderworldLayer;
48163 flag2 = (double)j > Main.worldSurface && (double)j < Main.rockLayer;
48164 }
48165 float num = 1f;
48166 bool flag3 = style >= 34 && style <= 36;
48167 switch (style)
48168 {
48169 case 4:
48170 case 5:
48171 case 6:
48172 num = 1.25f;
48173 break;
48174 default:
48175 if (style >= 7 && style <= 9)
48176 {
48177 num = 1.75f;
48178 }
48179 else if (style >= 10 && style <= 12)
48180 {
48181 num = 1.9f;
48182 }
48183 else if (style >= 13 && style <= 15)
48184 {
48185 num = 2.1f;
48186 }
48187 else if (style >= 16 && style <= 18)
48188 {
48189 num = 1.6f;
48190 }
48191 else if (style >= 19 && style <= 21)
48192 {
48193 num = 3.5f;
48194 }
48195 else if (style >= 22 && style <= 24)
48196 {
48197 num = 1.6f;
48198 }
48199 else if (style >= 25 && style <= 27)
48200 {
48201 num = 10f;
48202 }
48203 else if (style >= 28 && style <= 30)
48204 {
48205 if (Main.hardMode)
48206 {
48207 num = 4f;
48208 }
48209 }
48210 else if (style >= 31 && style <= 33)
48211 {
48212 num = 2f;
48213 }
48214 else if (style >= 34 && style <= 36)
48215 {
48216 num = 1.25f;
48217 }
48218 break;
48219 case 0:
48220 case 1:
48221 case 2:
48222 case 3:
48223 break;
48224 }
48225 num = (num * 2f + 1f) / 3f;
48226 int range = (int)(500f / ((num + 1f) / 2f));
48227 if (gen)
48228 {
48229 return;
48230 }
48231 if (Player.GetClosestRollLuck(i, j, range) == 0f)
48232 {
48233 if (Main.netMode != 1)
48234 {
48235 Projectile.NewProjectile(GetProjectileSource_TileBreak(i, j), i * 16 + 16, j * 16 + 16, 0f, -12f, 518, 0, 0f, Main.myPlayer);
48236 }
48237 return;
48238 }
48239 if (genRand.Next(35) == 0 && Main.wallDungeon[Main.tile[i, j].wall] && (double)j > Main.worldSurface)
48240 {
48241 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 327);
48242 return;
48243 }
48244 if (Main.getGoodWorld && genRand.Next(6) == 0)
48245 {
48246 Projectile.NewProjectile(GetProjectileSource_TileBreak(i, j), i * 16 + 16, j * 16 + 8, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, 28, 0, 0f, Main.myPlayer, 16f, 16f);
48247 return;
48248 }
48249 if (Main.remixWorld && Main.netMode != 1 && genRand.Next(5) == 0)
48250 {
48251 Player player = Main.player[Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)];
48252 if (Main.rand.Next(2) == 0)
48253 {
48254 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 75);
48255 }
48256 else if (player.ZoneJungle)
48257 {
48258 int num2 = -1;
48259 num2 = NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -10);
48260 if (num2 > -1)
48261 {
48262 Main.npc[num2].ai[1] = 75f;
48263 Main.npc[num2].netUpdate = true;
48264 }
48265 }
48266 else if ((double)j > Main.rockLayer && j < Main.maxTilesY - 350)
48267 {
48268 int num3 = -1;
48269 num3 = ((Main.rand.Next(9) == 0) ? NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -7) : ((Main.rand.Next(7) == 0) ? NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -8) : ((Main.rand.Next(6) == 0) ? NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -9) : ((Main.rand.Next(3) != 0) ? NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, 1) : NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -3)))));
48270 if (num3 > -1)
48271 {
48272 Main.npc[num3].ai[1] = 75f;
48273 Main.npc[num3].netUpdate = true;
48274 }
48275 }
48276 else if ((double)j > Main.worldSurface && (double)j <= Main.rockLayer)
48277 {
48278 int num4 = -1;
48279 num4 = NPC.NewNPC(NPC.GetSpawnSourceForNaturalSpawn(), x2 * 16 + 16, y2 * 16 + 32, -6);
48280 if (num4 > -1)
48281 {
48282 Main.npc[num4].ai[1] = 75f;
48283 Main.npc[num4].netUpdate = true;
48284 }
48285 }
48286 else
48287 {
48288 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 75);
48289 }
48290 return;
48291 }
48292 if (Main.remixWorld && (double)i > (double)Main.maxTilesX * 0.37 && (double)i < (double)Main.maxTilesX * 0.63 && j > Main.maxTilesY - 220)
48293 {
48294 int stack = Main.rand.Next(20, 41);
48295 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 965, stack);
48296 return;
48297 }
48298 if (genRand.Next(45) == 0 || (Main.rand.Next(45) == 0 && Main.expertMode))
48299 {
48300 if ((double)j < Main.worldSurface)
48301 {
48302 int num5 = genRand.Next(10);
48303 if (num5 == 0)
48304 {
48305 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 292);
48306 }
48307 if (num5 == 1)
48308 {
48309 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 298);
48310 }
48311 if (num5 == 2)
48312 {
48313 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 299);
48314 }
48315 if (num5 == 3)
48316 {
48317 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 290);
48318 }
48319 if (num5 == 4)
48320 {
48321 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2322);
48322 }
48323 if (num5 == 5)
48324 {
48325 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2324);
48326 }
48327 if (num5 == 6)
48328 {
48329 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2325);
48330 }
48331 if (num5 >= 7)
48332 {
48333 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2350, genRand.Next(1, 3));
48334 }
48335 }
48336 else if (flag)
48337 {
48338 int num6 = genRand.Next(11);
48339 if (num6 == 0)
48340 {
48341 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 289);
48342 }
48343 if (num6 == 1)
48344 {
48345 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 298);
48346 }
48347 if (num6 == 2)
48348 {
48349 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 299);
48350 }
48351 if (num6 == 3)
48352 {
48353 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 290);
48354 }
48355 if (num6 == 4)
48356 {
48357 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 303);
48358 }
48359 if (num6 == 5)
48360 {
48361 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 291);
48362 }
48363 if (num6 == 6)
48364 {
48365 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 304);
48366 }
48367 if (num6 == 7)
48368 {
48369 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2322);
48370 }
48371 if (num6 == 8)
48372 {
48373 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2329);
48374 }
48375 if (num6 >= 7)
48376 {
48377 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2350, genRand.Next(1, 3));
48378 }
48379 }
48380 else if (flag2)
48381 {
48382 int num7 = genRand.Next(15);
48383 if (num7 == 0)
48384 {
48385 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 296);
48386 }
48387 if (num7 == 1)
48388 {
48389 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 295);
48390 }
48391 if (num7 == 2)
48392 {
48393 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 299);
48394 }
48395 if (num7 == 3)
48396 {
48397 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 302);
48398 }
48399 if (num7 == 4)
48400 {
48401 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 303);
48402 }
48403 if (num7 == 5)
48404 {
48405 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 305);
48406 }
48407 if (num7 == 6)
48408 {
48409 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 301);
48410 }
48411 if (num7 == 7)
48412 {
48413 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 302);
48414 }
48415 if (num7 == 8)
48416 {
48417 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 297);
48418 }
48419 if (num7 == 9)
48420 {
48421 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 304);
48422 }
48423 if (num7 == 10)
48424 {
48425 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2322);
48426 }
48427 if (num7 == 11)
48428 {
48429 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2323);
48430 }
48431 if (num7 == 12)
48432 {
48433 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2327);
48434 }
48435 if (num7 == 13)
48436 {
48437 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2329);
48438 }
48439 if (num7 >= 7)
48440 {
48441 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2350, genRand.Next(1, 3));
48442 }
48443 }
48444 else
48445 {
48446 int num8 = genRand.Next(14);
48447 if (num8 == 0)
48448 {
48449 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 296);
48450 }
48451 if (num8 == 1)
48452 {
48453 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 295);
48454 }
48455 if (num8 == 2)
48456 {
48457 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 293);
48458 }
48459 if (num8 == 3)
48460 {
48461 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 288);
48462 }
48463 if (num8 == 4)
48464 {
48465 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 294);
48466 }
48467 if (num8 == 5)
48468 {
48469 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 297);
48470 }
48471 if (num8 == 6)
48472 {
48473 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 304);
48474 }
48475 if (num8 == 7)
48476 {
48477 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 305);
48478 }
48479 if (num8 == 8)
48480 {
48481 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 301);
48482 }
48483 if (num8 == 9)
48484 {
48485 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 302);
48486 }
48487 if (num8 == 10)
48488 {
48489 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 288);
48490 }
48491 if (num8 == 11)
48492 {
48493 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 300);
48494 }
48495 if (num8 == 12)
48496 {
48497 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2323);
48498 }
48499 if (num8 == 13)
48500 {
48501 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2326);
48502 }
48503 if (genRand.Next(5) == 0)
48504 {
48505 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 4870);
48506 }
48507 }
48508 return;
48509 }
48510 if (Main.netMode == 2 && Main.rand.Next(30) == 0)
48511 {
48512 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 2997);
48513 return;
48514 }
48515 int num9 = Main.rand.Next(7);
48516 if (Main.expertMode)
48517 {
48518 num9--;
48519 }
48520 Player player2 = Main.player[Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)];
48521 int num10 = 0;
48522 int num11 = 20;
48523 for (int k = 0; k < 50; k++)
48524 {
48525 Item item = player2.inventory[k];
48526 if (!item.IsAir && item.createTile == 4)
48527 {
48528 num10 += item.stack;
48529 if (num10 >= num11)
48530 {
48531 break;
48532 }
48533 }
48534 }
48535 bool flag4 = num10 < num11;
48536 if (num9 == 0 && player2.statLife < player2.statLifeMax2)
48537 {
48538 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 58);
48539 if (Main.rand.Next(2) == 0)
48540 {
48541 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 58);
48542 }
48543 if (Main.expertMode)
48544 {
48545 if (Main.rand.Next(2) == 0)
48546 {
48547 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 58);
48548 }
48549 if (Main.rand.Next(2) == 0)
48550 {
48551 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 58);
48552 }
48553 }
48554 return;
48555 }
48556 if (num9 == 1 || (num9 == 0 && flag4))
48557 {
48558 int num12 = Main.rand.Next(2, 7);
48559 if (Main.expertMode)
48560 {
48561 num12 += Main.rand.Next(1, 7);
48562 }
48563 int type = 8;
48564 int type2 = 282;
48565 if (player2.ZoneHallow)
48566 {
48567 num12 += Main.rand.Next(2, 7);
48568 type = 4387;
48569 }
48570 else if ((style >= 22 && style <= 24) || player2.ZoneCrimson)
48571 {
48572 num12 += Main.rand.Next(2, 7);
48573 type = 4386;
48574 }
48575 else if ((style >= 16 && style <= 18) || player2.ZoneCorrupt)
48576 {
48577 num12 += Main.rand.Next(2, 7);
48578 type = 4385;
48579 }
48580 else if (style >= 7 && style <= 9)
48581 {
48582 num12 += Main.rand.Next(2, 7);
48583 num12 = (int)((float)num12 * 1.5f);
48584 type = 4388;
48585 }
48586 else if (style >= 4 && style <= 6)
48587 {
48588 type = 974;
48589 type2 = 286;
48590 }
48591 else if (style >= 34 && style <= 36)
48592 {
48593 num12 += Main.rand.Next(2, 7);
48594 type = 4383;
48595 }
48596 else if (player2.ZoneGlowshroom)
48597 {
48598 num12 += Main.rand.Next(2, 7);
48599 type = 5293;
48600 }
48601 if (Main.tile[i, j].liquid > 0)
48602 {
48603 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, type2, num12);
48604 }
48605 else
48606 {
48607 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, type, num12);
48608 }
48609 return;
48610 }
48611 switch (num9)
48612 {
48613 case 2:
48614 {
48615 int stack2 = Main.rand.Next(10, 21);
48616 int type4 = 40;
48617 if (flag && genRand.Next(2) == 0)
48618 {
48619 type4 = ((!Main.hardMode) ? 42 : 168);
48620 }
48621 if (j > Main.UnderworldLayer)
48622 {
48623 type4 = 265;
48624 }
48625 else if (Main.hardMode)
48626 {
48627 type4 = ((Main.rand.Next(2) != 0) ? 47 : ((SavedOreTiers.Silver != 168) ? 278 : 4915));
48628 }
48629 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, type4, stack2);
48630 return;
48631 }
48632 case 3:
48633 {
48634 int type5 = 28;
48636 {
48637 type5 = 188;
48638 }
48639 int num14 = 1;
48640 if (Main.expertMode && Main.rand.Next(3) != 0)
48641 {
48642 num14++;
48643 }
48644 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, type5, num14);
48645 return;
48646 }
48647 case 4:
48648 if (flag3 || flag2)
48649 {
48650 int type3 = 166;
48651 if (flag3)
48652 {
48653 type3 = 4423;
48654 }
48655 int num13 = Main.rand.Next(4) + 1;
48656 if (Main.expertMode)
48657 {
48658 num13 += Main.rand.Next(4);
48659 }
48660 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, type3, num13);
48661 return;
48662 }
48663 break;
48664 }
48665 if ((num9 == 4 || num9 == 5) && j < Main.UnderworldLayer && !Main.hardMode)
48666 {
48667 int stack3 = Main.rand.Next(20, 41);
48668 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 965, stack3);
48669 return;
48670 }
48671 float num15 = 200 + genRand.Next(-100, 101);
48672 if ((double)j < Main.worldSurface)
48673 {
48674 num15 *= 0.5f;
48675 }
48676 else if (flag)
48677 {
48678 num15 *= 0.75f;
48679 }
48680 else if (j > Main.maxTilesY - 250)
48681 {
48682 num15 *= 1.25f;
48683 }
48684 num15 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
48685 if (Main.rand.Next(4) == 0)
48686 {
48687 num15 *= 1f + (float)Main.rand.Next(5, 11) * 0.01f;
48688 }
48689 if (Main.rand.Next(8) == 0)
48690 {
48691 num15 *= 1f + (float)Main.rand.Next(10, 21) * 0.01f;
48692 }
48693 if (Main.rand.Next(12) == 0)
48694 {
48695 num15 *= 1f + (float)Main.rand.Next(20, 41) * 0.01f;
48696 }
48697 if (Main.rand.Next(16) == 0)
48698 {
48699 num15 *= 1f + (float)Main.rand.Next(40, 81) * 0.01f;
48700 }
48701 if (Main.rand.Next(20) == 0)
48702 {
48703 num15 *= 1f + (float)Main.rand.Next(50, 101) * 0.01f;
48704 }
48705 if (Main.expertMode)
48706 {
48707 num15 *= 2.5f;
48708 }
48709 if (Main.expertMode && Main.rand.Next(2) == 0)
48710 {
48711 num15 *= 1.25f;
48712 }
48713 if (Main.expertMode && Main.rand.Next(3) == 0)
48714 {
48715 num15 *= 1.5f;
48716 }
48717 if (Main.expertMode && Main.rand.Next(4) == 0)
48718 {
48719 num15 *= 1.75f;
48720 }
48721 num15 *= num;
48722 if (NPC.downedBoss1)
48723 {
48724 num15 *= 1.1f;
48725 }
48726 if (NPC.downedBoss2)
48727 {
48728 num15 *= 1.1f;
48729 }
48730 if (NPC.downedBoss3)
48731 {
48732 num15 *= 1.1f;
48733 }
48734 if (NPC.downedMechBoss1)
48735 {
48736 num15 *= 1.1f;
48737 }
48738 if (NPC.downedMechBoss2)
48739 {
48740 num15 *= 1.1f;
48741 }
48742 if (NPC.downedMechBoss3)
48743 {
48744 num15 *= 1.1f;
48745 }
48746 if (NPC.downedPlantBoss)
48747 {
48748 num15 *= 1.1f;
48749 }
48750 if (NPC.downedQueenBee)
48751 {
48752 num15 *= 1.1f;
48753 }
48754 if (NPC.downedGolemBoss)
48755 {
48756 num15 *= 1.1f;
48757 }
48758 if (NPC.downedPirates)
48759 {
48760 num15 *= 1.1f;
48761 }
48762 if (NPC.downedGoblins)
48763 {
48764 num15 *= 1.1f;
48765 }
48766 if (NPC.downedFrost)
48767 {
48768 num15 *= 1.1f;
48769 }
48770 while ((int)num15 > 0)
48771 {
48772 if (num15 > 1000000f)
48773 {
48774 int num16 = (int)(num15 / 1000000f);
48775 if (num16 > 50 && Main.rand.Next(2) == 0)
48776 {
48777 num16 /= Main.rand.Next(3) + 1;
48778 }
48779 if (Main.rand.Next(2) == 0)
48780 {
48781 num16 /= Main.rand.Next(3) + 1;
48782 }
48783 num15 -= (float)(1000000 * num16);
48784 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 74, num16);
48785 continue;
48786 }
48787 if (num15 > 10000f)
48788 {
48789 int num17 = (int)(num15 / 10000f);
48790 if (num17 > 50 && Main.rand.Next(2) == 0)
48791 {
48792 num17 /= Main.rand.Next(3) + 1;
48793 }
48794 if (Main.rand.Next(2) == 0)
48795 {
48796 num17 /= Main.rand.Next(3) + 1;
48797 }
48798 num15 -= (float)(10000 * num17);
48799 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 73, num17);
48800 continue;
48801 }
48802 if (num15 > 100f)
48803 {
48804 int num18 = (int)(num15 / 100f);
48805 if (num18 > 50 && Main.rand.Next(2) == 0)
48806 {
48807 num18 /= Main.rand.Next(3) + 1;
48808 }
48809 if (Main.rand.Next(2) == 0)
48810 {
48811 num18 /= Main.rand.Next(3) + 1;
48812 }
48813 num15 -= (float)(100 * num18);
48814 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 72, num18);
48815 continue;
48816 }
48817 int num19 = (int)num15;
48818 if (num19 > 50 && Main.rand.Next(2) == 0)
48819 {
48820 num19 /= Main.rand.Next(3) + 1;
48821 }
48822 if (Main.rand.Next(2) == 0)
48823 {
48824 num19 /= Main.rand.Next(4) + 1;
48825 }
48826 if (num19 < 1)
48827 {
48828 num19 = 1;
48829 }
48830 num15 -= (float)num19;
48831 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 71, num19);
48832 }
48833 }
48834
48835 public static int PlaceChest(int x, int y, ushort type = 21, bool notNearOtherChests = false, int style = 0)
48836 {
48837 int num = -1;
48838 if (TileID.Sets.Boulders[Main.tile[x, y + 1].type] || TileID.Sets.Boulders[Main.tile[x + 1, y + 1].type])
48839 {
48840 return -1;
48841 }
48842 if (TileObject.CanPlace(x, y, type, style, 1, out var objectData))
48843 {
48844 bool flag = true;
48845 if (notNearOtherChests && Chest.NearOtherChests(x - 1, y - 1))
48846 {
48847 flag = false;
48848 }
48849 if (flag)
48850 {
48852 num = Chest.CreateChest(objectData.xCoord, objectData.yCoord);
48853 }
48854 }
48855 else
48856 {
48857 num = -1;
48858 }
48859 if (num != -1 && Main.netMode == 1 && type == 21)
48860 {
48861 NetMessage.SendData(34, -1, -1, null, 0, x, y, style);
48862 }
48863 if (num != -1 && Main.netMode == 1 && type == 467)
48864 {
48865 NetMessage.SendData(34, -1, -1, null, 4, x, y, style);
48866 }
48867 return num;
48868 }
48869
48870 public static void PlaceChestDirect(int x, int y, ushort type, int style, int id)
48871 {
48872 Chest.CreateChest(x, y - 1, id);
48873 for (int i = 0; i <= 1; i++)
48874 {
48875 for (int j = -1; j <= 0; j++)
48876 {
48877 if (Main.tile[x + i, y + j] == null)
48878 {
48879 Main.tile[x + i, y + j] = new Tile();
48880 }
48881 }
48882 }
48883 Main.tile[x, y - 1].active(active: true);
48884 Main.tile[x, y - 1].frameY = 0;
48885 Main.tile[x, y - 1].frameX = (short)(36 * style);
48886 Main.tile[x, y - 1].type = type;
48887 Main.tile[x, y - 1].halfBrick(halfBrick: false);
48888 Main.tile[x + 1, y - 1].active(active: true);
48889 Main.tile[x + 1, y - 1].frameY = 0;
48890 Main.tile[x + 1, y - 1].frameX = (short)(18 + 36 * style);
48891 Main.tile[x + 1, y - 1].type = type;
48892 Main.tile[x + 1, y - 1].halfBrick(halfBrick: false);
48893 Main.tile[x, y].active(active: true);
48894 Main.tile[x, y].frameY = 18;
48895 Main.tile[x, y].frameX = (short)(36 * style);
48896 Main.tile[x, y].type = type;
48897 Main.tile[x, y].halfBrick(halfBrick: false);
48898 Main.tile[x + 1, y].active(active: true);
48899 Main.tile[x + 1, y].frameY = 18;
48900 Main.tile[x + 1, y].frameX = (short)(18 + 36 * style);
48901 Main.tile[x + 1, y].type = type;
48902 Main.tile[x + 1, y].halfBrick(halfBrick: false);
48903 }
48904
48905 public static void PlaceDresserDirect(int x, int y, ushort type, int style, int id)
48906 {
48907 Chest.CreateChest(x - 1, y - 1, id);
48908 for (int i = -1; i <= 1; i++)
48909 {
48910 for (int j = -1; j <= 0; j++)
48911 {
48912 if (Main.tile[x + i, y + j] == null)
48913 {
48914 Main.tile[x + i, y + j] = new Tile();
48915 }
48916 }
48917 }
48918 short num = (short)(style * 54);
48919 Main.tile[x - 1, y - 1].active(active: true);
48920 Main.tile[x - 1, y - 1].frameY = 0;
48921 Main.tile[x - 1, y - 1].frameX = num;
48922 Main.tile[x - 1, y - 1].type = type;
48923 Main.tile[x, y - 1].active(active: true);
48924 Main.tile[x, y - 1].frameY = 0;
48925 Main.tile[x, y - 1].frameX = (short)(num + 18);
48926 Main.tile[x, y - 1].type = type;
48927 Main.tile[x + 1, y - 1].active(active: true);
48928 Main.tile[x + 1, y - 1].frameY = 0;
48929 Main.tile[x + 1, y - 1].frameX = (short)(num + 36);
48930 Main.tile[x + 1, y - 1].type = type;
48931 Main.tile[x - 1, y].active(active: true);
48932 Main.tile[x - 1, y].frameY = 18;
48933 Main.tile[x - 1, y].frameX = num;
48934 Main.tile[x - 1, y].type = type;
48935 Main.tile[x, y].active(active: true);
48936 Main.tile[x, y].frameY = 18;
48937 Main.tile[x, y].frameX = (short)(num + 18);
48938 Main.tile[x, y].type = type;
48939 Main.tile[x + 1, y].active(active: true);
48940 Main.tile[x + 1, y].frameY = 18;
48941 Main.tile[x + 1, y].frameX = (short)(num + 36);
48942 Main.tile[x + 1, y].type = type;
48943 }
48944
48945 public static void CheckChest(int i, int j, int type)
48946 {
48947 if (destroyObject)
48948 {
48949 return;
48950 }
48951 bool flag = false;
48952 int num = 0;
48953 int num2 = j;
48954 num += Main.tile[i, j].frameX / 18;
48955 num2 += Main.tile[i, j].frameY / 18 * -1;
48956 while (num > 1)
48957 {
48958 num -= 2;
48959 }
48960 num *= -1;
48961 num += i;
48962 for (int k = num; k < num + 2; k++)
48963 {
48964 for (int l = num2; l < num2 + 2; l++)
48965 {
48966 if (Main.tile[k, l] == null)
48967 {
48968 Main.tile[k, l] = new Tile();
48969 }
48970 int num3;
48971 for (num3 = Main.tile[k, l].frameX / 18; num3 > 1; num3 -= 2)
48972 {
48973 }
48974 if (!Main.tile[k, l].active() || Main.tile[k, l].type != type || num3 != k - num || Main.tile[k, l].frameY != (l - num2) * 18)
48975 {
48976 flag = true;
48977 }
48978 }
48979 if (Main.tile[k, num2 + 2] == null)
48980 {
48981 Main.tile[k, num2 + 2] = new Tile();
48982 }
48983 if ((!Main.tile[k, num2 + 2].active() || !Main.tileSolid[Main.tile[k, num2 + 2].type]) && Chest.CanDestroyChest(num, num2))
48984 {
48985 flag = true;
48986 }
48987 }
48988 if (!flag)
48989 {
48990 return;
48991 }
48992 int chestItemDrop = GetChestItemDrop(i, j, type);
48993 destroyObject = true;
48994 for (int m = num; m < num + 2; m++)
48995 {
48996 for (int n = num2; n < num2 + 3; n++)
48997 {
48998 if (Main.tile[m, n].type == type && Main.tile[m, n].active())
48999 {
49001 KillTile(m, n);
49002 }
49003 }
49004 }
49005 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 32, 32, chestItemDrop);
49006 destroyObject = false;
49007 }
49008
49009 private static int GetChestItemDrop(int x, int y, int type)
49010 {
49011 int num = Main.tile[x, y].frameX / 36;
49012 if (type == 467)
49013 {
49014 return Chest.chestItemSpawn2[num];
49015 }
49016 return Chest.chestItemSpawn[num];
49017 }
49018
49019 public static bool PlaceActuator(int i, int j)
49020 {
49021 if (!Main.tile[i, j].actuator())
49022 {
49023 SoundEngine.PlaySound(0, i * 16, j * 16);
49024 Main.tile[i, j].actuator(actuator: true);
49025 return true;
49026 }
49027 return false;
49028 }
49029
49030 public static bool KillActuator(int i, int j)
49031 {
49032 if (Main.tile[i, j].actuator())
49033 {
49034 SoundEngine.PlaySound(0, i * 16, j * 16);
49035 Main.tile[i, j].actuator(actuator: false);
49036 if (Main.netMode != 1)
49037 {
49038 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 849);
49039 }
49040 for (int k = 0; k < 5; k++)
49041 {
49042 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 50);
49043 }
49044 return true;
49045 }
49046 return false;
49047 }
49048
49049 public static bool PlaceWire(int i, int j)
49050 {
49051 if (!Main.tile[i, j].wire())
49052 {
49053 SoundEngine.PlaySound(0, i * 16, j * 16);
49054 Main.tile[i, j].wire(wire: true);
49055 return true;
49056 }
49057 return false;
49058 }
49059
49060 public static bool KillWire(int i, int j)
49061 {
49062 if (Main.tile[i, j].wire())
49063 {
49064 SoundEngine.PlaySound(0, i * 16, j * 16);
49065 Main.tile[i, j].wire(wire: false);
49066 if (Main.netMode != 1)
49067 {
49068 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 530);
49069 }
49070 for (int k = 0; k < 5; k++)
49071 {
49072 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 50);
49073 }
49074 return true;
49075 }
49076 return false;
49077 }
49078
49079 public static bool PlaceWire2(int i, int j)
49080 {
49081 if (!Main.tile[i, j].wire2())
49082 {
49083 SoundEngine.PlaySound(0, i * 16, j * 16);
49084 Main.tile[i, j].wire2(wire2: true);
49085 return true;
49086 }
49087 return false;
49088 }
49089
49090 public static bool KillWire2(int i, int j)
49091 {
49092 if (Main.tile[i, j].wire2())
49093 {
49094 SoundEngine.PlaySound(0, i * 16, j * 16);
49095 Main.tile[i, j].wire2(wire2: false);
49096 if (Main.netMode != 1)
49097 {
49098 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 530);
49099 }
49100 for (int k = 0; k < 5; k++)
49101 {
49102 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 50);
49103 }
49104 return true;
49105 }
49106 return false;
49107 }
49108
49109 public static bool PlaceWire3(int i, int j)
49110 {
49111 if (!Main.tile[i, j].wire3())
49112 {
49113 SoundEngine.PlaySound(0, i * 16, j * 16);
49114 Main.tile[i, j].wire3(wire3: true);
49115 return true;
49116 }
49117 return false;
49118 }
49119
49120 public static bool KillWire3(int i, int j)
49121 {
49122 if (Main.tile[i, j].wire3())
49123 {
49124 SoundEngine.PlaySound(0, i * 16, j * 16);
49125 Main.tile[i, j].wire3(wire3: false);
49126 if (Main.netMode != 1)
49127 {
49128 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 530);
49129 }
49130 for (int k = 0; k < 5; k++)
49131 {
49132 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 50);
49133 }
49134 return true;
49135 }
49136 return false;
49137 }
49138
49139 public static bool PlaceWire4(int i, int j)
49140 {
49141 if (!Main.tile[i, j].wire4())
49142 {
49143 SoundEngine.PlaySound(0, i * 16, j * 16);
49144 Main.tile[i, j].wire4(wire4: true);
49145 return true;
49146 }
49147 return false;
49148 }
49149
49150 public static bool KillWire4(int i, int j)
49151 {
49152 if (Main.tile[i, j].wire4())
49153 {
49154 SoundEngine.PlaySound(0, i * 16, j * 16);
49155 Main.tile[i, j].wire4(wire4: false);
49156 if (Main.netMode != 1)
49157 {
49158 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, 530);
49159 }
49160 for (int k = 0; k < 5; k++)
49161 {
49162 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 50);
49163 }
49164 return true;
49165 }
49166 return false;
49167 }
49168
49169 public static bool IsFitToPlaceFlowerIn(int x, int y, int typeAttemptedToPlace)
49170 {
49171 if (y < 1 || y > Main.maxTilesY - 1)
49172 {
49173 return false;
49174 }
49175 Tile tile = Main.tile[x, y + 1];
49176 if (tile.active() && tile.slope() == 0 && !tile.halfBrick())
49177 {
49178 if (((tile.type != 2 && tile.type != 78 && tile.type != 380 && tile.type != 477 && tile.type != 579) || typeAttemptedToPlace != 3) && ((tile.type != 23 && tile.type != 661) || typeAttemptedToPlace != 24) && ((tile.type != 109 && tile.type != 492) || typeAttemptedToPlace != 110) && ((tile.type != 199 && tile.type != 662) || typeAttemptedToPlace != 201))
49179 {
49180 if (tile.type == 633)
49181 {
49182 return typeAttemptedToPlace == 637;
49183 }
49184 return false;
49185 }
49186 return true;
49187 }
49188 return false;
49189 }
49190
49191 private static bool SeaOatWaterCheck(int x, int y)
49192 {
49193 int num = 45;
49194 int num2 = 20;
49195 int num3 = 20;
49196 int num4 = -1;
49197 int num5 = num + 1;
49198 int num6 = 0;
49199 bool flag = false;
49200 if (x <= beachDistance || x >= Main.maxTilesX - beachDistance)
49201 {
49202 flag = true;
49203 num4 = 40;
49204 num = 65;
49205 num2 += 5;
49206 }
49207 for (int i = x - num; i <= x + num; i++)
49208 {
49209 for (int j = y - num2; j <= y + num2; j++)
49210 {
49211 if (InWorld(i, j) && !SolidTile(i, j) && Main.tile[i, j].liquid > 0)
49212 {
49213 num6 += Main.tile[i, j].liquid;
49214 int num7 = Math.Abs(i - x);
49215 if (num7 < num5)
49216 {
49217 num5 = num7;
49218 }
49219 }
49220 }
49221 }
49222 if (num6 / 255 >= num3)
49223 {
49224 if (flag)
49225 {
49226 return false;
49227 }
49228 return true;
49229 }
49230 if (flag)
49231 {
49232 return true;
49233 }
49234 return false;
49235 }
49236
49237 private static bool PlantSeaOat(int x, int y)
49238 {
49239 if (Main.tile[x, y].wall > 0 || Main.tile[x, y].active() || Main.tile[x, y].liquid > 0 || !SolidTileAllowBottomSlope(x, y + 1) || !TileID.Sets.Conversion.Sand[Main.tile[x, y + 1].type])
49240 {
49241 return false;
49242 }
49243 if (!SeaOatWaterCheck(x, y))
49244 {
49245 return false;
49246 }
49247 Main.tile[x, y].active(active: true);
49248 Main.tile[x, y].slope(0);
49249 Main.tile[x, y].halfBrick(halfBrick: false);
49250 Main.tile[x, y].type = 529;
49251 Main.tile[x, y].frameX = (short)(genRand.Next(5) * 18);
49252 int num = 0;
49253 Main.tile[x, y].frameY = (short)(num * 34);
49254 if (Main.netMode == 2)
49255 {
49256 NetMessage.SendTileSquare(-1, x, y);
49257 }
49258 return true;
49259 }
49260
49261 private static bool CheckSeaOat(int x, int y)
49262 {
49263 if (!SeaOatWaterCheck(x, y))
49264 {
49265 KillTile(x, y);
49266 if (Main.netMode == 2)
49267 {
49268 NetMessage.SendData(17, -1, -1, null, 0, x, y);
49269 }
49270 return false;
49271 }
49272 return true;
49273 }
49274
49275 private static bool GrowSeaOat(int x, int y)
49276 {
49277 if (Main.tile[x, y].frameX < 180)
49278 {
49279 Main.tile[x, y].frameX += 90;
49280 }
49281 if (Main.netMode == 2)
49282 {
49283 NetMessage.SendTileSquare(-1, x, y);
49284 }
49285 return false;
49286 }
49287
49288 private static int GetWaterDepth(int x, int y)
49289 {
49290 int num = y;
49291 while (!SolidTile(x, num))
49292 {
49293 num++;
49294 if (num > Main.maxTilesY - 1)
49295 {
49296 return 0;
49297 }
49298 }
49299 num--;
49300 int num2 = num;
49301 while (Main.tile[x, num2].liquid > 0 && !SolidTile(x, num2))
49302 {
49303 num2--;
49304 }
49305 return num - num2;
49306 }
49307
49308 private static int CountGrowingPlantTiles(int x, int y, int range, int type)
49309 {
49310 int num = 0;
49311 for (int i = x - range; i <= x + range; i++)
49312 {
49313 for (int j = y - range * 3; j <= y + range * 3; j++)
49314 {
49315 if (Main.tile[i, j].active() && Main.tile[i, j].type == type)
49316 {
49317 num++;
49318 }
49319 }
49320 }
49321 return num;
49322 }
49323
49324 private static bool PlaceBamboo(int x, int y)
49325 {
49326 int num = 2;
49327 int num2 = 5;
49328 int num3 = genRand.Next(1, 21);
49329 Tile tile = Main.tile[x, y];
49330 if (tile.wall > 0 && (double)y <= Main.worldSurface)
49331 {
49332 return false;
49333 }
49334 if (tile.active() && tile.type == 314)
49335 {
49336 return false;
49337 }
49338 Tile tile2 = Main.tile[x, y + 1];
49339 if (tile2.type == 571 || tile2.type == 60)
49340 {
49341 int waterDepth = GetWaterDepth(x, y);
49343 {
49344 return false;
49345 }
49346 int num4 = CountGrowingPlantTiles(x, y, 5, 571);
49347 int i = 1;
49348 if (tile2.type == 571)
49349 {
49350 for (; !SolidTile(x, y + i); i++)
49351 {
49352 }
49353 if (i + num4 / genRand.Next(1, 21) > num3)
49354 {
49355 return false;
49356 }
49357 }
49358 else
49359 {
49360 num4 += 25;
49361 }
49362 num4 += i * 2;
49363 if (num4 > genRand.Next(40, 61))
49364 {
49365 return false;
49366 }
49367 tile = Main.tile[x, y];
49368 tile.active(active: true);
49369 tile.type = 571;
49370 tile.frameX = 0;
49371 tile.frameY = 0;
49372 tile.slope(0);
49373 tile.halfBrick(halfBrick: false);
49374 SquareTileFrame(x, y);
49375 return true;
49376 }
49377 return false;
49378 }
49379
49380 public static void CheckBamboo(int x, int y)
49381 {
49382 Tile tile = Main.tile[x, y + 1];
49383 if (tile == null)
49384 {
49385 return;
49386 }
49387 if (!tile.active() || (tile.type != 60 && tile.type != 571))
49388 {
49389 KillTile(x, y);
49390 if (Main.netMode == 2)
49391 {
49392 NetMessage.SendData(17, -1, -1, null, 0, x, y);
49393 }
49394 SquareTileFrame(x, y);
49395 return;
49396 }
49397 Tile tile2 = Main.tile[x, y - 1];
49398 if (tile2 == null)
49399 {
49400 return;
49401 }
49402 Tile tile3 = Main.tile[x, y];
49403 if (tile3 == null)
49404 {
49405 return;
49406 }
49407 bool num = tile2.active() && tile2.type == 571;
49408 bool flag = tile.active() && tile.type == 571;
49409 int num2 = tile3.frameX / 18;
49410 tile3.frameY = 0;
49411 if (num)
49412 {
49413 if (flag)
49414 {
49415 if (num2 < 5 || num2 > 14)
49416 {
49417 tile3.frameX = (short)(genRand.Next(5, 15) * 18);
49418 if (Main.netMode == 2)
49419 {
49420 NetMessage.SendTileSquare(-1, x, y);
49421 }
49422 }
49423 }
49424 else if (num2 < 1 || num2 > 4)
49425 {
49426 tile3.frameX = (short)(genRand.Next(1, 5) * 18);
49427 if (Main.netMode == 2)
49428 {
49429 NetMessage.SendTileSquare(-1, x, y);
49430 }
49431 }
49432 }
49433 else if (flag)
49434 {
49435 if (num2 < 15 || num2 > 19)
49436 {
49437 tile3.frameX = (short)(genRand.Next(15, 20) * 18);
49438 if (Main.netMode == 2)
49439 {
49440 NetMessage.SendTileSquare(-1, x, y);
49441 }
49442 }
49443 }
49444 else if (num2 != 0)
49445 {
49446 tile3.frameX = 0;
49447 if (Main.netMode == 2)
49448 {
49449 NetMessage.SendTileSquare(-1, x, y);
49450 }
49451 }
49452 }
49453
49454 public static void PlaceUnderwaterPlant(ushort type, int x, int y)
49455 {
49456 if (CanUnderwaterPlantGrowHere(type, x, y, ignoreSelf: false))
49457 {
49459 tileSafely.slope(0);
49460 tileSafely.halfBrick(halfBrick: false);
49462 tileSafely2.active(active: true);
49463 tileSafely2.type = type;
49464 tileSafely2.frameX = 0;
49465 tileSafely2.frameY = 0;
49466 tileSafely2.slope(0);
49467 tileSafely2.halfBrick(halfBrick: false);
49468 SquareTileFrame(x, y);
49469 }
49470 }
49471
49472 public static bool CanUnderwaterPlantGrowHere(ushort type, int x, int y, bool ignoreSelf)
49473 {
49474 if (!InWorld(x, y, 50))
49475 {
49476 return false;
49477 }
49479 if (!ignoreSelf && tileSafely.active())
49480 {
49481 return false;
49482 }
49483 for (int i = 0; i < 3; i++)
49484 {
49485 tileSafely = Framing.GetTileSafely(x, y - i);
49486 if (tileSafely.liquid == 0 || tileSafely.liquidType() != 0)
49487 {
49488 return false;
49489 }
49490 }
49492 if (!tileSafely2.nactive())
49493 {
49494 return false;
49495 }
49496 if (!TileID.Sets.Conversion.Sand[tileSafely2.type] && type != tileSafely2.type)
49497 {
49498 return false;
49499 }
49501 ushort wall = tileSafely.wall;
49502 if (wall != 0 && (uint)(wall - 63) > 6u && (uint)(wall - 80) > 1u)
49503 {
49504 return false;
49505 }
49506 return true;
49507 }
49508
49509 public static void CheckUnderwaterPlant(ushort type, int x, int y)
49510 {
49511 if (!CanUnderwaterPlantGrowHere(type, x, y, ignoreSelf: true))
49512 {
49513 KillTile(x, y);
49514 if (Main.netMode == 2)
49515 {
49516 NetMessage.SendData(17, -1, -1, null, 0, x, y);
49517 }
49518 SquareTileFrame(x, y);
49519 return;
49520 }
49524 bool num = tileSafely.active() && tileSafely.type == type;
49525 bool flag = tileSafely3.active() && tileSafely3.type == type;
49526 int num2 = tileSafely2.frameX / 18;
49527 tileSafely2.frameY = 0;
49528 if (num)
49529 {
49530 if (1 > num2 || num2 > 7)
49531 {
49532 tileSafely2.frameX = (short)(genRand.Next(1, 8) * 18);
49533 if (Main.netMode == 2)
49534 {
49535 NetMessage.SendTileSquare(-1, x, y);
49536 }
49537 }
49538 }
49539 else if (flag)
49540 {
49541 if (7 > num2 || num2 > 12)
49542 {
49543 tileSafely2.frameX = (short)(genRand.Next(7, 13) * 18);
49544 if (Main.netMode == 2)
49545 {
49546 NetMessage.SendTileSquare(-1, x, y);
49547 }
49548 }
49549 }
49550 else if (num2 != 0)
49551 {
49552 tileSafely2.frameX = 0;
49553 if (Main.netMode == 2)
49554 {
49555 NetMessage.SendTileSquare(-1, x, y);
49556 }
49557 }
49558 }
49559
49560 public static Point PlaceCatTail(int x, int j)
49561 {
49562 int num = j;
49563 Point result = new Point(-1, -1);
49565 {
49566 return result;
49567 }
49568 if ((Main.tile[x, num].active() && Main.tile[x, num].type != 71) || Main.tile[x, num].liquid == 0 || Main.tile[x, num].liquidType() != 0)
49569 {
49570 return result;
49571 }
49572 while (Main.tile[x, num].liquid > 0 && num > 50)
49573 {
49574 num--;
49575 }
49576 num++;
49577 if (Main.tile[x, num].active() || Main.tile[x, num - 1].active() || Main.tile[x, num].liquid == 0 || Main.tile[x, num].liquidType() != 0)
49578 {
49579 return result;
49580 }
49581 if (Main.tile[x, num].wall != 0 && Main.tile[x, num].wall != 80 && Main.tile[x, num].wall != 81 && Main.tile[x, num].wall != 69 && (Main.tile[x, num].wall < 63 || Main.tile[x, num].wall > 68))
49582 {
49583 return result;
49584 }
49585 int num2 = 7;
49586 int num3 = 0;
49587 for (int i = x - num2; i <= x + num2; i++)
49588 {
49589 for (int k = num - num2; k <= num + num2; k++)
49590 {
49591 if (Main.tile[i, k].active() && Main.tile[i, k].type == 519)
49592 {
49593 num3++;
49594 break;
49595 }
49596 }
49597 }
49598 if (num3 > 3)
49599 {
49600 return result;
49601 }
49602 int l;
49603 for (l = num; (!Main.tile[x, l].active() || !Main.tileSolid[Main.tile[x, l].type] || Main.tileSolidTop[Main.tile[x, l].type]) && l < Main.maxTilesY - 50; l++)
49604 {
49605 if (Main.tile[x, l].active() && Main.tile[x, l].type != 71)
49606 {
49607 return result;
49608 }
49609 }
49610 int num4 = catTailDistance - 1;
49611 if (l - num > num4)
49612 {
49613 return result;
49614 }
49615 if (l - num < 2)
49616 {
49617 return result;
49618 }
49619 int type = Main.tile[x, l].type;
49620 if (!Main.tile[x, l].nactive())
49621 {
49622 return result;
49623 }
49624 int num5 = -1;
49625 switch (type)
49626 {
49627 case 2:
49628 case 477:
49629 num5 = 0;
49630 break;
49631 case 53:
49632 if (x < beachDistance || x > Main.maxTilesX - beachDistance)
49633 {
49634 return result;
49635 }
49636 num5 = 18;
49637 break;
49638 case 199:
49639 case 234:
49640 case 662:
49641 num5 = 54;
49642 break;
49643 case 23:
49644 case 112:
49645 case 661:
49646 num5 = 72;
49647 break;
49648 case 70:
49649 num5 = 90;
49650 break;
49651 }
49652 if (num5 < 0)
49653 {
49654 return result;
49655 }
49656 if (Main.tile[x, l].topSlope() && gen && genRand.Next(3) != 0)
49657 {
49658 Main.tile[x, l].slope(0);
49659 }
49660 else if (Main.tile[x, l].topSlope() || Main.tile[x, l].halfBrick())
49661 {
49662 return result;
49663 }
49664 num = l - 1;
49665 Main.tile[x, num].active(active: true);
49666 Main.tile[x, num].type = 519;
49667 Main.tile[x, num].frameX = 0;
49668 Main.tile[x, num].frameY = (short)num5;
49669 Main.tile[x, num].halfBrick(halfBrick: false);
49670 Main.tile[x, num].slope(0);
49671 Main.tile[x, num].CopyPaintAndCoating(Main.tile[x, num + 1]);
49672 SquareTileFrame(x, num);
49673 return new Point(x, num);
49674 }
49675
49676 public static void CheckCatTail(int x, int j)
49677 {
49678 if (Main.tile[x, j] == null)
49679 {
49680 return;
49681 }
49682 int num = j;
49683 bool flag = false;
49684 int num2 = num;
49685 while ((!Main.tile[x, num2].active() || !Main.tileSolid[Main.tile[x, num2].type] || Main.tileSolidTop[Main.tile[x, num2].type]) && num2 < Main.maxTilesY - 50)
49686 {
49687 if (Main.tile[x, num2].active() && Main.tile[x, num2].type != 519)
49688 {
49689 flag = true;
49690 }
49691 if (!Main.tile[x, num2].active())
49692 {
49693 break;
49694 }
49695 num2++;
49696 if (Main.tile[x, num2] == null)
49697 {
49698 return;
49699 }
49700 }
49701 num = num2 - 1;
49702 if (Main.tile[x, num] == null)
49703 {
49704 return;
49705 }
49706 while (Main.tile[x, num] != null && Main.tile[x, num].liquid > 0 && num > 50)
49707 {
49708 if ((Main.tile[x, num].active() && Main.tile[x, num].type != 519) || Main.tile[x, num].liquidType() != 0)
49709 {
49710 flag = true;
49711 }
49712 num--;
49713 if (Main.tile[x, num] == null)
49714 {
49715 return;
49716 }
49717 }
49718 num++;
49719 if (Main.tile[x, num] == null)
49720 {
49721 return;
49722 }
49723 int num3 = num;
49724 int num4 = catTailDistance;
49725 if (num2 - num3 > num4)
49726 {
49727 flag = true;
49728 }
49729 int type = Main.tile[x, num2].type;
49730 int num5 = -1;
49731 switch (type)
49732 {
49733 case 2:
49734 case 477:
49735 num5 = 0;
49736 break;
49737 case 53:
49738 num5 = 18;
49739 break;
49740 case 199:
49741 case 234:
49742 case 662:
49743 num5 = 54;
49744 break;
49745 case 23:
49746 case 112:
49747 case 661:
49748 num5 = 72;
49749 break;
49750 case 70:
49751 num5 = 90;
49752 break;
49753 }
49754 if (!Main.tile[x, num2].nactive())
49755 {
49756 flag = true;
49757 }
49758 if (num5 < 0)
49759 {
49760 flag = true;
49761 }
49762 num = num2 - 1;
49763 if (Main.tile[x, num] != null && !Main.tile[x, num].active())
49764 {
49765 for (int num6 = num; num6 >= num3; num6--)
49766 {
49767 if (Main.tile[x, num6] == null)
49768 {
49769 return;
49770 }
49771 if (Main.tile[x, num6].active() && Main.tile[x, num6].type == 519)
49772 {
49773 num = num6;
49774 break;
49775 }
49776 }
49777 }
49778 while (Main.tile[x, num] != null && Main.tile[x, num].active() && Main.tile[x, num].type == 519)
49779 {
49780 num--;
49781 }
49782 num++;
49783 if (Main.tile[x, num2 - 1] != null && Main.tile[x, num2 - 1].liquid < 127 && genRand.Next(4) == 0)
49784 {
49785 flag = true;
49786 }
49787 if (Main.tile[x, num] != null && Main.tile[x, num].frameX >= 180 && Main.tile[x, num].liquid > 127 && genRand.Next(4) == 0)
49788 {
49789 flag = true;
49790 }
49791 if (Main.tile[x, num] != null && Main.tile[x, num2 - 1] != null && Main.tile[x, num].frameX > 18)
49792 {
49793 if (Main.tile[x, num2 - 1].frameX < 36 || Main.tile[x, num2 - 1].frameX > 72)
49794 {
49795 flag = true;
49796 }
49797 else if (Main.tile[x, num].frameX < 90)
49798 {
49799 flag = true;
49800 }
49801 else if (Main.tile[x, num].frameX >= 108 && Main.tile[x, num].frameX <= 162)
49802 {
49803 Main.tile[x, num].frameX = 90;
49804 }
49805 }
49806 if (num2 > num + 4 && Main.tile[x, num + 4] != null && Main.tile[x, num + 3] != null && Main.tile[x, num + 4].liquid == 0 && Main.tile[x, num + 3].type == 519)
49807 {
49808 flag = true;
49809 }
49810 if (flag)
49811 {
49812 int num7 = num3;
49813 if (num < num3)
49814 {
49815 num7 = num;
49816 }
49817 num7 -= 4;
49818 for (int i = num7; i <= num2; i++)
49819 {
49820 if (Main.tile[x, i] != null && Main.tile[x, i].active() && Main.tile[x, i].type == 519)
49821 {
49822 KillTile(x, i);
49823 if (Main.netMode == 2)
49824 {
49825 NetMessage.SendData(17, -1, -1, null, 0, x, i);
49826 }
49827 SquareTileFrame(x, i);
49828 }
49829 }
49830 }
49831 else
49832 {
49833 if (num5 == Main.tile[x, num].frameY)
49834 {
49835 return;
49836 }
49837 for (int k = num; k < num2; k++)
49838 {
49839 if (Main.tile[x, k] != null && Main.tile[x, k].active() && Main.tile[x, k].type == 519)
49840 {
49841 Main.tile[x, k].frameY = (short)num5;
49842 if (Main.netMode == 2)
49843 {
49844 NetMessage.SendTileSquare(-1, x, num);
49845 }
49846 }
49847 }
49848 }
49849 }
49850
49851 public static void GrowCheckSeaweed(int x, int y)
49852 {
49853 int maxValue = 1;
49854 if (Main.netMode == 1)
49855 {
49856 return;
49857 }
49858 if ((Main.tile[x, y].type == 549 && Main.tile[x, y].liquid < 200) || Main.tile[x, y - 1].liquid < 200)
49859 {
49860 if (Main.tile[x, y].active() && Main.tile[x, y].type == 549 && genRand.Next(2) == 0)
49861 {
49862 KillTile(x, y);
49863 if (Main.netMode == 2)
49864 {
49865 NetMessage.SendData(17, -1, -1, null, 0, x, y);
49866 }
49867 }
49868 }
49869 else
49870 {
49871 if (Main.tile[x, y - 1].active() || Main.tile[x, y - 2].active() || genRand.Next(maxValue) != 0 || Main.tile[x, y - 2].liquid != byte.MaxValue || Main.tile[x, y - 3].liquid != byte.MaxValue)
49872 {
49873 return;
49874 }
49875 int num = 17;
49876 int num2 = 4;
49877 int num3 = 30;
49878 int num4 = 0;
49879 for (int i = x - num2; i <= x + num2; i++)
49880 {
49881 for (int j = y; j <= y + num2 * 3; j++)
49882 {
49883 if (Main.tile[i, j].active() && Main.tile[i, j].type == 549)
49884 {
49885 num4++;
49886 if (num4 > num3)
49887 {
49888 return;
49889 }
49890 }
49891 }
49892 }
49893 int k;
49894 for (k = y; !SolidTile(x, k) && k < Main.maxTilesY - 50; k++)
49895 {
49896 }
49897 if (k - y < num - genRand.Next(20))
49898 {
49899 PlaceTile(x, y - 1, 549, mute: true);
49900 if (Main.netMode == 2)
49901 {
49902 NetMessage.SendTileSquare(-1, x, y - 1);
49903 }
49904 }
49905 }
49906 }
49907
49908 public static void GrowCatTail(int x, int j)
49909 {
49910 if (Main.netMode == 1)
49911 {
49912 return;
49913 }
49914 int num = j;
49915 while (Main.tile[x, num].liquid > 0 && num > 50)
49916 {
49917 num--;
49918 }
49919 num++;
49920 int i;
49921 for (i = num; (!Main.tile[x, i].active() || !Main.tileSolid[Main.tile[x, i].type] || Main.tileSolidTop[Main.tile[x, i].type]) && i < Main.maxTilesY - 50; i++)
49922 {
49923 }
49924 num = i - 1;
49925 while (Main.tile[x, num].active() && Main.tile[x, num].type == 519)
49926 {
49927 num--;
49928 }
49929 num++;
49930 if (Main.tile[x, num].frameX == 90 && Main.tile[x, num - 1].active() && Main.tileCut[Main.tile[x, num - 1].type])
49931 {
49932 KillTile(x, num - 1);
49933 if (Main.netMode == 2)
49934 {
49935 NetMessage.SendData(17, -1, -1, null, 0, x, num - 1);
49936 }
49937 }
49938 if (Main.tile[x, num - 1].active())
49939 {
49940 return;
49941 }
49942 if (Main.tile[x, num].frameX == 0)
49943 {
49944 Main.tile[x, num].frameX = 18;
49945 SquareTileFrame(x, num);
49946 if (Main.netMode == 2)
49947 {
49948 NetMessage.SendTileSquare(-1, x, num);
49949 }
49950 }
49951 else if (Main.tile[x, num].frameX == 18)
49952 {
49953 Main.tile[x, num].frameX = (short)(18 * genRand.Next(2, 5));
49954 Main.tile[x, num - 1].active(active: true);
49955 Main.tile[x, num - 1].type = 519;
49956 Main.tile[x, num - 1].frameX = 90;
49957 Main.tile[x, num - 1].frameY = Main.tile[x, num].frameY;
49958 Main.tile[x, num - 1].halfBrick(halfBrick: false);
49959 Main.tile[x, num - 1].slope(0);
49960 Main.tile[x, num - 1].CopyPaintAndCoating(Main.tile[x, num]);
49961 SquareTileFrame(x, num);
49962 if (Main.netMode == 2)
49963 {
49964 NetMessage.SendTileSquare(-1, x, num);
49965 }
49966 }
49967 else if (Main.tile[x, num].frameX == 90)
49968 {
49969 if (Main.tile[x, num - 1].liquid == 0)
49970 {
49971 if (!Main.tile[x, num - 2].active() && (Main.tile[x, num].liquid > 0 || Main.tile[x, num + 1].liquid > 0 || Main.tile[x, num + 2].liquid > 0) && genRand.Next(3) == 0)
49972 {
49973 Main.tile[x, num].frameX = 108;
49974 Main.tile[x, num - 1].active(active: true);
49975 Main.tile[x, num - 1].type = 519;
49976 Main.tile[x, num - 1].frameX = 90;
49977 Main.tile[x, num - 1].frameY = Main.tile[x, num].frameY;
49978 Main.tile[x, num - 1].halfBrick(halfBrick: false);
49979 Main.tile[x, num - 1].slope(0);
49980 Main.tile[x, num - 1].CopyPaintAndCoating(Main.tile[x, num]);
49981 SquareTileFrame(x, num);
49982 }
49983 else
49984 {
49985 int num2 = genRand.Next(3);
49986 Main.tile[x, num].frameX = (short)(126 + num2 * 18);
49987 Main.tile[x, num - 1].active(active: true);
49988 Main.tile[x, num - 1].type = 519;
49989 Main.tile[x, num - 1].frameX = (short)(180 + num2 * 18);
49990 Main.tile[x, num - 1].frameY = Main.tile[x, num].frameY;
49991 Main.tile[x, num - 1].halfBrick(halfBrick: false);
49992 Main.tile[x, num - 1].slope(0);
49993 Main.tile[x, num - 1].CopyPaintAndCoating(Main.tile[x, num]);
49994 SquareTileFrame(x, num);
49995 }
49996 }
49997 else
49998 {
49999 Main.tile[x, num].frameX = 108;
50000 Main.tile[x, num - 1].active(active: true);
50001 Main.tile[x, num - 1].type = 519;
50002 Main.tile[x, num - 1].frameX = 90;
50003 Main.tile[x, num - 1].frameY = Main.tile[x, num].frameY;
50004 Main.tile[x, num - 1].halfBrick(halfBrick: false);
50005 Main.tile[x, num - 1].slope(0);
50006 Main.tile[x, num - 1].CopyPaintAndCoating(Main.tile[x, num]);
50007 SquareTileFrame(x, num);
50008 }
50009 }
50010 SquareTileFrame(x, num - 1, resetFrame: false);
50011 if (Main.netMode == 2)
50012 {
50013 NetMessage.SendTileSquare(-1, x, num - 1, 1, 2);
50014 }
50015 }
50016
50017 public static bool PlaceLilyPad(int x, int j)
50018 {
50019 int num = j;
50021 {
50022 return false;
50023 }
50024 if (Main.tile[x, num].active() || Main.tile[x, num].liquid == 0 || Main.tile[x, num].liquidType() != 0)
50025 {
50026 return false;
50027 }
50028 while (Main.tile[x, num].liquid > 0 && num > 50)
50029 {
50030 num--;
50031 }
50032 num++;
50033 if (Main.tile[x, num].active() || Main.tile[x, num - 1].active() || Main.tile[x, num].liquid == 0 || Main.tile[x, num].liquidType() != 0)
50034 {
50035 return false;
50036 }
50037 if (Main.tile[x, num].wall != 0 && Main.tile[x, num].wall != 15 && Main.tile[x, num].wall != 70 && (Main.tile[x, num].wall < 63 || Main.tile[x, num].wall > 68))
50038 {
50039 return false;
50040 }
50041 int num2 = 5;
50042 int num3 = 0;
50043 for (int i = x - num2; i <= x + num2; i++)
50044 {
50045 for (int k = num - num2; k <= num + num2; k++)
50046 {
50047 if (Main.tile[i, k].active() && Main.tile[i, k].type == 518)
50048 {
50049 num3++;
50050 }
50051 }
50052 }
50053 if (num3 > 3)
50054 {
50055 return false;
50056 }
50057 int l;
50058 for (l = num; (!Main.tile[x, l].active() || !Main.tileSolid[Main.tile[x, l].type] || Main.tileSolidTop[Main.tile[x, l].type]) && l < Main.maxTilesY - 50; l++)
50059 {
50060 if (Main.tile[x, l].active() && Main.tile[x, l].type == 519)
50061 {
50062 return false;
50063 }
50064 }
50065 int num4 = 12;
50066 if (l - num > num4)
50067 {
50068 return false;
50069 }
50070 if (l - num < 3)
50071 {
50072 return false;
50073 }
50074 int type = Main.tile[x, l].type;
50075 int num5 = -1;
50076 if (type == 2 || type == 477)
50077 {
50078 num5 = 0;
50079 }
50080 if (type == 109 || type == 109 || type == 116)
50081 {
50082 num5 = 18;
50083 }
50084 if (type == 60)
50085 {
50086 num5 = 36;
50087 }
50088 if (num5 < 0)
50089 {
50090 return false;
50091 }
50092 Main.tile[x, num].active(active: true);
50093 Main.tile[x, num].type = 518;
50094 if (genRand.Next(2) == 0)
50095 {
50096 Main.tile[x, num].frameX = (short)(18 * genRand.Next(3));
50097 }
50098 else if (genRand.Next(15) == 0)
50099 {
50100 Main.tile[x, num].frameX = (short)(18 * genRand.Next(18));
50101 }
50102 else
50103 {
50104 int num6 = Main.maxTilesX / 5;
50105 if (x < num6)
50106 {
50107 Main.tile[x, num].frameX = (short)(18 * genRand.Next(6, 9));
50108 }
50109 else if (x < num6 * 2)
50110 {
50111 Main.tile[x, num].frameX = (short)(18 * genRand.Next(9, 12));
50112 }
50113 else if (x < num6 * 3)
50114 {
50115 Main.tile[x, num].frameX = (short)(18 * genRand.Next(3, 6));
50116 }
50117 else if (x < num6 * 4)
50118 {
50119 Main.tile[x, num].frameX = (short)(18 * genRand.Next(15, 18));
50120 }
50121 else
50122 {
50123 Main.tile[x, num].frameX = (short)(18 * genRand.Next(12, 15));
50124 }
50125 }
50126 Main.tile[x, num].frameY = (short)num5;
50127 Main.tile[x, num].halfBrick(halfBrick: false);
50128 Main.tile[x, num].slope(0);
50129 SquareTileFrame(x, num);
50130 return true;
50131 }
50132
50133 public static void CheckLilyPad(int x, int y)
50134 {
50135 if (Main.netMode == 1)
50136 {
50137 return;
50138 }
50139 if (Main.tile[x, y].liquidType() != 0)
50140 {
50141 KillTile(x, y);
50142 if (Main.netMode == 2)
50143 {
50144 NetMessage.SendData(17, -1, -1, null, 0, x, y);
50145 }
50146 return;
50147 }
50148 int num = y;
50149 while ((!Main.tile[x, num].active() || !Main.tileSolid[Main.tile[x, num].type] || Main.tileSolidTop[Main.tile[x, num].type]) && num < Main.maxTilesY - 50)
50150 {
50151 num++;
50152 if (Main.tile[x, num] == null)
50153 {
50154 return;
50155 }
50156 }
50157 int type = Main.tile[x, num].type;
50158 int num2 = -1;
50159 if (type == 2 || type == 477)
50160 {
50161 num2 = 0;
50162 }
50163 if (type == 109 || type == 109 || type == 116)
50164 {
50165 num2 = 18;
50166 }
50167 if (type == 60)
50168 {
50169 num2 = 36;
50170 }
50171 if (num2 >= 0)
50172 {
50173 if (num2 != Main.tile[x, y].frameY)
50174 {
50175 Main.tile[x, y].frameY = (short)num2;
50176 if (Main.netMode == 2)
50177 {
50178 NetMessage.SendTileSquare(-1, x, y);
50179 }
50180 }
50181 if (Main.tile[x, y - 1].liquid > 0 && !Main.tile[x, y - 1].active())
50182 {
50183 Main.tile[x, y - 1].active(active: true);
50184 Main.tile[x, y - 1].type = 518;
50185 Main.tile[x, y - 1].frameX = Main.tile[x, y].frameX;
50186 Main.tile[x, y - 1].frameY = Main.tile[x, y].frameY;
50187 Main.tile[x, y - 1].halfBrick(halfBrick: false);
50188 Main.tile[x, y - 1].slope(0);
50189 Main.tile[x, y].active(active: false);
50190 Main.tile[x, y].type = 0;
50191 SquareTileFrame(x, y - 1, resetFrame: false);
50192 if (Main.netMode == 2)
50193 {
50194 NetMessage.SendTileSquare(-1, x, y - 1, 1, 2);
50195 }
50196 }
50197 else
50198 {
50199 if (Main.tile[x, y].liquid != 0)
50200 {
50201 return;
50202 }
50204 if (!tileSafely.active())
50205 {
50206 Main.tile[x, y + 1].active(active: true);
50207 Main.tile[x, y + 1].type = 518;
50208 Main.tile[x, y + 1].frameX = Main.tile[x, y].frameX;
50209 Main.tile[x, y + 1].frameY = Main.tile[x, y].frameY;
50210 Main.tile[x, y + 1].halfBrick(halfBrick: false);
50211 Main.tile[x, y + 1].slope(0);
50212 Main.tile[x, y].active(active: false);
50213 Main.tile[x, y].type = 0;
50214 SquareTileFrame(x, y + 1, resetFrame: false);
50215 if (Main.netMode == 2)
50216 {
50217 NetMessage.SendTileSquare(-1, x, y, 1, 2);
50218 }
50219 }
50220 else if (tileSafely.active() && !TileID.Sets.Platforms[tileSafely.type] && (!Main.tileSolid[tileSafely.type] || Main.tileSolidTop[tileSafely.type]))
50221 {
50222 KillTile(x, y);
50223 if (Main.netMode == 2)
50224 {
50225 NetMessage.SendData(17, -1, -1, null, 0, x, y);
50226 }
50227 }
50228 }
50229 }
50230 else
50231 {
50232 KillTile(x, y);
50233 if (Main.netMode == 2)
50234 {
50235 NetMessage.SendData(17, -1, -1, null, 0, x, y);
50236 }
50237 }
50238 }
50239
50240 public static bool TryKillingReplaceableTile(int x, int y, int tileType)
50241 {
50242 if (!InWorld(x, y, 2))
50243 {
50244 return false;
50245 }
50246 if (Main.tile[x, y].active() && (Main.tileCut[Main.tile[x, y].type] || TileID.Sets.BreakableWhenPlacing[Main.tile[x, y].type] || (Main.tile[x, y].type >= 373 && Main.tile[x, y].type <= 375) || Main.tile[x, y].type == 461))
50247 {
50248 if (Main.tile[x, y].type != tileType)
50249 {
50250 bool num = Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 579;
50251 bool flag = Main.tile[x, y].type == 3 || Main.tile[x, y].type == 73;
50252 bool flag2 = Main.tileAlch[Main.tile[x, y].type] && IsHarvestableHerbWithSeed(Main.tile[x, y].type, Main.tile[x, y].frameX / 18);
50253 bool flag3 = Main.tileAlch[tileType];
50254 if (num || ((flag || flag2) && flag3))
50255 {
50256 KillTile(x, y);
50257 if (!Main.tile[x, y].active() && Main.netMode != 0)
50258 {
50259 NetMessage.SendData(17, -1, -1, null, 0, x, y);
50260 }
50261 return true;
50262 }
50263 return false;
50264 }
50265 return false;
50266 }
50267 return false;
50268 }
50269
50270 public static bool PlaceTile(int i, int j, int Type, bool mute = false, bool forced = false, int plr = -1, int style = 0)
50271 {
50272 int num = Type;
50273 if (gen && Main.tile[i, j].active() && Main.tile[i, j].type == 488)
50274 {
50275 return false;
50276 }
50277 if (num >= TileID.Count)
50278 {
50279 return false;
50280 }
50281 bool result = false;
50282 if (i >= 0 && j >= 0 && i < Main.maxTilesX && j < Main.maxTilesY)
50283 {
50284 Tile tile = Main.tile[i, j];
50285 if (tile == null)
50286 {
50287 tile = new Tile();
50288 Main.tile[i, j] = tile;
50289 }
50290 if (tile.active())
50291 {
50292 if (num == 23 && tile.type == 59)
50293 {
50294 num = 661;
50295 }
50296 if (num == 199 && tile.type == 59)
50297 {
50298 num = 662;
50299 }
50300 }
50301 if (forced || Collision.EmptyTile(i, j) || !Main.tileSolid[num] || (num == 23 && tile.type == 0 && tile.active()) || (num == 199 && tile.type == 0 && tile.active()) || (num == 2 && tile.type == 0 && tile.active()) || (num == 109 && tile.type == 0 && tile.active()) || (num == 60 && tile.type == 59 && tile.active()) || (num == 661 && tile.type == 59 && tile.active()) || (num == 662 && tile.type == 59 && tile.active()) || (num == 70 && tile.type == 59 && tile.active()) || (num == 633 && tile.type == 57 && tile.active()) || (Main.tileMoss[num] && (tile.type == 1 || tile.type == 38) && tile.active()))
50302 {
50303 if (num == 23 && (tile.type != 0 || !tile.active()))
50304 {
50305 return false;
50306 }
50307 if (num == 199 && (tile.type != 0 || !tile.active()))
50308 {
50309 return false;
50310 }
50311 if (num == 2 && (tile.type != 0 || !tile.active()))
50312 {
50313 return false;
50314 }
50315 if (num == 109 && (tile.type != 0 || !tile.active()))
50316 {
50317 return false;
50318 }
50319 if (num == 60 && (tile.type != 59 || !tile.active()))
50320 {
50321 return false;
50322 }
50323 if (num == 661 && (tile.type != 59 || !tile.active()))
50324 {
50325 return false;
50326 }
50327 if (num == 662 && (tile.type != 59 || !tile.active()))
50328 {
50329 return false;
50330 }
50331 if (num == 70 && (tile.type != 59 || !tile.active()))
50332 {
50333 return false;
50334 }
50335 if (num == 633 && (tile.type != 57 || !tile.active()))
50336 {
50337 return false;
50338 }
50339 if (Main.tileMoss[num])
50340 {
50341 if ((tile.type != 1 && tile.type != 38) || !tile.active())
50342 {
50343 return false;
50344 }
50345 if (tile.type == 38)
50346 {
50347 num = num switch
50348 {
50349 381 => 517,
50350 534 => 535,
50351 536 => 537,
50352 539 => 540,
50353 625 => 626,
50354 627 => 628,
50355 _ => 512 + num - 179,
50356 };
50357 }
50358 }
50359 if (num == 81)
50360 {
50361 if (Main.tile[i, j - 1] == null)
50362 {
50363 Main.tile[i, j - 1] = new Tile();
50364 }
50365 if (Main.tile[i, j + 1] == null)
50366 {
50367 Main.tile[i, j + 1] = new Tile();
50368 }
50369 if (Main.tile[i, j - 1].active())
50370 {
50371 return false;
50372 }
50373 if (!Main.tile[i, j + 1].active() || !Main.tileSolid[Main.tile[i, j + 1].type] || Main.tile[i, j + 1].halfBrick() || Main.tile[i, j + 1].slope() != 0)
50374 {
50375 return false;
50376 }
50377 }
50378 if ((num == 373 || num == 375 || num == 374 || num == 461) && (Main.tile[i, j - 1] == null || Main.tile[i, j - 1].bottomSlope()))
50379 {
50380 return false;
50381 }
50382 if (tile.liquid > 0 || tile.checkingLiquid())
50383 {
50384 switch (num)
50385 {
50386 case 4:
50387 if (style != 8 && style != 11 && style != 17)
50388 {
50389 return false;
50390 }
50391 break;
50392 case 3:
50393 case 20:
50394 case 24:
50395 case 27:
50396 case 32:
50397 case 51:
50398 case 69:
50399 case 72:
50400 case 201:
50401 case 352:
50402 case 529:
50403 case 624:
50404 case 637:
50405 case 656:
50406 return false;
50407 }
50408 }
50410 {
50411 tile.halfBrick(halfBrick: false);
50412 tile.frameY = 0;
50413 tile.frameX = 0;
50414 }
50415 if (num == 624)
50416 {
50417 if ((!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type]) && HasValidGroundForAbigailsFlowerBelowSpot(i, j))
50418 {
50419 tile.active(active: true);
50420 tile.type = 624;
50421 tile.halfBrick(halfBrick: false);
50422 tile.slope(0);
50423 tile.frameX = 0;
50424 tile.frameY = 0;
50425 }
50426 }
50427 else if (num == 656)
50428 {
50429 if ((!tile.active() || Main.tileCut[tile.type] || TileID.Sets.BreakableWhenPlacing[tile.type]) && HasValidGroundForGlowTulipBelowSpot(i, j))
50430 {
50431 tile.active(active: true);
50432 tile.type = 656;
50433 tile.halfBrick(halfBrick: false);
50434 tile.slope(0);
50435 tile.frameX = 0;
50436 tile.frameY = 0;
50437 }
50438 }
50439 else if (num == 3 || num == 24 || num == 110 || num == 201 || num == 637)
50440 {
50441 if (IsFitToPlaceFlowerIn(i, j, num))
50442 {
50443 if (num == 24 && genRand.Next(13) == 0)
50444 {
50445 tile.active(active: true);
50446 tile.type = 32;
50447 SquareTileFrame(i, j);
50448 }
50449 else if (num == 201 && genRand.Next(13) == 0)
50450 {
50451 tile.active(active: true);
50452 tile.type = 352;
50453 SquareTileFrame(i, j);
50454 }
50455 else if (Main.tile[i, j + 1].type == 78 || Main.tile[i, j + 1].type == 380 || Main.tile[i, j + 1].type == 579)
50456 {
50457 tile.active(active: true);
50458 tile.type = (ushort)num;
50459 int num2 = genRand.NextFromList<int>(6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 27, 30, 33, 36, 39, 42);
50460 switch (num2)
50461 {
50462 case 21:
50463 case 24:
50464 case 27:
50465 case 30:
50466 case 33:
50467 case 36:
50468 case 39:
50469 case 42:
50470 num2 += genRand.Next(3);
50471 break;
50472 }
50473 tile.frameX = (short)(num2 * 18);
50474 }
50475 else if (tile.wall >= 0 && tile.wall < WallID.Count && WallID.Sets.AllowsPlantsToGrow[tile.wall] && Main.tile[i, j + 1].wall >= 0 && Main.tile[i, j + 1].wall < WallID.Count && WallID.Sets.AllowsPlantsToGrow[Main.tile[i, j + 1].wall])
50476 {
50477 if (genRand.Next(50) == 0 || ((num == 24 || num == 201) && genRand.Next(40) == 0))
50478 {
50479 tile.active(active: true);
50480 tile.type = (ushort)num;
50481 if (num == 201)
50482 {
50483 tile.frameX = 270;
50484 }
50485 else
50486 {
50487 tile.frameX = 144;
50488 }
50489 }
50490 else if (genRand.Next(35) == 0 || (Main.tile[i, j].wall >= 63 && Main.tile[i, j].wall <= 70))
50491 {
50492 tile.active(active: true);
50493 tile.type = (ushort)num;
50494 int num3 = genRand.NextFromList<int>(6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
50495 if (num == 201)
50496 {
50497 num3 = genRand.NextFromList<int>(6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22);
50498 }
50499 if (num == 637)
50500 {
50501 num3 = genRand.NextFromList<int>(6, 7, 8, 9, 10);
50502 }
50503 tile.frameX = (short)(num3 * 18);
50504 }
50505 else
50506 {
50507 tile.active(active: true);
50508 tile.type = (ushort)num;
50509 tile.frameX = (short)(genRand.Next(6) * 18);
50510 }
50511 }
50512 }
50513 }
50514 else if (num == 61)
50515 {
50516 if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1].active() && Main.tile[i, j + 1].slope() == 0 && !Main.tile[i, j + 1].halfBrick() && Main.tile[i, j + 1].type == 60)
50517 {
50518 bool flag = (double)j > Main.rockLayer || Main.remixWorld || remixWorldGen;
50519 if (genRand.Next(16) == 0 && (double)j > Main.worldSurface)
50520 {
50521 tile.active(active: true);
50522 tile.type = 69;
50523 SquareTileFrame(i, j);
50524 }
50525 else if (genRand.Next(60) == 0 && flag)
50526 {
50527 tile.active(active: true);
50528 tile.type = (ushort)num;
50529 tile.frameX = 144;
50530 }
50531 else if (genRand.Next(230) == 0 && flag)
50532 {
50533 tile.active(active: true);
50534 tile.type = (ushort)num;
50535 tile.frameX = 162;
50536 }
50537 else if (genRand.Next(15) == 0)
50538 {
50539 tile.active(active: true);
50540 tile.type = (ushort)num;
50541 if (genRand.Next(3) != 0)
50542 {
50543 tile.frameX = (short)(genRand.Next(2) * 18 + 108);
50544 }
50545 else
50546 {
50547 tile.frameX = (short)(genRand.Next(13) * 18 + 180);
50548 }
50549 }
50550 else
50551 {
50552 tile.active(active: true);
50553 tile.type = (ushort)num;
50554 tile.frameX = (short)(genRand.Next(6) * 18);
50555 }
50556 }
50557 }
50558 else if (num == 518)
50559 {
50560 PlaceLilyPad(i, j);
50561 }
50562 else if (num == 519)
50563 {
50564 PlaceCatTail(i, j);
50565 }
50566 else if (num == 529)
50567 {
50568 PlantSeaOat(i, j);
50569 }
50570 else if (num == 571)
50571 {
50572 PlaceBamboo(i, j);
50573 }
50574 else if (num == 549)
50575 {
50576 PlaceUnderwaterPlant(549, i, j);
50577 }
50578 else if (num == 71)
50579 {
50580 if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1].active() && Main.tile[i, j + 1].slope() == 0 && !Main.tile[i, j + 1].halfBrick() && Main.tile[i, j + 1].type == 70)
50581 {
50582 Point point = new Point(-1, -1);
50583 if ((double)j > Main.worldSurface)
50584 {
50585 point = PlaceCatTail(i, j);
50586 }
50587 if (InWorld(point.X, point.Y))
50588 {
50589 if (gen)
50590 {
50591 int num4 = genRand.Next(14);
50592 for (int k = 0; k < num4; k++)
50593 {
50594 GrowCatTail(point.X, point.Y);
50595 }
50596 SquareTileFrame(point.X, point.Y);
50597 }
50598 }
50599 else
50600 {
50601 tile.active(active: true);
50602 tile.type = (ushort)num;
50603 tile.frameX = (short)(genRand.Next(5) * 18);
50604 }
50605 }
50606 }
50607 else if (num == 129)
50608 {
50609 if (SolidTile(i - 1, j) || SolidTile(i + 1, j) || SolidTile(i, j - 1) || SolidTile(i, j + 1))
50610 {
50611 tile.active(active: true);
50612 tile.type = (ushort)num;
50613 tile.frameX = (short)(style * 18);
50614 SquareTileFrame(i, j);
50615 }
50616 }
50617 else if (num == 178)
50618 {
50619 if (SolidTile(i - 1, j, noDoors: true) || SolidTile(i + 1, j, noDoors: true) || SolidTile(i, j - 1) || SolidTile(i, j + 1))
50620 {
50621 tile.active(active: true);
50622 tile.type = (ushort)num;
50623 tile.frameX = (short)(style * 18);
50624 tile.frameY = (short)(genRand.Next(3) * 18);
50625 SquareTileFrame(i, j);
50626 }
50627 }
50628 else if (num == 184)
50629 {
50630 if ((Main.tileMoss[Main.tile[i - 1, j].type] && SolidTile(i - 1, j)) || (Main.tileMoss[Main.tile[i + 1, j].type] && SolidTile(i + 1, j)) || (Main.tileMoss[Main.tile[i, j - 1].type] && SolidTile(i, j - 1)) || (Main.tileMoss[Main.tile[i, j + 1].type] && SolidTile(i, j + 1)))
50631 {
50632 tile.active(active: true);
50633 tile.type = (ushort)num;
50634 tile.frameX = (short)(style * 18);
50635 tile.frameY = (short)(genRand.Next(3) * 18);
50636 SquareTileFrame(i, j);
50637 }
50638 if ((TileID.Sets.tileMossBrick[Main.tile[i - 1, j].type] && SolidTile(i - 1, j)) || (TileID.Sets.tileMossBrick[Main.tile[i + 1, j].type] && SolidTile(i + 1, j)) || (TileID.Sets.tileMossBrick[Main.tile[i, j - 1].type] && SolidTile(i, j - 1)) || (TileID.Sets.tileMossBrick[Main.tile[i, j + 1].type] && SolidTile(i, j + 1)))
50639 {
50640 tile.active(active: true);
50641 tile.type = (ushort)num;
50642 tile.frameX = (short)(style * 18);
50643 tile.frameY = (short)(genRand.Next(3) * 18);
50644 SquareTileFrame(i, j);
50645 }
50646 }
50647 else if (num == 485)
50648 {
50649 PlaceObject(i, j, num, mute, style);
50650 }
50651 else if (num == 171)
50652 {
50653 PlaceXmasTree(i, j, 171);
50654 }
50655 else if (num == 254)
50656 {
50657 Place2x2Style(i, j, (ushort)num, style);
50658 }
50659 else if (num == 335 || num == 564 || num == 594)
50660 {
50661 Place2x2(i, j, (ushort)num, 0);
50662 }
50663 else if (num == 654 || num == 319 || num == 132 || num == 484 || num == 138 || num == 664 || num == 142 || num == 143 || num == 282 || (num >= 288 && num <= 295) || (num >= 316 && num <= 318))
50664 {
50665 Place2x2(i, j, (ushort)num, 0);
50666 }
50667 else if (num == 411)
50668 {
50669 Place2x2(i, j, (ushort)num, 0);
50670 }
50671 else if (num == 457)
50672 {
50673 Place2x2Horizontal(i, j, 457, style);
50674 }
50675 else if (num == 137)
50676 {
50677 tile.active(active: true);
50678 tile.type = (ushort)num;
50679 tile.frameY = (short)(18 * style);
50680 }
50681 else if (num == 136)
50682 {
50683 if (Main.tile[i - 1, j] == null)
50684 {
50685 Main.tile[i - 1, j] = new Tile();
50686 }
50687 if (Main.tile[i + 1, j] == null)
50688 {
50689 Main.tile[i + 1, j] = new Tile();
50690 }
50691 if (Main.tile[i, j + 1] == null)
50692 {
50693 Main.tile[i, j + 1] = new Tile();
50694 }
50695 if ((Main.tile[i - 1, j].nactive() && !Main.tile[i - 1, j].halfBrick() && !TileID.Sets.NotReallySolid[Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == 0 && (SolidTile(i - 1, j) || TileID.Sets.IsBeam[Main.tile[i - 1, j].type] || (Main.tile[i - 1, j].type == 5 && Main.tile[i - 1, j - 1].type == 5 && Main.tile[i - 1, j + 1].type == 5))) || (Main.tile[i + 1, j].nactive() && !Main.tile[i + 1, j].halfBrick() && !TileID.Sets.NotReallySolid[Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == 0 && (SolidTile(i + 1, j) || TileID.Sets.IsBeam[Main.tile[i + 1, j].type] || (Main.tile[i + 1, j].type == 5 && Main.tile[i + 1, j - 1].type == 5 && Main.tile[i + 1, j + 1].type == 5))) || (Main.tile[i, j + 1].nactive() && !Main.tile[i, j + 1].halfBrick() && SolidTile(i, j + 1) && Main.tile[i, j + 1].slope() == 0) || tile.wall > 0)
50696 {
50697 tile.active(active: true);
50698 tile.type = (ushort)num;
50699 SquareTileFrame(i, j);
50700 }
50701 }
50702 else if (num == 442)
50703 {
50704 if (Main.tile[i - 1, j] == null)
50705 {
50706 Main.tile[i - 1, j] = new Tile();
50707 }
50708 if (Main.tile[i + 1, j] == null)
50709 {
50710 Main.tile[i + 1, j] = new Tile();
50711 }
50712 if (Main.tile[i, j + 1] == null)
50713 {
50714 Main.tile[i, j + 1] = new Tile();
50715 }
50716 if ((Main.tile[i - 1, j].nactive() && !Main.tile[i - 1, j].halfBrick() && !TileID.Sets.NotReallySolid[Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == 0 && (SolidTile(i - 1, j) || TileID.Sets.IsBeam[Main.tile[i - 1, j].type] || (Main.tile[i - 1, j].type == 5 && Main.tile[i - 1, j - 1].type == 5 && Main.tile[i - 1, j + 1].type == 5))) || (Main.tile[i + 1, j].nactive() && !Main.tile[i + 1, j].halfBrick() && !TileID.Sets.NotReallySolid[Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == 0 && (SolidTile(i + 1, j) || TileID.Sets.IsBeam[Main.tile[i + 1, j].type] || (Main.tile[i + 1, j].type == 5 && Main.tile[i + 1, j - 1].type == 5 && Main.tile[i + 1, j + 1].type == 5))) || (Main.tile[i, j + 1].nactive() && !Main.tile[i, j + 1].halfBrick() && SolidTile(i, j + 1) && Main.tile[i, j + 1].slope() == 0))
50717 {
50718 tile.active(active: true);
50719 tile.type = (ushort)num;
50720 SquareTileFrame(i, j);
50721 }
50722 }
50723 else if (num == 4)
50724 {
50725 if (Main.tile[i - 1, j] == null)
50726 {
50727 Main.tile[i - 1, j] = new Tile();
50728 }
50729 if (Main.tile[i + 1, j] == null)
50730 {
50731 Main.tile[i + 1, j] = new Tile();
50732 }
50733 if (Main.tile[i, j + 1] == null)
50734 {
50735 Main.tile[i, j + 1] = new Tile();
50736 }
50737 Tile tile2 = Main.tile[i - 1, j];
50738 Tile tile3 = Main.tile[i + 1, j];
50739 Tile tile4 = Main.tile[i, j + 1];
50740 if (tile.wall > 0 || (tile2.active() && (tile2.slope() == 0 || tile2.slope() % 2 != 1) && ((Main.tileSolid[tile2.type] && !Main.tileSolidTop[tile2.type] && !TileID.Sets.NotReallySolid[tile2.type]) || TileID.Sets.IsBeam[tile2.type] || (IsTreeType(tile2.type) && IsTreeType(Main.tile[i - 1, j - 1].type) && IsTreeType(Main.tile[i - 1, j + 1].type)))) || (tile3.active() && (tile3.slope() == 0 || tile3.slope() % 2 != 0) && ((Main.tileSolid[tile3.type] && !Main.tileSolidTop[tile3.type] && !TileID.Sets.NotReallySolid[tile3.type]) || TileID.Sets.IsBeam[tile3.type] || (IsTreeType(tile3.type) && IsTreeType(Main.tile[i + 1, j - 1].type) && IsTreeType(Main.tile[i + 1, j + 1].type)))) || (tile4.active() && Main.tileSolid[tile4.type] && ((TileID.Sets.Platforms[tile4.type] && TopEdgeCanBeAttachedTo(i, j + 1)) || ((!Main.tileSolidTop[tile4.type] || (tile4.type == 380 && tile4.slope() == 0)) && !TileID.Sets.NotReallySolid[tile4.type] && !tile4.halfBrick() && tile4.slope() == 0))))
50741 {
50742 tile.active(active: true);
50743 tile.type = (ushort)num;
50744 tile.frameY = (short)(22 * style);
50745 SquareTileFrame(i, j);
50746 }
50747 }
50748 else if (num == 10)
50749 {
50750 if (Main.tile[i, j - 1] == null)
50751 {
50752 Main.tile[i, j - 1] = new Tile();
50753 }
50754 if (Main.tile[i, j - 2] == null)
50755 {
50756 Main.tile[i, j - 2] = new Tile();
50757 }
50758 if (Main.tile[i, j - 3] == null)
50759 {
50760 Main.tile[i, j - 3] = new Tile();
50761 }
50762 if (Main.tile[i, j + 1] == null)
50763 {
50764 Main.tile[i, j + 1] = new Tile();
50765 }
50766 if (Main.tile[i, j + 2] == null)
50767 {
50768 Main.tile[i, j + 2] = new Tile();
50769 }
50770 if (Main.tile[i, j + 3] == null)
50771 {
50772 Main.tile[i, j + 3] = new Tile();
50773 }
50774 if (!Main.tile[i, j - 1].active() && !Main.tile[i, j - 2].active() && Main.tile[i, j - 3].active() && Main.tileSolid[Main.tile[i, j - 3].type])
50775 {
50776 PlaceDoor(i, j - 1, num, style);
50777 SquareTileFrame(i, j);
50778 }
50779 else
50780 {
50781 if (Main.tile[i, j + 1].active() || Main.tile[i, j + 2].active() || !Main.tile[i, j + 3].active() || !Main.tileSolid[Main.tile[i, j + 3].type])
50782 {
50783 return false;
50784 }
50785 PlaceDoor(i, j + 1, num, style);
50786 SquareTileFrame(i, j);
50787 }
50788 }
50789 else if ((num >= 275 && num <= 281) || num == 296 || num == 297 || num == 309 || num == 358 || num == 359 || num == 413 || num == 414 || num == 542)
50790 {
50791 Place6x3(i, j, (ushort)num);
50792 }
50793 else if (num == 237 || num == 244 || num == 285 || num == 286 || num == 298 || num == 299 || num == 310 || num == 339 || num == 538 || (num >= 361 && num <= 364) || num == 532 || num == 533 || num == 486 || num == 488 || num == 544 || num == 582 || num == 619 || num == 629)
50794 {
50795 Place3x2(i, j, (ushort)num);
50796 }
50797 else if (num == 128)
50798 {
50799 PlaceMan(i, j, style);
50800 SquareTileFrame(i, j);
50801 }
50802 else if (num == 269)
50803 {
50804 PlaceWoman(i, j, style);
50805 SquareTileFrame(i, j);
50806 }
50807 else if (num == 334)
50808 {
50809 int style2 = 0;
50810 if (style == -1)
50811 {
50812 style2 = 1;
50813 }
50814 Place3x3Wall(i, j, 334, style2);
50815 SquareTileFrame(i, j);
50816 }
50817 else if (num == 149)
50818 {
50819 if (SolidTile(i - 1, j) || SolidTile(i + 1, j) || SolidTile(i, j - 1) || SolidTile(i, j + 1))
50820 {
50821 tile.frameX = (short)(18 * style);
50822 tile.active(active: true);
50823 tile.type = (ushort)num;
50824 SquareTileFrame(i, j);
50825 }
50826 }
50827 else if (num == 139 || num == 35)
50828 {
50829 PlaceMB(i, j, (ushort)num, style);
50830 SquareTileFrame(i, j);
50831 }
50832 else if (num == 165)
50833 {
50834 PlaceTight(i, j);
50835 SquareTileFrame(i, j);
50836 }
50837 else if (num == 235)
50838 {
50839 Place3x1(i, j, (ushort)num);
50840 SquareTileFrame(i, j);
50841 }
50842 else if (num == 240)
50843 {
50844 Place3x3Wall(i, j, (ushort)num, style);
50845 }
50846 else if (num == 440)
50847 {
50848 Place3x3Wall(i, j, (ushort)num, style);
50849 }
50850 else if (num == 245)
50851 {
50852 Place2x3Wall(i, j, (ushort)num, style);
50853 }
50854 else if (num == 246)
50855 {
50856 Place3x2Wall(i, j, (ushort)num, style);
50857 }
50858 else if (num == 241)
50859 {
50860 Place4x3Wall(i, j, (ushort)num, style);
50861 }
50862 else if (num == 242)
50863 {
50864 Place6x4Wall(i, j, (ushort)num, style);
50865 }
50866 else if (num == 34)
50867 {
50868 PlaceChand(i, j, (ushort)num, style);
50869 SquareTileFrame(i, j);
50870 }
50871 else if (num == 106 || num == 212 || num == 219 || num == 220 || num == 228 || num == 231 || num == 243 || num == 247 || num == 283 || (num >= 300 && num <= 308) || num == 354 || num == 355 || num == 491 || num == 642)
50872 {
50873 Place3x3(i, j, (ushort)num, style);
50874 SquareTileFrame(i, j);
50875 }
50876 else
50877 {
50878 switch (num)
50879 {
50880 case 13:
50881 case 33:
50882 case 49:
50883 case 50:
50884 case 78:
50885 case 174:
50886 case 372:
50887 case 646:
50888 PlaceOnTable1x1(i, j, num, style);
50889 SquareTileFrame(i, j);
50890 break;
50891 case 14:
50892 case 26:
50893 case 86:
50894 case 87:
50895 case 88:
50896 case 89:
50897 case 114:
50898 case 186:
50899 case 187:
50900 case 215:
50901 case 217:
50902 case 218:
50903 case 377:
50904 case 469:
50905 Place3x2(i, j, (ushort)num, style);
50906 SquareTileFrame(i, j);
50907 break;
50908 case 236:
50909 PlaceJunglePlant(i, j, (ushort)num, genRand.Next(3), 0);
50910 SquareTileFrame(i, j);
50911 break;
50912 case 238:
50913 PlaceJunglePlant(i, j, (ushort)num, 0, 0);
50914 SquareTileFrame(i, j);
50915 break;
50916 case 20:
50917 {
50918 if (Main.tile[i, j + 1] == null)
50919 {
50920 Main.tile[i, j + 1] = new Tile();
50921 }
50922 int type = Main.tile[i, j + 1].type;
50923 if (Main.tile[i, j + 1].active() && (type == 2 || type == 109 || type == 147 || type == 60 || type == 23 || type == 199 || type == 661 || type == 662 || type == 53 || type == 234 || type == 116 || type == 112))
50924 {
50925 Place1x2(i, j, (ushort)num, style);
50926 SquareTileFrame(i, j);
50927 }
50928 break;
50929 }
50930 case 15:
50931 case 216:
50932 case 338:
50933 case 390:
50934 if (Main.tile[i, j - 1] == null)
50935 {
50936 Main.tile[i, j - 1] = new Tile();
50937 }
50938 if (Main.tile[i, j] == null)
50939 {
50940 Main.tile[i, j] = new Tile();
50941 }
50942 Place1x2(i, j, (ushort)num, style);
50943 SquareTileFrame(i, j);
50944 break;
50945 case 227:
50946 PlaceDye(i, j, style);
50947 SquareTileFrame(i, j);
50948 break;
50949 case 567:
50950 PlaceGnome(i, j, style);
50951 SquareTileFrame(i, j);
50952 break;
50953 case 16:
50954 case 18:
50955 case 29:
50956 case 103:
50957 case 134:
50958 case 462:
50959 Place2x1(i, j, (ushort)num, style);
50960 SquareTileFrame(i, j);
50961 break;
50962 case 92:
50963 case 93:
50964 case 453:
50965 Place1xX(i, j, (ushort)num, style);
50966 SquareTileFrame(i, j);
50967 break;
50968 case 104:
50969 case 105:
50970 case 320:
50971 case 337:
50972 case 349:
50973 case 356:
50974 case 378:
50975 case 456:
50976 case 506:
50977 case 545:
50978 case 663:
50979 Place2xX(i, j, (ushort)num, style);
50980 SquareTileFrame(i, j);
50981 break;
50982 case 17:
50983 case 77:
50984 case 133:
50985 Place3x2(i, j, (ushort)num, style);
50986 SquareTileFrame(i, j);
50987 break;
50988 case 207:
50989 Place2xX(i, j, (ushort)num, style);
50990 SquareTileFrame(i, j);
50991 break;
50992 case 410:
50993 case 480:
50994 case 509:
50995 case 657:
50996 case 658:
50997 Place2xX(i, j, (ushort)num, style);
50998 SquareTileFrame(i, j);
50999 break;
51000 case 465:
51001 case 531:
51002 case 591:
51003 case 592:
51004 Place2xX(i, j, (ushort)num, style);
51005 SquareTileFrame(i, j);
51006 break;
51007 default:
51008 if (TileID.Sets.BasicChest[num])
51009 {
51010 PlaceChest(i, j, (ushort)num, notNearOtherChests: false, style);
51011 SquareTileFrame(i, j);
51012 break;
51013 }
51014 switch (num)
51015 {
51016 case 91:
51017 PlaceBanner(i, j, (ushort)num, style);
51018 SquareTileFrame(i, j);
51019 break;
51020 case 419:
51021 case 420:
51022 case 423:
51023 case 424:
51024 case 429:
51025 case 445:
51026 PlaceLogicTiles(i, j, num, style);
51027 SquareTileFrame(i, j);
51028 break;
51029 case 36:
51030 case 135:
51031 case 141:
51032 case 144:
51033 case 210:
51034 case 239:
51035 case 324:
51036 case 476:
51037 case 494:
51038 Place1x1(i, j, num, style);
51039 SquareTileFrame(i, j);
51040 break;
51041 case 101:
51042 case 102:
51043 case 463:
51044 Place3x4(i, j, (ushort)num, style);
51045 SquareTileFrame(i, j);
51046 break;
51047 case 464:
51048 case 466:
51049 Place5x4(i, j, (ushort)num, style);
51050 SquareTileFrame(i, j);
51051 break;
51052 case 27:
51053 PlaceSunflower(i, j, 27);
51054 SquareTileFrame(i, j);
51055 break;
51056 case 28:
51057 PlacePot(i, j, 28, genRand.Next(4));
51058 SquareTileFrame(i, j);
51059 break;
51060 case 42:
51061 case 270:
51062 case 271:
51063 Place1x2Top(i, j, (ushort)num, style);
51064 SquareTileFrame(i, j);
51065 break;
51066 case 55:
51067 case 425:
51068 case 510:
51069 case 511:
51070 PlaceSign(i, j, (ushort)num, style);
51071 break;
51072 case 85:
51073 case 376:
51074 Place2x2Horizontal(i, j, (ushort)num, style);
51075 break;
51076 default:
51077 if (Main.tileAlch[num])
51078 {
51079 PlaceAlch(i, j, style);
51080 break;
51081 }
51082 switch (num)
51083 {
51084 case 94:
51085 case 95:
51086 case 97:
51087 case 98:
51088 case 99:
51089 case 100:
51090 case 125:
51091 case 126:
51092 case 172:
51093 case 173:
51094 case 287:
51095 Place2x2(i, j, (ushort)num, style);
51096 break;
51097 case 96:
51098 Place2x2Style(i, j, (ushort)num, style);
51099 break;
51100 case 79:
51101 case 90:
51102 {
51103 int direction = 1;
51104 if (plr > -1)
51105 {
51106 direction = Main.player[plr].direction;
51107 }
51108 Place4x2(i, j, (ushort)num, direction, style);
51109 break;
51110 }
51111 case 209:
51112 PlaceCannon(i, j, (ushort)num, style);
51113 break;
51114 case 81:
51115 tile.frameX = (short)(26 * genRand.Next(6));
51116 tile.active(active: true);
51117 tile.type = (ushort)num;
51118 break;
51119 case 19:
51120 tile.frameY = (short)(18 * style);
51121 tile.active(active: true);
51122 tile.type = (ushort)num;
51123 break;
51124 case 380:
51125 tile.frameY = (short)(18 * style);
51126 tile.active(active: true);
51127 tile.type = (ushort)num;
51128 break;
51129 case 314:
51130 Minecart.PlaceTrack(tile, style);
51131 break;
51132 default:
51133 tile.active(active: true);
51134 tile.type = (ushort)num;
51135 if (Main.tenthAnniversaryWorld && !Main.remixWorld && (num == 53 || num == 396 || num == 397))
51136 {
51137 tile.color(7);
51138 }
51139 break;
51140 }
51141 break;
51142 }
51143 break;
51144 }
51145 }
51146 if (tile.active())
51147 {
51149 {
51150 SquareWallFrame(i, j);
51151 }
51152 SquareTileFrame(i, j);
51153 result = true;
51154 if (!mute)
51155 {
51156 switch (num)
51157 {
51158 case 127:
51159 SoundEngine.PlaySound(SoundID.Item30, i * 16, j * 16);
51160 break;
51161 case 314:
51162 SoundEngine.PlaySound(SoundID.Item52, i * 16, j * 16);
51163 break;
51164 case 330:
51165 case 331:
51166 case 332:
51167 case 333:
51168 SoundEngine.PlaySound(18, i * 16, j * 16);
51169 break;
51170 default:
51171 SoundEngine.PlaySound(0, i * 16, j * 16);
51172 break;
51173 }
51174 if (num == 22 || num == 140)
51175 {
51176 for (int l = 0; l < 3; l++)
51177 {
51178 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 14);
51179 }
51180 }
51181 }
51182 }
51183 }
51184 }
51185 return result;
51186 }
51187
51188 public static void KillWall(int i, int j, bool fail = false)
51189 {
51190 if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
51191 {
51192 return;
51193 }
51194 Tile tile = Main.tile[i, j];
51195 if (tile == null)
51196 {
51197 tile = new Tile();
51198 Main.tile[i, j] = tile;
51199 }
51200 if (tile.wall <= 0)
51201 {
51202 return;
51203 }
51204 fail = KillWall_CheckFailure(fail, tile);
51205 KillWall_PlaySounds(i, j, tile);
51206 int num = 10;
51207 if (fail)
51208 {
51209 num = 3;
51210 }
51211 for (int k = 0; k < num; k++)
51212 {
51213 KillWall_MakeWallDust(i, j, tile);
51214 }
51215 if (fail)
51216 {
51217 SquareWallFrame(i, j);
51218 return;
51219 }
51220 KillWall_DropItems(i, j, tile);
51221 tile.wall = 0;
51223 SquareWallFrame(i, j);
51224 if (tile.type >= 0 && tile.type < TileID.Count && TileID.Sets.FramesOnKillWall[tile.type])
51225 {
51226 TileFrame(i, j);
51227 }
51228 }
51229
51230 private static bool KillWall_CheckFailure(bool fail, Tile tileCache)
51231 {
51232 if (Main.wallDungeon[tileCache.wall] && !NPC.downedBoss3)
51233 {
51234 fail = true;
51235 }
51236 if (tileCache.wall == 87 && !NPC.downedGolemBoss)
51237 {
51238 fail = true;
51239 }
51240 return fail;
51241 }
51242
51243 private static void KillWall_PlaySounds(int i, int j, Tile tileCache)
51244 {
51245 if (tileCache.wall == 241 || (tileCache.wall >= 88 && tileCache.wall <= 93) || tileCache.wall == 21 || tileCache.wall == 186 || tileCache.wall == 136 || tileCache.wall == 137 || tileCache.wall == 168 || tileCache.wall == 169 || tileCache.wall == 172 || tileCache.wall == 226 || tileCache.wall == 227 || tileCache.wall == 242 || tileCache.wall == 243)
51246 {
51247 SoundEngine.PlaySound(13, i * 16, j * 16);
51248 }
51249 else if ((tileCache.wall >= 63 && tileCache.wall <= 70) || tileCache.wall == 264 || tileCache.wall == 268 || tileCache.wall == 265)
51250 {
51251 SoundEngine.PlaySound(6, i * 16, j * 16);
51252 }
51253 else
51254 {
51255 SoundEngine.PlaySound(0, i * 16, j * 16);
51256 }
51257 }
51258
51259 private static void KillWall_DropItems(int i, int j, Tile tileCache)
51260 {
51261 int num = KillWall_GetItemDrops(tileCache);
51262 if (num > 0)
51263 {
51264 Item.NewItem(GetItemSource_FromWallBreak(i, j), i * 16, j * 16, 16, 16, num);
51265 }
51266 }
51267
51268 private static int KillWall_GetItemDrops(Tile tileCache)
51269 {
51270 switch (tileCache.wall)
51271 {
51272 case 237:
51273 return 4233;
51274 case 238:
51275 return 4234;
51276 case 239:
51277 return 4235;
51278 case 240:
51279 return 4236;
51280 case 246:
51281 return 4486;
51282 case 247:
51283 return 4487;
51284 case 248:
51285 return 4488;
51286 case 249:
51287 return 4489;
51288 case 250:
51289 return 4490;
51290 case 251:
51291 return 4491;
51292 case 252:
51293 return 4492;
51294 case 253:
51295 return 4493;
51296 case 254:
51297 return 4494;
51298 case 255:
51299 return 4495;
51300 case 314:
51301 return 4647;
51302 case 256:
51303 return 4496;
51304 case 257:
51305 return 4497;
51306 case 258:
51307 return 4498;
51308 case 259:
51309 return 4499;
51310 case 260:
51311 return 4500;
51312 case 261:
51313 return 4501;
51314 case 262:
51315 return 4502;
51316 case 263:
51317 return 4503;
51318 case 264:
51319 return 4504;
51320 case 265:
51321 return 4505;
51322 case 266:
51323 return 4506;
51324 case 267:
51325 return 4507;
51326 case 268:
51327 return 4508;
51328 case 269:
51329 return 4509;
51330 case 270:
51331 return 4510;
51332 case 271:
51333 return 4511;
51334 case 274:
51335 return 4512;
51336 case 275:
51337 return 3273;
51338 case 276:
51339 return 4513;
51340 case 277:
51341 return 4514;
51342 case 278:
51343 return 4515;
51344 case 279:
51345 return 4516;
51346 case 280:
51347 return 4517;
51348 case 281:
51349 return 4518;
51350 case 282:
51351 return 4519;
51352 case 283:
51353 return 4520;
51354 case 284:
51355 return 4521;
51356 case 285:
51357 return 4522;
51358 case 286:
51359 return 4523;
51360 case 287:
51361 return 4524;
51362 case 288:
51363 return 4525;
51364 case 289:
51365 return 4526;
51366 case 290:
51367 return 4527;
51368 case 291:
51369 return 4528;
51370 case 292:
51371 return 4529;
51372 case 293:
51373 return 4530;
51374 case 294:
51375 return 4531;
51376 case 295:
51377 return 4532;
51378 case 296:
51379 return 4533;
51380 case 297:
51381 return 4534;
51382 case 298:
51383 return 4535;
51384 case 299:
51385 return 4536;
51386 case 300:
51387 return 4537;
51388 case 301:
51389 return 4538;
51390 case 302:
51391 return 4539;
51392 case 303:
51393 return 4540;
51394 case 304:
51395 return 3340;
51396 case 305:
51397 return 3341;
51398 case 306:
51399 return 3342;
51400 case 307:
51401 return 3343;
51402 case 308:
51403 return 3344;
51404 case 309:
51405 return 3345;
51406 case 310:
51407 return 3346;
51408 case 311:
51409 return 3348;
51410 default:
51411 {
51412 int result = 0;
51413 if (tileCache.wall == 168)
51414 {
51415 result = 2696;
51416 }
51417 if (tileCache.wall == 169)
51418 {
51419 result = 2698;
51420 }
51421 if (tileCache.wall == 226)
51422 {
51423 result = 3752;
51424 }
51425 if (tileCache.wall == 227)
51426 {
51427 result = 3753;
51428 }
51429 if (tileCache.wall == 228)
51430 {
51431 result = 3760;
51432 }
51433 if (tileCache.wall == 229)
51434 {
51435 result = 3761;
51436 }
51437 if (tileCache.wall == 230)
51438 {
51439 result = 3762;
51440 }
51441 if (tileCache.wall == 142)
51442 {
51443 result = 2263;
51444 }
51445 if (tileCache.wall == 143)
51446 {
51447 result = 2264;
51448 }
51449 if (tileCache.wall == 144)
51450 {
51451 result = 2271;
51452 }
51453 if (tileCache.wall == 149)
51454 {
51455 result = 2505;
51456 }
51457 if (tileCache.wall == 150)
51458 {
51459 result = 2507;
51460 }
51461 if (tileCache.wall == 151)
51462 {
51463 result = 2506;
51464 }
51465 if (tileCache.wall == 152)
51466 {
51467 result = 2508;
51468 }
51469 if (tileCache.wall == 316)
51470 {
51471 result = 5216;
51472 }
51473 if (tileCache.wall == 317)
51474 {
51475 result = 5217;
51476 }
51477 if (tileCache.wall == 245)
51478 {
51479 result = 4424;
51480 }
51481 if (tileCache.wall == 315)
51482 {
51483 result = 4667;
51484 }
51485 if (tileCache.wall == 1)
51486 {
51487 result = 26;
51488 }
51489 if (tileCache.wall == 4)
51490 {
51491 result = 93;
51492 }
51493 if (tileCache.wall == 5)
51494 {
51495 result = 130;
51496 }
51497 if (tileCache.wall == 6)
51498 {
51499 result = 132;
51500 }
51501 if (tileCache.wall == 7)
51502 {
51503 result = 135;
51504 }
51505 if (tileCache.wall == 8)
51506 {
51507 result = 138;
51508 }
51509 if (tileCache.wall == 9)
51510 {
51511 result = 140;
51512 }
51513 if (tileCache.wall == 10)
51514 {
51515 result = 142;
51516 }
51517 if (tileCache.wall == 11)
51518 {
51519 result = 144;
51520 }
51521 if (tileCache.wall == 12)
51522 {
51523 result = 146;
51524 }
51525 if (tileCache.wall == 14)
51526 {
51527 result = 330;
51528 }
51529 if (tileCache.wall == 224)
51530 {
51531 result = 3472;
51532 }
51533 if (tileCache.wall == 323)
51534 {
51535 result = 5409;
51536 }
51537 if (tileCache.wall == 324)
51538 {
51539 result = 5410;
51540 }
51541 if (tileCache.wall == 325)
51542 {
51543 result = 5411;
51544 }
51545 if (tileCache.wall == 326)
51546 {
51547 result = 5412;
51548 }
51549 if (tileCache.wall == 327)
51550 {
51551 result = 5413;
51552 }
51553 if (tileCache.wall == 328)
51554 {
51555 result = 5414;
51556 }
51557 if (tileCache.wall == 329)
51558 {
51559 result = 5415;
51560 }
51561 if (tileCache.wall == 330)
51562 {
51563 result = 5416;
51564 }
51565 if (tileCache.wall == 331)
51566 {
51567 result = 5418;
51568 }
51569 if (tileCache.wall == 332)
51570 {
51571 result = 5420;
51572 }
51573 if (tileCache.wall == 333)
51574 {
51575 result = 5422;
51576 }
51577 if (tileCache.wall == 334)
51578 {
51579 result = 5424;
51580 }
51581 if (tileCache.wall == 335)
51582 {
51583 result = 5426;
51584 }
51585 if (tileCache.wall == 336)
51586 {
51587 result = 5428;
51588 }
51589 if (tileCache.wall == 337)
51590 {
51591 result = 5434;
51592 }
51593 if (tileCache.wall == 338)
51594 {
51595 result = 5436;
51596 }
51597 if (tileCache.wall == 339)
51598 {
51599 result = 5430;
51600 }
51601 if (tileCache.wall == 340)
51602 {
51603 result = 5432;
51604 }
51605 if (tileCache.wall == 341)
51606 {
51607 result = 5445;
51608 }
51609 if (tileCache.wall == 342)
51610 {
51611 result = 5446;
51612 }
51613 if (tileCache.wall == 343)
51614 {
51615 result = 5447;
51616 }
51617 if (tileCache.wall == 344)
51618 {
51619 result = 5448;
51620 }
51621 if (tileCache.wall == 345)
51622 {
51623 result = 5449;
51624 }
51625 if (tileCache.wall == 346)
51626 {
51627 result = 5450;
51628 }
51629 if (tileCache.wall == 177)
51630 {
51631 result = 3067;
51632 }
51633 if (tileCache.wall == 167)
51634 {
51635 result = 2691;
51636 }
51637 if (tileCache.wall == 60)
51638 {
51639 result = 3584;
51640 }
51641 if (tileCache.wall == 231)
51642 {
51643 result = 3952;
51644 }
51645 if (tileCache.wall == 232)
51646 {
51647 result = 3954;
51648 }
51649 if (tileCache.wall == 225)
51650 {
51651 result = 3751;
51652 }
51653 if (tileCache.wall == 233)
51654 {
51655 result = 3956;
51656 }
51657 if (tileCache.wall == 234)
51658 {
51659 result = 4052;
51660 }
51661 if (tileCache.wall == 235)
51662 {
51663 result = 4053;
51664 }
51665 if (tileCache.wall == 236)
51666 {
51667 result = 4140;
51668 }
51669 if (tileCache.wall == 312)
51670 {
51671 result = 4565;
51672 }
51673 if (tileCache.wall == 313)
51674 {
51675 result = 4548;
51676 }
51677 if (tileCache.wall == 319)
51678 {
51679 result = 5307;
51680 }
51681 if (tileCache.wall == 318)
51682 {
51683 result = 5291;
51684 }
51685 if (tileCache.wall == 179)
51686 {
51687 result = 3083;
51688 }
51689 if (tileCache.wall == 183)
51690 {
51691 result = 3082;
51692 }
51693 if (tileCache.wall == 321)
51694 {
51695 result = 5397;
51696 }
51697 if (tileCache.wall == 322)
51698 {
51699 result = 5399;
51700 }
51701 if (tileCache.wall == 181)
51702 {
51703 result = 3089;
51704 }
51705 if (tileCache.wall == 184)
51706 {
51707 result = 3088;
51708 }
51709 if (tileCache.wall == 186)
51710 {
51711 result = 3238;
51712 }
51713 if (tileCache.wall == 320)
51714 {
51715 result = 5396;
51716 }
51717 if (tileCache.wall >= 153 && tileCache.wall <= 166)
51718 {
51719 switch (tileCache.wall)
51720 {
51721 case 154:
51722 result = 2679;
51723 break;
51724 case 158:
51725 result = 2680;
51726 break;
51727 case 166:
51728 result = 2689;
51729 break;
51730 case 163:
51731 result = 2690;
51732 break;
51733 case 165:
51734 result = 2687;
51735 break;
51736 case 162:
51737 result = 2688;
51738 break;
51739 case 156:
51740 result = 2683;
51741 break;
51742 case 160:
51743 result = 2684;
51744 break;
51745 case 164:
51746 result = 2685;
51747 break;
51748 case 161:
51749 result = 2686;
51750 break;
51751 case 155:
51752 result = 2681;
51753 break;
51754 case 159:
51755 result = 2682;
51756 break;
51757 case 153:
51758 result = 2677;
51759 break;
51760 case 157:
51761 result = 2678;
51762 break;
51763 }
51764 }
51765 if (tileCache.wall == 136)
51766 {
51767 result = 2169;
51768 }
51769 if (tileCache.wall == 137)
51770 {
51771 result = 2170;
51772 }
51773 if (tileCache.wall == 172)
51774 {
51775 result = 2788;
51776 }
51777 if (tileCache.wall == 242)
51778 {
51779 result = 4279;
51780 }
51781 if (tileCache.wall == 243)
51782 {
51783 result = 4280;
51784 }
51785 if (tileCache.wall == 145)
51786 {
51787 result = 2333;
51788 }
51789 if (tileCache.wall == 16)
51790 {
51791 result = 30;
51792 }
51793 if (tileCache.wall == 17)
51794 {
51795 result = 135;
51796 }
51797 if (tileCache.wall == 18)
51798 {
51799 result = 138;
51800 }
51801 if (tileCache.wall == 19)
51802 {
51803 result = 140;
51804 }
51805 if (tileCache.wall == 20)
51806 {
51807 result = 330;
51808 }
51809 if (tileCache.wall == 21)
51810 {
51811 result = 392;
51812 }
51813 if (tileCache.wall == 86 || tileCache.wall == 108)
51814 {
51815 result = 1126;
51816 }
51817 if (tileCache.wall == 173)
51818 {
51819 result = 2789;
51820 }
51821 if (tileCache.wall == 174)
51822 {
51823 result = 2790;
51824 }
51825 if (tileCache.wall == 175)
51826 {
51827 result = 2791;
51828 }
51829 if (tileCache.wall == 176)
51830 {
51831 result = 2861;
51832 }
51833 if (tileCache.wall == 182)
51834 {
51835 result = 3101;
51836 }
51837 if (tileCache.wall == 133)
51838 {
51839 result = 2158;
51840 }
51841 if (tileCache.wall == 134)
51842 {
51843 result = 2159;
51844 }
51845 if (tileCache.wall == 135)
51846 {
51847 result = 2160;
51848 }
51849 else if (tileCache.wall == 113)
51850 {
51851 result = 1726;
51852 }
51853 else if (tileCache.wall == 114)
51854 {
51855 result = 1728;
51856 }
51857 else if (tileCache.wall == 115)
51858 {
51859 result = 1730;
51860 }
51861 else if (tileCache.wall == 146)
51862 {
51863 result = 2432;
51864 }
51865 else if (tileCache.wall == 147)
51866 {
51867 result = 2433;
51868 }
51869 else if (tileCache.wall == 148)
51870 {
51871 result = 2434;
51872 }
51873 if (tileCache.wall >= 116 && tileCache.wall <= 125)
51874 {
51875 result = 1948 + tileCache.wall - 116;
51876 }
51877 if (tileCache.wall >= 126 && tileCache.wall <= 132)
51878 {
51879 result = 2008 + tileCache.wall - 126;
51880 }
51881 if (tileCache.wall == 22)
51882 {
51883 result = 417;
51884 }
51885 if (tileCache.wall == 23)
51886 {
51887 result = 418;
51888 }
51889 if (tileCache.wall == 24)
51890 {
51891 result = 419;
51892 }
51893 if (tileCache.wall == 25)
51894 {
51895 result = 420;
51896 }
51897 if (tileCache.wall == 26)
51898 {
51899 result = 421;
51900 }
51901 if (tileCache.wall == 29)
51902 {
51903 result = 587;
51904 }
51905 if (tileCache.wall == 30)
51906 {
51907 result = 592;
51908 }
51909 if (tileCache.wall == 31)
51910 {
51911 result = 595;
51912 }
51913 if (tileCache.wall == 32)
51914 {
51915 result = 605;
51916 }
51917 if (tileCache.wall == 33)
51918 {
51919 result = 606;
51920 }
51921 if (tileCache.wall == 34)
51922 {
51923 result = 608;
51924 }
51925 if (tileCache.wall == 35)
51926 {
51927 result = 610;
51928 }
51929 if (tileCache.wall == 36)
51930 {
51931 result = 615;
51932 }
51933 if (tileCache.wall == 37)
51934 {
51935 result = 616;
51936 }
51937 if (tileCache.wall == 38)
51938 {
51939 result = 617;
51940 }
51941 if (tileCache.wall == 39)
51942 {
51943 result = 618;
51944 }
51945 if (tileCache.wall == 41)
51946 {
51947 result = 622;
51948 }
51949 if (tileCache.wall == 42)
51950 {
51951 result = 623;
51952 }
51953 if (tileCache.wall == 43)
51954 {
51955 result = 624;
51956 }
51957 if (tileCache.wall == 44)
51958 {
51959 result = 663;
51960 }
51961 if (tileCache.wall == 45)
51962 {
51963 result = 720;
51964 }
51965 if (tileCache.wall == 46)
51966 {
51967 result = 721;
51968 }
51969 if (tileCache.wall == 47)
51970 {
51971 result = 722;
51972 }
51973 if (tileCache.wall == 66)
51974 {
51975 result = 745;
51976 }
51977 if (tileCache.wall == 67)
51978 {
51979 result = 746;
51980 }
51981 if (tileCache.wall == 68)
51982 {
51983 result = 747;
51984 }
51985 if (tileCache.wall == 84)
51986 {
51987 result = 884;
51988 }
51989 if (tileCache.wall == 72)
51990 {
51991 result = 750;
51992 }
51993 if (tileCache.wall == 73)
51994 {
51995 result = 752;
51996 }
51997 if (tileCache.wall == 74)
51998 {
51999 result = 764;
52000 }
52001 if (tileCache.wall == 85)
52002 {
52003 result = 927;
52004 }
52005 if (tileCache.wall == 75)
52006 {
52007 result = 768;
52008 }
52009 if (tileCache.wall == 76)
52010 {
52011 result = 769;
52012 }
52013 if (tileCache.wall == 77)
52014 {
52015 result = 770;
52016 }
52017 if (tileCache.wall == 82)
52018 {
52019 result = 825;
52020 }
52021 if (tileCache.wall == 27)
52022 {
52023 result = 479;
52024 }
52025 if (tileCache.wall == 106)
52026 {
52027 result = 1447;
52028 }
52029 if (tileCache.wall == 107)
52030 {
52031 result = 1448;
52032 }
52033 if (tileCache.wall == 109)
52034 {
52035 result = 1590;
52036 }
52037 if (tileCache.wall == 110)
52038 {
52039 result = 1592;
52040 }
52041 if (tileCache.wall == 111)
52042 {
52043 result = 1594;
52044 }
52045 if (tileCache.wall == 78)
52046 {
52047 result = 1723;
52048 }
52049 if (tileCache.wall == 87 || tileCache.wall == 112)
52050 {
52051 result = 1102;
52052 }
52053 if (tileCache.wall == 94 || tileCache.wall == 100)
52054 {
52055 result = 1378;
52056 }
52057 if (tileCache.wall == 95 || tileCache.wall == 101)
52058 {
52059 result = 1379;
52060 }
52061 if (tileCache.wall == 96 || tileCache.wall == 102)
52062 {
52063 result = 1380;
52064 }
52065 if (tileCache.wall == 97 || tileCache.wall == 103)
52066 {
52067 result = 1381;
52068 }
52069 if (tileCache.wall == 98 || tileCache.wall == 104)
52070 {
52071 result = 1382;
52072 }
52073 if (tileCache.wall == 99 || tileCache.wall == 105)
52074 {
52075 result = 1383;
52076 }
52077 if (tileCache.wall == 241)
52078 {
52079 result = 4260;
52080 }
52081 if (tileCache.wall >= 88 && tileCache.wall <= 93)
52082 {
52083 result = 1267 + tileCache.wall - 88;
52084 }
52085 if (tileCache.wall >= 138 && tileCache.wall <= 141)
52086 {
52087 result = 2210 + tileCache.wall - 138;
52088 }
52089 return result;
52090 }
52091 }
52092 }
52093
52094 private static void KillWall_MakeWallDust(int i, int j, Tile tileCache)
52095 {
52096 int num = 0;
52097 switch (tileCache.wall)
52098 {
52099 case 316:
52100 case 317:
52101 num = 36;
52102 break;
52103 case 7:
52104 case 17:
52105 case 94:
52106 case 95:
52107 case 100:
52108 case 101:
52109 case 331:
52110 num = 275;
52111 break;
52112 case 8:
52113 case 18:
52114 case 98:
52115 case 99:
52116 case 104:
52117 case 105:
52118 case 332:
52119 num = 276;
52120 break;
52121 case 9:
52122 case 19:
52123 case 96:
52124 case 97:
52125 case 102:
52126 case 103:
52127 case 333:
52128 num = 277;
52129 break;
52130 case 232:
52131 num = 82;
52132 break;
52133 case 231:
52134 num = 8;
52135 break;
52136 case 233:
52137 num = 18;
52138 break;
52139 case 237:
52140 num = 6;
52141 break;
52142 case 238:
52143 num = 61;
52144 break;
52145 case 239:
52146 num = 242;
52147 break;
52148 case 240:
52149 num = 135;
52150 break;
52151 case 3:
52152 case 246:
52153 num = ((genRand.Next(2) != 0) ? 1 : 14);
52154 break;
52155 case 15:
52156 case 247:
52157 num = 38;
52158 break;
52159 case 22:
52160 case 28:
52161 case 248:
52162 num = 51;
52163 break;
52164 case 40:
52165 case 249:
52166 num = 51;
52167 break;
52168 case 48:
52169 case 49:
52170 case 50:
52171 case 51:
52172 case 52:
52173 case 53:
52174 case 54:
52175 case 55:
52176 case 56:
52177 case 57:
52178 case 58:
52179 case 185:
52180 case 250:
52181 case 251:
52182 case 252:
52183 case 253:
52184 case 254:
52185 case 255:
52186 case 256:
52187 case 257:
52188 case 258:
52189 case 259:
52190 case 260:
52191 case 274:
52192 case 314:
52193 num = 1;
52194 break;
52195 case 59:
52196 case 61:
52197 case 261:
52198 case 262:
52199 num = 0;
52200 break;
52201 case 62:
52202 case 263:
52203 num = 0;
52204 break;
52205 case 69:
52206 case 264:
52207 num = ((genRand.Next(2) != 0) ? 17 : 14);
52208 break;
52209 case 70:
52210 case 265:
52211 num = 47;
52212 break;
52213 case 71:
52214 case 266:
52215 num = 80;
52216 break;
52217 case 79:
52218 case 267:
52219 num = 37;
52220 break;
52221 case 81:
52222 case 268:
52223 num = 123;
52224 break;
52225 case 83:
52226 case 234:
52227 case 269:
52228 num = ((genRand.Next(2) == 0) ? 1 : 117);
52229 break;
52230 case 170:
52231 case 171:
52232 case 270:
52233 case 271:
52234 num = 0;
52235 break;
52236 case 187:
52237 case 275:
52238 num = 0;
52239 break;
52240 case 188:
52241 case 189:
52242 case 190:
52243 case 191:
52244 case 276:
52245 case 277:
52246 case 278:
52247 case 279:
52248 num = 37;
52249 break;
52250 case 192:
52251 case 193:
52252 case 194:
52253 case 195:
52254 case 280:
52255 case 281:
52256 case 282:
52257 case 283:
52258 num = 117;
52259 break;
52260 case 196:
52261 case 197:
52262 case 198:
52263 case 199:
52264 case 284:
52265 case 285:
52266 case 286:
52267 case 287:
52268 num = 0;
52269 break;
52270 case 200:
52271 case 202:
52272 case 288:
52273 case 290:
52274 num = ((genRand.Next(2) != 0) ? 70 : 69);
52275 break;
52276 case 201:
52277 case 289:
52278 num = 17;
52279 break;
52280 case 203:
52281 case 291:
52282 num = ((genRand.Next(2) != 0) ? 68 : 69);
52283 break;
52284 case 204:
52285 case 205:
52286 case 207:
52287 case 292:
52288 case 293:
52289 case 295:
52290 num = 0;
52291 break;
52292 case 206:
52293 case 294:
52294 num = 1;
52295 break;
52296 case 208:
52297 case 209:
52298 case 210:
52299 case 211:
52300 case 296:
52301 case 297:
52302 case 298:
52303 case 299:
52304 num = ((genRand.Next(2) != 0) ? 125 : 155);
52305 break;
52306 case 212:
52307 case 213:
52308 case 214:
52309 case 215:
52310 case 300:
52311 case 301:
52312 case 302:
52313 case 303:
52314 num = 1;
52315 break;
52316 case 216:
52317 case 304:
52318 num = 0;
52319 break;
52320 case 217:
52321 case 305:
52322 num = 37;
52323 break;
52324 case 218:
52325 case 306:
52326 num = 155;
52327 break;
52328 case 219:
52329 case 307:
52330 num = 17;
52331 break;
52332 case 220:
52333 case 308:
52334 num = 37;
52335 break;
52336 case 221:
52337 case 309:
52338 num = 155;
52339 break;
52340 case 222:
52341 case 310:
52342 num = 37;
52343 break;
52344 case 223:
52345 case 311:
52346 num = 0;
52347 break;
52348 case 312:
52349 case 313:
52350 case 315:
52351 num = -1;
52352 break;
52353 }
52354 if (tileCache.wall == 148)
52355 {
52356 num = -1;
52357 }
52358 if (tileCache.wall == 1 || tileCache.wall == 5 || tileCache.wall == 6 || tileCache.wall == 107)
52359 {
52360 num = 1;
52361 }
52362 if (tileCache.wall == 35)
52363 {
52364 num = 37;
52365 }
52366 if (tileCache.wall == 4 || tileCache.wall == 106)
52367 {
52368 num = 7;
52369 }
52370 if (tileCache.wall == 12)
52371 {
52372 num = 9;
52373 }
52374 if (tileCache.wall == 336)
52375 {
52376 num = 9;
52377 }
52378 if (tileCache.wall == 10)
52379 {
52380 num = 10;
52381 }
52382 if (tileCache.wall == 334)
52383 {
52384 num = 10;
52385 }
52386 if (tileCache.wall == 11)
52387 {
52388 num = 11;
52389 }
52390 if (tileCache.wall == 335)
52391 {
52392 num = 11;
52393 }
52394 if (tileCache.wall == 21)
52395 {
52396 num = 13;
52397 }
52398 if (tileCache.wall == 34)
52399 {
52400 num = 32;
52401 }
52402 if (tileCache.wall == 225)
52403 {
52404 num = 1;
52405 }
52406 if (tileCache.wall == 145)
52407 {
52408 num = 8;
52409 }
52410 if (tileCache.wall == 23)
52411 {
52412 num = 38;
52413 }
52414 if (tileCache.wall == 24)
52415 {
52416 num = 36;
52417 }
52418 if (tileCache.wall == 25 || tileCache.wall == 339)
52419 {
52420 num = 48;
52421 }
52422 if (tileCache.wall == 179 || tileCache.wall == 178 || tileCache.wall == 183)
52423 {
52424 num = 236;
52425 }
52426 if (tileCache.wall == 181 || tileCache.wall == 180 || tileCache.wall == 184)
52427 {
52428 num = 240;
52429 }
52430 if (tileCache.wall == 113)
52431 {
52432 num = 189;
52433 }
52434 if (tileCache.wall == 114)
52435 {
52436 num = 190;
52437 }
52438 if (tileCache.wall == 115)
52439 {
52440 num = 191;
52441 }
52442 if (tileCache.wall == 177 || tileCache.wall == 13 || tileCache.wall == 338)
52443 {
52444 num = 25;
52445 }
52446 if (tileCache.wall == 186)
52447 {
52448 num = genRand.Next(68, 71);
52449 }
52450 if (tileCache.wall == 319)
52451 {
52452 num = 171;
52453 }
52454 if (tileCache.wall == 321)
52455 {
52456 num = 308;
52457 }
52458 if (tileCache.wall == 322)
52459 {
52460 num = 308;
52461 }
52462 if (tileCache.wall == 318)
52463 {
52464 num = 226;
52465 }
52466 if (tileCache.wall == 142)
52467 {
52468 num = 210;
52469 }
52470 if (tileCache.wall == 143)
52471 {
52472 num = 210;
52473 }
52474 if (tileCache.wall == 224)
52475 {
52476 num = 265;
52477 }
52478 if (tileCache.wall == 323)
52479 {
52480 num = 314;
52481 }
52482 if (tileCache.wall == 324)
52483 {
52484 num = 315;
52485 }
52486 if (tileCache.wall == 325)
52487 {
52488 num = 316;
52489 }
52490 if (tileCache.wall == 326)
52491 {
52492 num = 317;
52493 }
52494 if (tileCache.wall == 327)
52495 {
52496 num = 318;
52497 }
52498 if (tileCache.wall == 328)
52499 {
52500 num = 319;
52501 }
52502 if (tileCache.wall == 329)
52503 {
52504 num = 320;
52505 }
52506 if (tileCache.wall == 330)
52507 {
52508 num = 321;
52509 }
52510 if (tileCache.wall == 320)
52511 {
52512 num = 0;
52513 }
52514 if (tileCache.wall == 341)
52515 {
52516 num = 258;
52517 }
52518 if (tileCache.wall == 342)
52519 {
52520 num = 301;
52521 }
52522 if (tileCache.wall == 343)
52523 {
52524 num = 299;
52525 }
52526 if (tileCache.wall == 344)
52527 {
52528 num = 300;
52529 }
52530 if (tileCache.wall == 345)
52531 {
52532 num = 305;
52533 }
52534 if (tileCache.wall == 173)
52535 {
52536 num = 128;
52537 }
52538 if (tileCache.wall == 174)
52539 {
52540 num = 117;
52541 }
52542 if (tileCache.wall == 175)
52543 {
52544 num = 42;
52545 }
52546 if (tileCache.wall == 176)
52547 {
52548 num = 226;
52549 }
52550 if (tileCache.wall == 182)
52551 {
52552 num = ((genRand.Next(2) != 0) ? 23 : 6);
52553 }
52554 if (tileCache.wall >= 153 && tileCache.wall <= 166)
52555 {
52556 switch (tileCache.wall)
52557 {
52558 case 154:
52559 case 158:
52560 num = 86;
52561 break;
52562 case 163:
52563 case 166:
52564 num = 87;
52565 break;
52566 case 162:
52567 case 165:
52568 num = 88;
52569 break;
52570 case 156:
52571 case 160:
52572 num = 89;
52573 break;
52574 case 161:
52575 case 164:
52576 num = 90;
52577 break;
52578 case 155:
52579 case 159:
52580 num = 91;
52581 break;
52582 case 153:
52583 case 157:
52584 num = 138;
52585 break;
52586 }
52587 }
52588 if (tileCache.wall == 26 || tileCache.wall == 30 || tileCache.wall == 340)
52589 {
52590 num = 49;
52591 }
52592 if (tileCache.wall == 29 || tileCache.wall == 32)
52593 {
52594 num = 50;
52595 }
52596 if (tileCache.wall == 31)
52597 {
52598 num = 51;
52599 }
52600 if (tileCache.wall == 14 || tileCache.wall == 20 || tileCache.wall == 337)
52601 {
52602 num = 109;
52603 }
52604 if (tileCache.wall == 241)
52605 {
52606 num = 286;
52607 }
52608 if (tileCache.wall >= 88 && tileCache.wall <= 93)
52609 {
52610 num = 86 + tileCache.wall - 88;
52611 if (tileCache.wall == 93)
52612 {
52613 num = genRand.Next(88, 94);
52614 }
52615 }
52616 if (tileCache.wall == 33)
52617 {
52618 num = 14;
52619 }
52620 if (tileCache.wall == 41)
52621 {
52622 num = 77;
52623 }
52624 if (tileCache.wall == 42)
52625 {
52626 num = 78;
52627 }
52628 if (tileCache.wall == 43)
52629 {
52630 num = 78;
52631 }
52632 if (tileCache.wall == 36)
52633 {
52634 num = 26;
52635 }
52636 if (tileCache.wall == 37)
52637 {
52638 num = 32;
52639 }
52640 if (tileCache.wall == 38)
52641 {
52642 num = 2;
52643 }
52644 if (tileCache.wall == 39)
52645 {
52646 num = 1;
52647 }
52648 if (tileCache.wall == 45)
52649 {
52650 num = 81;
52651 }
52652 if (tileCache.wall == 46)
52653 {
52654 num = 83;
52655 }
52656 if (tileCache.wall == 47)
52657 {
52658 num = 84;
52659 }
52660 if (tileCache.wall == 85)
52661 {
52662 num = 126;
52663 }
52664 if (tileCache.wall == 63)
52665 {
52666 num = 3;
52667 }
52668 if (tileCache.wall == 65)
52669 {
52670 num = 3;
52671 }
52672 if (tileCache.wall == 66)
52673 {
52674 num = 3;
52675 }
52676 if (tileCache.wall == 68)
52677 {
52678 num = 3;
52679 }
52680 if (tileCache.wall == 64)
52681 {
52682 num = 40;
52683 }
52684 if (tileCache.wall == 67)
52685 {
52686 num = 40;
52687 }
52688 if (tileCache.wall == 84)
52689 {
52690 num = 80;
52691 }
52692 if (tileCache.wall == 60)
52693 {
52694 num = 3;
52695 }
52696 if (tileCache.wall == 167)
52697 {
52698 num = 81;
52699 }
52700 if (tileCache.wall == 147)
52701 {
52702 num = 51;
52703 }
52704 if (tileCache.wall == 146)
52705 {
52706 num = 9;
52707 }
52708 if (tileCache.wall == 109)
52709 {
52710 num = 144;
52711 }
52712 if (tileCache.wall == 110)
52713 {
52714 num = 145;
52715 }
52716 if (tileCache.wall == 111)
52717 {
52718 num = 146;
52719 }
52720 if (tileCache.wall == 86 || tileCache.wall == 108)
52721 {
52722 num = 147;
52723 }
52724 if (tileCache.wall == 87)
52725 {
52726 num = 148;
52727 }
52728 if (tileCache.wall == 136)
52729 {
52730 num = 13;
52731 }
52732 if (tileCache.wall == 137)
52733 {
52734 num = 13;
52735 }
52736 if (tileCache.wall == 168)
52737 {
52738 num = 13;
52739 }
52740 if (tileCache.wall == 169)
52741 {
52742 num = 13;
52743 }
52744 if (tileCache.wall == 172)
52745 {
52746 num = 13;
52747 }
52748 if (tileCache.wall == 226)
52749 {
52750 num = 13;
52751 }
52752 if (tileCache.wall == 227)
52753 {
52754 num = 13;
52755 }
52756 if (tileCache.wall == 242)
52757 {
52758 num = 13;
52759 }
52760 if (tileCache.wall == 243)
52761 {
52762 num = 13;
52763 }
52764 if (tileCache.wall == 72)
52765 {
52766 num = 40;
52767 }
52768 if (tileCache.wall == 73)
52769 {
52770 num = 16;
52771 }
52772 if (tileCache.wall == 74 || tileCache.wall == 80)
52773 {
52774 num = 26;
52775 }
52776 if (tileCache.wall == 144)
52777 {
52778 num = ((genRand.Next(2) != 0) ? 118 : 10);
52779 }
52780 if (tileCache.wall == 75)
52781 {
52782 num = 26;
52783 }
52784 if (tileCache.wall == 76)
52785 {
52786 num = 4;
52787 }
52788 if (tileCache.wall == 77 || tileCache.wall == 81)
52789 {
52790 num = 5;
52791 }
52792 if (tileCache.wall == 78 || tileCache.wall == 244)
52793 {
52794 num = 7;
52795 }
52796 if (tileCache.wall == 82)
52797 {
52798 num = 36;
52799 }
52800 if (tileCache.wall == 27)
52801 {
52802 num = ((genRand.Next(2) != 0) ? 1 : 7);
52803 }
52804 if (tileCache.wall == 138)
52805 {
52806 num = 77;
52807 }
52808 if (tileCache.wall == 139)
52809 {
52810 num = 78;
52811 }
52812 if (tileCache.wall == 140)
52813 {
52814 num = 79;
52815 }
52816 if (tileCache.wall == 141)
52817 {
52818 num = 126;
52819 }
52820 if (tileCache.wall == 149 || tileCache.wall == 150)
52821 {
52822 num = 214;
52823 }
52824 if (tileCache.wall == 151 || tileCache.wall == 152)
52825 {
52826 num = 215;
52827 }
52828 if (tileCache.wall == 245)
52829 {
52830 num = 195;
52831 }
52832 if (tileCache.wall == 44 || tileCache.wall == 346)
52833 {
52834 int num2 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
52835 Main.dust[num2].noGravity = true;
52836 }
52837 else if ((tileCache.wall < 133 || tileCache.wall > 135) && (tileCache.wall < 116 || tileCache.wall > 125) && (tileCache.wall < 126 || tileCache.wall > 132))
52838 {
52839 if (tileCache.wall == 76)
52840 {
52841 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 75, new Color(0, 80, 255, 100), 0.75f);
52842 }
52843 else if (num >= 0)
52844 {
52845 Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num);
52846 }
52847 }
52848 }
52849
52850 public static void LaunchRocket(int x, int y, bool fromWiring)
52851 {
52852 int num = Main.tile[x, y].frameY;
52853 int num2 = 0;
52854 while (num >= 40)
52855 {
52856 num -= 40;
52857 num2++;
52858 }
52859 if (num == 18)
52860 {
52861 y--;
52862 }
52863 Vector2 vector = new Vector2(x * 16 + 8, y * 16 + 4);
52864 int type = 167 + num2;
52865 int damage = 150;
52866 int num3 = 7;
52867 int num4 = Projectile.NewProjectile(GetProjectileSource_PlayerOrWires(x, y, fromWiring, Main.LocalPlayer), vector.X, vector.Y + 2f, 0f, -8f, type, damage, num3, Main.myPlayer);
52868 Main.projectile[num4].originatedFromActivableTile = true;
52869 Main.tile[x, y].active(active: false);
52870 Main.tile[x, y + 1].active(active: false);
52871 NetMessage.SendTileSquare(-1, x, y, 1, 2);
52872 }
52873
52874 public static void LaunchRocketSmall(int x, int y, bool fromWiring)
52875 {
52876 if (Main.tile[x, y].frameX == 18)
52877 {
52878 x--;
52879 }
52880 if (Main.tile[x, y].frameY == 18)
52881 {
52882 y--;
52883 }
52884 Vector2 vector = new Vector2(x * 16 + 16, y * 16);
52885 int type = 415 + Main.rand.Next(4);
52886 int damage = 0;
52887 int num = 0;
52888 int num2 = Projectile.NewProjectile(GetProjectileSource_PlayerOrWires(x, y, fromWiring, Main.LocalPlayer), vector.X, vector.Y + 2f, 0f, -8f, type, damage, num, Main.myPlayer);
52889 Main.projectile[num2].originatedFromActivableTile = true;
52890 }
52891
52892 public static bool CanKillTile(int i, int j, SpecialKillTileContext context)
52893 {
52894 if (context == SpecialKillTileContext.MowingTheGrass)
52895 {
52896 Tile tile = Main.tile[i, j];
52897 if (tile == null)
52898 {
52899 return false;
52900 }
52901 if (tile.type == 2 || tile.type == 109)
52902 {
52903 return true;
52904 }
52905 }
52906 return CanKillTile(i, j);
52907 }
52908
52909 public static bool CanKillTile(int i, int j)
52910 {
52911 bool blockDamaged;
52912 return CanKillTile(i, j, out blockDamaged);
52913 }
52914
52915 public static bool CanKillTile(int i, int j, out bool blockDamaged)
52916 {
52917 blockDamaged = false;
52918 if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
52919 {
52920 return false;
52921 }
52922 Tile tile = Main.tile[i, j];
52923 Tile tile2 = null;
52924 if (tile == null)
52925 {
52926 return false;
52927 }
52928 if (!tile.active())
52929 {
52930 return false;
52931 }
52932 if (j >= 1)
52933 {
52934 tile2 = Main.tile[i, j - 1];
52935 }
52936 if (tile2 != null && tile2.active())
52937 {
52938 int type = tile2.type;
52939 if (TileID.Sets.IsATreeTrunk[type] && tile.type != type && (tile2.frameX != 66 || tile2.frameY < 0 || tile2.frameY > 44) && (tile2.frameX != 88 || tile2.frameY < 66 || tile2.frameY > 110) && tile2.frameY < 198)
52940 {
52941 return false;
52942 }
52943 switch (type)
52944 {
52945 case 323:
52946 if (tile.type != type && (tile2.frameX == 66 || tile2.frameX == 220))
52947 {
52948 return false;
52949 }
52950 break;
52951 case 21:
52952 case 26:
52953 case 72:
52954 case 77:
52955 case 88:
52956 case 467:
52957 case 488:
52958 if (tile.type != type)
52959 {
52960 return false;
52961 }
52962 break;
52963 case 80:
52964 if (tile.type != type)
52965 {
52966 int num = tile2.frameX / 18;
52967 if ((uint)num <= 1u || (uint)(num - 4) <= 1u)
52968 {
52969 return false;
52970 }
52971 }
52972 break;
52973 }
52974 }
52975 if (TileID.Sets.Boulders[tile.type] && CheckBoulderChest(i, j))
52976 {
52977 blockDamaged = true;
52978 return false;
52979 }
52980 switch (tile.type)
52981 {
52982 case 10:
52983 if (IsLockedDoor(tile))
52984 {
52985 blockDamaged = true;
52986 return false;
52987 }
52988 break;
52989 case 235:
52990 {
52991 int num2 = i - tile.frameX % 54 / 18;
52992 for (int k = 0; k < 3; k++)
52993 {
52994 Tile tile3 = Main.tile[num2 + k, j - 1];
52995 if (tile3.active() && IsAContainer(tile3))
52996 {
52997 blockDamaged = true;
52998 return false;
52999 }
53000 }
53001 break;
53002 }
53003 case 21:
53004 case 467:
53005 if (!Chest.CanDestroyChest(i - tile.frameX / 18 % 2, j - tile.frameY / 18))
53006 {
53007 return false;
53008 }
53009 break;
53010 case 88:
53011 if (!Chest.CanDestroyChest(i - tile.frameX / 18 % 3, j - tile.frameY / 18))
53012 {
53013 return false;
53014 }
53015 break;
53016 }
53017 return true;
53018 }
53019
53020 public static bool IsTileReplacable(int x, int y)
53021 {
53022 Tile tile = Main.tile[x, y];
53023 if (y >= 1)
53024 {
53025 Tile tile2 = Main.tile[x, y - 1];
53026 if (tile == null || tile2 == null)
53027 {
53028 return false;
53029 }
53030 if (tile2.active())
53031 {
53032 if (tile2.type == 80)
53033 {
53034 return false;
53035 }
53036 if (tile2.type == 488)
53037 {
53038 return false;
53039 }
53040 if (TileID.Sets.PreventsTileReplaceIfOnTopOfIt[tile2.type] && tile.type != tile2.type)
53041 {
53042 if (TileID.Sets.IsATreeTrunk[tile2.type])
53043 {
53044 if ((tile2.frameX == 66 && tile2.frameY >= 0 && tile2.frameY <= 44) || (tile2.frameX == 88 && tile2.frameY >= 66 && tile2.frameY <= 110) || tile2.frameY >= 198)
53045 {
53046 return true;
53047 }
53048 return false;
53049 }
53050 if (tile2.type == 323)
53051 {
53052 if (tile2.frameX == 66 || tile2.frameX == 220)
53053 {
53054 return false;
53055 }
53056 return true;
53057 }
53058 return false;
53059 }
53060 }
53061 }
53062 return true;
53063 }
53064
53065 public static int CheckTileBreakability(int x, int y)
53066 {
53067 if (Main.tile[x, y] == null)
53068 {
53069 Main.tile[x, y] = new Tile();
53070 }
53071 Tile tile = Main.tile[x, y];
53072 if (y >= 1 && y <= Main.maxTilesY - 1)
53073 {
53074 if (Main.tile[x, y - 1] == null)
53075 {
53076 Main.tile[x, y - 1] = new Tile();
53077 }
53078 if (Main.tile[x, y + 1] == null)
53079 {
53080 Main.tile[x, y + 1] = new Tile();
53081 }
53082 Tile tile2 = Main.tile[x, y - 1];
53083 Tile tile3 = Main.tile[x, y + 1];
53084 if (tile3 != null && tile3.active() && IsLockedDoor(x, y + 1))
53085 {
53086 return 2;
53087 }
53088 if (!Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
53089 {
53090 return 0;
53091 }
53092 if (tile2.active())
53093 {
53094 if ((TileID.Sets.PreventsTileRemovalIfOnTopOfIt[tile2.type] && tile.type != tile2.type) | IsLockedDoor(x, y - 1) | (tile2.type == 77 && tile.type != 77 && !Main.hardMode) | (IsAContainer(tile2) && !IsAContainer(tile)))
53095 {
53096 if (TileID.Sets.IsATreeTrunk[tile2.type])
53097 {
53098 if ((tile2.frameX == 66 && tile2.frameY >= 0 && tile2.frameY <= 44) || (tile2.frameX == 88 && tile2.frameY >= 66 && tile2.frameY <= 110) || tile2.frameY >= 198)
53099 {
53100 return 0;
53101 }
53102 return 2;
53103 }
53104 if (tile2.type == 323)
53105 {
53106 if (tile2.frameX == 66 || tile2.frameX == 220)
53107 {
53108 return 2;
53109 }
53110 return 0;
53111 }
53112 return 2;
53113 }
53114 if (tile2.type == 80 && tile2.type != tile.type)
53115 {
53116 int num = tile2.frameX / 18;
53117 if ((uint)num <= 1u || (uint)(num - 4) <= 1u)
53118 {
53119 return 2;
53120 }
53121 }
53122 if (tile.type == 10 && IsLockedDoor(tile))
53123 {
53124 return 1;
53125 }
53126 if (TileID.Sets.Boulders[tile.type])
53127 {
53128 if (CheckBoulderChest(x, y))
53129 {
53130 return 1;
53131 }
53132 return 0;
53133 }
53134 }
53135 if (tile.type == 235)
53136 {
53137 int frameX = tile.frameX;
53138 int num2 = x - frameX % 54 / 18;
53139 for (int i = 0; i < 3; i++)
53140 {
53141 if (Main.tile[num2 + i, y - 1].active() && IsAContainer(Main.tile[num2 + i, y - 1]))
53142 {
53143 return 2;
53144 }
53145 }
53146 }
53147 }
53148 return 0;
53149 }
53150
53151 public static bool CheckTileBreakability2_ShouldTileSurvive(int x, int y)
53152 {
53153 if (Main.netMode == 1)
53154 {
53155 return false;
53156 }
53157 if (Main.tile[x, y] == null)
53158 {
53159 Main.tile[x, y] = new Tile();
53160 }
53161 Tile tile = Main.tile[x, y];
53162 if (TileID.Sets.BasicChest[tile.type])
53163 {
53164 int num = tile.frameX / 18;
53165 int y2 = y - tile.frameY / 18;
53166 while (num > 1)
53167 {
53168 num -= 2;
53169 }
53170 num = x - num;
53171 if (!Chest.DestroyChest(num, y2))
53172 {
53173 return true;
53174 }
53175 }
53176 if (tile.type == 88)
53177 {
53178 int num2 = tile.frameX / 18;
53179 int y3 = y - tile.frameY / 18;
53180 num2 %= 3;
53181 num2 = x - num2;
53182 if (!Chest.DestroyChest(num2, y3))
53183 {
53184 return true;
53185 }
53186 }
53187 if (tile.type == 470)
53188 {
53189 return !TEDisplayDoll.IsBreakable(x, y);
53190 }
53191 if (tile.type == 475)
53192 {
53193 return !TEHatRack.IsBreakable(x, y);
53194 }
53195 return false;
53196 }
53197
53198 public static bool ReplaceWall(int x, int y, ushort targetWall)
53199 {
53200 if (targetWall >= WallID.Count)
53201 {
53202 return false;
53203 }
53204 Tile tile = Main.tile[x, y];
53205 if (tile.wall == 0 || targetWall == 0)
53206 {
53207 return false;
53208 }
53209 if (KillWall_CheckFailure(fail: false, tile))
53210 {
53211 return false;
53212 }
53213 int num = 10;
53214 for (int i = 0; i < num; i++)
53215 {
53216 KillWall_MakeWallDust(x, y, tile);
53217 }
53218 KillWall_PlaySounds(x, y, tile);
53219 KillWall_DropItems(x, y, tile);
53220 tile.wall = targetWall;
53222 SquareWallFrame(x, y);
53223 return true;
53224 }
53225
53226 public static bool ReplaceTile(int x, int y, ushort targetType, int targetStyle)
53227 {
53229 if (!WouldTileReplacementWork(targetType, x, y))
53230 {
53231 return false;
53232 }
53233 if (!IsTileReplacable(x, y))
53234 {
53235 return false;
53236 }
53237 MoveReplaceTileAnchor(ref x, ref y, targetType, tileSafely);
53238 int num = KillTile_GetTileDustAmount(fail: false, tileSafely);
53239 for (int i = 0; i < num; i++)
53240 {
53241 KillTile_MakeTileDust(x, y, tileSafely);
53242 }
53243 KillTile_PlaySounds(x, y, fail: false, tileSafely);
53244 KillTile_DropItems(x, y, tileSafely, includeLargeObjectDrops: true);
53245 AttemptFossilShattering(x, y, tileSafely, fail: false);
53246 ReplaceTIle_DoActualReplacement(targetType, targetStyle, x, y, tileSafely);
53247 return true;
53248 }
53249
53250 private static void ReplaceTIle_DoActualReplacement(ushort targetType, int targetStyle, int topLeftX, int topLeftY, Tile t)
53251 {
53253 {
53254 if (IsChestRigged(topLeftX, topLeftY) && Main.netMode != 1)
53255 {
53257 NetMessage.SendData(59, -1, -1, null, topLeftX, topLeftY);
53258 }
53259 ReplaceTile_DoActualReplacement_Area(targetType, targetStyle, topLeftX, topLeftY, 2, 2);
53260 }
53262 {
53263 ReplaceTile_DoActualReplacement_Area(targetType, targetStyle, topLeftX, topLeftY, 3, 2);
53264 }
53265 else if (targetType == 215)
53266 {
53267 ReplaceTile_DoActualReplacement_Area(targetType, targetStyle, topLeftX, topLeftY, 3, 2);
53268 }
53269 else
53270 {
53271 ReplaceTile_DoActualReplacement_Single(targetType, targetStyle, topLeftX, topLeftY, t);
53272 }
53273 }
53274
53276 {
53277 ReplaceTile_EliminateNaturalExtras(topLeftX, topLeftY);
53278 int type = t.type;
53279 t.type = targetType;
53280 if (TileID.Sets.Platforms[t.type])
53281 {
53282 t.frameY = (short)(targetStyle * 18);
53283 }
53284 if (t.type == 4)
53285 {
53286 t.frameY = (short)(targetStyle * 22);
53287 }
53289 bool flag = !CanPoundTile(topLeftX, topLeftY);
53291 {
53292 flag = false;
53293 }
53294 if (flag)
53295 {
53296 t.slope(0);
53297 t.halfBrick(halfBrick: false);
53298 }
53299 if (Main.tenthAnniversaryWorld && !Main.remixWorld && (targetType == 53 || targetType == 396 || targetType == 397))
53300 {
53301 t.color(7);
53302 }
53303 SquareTileFrame(topLeftX, topLeftY);
53304 }
53305
53306 private static void ReplaceTile_EliminateNaturalExtras(int x, int y)
53307 {
53308 if (InWorld(x, y, 2))
53309 {
53310 if (Main.tile[x, y - 1] != null && Main.tile[x, y - 1].active() && (TileID.Sets.ReplaceTileBreakUp[Main.tile[x, y - 1].type] || (Main.tile[x, y - 1].type == 165 && (Main.tile[x, y - 1].frameY == 36 || Main.tile[x, y - 1].frameY == 54 || Main.tile[x, y - 1].frameY == 90))))
53311 {
53312 KillTile(x, y - 1);
53313 }
53314 if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].active() && (TileID.Sets.ReplaceTileBreakDown[Main.tile[x, y + 1].type] || (Main.tile[x, y + 1].type == 165 && (Main.tile[x, y + 1].frameY == 0 || Main.tile[x, y + 1].frameY == 18 || Main.tile[x, y + 1].frameY == 72))))
53315 {
53316 KillTile(x, y + 1);
53317 }
53318 }
53319 }
53320
53322 {
53323 for (int i = 0; i < areaSizeX; i++)
53324 {
53325 for (int j = 0; j < areaSizeY; j++)
53326 {
53327 Tile tile = Main.tile[topLeftX + i, topLeftY + j];
53328 tile.type = targetType;
53329 tile.frameX = (short)(targetStyle * (areaSizeX * 18) + i * 18);
53330 tile.frameY = (short)(j * 18);
53332 }
53333 }
53334 for (int k = 0; k < areaSizeX; k++)
53335 {
53336 for (int l = 0; l < areaSizeY; l++)
53337 {
53338 SquareTileFrame(topLeftX + k, topLeftY + l);
53339 }
53340 }
53341 }
53342
53343 private static void MoveReplaceTileAnchor(ref int x, ref int y, ushort targetType, Tile t)
53344 {
53345 if (TileID.Sets.BasicChest[t.type])
53346 {
53347 x -= t.frameX % 36 / 18;
53348 y -= t.frameY % 36 / 18;
53349 }
53351 {
53352 x -= t.frameX % 54 / 18;
53353 y -= t.frameY % 36 / 18;
53354 }
53355 if (t.type == 215)
53356 {
53357 x -= t.frameX % 54 / 18;
53358 y -= t.frameY % 36 / 18;
53359 }
53360 }
53361
53362 public static bool WouldTileReplacementBeBlockedByLiquid(int x, int y, int liquidType)
53363 {
53364 if ((Main.tile[x - 1, y].liquid <= 0 || Main.tile[x - 1, y].liquidType() != liquidType) && (Main.tile[x + 1, y].liquid <= 0 || Main.tile[x + 1, y].liquidType() != liquidType))
53365 {
53366 if (Main.tile[x, y - 1].liquid > 0)
53367 {
53368 return Main.tile[x, y - 1].liquidType() == liquidType;
53369 }
53370 return false;
53371 }
53372 return true;
53373 }
53374
53375 public static bool WouldTileReplacementWork(ushort attemptingToReplaceWith, int x, int y)
53376 {
53377 Tile tile = Main.tile[x, y];
53379 {
53380 return false;
53381 }
53383 {
53384 return false;
53385 }
53386 if (Main.tileRope[tile.type] && InWorld(x, y, 2))
53387 {
53388 Tile tile2 = Main.tile[x - 1, y];
53389 Tile tile3 = Main.tile[x + 1, y];
53390 if (attemptingToReplaceWith == 314 && tile2 != null && tile3 != null && ((tile2.active() && tile2.type == 314) || (tile3.active() && tile3.type == 314)))
53391 {
53392 return true;
53393 }
53394 if (TileID.Sets.Platforms[attemptingToReplaceWith] && tile2 != null && tile3 != null && ((tile2.active() && TileID.Sets.Platforms[tile2.type]) || (tile3.active() && TileID.Sets.Platforms[tile3.type])))
53395 {
53396 return true;
53397 }
53398 }
53399 bool flag = !ReplaceTile_IsValidSolid(attemptingToReplaceWith) || !ReplaceTile_IsValidSolid(tile.type);
53400 bool flag2 = !ReplaceTile_IsValidTorch(attemptingToReplaceWith) || !ReplaceTile_IsValidTorch(tile.type);
53401 bool flag3 = !ReplaceTile_IsValidCampfire(attemptingToReplaceWith) || !ReplaceTile_IsValidCampfire(tile.type);
53402 bool num = !ReplaceTile_IsValidPlatform(attemptingToReplaceWith) || !ReplaceTile_IsValidPlatform(tile.type);
53403 bool flag4 = (!ReplaceTile_IsValidSolid(attemptingToReplaceWith) && !ReplaceTile_IsValidPlatform(attemptingToReplaceWith)) || (!ReplaceTile_IsValidSolid(tile.type) && !ReplaceTile_IsValidPlatform(tile.type));
53404 bool flag5 = !ReplaceTile_IsValidChest(attemptingToReplaceWith) || !ReplaceTile_IsValidChest(tile.type) || Chest.IsLocked(tile);
53405 bool flag6 = !ReplaceTile_IsValidDresser(attemptingToReplaceWith) || !ReplaceTile_IsValidDresser(tile.type);
53406 return !(num && flag2 && flag3 && flag && flag4 && flag5 && flag6);
53407 }
53408
53409 private static bool ReplaceTile_IsValidSolid(int type)
53410 {
53412 {
53413 if (!Main.tileRope[type])
53414 {
53415 return !Main.tileFrameImportant[type];
53416 }
53417 return true;
53418 }
53419 return false;
53420 }
53421
53422 private static bool ReplaceTile_IsValidTorch(int type)
53423 {
53424 return type == 4;
53425 }
53426
53427 private static bool ReplaceTile_IsValidCampfire(int type)
53428 {
53429 return type == 215;
53430 }
53431
53432 private static bool ReplaceTile_IsValidChest(int type)
53433 {
53434 return TileID.Sets.BasicChest[type];
53435 }
53436
53437 private static bool ReplaceTile_IsValidDresser(int type)
53438 {
53439 return TileID.Sets.BasicDresser[type];
53440 }
53441
53442 private static bool ReplaceTile_IsValidPlatform(int type)
53443 {
53444 return TileID.Sets.Platforms[type];
53445 }
53446
53447 public static bool GetAshTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
53448 {
53449 _ = Main.tile[i, j];
53450 int num = i + xoffset;
53453 floorY = j;
53454 for (int k = 0; k < 100; k++)
53455 {
53456 floorY = j + k;
53457 Tile tile = Main.tile[num, floorY];
53458 if (tile == null)
53459 {
53460 return false;
53461 }
53462 if (tile.type == 633)
53463 {
53464 treeStyle = 31;
53465 return true;
53466 }
53467 }
53468 return false;
53469 }
53470
53471 public static bool GetVanityTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
53472 {
53473 Tile tile = Main.tile[i, j];
53474 int num = i + xoffset;
53477 floorY = j;
53478 for (int k = 0; k < 100; k++)
53479 {
53480 floorY = j + k;
53481 Tile tile2 = Main.tile[num, floorY];
53482 if (tile2 == null)
53483 {
53484 return false;
53485 }
53486 if (TileID.Sets.Conversion.Grass[tile2.type])
53487 {
53488 switch (tile.type)
53489 {
53490 case 596:
53491 treeStyle = 29;
53492 return true;
53493 case 616:
53494 treeStyle = 30;
53495 return true;
53496 }
53497 }
53498 }
53499 return false;
53500 }
53501
53502 public static bool GetGemTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
53503 {
53504 Tile tile = Main.tile[i, j];
53505 int num = i + xoffset;
53508 floorY = j;
53510 {
53511 return false;
53512 }
53513 for (int k = 0; k < 100; k++)
53514 {
53515 floorY = j + k;
53516 Tile tile2 = Main.tile[num, floorY];
53517 if (tile2 == null)
53518 {
53519 return false;
53520 }
53521 if (profile.GroundTest(tile2.type))
53522 {
53523 switch (tile.type)
53524 {
53525 case 583:
53526 treeStyle = 22;
53527 return true;
53528 case 584:
53529 treeStyle = 23;
53530 return true;
53531 case 585:
53532 treeStyle = 24;
53533 return true;
53534 case 586:
53535 treeStyle = 25;
53536 return true;
53537 case 587:
53538 treeStyle = 26;
53539 return true;
53540 case 588:
53541 treeStyle = 27;
53542 return true;
53543 case 589:
53544 treeStyle = 28;
53545 return true;
53546 }
53547 }
53548 }
53549 return false;
53550 }
53551
53552 public static bool GetCommonTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
53553 {
53554 _ = Main.tile[i, j];
53555 int num = i + xoffset;
53558 floorY = j;
53559 int num2 = 0;
53560 for (int k = 0; k < 100; k++)
53561 {
53562 floorY = j + k;
53563 Tile tile = Main.tile[num, floorY];
53564 if (tile == null)
53565 {
53566 return false;
53567 }
53568 switch (tile.type)
53569 {
53570 case 2:
53571 case 477:
53572 {
53573 int num4 = 0;
53574 num4 = ((num <= Main.treeX[0]) ? TreeTops.GetTreeStyle(0) : ((num <= Main.treeX[1]) ? TreeTops.GetTreeStyle(1) : ((num > Main.treeX[2]) ? TreeTops.GetTreeStyle(3) : TreeTops.GetTreeStyle(2))));
53575 switch (num4)
53576 {
53577 case 0:
53578 treeStyle = 0;
53579 break;
53580 case 5:
53581 treeStyle = 10;
53582 break;
53583 default:
53584 treeStyle = 5 + num4;
53585 break;
53586 }
53587 return true;
53588 }
53589 case 23:
53590 case 661:
53591 treeStyle = 1;
53592 return true;
53593 case 70:
53594 treeStyle = 14;
53595 return true;
53596 case 199:
53597 case 662:
53598 treeStyle = 5;
53599 return true;
53600 case 60:
53603 treeStyle = 2;
53604 num2 = TreeTops.GetTreeStyle(5);
53605 if (num2 == 1)
53606 {
53607 treeStyle = 11;
53609 }
53610 if ((double)floorY > Main.worldSurface)
53611 {
53612 treeStyle = 13;
53614 }
53615 return true;
53616 case 147:
53617 treeStyle = 4;
53618 num2 = TreeTops.GetTreeStyle(6);
53619 if (num2 == 0)
53620 {
53621 treeStyle = 12;
53622 if (i % 10 == 0)
53623 {
53624 treeStyle = 18;
53625 }
53626 }
53627 if (num2 == 2 || num2 == 3 || num2 == 32 || num2 == 4 || num2 == 42 || num2 == 5 || num2 == 7)
53628 {
53629 if (num2 % 2 == 0)
53630 {
53631 if (i < Main.maxTilesX / 2)
53632 {
53633 treeStyle = 16;
53634 }
53635 else
53636 {
53637 treeStyle = 17;
53638 }
53639 }
53640 else if (i > Main.maxTilesX / 2)
53641 {
53642 treeStyle = 16;
53643 }
53644 else
53645 {
53646 treeStyle = 17;
53647 }
53648 }
53649 return true;
53650 case 109:
53651 case 492:
53652 {
53654 int num3 = (treeStyle = GetHollowTreeFoliageStyle());
53655 if (num3 == 19)
53656 {
53658 }
53659 if (num3 == 20)
53660 {
53661 treeStyle = 20;
53662 if (i % 6 == 1)
53663 {
53664 treeFrame += 3;
53665 }
53666 else if (i % 6 == 2)
53667 {
53668 treeFrame += 6;
53669 }
53670 else if (i % 6 == 3)
53671 {
53672 treeFrame += 9;
53673 }
53674 else if (i % 6 == 4)
53675 {
53676 treeFrame += 12;
53677 }
53678 else if (i % 6 == 5)
53679 {
53680 treeFrame += 15;
53681 }
53682 }
53683 else if (i % 3 == 1)
53684 {
53685 treeFrame += 3;
53686 }
53687 else if (i % 3 == 2)
53688 {
53689 treeFrame += 6;
53690 }
53691 return true;
53692 }
53693 }
53694 }
53695 return false;
53696 }
53697
53698 public static int GetHollowTreeFoliageStyle()
53699 {
53700 TreeTops.GetTreeStyle(7);
53701 switch (hallowBG)
53702 {
53703 default:
53704 return 3;
53705 case 4:
53706 return 19;
53707 case 2:
53708 case 3:
53709 return 20;
53710 }
53711 }
53712
53713 public static int GetTreeFrame(Tile t)
53714 {
53715 if (t.frameY == 220)
53716 {
53717 return 1;
53718 }
53719 if (t.frameY == 242)
53720 {
53721 return 2;
53722 }
53723 return 0;
53724 }
53725
53726 public static TreeTypes GetTreeType(int tileType)
53727 {
53728 switch (tileType)
53729 {
53730 case 2:
53731 case 477:
53732 return TreeTypes.Forest;
53733 case 23:
53734 return TreeTypes.Corrupt;
53735 case 70:
53736 return TreeTypes.Mushroom;
53737 case 199:
53738 return TreeTypes.Crimson;
53739 case 60:
53740 return TreeTypes.Jungle;
53741 case 147:
53742 return TreeTypes.Snow;
53743 case 109:
53744 case 492:
53745 return TreeTypes.Hallowed;
53746 case 53:
53747 return TreeTypes.Palm;
53748 case 112:
53749 return TreeTypes.PalmCorrupt;
53750 case 234:
53751 return TreeTypes.PalmCrimson;
53752 case 116:
53753 return TreeTypes.PalmHallowed;
53754 case 633:
53755 return TreeTypes.Ash;
53756 default:
53757 return TreeTypes.None;
53758 }
53759 }
53760
53761 public static bool IsThisAMushroomTree(int i, int j)
53762 {
53763 GetTreeBottom(i, j, out var x, out var y);
53764 if (GetTreeType(Main.tile[x, y].type) == TreeTypes.Mushroom)
53765 {
53766 return true;
53767 }
53768 return false;
53769 }
53770
53771 public static void ResetTreeShakes()
53772 {
53773 numTreeShakes = 0;
53774 }
53775
53776 private static void ShakeTree(int i, int j)
53777 {
53778 if (numTreeShakes == maxTreeShakes)
53779 {
53780 return;
53781 }
53782 GetTreeBottom(i, j, out var x, out var y);
53783 int num = y;
53784 TreeTypes treeType = GetTreeType(Main.tile[x, y].type);
53785 if (treeType == TreeTypes.None)
53786 {
53787 return;
53788 }
53789 for (int k = 0; k < numTreeShakes; k++)
53790 {
53791 if (treeShakeX[k] == x && treeShakeY[k] == y)
53792 {
53793 return;
53794 }
53795 }
53796 treeShakeX[numTreeShakes] = x;
53797 treeShakeY[numTreeShakes] = y;
53798 numTreeShakes++;
53799 y--;
53800 while (y > 10 && Main.tile[x, y].active() && TileID.Sets.IsShakeable[Main.tile[x, y].type])
53801 {
53802 y--;
53803 }
53804 y++;
53805 if (!IsTileALeafyTreeTop(x, y) || Collision.SolidTiles(x - 2, x + 2, y - 2, y + 2))
53806 {
53807 return;
53808 }
53809 if (Main.getGoodWorld && genRand.Next(17) == 0)
53810 {
53811 Projectile.NewProjectile(GetProjectileSource_ShakeTree(x, y), x * 16, y * 16, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, 28, 0, 0f, Main.myPlayer, 16f, 16f);
53812 }
53813 else if (genRand.Next(300) == 0 && treeType == TreeTypes.Forest)
53814 {
53815 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 832);
53816 }
53817 else if (genRand.Next(300) == 0 && treeType == TreeTypes.Forest)
53818 {
53819 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 933);
53820 }
53821 else if (genRand.Next(200) == 0 && treeType == TreeTypes.Jungle)
53822 {
53823 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 3360);
53824 }
53825 else if (genRand.Next(200) == 0 && treeType == TreeTypes.Jungle)
53826 {
53827 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 3361);
53828 }
53829 else if (genRand.Next(1000) == 0 && treeType == TreeTypes.Forest)
53830 {
53831 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 4366);
53832 }
53833 else if (genRand.Next(7) == 0 && (treeType == TreeTypes.Forest || treeType == TreeTypes.Snow || treeType == TreeTypes.Hallowed || treeType == TreeTypes.Ash))
53834 {
53835 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 27, genRand.Next(1, 3));
53836 }
53837 else if (genRand.Next(8) == 0 && treeType == TreeTypes.Mushroom)
53838 {
53839 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 194, genRand.Next(1, 2));
53840 }
53841 else if (genRand.Next(35) == 0 && Main.halloween)
53842 {
53843 Item.NewItem(GetItemSource_ShakeTree(x, y), x * 16, y * 16, 16, 16, 1809, genRand.Next(1, 3));
53844 }
53845 else if (genRand.Next(12) == 0)
53846 {
53847 int dropItem = 0;
53848 KillTile_GetItemDrops(i, j, Main.tile[i, j], out dropItem, out var _, out var _, out var _);
53849 Item.NewItem(GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, dropItem, genRand.Next(1, 4));
53850 }
53851 else if (genRand.Next(20) == 0)
53852 {
53853 int type = 71;
53854 int num2 = genRand.Next(50, 100);
53855 if (genRand.Next(30) == 0)
53856 {
53857 type = 73;
53858 num2 = 1;
53859 if (genRand.Next(5) == 0)
53860 {
53861 num2++;
53862 }
53863 if (genRand.Next(10) == 0)
53864 {
53865 num2++;
53866 }
53867 }
53868 else if (genRand.Next(10) == 0)
53869 {
53870 type = 72;
53871 num2 = genRand.Next(1, 21);
53872 if (genRand.Next(3) == 0)
53873 {
53874 num2 += genRand.Next(1, 21);
53875 }
53876 if (genRand.Next(4) == 0)
53877 {
53878 num2 += genRand.Next(1, 21);
53879 }
53880 }
53881 Item.NewItem(GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, type, num2);
53882 }
53883 else if (genRand.Next(15) == 0 && (treeType == TreeTypes.Forest || treeType == TreeTypes.Hallowed))
53884 {
53885 int type2 = genRand.Next(5) switch
53886 {
53887 0 => 74,
53888 1 => 297,
53889 2 => 298,
53890 3 => 299,
53891 _ => 538,
53892 };
53894 {
53895 type2 = ((genRand.Next(2) != 0) ? 539 : 442);
53896 }
53897 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, type2);
53898 }
53899 else if (genRand.Next(50) == 0 && treeType == TreeTypes.Hallowed && !Main.dayTime)
53900 {
53901 int type3 = Main.rand.NextFromList(new short[3] { 583, 584, 585 });
53902 if (Main.tenthAnniversaryWorld && Main.rand.Next(4) != 0)
53903 {
53904 type3 = 583;
53905 }
53906 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, type3);
53907 }
53908 else if (genRand.Next(50) == 0 && treeType == TreeTypes.Forest && !Main.dayTime)
53909 {
53910 NPC obj = Main.npc[NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, 611)];
53911 obj.velocity.Y = 1f;
53912 obj.netUpdate = true;
53913 }
53914 else if (genRand.Next(50) == 0 && treeType == TreeTypes.Jungle && Main.dayTime)
53915 {
53916 NPC obj2 = Main.npc[NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, Main.rand.NextFromList(new short[5] { 671, 672, 673, 674, 675 }))];
53917 obj2.velocity.Y = 1f;
53918 obj2.netUpdate = true;
53919 }
53920 else if (genRand.Next(40) == 0 && treeType == TreeTypes.Forest && !Main.dayTime && Main.halloween)
53921 {
53922 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, 301);
53923 }
53924 else if (genRand.Next(50) == 0 && (treeType == TreeTypes.Forest || treeType == TreeTypes.Hallowed))
53925 {
53926 for (int l = 0; l < 5; l++)
53927 {
53928 Point point = new Point(x + Main.rand.Next(-2, 2), y - 1 + Main.rand.Next(-2, 2));
53929 int type4 = ((Player.GetClosestRollLuck(x, y, NPC.goldCritterChance) != 0f) ? Main.rand.NextFromList(new short[3] { 74, 297, 298 }) : 442);
53930 NPC obj3 = Main.npc[NPC.NewNPC(new EntitySource_ShakeTree(x, y), point.X * 16, point.Y * 16, type4)];
53931 obj3.velocity = Main.rand.NextVector2CircularEdge(3f, 3f);
53932 obj3.netUpdate = true;
53933 }
53934 }
53935 else if (genRand.Next(40) == 0 && treeType == TreeTypes.Jungle)
53936 {
53937 for (int m = 0; m < 5; m++)
53938 {
53939 Point point2 = new Point(x + Main.rand.Next(-2, 2), y - 1 + Main.rand.Next(-2, 2));
53940 NPC obj4 = Main.npc[NPC.NewNPC(new EntitySource_ShakeTree(x, y), point2.X * 16, point2.Y * 16, Main.rand.NextFromList(new short[2] { 210, 211 }))];
53941 obj4.ai[1] = 65f;
53942 obj4.netUpdate = true;
53943 }
53944 }
53945 else if (genRand.Next(20) == 0 && (treeType == TreeTypes.Palm || treeType == TreeTypes.PalmCorrupt || treeType == TreeTypes.PalmCrimson || treeType == TreeTypes.PalmHallowed) && !IsPalmOasisTree(x))
53946 {
53947 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, 603);
53948 }
53949 else if (genRand.Next(30) == 0 && (treeType == TreeTypes.Crimson || treeType == TreeTypes.PalmCrimson))
53950 {
53951 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16 + 8, (y - 1) * 16, -22);
53952 }
53953 else if (genRand.Next(30) == 0 && (treeType == TreeTypes.Corrupt || treeType == TreeTypes.PalmCorrupt))
53954 {
53955 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16 + 8, (y - 1) * 16, -11);
53956 }
53957 else if (genRand.Next(30) == 0 && treeType == TreeTypes.Jungle && !Main.dayTime)
53958 {
53959 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, 51);
53960 }
53961 else if (genRand.Next(40) == 0 && treeType == TreeTypes.Jungle)
53962 {
53963 Projectile.NewProjectile(GetProjectileSource_ShakeTree(x, y), x * 16 + 8, (y - 1) * 16, 0f, 0f, 655, 0, 0f, Main.myPlayer);
53964 }
53965 else if (genRand.Next(20) == 0 && (treeType == TreeTypes.Forest || treeType == TreeTypes.Hallowed) && !Main.raining && !NPC.TooWindyForButterflies && Main.dayTime)
53966 {
53967 int type5 = 356;
53969 {
53970 type5 = 444;
53971 }
53972 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, type5);
53973 }
53974 else if (genRand.Next(20) == 0 && treeType == TreeTypes.Ash && y > Main.maxTilesY - 250)
53975 {
53976 int num3 = genRand.Next(3);
53977 NPC.NewNPC(new EntitySource_ShakeTree(x, y), x * 16, y * 16, num3 switch
53978 {
53979 0 => 654,
53980 1 => 653,
53981 _ => 655,
53982 });
53983 }
53984 else if (Main.remixWorld && genRand.Next(20) == 0 && treeType == TreeTypes.Ash && y > Main.maxTilesY - 250)
53985 {
53986 Item.NewItem(GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, 965, genRand.Next(20, 41));
53987 }
53988 else if (genRand.Next(12) == 0 && treeType == TreeTypes.Forest)
53989 {
53990 int num4 = genRand.Next(5);
53991 Item.NewItem(GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, num4 switch
53992 {
53993 0 => 4009,
53994 1 => 4293,
53995 2 => 4282,
53996 3 => 4290,
53997 _ => 4291,
53998 });
53999 }
54000 else if (genRand.Next(12) == 0 && treeType == TreeTypes.Snow)
54001 {
54002 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4295 : 4286, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54003 }
54004 else if (genRand.Next(12) == 0 && treeType == TreeTypes.Jungle)
54005 {
54006 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4292 : 4294, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54007 }
54008 else if (genRand.Next(12) == 0 && (treeType == TreeTypes.Palm || treeType == TreeTypes.PalmCorrupt || treeType == TreeTypes.PalmCrimson || treeType == TreeTypes.PalmHallowed) && !IsPalmOasisTree(x))
54009 {
54010 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4287 : 4283, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54011 }
54012 else if (genRand.Next(12) == 0 && (treeType == TreeTypes.Corrupt || treeType == TreeTypes.PalmCorrupt))
54013 {
54014 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4289 : 4284, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54015 }
54016 else if (genRand.Next(12) == 0 && (treeType == TreeTypes.Hallowed || treeType == TreeTypes.PalmHallowed))
54017 {
54018 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4288 : 4297, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54019 }
54020 else if (genRand.Next(12) == 0 && (treeType == TreeTypes.Crimson || treeType == TreeTypes.PalmCrimson))
54021 {
54022 Item.NewItem(Type: (genRand.Next(2) != 0) ? 4285 : 4296, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54023 }
54024 else if (genRand.Next(12) == 0 && treeType == TreeTypes.Ash)
54025 {
54026 Item.NewItem(Type: (genRand.Next(2) != 0) ? 5278 : 5277, source: GetItemSource_FromTreeShake(x, y), X: x * 16, Y: y * 16, Width: 16, Height: 16);
54027 }
54028 int treeHeight = 0;
54029 int treeFrame = 0;
54030 int passStyle = 0;
54031 GetTreeLeaf(x, Main.tile[x, y], Main.tile[x, num], ref treeHeight, out treeFrame, out passStyle);
54032 if (passStyle != -1)
54033 {
54034 if (Main.netMode == 2)
54035 {
54036 NetMessage.SendData(112, -1, -1, null, 1, x, y, 1f, passStyle);
54037 }
54038 if (Main.netMode == 0)
54039 {
54040 TreeGrowFX(x, y, 1, passStyle, hitTree: true);
54041 }
54042 }
54043 }
54044
54045 private static void GetVineTop(int i, int j, out int x, out int y)
54046 {
54047 x = i;
54048 y = j;
54050 if (TileID.Sets.IsVine[tileSafely.type])
54051 {
54052 while (y > 20 && tileSafely.active() && TileID.Sets.IsVine[tileSafely.type])
54053 {
54054 y--;
54056 }
54057 }
54058 }
54059
54060 public static void GetTreeBottom(int i, int j, out int x, out int y)
54061 {
54062 x = i;
54063 y = j;
54065 if (tileSafely.type == 323)
54066 {
54067 while (y < Main.maxTilesY - 50 && (!tileSafely.active() || tileSafely.type == 323))
54068 {
54069 y++;
54071 }
54072 return;
54073 }
54074 int num = tileSafely.frameX / 22;
54075 int num2 = tileSafely.frameY / 22;
54076 if (num == 3 && num2 <= 2)
54077 {
54078 x++;
54079 }
54080 else if (num == 4 && num2 >= 3 && num2 <= 5)
54081 {
54082 x--;
54083 }
54084 else if (num == 1 && num2 >= 6 && num2 <= 8)
54085 {
54086 x--;
54087 }
54088 else if (num == 2 && num2 >= 6 && num2 <= 8)
54089 {
54090 x++;
54091 }
54092 else if (num == 2 && num2 >= 9)
54093 {
54094 x++;
54095 }
54096 else if (num == 3 && num2 >= 9)
54097 {
54098 x--;
54099 }
54101 while (y < Main.maxTilesY - 50 && (!tileSafely.active() || TileID.Sets.IsATreeTrunk[tileSafely.type] || tileSafely.type == 72))
54102 {
54103 y++;
54105 }
54106 }
54107
54108 private static void AttemptFossilShattering(int i, int j, Tile tileCache, bool fail)
54109 {
54110 if (tileCache.type != 404 || Main.netMode == 1 || fossilBreak)
54111 {
54112 return;
54113 }
54114 fossilBreak = true;
54115 for (int k = i - 1; k <= i + 1; k++)
54116 {
54117 for (int l = j - 1; l <= j + 1; l++)
54118 {
54119 int maxValue = 15;
54120 if (!SolidTile(k, l + 1))
54121 {
54122 maxValue = 4;
54123 }
54124 else if (k == i && l == j - 1 && !fail)
54125 {
54126 maxValue = 4;
54127 }
54128 if ((k != i || l != j) && Main.tile[k, l].active() && Main.tile[k, l].type == 404 && genRand.Next(maxValue) == 0)
54129 {
54130 KillTile(k, l, fail: false, effectOnly: false, noItem: true);
54131 if (Main.netMode == 2)
54132 {
54133 NetMessage.SendData(17, -1, -1, null, 0, k, l);
54134 }
54135 }
54136 }
54137 }
54138 fossilBreak = false;
54139 }
54140
54141 public static void KillTile(int i, int j, bool fail = false, bool effectOnly = false, bool noItem = false)
54142 {
54143 if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
54144 {
54145 return;
54146 }
54147 Tile tile = Main.tile[i, j];
54148 if (tile == null)
54149 {
54150 tile = new Tile();
54151 Main.tile[i, j] = tile;
54152 }
54153 if (!tile.active())
54154 {
54155 return;
54156 }
54157 if (j >= 1 && Main.tile[i, j - 1] == null)
54158 {
54159 Main.tile[i, j - 1] = new Tile();
54160 }
54161 int num = CheckTileBreakability(i, j);
54162 if (num == 1)
54163 {
54164 fail = true;
54165 }
54166 if (num == 2)
54167 {
54168 return;
54169 }
54170 if (gen)
54171 {
54172 noItem = true;
54173 }
54174 if (!effectOnly && !stopDrops)
54175 {
54177 {
54178 return;
54179 }
54180 if (!Main.dedServ && !gen && !Main.gameMenu)
54181 {
54182 KillTile_PlaySounds(i, j, fail, tile);
54183 }
54184 }
54185 if (tile.type == 128 || tile.type == 269)
54186 {
54187 int num2 = i;
54188 int num3 = tile.frameX;
54189 int num4;
54190 for (num4 = tile.frameX; num4 >= 100; num4 -= 100)
54191 {
54192 }
54193 while (num4 >= 36)
54194 {
54195 num4 -= 36;
54196 }
54197 if (num4 == 18)
54198 {
54199 num3 = Main.tile[i - 1, j].frameX;
54200 num2--;
54201 }
54202 if (num3 >= 100)
54203 {
54204 int num5 = 0;
54205 while (num3 >= 100)
54206 {
54207 num3 -= 100;
54208 num5++;
54209 }
54210 int num6 = Main.tile[num2, j].frameY / 18;
54211 if (num6 == 0)
54212 {
54213 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.headType[num5]);
54214 }
54215 if (num6 == 1)
54216 {
54217 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.bodyType[num5]);
54218 }
54219 if (num6 == 2)
54220 {
54221 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.legType[num5]);
54222 }
54223 for (num3 = Main.tile[num2, j].frameX; num3 >= 100; num3 -= 100)
54224 {
54225 }
54226 Main.tile[num2, j].frameX = (short)num3;
54227 }
54228 }
54229 if (tile.type == 334)
54230 {
54231 int num7 = i;
54232 int frameX = tile.frameX;
54233 int num8 = tile.frameX;
54234 int num9 = 0;
54235 while (num8 >= 5000)
54236 {
54237 num8 -= 5000;
54238 num9++;
54239 }
54240 if (num9 != 0)
54241 {
54242 num8 = (num9 - 1) * 18;
54243 }
54244 num8 %= 54;
54245 if (num8 == 18)
54246 {
54247 frameX = Main.tile[i - 1, j].frameX;
54248 num7--;
54249 }
54250 if (num8 == 36)
54251 {
54252 frameX = Main.tile[i - 2, j].frameX;
54253 num7 -= 2;
54254 }
54255 if (frameX >= 5000)
54256 {
54257 int num10 = frameX % 5000;
54258 num10 -= 100;
54259 int frameX2 = Main.tile[num7 + 1, j].frameX;
54260 frameX2 = ((frameX2 < 25000) ? (frameX2 - 10000) : (frameX2 - 25000));
54261 if (Main.netMode != 1)
54262 {
54263 Item item = new Item();
54264 item.netDefaults(num10);
54265 item.Prefix(frameX2);
54266 int num11 = Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, num10, 1, noBroadcast: true);
54267 item.position = Main.item[num11].position;
54268 Main.item[num11] = item;
54269 NetMessage.SendData(21, -1, -1, null, num11);
54270 }
54271 frameX = Main.tile[num7, j].frameX;
54272 int num12 = 0;
54273 while (frameX >= 5000)
54274 {
54275 frameX -= 5000;
54276 num12++;
54277 }
54278 if (num12 != 0)
54279 {
54280 frameX = (num12 - 1) * 18;
54281 }
54282 Main.tile[num7, j].frameX = (short)frameX;
54283 Main.tile[num7 + 1, j].frameX = (short)(frameX + 18);
54284 }
54285 }
54286 if (tile.type == 395)
54287 {
54288 int num13 = TEItemFrame.Find(i - tile.frameX % 36 / 18, j - tile.frameY % 36 / 18);
54289 if (num13 != -1 && ((TEItemFrame)TileEntity.ByID[num13]).item.stack > 0)
54290 {
54291 ((TEItemFrame)TileEntity.ByID[num13]).DropItem();
54292 if (Main.netMode != 2)
54293 {
54294 Main.LocalPlayer.InterruptItemUsageIfOverTile(395);
54295 }
54296 return;
54297 }
54298 }
54299 if (tile.type == 471)
54300 {
54301 int num14 = TEWeaponsRack.Find(i - tile.frameX % 54 / 18, j - tile.frameY % 54 / 18);
54302 if (num14 != -1 && ((TEWeaponsRack)TileEntity.ByID[num14]).item.stack > 0)
54303 {
54304 ((TEWeaponsRack)TileEntity.ByID[num14]).DropItem();
54305 if (Main.netMode != 2)
54306 {
54307 Main.LocalPlayer.InterruptItemUsageIfOverTile(471);
54308 }
54309 return;
54310 }
54311 }
54312 if (tile.type == 520)
54313 {
54314 int num15 = TEFoodPlatter.Find(i, j);
54315 if (num15 != -1 && ((TEFoodPlatter)TileEntity.ByID[num15]).item.stack > 0)
54316 {
54317 ((TEFoodPlatter)TileEntity.ByID[num15]).DropItem();
54318 if (Main.netMode != 2)
54319 {
54320 Main.LocalPlayer.InterruptItemUsageIfOverTile(520);
54321 }
54322 return;
54323 }
54324 }
54325 if ((tile.type == 470 && (CheckTileBreakability2_ShouldTileSurvive(i, j) || fail)) || (tile.type == 475 && (CheckTileBreakability2_ShouldTileSurvive(i, j) || fail)))
54326 {
54327 return;
54328 }
54329 int num16 = KillTile_GetTileDustAmount(fail, tile);
54330 for (int k = 0; k < num16; k++)
54331 {
54332 KillTile_MakeTileDust(i, j, tile);
54333 }
54334 if (effectOnly)
54335 {
54336 return;
54337 }
54338 AttemptFossilShattering(i, j, tile, fail);
54339 if (fail)
54340 {
54341 if (Main.netMode != 1 && TileID.Sets.IsShakeable[tile.type])
54342 {
54343 ShakeTree(i, j);
54344 }
54345 if (tile.type == 2 || tile.type == 23 || tile.type == 109 || tile.type == 199 || tile.type == 477 || tile.type == 492)
54346 {
54347 tile.type = 0;
54348 }
54349 if (tile.type == 633)
54350 {
54351 tile.type = 57;
54352 }
54353 if (tile.type == 60 || tile.type == 661 || tile.type == 662 || tile.type == 70)
54354 {
54355 tile.type = 59;
54356 }
54357 if (Main.tileMoss[tile.type])
54358 {
54359 tile.type = 1;
54360 }
54361 if (TileID.Sets.tileMossBrick[tile.type])
54362 {
54363 tile.type = 38;
54364 }
54365 SquareTileFrame(i, j);
54366 return;
54367 }
54368 if (Main.getGoodWorld && Main.netMode != 1 && tile.type == 57)
54369 {
54370 for (int l = 0; l < 8; l++)
54371 {
54372 int maxValue = 2;
54373 int num17 = i;
54374 int num18 = j;
54375 switch (l)
54376 {
54377 case 0:
54378 num17--;
54379 break;
54380 case 1:
54381 num17++;
54382 break;
54383 case 2:
54384 num18--;
54385 break;
54386 case 3:
54387 num18++;
54388 break;
54389 case 4:
54390 num17--;
54391 num18--;
54392 break;
54393 case 5:
54394 num17++;
54395 num18--;
54396 break;
54397 case 6:
54398 num17--;
54399 num18++;
54400 break;
54401 case 7:
54402 num17++;
54403 num18++;
54404 break;
54405 }
54407 if (tile2.active() && genRand.Next(maxValue) == 0 && tile2.type == 57 && !SolidTile(num17, num18 + 1))
54408 {
54409 KillTile(num17, num18, fail: false, effectOnly: false, noItem: true);
54410 if (Main.netMode == 2)
54411 {
54412 NetMessage.TrySendData(17, -1, -1, null, 20, num17, num18);
54413 }
54414 int num19 = Projectile.NewProjectile(GetProjectileSource_TileBreak(num17, num18), num17 * 16 + 8, num18 * 16 + 8, 0f, 0.41f, 40, 15, 0f, Main.myPlayer);
54415 Main.projectile[num19].netUpdate = true;
54416 }
54417 }
54418 }
54419 if (Main.netMode != 1 && tile.type >= 481 && tile.type <= 483)
54420 {
54421 for (int m = 0; m < 8; m++)
54422 {
54423 int num20 = 6;
54424 int num21 = i;
54425 int num22 = j;
54426 switch (m)
54427 {
54428 case 0:
54429 num21--;
54430 break;
54431 case 1:
54432 num21++;
54433 break;
54434 case 2:
54435 num22--;
54436 num20 /= 2;
54437 break;
54438 case 3:
54439 num22++;
54440 break;
54441 case 4:
54442 num21--;
54443 num22--;
54444 break;
54445 case 5:
54446 num21++;
54447 num22--;
54448 break;
54449 case 6:
54450 num21--;
54451 num22++;
54452 break;
54453 case 7:
54454 num21++;
54455 num22++;
54456 break;
54457 }
54459 if (tile3.active() && genRand.Next(num20) == 0 && tile3.type >= 481 && tile3.type <= 483)
54460 {
54461 tile.active(active: false);
54462 KillTile(num21, num22, fail: false, effectOnly: false, noItem: true);
54463 if (Main.netMode == 2)
54464 {
54465 NetMessage.TrySendData(17, -1, -1, null, 20, num21, num22);
54466 }
54467 }
54468 }
54469 int type = tile.type - 481 + 736;
54470 int damage = 20;
54471 EntitySource_TileBreak projectileSource_TileBreak = GetProjectileSource_TileBreak(i, j);
54472 if (Main.netMode == 0)
54473 {
54474 Projectile.NewProjectile(projectileSource_TileBreak, i * 16 + 8, j * 16 + 8, 0f, 0.41f, type, damage, 0f, Main.myPlayer);
54475 }
54476 else if (Main.netMode == 2)
54477 {
54478 int num23 = Projectile.NewProjectile(projectileSource_TileBreak, i * 16 + 8, j * 16 + 8, 0f, 0.41f, type, damage, 0f, Main.myPlayer);
54479 Main.projectile[num23].netUpdate = true;
54480 }
54481 }
54482 if (CheckTileBreakability2_ShouldTileSurvive(i, j))
54483 {
54484 return;
54485 }
54486 if (tile.type == 51 && tile.wall == 62 && genRand.Next(4) != 0)
54487 {
54488 noItem = true;
54489 }
54490 if (!noItem && !stopDrops && Main.netMode != 1)
54491 {
54492 KillTile_DropBait(i, j, tile);
54493 KillTile_DropItems(i, j, tile);
54494 }
54495 if (tile.type == 520)
54496 {
54497 TEFoodPlatter.Kill(i, j);
54498 }
54499 if (tile.type == 423)
54500 {
54501 TELogicSensor.Kill(i, j);
54502 }
54503 if (Main.netMode != 2)
54504 {
54506 }
54507 tile.active(active: false);
54508 tile.halfBrick(halfBrick: false);
54509 tile.frameX = -1;
54510 tile.frameY = -1;
54512 tile.frameNumber(0);
54513 if (Main.netMode != 1)
54514 {
54515 if (tile.type == 58 && j > Main.UnderworldLayer)
54516 {
54517 tile.lava(lava: true);
54518 tile.liquid = 128;
54519 }
54520 else if (tile.type == 230 && Main.getGoodWorld && genRand.Next(2) == 0)
54521 {
54522 tile.lava(lava: true);
54523 tile.liquid = 128;
54524 }
54525 }
54526 if (tile.type == 419)
54527 {
54528 Wiring.PokeLogicGate(i, j + 1);
54529 }
54531 {
54532 SquareWallFrame(i, j);
54533 }
54534 tile.type = 0;
54535 tile.inActive(inActive: false);
54536 SquareTileFrame(i, j);
54537 while (!destroyObject && ExploitDestroyQueue.Count > 0)
54538 {
54539 Point point = ExploitDestroyQueue.Dequeue();
54540 if (Framing.GetTileSafely(point.X, point.Y).active())
54541 {
54542 SquareTileFrame(point.X, point.Y);
54543 NetMessage.SendTileSquare(-1, point.X, point.Y);
54544 }
54545 }
54546 }
54547
54548 private static Player GetPlayerForTile(int x, int y)
54549 {
54550 return Main.player[Player.FindClosest(new Vector2(x, y) * 16f, 16, 16)];
54551 }
54552
54553 private static void KillTile_DropItems(int x, int y, Tile tileCache, bool includeLargeObjectDrops = false)
54554 {
54556 if (!Main.getGoodWorld || tileCache.active())
54557 {
54558 if (dropItem > 0)
54559 {
54560 int num = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, dropItem, dropItemStack, noBroadcast: false, -1);
54561 Main.item[num].TryCombiningIntoNearbyItems(num);
54562 }
54563 if (secondaryItem > 0)
54564 {
54565 int num2 = Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, secondaryItem, secondaryItemStack, noBroadcast: false, -1);
54566 Main.item[num2].TryCombiningIntoNearbyItems(num2);
54567 }
54568 }
54569 }
54570
54571 public static void KillTile_GetItemDrops(int x, int y, Tile tileCache, out int dropItem, out int dropItemStack, out int secondaryItem, out int secondaryItemStack, bool includeLargeObjectDrops = false)
54572 {
54573 dropItem = 0;
54574 dropItemStack = 1;
54575 secondaryItem = 0;
54577 int num = 0;
54579 {
54580 switch (tileCache.type)
54581 {
54582 case 21:
54583 case 467:
54584 dropItem = GetChestItemDrop(x, y, tileCache.type);
54585 break;
54586 case 88:
54587 num = tileCache.frameX / 54;
54588 dropItem = GetDresserItemDrop(num);
54589 break;
54590 case 215:
54591 num = tileCache.frameX / 54;
54592 dropItem = GetCampfireItemDrop(num);
54593 break;
54594 }
54595 }
54596 switch (tileCache.type)
54597 {
54598 case 668:
54599 dropItem = 5400;
54600 break;
54601 case 659:
54602 dropItem = 5349;
54603 break;
54604 case 667:
54605 dropItem = 5398;
54606 break;
54607 case 179:
54608 case 180:
54609 case 181:
54610 case 182:
54611 case 183:
54612 case 381:
54613 case 534:
54614 case 536:
54615 case 539:
54616 case 625:
54617 case 627:
54618 dropItem = 3;
54619 break;
54620 case 512:
54621 case 513:
54622 case 514:
54623 case 515:
54624 case 516:
54625 case 517:
54626 case 535:
54627 case 537:
54628 case 540:
54629 case 626:
54630 case 628:
54631 dropItem = 129;
54632 break;
54633 case 0:
54634 case 2:
54635 case 109:
54636 case 199:
54637 case 477:
54638 case 492:
54639 dropItem = 2;
54640 break;
54641 case 633:
54642 dropItem = 172;
54643 break;
54644 case 426:
54645 dropItem = 3621;
54646 break;
54647 case 430:
54648 dropItem = 3633;
54649 break;
54650 case 431:
54651 dropItem = 3634;
54652 break;
54653 case 432:
54654 dropItem = 3635;
54655 break;
54656 case 433:
54657 dropItem = 3636;
54658 break;
54659 case 434:
54660 dropItem = 3637;
54661 break;
54662 case 427:
54663 dropItem = 3622;
54664 break;
54665 case 435:
54666 dropItem = 3638;
54667 break;
54668 case 436:
54669 dropItem = 3639;
54670 break;
54671 case 437:
54672 dropItem = 3640;
54673 break;
54674 case 438:
54675 dropItem = 3641;
54676 break;
54677 case 439:
54678 dropItem = 3642;
54679 break;
54680 case 446:
54681 dropItem = 3736;
54682 break;
54683 case 447:
54684 dropItem = 3737;
54685 break;
54686 case 448:
54687 dropItem = 3738;
54688 break;
54689 case 449:
54690 dropItem = 3739;
54691 break;
54692 case 450:
54693 dropItem = 3740;
54694 break;
54695 case 451:
54696 dropItem = 3741;
54697 break;
54698 case 368:
54699 dropItem = 3086;
54700 break;
54701 case 369:
54702 dropItem = 3087;
54703 break;
54704 case 367:
54705 dropItem = 3081;
54706 break;
54707 case 379:
54708 dropItem = 3214;
54709 break;
54710 case 353:
54711 dropItem = 2996;
54712 break;
54713 case 365:
54714 dropItem = 3077;
54715 break;
54716 case 366:
54717 dropItem = 3078;
54718 break;
54719 case 357:
54720 dropItem = 3066;
54721 break;
54722 case 1:
54723 dropItem = 3;
54724 break;
54725 case 442:
54726 dropItem = 3707;
54727 break;
54728 case 383:
54729 dropItem = 620;
54730 break;
54731 case 315:
54732 dropItem = 2435;
54733 break;
54734 case 641:
54735 dropItem = 5306;
54736 break;
54737 case 330:
54738 dropItem = 71;
54739 break;
54740 case 331:
54741 dropItem = 72;
54742 break;
54743 case 332:
54744 dropItem = 73;
54745 break;
54746 case 333:
54747 dropItem = 74;
54748 break;
54749 case 408:
54750 dropItem = 3460;
54751 break;
54752 case 409:
54753 dropItem = 3461;
54754 break;
54755 case 669:
54756 dropItem = 5401;
54757 break;
54758 case 670:
54759 dropItem = 5402;
54760 break;
54761 case 671:
54762 dropItem = 5403;
54763 break;
54764 case 672:
54765 dropItem = 5404;
54766 break;
54767 case 673:
54768 dropItem = 5405;
54769 break;
54770 case 674:
54771 dropItem = 5406;
54772 break;
54773 case 675:
54774 dropItem = 5407;
54775 break;
54776 case 676:
54777 dropItem = 5408;
54778 break;
54779 case 677:
54780 dropItem = 5417;
54781 break;
54782 case 678:
54783 dropItem = 5419;
54784 break;
54785 case 679:
54786 dropItem = 5421;
54787 break;
54788 case 680:
54789 dropItem = 5423;
54790 break;
54791 case 681:
54792 dropItem = 5425;
54793 break;
54794 case 682:
54795 dropItem = 5427;
54796 break;
54797 case 683:
54798 dropItem = 5433;
54799 break;
54800 case 684:
54801 dropItem = 5435;
54802 break;
54803 case 685:
54804 dropItem = 5429;
54805 break;
54806 case 686:
54807 dropItem = 5431;
54808 break;
54809 case 687:
54810 dropItem = 5439;
54811 break;
54812 case 688:
54813 dropItem = 5440;
54814 break;
54815 case 689:
54816 dropItem = 5441;
54817 break;
54818 case 690:
54819 dropItem = 5442;
54820 break;
54821 case 691:
54822 dropItem = 5443;
54823 break;
54824 case 692:
54825 dropItem = 5444;
54826 break;
54827 case 666:
54828 dropItem = 5395;
54829 break;
54830 case 415:
54831 dropItem = 3573;
54832 break;
54833 case 416:
54834 dropItem = 3574;
54835 break;
54836 case 417:
54837 dropItem = 3575;
54838 break;
54839 case 418:
54840 dropItem = 3576;
54841 break;
54842 case 421:
54843 dropItem = 3609;
54844 break;
54845 case 422:
54846 dropItem = 3610;
54847 break;
54848 case 498:
54849 dropItem = 4139;
54850 break;
54851 case 424:
54852 dropItem = 3616;
54853 break;
54854 case 445:
54855 dropItem = 3725;
54856 break;
54857 case 429:
54858 dropItem = 3629;
54859 break;
54860 case 272:
54861 dropItem = 1344;
54862 break;
54863 case 273:
54864 dropItem = 2119;
54865 break;
54866 case 274:
54867 dropItem = 2120;
54868 break;
54869 case 618:
54870 dropItem = 4962;
54871 break;
54872 case 460:
54873 dropItem = 3756;
54874 break;
54875 case 541:
54876 dropItem = 4392;
54877 break;
54878 case 630:
54879 dropItem = 5137;
54880 break;
54881 case 631:
54882 dropItem = 5138;
54883 break;
54884 case 472:
54885 dropItem = 3951;
54886 break;
54887 case 473:
54888 dropItem = 3953;
54889 break;
54890 case 474:
54891 dropItem = 3955;
54892 break;
54893 case 478:
54894 dropItem = 4050;
54895 break;
54896 case 479:
54897 dropItem = 4051;
54898 break;
54899 case 496:
54900 dropItem = 4091;
54901 break;
54902 case 495:
54903 dropItem = 4090;
54904 break;
54905 case 346:
54906 dropItem = 2792;
54907 break;
54908 case 347:
54909 dropItem = 2793;
54910 break;
54911 case 348:
54912 dropItem = 2794;
54913 break;
54914 case 350:
54915 dropItem = 2860;
54916 break;
54917 case 336:
54918 dropItem = 2701;
54919 break;
54920 case 340:
54921 dropItem = 2751;
54922 break;
54923 case 341:
54924 dropItem = 2752;
54925 break;
54926 case 342:
54927 dropItem = 2753;
54928 break;
54929 case 343:
54930 dropItem = 2754;
54931 break;
54932 case 344:
54933 dropItem = 2755;
54934 break;
54935 case 351:
54936 dropItem = 2868;
54937 break;
54938 case 500:
54939 dropItem = 4229;
54940 break;
54941 case 501:
54942 dropItem = 4230;
54943 break;
54944 case 502:
54945 dropItem = 4231;
54946 break;
54947 case 503:
54948 dropItem = 4232;
54949 break;
54950 case 546:
54951 case 557:
54952 dropItem = 4422;
54953 break;
54954 case 561:
54955 dropItem = 4554;
54956 break;
54957 case 574:
54958 dropItem = 4717;
54959 break;
54960 case 575:
54961 dropItem = 4718;
54962 break;
54963 case 576:
54964 dropItem = 4719;
54965 break;
54966 case 577:
54967 dropItem = 4720;
54968 break;
54969 case 578:
54970 dropItem = 4721;
54971 break;
54972 case 562:
54973 dropItem = 4564;
54974 break;
54975 case 571:
54976 dropItem = 4564;
54977 dropItemStack = genRand.Next(1, 3);
54978 break;
54979 case 563:
54980 dropItem = 4547;
54981 break;
54982 case 251:
54983 dropItem = 1725;
54984 break;
54985 case 252:
54986 dropItem = 1727;
54987 break;
54988 case 253:
54989 dropItem = 1729;
54990 break;
54991 case 325:
54992 dropItem = 2692;
54993 break;
54994 case 370:
54995 dropItem = 3100;
54996 break;
54997 case 396:
54998 dropItem = 3271;
54999 break;
55000 case 400:
55001 dropItem = 3276;
55002 break;
55003 case 401:
55004 dropItem = 3277;
55005 break;
55006 case 403:
55007 dropItem = 3339;
55008 break;
55009 case 397:
55010 dropItem = 3272;
55011 break;
55012 case 398:
55013 dropItem = 3274;
55014 break;
55015 case 399:
55016 dropItem = 3275;
55017 break;
55018 case 402:
55019 dropItem = 3338;
55020 break;
55021 case 404:
55022 dropItem = 3347;
55023 break;
55024 case 407:
55025 dropItem = 3380;
55026 break;
55027 case 579:
55028 dropItem = 4761;
55029 break;
55030 case 593:
55031 dropItem = 4868;
55032 break;
55033 case 624:
55034 dropItem = 5114;
55035 break;
55036 case 656:
55037 dropItem = 5333;
55038 break;
55039 case 170:
55040 dropItem = 1872;
55041 break;
55042 case 284:
55043 dropItem = 2173;
55044 break;
55045 case 214:
55046 dropItem = 85;
55047 break;
55048 case 213:
55049 dropItem = 965;
55050 break;
55051 case 211:
55052 dropItem = 947;
55053 break;
55054 case 6:
55055 dropItem = 11;
55056 break;
55057 case 7:
55058 dropItem = 12;
55059 break;
55060 case 8:
55061 dropItem = 13;
55062 break;
55063 case 9:
55064 dropItem = 14;
55065 break;
55066 case 202:
55067 dropItem = 824;
55068 break;
55069 case 234:
55070 dropItem = 1246;
55071 break;
55072 case 226:
55073 dropItem = 1101;
55074 break;
55075 case 224:
55076 dropItem = 1103;
55077 break;
55078 case 36:
55079 dropItem = 1869;
55080 break;
55081 case 311:
55082 dropItem = 2260;
55083 break;
55084 case 312:
55085 dropItem = 2261;
55086 break;
55087 case 313:
55088 dropItem = 2262;
55089 break;
55090 case 229:
55091 dropItem = 1125;
55092 break;
55093 case 230:
55094 dropItem = 1127;
55095 break;
55096 case 221:
55097 dropItem = 1104;
55098 break;
55099 case 222:
55100 dropItem = 1105;
55101 break;
55102 case 223:
55103 dropItem = 1106;
55104 break;
55105 case 248:
55106 dropItem = 1589;
55107 break;
55108 case 249:
55109 dropItem = 1591;
55110 break;
55111 case 250:
55112 dropItem = 1593;
55113 break;
55114 case 191:
55115 dropItem = 9;
55116 break;
55117 case 203:
55118 dropItem = 836;
55119 break;
55120 case 204:
55121 dropItem = 880;
55122 break;
55123 case 166:
55124 dropItem = 699;
55125 break;
55126 case 167:
55127 dropItem = 700;
55128 break;
55129 case 168:
55130 dropItem = 701;
55131 break;
55132 case 169:
55133 dropItem = 702;
55134 break;
55135 case 123:
55136 dropItem = 424;
55137 break;
55138 case 124:
55139 dropItem = 480;
55140 break;
55141 case 157:
55142 dropItem = 619;
55143 break;
55144 case 158:
55145 dropItem = 620;
55146 break;
55147 case 159:
55148 dropItem = 621;
55149 break;
55150 case 161:
55151 dropItem = 664;
55152 break;
55153 case 206:
55154 dropItem = 883;
55155 break;
55156 case 232:
55157 dropItem = 1150;
55158 break;
55159 case 198:
55160 dropItem = 775;
55161 break;
55162 case 314:
55163 dropItem = Minecart.GetTrackItem(tileCache);
55164 break;
55165 case 189:
55166 dropItem = 751;
55167 break;
55168 case 195:
55169 dropItem = 763;
55170 break;
55171 case 194:
55172 dropItem = 154;
55173 break;
55174 case 193:
55175 dropItem = 762;
55176 break;
55177 case 196:
55178 dropItem = 765;
55179 break;
55180 case 197:
55181 dropItem = 767;
55182 break;
55183 case 22:
55184 dropItem = 56;
55185 break;
55186 case 140:
55187 dropItem = 577;
55188 break;
55189 case 23:
55190 dropItem = 2;
55191 break;
55192 case 25:
55193 dropItem = 61;
55194 break;
55195 case 30:
55196 dropItem = 9;
55197 break;
55198 case 208:
55199 dropItem = 911;
55200 break;
55201 case 372:
55202 dropItem = 3117;
55203 break;
55204 case 646:
55205 dropItem = 5322;
55206 break;
55207 case 371:
55208 dropItem = 3113;
55209 break;
55210 case 174:
55211 dropItem = 713;
55212 break;
55213 case 37:
55214 dropItem = 116;
55215 break;
55216 case 38:
55217 dropItem = 129;
55218 break;
55219 case 39:
55220 dropItem = 131;
55221 break;
55222 case 40:
55223 dropItem = 133;
55224 break;
55225 case 41:
55226 dropItem = 134;
55227 break;
55228 case 43:
55229 dropItem = 137;
55230 break;
55231 case 44:
55232 dropItem = 139;
55233 break;
55234 case 45:
55235 dropItem = 141;
55236 break;
55237 case 46:
55238 dropItem = 143;
55239 break;
55240 case 47:
55241 dropItem = 145;
55242 break;
55243 case 48:
55244 dropItem = 147;
55245 break;
55246 case 49:
55247 dropItem = 148;
55248 break;
55249 case 51:
55250 dropItem = 150;
55251 break;
55252 case 53:
55253 dropItem = 169;
55254 break;
55255 case 151:
55256 dropItem = 607;
55257 break;
55258 case 152:
55259 dropItem = 609;
55260 break;
55261 case 56:
55262 dropItem = 173;
55263 break;
55264 case 57:
55265 dropItem = 172;
55266 break;
55267 case 58:
55268 dropItem = 174;
55269 break;
55270 case 70:
55271 dropItem = 176;
55272 break;
55273 case 75:
55274 dropItem = 192;
55275 break;
55276 case 76:
55277 dropItem = 214;
55278 break;
55279 case 78:
55280 dropItem = 222;
55281 break;
55282 case 81:
55283 dropItem = 275;
55284 break;
55285 case 80:
55286 dropItem = 276;
55287 break;
55288 case 188:
55289 dropItem = 276;
55290 break;
55291 case 107:
55292 dropItem = 364;
55293 break;
55294 case 108:
55295 dropItem = 365;
55296 break;
55297 case 111:
55298 dropItem = 366;
55299 break;
55300 case 150:
55301 dropItem = 604;
55302 break;
55303 case 112:
55304 dropItem = 370;
55305 break;
55306 case 116:
55307 dropItem = 408;
55308 break;
55309 case 117:
55310 dropItem = 409;
55311 break;
55312 case 118:
55313 dropItem = 412;
55314 break;
55315 case 119:
55316 dropItem = 413;
55317 break;
55318 case 120:
55319 dropItem = 414;
55320 break;
55321 case 121:
55322 dropItem = 415;
55323 break;
55324 case 122:
55325 dropItem = 416;
55326 break;
55327 case 136:
55328 dropItem = 538;
55329 break;
55330 case 385:
55331 dropItem = 3234;
55332 break;
55333 case 141:
55334 dropItem = 580;
55335 break;
55336 case 145:
55337 dropItem = 586;
55338 break;
55339 case 146:
55340 dropItem = 591;
55341 break;
55342 case 147:
55343 dropItem = 593;
55344 break;
55345 case 148:
55346 dropItem = 594;
55347 break;
55348 case 153:
55349 dropItem = 611;
55350 break;
55351 case 154:
55352 dropItem = 612;
55353 break;
55354 case 155:
55355 dropItem = 613;
55356 break;
55357 case 156:
55358 dropItem = 614;
55359 break;
55360 case 160:
55361 dropItem = 662;
55362 break;
55363 case 175:
55364 dropItem = 717;
55365 break;
55366 case 176:
55367 dropItem = 718;
55368 break;
55369 case 177:
55370 dropItem = 719;
55371 break;
55372 case 163:
55373 dropItem = 833;
55374 break;
55375 case 164:
55376 dropItem = 834;
55377 break;
55378 case 200:
55379 dropItem = 835;
55380 break;
55381 case 210:
55382 dropItem = 937;
55383 break;
55384 case 130:
55385 dropItem = 511;
55386 break;
55387 case 131:
55388 dropItem = 512;
55389 break;
55390 case 321:
55391 dropItem = 2503;
55392 break;
55393 case 322:
55394 dropItem = 2504;
55395 break;
55396 case 635:
55397 dropItem = 5215;
55398 break;
55399 case 54:
55400 dropItem = 170;
55401 break;
55402 case 326:
55403 dropItem = 2693;
55404 break;
55405 case 327:
55406 dropItem = 2694;
55407 break;
55408 case 458:
55409 dropItem = 3754;
55410 break;
55411 case 459:
55412 dropItem = 3755;
55413 break;
55414 case 345:
55415 dropItem = 2787;
55416 break;
55417 case 328:
55418 dropItem = 2695;
55419 break;
55420 case 329:
55421 dropItem = 2697;
55422 break;
55423 case 507:
55424 dropItem = 4277;
55425 break;
55426 case 508:
55427 dropItem = 4278;
55428 break;
55429 case 255:
55430 case 256:
55431 case 257:
55432 case 258:
55433 case 259:
55434 case 260:
55435 case 261:
55436 dropItem = 1970 + tileCache.type - 255;
55437 break;
55438 case 262:
55439 case 263:
55440 case 264:
55441 case 265:
55442 case 266:
55443 case 267:
55444 case 268:
55445 dropItem = 1970 + tileCache.type - 262;
55446 break;
55447 case 59:
55448 case 60:
55449 case 661:
55450 case 662:
55451 dropItem = 176;
55452 break;
55453 case 190:
55454 dropItem = 183;
55455 break;
55456 case 63:
55457 case 64:
55458 case 65:
55459 case 66:
55460 case 67:
55461 case 68:
55462 dropItem = tileCache.type - 63 + 177;
55463 break;
55464 case 566:
55465 dropItem = 999;
55466 break;
55467 case 637:
55468 if (Main.rand.Next(100) == 0)
55469 {
55470 dropItem = 5214;
55471 }
55472 break;
55473 case 129:
55474 if (tileCache.frameX >= 324)
55475 {
55476 dropItem = 4988;
55477 }
55478 else
55479 {
55480 dropItem = 502;
55481 }
55482 break;
55483 case 3:
55484 if (tileCache.frameX == 144)
55485 {
55486 dropItem = 5;
55487 }
55488 else if (KillTile_ShouldDropSeeds(x, y))
55489 {
55490 dropItem = 283;
55491 }
55492 break;
55493 case 519:
55494 if (tileCache.frameY == 90 && genRand.Next(2) == 0)
55495 {
55496 dropItem = 183;
55497 }
55498 break;
55499 case 528:
55500 if (genRand.Next(2) == 0)
55501 {
55502 dropItem = 183;
55503 }
55504 break;
55505 case 110:
55506 if (tileCache.frameX == 144)
55507 {
55508 dropItem = 5;
55509 }
55510 break;
55511 case 24:
55512 if (tileCache.frameX == 144)
55513 {
55514 dropItem = 60;
55515 }
55516 break;
55517 case 201:
55518 if (tileCache.frameX == 270)
55519 {
55520 dropItem = 2887;
55521 }
55522 break;
55523 case 73:
55524 if (KillTile_ShouldDropSeeds(x, y))
55525 {
55526 dropItem = 283;
55527 }
55528 break;
55529 case 52:
55530 case 62:
55531 case 382:
55532 if (Main.rand.Next(2) == 0 && GetPlayerForTile(x, y).cordage)
55533 {
55534 dropItem = 2996;
55535 }
55536 break;
55537 case 227:
55538 num = tileCache.frameX / 34;
55539 dropItem = 1107 + num;
55540 if (num >= 8 && num <= 11)
55541 {
55542 dropItem = 3385 + num - 8;
55543 }
55544 break;
55545 case 4:
55546 num = tileCache.frameY / 22;
55547 switch (num)
55548 {
55549 case 0:
55550 dropItem = 8;
55551 break;
55552 case 8:
55553 dropItem = 523;
55554 break;
55555 case 9:
55556 dropItem = 974;
55557 break;
55558 case 10:
55559 dropItem = 1245;
55560 break;
55561 case 11:
55562 dropItem = 1333;
55563 break;
55564 case 12:
55565 dropItem = 2274;
55566 break;
55567 case 13:
55568 dropItem = 3004;
55569 break;
55570 case 14:
55571 dropItem = 3045;
55572 break;
55573 case 15:
55574 dropItem = 3114;
55575 break;
55576 case 16:
55577 dropItem = 4383;
55578 break;
55579 case 17:
55580 dropItem = 4384;
55581 break;
55582 case 18:
55583 dropItem = 4385;
55584 break;
55585 case 19:
55586 dropItem = 4386;
55587 break;
55588 case 20:
55589 dropItem = 4387;
55590 break;
55591 case 21:
55592 dropItem = 4388;
55593 break;
55594 case 22:
55595 dropItem = 5293;
55596 break;
55597 case 23:
55598 dropItem = 5353;
55599 break;
55600 default:
55601 dropItem = 426 + num;
55602 break;
55603 }
55604 break;
55605 case 239:
55606 num = tileCache.frameX / 18;
55607 if (num == 0)
55608 {
55609 dropItem = 20;
55610 }
55611 if (num == 1)
55612 {
55613 dropItem = 703;
55614 }
55615 if (num == 2)
55616 {
55617 dropItem = 22;
55618 }
55619 if (num == 3)
55620 {
55621 dropItem = 704;
55622 }
55623 if (num == 4)
55624 {
55625 dropItem = 21;
55626 }
55627 if (num == 5)
55628 {
55629 dropItem = 705;
55630 }
55631 if (num == 6)
55632 {
55633 dropItem = 19;
55634 }
55635 if (num == 7)
55636 {
55637 dropItem = 706;
55638 }
55639 if (num == 8)
55640 {
55641 dropItem = 57;
55642 }
55643 if (num == 9)
55644 {
55645 dropItem = 117;
55646 }
55647 if (num == 10)
55648 {
55649 dropItem = 175;
55650 }
55651 if (num == 11)
55652 {
55653 dropItem = 381;
55654 }
55655 if (num == 12)
55656 {
55657 dropItem = 1184;
55658 }
55659 if (num == 13)
55660 {
55661 dropItem = 382;
55662 }
55663 if (num == 14)
55664 {
55665 dropItem = 1191;
55666 }
55667 if (num == 15)
55668 {
55669 dropItem = 391;
55670 }
55671 if (num == 16)
55672 {
55673 dropItem = 1198;
55674 }
55675 if (num == 17)
55676 {
55677 dropItem = 1006;
55678 }
55679 if (num == 18)
55680 {
55681 dropItem = 1225;
55682 }
55683 if (num == 19)
55684 {
55685 dropItem = 1257;
55686 }
55687 if (num == 20)
55688 {
55689 dropItem = 1552;
55690 }
55691 if (num == 21)
55692 {
55693 dropItem = 3261;
55694 }
55695 if (num == 22)
55696 {
55697 dropItem = 3467;
55698 }
55699 break;
55700 case 380:
55701 num = tileCache.frameY / 18;
55702 dropItem = 3215 + num;
55703 break;
55704 case 5:
55705 case 596:
55706 case 616:
55707 case 634:
55708 {
55709 bool bonusWood = false;
55710 KillTile_GetTreeDrops(x, y, tileCache, ref bonusWood, ref dropItem, ref secondaryItem);
55711 if (bonusWood)
55712 {
55713 dropItemStack++;
55714 }
55715 break;
55716 }
55717 case 323:
55718 {
55719 dropItem = 2504;
55721 {
55722 dropItemStack += genRand.Next(2, 5);
55723 }
55724 if (tileCache.frameX <= 132 && tileCache.frameX >= 88)
55725 {
55726 secondaryItem = 27;
55727 }
55728 int j;
55729 for (j = y; !Main.tile[x, j].active() || !Main.tileSolid[Main.tile[x, j].type]; j++)
55730 {
55731 }
55732 if (Main.tile[x, j].active())
55733 {
55734 switch (Main.tile[x, j].type)
55735 {
55736 case 234:
55737 dropItem = 911;
55738 break;
55739 case 116:
55740 dropItem = 621;
55741 break;
55742 case 112:
55743 dropItem = 619;
55744 break;
55745 }
55746 }
55747 break;
55748 }
55749 case 171:
55750 if (tileCache.frameX >= 10)
55751 {
55752 dropXmasTree(x, y, 0);
55753 dropXmasTree(x, y, 1);
55754 dropXmasTree(x, y, 2);
55755 dropXmasTree(x, y, 3);
55756 }
55757 break;
55758 case 324:
55759 switch (tileCache.frameY / 22)
55760 {
55761 case 0:
55762 dropItem = 2625;
55763 break;
55764 case 1:
55765 dropItem = 2626;
55766 break;
55767 case 2:
55768 dropItem = 4072;
55769 break;
55770 case 3:
55771 dropItem = 4073;
55772 break;
55773 case 4:
55774 dropItem = 4071;
55775 break;
55776 }
55777 break;
55778 case 419:
55779 switch (tileCache.frameX / 18)
55780 {
55781 case 0:
55782 dropItem = 3602;
55783 break;
55784 case 1:
55785 dropItem = 3618;
55786 break;
55787 case 2:
55788 dropItem = 3663;
55789 break;
55790 }
55791 break;
55792 case 428:
55793 switch (tileCache.frameY / 18)
55794 {
55795 case 0:
55796 dropItem = 3630;
55797 break;
55798 case 1:
55799 dropItem = 3632;
55800 break;
55801 case 2:
55802 dropItem = 3631;
55803 break;
55804 case 3:
55805 dropItem = 3626;
55806 break;
55807 }
55809 break;
55810 case 420:
55811 switch (tileCache.frameY / 18)
55812 {
55813 case 0:
55814 dropItem = 3603;
55815 break;
55816 case 1:
55817 dropItem = 3604;
55818 break;
55819 case 2:
55820 dropItem = 3605;
55821 break;
55822 case 3:
55823 dropItem = 3606;
55824 break;
55825 case 4:
55826 dropItem = 3607;
55827 break;
55828 case 5:
55829 dropItem = 3608;
55830 break;
55831 }
55832 break;
55833 case 650:
55834 num = tileCache.frameX / 18;
55835 if (num < 6)
55836 {
55837 dropItem = 3;
55838 }
55839 else if (num < 12)
55840 {
55841 dropItem = 2;
55842 }
55843 else if (num < 20)
55844 {
55845 dropItem = 154;
55846 }
55847 else if (num < 28)
55848 {
55849 dropItem = 154;
55850 }
55851 else if (num < 36)
55852 {
55853 dropItem = 9;
55854 }
55855 else if (num < 42)
55856 {
55857 dropItem = 593;
55858 }
55859 else if (num < 48)
55860 {
55861 dropItem = 664;
55862 }
55863 else if (num < 54)
55864 {
55865 dropItem = 150;
55866 }
55867 else if (num < 60)
55868 {
55869 dropItem = 3271;
55870 }
55871 else if (num < 66)
55872 {
55873 dropItem = 3086;
55874 }
55875 else if (num < 72)
55876 {
55877 dropItem = 3081;
55878 }
55879 else if (num < 73)
55880 {
55881 dropItem = 62;
55882 }
55883 else if (num < 77)
55884 {
55885 dropItem = 169;
55886 }
55887 break;
55888 case 476:
55889 dropItem = 4040;
55890 break;
55891 case 494:
55892 dropItem = 4089;
55893 break;
55894 case 423:
55895 TELogicSensor.Kill(x, y);
55896 switch (tileCache.frameY / 18)
55897 {
55898 case 0:
55899 dropItem = 3613;
55900 break;
55901 case 1:
55902 dropItem = 3614;
55903 break;
55904 case 2:
55905 dropItem = 3615;
55906 break;
55907 case 3:
55908 dropItem = 3726;
55909 break;
55910 case 4:
55911 dropItem = 3727;
55912 break;
55913 case 5:
55914 dropItem = 3728;
55915 break;
55916 case 6:
55917 dropItem = 3729;
55918 break;
55919 }
55920 break;
55921 case 520:
55922 dropItem = 4326;
55923 break;
55924 case 225:
55925 if (Main.rand.Next(3) == 0)
55926 {
55927 tileCache.honey(honey: true);
55928 tileCache.liquid = byte.MaxValue;
55929 break;
55930 }
55931 dropItem = 1124;
55932 if (Main.netMode != 1 && Main.rand.Next(2) == 0)
55933 {
55934 int num3 = 1;
55935 if (Main.rand.Next(3) == 0)
55936 {
55937 num3 = 2;
55938 }
55939 for (int i = 0; i < num3; i++)
55940 {
55941 int type = Main.rand.Next(210, 212);
55942 int num4 = NPC.NewNPC(GetNPCSource_TileBreak(x, y), x * 16 + 8, y * 16 + 15, type, 1);
55943 Main.npc[num4].velocity.X = (float)Main.rand.Next(-200, 201) * 0.002f;
55944 Main.npc[num4].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.002f;
55945 Main.npc[num4].netUpdate = true;
55946 }
55947 }
55948 break;
55949 case 178:
55950 switch (tileCache.frameX / 18)
55951 {
55952 case 0:
55953 dropItem = 181;
55954 break;
55955 case 1:
55956 dropItem = 180;
55957 break;
55958 case 2:
55959 dropItem = 177;
55960 break;
55961 case 3:
55962 dropItem = 179;
55963 break;
55964 case 4:
55965 dropItem = 178;
55966 break;
55967 case 5:
55968 dropItem = 182;
55969 break;
55970 case 6:
55971 dropItem = 999;
55972 break;
55973 }
55974 break;
55975 case 149:
55976 if (tileCache.frameX == 0 || tileCache.frameX == 54)
55977 {
55978 dropItem = 596;
55979 }
55980 else if (tileCache.frameX == 18 || tileCache.frameX == 72)
55981 {
55982 dropItem = 597;
55983 }
55984 else if (tileCache.frameX == 36 || tileCache.frameX == 90)
55985 {
55986 dropItem = 598;
55987 }
55988 break;
55989 case 13:
55990 switch (tileCache.frameX / 18)
55991 {
55992 case 1:
55993 dropItem = 28;
55994 break;
55995 case 2:
55996 dropItem = 110;
55997 break;
55998 case 3:
55999 dropItem = 350;
56000 break;
56001 case 4:
56002 dropItem = 351;
56003 break;
56004 case 5:
56005 dropItem = 2234;
56006 break;
56007 case 6:
56008 dropItem = 2244;
56009 break;
56010 case 7:
56011 dropItem = 2257;
56012 break;
56013 case 8:
56014 dropItem = 2258;
56015 break;
56016 default:
56017 dropItem = 31;
56018 break;
56019 }
56020 break;
56021 case 19:
56022 num = tileCache.frameY / 18;
56023 switch (num)
56024 {
56025 case 0:
56026 dropItem = 94;
56027 break;
56028 case 1:
56029 dropItem = 631;
56030 break;
56031 case 2:
56032 dropItem = 632;
56033 break;
56034 case 3:
56035 dropItem = 633;
56036 break;
56037 case 4:
56038 dropItem = 634;
56039 break;
56040 case 5:
56041 dropItem = 913;
56042 break;
56043 case 6:
56044 dropItem = 1384;
56045 break;
56046 case 7:
56047 dropItem = 1385;
56048 break;
56049 case 8:
56050 dropItem = 1386;
56051 break;
56052 case 9:
56053 dropItem = 1387;
56054 break;
56055 case 10:
56056 dropItem = 1388;
56057 break;
56058 case 11:
56059 dropItem = 1389;
56060 break;
56061 case 12:
56062 dropItem = 1418;
56063 break;
56064 case 13:
56065 dropItem = 1457;
56066 break;
56067 case 14:
56068 dropItem = 1702;
56069 break;
56070 case 15:
56071 dropItem = 1796;
56072 break;
56073 case 16:
56074 dropItem = 1818;
56075 break;
56076 case 17:
56077 dropItem = 2518;
56078 break;
56079 case 18:
56080 dropItem = 2549;
56081 break;
56082 case 19:
56083 dropItem = 2566;
56084 break;
56085 case 20:
56086 dropItem = 2581;
56087 break;
56088 case 21:
56089 dropItem = 2627;
56090 break;
56091 case 22:
56092 dropItem = 2628;
56093 break;
56094 case 23:
56095 dropItem = 2629;
56096 break;
56097 case 24:
56098 dropItem = 2630;
56099 break;
56100 case 25:
56101 dropItem = 2744;
56102 break;
56103 case 26:
56104 dropItem = 2822;
56105 break;
56106 case 27:
56107 dropItem = 3144;
56108 break;
56109 case 28:
56110 dropItem = 3146;
56111 break;
56112 case 29:
56113 dropItem = 3145;
56114 break;
56115 case 30:
56116 case 31:
56117 case 32:
56118 case 33:
56119 case 34:
56120 case 35:
56121 dropItem = 3903 + num - 30;
56122 break;
56123 default:
56124 switch (num)
56125 {
56126 case 36:
56127 dropItem = 3945;
56128 break;
56129 case 37:
56130 dropItem = 3957;
56131 break;
56132 case 38:
56133 dropItem = 4159;
56134 break;
56135 case 39:
56136 dropItem = 4180;
56137 break;
56138 case 40:
56139 dropItem = 4201;
56140 break;
56141 case 41:
56142 dropItem = 4222;
56143 break;
56144 case 42:
56145 dropItem = 4311;
56146 break;
56147 case 43:
56148 dropItem = 4416;
56149 break;
56150 case 44:
56151 dropItem = 4580;
56152 break;
56153 case 45:
56154 dropItem = 5162;
56155 break;
56156 case 46:
56157 dropItem = 5183;
56158 break;
56159 case 47:
56160 dropItem = 5204;
56161 break;
56162 case 48:
56163 dropItem = 5292;
56164 break;
56165 }
56166 break;
56167 }
56168 break;
56169 case 33:
56170 num = tileCache.frameY / 22;
56171 dropItem = 105;
56172 switch (num)
56173 {
56174 case 1:
56175 dropItem = 1405;
56176 break;
56177 case 2:
56178 dropItem = 1406;
56179 break;
56180 case 3:
56181 dropItem = 1407;
56182 break;
56183 case 4:
56184 case 5:
56185 case 6:
56186 case 7:
56187 case 8:
56188 case 9:
56189 case 10:
56190 case 11:
56191 case 12:
56192 case 13:
56193 dropItem = 2045 + num - 4;
56194 break;
56195 default:
56196 if (num >= 14 && num <= 16)
56197 {
56198 dropItem = 2153 + num - 14;
56199 break;
56200 }
56201 switch (num)
56202 {
56203 case 17:
56204 dropItem = 2236;
56205 break;
56206 case 18:
56207 dropItem = 2523;
56208 break;
56209 case 19:
56210 dropItem = 2542;
56211 break;
56212 case 20:
56213 dropItem = 2556;
56214 break;
56215 case 21:
56216 dropItem = 2571;
56217 break;
56218 case 22:
56219 dropItem = 2648;
56220 break;
56221 case 23:
56222 dropItem = 2649;
56223 break;
56224 case 24:
56225 dropItem = 2650;
56226 break;
56227 case 25:
56228 dropItem = 2651;
56229 break;
56230 case 26:
56231 dropItem = 2818;
56232 break;
56233 case 27:
56234 dropItem = 3171;
56235 break;
56236 case 28:
56237 dropItem = 3173;
56238 break;
56239 case 29:
56240 dropItem = 3172;
56241 break;
56242 case 30:
56243 dropItem = 3890;
56244 break;
56245 case 31:
56246 dropItem = 3936;
56247 break;
56248 case 32:
56249 dropItem = 3962;
56250 break;
56251 case 33:
56252 dropItem = 4150;
56253 break;
56254 case 34:
56255 dropItem = 4171;
56256 break;
56257 case 35:
56258 dropItem = 4192;
56259 break;
56260 case 36:
56261 dropItem = 4213;
56262 break;
56263 case 37:
56264 dropItem = 4303;
56265 break;
56266 case 38:
56267 dropItem = 4571;
56268 break;
56269 case 39:
56270 dropItem = 5153;
56271 break;
56272 case 40:
56273 dropItem = 5174;
56274 break;
56275 case 41:
56276 dropItem = 5195;
56277 break;
56278 }
56279 break;
56280 }
56281 break;
56282 case 137:
56283 num = tileCache.frameY / 18;
56284 if (num == 0)
56285 {
56286 dropItem = 539;
56287 }
56288 if (num == 1)
56289 {
56290 dropItem = 1146;
56291 }
56292 if (num == 2)
56293 {
56294 dropItem = 1147;
56295 }
56296 if (num == 3)
56297 {
56298 dropItem = 1148;
56299 }
56300 if (num == 4)
56301 {
56302 dropItem = 1149;
56303 }
56304 if (num == 5)
56305 {
56306 dropItem = 5135;
56307 }
56308 break;
56309 case 135:
56310 num = tileCache.frameY / 18;
56311 if (num == 0)
56312 {
56313 dropItem = 529;
56314 }
56315 if (num == 1)
56316 {
56317 dropItem = 541;
56318 }
56319 if (num == 2)
56320 {
56321 dropItem = 542;
56322 }
56323 if (num == 3)
56324 {
56325 dropItem = 543;
56326 }
56327 if (num == 4)
56328 {
56329 dropItem = 852;
56330 }
56331 if (num == 5)
56332 {
56333 dropItem = 853;
56334 }
56335 if (num == 6)
56336 {
56337 dropItem = 1151;
56338 }
56339 break;
56340 case 144:
56341 if (tileCache.frameX == 0)
56342 {
56343 dropItem = 583;
56344 }
56345 if (tileCache.frameX == 18)
56346 {
56347 dropItem = 584;
56348 }
56349 if (tileCache.frameX == 36)
56350 {
56351 dropItem = 585;
56352 }
56353 if (tileCache.frameX == 54)
56354 {
56355 dropItem = 4484;
56356 }
56357 if (tileCache.frameX == 72)
56358 {
56359 dropItem = 4485;
56360 }
56361 break;
56362 case 61:
56363 case 74:
56364 if (tileCache.frameX == 144 && tileCache.type == 61)
56365 {
56366 dropItem = 331;
56367 dropItemStack = Main.rand.Next(2, 4);
56368 }
56369 else if (tileCache.frameX == 162 && tileCache.type == 61)
56370 {
56371 dropItem = 223;
56372 }
56373 else if (tileCache.frameX >= 108 && tileCache.frameX <= 126 && tileCache.type == 61 && Main.rand.Next(20) == 0)
56374 {
56375 dropItem = 208;
56376 }
56377 else if (Main.rand.Next(100) == 0)
56378 {
56379 dropItem = 195;
56380 }
56381 break;
56382 case 71:
56383 case 72:
56384 if (Main.rand.Next(40) == 0)
56385 {
56386 dropItem = 194;
56387 }
56388 else if (Main.rand.Next(2) == 0)
56389 {
56390 dropItem = 183;
56391 }
56392 break;
56393 case 50:
56394 if (tileCache.frameX == 90)
56395 {
56396 dropItem = 165;
56397 }
56398 else
56399 {
56400 dropItem = 149;
56401 }
56402 break;
56403 case 83:
56404 case 84:
56405 {
56406 num = tileCache.frameX / 18;
56407 dropItem = 313 + num;
56408 int num2 = 307 + num;
56409 if (num == 6)
56410 {
56411 dropItem = 2358;
56412 num2 = 2357;
56413 }
56414 bool flag = IsHarvestableHerbWithSeed(tileCache.type, num);
56415 Player playerForTile = GetPlayerForTile(x, y);
56416 if (playerForTile.HeldItem.type == 213 || playerForTile.HeldItem.type == 5295)
56417 {
56418 dropItemStack = Main.rand.Next(1, 3);
56420 secondaryItemStack = Main.rand.Next(1, 6);
56421 }
56422 else if (flag)
56423 {
56425 secondaryItemStack = Main.rand.Next(1, 4);
56426 }
56427 break;
56428 }
56429 case 589:
56430 SetGemTreeDrops(999, 4857, tileCache, ref dropItem, ref secondaryItem);
56431 if (dropItem == 3)
56432 {
56433 dropItemStack = Main.rand.Next(1, 3);
56434 }
56435 break;
56436 case 584:
56437 SetGemTreeDrops(181, 4852, tileCache, ref dropItem, ref secondaryItem);
56438 if (dropItem == 3)
56439 {
56440 dropItemStack = Main.rand.Next(1, 3);
56441 }
56442 break;
56443 case 583:
56444 SetGemTreeDrops(180, 4851, tileCache, ref dropItem, ref secondaryItem);
56445 if (dropItem == 3)
56446 {
56447 dropItemStack = Main.rand.Next(1, 3);
56448 }
56449 break;
56450 case 586:
56451 SetGemTreeDrops(179, 4854, tileCache, ref dropItem, ref secondaryItem);
56452 if (dropItem == 3)
56453 {
56454 dropItemStack = Main.rand.Next(1, 3);
56455 }
56456 break;
56457 case 585:
56458 SetGemTreeDrops(177, 4853, tileCache, ref dropItem, ref secondaryItem);
56459 if (dropItem == 3)
56460 {
56461 dropItemStack = Main.rand.Next(1, 3);
56462 }
56463 break;
56464 case 587:
56465 SetGemTreeDrops(178, 4855, tileCache, ref dropItem, ref secondaryItem);
56466 if (dropItem == 3)
56467 {
56468 dropItemStack = Main.rand.Next(1, 3);
56469 }
56470 break;
56471 case 588:
56472 SetGemTreeDrops(182, 4856, tileCache, ref dropItem, ref secondaryItem);
56473 if (dropItem == 3)
56474 {
56475 dropItemStack = Main.rand.Next(1, 3);
56476 }
56477 break;
56478 case 10:
56479 case 11:
56480 case 12:
56481 case 14:
56482 case 15:
56483 case 16:
56484 case 17:
56485 case 18:
56486 case 20:
56487 case 21:
56488 case 26:
56489 case 27:
56490 case 28:
56491 case 29:
56492 case 31:
56493 case 32:
56494 case 34:
56495 case 35:
56496 case 42:
56497 case 55:
56498 case 69:
56499 case 77:
56500 case 79:
56501 case 82:
56502 case 85:
56503 case 86:
56504 case 87:
56505 case 88:
56506 case 89:
56507 case 90:
56508 case 91:
56509 case 92:
56510 case 93:
56511 case 94:
56512 case 95:
56513 case 96:
56514 case 97:
56515 case 98:
56516 case 99:
56517 case 100:
56518 case 101:
56519 case 102:
56520 case 103:
56521 case 104:
56522 case 105:
56523 case 106:
56524 case 113:
56525 case 114:
56526 case 115:
56527 case 125:
56528 case 126:
56529 case 127:
56530 case 128:
56531 case 132:
56532 case 133:
56533 case 134:
56534 case 138:
56535 case 139:
56536 case 142:
56537 case 143:
56538 case 162:
56539 case 165:
56540 case 172:
56541 case 173:
56542 case 184:
56543 case 185:
56544 case 186:
56545 case 187:
56546 case 192:
56547 case 205:
56548 case 207:
56549 case 209:
56550 case 212:
56551 case 215:
56552 case 216:
56553 case 217:
56554 case 218:
56555 case 219:
56556 case 220:
56557 case 228:
56558 case 231:
56559 case 233:
56560 case 235:
56561 case 236:
56562 case 237:
56563 case 238:
56564 case 240:
56565 case 241:
56566 case 242:
56567 case 243:
56568 case 244:
56569 case 245:
56570 case 246:
56571 case 247:
56572 case 254:
56573 case 269:
56574 case 270:
56575 case 271:
56576 case 275:
56577 case 276:
56578 case 277:
56579 case 278:
56580 case 279:
56581 case 280:
56582 case 281:
56583 case 282:
56584 case 283:
56585 case 285:
56586 case 286:
56587 case 287:
56588 case 288:
56589 case 289:
56590 case 290:
56591 case 291:
56592 case 292:
56593 case 293:
56594 case 294:
56595 case 295:
56596 case 296:
56597 case 297:
56598 case 298:
56599 case 299:
56600 case 300:
56601 case 301:
56602 case 302:
56603 case 303:
56604 case 304:
56605 case 305:
56606 case 306:
56607 case 307:
56608 case 308:
56609 case 309:
56610 case 310:
56611 case 316:
56612 case 317:
56613 case 318:
56614 case 319:
56615 case 320:
56616 case 334:
56617 case 335:
56618 case 337:
56619 case 338:
56620 case 339:
56621 case 349:
56622 case 352:
56623 case 354:
56624 case 355:
56625 case 356:
56626 case 358:
56627 case 359:
56628 case 360:
56629 case 361:
56630 case 362:
56631 case 363:
56632 case 364:
56633 case 373:
56634 case 374:
56635 case 375:
56636 case 376:
56637 case 377:
56638 case 378:
56639 case 384:
56640 case 386:
56641 case 387:
56642 case 388:
56643 case 389:
56644 case 390:
56645 case 391:
56646 case 392:
56647 case 393:
56648 case 394:
56649 case 395:
56650 case 405:
56651 case 406:
56652 case 410:
56653 case 411:
56654 case 412:
56655 case 413:
56656 case 414:
56657 case 425:
56658 case 440:
56659 case 441:
56660 case 443:
56661 case 444:
56662 case 452:
56663 case 453:
56664 case 454:
56665 case 455:
56666 case 456:
56667 case 457:
56668 case 461:
56669 case 462:
56670 case 463:
56671 case 464:
56672 case 465:
56673 case 466:
56674 case 467:
56675 case 468:
56676 case 469:
56677 case 470:
56678 case 471:
56679 case 475:
56680 case 480:
56681 case 481:
56682 case 482:
56683 case 483:
56684 case 484:
56685 case 485:
56686 case 486:
56687 case 487:
56688 case 488:
56689 case 489:
56690 case 490:
56691 case 491:
56692 case 493:
56693 case 497:
56694 case 499:
56695 case 504:
56696 case 505:
56697 case 506:
56698 case 509:
56699 case 510:
56700 case 511:
56701 case 518:
56702 case 521:
56703 case 522:
56704 case 523:
56705 case 524:
56706 case 525:
56707 case 526:
56708 case 527:
56709 case 529:
56710 case 530:
56711 case 531:
56712 case 532:
56713 case 533:
56714 case 538:
56715 case 542:
56716 case 543:
56717 case 544:
56718 case 545:
56719 case 547:
56720 case 548:
56721 case 549:
56722 case 550:
56723 case 551:
56724 case 552:
56725 case 553:
56726 case 554:
56727 case 555:
56728 case 556:
56729 case 558:
56730 case 559:
56731 case 560:
56732 case 564:
56733 case 565:
56734 case 567:
56735 case 568:
56736 case 569:
56737 case 570:
56738 case 572:
56739 case 573:
56740 case 580:
56741 case 581:
56742 case 582:
56743 case 590:
56744 case 591:
56745 case 592:
56746 case 594:
56747 case 595:
56748 case 597:
56749 case 598:
56750 case 599:
56751 case 600:
56752 case 601:
56753 case 602:
56754 case 603:
56755 case 604:
56756 case 605:
56757 case 606:
56758 case 607:
56759 case 608:
56760 case 609:
56761 case 610:
56762 case 611:
56763 case 612:
56764 case 613:
56765 case 614:
56766 case 615:
56767 case 617:
56768 case 619:
56769 case 620:
56770 case 621:
56771 case 622:
56772 case 623:
56773 case 629:
56774 case 632:
56775 case 636:
56776 case 638:
56777 case 639:
56778 case 640:
56779 case 642:
56780 case 643:
56781 case 644:
56782 case 645:
56783 case 647:
56784 case 648:
56785 case 649:
56786 case 651:
56787 case 652:
56788 case 653:
56789 case 654:
56790 case 655:
56791 case 657:
56792 case 658:
56793 case 660:
56794 case 663:
56795 case 664:
56796 case 665:
56797 break;
56798 }
56799 }
56800
56801 private static void SetGemTreeDrops(int gemType, int seedType, Tile tileCache, ref int dropItem, ref int secondaryItem)
56802 {
56803 if (Main.rand.Next(10) == 0)
56804 {
56805 dropItem = gemType;
56806 }
56807 else
56808 {
56809 dropItem = 3;
56810 }
56811 if (tileCache.frameX >= 22 && tileCache.frameY >= 198 && Main.rand.Next(2) == 0)
56812 {
56814 }
56815 }
56816
56817 private static void SetVanityTreeDrops(int dropType, Tile tileCache, ref int dropItem)
56818 {
56819 if (Main.rand.Next(2) == 0)
56820 {
56822 }
56823 }
56824
56825 public static bool IsHarvestableHerbWithSeed(int type, int style)
56826 {
56827 switch (type)
56828 {
56829 case 82:
56830 return false;
56831 default:
56832 return false;
56833 case 83:
56834 case 84:
56835 {
56836 bool result = false;
56837 if (type == 84)
56838 {
56839 result = true;
56840 }
56841 if (style == 0 && Main.dayTime)
56842 {
56843 result = true;
56844 }
56845 if (style == 1 && !Main.dayTime)
56846 {
56847 result = true;
56848 }
56849 if (style == 3 && !Main.dayTime && (Main.bloodMoon || Main.moonPhase == 0))
56850 {
56851 result = true;
56852 }
56853 if (style == 4 && (Main.raining || Main.cloudAlpha > 0f))
56854 {
56855 result = true;
56856 }
56857 if (style == 5 && !Main.raining && Main.dayTime && Main.time > 40500.0)
56858 {
56859 result = true;
56860 }
56861 return result;
56862 }
56863 }
56864 }
56865
56866 private static bool KillTile_ShouldDropSeeds(int x, int y)
56867 {
56868 if (Main.rand.Next(2) == 0)
56869 {
56870 if (!GetPlayerForTile(x, y).HasItem(281))
56871 {
56872 return GetPlayerForTile(x, y).HasItem(986);
56873 }
56874 return true;
56875 }
56876 return false;
56877 }
56878
56879 private static void KillTile_GetTreeDrops(int i, int j, Tile tileCache, ref bool bonusWood, ref int dropItem, ref int secondaryItem)
56880 {
56881 if (tileCache.frameX >= 22 && tileCache.frameY >= 198)
56882 {
56883 if (Main.netMode != 1)
56884 {
56885 if (genRand.Next(2) == 0)
56886 {
56887 int k;
56888 for (k = j; Main.tile[i, k] != null && (!Main.tile[i, k].active() || !Main.tileSolid[Main.tile[i, k].type] || Main.tileSolidTop[Main.tile[i, k].type]); k++)
56889 {
56890 }
56891 if (Main.tile[i, k] != null)
56892 {
56893 Tile tile = Main.tile[i, k];
56894 if (tile.type == 2 || tile.type == 109 || tile.type == 477 || tile.type == 492 || tile.type == 147 || tile.type == 199 || tile.type == 23 || tile.type == 633)
56895 {
56896 dropItem = 9;
56897 secondaryItem = 27;
56898 }
56899 else
56900 {
56901 dropItem = 9;
56902 }
56903 }
56904 }
56905 else
56906 {
56907 dropItem = 9;
56908 }
56909 }
56910 }
56911 else
56912 {
56913 dropItem = 9;
56914 }
56915 if (dropItem != 9)
56916 {
56917 return;
56918 }
56919 GetTreeBottom(i, j, out var x, out var y);
56920 if (Main.tile[x, y].active())
56921 {
56922 switch (Main.tile[x, y].type)
56923 {
56924 case 633:
56925 dropItem = 5215;
56926 break;
56927 case 23:
56928 case 661:
56929 dropItem = 619;
56930 break;
56931 case 199:
56932 case 662:
56933 dropItem = 911;
56934 break;
56935 case 60:
56936 dropItem = 620;
56937 break;
56938 case 109:
56939 case 492:
56940 dropItem = 621;
56941 break;
56942 case 70:
56943 if (genRand.Next(2) == 0)
56944 {
56945 dropItem = 183;
56946 }
56947 else
56948 {
56949 dropItem = 0;
56950 }
56951 break;
56952 case 147:
56953 dropItem = 2503;
56954 break;
56955 }
56956 }
56957 int num = Player.FindClosest(new Vector2(x * 16, y * 16), 16, 16);
56958 int axe = Main.player[num].inventory[Main.player[num].selectedItem].axe;
56959 if (genRand.Next(100) < axe || Main.rand.Next(3) == 0)
56960 {
56961 bonusWood = true;
56962 }
56963 }
56964
56965 private static void KillTile_DropBait(int i, int j, Tile tileCache)
56966 {
56967 int num = -1;
56968 int num2 = -1;
56969 int num3 = -1;
56970 int num4 = -1;
56971 int num5 = Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16);
56972 if (tileCache.type == 3)
56973 {
56974 num = 400;
56975 num2 = 100;
56976 if (Main.player[num5].flowerBoots && tileCache.frameX >= 108)
56977 {
56978 num *= 10000;
56979 num2 *= 10000;
56980 }
56981 }
56982 if (tileCache.type == 73)
56983 {
56984 num = 200;
56985 num2 = 50;
56986 if (Main.player[num5].flowerBoots && tileCache.frameX >= 108)
56987 {
56988 num *= 10000;
56989 num2 *= 10000;
56990 }
56991 }
56992 if (tileCache.type == 637)
56993 {
56994 num4 = 100;
56995 if (Main.player[num5].flowerBoots && tileCache.frameX >= 108)
56996 {
56997 num4 *= 10000;
56998 }
56999 }
57000 if (tileCache.type == 61)
57001 {
57002 num3 = 80;
57003 if (Main.player[num5].flowerBoots && tileCache.frameX >= 108)
57004 {
57005 num3 *= 10000;
57006 }
57007 }
57008 if (tileCache.type == 74)
57009 {
57010 num3 = 40;
57011 if (Main.player[num5].flowerBoots && tileCache.frameX >= 108)
57012 {
57013 num3 *= 10000;
57014 }
57015 }
57016 if (tileCache.type == 62)
57017 {
57018 num3 = 250;
57019 }
57020 if (tileCache.type == 185)
57021 {
57022 if (tileCache.frameY == 0 && tileCache.frameX < 214)
57023 {
57024 num = 6;
57025 }
57026 if (tileCache.frameY == 18 && (tileCache.frameX < 214 || tileCache.frameX >= 1368))
57027 {
57028 num = 6;
57029 }
57030 }
57031 else if (tileCache.type == 186)
57032 {
57033 if (tileCache.frameX >= 378 && tileCache.frameX <= 700)
57034 {
57035 num = 6;
57036 }
57037 }
57038 else if (tileCache.type == 187)
57039 {
57040 if (tileCache.frameX >= 756 && tileCache.frameX <= 916)
57041 {
57042 num = 6;
57043 }
57044 if (tileCache.frameX <= 322)
57045 {
57046 num = 6;
57047 }
57048 }
57049 else if (tileCache.type == 233)
57050 {
57051 num3 = 10;
57052 }
57053 int num6 = 357;
57054 if (Main.player[num5].ZoneGraveyard)
57055 {
57056 num6 = 606;
57057 }
57058 if (num > 0 && NPC.CountNPCS(num6) < 5 && genRand.Next(num) == 0)
57059 {
57060 int type = num6;
57061 if (num6 == 357 && Player.GetClosestRollLuck(i, j, NPC.goldCritterChance) == 0f)
57062 {
57063 type = 448;
57064 }
57065 int num7 = NPC.NewNPC(GetNPCSource_TileBreak(i, j), i * 16 + 10, j * 16, type);
57066 Main.npc[num7].TargetClosest();
57067 Main.npc[num7].velocity.Y = (float)genRand.Next(-50, -21) * 0.1f;
57068 Main.npc[num7].velocity.X = (float)genRand.Next(0, 26) * 0.1f * (float)(-Main.npc[num7].direction);
57069 Main.npc[num7].direction *= -1;
57070 Main.npc[num7].netUpdate = true;
57071 }
57072 if (num2 > 0 && NPC.CountNPCS(377) < 5 && genRand.Next(num2) == 0)
57073 {
57074 int type2 = 377;
57076 {
57077 type2 = 446;
57078 }
57079 int num8 = NPC.NewNPC(GetNPCSource_TileBreak(i, j), i * 16 + 10, j * 16, type2);
57080 Main.npc[num8].TargetClosest();
57081 Main.npc[num8].velocity.Y = (float)genRand.Next(-50, -21) * 0.1f;
57082 Main.npc[num8].velocity.X = (float)genRand.Next(0, 26) * 0.1f * (float)(-Main.npc[num8].direction);
57083 Main.npc[num8].direction *= -1;
57084 Main.npc[num8].netUpdate = true;
57085 }
57086 if (num3 > 0 && NPC.CountNPCS(485) + NPC.CountNPCS(486) + NPC.CountNPCS(487) < 8 && genRand.Next(num3) == 0)
57087 {
57088 int type3 = 485;
57089 if (genRand.Next(4) == 0)
57090 {
57091 type3 = 486;
57092 }
57093 if (genRand.Next(12) == 0)
57094 {
57095 type3 = 487;
57096 }
57097 int num9 = NPC.NewNPC(GetNPCSource_TileBreak(i, j), i * 16 + 10, j * 16, type3);
57098 Main.npc[num9].TargetClosest();
57099 Main.npc[num9].velocity.Y = (float)genRand.Next(-50, -21) * 0.1f;
57100 Main.npc[num9].velocity.X = (float)genRand.Next(0, 26) * 0.1f * (float)(-Main.npc[num9].direction);
57101 Main.npc[num9].direction *= -1;
57102 Main.npc[num9].netUpdate = true;
57103 }
57104 if (num4 > 0 && NPC.CountNPCS(654) + NPC.CountNPCS(653) < 8 && genRand.Next(num4) == 0)
57105 {
57106 int type4 = 653;
57107 if (genRand.Next(2) == 0)
57108 {
57109 type4 = 654;
57110 }
57111 int num10 = NPC.NewNPC(GetNPCSource_TileBreak(i, j), i * 16 + 10, j * 16, type4);
57112 Main.npc[num10].TargetClosest();
57113 Main.npc[num10].velocity.Y = (float)genRand.Next(-50, -21) * 0.1f;
57114 Main.npc[num10].velocity.X = (float)genRand.Next(0, 26) * 0.1f * (float)(-Main.npc[num10].direction);
57115 Main.npc[num10].direction *= -1;
57116 Main.npc[num10].netUpdate = true;
57117 }
57118 }
57119
57120 public static void KillTile_PlaySounds(int i, int j, bool fail, Tile tileCache)
57121 {
57122 if (gen)
57123 {
57124 return;
57125 }
57126 int type = tileCache.type;
57127 if (type == 127 || type == 623)
57128 {
57129 SoundEngine.PlaySound(SoundID.Item27, i * 16, j * 16);
57130 }
57131 else if (type == 147 || type == 224)
57132 {
57133 if (genRand.Next(2) == 0)
57134 {
57135 SoundEngine.PlaySound(SoundID.Item48, i * 16, j * 16);
57136 }
57137 else
57138 {
57139 SoundEngine.PlaySound(SoundID.Item49, i * 16, j * 16);
57140 }
57141 }
57142 else if (type == 161 || type == 163 || type == 164 || type == 200 || type == 541)
57143 {
57144 SoundEngine.PlaySound(SoundID.Item50, i * 16, j * 16);
57145 }
57146 else if (type == 518 || type == 519 || type == 528 || type == 529 || type == 549 || type == 637 || type == 638 || type == 636)
57147 {
57148 SoundEngine.PlaySound(6, i * 16, j * 16);
57149 }
57150 else if (type == 530 && tileCache.frameX < 270)
57151 {
57152 SoundEngine.PlaySound(6, i * 16, j * 16);
57153 }
57154 else
57155 {
57156 switch (type)
57157 {
57158 case 3:
57159 case 110:
57160 SoundEngine.PlaySound(6, i * 16, j * 16);
57161 break;
57162 case 254:
57163 SoundEngine.PlaySound(6, i * 16, j * 16);
57164 break;
57165 case 24:
57166 SoundEngine.PlaySound(6, i * 16, j * 16);
57167 break;
57168 default:
57169 if (Main.tileAlch[type] || type == 384 || type == 227 || type == 32 || type == 51 || type == 52 || type == 61 || type == 62 || type == 69 || type == 655 || type == 71 || type == 73 || type == 74 || type == 113 || type == 115 || type == 184 || type == 192 || type == 205 || type == 233 || type == 352 || type == 382 || type == 624 || type == 656)
57170 {
57171 SoundEngine.PlaySound(6, i * 16, j * 16);
57172 break;
57173 }
57174 if (type == 485)
57175 {
57176 SoundEngine.PlaySound(4, i * 16, j * 16, 11);
57177 break;
57178 }
57179 if (type == 201)
57180 {
57181 SoundEngine.PlaySound(6, i * 16, j * 16);
57182 break;
57183 }
57184 if (type == 481 || type == 482 || type == 483)
57185 {
57186 SoundEngine.PlaySound(SoundID.Item127, i * 16, j * 16);
57187 break;
57188 }
57189 if (type == 1 || type == 6 || type == 7 || type == 8 || type == 9 || type == 22 || type == 140 || type == 25 || type == 37 || type == 38 || type == 39 || type == 41 || type == 43 || type == 44 || type == 45 || type == 46 || type == 47 || type == 48 || type == 56 || type == 58 || type == 63 || type == 64 || type == 65 || type == 66 || type == 67 || type == 68 || type == 75 || type == 76 || type == 107 || type == 108 || type == 111 || type == 117 || type == 118 || type == 119 || type == 120 || type == 121 || type == 122 || type == 150 || type == 151 || type == 152 || type == 153 || type == 154 || type == 155 || type == 156 || type == 160 || type == 161 || type == 166 || type == 167 || type == 168 || type == 169 || type == 175 || type == 176 || type == 177 || type == 203 || type == 202 || type == 204 || type == 206 || type == 211 || type == 221 || type == 222 || type == 223 || type == 226 || type == 248 || type == 249 || type == 250 || type == 272 || type == 273 || type == 274 || type == 478 || type == 284 || type == 325 || type == 346 || type == 347 || type == 348 || type == 350 || type == 367 || type == 357 || type == 368 || type == 369 || type == 370 || type == 407 || type == 472 || type == 473 || type == 500 || type == 501 || type == 502 || type == 503 || type == 546 || type == 557 || type == 566 || type == 618 || type == 408 || type == 409 || type == 669 || type == 670 || type == 671 || type == 672 || type == 673 || type == 674 || type == 675 || type == 676 || type == 677 || type == 678 || type == 679 || type == 680 || type == 681 || type == 682 || type == 683 || type == 684 || type == 685 || type == 686 || type == 687 || type == 689 || type == 688 || type == 690 || type == 691 || type == 692)
57190 {
57191 SoundEngine.PlaySound(21, i * 16, j * 16);
57192 break;
57193 }
57194 if (type == 666)
57195 {
57196 SoundEngine.PlaySound(SoundID.Item177, i * 16, j * 16);
57197 break;
57198 }
57199 if (type == 231 || type == 195 || type == 474)
57200 {
57201 SoundEngine.PlaySound(4, i * 16, j * 16);
57202 if (type == 231)
57203 {
57204 SoundEngine.PlaySound(SoundID.Item173, i * 16, j * 16);
57205 }
57206 break;
57207 }
57208 if (type == 26 && tileCache.frameX >= 54)
57209 {
57210 SoundEngine.PlaySound(4, i * 16, j * 16);
57211 break;
57212 }
57213 switch (type)
57214 {
57215 case 314:
57216 SoundEngine.PlaySound(SoundID.Item52, i * 16, j * 16);
57217 break;
57218 case 330:
57219 case 331:
57220 case 332:
57221 case 333:
57222 SoundEngine.PlaySound(18, i * 16, j * 16);
57223 break;
57224 default:
57225 if ((type == 162 || type == 385 || type == 129 || (type == 165 && tileCache.frameX < 54)) && !fail)
57226 {
57227 SoundEngine.PlaySound(SoundID.Item27, i * 16, j * 16);
57228 }
57229 else if (type != 138)
57230 {
57231 SoundEngine.PlaySound(0, i * 16, j * 16);
57232 }
57233 break;
57234 }
57235 break;
57236 }
57237 }
57238 if (!fail)
57239 {
57240 if (tileCache.type == 13)
57241 {
57242 SoundEngine.PlaySound(13, i * 16, j * 16);
57243 }
57244 else if (tileCache.type == 54)
57245 {
57246 SoundEngine.PlaySound(13, i * 16, j * 16);
57247 }
57248 else if (tileCache.type == 326)
57249 {
57250 SoundEngine.PlaySound(13, i * 16, j * 16);
57251 }
57252 else if (tileCache.type == 327)
57253 {
57254 SoundEngine.PlaySound(13, i * 16, j * 16);
57255 }
57256 else if (tileCache.type == 458)
57257 {
57258 SoundEngine.PlaySound(13, i * 16, j * 16);
57259 }
57260 else if (tileCache.type == 459)
57261 {
57262 SoundEngine.PlaySound(13, i * 16, j * 16);
57263 }
57264 else if (tileCache.type == 345)
57265 {
57266 SoundEngine.PlaySound(13, i * 16, j * 16);
57267 }
57268 else if (tileCache.type == 328)
57269 {
57270 SoundEngine.PlaySound(13, i * 16, j * 16);
57271 }
57272 else if (tileCache.type == 329)
57273 {
57274 SoundEngine.PlaySound(13, i * 16, j * 16);
57275 }
57276 else if (tileCache.type == 507)
57277 {
57278 SoundEngine.PlaySound(13, i * 16, j * 16);
57279 }
57280 else if (tileCache.type == 508)
57281 {
57282 SoundEngine.PlaySound(13, i * 16, j * 16);
57283 }
57284 }
57285 }
57286
57287 public static Rectangle? GetTileVisualHitbox(int x, int y)
57288 {
57289 Tile tile = Main.tile[x, y];
57290 if (tile == null || !tile.nactive())
57291 {
57292 return null;
57293 }
57294 Rectangle value = new Rectangle(x * 16, y * 16, 16, 16);
57295 ushort type = tile.type;
57296 if (type == 323)
57297 {
57298 value.X += tile.frameY;
57299 }
57300 if (tile.halfBrick())
57301 {
57302 value.Y += 8;
57303 value.Height = 8;
57304 }
57305 return value;
57306 }
57307
57308 public static int KillTile_GetTileDustAmount(bool fail, Tile tileCache)
57309 {
57310 switch (tileCache.type)
57311 {
57312 default:
57313 if (!fail)
57314 {
57315 return 10;
57316 }
57317 return 3;
57318 case 654:
57319 return 0;
57320 case 630:
57321 case 631:
57322 return 0;
57323 case 231:
57324 if (!fail)
57325 {
57326 return 6;
57327 }
57328 return 3;
57329 case 481:
57330 case 482:
57331 case 483:
57332 return 3;
57333 case 541:
57334 return 1;
57335 case 549:
57336 return 2;
57337 case 125:
57338 case 138:
57339 case 172:
57340 case 287:
57341 case 300:
57342 case 301:
57343 case 302:
57344 case 303:
57345 case 304:
57346 case 305:
57347 case 306:
57348 case 307:
57349 case 308:
57350 case 354:
57351 case 355:
57352 case 373:
57353 case 374:
57354 case 375:
57355 case 376:
57356 case 461:
57357 case 484:
57358 case 499:
57359 case 564:
57360 case 565:
57361 case 593:
57362 case 594:
57363 case 617:
57364 case 664:
57365 case 665:
57366 return 0;
57367 case 534:
57368 case 536:
57369 case 539:
57370 case 625:
57371 case 627:
57372 if (!fail)
57373 {
57374 return 5;
57375 }
57376 return 3;
57377 case 184:
57378 if (tileCache.frameX / 22 >= 5)
57379 {
57380 return 5;
57381 }
57382 if (!fail)
57383 {
57384 return 10;
57385 }
57386 return 3;
57387 }
57388 }
57389
57390 public static int KillTile_MakeTileDust(int i, int j, Tile tileCache)
57391 {
57392 int num = 0;
57393 if (tileCache.type == 216)
57394 {
57395 num = -1;
57396 }
57397 if (tileCache.type == 324)
57398 {
57399 num = ((tileCache.frameY != 0) ? (281 + tileCache.frameX / 18) : 280);
57400 }
57401 if (tileCache.type == 216)
57402 {
57403 num = -1;
57404 }
57405 if (tileCache.type == 335)
57406 {
57407 num = -1;
57408 }
57409 if (tileCache.type == 338)
57410 {
57411 num = -1;
57412 }
57413 if (tileCache.type == 0)
57414 {
57415 num = 0;
57416 }
57417 if (tileCache.type == 192)
57418 {
57419 num = 3;
57420 }
57421 if (tileCache.type == 208)
57422 {
57423 num = 126;
57424 }
57425 else if (tileCache.type == 408 || tileCache.type == 409)
57426 {
57427 num = 265;
57428 }
57429 else if (tileCache.type == 669)
57430 {
57431 num = 314;
57432 }
57433 else if (tileCache.type == 670)
57434 {
57435 num = 315;
57436 }
57437 else if (tileCache.type == 671)
57438 {
57439 num = 316;
57440 }
57441 else if (tileCache.type == 672)
57442 {
57443 num = 317;
57444 }
57445 else if (tileCache.type == 673)
57446 {
57447 num = 318;
57448 }
57449 else if (tileCache.type == 674)
57450 {
57451 num = 319;
57452 }
57453 else if (tileCache.type == 675)
57454 {
57455 num = 320;
57456 }
57457 else if (tileCache.type == 676)
57458 {
57459 num = 321;
57460 }
57461 if (tileCache.type == 16)
57462 {
57463 num = 1;
57464 if (tileCache.frameX >= 36)
57465 {
57466 num = 82;
57467 }
57468 }
57469 else if (tileCache.type == 415 || tileCache.type == 500)
57470 {
57471 num = 6;
57472 }
57473 else if (tileCache.type == 416 || tileCache.type == 501)
57474 {
57475 num = 61;
57476 }
57477 else if (tileCache.type == 417 || tileCache.type == 502)
57478 {
57479 num = 242;
57480 }
57481 else if (tileCache.type == 418 || tileCache.type == 503)
57482 {
57483 num = 135;
57484 }
57485 else if (tileCache.type == 474)
57486 {
57487 num = 18;
57488 }
57489 if (tileCache.type == 1 || tileCache.type == 17 || tileCache.type == 38 || tileCache.type == 39 || tileCache.type == 41 || tileCache.type == 43 || tileCache.type == 44 || tileCache.type == 481 || tileCache.type == 482 || tileCache.type == 483 || tileCache.type == 48 || Main.tileStone[tileCache.type] || tileCache.type == 85 || tileCache.type == 90 || tileCache.type == 92 || tileCache.type == 96 || tileCache.type == 97 || tileCache.type == 99 || tileCache.type == 117 || tileCache.type == 130 || tileCache.type == 131 || tileCache.type == 132 || tileCache.type == 135 || tileCache.type == 135 || tileCache.type == 142 || tileCache.type == 143 || tileCache.type == 144 || tileCache.type == 210 || tileCache.type == 207 || tileCache.type == 235 || tileCache.type == 247 || tileCache.type == 272 || tileCache.type == 273 || tileCache.type == 283 || tileCache.type == 410 || tileCache.type == 480 || tileCache.type == 509 || tileCache.type == 618 || tileCache.type == 657 || tileCache.type == 658 || tileCache.type == 677 || tileCache.type == 678 || tileCache.type == 679)
57490 {
57491 num = 1;
57492 }
57493 if (tileCache.type == 379)
57494 {
57495 num = 257;
57496 }
57497 if (tileCache.type == 311)
57498 {
57499 num = 207;
57500 }
57501 if (tileCache.type == 312)
57502 {
57503 num = 208;
57504 }
57505 if (tileCache.type == 313)
57506 {
57507 num = 209;
57508 }
57509 if (tileCache.type == 104)
57510 {
57511 num = -1;
57512 }
57513 if (tileCache.type == 95 || tileCache.type == 98 || tileCache.type == 100 || tileCache.type == 174 || tileCache.type == 173)
57514 {
57515 num = 6;
57516 }
57517 if (tileCache.type == 30 || tileCache.type == 86 || tileCache.type == 94 || tileCache.type == 106 || tileCache.type == 114 || tileCache.type == 124 || tileCache.type == 128 || tileCache.type == 269)
57518 {
57519 num = 7;
57520 }
57521 if (tileCache.type == 372)
57522 {
57523 num = 242;
57524 }
57525 if (tileCache.type == 646)
57526 {
57527 num = 29;
57528 }
57529 if (tileCache.type == 49)
57530 {
57531 num = 29;
57532 }
57533 if (tileCache.type == 371)
57534 {
57535 num = 243;
57536 }
57537 if (tileCache.type == 334)
57538 {
57539 num = 7;
57540 }
57541 switch (tileCache.type)
57542 {
57543 case 10:
57544 case 11:
57545 case 87:
57546 case 89:
57547 case 93:
57548 case 139:
57549 case 209:
57550 case 319:
57551 case 320:
57552 case 386:
57553 case 387:
57554 case 390:
57555 case 405:
57556 case 406:
57557 case 411:
57558 case 412:
57559 case 419:
57560 case 420:
57561 case 421:
57562 case 422:
57563 case 423:
57564 case 424:
57565 case 425:
57566 case 428:
57567 case 429:
57568 case 441:
57569 case 442:
57570 case 445:
57571 case 446:
57572 case 447:
57573 case 448:
57574 case 449:
57575 case 450:
57576 case 451:
57577 case 452:
57578 case 453:
57579 case 455:
57580 case 456:
57581 case 457:
57582 case 462:
57583 case 463:
57584 case 464:
57585 case 465:
57586 case 466:
57587 case 468:
57588 case 476:
57589 case 486:
57590 case 487:
57591 case 489:
57592 case 490:
57593 case 491:
57594 case 493:
57595 case 494:
57596 case 497:
57597 case 510:
57598 case 511:
57599 case 520:
57600 case 521:
57601 case 522:
57602 case 523:
57603 case 524:
57604 case 525:
57605 case 526:
57606 case 527:
57607 case 531:
57608 case 545:
57609 case 547:
57610 case 548:
57611 case 560:
57612 case 564:
57613 case 565:
57614 case 567:
57615 case 572:
57616 case 579:
57617 case 591:
57618 case 592:
57619 case 593:
57620 case 594:
57621 case 613:
57622 case 614:
57623 case 621:
57624 case 622:
57625 case 623:
57626 case 624:
57627 case 630:
57628 case 631:
57629 case 656:
57630 num = -1;
57631 break;
57632 case 668:
57633 num = 0;
57634 break;
57635 case 407:
57636 num = 10;
57637 break;
57638 case 454:
57639 num = 139;
57640 break;
57641 case 41:
57642 case 481:
57643 case 677:
57644 num = 275;
57645 break;
57646 case 43:
57647 case 482:
57648 case 678:
57649 num = 276;
57650 break;
57651 case 44:
57652 case 483:
57653 case 679:
57654 num = 277;
57655 break;
57656 case 473:
57657 num = 82;
57658 break;
57659 case 472:
57660 case 546:
57661 case 557:
57662 num = 8;
57663 break;
57664 case 498:
57665 num = 30;
57666 break;
57667 case 517:
57668 case 687:
57669 num = 258;
57670 break;
57671 case 535:
57672 case 689:
57673 num = 299;
57674 break;
57675 case 537:
57676 case 690:
57677 num = 300;
57678 break;
57679 case 540:
57680 case 688:
57681 num = 301;
57682 break;
57683 case 626:
57684 case 691:
57685 num = 305;
57686 break;
57687 case 184:
57688 {
57689 int num2 = tileCache.frameX / 22;
57690 num = num2 switch
57691 {
57692 5 => 258,
57693 6 => 299,
57694 7 => 300,
57695 8 => 301,
57696 9 => 305,
57697 10 => 267,
57698 _ => 93 + num2,
57699 };
57700 break;
57701 }
57702 case 515:
57703 num = 96;
57704 break;
57705 case 516:
57706 num = 97;
57707 break;
57708 case 514:
57709 num = 95;
57710 break;
57711 case 513:
57712 num = 94;
57713 break;
57714 case 512:
57715 num = 93;
57716 break;
57717 case 541:
57718 num = 226;
57719 break;
57720 case 590:
57721 num = 1;
57722 break;
57723 case 583:
57724 num = ((genRand.Next(10) != 0) ? 1 : 87);
57725 break;
57726 case 584:
57727 num = ((genRand.Next(10) != 0) ? 1 : 86);
57728 break;
57729 case 585:
57730 num = ((genRand.Next(10) != 0) ? 1 : 88);
57731 break;
57732 case 586:
57733 num = ((genRand.Next(10) != 0) ? 1 : 89);
57734 break;
57735 case 587:
57736 num = ((genRand.Next(10) != 0) ? 1 : 90);
57737 break;
57738 case 588:
57739 num = ((genRand.Next(10) != 0) ? 1 : 91);
57740 break;
57741 case 589:
57742 num = ((genRand.Next(10) != 0) ? 1 : 138);
57743 break;
57744 case 595:
57745 num = 78;
57746 break;
57747 case 596:
57748 num = 78;
57749 break;
57750 case 615:
57751 num = 78;
57752 break;
57753 case 616:
57754 num = 78;
57755 break;
57756 case 633:
57757 num = ((genRand.Next(6) != 0) ? 237 : 36);
57758 break;
57759 case 637:
57760 case 638:
57761 num = 237;
57762 break;
57763 case 634:
57764 num = ((genRand.Next(10) != 0) ? 36 : 31);
57765 if (genRand.Next(12) == 0)
57766 {
57767 num = 6;
57768 }
57769 break;
57770 }
57771 if (Main.tileMoss[tileCache.type])
57772 {
57773 num = ((tileCache.type == 381) ? 258 : ((tileCache.type == 534) ? 299 : ((tileCache.type == 536) ? 300 : ((tileCache.type == 539) ? 301 : ((tileCache.type == 625) ? 305 : ((tileCache.type != 627) ? (tileCache.type - 179 + 93) : 267))))));
57774 }
57775 if (tileCache.type == 240)
57776 {
57777 int num3 = tileCache.frameX / 54;
57778 if (tileCache.frameY >= 54)
57779 {
57780 num3 += 36 * (tileCache.frameY / 54);
57781 }
57782 num = 7;
57783 if (num3 == 16 || num3 == 17)
57784 {
57785 num = 26;
57786 }
57787 if (num3 >= 46 && num3 <= 49)
57788 {
57789 num = -1;
57790 }
57791 }
57792 if (tileCache.type == 241)
57793 {
57794 num = 1;
57795 }
57796 if (tileCache.type == 242)
57797 {
57798 num = -1;
57799 }
57800 if (tileCache.type == 529)
57801 {
57802 num = Main.tile[i, j + 1].type switch
57803 {
57804 116 => num = 47,
57805 234 => num = 125,
57806 112 => num = 17,
57807 _ => (i >= beachDistance && i <= Main.maxTilesX - beachDistance) ? 289 : 290,
57808 };
57809 }
57810 if (tileCache.type == 356)
57811 {
57812 num = -1;
57813 }
57814 if (tileCache.type == 663)
57815 {
57816 num = -1;
57817 }
57818 if (tileCache.type == 351)
57819 {
57820 num = -1;
57821 }
57822 if (tileCache.type == 246)
57823 {
57824 num = -1;
57825 }
57826 if (tileCache.type == 36)
57827 {
57828 num = -1;
57829 }
57830 if (tileCache.type == 365)
57831 {
57832 num = 239;
57833 }
57834 if (tileCache.type == 366)
57835 {
57836 num = 30;
57837 }
57838 if (tileCache.type == 504)
57839 {
57840 num = -1;
57841 }
57842 if (tileCache.type == 357 || tileCache.type == 367 || tileCache.type == 561)
57843 {
57844 num = 236;
57845 }
57846 if (tileCache.type == 368 || tileCache.type == 369 || tileCache.type == 576)
57847 {
57848 num = 240;
57849 }
57850 if (tileCache.type == 170)
57851 {
57852 num = 196;
57853 }
57854 if (tileCache.type == 315)
57855 {
57856 num = 225;
57857 }
57858 if (tileCache.type == 641)
57859 {
57860 num = ((genRand.Next(2) != 0) ? 161 : 243);
57861 }
57862 if (tileCache.type == 659)
57863 {
57864 num = 308;
57865 }
57866 if (tileCache.type == 667)
57867 {
57868 num = 308;
57869 }
57870 if (tileCache.type == 346)
57871 {
57872 num = 128;
57873 }
57874 if (tileCache.type == 347)
57875 {
57876 num = 117;
57877 }
57878 if (tileCache.type == 348)
57879 {
57880 num = 42;
57881 }
57882 if (tileCache.type == 350)
57883 {
57884 num = 226;
57885 }
57886 if (tileCache.type == 370)
57887 {
57888 num = ((genRand.Next(2) != 0) ? 23 : 6);
57889 }
57890 if (tileCache.type == 171)
57891 {
57892 num = ((genRand.Next(2) != 0) ? (-1) : 196);
57893 }
57894 if (tileCache.type == 326)
57895 {
57896 num = 13;
57897 }
57898 if (tileCache.type == 327)
57899 {
57900 num = 13;
57901 }
57902 if (tileCache.type == 345)
57903 {
57904 num = 13;
57905 }
57906 if (tileCache.type == 458)
57907 {
57908 num = 13;
57909 }
57910 if (tileCache.type == 459)
57911 {
57912 num = 13;
57913 }
57914 if (tileCache.type == 336)
57915 {
57916 num = 6;
57917 }
57918 if (tileCache.type == 340)
57919 {
57920 num = 75;
57921 }
57922 if (tileCache.type == 341)
57923 {
57924 num = 65;
57925 }
57926 if (tileCache.type == 342)
57927 {
57928 num = 135;
57929 }
57930 if (tileCache.type == 343)
57931 {
57932 num = 169;
57933 }
57934 if (tileCache.type == 344)
57935 {
57936 num = 156;
57937 }
57938 if (tileCache.type == 328)
57939 {
57940 num = 13;
57941 }
57942 if (tileCache.type == 329)
57943 {
57944 num = 13;
57945 }
57946 if (tileCache.type == 507)
57947 {
57948 num = 13;
57949 }
57950 if (tileCache.type == 508)
57951 {
57952 num = 13;
57953 }
57954 if (tileCache.type == 562)
57955 {
57956 num = -1;
57957 }
57958 if (tileCache.type == 571)
57959 {
57960 num = 40;
57961 }
57962 if (tileCache.type == 563)
57963 {
57964 num = -1;
57965 }
57966 if (tileCache.type == 330)
57967 {
57968 num = 9;
57969 }
57970 if (tileCache.type == 331)
57971 {
57972 num = 11;
57973 }
57974 if (tileCache.type == 332)
57975 {
57976 num = 19;
57977 }
57978 if (tileCache.type == 333)
57979 {
57980 num = 11;
57981 }
57982 if (tileCache.type == 101)
57983 {
57984 num = -1;
57985 }
57986 if (tileCache.type == 19)
57987 {
57988 num = (tileCache.frameY / 18) switch
57989 {
57990 0 => 7,
57991 1 => 77,
57992 2 => 78,
57993 3 => 79,
57994 4 => 26,
57995 5 => 126,
57996 6 => 275,
57997 7 => 277,
57998 8 => 276,
57999 9 => 1,
58000 10 => 214,
58001 11 => 214,
58002 12 => 214,
58003 13 => 109,
58004 14 => 13,
58005 15 => 189,
58006 16 => 191,
58007 17 => 215,
58008 18 => 26,
58009 19 => 214,
58010 20 => 4,
58011 21 => 10,
58012 22 => 32,
58013 23 => 78,
58014 24 => 147,
58015 25 => 40,
58016 26 => 226,
58017 27 => 23,
58018 28 => 240,
58019 29 => 236,
58020 30 => 68 + Main.rand.Next(3),
58021 31 => 10,
58022 32 => 78,
58023 33 => 148,
58024 34 => 5,
58025 35 => 80,
58026 37 => 18,
58027 38 => 6,
58028 39 => 61,
58029 40 => 242,
58030 41 => 135,
58031 42 => 287,
58032 44 => 273,
58033 45 => 243,
58034 46 => 243,
58035 47 => 36,
58036 48 => 226,
58037 _ => 1,
58038 };
58039 }
58040 if (tileCache.type == 79)
58041 {
58042 int num4 = tileCache.frameY / 36;
58043 num = ((num4 == 0) ? 7 : ((num4 == 1) ? 77 : ((num4 == 2) ? 78 : ((num4 == 3) ? 79 : ((num4 == 4) ? 126 : ((num4 == 8) ? 109 : ((num4 < 9) ? 1 : (-1))))))));
58044 }
58045 if (tileCache.type == 18)
58046 {
58047 switch (tileCache.frameX / 36)
58048 {
58049 case 0:
58050 num = 7;
58051 break;
58052 case 1:
58053 num = 77;
58054 break;
58055 case 2:
58056 num = 78;
58057 break;
58058 case 3:
58059 num = 79;
58060 break;
58061 case 4:
58062 num = 26;
58063 break;
58064 case 5:
58065 num = 40;
58066 break;
58067 case 6:
58068 num = 5;
58069 break;
58070 case 7:
58071 num = 26;
58072 break;
58073 case 8:
58074 num = 4;
58075 break;
58076 case 9:
58077 num = 126;
58078 break;
58079 case 10:
58080 num = 148;
58081 break;
58082 case 11:
58083 case 12:
58084 case 13:
58085 num = 1;
58086 break;
58087 case 14:
58088 num = 109;
58089 break;
58090 case 15:
58091 num = 126;
58092 break;
58093 default:
58094 num = -1;
58095 break;
58096 }
58097 }
58098 if (tileCache.type == 14 || tileCache.type == 87 || tileCache.type == 88 || tileCache.type == 469)
58099 {
58100 num = -1;
58101 }
58102 if (tileCache.type >= 255 && tileCache.type <= 261)
58103 {
58104 int num5 = tileCache.type - 255;
58105 num = 86 + num5;
58106 if (num5 == 6)
58107 {
58108 num = 138;
58109 }
58110 }
58111 if (tileCache.type >= 262 && tileCache.type <= 268)
58112 {
58113 int num6 = tileCache.type - 262;
58114 num = 86 + num6;
58115 if (num6 == 6)
58116 {
58117 num = 138;
58118 }
58119 }
58120 if (tileCache.type == 178)
58121 {
58122 int num7 = tileCache.frameX / 18;
58123 num = 86 + num7;
58124 if (num7 == 6)
58125 {
58126 num = 138;
58127 }
58128 }
58129 if (tileCache.type == 440)
58130 {
58131 num = (tileCache.frameX / 54) switch
58132 {
58133 0 => 90,
58134 1 => 88,
58135 2 => 89,
58136 3 => 87,
58137 4 => 86,
58138 5 => 91,
58139 6 => 138,
58140 _ => -1,
58141 };
58142 if (tileCache.frameY < 54)
58143 {
58144 num = -1;
58145 }
58146 }
58147 switch (tileCache.type)
58148 {
58149 case 426:
58150 case 427:
58151 num = 90;
58152 break;
58153 case 430:
58154 case 435:
58155 num = 89;
58156 break;
58157 case 431:
58158 case 436:
58159 num = 88;
58160 break;
58161 case 432:
58162 case 437:
58163 num = 87;
58164 break;
58165 case 433:
58166 case 438:
58167 num = 86;
58168 break;
58169 case 434:
58170 case 439:
58171 num = 91;
58172 break;
58173 case 496:
58174 num = 109;
58175 break;
58176 case 549:
58177 num = 3;
58178 break;
58179 case 552:
58180 num = 32;
58181 break;
58182 }
58183 if (tileCache.type == 186)
58184 {
58185 num = ((tileCache.frameX <= 360) ? 26 : ((tileCache.frameX <= 846) ? 1 : ((tileCache.frameX <= 954) ? 9 : ((tileCache.frameX <= 1062) ? 11 : ((tileCache.frameX <= 1170) ? 10 : ((tileCache.frameX > 1332) ? ((tileCache.frameX > 1386) ? 80 : 10) : 0))))));
58186 }
58187 if (tileCache.type == 187)
58188 {
58189 if (tileCache.frameX <= 144)
58190 {
58191 num = 1;
58192 }
58193 else if (tileCache.frameX <= 306)
58194 {
58195 num = 38;
58196 }
58197 else if (tileCache.frameX <= 468)
58198 {
58199 num = 36;
58200 }
58201 else if (tileCache.frameX <= 738)
58202 {
58203 num = 30;
58204 }
58205 else if (tileCache.frameX <= 970)
58206 {
58207 num = 1;
58208 }
58209 else if (tileCache.frameX <= 1132)
58210 {
58211 num = 148;
58212 }
58213 else if (tileCache.frameX <= 1132)
58214 {
58215 num = 155;
58216 }
58217 else if (tileCache.frameX <= 1348)
58218 {
58219 num = 1;
58220 }
58221 else if (tileCache.frameX <= 1564)
58222 {
58223 num = 0;
58224 }
58225 else if (tileCache.frameX <= 1890)
58226 {
58227 num = 250;
58228 }
58229 else if (tileCache.frameX <= 2196)
58230 {
58231 num = 240;
58232 }
58233 else if (tileCache.frameX <= 2520)
58234 {
58235 num = 236;
58236 }
58237 }
58238 if (tileCache.type == 647)
58239 {
58240 int num8 = tileCache.frameX / 54;
58241 if (num8 < 7)
58242 {
58243 num = 26;
58244 }
58245 else if (num8 < 16)
58246 {
58247 num = 1;
58248 }
58249 else if (num8 < 18)
58250 {
58251 num = 9;
58252 }
58253 else if (num8 < 20)
58254 {
58255 num = 11;
58256 }
58257 else if (num8 < 22)
58258 {
58259 num = 10;
58260 }
58261 else if (num8 < 26)
58262 {
58263 num = 7;
58264 }
58265 else if (num8 < 32)
58266 {
58267 num = 80;
58268 }
58269 else if (num8 < 35)
58270 {
58271 num = 80;
58272 }
58273 }
58274 if (tileCache.type == 648)
58275 {
58276 int num9 = tileCache.frameX / 54;
58277 num9 += tileCache.frameY / 36 * 35;
58278 if (num9 < 3)
58279 {
58280 num = 1;
58281 }
58282 else if (num9 < 6)
58283 {
58284 num = 38;
58285 }
58286 else if (num9 < 9)
58287 {
58288 num = 36;
58289 }
58290 else if (num9 < 14)
58291 {
58292 num = 30;
58293 }
58294 else if (num9 < 17)
58295 {
58296 num = 1;
58297 }
58298 else if (num9 < 18)
58299 {
58300 num = 1;
58301 }
58302 else if (num9 < 21)
58303 {
58304 num = 148;
58305 }
58306 else if (num9 < 29)
58307 {
58308 num = 155;
58309 }
58310 else if (num9 < 35)
58311 {
58312 num = 287;
58313 }
58314 else if (num9 < 41)
58315 {
58316 num = 240;
58317 }
58318 else if (num9 < 47)
58319 {
58320 num = 236;
58321 }
58322 else if (num9 < 50)
58323 {
58324 num = 0;
58325 }
58326 else if (num9 < 52)
58327 {
58328 num = 2;
58329 }
58330 else if (num9 < 55)
58331 {
58332 num = 26;
58333 }
58334 }
58335 if (tileCache.type == 105)
58336 {
58337 num = 1;
58338 if (tileCache.frameX >= 1548 && tileCache.frameX <= 1654 && tileCache.frameY < 54)
58339 {
58340 num = 148;
58341 }
58342 }
58343 if (tileCache.type == 349)
58344 {
58345 num = 1;
58346 }
58347 if (tileCache.type == 337 || tileCache.type == 506)
58348 {
58349 num = 1;
58350 }
58351 if (tileCache.type == 239)
58352 {
58353 int num10 = tileCache.frameX / 18;
58354 if (num10 == 0)
58355 {
58356 num = 9;
58357 }
58358 if (num10 == 1)
58359 {
58360 num = 81;
58361 }
58362 if (num10 == 2)
58363 {
58364 num = 8;
58365 }
58366 if (num10 == 3)
58367 {
58368 num = 82;
58369 }
58370 if (num10 == 4)
58371 {
58372 num = 11;
58373 }
58374 if (num10 == 5)
58375 {
58376 num = 83;
58377 }
58378 if (num10 == 6)
58379 {
58380 num = 10;
58381 }
58382 if (num10 == 7)
58383 {
58384 num = 84;
58385 }
58386 if (num10 == 8)
58387 {
58388 num = 14;
58389 }
58390 if (num10 == 9)
58391 {
58392 num = 23;
58393 }
58394 if (num10 == 10)
58395 {
58396 num = 25;
58397 }
58398 if (num10 == 11)
58399 {
58400 num = 48;
58401 }
58402 if (num10 == 12)
58403 {
58404 num = 144;
58405 }
58406 if (num10 == 13)
58407 {
58408 num = 49;
58409 }
58410 if (num10 == 14)
58411 {
58412 num = 145;
58413 }
58414 if (num10 == 15)
58415 {
58416 num = 50;
58417 }
58418 if (num10 == 16)
58419 {
58420 num = 146;
58421 }
58422 if (num10 == 17)
58423 {
58424 num = 128;
58425 }
58426 if (num10 == 18)
58427 {
58428 num = 84;
58429 }
58430 if (num10 == 19)
58431 {
58432 num = 117;
58433 }
58434 if (num10 == 20)
58435 {
58436 num = 42;
58437 }
58438 if (num10 == 21)
58439 {
58440 num = -1;
58441 }
58442 if (num10 == 22)
58443 {
58444 num = 265;
58445 }
58446 }
58447 if (tileCache.type == 185)
58448 {
58449 if (tileCache.frameY == 18)
58450 {
58451 int num11 = tileCache.frameX / 36;
58452 if (num11 < 6)
58453 {
58454 num = 1;
58455 }
58456 else if (num11 < 16)
58457 {
58458 num = 26;
58459 }
58460 else if (num11 == 16)
58461 {
58462 num = 9;
58463 }
58464 else if (num11 == 17)
58465 {
58466 num = 11;
58467 }
58468 else if (num11 == 18)
58469 {
58470 num = 10;
58471 }
58472 else if (num11 == 19)
58473 {
58474 num = 86;
58475 }
58476 else if (num11 == 20)
58477 {
58478 num = 87;
58479 }
58480 else if (num11 == 21)
58481 {
58482 num = 88;
58483 }
58484 else if (num11 == 22)
58485 {
58486 num = 89;
58487 }
58488 else if (num11 == 23)
58489 {
58490 num = 90;
58491 }
58492 else if (num11 == 24)
58493 {
58494 num = 91;
58495 }
58496 else if (num11 < 31)
58497 {
58498 num = 80;
58499 }
58500 else if (num11 < 33)
58501 {
58502 num = 7;
58503 }
58504 else if (num11 < 34)
58505 {
58506 num = 8;
58507 }
58508 else if (num11 < 38)
58509 {
58510 num = 30;
58511 }
58512 else if (num11 < 41)
58513 {
58514 num = 1;
58515 }
58516 else if (num11 < 47)
58517 {
58518 num = 287;
58519 }
58520 else if (num11 < 53)
58521 {
58522 num = 240;
58523 }
58524 else if (num11 < 59)
58525 {
58526 num = 236;
58527 }
58528 }
58529 else
58530 {
58531 int num12 = tileCache.frameX / 18;
58532 if (num12 < 6)
58533 {
58534 num = 1;
58535 }
58536 else if (num12 < 12)
58537 {
58538 num = 0;
58539 }
58540 else if (num12 < 28)
58541 {
58542 num = 26;
58543 }
58544 else if (num12 < 33)
58545 {
58546 num = 1;
58547 }
58548 else if (num12 < 36)
58549 {
58550 num = 0;
58551 }
58552 else if (num12 < 48)
58553 {
58554 num = 80;
58555 }
58556 else if (num12 < 54)
58557 {
58558 num = 30;
58559 }
58560 else if (num12 < 60)
58561 {
58562 num = 287;
58563 }
58564 else if (num12 < 66)
58565 {
58566 num = 240;
58567 }
58568 else if (num12 < 72)
58569 {
58570 num = 236;
58571 }
58572 else if (num12 < 73)
58573 {
58574 num = 0;
58575 }
58576 else if (num12 < 77)
58577 {
58578 num = 32;
58579 }
58580 }
58581 }
58582 if (tileCache.type == 649)
58583 {
58584 int num13 = tileCache.frameX / 36 + tileCache.frameY / 18 * 53;
58585 if (num13 < 6)
58586 {
58587 num = 1;
58588 }
58589 else if (num13 < 16)
58590 {
58591 num = 26;
58592 }
58593 else if (num13 == 16)
58594 {
58595 num = 9;
58596 }
58597 else if (num13 == 17)
58598 {
58599 num = 11;
58600 }
58601 else if (num13 == 18)
58602 {
58603 num = 10;
58604 }
58605 else if (num13 == 19)
58606 {
58607 num = 86;
58608 }
58609 else if (num13 == 20)
58610 {
58611 num = 87;
58612 }
58613 else if (num13 == 21)
58614 {
58615 num = 88;
58616 }
58617 else if (num13 == 22)
58618 {
58619 num = 89;
58620 }
58621 else if (num13 == 23)
58622 {
58623 num = 90;
58624 }
58625 else if (num13 == 24)
58626 {
58627 num = 91;
58628 }
58629 else if (num13 < 31)
58630 {
58631 num = 80;
58632 }
58633 else if (num13 < 33)
58634 {
58635 num = 7;
58636 }
58637 else if (num13 < 34)
58638 {
58639 num = 8;
58640 }
58641 else if (num13 < 38)
58642 {
58643 num = 30;
58644 }
58645 else if (num13 < 41)
58646 {
58647 num = 1;
58648 }
58649 else if (num13 < 47)
58650 {
58651 num = 287;
58652 }
58653 else if (num13 < 53)
58654 {
58655 num = 240;
58656 }
58657 else if (num13 < 59)
58658 {
58659 num = 236;
58660 }
58661 else if (num13 < 62)
58662 {
58663 num = 0;
58664 }
58665 else if (num13 < 65)
58666 {
58667 num = 32;
58668 }
58669 }
58670 if (tileCache.type == 650)
58671 {
58672 int num14 = tileCache.frameX / 18;
58673 if (num14 < 6)
58674 {
58675 num = 1;
58676 }
58677 else if (num14 < 12)
58678 {
58679 num = 0;
58680 }
58681 else if (num14 < 28)
58682 {
58683 num = 26;
58684 }
58685 else if (num14 < 33)
58686 {
58687 num = 1;
58688 }
58689 else if (num14 < 36)
58690 {
58691 num = 0;
58692 }
58693 else if (num14 < 48)
58694 {
58695 num = 80;
58696 }
58697 else if (num14 < 54)
58698 {
58699 num = 30;
58700 }
58701 else if (num14 < 60)
58702 {
58703 num = 287;
58704 }
58705 else if (num14 < 66)
58706 {
58707 num = 240;
58708 }
58709 else if (num14 < 72)
58710 {
58711 num = 236;
58712 }
58713 else if (num14 < 73)
58714 {
58715 num = 0;
58716 }
58717 else if (num14 < 77)
58718 {
58719 num = 32;
58720 }
58721 }
58722 if (tileCache.type == 237)
58723 {
58724 num = 148;
58725 }
58726 if (tileCache.type == 157)
58727 {
58728 num = 77;
58729 }
58730 if (tileCache.type == 158 || tileCache.type == 232 || tileCache.type == 383 || tileCache.type == 575)
58731 {
58732 num = 78;
58733 }
58734 if (tileCache.type == 159)
58735 {
58736 num = 78;
58737 }
58738 if (tileCache.type == 15)
58739 {
58740 num = -1;
58741 }
58742 if (tileCache.type == 191)
58743 {
58744 num = 7;
58745 }
58746 if (tileCache.type == 5)
58747 {
58748 num = 7;
58749 if (i > 5 && i < Main.maxTilesX - 5)
58750 {
58751 int num15 = i;
58752 int k = j;
58753 if (tileCache.frameX == 66 && tileCache.frameY <= 45)
58754 {
58755 num15++;
58756 }
58757 if (tileCache.frameX == 88 && tileCache.frameY >= 66 && tileCache.frameY <= 110)
58758 {
58759 num15--;
58760 }
58761 if (tileCache.frameX == 22 && tileCache.frameY >= 132 && tileCache.frameY <= 176)
58762 {
58763 num15--;
58764 }
58765 if (tileCache.frameX == 44 && tileCache.frameY >= 132 && tileCache.frameY <= 176)
58766 {
58767 num15++;
58768 }
58769 if (tileCache.frameX == 44 && tileCache.frameY >= 132 && tileCache.frameY <= 176)
58770 {
58771 num15++;
58772 }
58773 if (tileCache.frameX == 44 && tileCache.frameY >= 198)
58774 {
58775 num15++;
58776 }
58777 if (tileCache.frameX == 66 && tileCache.frameY >= 198)
58778 {
58779 num15--;
58780 }
58781 for (; Main.tile[num15, k] != null && (!Main.tile[num15, k].active() || !Main.tileSolid[Main.tile[num15, k].type]); k++)
58782 {
58783 }
58784 if (Main.tile[num15, k] != null)
58785 {
58786 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 23)
58787 {
58788 num = 77;
58789 }
58790 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 661)
58791 {
58792 num = 77;
58793 }
58794 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 60)
58795 {
58796 num = 78;
58797 }
58798 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 70)
58799 {
58800 num = 26;
58801 }
58802 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 109)
58803 {
58804 num = 79;
58805 }
58806 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 199)
58807 {
58808 num = 121;
58809 }
58810 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 662)
58811 {
58812 num = 121;
58813 }
58814 if (Main.tile[num15, k].active() && Main.tile[num15, k].type == 147)
58815 {
58816 num = 122;
58817 }
58818 }
58819 }
58820 }
58821 if (tileCache.type == 323)
58822 {
58823 num = 215;
58824 if (i > 5 && i < Main.maxTilesX - 5)
58825 {
58826 int l;
58827 for (l = j; Main.tile[i, l] != null && (!Main.tile[i, l].active() || !Main.tileSolid[Main.tile[i, l].type]); l++)
58828 {
58829 }
58830 if (Main.tile[i, l] != null)
58831 {
58832 if (Main.tile[i, l].active() && Main.tile[i, l].type == 234)
58833 {
58834 num = 121;
58835 }
58836 if (Main.tile[i, l].active() && Main.tile[i, l].type == 116)
58837 {
58838 num = 79;
58839 }
58840 if (Main.tile[i, l].active() && Main.tile[i, l].type == 112)
58841 {
58842 num = 77;
58843 }
58844 }
58845 }
58846 }
58847 if (tileCache.type == 137)
58848 {
58849 switch (tileCache.frameY / 18)
58850 {
58851 default:
58852 num = 1;
58853 break;
58854 case 1:
58855 case 2:
58856 case 3:
58857 case 4:
58858 num = 148;
58859 break;
58860 case 5:
58861 num = 1;
58862 break;
58863 }
58864 }
58865 if (tileCache.type == 443)
58866 {
58867 num = 1;
58868 }
58869 if (tileCache.type == 444)
58870 {
58871 num = -1;
58872 }
58873 if (tileCache.type == 212)
58874 {
58875 num = -1;
58876 }
58877 if (tileCache.type == 213)
58878 {
58879 num = 129;
58880 }
58881 if (tileCache.type == 214)
58882 {
58883 num = 1;
58884 }
58885 if (tileCache.type == 215)
58886 {
58887 num = -6;
58888 }
58889 if (tileCache.type == 325)
58890 {
58891 num = 81;
58892 }
58893 if (tileCache.type == 251)
58894 {
58895 num = 189;
58896 }
58897 if (tileCache.type == 252)
58898 {
58899 num = 190;
58900 }
58901 if (tileCache.type == 253)
58902 {
58903 num = 191;
58904 }
58905 if (tileCache.type == 254)
58906 {
58907 if (tileCache.frameX < 72)
58908 {
58909 num = 3;
58910 }
58911 else if (tileCache.frameX < 108)
58912 {
58913 num = 3;
58914 if (genRand.Next(3) == 0)
58915 {
58916 num = 189;
58917 }
58918 }
58919 else if (tileCache.frameX < 144)
58920 {
58921 num = 3;
58922 if (genRand.Next(2) == 0)
58923 {
58924 num = 189;
58925 }
58926 }
58927 else
58928 {
58929 num = 3;
58930 if (genRand.Next(4) != 0)
58931 {
58932 num = 189;
58933 }
58934 }
58935 }
58936 if (tileCache.type == 467)
58937 {
58938 num = -1;
58939 }
58940 if (tileCache.type == 21)
58941 {
58942 num = ((tileCache.frameX >= 1008) ? (-1) : ((tileCache.frameX >= 612) ? 11 : ((tileCache.frameX >= 576) ? 148 : ((tileCache.frameX >= 540) ? 26 : ((tileCache.frameX >= 504) ? 126 : ((tileCache.frameX >= 468) ? 116 : ((tileCache.frameX >= 432) ? 7 : ((tileCache.frameX >= 396) ? 11 : ((tileCache.frameX >= 360) ? 10 : ((tileCache.frameX >= 324) ? 79 : ((tileCache.frameX >= 288) ? 78 : ((tileCache.frameX >= 252) ? 77 : ((tileCache.frameX >= 216) ? 1 : ((tileCache.frameX >= 180) ? 7 : ((tileCache.frameX >= 108) ? 37 : ((tileCache.frameX < 36) ? 7 : 10))))))))))))))));
58943 }
58944 if (tileCache.type == 382)
58945 {
58946 num = 3;
58947 }
58948 if (tileCache.type == 2 || tileCache.type == 477)
58949 {
58950 num = ((genRand.Next(2) != 0) ? 2 : 0);
58951 }
58952 if (tileCache.type == 127)
58953 {
58954 num = 67;
58955 }
58956 if (tileCache.type == 91)
58957 {
58958 num = -1;
58959 }
58960 if (tileCache.type == 198)
58961 {
58962 num = 109;
58963 }
58964 if (tileCache.type == 26)
58965 {
58966 num = ((tileCache.frameX < 54) ? 8 : 5);
58967 }
58968 if (tileCache.type == 34)
58969 {
58970 num = -1;
58971 }
58972 if (tileCache.type == 6)
58973 {
58974 num = 8;
58975 }
58976 if (tileCache.type == 7 || tileCache.type == 47 || tileCache.type == 284 || tileCache.type == 682)
58977 {
58978 num = 9;
58979 }
58980 if (tileCache.type == 8 || tileCache.type == 45 || tileCache.type == 102 || tileCache.type == 680)
58981 {
58982 num = 10;
58983 }
58984 if (tileCache.type == 9 || tileCache.type == 42 || tileCache.type == 46 || tileCache.type == 126 || tileCache.type == 136 || tileCache.type == 681)
58985 {
58986 num = 11;
58987 }
58988 if (tileCache.type == 166 || tileCache.type == 175)
58989 {
58990 num = 81;
58991 }
58992 if (tileCache.type == 167)
58993 {
58994 num = 82;
58995 }
58996 if (tileCache.type == 168 || tileCache.type == 176)
58997 {
58998 num = 83;
58999 }
59000 if (tileCache.type == 169 || tileCache.type == 177)
59001 {
59002 num = 84;
59003 }
59004 if (tileCache.type == 199 || tileCache.type == 662)
59005 {
59006 num = 117;
59007 }
59008 if (tileCache.type == 205)
59009 {
59010 num = 125;
59011 }
59012 if (tileCache.type == 201)
59013 {
59014 num = 125;
59015 }
59016 if (tileCache.type == 211)
59017 {
59018 num = 128;
59019 }
59020 if (tileCache.type == 227)
59021 {
59022 switch (tileCache.frameX / 34)
59023 {
59024 case 0:
59025 case 1:
59026 num = 26;
59027 break;
59028 case 3:
59029 num = 3;
59030 break;
59031 case 2:
59032 case 4:
59033 case 5:
59034 case 6:
59035 num = 40;
59036 break;
59037 case 7:
59038 num = 117;
59039 break;
59040 case 8:
59041 num = 17;
59042 break;
59043 case 9:
59044 num = 6;
59045 break;
59046 case 10:
59047 num = 3;
59048 break;
59049 case 11:
59050 num = 26;
59051 break;
59052 }
59053 }
59054 if (tileCache.type == 204 || tileCache.type == 478)
59055 {
59056 num = 117;
59057 if (genRand.Next(2) == 0)
59058 {
59059 num = 1;
59060 }
59061 }
59062 if (tileCache.type == 203)
59063 {
59064 num = 117;
59065 }
59066 if (tileCache.type == 243)
59067 {
59068 num = ((genRand.Next(2) != 0) ? 13 : 7);
59069 }
59070 if (tileCache.type == 219)
59071 {
59072 num = -1;
59073 }
59074 if (tileCache.type == 642)
59075 {
59076 num = -128;
59077 }
59078 if (tileCache.type == 244)
59079 {
59080 num = ((genRand.Next(2) == 0) ? 1 : 13);
59081 }
59082 if (tileCache.type == 597)
59083 {
59084 num = -1;
59085 }
59086 else if ((tileCache.type >= 358 && tileCache.type <= 364) || (tileCache.type >= 275 && tileCache.type <= 282) || tileCache.type == 285 || tileCache.type == 286 || (tileCache.type >= 288 && tileCache.type <= 297) || (tileCache.type >= 316 && tileCache.type <= 318) || tileCache.type == 298 || tileCache.type == 299 || tileCache.type == 309 || tileCache.type == 310 || tileCache.type == 339 || tileCache.type == 538 || tileCache.type == 413 || tileCache.type == 414 || tileCache.type == 505 || tileCache.type == 521 || tileCache.type == 522 || tileCache.type == 523 || tileCache.type == 524 || tileCache.type == 525 || tileCache.type == 526 || tileCache.type == 527 || tileCache.type == 532 || tileCache.type == 543 || tileCache.type == 544 || tileCache.type == 550 || tileCache.type == 551 || tileCache.type == 533 || tileCache.type == 553 || tileCache.type == 554 || tileCache.type == 555 || tileCache.type == 556 || tileCache.type == 558 || tileCache.type == 559 || tileCache.type == 542 || tileCache.type == 391 || tileCache.type == 394 || tileCache.type == 392 || tileCache.type == 393 || tileCache.type == 568 || tileCache.type == 569 || tileCache.type == 570 || tileCache.type == 582 || tileCache.type == 580 || tileCache.type == 598 || tileCache.type == 599 || tileCache.type == 600 || tileCache.type == 601 || tileCache.type == 602 || tileCache.type == 603 || tileCache.type == 604 || tileCache.type == 605 || tileCache.type == 606 || tileCache.type == 607 || tileCache.type == 608 || tileCache.type == 609 || tileCache.type == 610 || tileCache.type == 611 || tileCache.type == 612 || tileCache.type == 619 || tileCache.type == 620 || tileCache.type == 629 || tileCache.type == 632 || tileCache.type == 640 || tileCache.type == 643 || tileCache.type == 644 || tileCache.type == 645)
59087 {
59088 num = 13;
59089 if (genRand.Next(3) != 0)
59090 {
59091 num = -1;
59092 }
59093 }
59094 if (tileCache.type == 13)
59095 {
59096 num = ((tileCache.frameX < 90) ? 13 : (-1));
59097 }
59098 if (tileCache.type == 189)
59099 {
59100 num = 16;
59101 }
59102 if (tileCache.type == 460)
59103 {
59104 num = 16;
59105 }
59106 if (tileCache.type == 530)
59107 {
59108 num = Main.tile[i, j + 2 - tileCache.frameY / 18].type switch
59109 {
59110 116 => 47,
59111 234 => 125,
59112 112 => 17,
59113 _ => (tileCache.frameX >= 270) ? 291 : 40,
59114 };
59115 }
59116 if (tileCache.type == 518)
59117 {
59118 if (tileCache.frameY == 0)
59119 {
59120 num = 3;
59121 }
59122 else if (tileCache.frameY == 18)
59123 {
59124 num = 47;
59125 }
59126 else if (tileCache.frameY == 36)
59127 {
59128 num = 40;
59129 }
59130 }
59131 else if (tileCache.type == 519)
59132 {
59133 if (tileCache.frameY == 0)
59134 {
59135 num = 3;
59136 }
59137 else if (tileCache.frameY == 18)
59138 {
59139 num = 40;
59140 }
59141 else if (tileCache.frameY == 36)
59142 {
59143 num = 47;
59144 }
59145 else if (tileCache.frameY == 54)
59146 {
59147 num = 125;
59148 }
59149 else if (tileCache.frameY == 72)
59150 {
59151 num = 17;
59152 }
59153 else if (tileCache.frameY == 90)
59154 {
59155 num = 26;
59156 }
59157 }
59158 else if (tileCache.type == 636)
59159 {
59160 num = 17;
59161 }
59162 else if (tileCache.type == 528)
59163 {
59164 num = 26;
59165 }
59166 if (tileCache.type == 12)
59167 {
59168 num = 12;
59169 }
59170 if (tileCache.type == 639)
59171 {
59172 num = 48;
59173 }
59174 if (tileCache.type == 3 || tileCache.type == 73)
59175 {
59176 num = 3;
59177 }
59178 if (tileCache.type == 54)
59179 {
59180 num = 13;
59181 }
59182 if (tileCache.type == 22 || tileCache.type == 140)
59183 {
59184 num = 14;
59185 }
59186 if (tileCache.type == 78)
59187 {
59188 num = 22;
59189 }
59190 if (tileCache.type == 28 || tileCache.type == 653)
59191 {
59192 num = 22;
59193 if (tileCache.frameY >= 72 && tileCache.frameY <= 90)
59194 {
59195 num = 1;
59196 }
59197 if (tileCache.frameY >= 144 && tileCache.frameY <= 234)
59198 {
59199 num = 48;
59200 }
59201 if (tileCache.frameY >= 252 && tileCache.frameY <= 358)
59202 {
59203 num = 85;
59204 }
59205 if (tileCache.frameY >= 360 && tileCache.frameY <= 466)
59206 {
59207 num = 26;
59208 }
59209 if (tileCache.frameY >= 468 && tileCache.frameY <= 574)
59210 {
59211 num = 36;
59212 }
59213 if (tileCache.frameY >= 576 && tileCache.frameY <= 790)
59214 {
59215 num = 18;
59216 }
59217 if (tileCache.frameY >= 792 && tileCache.frameY <= 898)
59218 {
59219 num = 5;
59220 }
59221 if (tileCache.frameY >= 900 && tileCache.frameY <= 1006)
59222 {
59223 num = 0;
59224 }
59225 if (tileCache.frameY >= 1008 && tileCache.frameY <= 1114)
59226 {
59227 num = 148;
59228 }
59229 if (tileCache.frameY >= 1116 && tileCache.frameY <= 1222)
59230 {
59231 num = 241;
59232 }
59233 if (tileCache.frameY >= 1224 && tileCache.frameY <= 1330)
59234 {
59235 num = 287;
59236 }
59237 }
59238 if (tileCache.type == 163)
59239 {
59240 num = 118;
59241 }
59242 if (tileCache.type == 164)
59243 {
59244 num = 119;
59245 }
59246 if (tileCache.type == 200)
59247 {
59248 num = 120;
59249 }
59250 if (tileCache.type == 221 || tileCache.type == 248)
59251 {
59252 num = 144;
59253 }
59254 if (tileCache.type == 222 || tileCache.type == 249)
59255 {
59256 num = 145;
59257 }
59258 if (tileCache.type == 223 || tileCache.type == 250)
59259 {
59260 num = 146;
59261 }
59262 if (tileCache.type == 224)
59263 {
59264 num = 149;
59265 }
59266 if (tileCache.type == 225)
59267 {
59268 num = 147;
59269 }
59270 if (tileCache.type == 229)
59271 {
59272 num = 153;
59273 }
59274 if (tileCache.type == 231)
59275 {
59276 num = 153;
59277 if (genRand.Next(3) == 0)
59278 {
59279 num = 26;
59280 }
59281 }
59282 if (tileCache.type == 226)
59283 {
59284 num = 148;
59285 }
59286 if (tileCache.type == 103)
59287 {
59288 num = -1;
59289 }
59290 if (tileCache.type == 29)
59291 {
59292 num = 23;
59293 }
59294 if (tileCache.type == 40)
59295 {
59296 num = 28;
59297 }
59298 if (tileCache.type == 50)
59299 {
59300 num = 22;
59301 }
59302 if (tileCache.type == 51)
59303 {
59304 num = 30;
59305 }
59306 if (tileCache.type == 52 || tileCache.type == 353)
59307 {
59308 num = 3;
59309 }
59310 if (tileCache.type == 53 || tileCache.type == 81 || tileCache.type == 151 || tileCache.type == 202 || tileCache.type == 274 || tileCache.type == 495)
59311 {
59312 num = 32;
59313 }
59314 if (tileCache.type == 56 || tileCache.type == 152)
59315 {
59316 num = 37;
59317 }
59318 if (tileCache.type == 75 || tileCache.type == 683)
59319 {
59320 num = 109;
59321 }
59322 if (tileCache.type == 57 || tileCache.type == 119 || tileCache.type == 141 || tileCache.type == 234 || tileCache.type == 635 || tileCache.type == 654)
59323 {
59324 num = 36;
59325 }
59326 if (tileCache.type == 59 || tileCache.type == 120)
59327 {
59328 num = 38;
59329 }
59330 if (tileCache.type == 61 || tileCache.type == 62 || tileCache.type == 74 || tileCache.type == 80 || tileCache.type == 188 || tileCache.type == 233 || tileCache.type == 236 || tileCache.type == 384 || tileCache.type == 652 || tileCache.type == 651)
59331 {
59332 num = 40;
59333 }
59334 if (tileCache.type == 485)
59335 {
59336 num = 32;
59337 }
59338 if (tileCache.type == 238)
59339 {
59340 num = ((genRand.Next(3) != 0) ? 166 : 167);
59341 }
59342 if (tileCache.type == 69)
59343 {
59344 num = 7;
59345 }
59346 if (tileCache.type == 655)
59347 {
59348 num = 166;
59349 }
59350 if (tileCache.type == 71 || tileCache.type == 72 || tileCache.type == 190 || tileCache.type == 578)
59351 {
59352 num = 26;
59353 }
59354 if (tileCache.type == 70)
59355 {
59356 num = 17;
59357 }
59358 if (tileCache.type == 112)
59359 {
59360 num = 14;
59361 }
59362 if (tileCache.type == 123)
59363 {
59364 num = 53;
59365 }
59366 if (tileCache.type == 161)
59367 {
59368 num = 80;
59369 }
59370 if (tileCache.type == 206)
59371 {
59372 num = 80;
59373 }
59374 if (tileCache.type == 162)
59375 {
59376 num = 80;
59377 }
59378 if (tileCache.type == 165)
59379 {
59380 num = (tileCache.frameX / 54) switch
59381 {
59382 0 => 80,
59383 1 => 1,
59384 2 => 30,
59385 3 => 147,
59386 4 => 1,
59387 5 => 14,
59388 6 => 117,
59389 7 => 250,
59390 8 => 240,
59391 9 => 236,
59392 _ => 1,
59393 };
59394 }
59395 if (tileCache.type == 666)
59396 {
59397 num = 322;
59398 }
59399 if (tileCache.type == 193)
59400 {
59401 num = 4;
59402 }
59403 if (tileCache.type == 194)
59404 {
59405 num = 26;
59406 }
59407 if (tileCache.type == 195)
59408 {
59409 num = 5;
59410 }
59411 if (tileCache.type == 196)
59412 {
59413 num = 108;
59414 }
59415 if (tileCache.type == 460)
59416 {
59417 num = 108;
59418 }
59419 if (tileCache.type == 197)
59420 {
59421 num = 4;
59422 }
59423 if (tileCache.type == 153)
59424 {
59425 num = 26;
59426 }
59427 if (tileCache.type == 154)
59428 {
59429 num = 32;
59430 }
59431 if (tileCache.type == 155)
59432 {
59433 num = 2;
59434 }
59435 if (tileCache.type == 156)
59436 {
59437 num = 1;
59438 }
59439 if (tileCache.type == 116 || tileCache.type == 118 || tileCache.type == 147 || tileCache.type == 148)
59440 {
59441 num = 51;
59442 }
59443 if (tileCache.type == 109 || tileCache.type == 492)
59444 {
59445 num = ((genRand.Next(2) != 0) ? 47 : 0);
59446 }
59447 if (tileCache.type == 110 || tileCache.type == 113 || tileCache.type == 115)
59448 {
59449 num = 47;
59450 }
59451 if (tileCache.type == 107 || tileCache.type == 121 || tileCache.type == 685)
59452 {
59453 num = 48;
59454 }
59455 if (tileCache.type == 108 || tileCache.type == 122 || tileCache.type == 146 || tileCache.type == 686)
59456 {
59457 num = 49;
59458 }
59459 if (tileCache.type == 111 || tileCache.type == 145 || tileCache.type == 150)
59460 {
59461 num = 50;
59462 }
59463 if (tileCache.type == 133)
59464 {
59465 num = 50;
59466 if (tileCache.frameX >= 54)
59467 {
59468 num = 146;
59469 }
59470 }
59471 if (tileCache.type == 134)
59472 {
59473 num = 49;
59474 if (tileCache.frameX >= 36)
59475 {
59476 num = 145;
59477 }
59478 }
59479 if (tileCache.type == 149)
59480 {
59481 num = 49;
59482 }
59483 if (Main.tileAlch[tileCache.type])
59484 {
59485 int num16 = tileCache.frameX / 18;
59486 if (num16 == 0)
59487 {
59488 num = 3;
59489 }
59490 if (num16 == 1)
59491 {
59492 num = 3;
59493 }
59494 if (num16 == 2)
59495 {
59496 num = 7;
59497 }
59498 if (num16 == 3)
59499 {
59500 num = 17;
59501 }
59502 if (num16 == 4)
59503 {
59504 num = 289;
59505 }
59506 if (num16 == 5)
59507 {
59508 num = 6;
59509 }
59510 if (num16 == 6)
59511 {
59512 num = 224;
59513 }
59514 }
59515 if (tileCache.type == 58 || tileCache.type == 76 || tileCache.type == 77 || tileCache.type == 684)
59516 {
59517 num = ((genRand.Next(2) != 0) ? 25 : 6);
59518 }
59519 if (tileCache.type == 37)
59520 {
59521 num = ((genRand.Next(2) != 0) ? 23 : 6);
59522 }
59523 if (tileCache.type == 32)
59524 {
59525 num = ((genRand.Next(2) != 0) ? 24 : 14);
59526 }
59527 if (tileCache.type == 352)
59528 {
59529 num = ((genRand.Next(3) != 0) ? 125 : 5);
59530 }
59531 if (tileCache.type == 23 || tileCache.type == 24 || tileCache.type == 661)
59532 {
59533 num = ((genRand.Next(2) != 0) ? 17 : 14);
59534 }
59535 if (tileCache.type == 25 || tileCache.type == 31)
59536 {
59537 num = ((tileCache.type == 31 && tileCache.frameX >= 36) ? 5 : ((genRand.Next(2) != 0) ? 1 : 14));
59538 }
59539 if (tileCache.type == 20)
59540 {
59541 num = (tileCache.frameX / 54) switch
59542 {
59543 1 => 122,
59544 2 => 78,
59545 3 => 77,
59546 4 => 121,
59547 5 => 79,
59548 _ => 7,
59549 };
59550 }
59551 if (tileCache.type == 27)
59552 {
59553 num = ((genRand.Next(2) != 0) ? 19 : 3);
59554 }
59555 if (tileCache.type == 129)
59556 {
59557 if (tileCache.frameX >= 324)
59558 {
59559 num = 69;
59560 }
59561 num = ((tileCache.frameX != 0 && tileCache.frameX != 54 && tileCache.frameX != 108) ? ((tileCache.frameX != 18 && tileCache.frameX != 72 && tileCache.frameX != 126) ? 70 : 69) : 68);
59562 }
59563 if (tileCache.type == 385)
59564 {
59565 num = genRand.Next(68, 71);
59566 }
59567 if (tileCache.type == 4)
59568 {
59569 int num17 = (int)MathHelper.Clamp(tileCache.frameY / 22, 0f, TorchID.Count - 1);
59570 num = TorchID.Dust[num17];
59571 }
59572 if (tileCache.type == 35)
59573 {
59574 num = 189;
59575 if (tileCache.frameX < 36 && genRand.Next(2) == 0)
59576 {
59577 num = 6;
59578 }
59579 }
59580 if ((tileCache.type == 34 || tileCache.type == 42) && genRand.Next(2) == 0)
59581 {
59582 num = 6;
59583 }
59584 if (tileCache.type == 270)
59585 {
59586 num = -1;
59587 }
59588 if (tileCache.type == 271)
59589 {
59590 num = -1;
59591 }
59592 if (tileCache.type == 581)
59593 {
59594 num = -1;
59595 }
59596 if (tileCache.type == 660)
59597 {
59598 num = -1;
59599 }
59600 if (tileCache.type == 79 || tileCache.type == 90 || tileCache.type == 101)
59601 {
59602 num = -1;
59603 }
59604 if (tileCache.type == 33 || tileCache.type == 34 || tileCache.type == 42 || tileCache.type == 93 || tileCache.type == 100)
59605 {
59606 num = -1;
59607 }
59608 if (tileCache.type == 321 || tileCache.type == 574)
59609 {
59610 num = 214;
59611 }
59612 if (tileCache.type == 322)
59613 {
59614 num = 215;
59615 }
59616 if (tileCache.type == 635)
59617 {
59618 num = 36;
59619 }
59620 bool flag = tileCache.type == 178 || tileCache.type == 440;
59621 ushort type = tileCache.type;
59622 if (type == 178 || (uint)(type - 426) <= 1u || (uint)(type - 430) <= 10u)
59623 {
59624 flag = true;
59625 }
59626 if (num >= 0)
59627 {
59628 if (tileCache.type == 627 || tileCache.type == 628 || (tileCache.type == 184 && tileCache.frameX / 22 == 10))
59629 {
59630 int num18 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB));
59631 Main.dust[num18].noGravity = true;
59632 Main.dust[num18].noLightEmittence = true;
59633 return num18;
59634 }
59635 if (tileCache.type == 518)
59636 {
59637 int num19 = tileCache.liquid / 16;
59638 num19 -= 3;
59639 if (SolidTile(i, j - 1) && num19 > 8)
59640 {
59641 num19 = 8;
59642 }
59643 return Dust.NewDust(new Vector2(i * 16, j * 16 - num19), 16, 16, num);
59644 }
59645 if (tileCache.type == 352 && num == 5)
59646 {
59647 int num20 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 5, 0f, 0f, 100);
59648 Main.dust[num20].scale = 1.5f;
59649 Main.dust[num20].noGravity = true;
59650 Main.dust[num20].velocity *= 1.65f;
59651 Main.dust[num20].fadeIn = 1.6f;
59652 return num20;
59653 }
59654 if (tileCache.type == 160 || tileCache.type == 692)
59655 {
59656 int num21 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
59657 Main.dust[num21].noGravity = true;
59658 return num21;
59659 }
59660 if (tileCache.type == 323)
59661 {
59662 int frameY = tileCache.frameY;
59663 return Dust.NewDust(new Vector2(i * 16 + frameY, j * 16), 16, 16, num);
59664 }
59665 if (tileCache.type == 314)
59666 {
59667 int num22 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, 213, genRand.Next(-2, 3), genRand.Next(-2, 3));
59668 Main.dust[num22].noGravity = true;
59669 Main.dust[num22].fadeIn = Main.dust[num22].scale + 1f + 0.01f * (float)genRand.Next(0, 51);
59670 Main.dust[num22].noGravity = true;
59671 return num22;
59672 }
59673 if (flag)
59674 {
59675 int num23 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 75, default(Color), 0.75f);
59676 Main.dust[num23].noLight = true;
59677 return num23;
59678 }
59679 if (tileCache.type == 193 || (tileCache.type == 18 && num == 4) || (tileCache.type == 19 && num == 4))
59680 {
59681 return Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 75, new Color(0, 80, 255, 100), 0.75f);
59682 }
59683 if (tileCache.type == 197)
59684 {
59685 return Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 75, new Color(97, 200, 255, 100), 0.75f);
59686 }
59687 if (tileCache.type == 185 && num >= 86 && num <= 91)
59688 {
59689 int num24 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 75, default(Color), 0.75f);
59690 Main.dust[num24].noLight = true;
59691 return num24;
59692 }
59693 if (tileCache.type == 4 && num == 66)
59694 {
59695 int num25 = Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num, 0f, 0f, 0, new Color((float)Main.DiscoR / 255f, (float)Main.DiscoG / 255f, (float)Main.DiscoB / 255f));
59696 Main.dust[num25].noGravity = true;
59697 return num25;
59698 }
59699 if (num == 139)
59700 {
59701 int type2 = num + Main.rand.Next(4);
59702 return Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, type2);
59703 }
59704 return Dust.NewDust(new Vector2(i * 16, j * 16), 16, 16, num);
59705 }
59706 return 6000;
59707 }
59708
59709 public static bool IsOpenDoorAnchorFrame(int x, int y)
59710 {
59711 Tile tile = Main.tile[x, y];
59712 if (!tile.active() || tile.type != 11)
59713 {
59714 return false;
59715 }
59716 int num = tile.frameX % 72;
59717 if (num >= 18)
59718 {
59719 return num >= 54;
59720 }
59721 return true;
59722 }
59723
59724 public static bool IsLockedDoor(int x, int y)
59725 {
59726 return IsLockedDoor(Main.tile[x, y]);
59727 }
59728
59729 public static bool IsLockedDoor(Tile t)
59730 {
59731 if (t.type == 10 && t.frameY >= 594 && t.frameY <= 646)
59732 {
59733 return t.frameX < 54;
59734 }
59735 return false;
59736 }
59737
59738 public static void DropDoorItem(int x, int y, int doorStyle)
59739 {
59740 int num = 0;
59741 switch (doorStyle)
59742 {
59743 case 0:
59744 num = 25;
59745 break;
59746 case 9:
59747 num = 837;
59748 break;
59749 case 10:
59750 num = 912;
59751 break;
59752 case 12:
59753 num = 1137;
59754 break;
59755 case 13:
59756 num = 1138;
59757 break;
59758 case 14:
59759 num = 1139;
59760 break;
59761 case 15:
59762 num = 1140;
59763 break;
59764 case 16:
59765 num = 1411;
59766 break;
59767 case 17:
59768 num = 1412;
59769 break;
59770 case 18:
59771 num = 1413;
59772 break;
59773 case 19:
59774 num = 1458;
59775 break;
59776 case 20:
59777 case 21:
59778 case 22:
59779 case 23:
59780 num = 1709 + doorStyle - 20;
59781 break;
59782 default:
59783 switch (doorStyle)
59784 {
59785 case 24:
59786 num = 1793;
59787 break;
59788 case 25:
59789 num = 1815;
59790 break;
59791 case 26:
59792 num = 1924;
59793 break;
59794 case 27:
59795 num = 2044;
59796 break;
59797 case 28:
59798 num = 2265;
59799 break;
59800 case 29:
59801 num = 2528;
59802 break;
59803 case 30:
59804 num = 2561;
59805 break;
59806 case 31:
59807 num = 2576;
59808 break;
59809 case 32:
59810 num = 2815;
59811 break;
59812 case 33:
59813 num = 3129;
59814 break;
59815 case 34:
59816 num = 3131;
59817 break;
59818 case 35:
59819 num = 3130;
59820 break;
59821 case 36:
59822 num = 3888;
59823 break;
59824 case 37:
59825 num = 3941;
59826 break;
59827 case 38:
59828 num = 3967;
59829 break;
59830 case 39:
59831 num = 4155;
59832 break;
59833 case 40:
59834 num = 4176;
59835 break;
59836 case 41:
59837 num = 4197;
59838 break;
59839 case 42:
59840 num = 4218;
59841 break;
59842 case 43:
59843 num = 4307;
59844 break;
59845 case 44:
59846 num = 4415;
59847 break;
59848 case 45:
59849 num = 4576;
59850 break;
59851 case 46:
59852 num = 5158;
59853 break;
59854 case 47:
59855 num = 5179;
59856 break;
59857 case 48:
59858 num = 5200;
59859 break;
59860 case 4:
59861 case 5:
59862 case 6:
59863 case 7:
59864 case 8:
59865 num = 812 + doorStyle;
59866 break;
59867 default:
59868 if (doorStyle != 11)
59869 {
59870 num = 649 + doorStyle;
59871 }
59872 break;
59873 }
59874 break;
59875 }
59876 if (num != 0)
59877 {
59878 Item.NewItem(GetItemSource_FromTileBreak(x, y), x * 16, y * 16, 16, 16, num);
59879 }
59880 }
59881
59882 public static IEntitySource GetItemSource_FromTileBreak(int x, int y)
59883 {
59884 return new EntitySource_TileBreak(x, y);
59885 }
59886
59887 public static IEntitySource GetItemSource_FromWallBreak(int x, int y)
59888 {
59889 return new EntitySource_TileBreak(x, y);
59890 }
59891
59892 public static IEntitySource GetItemSource_FromTreeShake(int x, int y)
59893 {
59894 return new EntitySource_ShakeTree(x, y);
59895 }
59896
59897 public static bool PlayerLOS(int x, int y)
59898 {
59899 Rectangle rectangle = new Rectangle(x * 16, y * 16, 16, 16);
59900 for (int i = 0; i < 255; i++)
59901 {
59902 if (Main.player[i].active)
59903 {
59904 Rectangle value = new Rectangle((int)((double)Main.player[i].position.X + (double)Main.player[i].width * 0.5 - (double)NPC.sWidth * 0.6), (int)((double)Main.player[i].position.Y + (double)Main.player[i].height * 0.5 - (double)NPC.sHeight * 0.6), (int)((double)NPC.sWidth * 1.2), (int)((double)NPC.sHeight * 1.2));
59905 if (rectangle.Intersects(value))
59906 {
59907 return true;
59908 }
59909 }
59910 }
59911 return false;
59912 }
59913
59914 public static void ChlorophyteDefense(int x, int y)
59915 {
59916 if (!Main.remixWorld)
59917 {
59918 return;
59919 }
59920 if (Main.tile[x, y].type == 23 || Main.tile[x, y].type == 199 || Main.tile[x, y].type == 661 || Main.tile[x, y].type == 662)
59921 {
59922 Main.tile[x, y].type = 60;
59923 SquareTileFrame(x, y);
59924 if (Main.netMode == 2)
59925 {
59926 NetMessage.SendTileSquare(-1, x, y);
59927 }
59928 }
59929 else if (Main.tile[x, y].type == 25 || Main.tile[x, y].type == 203)
59930 {
59931 Main.tile[x, y].type = 1;
59932 SquareTileFrame(x, y);
59933 if (Main.netMode == 2)
59934 {
59935 NetMessage.SendTileSquare(-1, x, y);
59936 }
59937 }
59938 else if (Main.tile[x, y].type == 112 || Main.tile[x, y].type == 234)
59939 {
59940 Main.tile[x, y].type = 53;
59941 SquareTileFrame(x, y);
59942 if (Main.netMode == 2)
59943 {
59944 NetMessage.SendTileSquare(-1, x, y);
59945 }
59946 }
59947 else if (Main.tile[x, y].type == 398 || Main.tile[x, y].type == 399)
59948 {
59949 Main.tile[x, y].type = 397;
59950 SquareTileFrame(x, y);
59951 if (Main.netMode == 2)
59952 {
59953 NetMessage.SendTileSquare(-1, x, y);
59954 }
59955 }
59956 else if (Main.tile[x, y].type == 400 || Main.tile[x, y].type == 401)
59957 {
59958 Main.tile[x, y].type = 396;
59959 SquareTileFrame(x, y);
59960 if (Main.netMode == 2)
59961 {
59962 NetMessage.SendTileSquare(-1, x, y);
59963 }
59964 }
59965 else if (Main.tile[x, y].type == 24 || Main.tile[x, y].type == 201 || Main.tile[x, y].type == 32 || Main.tile[x, y].type == 352 || Main.tile[x, y].type == 636 || Main.tile[x, y].type == 205)
59966 {
59967 KillTile(x, y);
59968 if (Main.netMode == 2)
59969 {
59970 NetMessage.SendTileSquare(-1, x, y);
59971 }
59972 }
59973 }
59974
59975 public static bool Chlorophyte(int i, int j)
59976 {
59977 int num = 40;
59978 int num2 = 130;
59979 int num3 = 35;
59980 int num4 = 85;
59981 if (Main.remixWorld)
59982 {
59983 num += 5;
59984 num2 *= 15;
59985 num3 -= 4;
59986 num4 -= 8;
59987 }
59988 else if ((double)j < Main.rockLayer)
59989 {
59990 num /= 2;
59991 num2 /= 2;
59992 num3 = (int)((double)num3 * 1.5);
59993 num4 = (int)((double)num4 * 1.5);
59994 }
59995 int num5 = 0;
59996 for (int k = i - num3; k < i + num3; k++)
59997 {
59998 for (int l = j - num3; l < j + num3; l++)
59999 {
60000 if (InWorld(k, l) && Main.tile[k, l].active() && Main.tile[k, l].type == 211)
60001 {
60002 num5++;
60003 }
60004 }
60005 }
60006 if (num5 > num)
60007 {
60008 return false;
60009 }
60010 num5 = 0;
60011 for (int m = i - num4; m < i + num4; m++)
60012 {
60013 for (int n = j - num4; n < j + num4; n++)
60014 {
60015 if (InWorld(m, n) && Main.tile[m, n].active() && Main.tile[m, n].type == 211)
60016 {
60017 num5++;
60018 }
60019 }
60020 }
60021 if (num5 > num2)
60022 {
60023 return false;
60024 }
60025 return true;
60026 }
60027
60028 private static bool nearbyChlorophyte(int i, int j)
60029 {
60030 double num = 0.0;
60031 int num2 = 5;
60033 {
60034 return false;
60035 }
60037 {
60038 return false;
60039 }
60040 for (int k = i - num2; k <= i + num2; k++)
60041 {
60042 for (int l = j - num2; l <= j + num2; l++)
60043 {
60044 if (Main.tile[k, l].active() && (Main.tile[k, l].type == 211 || Main.tile[k, l].type == 346))
60045 {
60046 num += 1.0;
60047 if (num >= 3.0)
60048 {
60049 return true;
60050 }
60051 }
60052 }
60053 }
60054 if (num > 0.0)
60055 {
60056 if (Main.remixWorld)
60057 {
60058 if ((double)genRand.Next(-1, 3) < num)
60059 {
60060 return true;
60061 }
60062 }
60063 else if ((double)genRand.Next(-1, 4) < num)
60064 {
60065 return true;
60066 }
60067 }
60068 return false;
60069 }
60070
60071 public static int CountNearBlocksTypes(int i, int j, int radius, int cap = 0, params int[] tiletypes)
60072 {
60073 if (tiletypes.Length == 0)
60074 {
60075 return 0;
60076 }
60077 int value = i - radius;
60078 int value2 = i + radius;
60079 int value3 = j - radius;
60080 int value4 = j + radius;
60081 int num = Utils.Clamp(value, 0, Main.maxTilesX - 1);
60082 value2 = Utils.Clamp(value2, 0, Main.maxTilesX - 1);
60083 value3 = Utils.Clamp(value3, 0, Main.maxTilesY - 1);
60084 value4 = Utils.Clamp(value4, 0, Main.maxTilesY - 1);
60085 int num2 = 0;
60086 for (int k = num; k <= value2; k++)
60087 {
60088 for (int l = value3; l <= value4; l++)
60089 {
60090 if (!Main.tile[k, l].active())
60091 {
60092 continue;
60093 }
60094 for (int m = 0; m < tiletypes.Length; m++)
60095 {
60096 if (tiletypes[m] == Main.tile[k, l].type)
60097 {
60098 num2++;
60099 if (cap <= 0 || num2 < cap)
60100 {
60101 break;
60102 }
60103 return num2;
60104 }
60105 }
60106 }
60107 }
60108 return num2;
60109 }
60110
60111 public static void hardUpdateWorld(int i, int j)
60112 {
60113 if (!Main.hardMode || Main.tile[i, j].inActive())
60114 {
60115 return;
60116 }
60117 int type = Main.tile[i, j].type;
60118 if (type > 0 && type < TileID.Count && TileID.Sets.CanGrowCrystalShards[type] && ((double)j > Main.rockLayer || Main.remixWorld) && genRand.Next(5) == 0)
60119 {
60120 int num = genRand.Next(4);
60121 int num2 = 0;
60122 int num3 = 0;
60123 switch (num)
60124 {
60125 case 0:
60126 num2 = -1;
60127 break;
60128 case 1:
60129 num2 = 1;
60130 break;
60131 default:
60132 num3 = ((num != 0) ? 1 : (-1));
60133 break;
60134 }
60135 if (!Main.tile[i + num2, j + num3].active())
60136 {
60137 int num4 = 0;
60138 int num5 = 6;
60139 for (int k = i - num5; k <= i + num5; k++)
60140 {
60141 for (int l = j - num5; l <= j + num5; l++)
60142 {
60143 if (Main.tile[k, l].active() && Main.tile[k, l].type == 129)
60144 {
60145 num4++;
60146 }
60147 }
60148 }
60149 if (num4 < 2)
60150 {
60151 int style = (short)genRand.Next(18);
60152 if (genRand.Next(50) == 0)
60153 {
60154 style = (short)(18 + genRand.Next(6));
60155 }
60156 PlaceTile(i + num2, j + num3, 129, mute: true, forced: false, -1, style);
60157 NetMessage.SendTileSquare(-1, i + num2, j + num3);
60158 }
60159 }
60160 }
60161 if ((double)j > (Main.worldSurface + Main.rockLayer) / 2.0 || Main.remixWorld)
60162 {
60163 if (type == 60 && genRand.Next(300) == 0)
60164 {
60165 int num6 = i + genRand.Next(-10, 11);
60166 int num7 = j + genRand.Next(-10, 11);
60167 if (InWorld(num6, num7, 2) && Main.tile[num6, num7].active() && Main.tile[num6, num7].type == 59 && (!Main.tile[num6, num7 - 1].active() || (Main.tile[num6, num7 - 1].type != 5 && Main.tile[num6, num7 - 1].type != 236 && Main.tile[num6, num7 - 1].type != 238)) && Chlorophyte(num6, num7))
60168 {
60169 Main.tile[num6, num7].type = 211;
60170 SquareTileFrame(num6, num7);
60171 if (Main.netMode == 2)
60172 {
60174 }
60175 }
60176 }
60177 if (type == 211 || type == 346)
60178 {
60179 int num8 = i;
60180 int num9 = j;
60181 if (genRand.Next(3) != 0)
60182 {
60183 int num10 = genRand.Next(4);
60184 if (num10 == 0)
60185 {
60186 num8++;
60187 }
60188 if (num10 == 1)
60189 {
60190 num8--;
60191 }
60192 if (num10 == 2)
60193 {
60194 num9++;
60195 }
60196 if (num10 == 3)
60197 {
60198 num9--;
60199 }
60200 if (InWorld(num8, num9, 2) && Main.tile[num8, num9].active() && (Main.tile[num8, num9].type == 59 || Main.tile[num8, num9].type == 60) && Chlorophyte(num8, num9))
60201 {
60202 Main.tile[num8, num9].type = 211;
60203 SquareTileFrame(num8, num9);
60204 if (Main.netMode == 2)
60205 {
60207 }
60208 }
60209 }
60210 bool flag = true;
60211 while (flag)
60212 {
60213 flag = false;
60214 num8 = i + Main.rand.Next(-6, 7);
60215 num9 = j + Main.rand.Next(-6, 7);
60216 if (!InWorld(num8, num9, 2) || !Main.tile[num8, num9].active())
60217 {
60218 continue;
60219 }
60220 if (Main.tile[num8, num9].type == 661 || Main.tile[num8, num9].type == 662 || Main.tile[num8, num9].type == 23 || Main.tile[num8, num9].type == 199 || Main.tile[num8, num9].type == 2 || Main.tile[num8, num9].type == 477 || Main.tile[num8, num9].type == 492 || Main.tile[num8, num9].type == 109)
60221 {
60222 Main.tile[num8, num9].type = 60;
60223 SquareTileFrame(num8, num9);
60224 if (Main.netMode == 2)
60225 {
60227 }
60228 flag = true;
60229 }
60230 else if (Main.tile[num8, num9].type == 0)
60231 {
60232 Main.tile[num8, num9].type = 59;
60233 SquareTileFrame(num8, num9);
60234 if (Main.netMode == 2)
60235 {
60237 }
60238 flag = true;
60239 }
60240 else if (Main.tile[num8, num9].type == 25 || Main.tile[num8, num9].type == 203)
60241 {
60242 Main.tile[num8, num9].type = 1;
60243 SquareTileFrame(num8, num9);
60244 if (Main.netMode == 2)
60245 {
60247 }
60248 flag = true;
60249 }
60250 else if (Main.tile[num8, num9].type == 112 || Main.tile[num8, num9].type == 234)
60251 {
60252 Main.tile[num8, num9].type = 53;
60253 SquareTileFrame(num8, num9);
60254 if (Main.netMode == 2)
60255 {
60257 }
60258 flag = true;
60259 }
60260 else if (Main.tile[num8, num9].type == 398 || Main.tile[num8, num9].type == 399)
60261 {
60262 Main.tile[num8, num9].type = 397;
60263 SquareTileFrame(num8, num9);
60264 if (Main.netMode == 2)
60265 {
60267 }
60268 flag = true;
60269 }
60270 else if (Main.tile[num8, num9].type == 400 || Main.tile[num8, num9].type == 401)
60271 {
60272 Main.tile[num8, num9].type = 396;
60273 SquareTileFrame(num8, num9);
60274 if (Main.netMode == 2)
60275 {
60277 }
60278 flag = true;
60279 }
60280 else if (Main.tile[num8, num9].type == 24 || Main.tile[num8, num9].type == 201 || Main.tile[num8, num9].type == 32 || Main.tile[num8, num9].type == 352 || Main.tile[num8, num9].type == 636 || Main.tile[num8, num9].type == 205)
60281 {
60282 KillTile(num8, num9);
60283 if (Main.netMode == 2)
60284 {
60286 }
60287 flag = true;
60288 }
60289 }
60290 }
60291 }
60292 if ((NPC.downedPlantBoss && genRand.Next(2) != 0) || !AllowedToSpreadInfections)
60293 {
60294 return;
60295 }
60296 if (type == 23 || type == 25 || type == 32 || type == 112 || type == 163 || type == 400 || type == 398 || type == 636 || type == 661)
60297 {
60298 bool flag2 = true;
60299 while (flag2)
60300 {
60301 flag2 = false;
60302 int num11 = i + genRand.Next(-3, 4);
60303 int num12 = j + genRand.Next(-3, 4);
60304 if (!InWorld(num11, num12, 10))
60305 {
60306 continue;
60307 }
60308 if (nearbyChlorophyte(num11, num12))
60309 {
60310 ChlorophyteDefense(num11, num12);
60311 }
60312 else
60313 {
60314 if (CountNearBlocksTypes(num11, num12, 2, 1, 27) > 0)
60315 {
60316 continue;
60317 }
60318 if (Main.tile[num11, num12].type == 2)
60319 {
60320 if (genRand.Next(2) == 0)
60321 {
60322 flag2 = true;
60323 }
60324 Main.tile[num11, num12].type = 23;
60325 SquareTileFrame(num11, num12);
60327 }
60328 else if (Main.tile[num11, num12].type == 1 || Main.tileMoss[Main.tile[num11, num12].type])
60329 {
60330 if (genRand.Next(2) == 0)
60331 {
60332 flag2 = true;
60333 }
60334 Main.tile[num11, num12].type = 25;
60335 SquareTileFrame(num11, num12);
60337 }
60338 else if (Main.tile[num11, num12].type == 53)
60339 {
60340 if (genRand.Next(2) == 0)
60341 {
60342 flag2 = true;
60343 }
60344 Main.tile[num11, num12].type = 112;
60345 SquareTileFrame(num11, num12);
60347 }
60348 else if (Main.tile[num11, num12].type == 396)
60349 {
60350 if (genRand.Next(2) == 0)
60351 {
60352 flag2 = true;
60353 }
60354 Main.tile[num11, num12].type = 400;
60355 SquareTileFrame(num11, num12);
60357 }
60358 else if (Main.tile[num11, num12].type == 397)
60359 {
60360 if (genRand.Next(2) == 0)
60361 {
60362 flag2 = true;
60363 }
60364 Main.tile[num11, num12].type = 398;
60365 SquareTileFrame(num11, num12);
60367 }
60368 else if (Main.tile[num11, num12].type == 60)
60369 {
60370 if (genRand.Next(2) == 0)
60371 {
60372 flag2 = true;
60373 }
60374 Main.tile[num11, num12].type = 661;
60375 SquareTileFrame(num11, num12);
60377 }
60378 else if (Main.tile[num11, num12].type == 69)
60379 {
60380 if (genRand.Next(2) == 0)
60381 {
60382 flag2 = true;
60383 }
60384 Main.tile[num11, num12].type = 32;
60385 SquareTileFrame(num11, num12);
60387 }
60388 else if (Main.tile[num11, num12].type == 161)
60389 {
60390 if (genRand.Next(2) == 0)
60391 {
60392 flag2 = true;
60393 }
60394 Main.tile[num11, num12].type = 163;
60395 SquareTileFrame(num11, num12);
60397 }
60398 }
60399 }
60400 }
60401 if (type == 199 || type == 200 || type == 201 || type == 203 || type == 205 || type == 234 || type == 352 || type == 401 || type == 399 || type == 662)
60402 {
60403 bool flag3 = true;
60404 while (flag3)
60405 {
60406 flag3 = false;
60407 int num13 = i + genRand.Next(-3, 4);
60408 int num14 = j + genRand.Next(-3, 4);
60409 if (!InWorld(num13, num14, 10))
60410 {
60411 continue;
60412 }
60413 if (nearbyChlorophyte(num13, num14))
60414 {
60415 ChlorophyteDefense(num13, num14);
60416 }
60417 else
60418 {
60419 if (CountNearBlocksTypes(num13, num14, 2, 1, 27) > 0)
60420 {
60421 continue;
60422 }
60423 if (Main.tile[num13, num14].type == 2)
60424 {
60425 if (genRand.Next(2) == 0)
60426 {
60427 flag3 = true;
60428 }
60429 Main.tile[num13, num14].type = 199;
60430 SquareTileFrame(num13, num14);
60432 }
60433 else if (Main.tile[num13, num14].type == 1 || Main.tileMoss[Main.tile[num13, num14].type])
60434 {
60435 if (genRand.Next(2) == 0)
60436 {
60437 flag3 = true;
60438 }
60439 Main.tile[num13, num14].type = 203;
60440 SquareTileFrame(num13, num14);
60442 }
60443 else if (Main.tile[num13, num14].type == 53)
60444 {
60445 if (genRand.Next(2) == 0)
60446 {
60447 flag3 = true;
60448 }
60449 Main.tile[num13, num14].type = 234;
60450 SquareTileFrame(num13, num14);
60452 }
60453 else if (Main.tile[num13, num14].type == 396)
60454 {
60455 if (genRand.Next(2) == 0)
60456 {
60457 flag3 = true;
60458 }
60459 Main.tile[num13, num14].type = 401;
60460 SquareTileFrame(num13, num14);
60462 }
60463 else if (Main.tile[num13, num14].type == 397)
60464 {
60465 if (genRand.Next(2) == 0)
60466 {
60467 flag3 = true;
60468 }
60469 Main.tile[num13, num14].type = 399;
60470 SquareTileFrame(num13, num14);
60472 }
60473 else if (Main.tile[num13, num14].type == 60)
60474 {
60475 if (genRand.Next(2) == 0)
60476 {
60477 flag3 = true;
60478 }
60479 Main.tile[num13, num14].type = 662;
60480 SquareTileFrame(num13, num14);
60482 }
60483 else if (Main.tile[num13, num14].type == 69)
60484 {
60485 if (genRand.Next(2) == 0)
60486 {
60487 flag3 = true;
60488 }
60489 Main.tile[num13, num14].type = 352;
60490 SquareTileFrame(num13, num14);
60492 }
60493 else if (Main.tile[num13, num14].type == 161)
60494 {
60495 if (genRand.Next(2) == 0)
60496 {
60497 flag3 = true;
60498 }
60499 Main.tile[num13, num14].type = 200;
60500 SquareTileFrame(num13, num14);
60502 }
60503 }
60504 }
60505 }
60506 if (type != 109 && type != 110 && type != 113 && type != 115 && type != 116 && type != 117 && type != 164 && type != 402 && type != 403 && type != 492)
60507 {
60508 return;
60509 }
60510 bool flag4 = true;
60511 while (flag4)
60512 {
60513 flag4 = false;
60514 int num15 = i + genRand.Next(-3, 4);
60515 int num16 = j + genRand.Next(-3, 4);
60516 if (!InWorld(num15, num16, 10) || CountNearBlocksTypes(num15, num16, 2, 1, 27) > 0)
60517 {
60518 continue;
60519 }
60520 if (Main.tile[num15, num16].type == 2)
60521 {
60522 if (genRand.Next(2) == 0)
60523 {
60524 flag4 = true;
60525 }
60526 Main.tile[num15, num16].type = 109;
60527 SquareTileFrame(num15, num16);
60529 }
60530 else if (Main.tile[num15, num16].type == 477)
60531 {
60532 if (genRand.Next(2) == 0)
60533 {
60534 flag4 = true;
60535 }
60536 Main.tile[num15, num16].type = 492;
60537 SquareTileFrame(num15, num16);
60539 }
60540 else if (Main.tile[num15, num16].type == 1 || Main.tileMoss[Main.tile[num15, num16].type])
60541 {
60542 if (genRand.Next(2) == 0)
60543 {
60544 flag4 = true;
60545 }
60546 Main.tile[num15, num16].type = 117;
60547 SquareTileFrame(num15, num16);
60549 }
60550 else if (Main.tile[num15, num16].type == 53)
60551 {
60552 if (genRand.Next(2) == 0)
60553 {
60554 flag4 = true;
60555 }
60556 Main.tile[num15, num16].type = 116;
60557 SquareTileFrame(num15, num16);
60559 }
60560 else if (Main.tile[num15, num16].type == 396)
60561 {
60562 if (genRand.Next(2) == 0)
60563 {
60564 flag4 = true;
60565 }
60566 Main.tile[num15, num16].type = 403;
60567 SquareTileFrame(num15, num16);
60569 }
60570 else if (Main.tile[num15, num16].type == 397)
60571 {
60572 if (genRand.Next(2) == 0)
60573 {
60574 flag4 = true;
60575 }
60576 Main.tile[num15, num16].type = 402;
60577 SquareTileFrame(num15, num16);
60579 }
60580 else if (Main.tile[num15, num16].type == 161)
60581 {
60582 if (genRand.Next(2) == 0)
60583 {
60584 flag4 = true;
60585 }
60586 Main.tile[num15, num16].type = 164;
60587 SquareTileFrame(num15, num16);
60589 }
60590 }
60591 }
60592
60593 public static bool SolidTile(Tile testTile)
60594 {
60595 try
60596 {
60597 if (testTile == null)
60598 {
60599 return true;
60600 }
60601 if (testTile.active() && Main.tileSolid[testTile.type] && !Main.tileSolidTop[testTile.type] && !testTile.halfBrick() && testTile.slope() == 0 && !testTile.inActive())
60602 {
60603 return true;
60604 }
60605 }
60606 catch
60607 {
60608 }
60609 return false;
60610 }
60611
60612 public static bool TileEmpty(int i, int j)
60613 {
60614 if (Main.tile[i, j] != null && Main.tile[i, j].active())
60615 {
60616 return Main.tile[i, j].inActive();
60617 }
60618 return true;
60619 }
60620
60621 public static bool SolidOrSlopedTile(Tile tile)
60622 {
60623 if (tile != null && tile.active() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
60624 {
60625 return !tile.inActive();
60626 }
60627 return false;
60628 }
60629
60630 public static int TileType(int x, int y)
60631 {
60632 if (!Main.tile[x, y].active())
60633 {
60634 return -1;
60635 }
60636 return Main.tile[x, y].type;
60637 }
60638
60639 public static bool SolidOrSlopedTile(int x, int y)
60640 {
60641 return SolidOrSlopedTile(Main.tile[x, y]);
60642 }
60643
60644 public static bool IsRope(int x, int y)
60645 {
60646 if (Main.tile[x, y] == null || !Main.tile[x, y].active())
60647 {
60648 return false;
60649 }
60650 if (Main.tileRope[Main.tile[x, y].type])
60651 {
60652 return true;
60653 }
60654 if ((Main.tile[x, y].type == 314 || TileID.Sets.Platforms[Main.tile[x, y].type]) && Main.tile[x, y - 1] != null && Main.tile[x, y + 1] != null && Main.tile[x, y - 1].active() && Main.tile[x, y + 1].active() && Main.tileRope[Main.tile[x, y - 1].type] && Main.tileRope[Main.tile[x, y + 1].type])
60655 {
60656 return true;
60657 }
60658 return false;
60659 }
60660
60661 public static bool SolidTile(Point p)
60662 {
60663 return SolidTile(p.X, p.Y);
60664 }
60665
60666 public static bool SolidTile(int i, int j, bool noDoors = false)
60667 {
60668 try
60669 {
60670 if (Main.tile[i, j] == null)
60671 {
60672 return true;
60673 }
60674 if (Main.tile[i, j].active() && Main.tileSolid[Main.tile[i, j].type] && !Main.tileSolidTop[Main.tile[i, j].type] && !Main.tile[i, j].halfBrick() && Main.tile[i, j].slope() == 0 && !Main.tile[i, j].inActive())
60675 {
60676 if (noDoors && Main.tile[i, j].type == 10)
60677 {
60678 return false;
60679 }
60680 return true;
60681 }
60682 }
60683 catch
60684 {
60685 }
60686 return false;
60687 }
60688
60689 public static bool SolidTile2(Tile testTile)
60690 {
60691 try
60692 {
60693 if (testTile == null)
60694 {
60695 return true;
60696 }
60697 if (testTile.active() && Main.tileSolid[testTile.type] && testTile.slope() == 0 && !testTile.halfBrick() && !testTile.inActive())
60698 {
60699 return true;
60700 }
60701 }
60702 catch
60703 {
60704 }
60705 return false;
60706 }
60707
60708 public static bool PlatformProperTopFrame(short frameX)
60709 {
60710 int num = frameX / TileObjectData.PlatformFrameWidth();
60711 if ((num < 0 || num > 7) && (num < 12 || num > 16))
60712 {
60713 if (num >= 25)
60714 {
60715 return num <= 26;
60716 }
60717 return false;
60718 }
60719 return true;
60720 }
60721
60722 public static bool SolidTileAllowBottomSlope(int i, int j)
60723 {
60724 try
60725 {
60726 Tile tile = Main.tile[i, j];
60727 if (tile == null)
60728 {
60729 return true;
60730 }
60731 if (tile.active() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]) && (!tile.topSlope() || (TileID.Sets.Platforms[tile.type] && PlatformProperTopFrame(tile.frameX))) && !tile.halfBrick() && !tile.inActive())
60732 {
60733 return true;
60734 }
60735 }
60736 catch
60737 {
60738 }
60739 return false;
60740 }
60741
60742 public static bool ActiveAndWalkableTile(int i, int j)
60743 {
60744 try
60745 {
60746 Tile tile = Main.tile[i, j];
60747 if (tile == null)
60748 {
60749 return true;
60750 }
60751 if (tile.active() && Main.tileSolid[tile.type] && !tile.inActive())
60752 {
60753 return true;
60754 }
60755 }
60756 catch
60757 {
60758 }
60759 return false;
60760 }
60761
60762 public static bool SolidTileAllowTopSlope(int i, int j)
60763 {
60764 try
60765 {
60766 Tile tile = Main.tile[i, j];
60767 if (tile == null)
60768 {
60769 return true;
60770 }
60771 if (tile.active() && (Main.tileSolid[tile.type] || tile.type == 380) && (!tile.bottomSlope() || (TileID.Sets.Platforms[tile.type] && tile.halfBrick())) && !tile.inActive())
60772 {
60773 return true;
60774 }
60775 }
60776 catch
60777 {
60778 }
60779 return false;
60780 }
60781
60782 public static bool SolidTileAllowLeftSlope(int i, int j)
60783 {
60784 try
60785 {
60786 Tile tile = Main.tile[i, j];
60787 if (tile == null)
60788 {
60789 return true;
60790 }
60791 if (tile.active() && Main.tileSolid[tile.type] && !tile.rightSlope() && !TileID.Sets.Platforms[tile.type] && !tile.inActive())
60792 {
60793 return true;
60794 }
60795 }
60796 catch
60797 {
60798 }
60799 return false;
60800 }
60801
60802 public static bool SolidTileAllowRightSlope(int i, int j)
60803 {
60804 try
60805 {
60806 Tile tile = Main.tile[i, j];
60807 if (tile == null)
60808 {
60809 return true;
60810 }
60811 if (tile.active() && Main.tileSolid[tile.type] && !tile.leftSlope() && !TileID.Sets.Platforms[tile.type] && !tile.inActive())
60812 {
60813 return true;
60814 }
60815 }
60816 catch
60817 {
60818 }
60819 return false;
60820 }
60821
60822 public static bool TopEdgeCanBeAttachedTo(int i, int j)
60823 {
60824 try
60825 {
60826 Tile tile = Main.tile[i, j];
60827 if (tile == null)
60828 {
60829 return true;
60830 }
60831 if (tile.active() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]) && (!tile.topSlope() || (TileID.Sets.Platforms[tile.type] && PlatformProperTopFrame(tile.frameX))) && !tile.halfBrick() && !tile.inActive())
60832 {
60833 return true;
60834 }
60835 }
60836 catch
60837 {
60838 }
60839 return false;
60840 }
60841
60842 public static bool RightEdgeCanBeAttachedTo(int i, int j)
60843 {
60844 try
60845 {
60846 Tile tile = Main.tile[i, j];
60847 if (tile == null)
60848 {
60849 return true;
60850 }
60851 if (tile.active() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type] && !tile.rightSlope() && !tile.halfBrick() && !tile.inActive() && !Main.tileNoAttach[tile.type])
60852 {
60853 return true;
60854 }
60855 }
60856 catch
60857 {
60858 }
60859 return false;
60860 }
60861
60862 public static bool LeftEdgeCanBeAttachedTo(int i, int j)
60863 {
60864 try
60865 {
60866 Tile tile = Main.tile[i, j];
60867 if (tile == null)
60868 {
60869 return true;
60870 }
60871 if (tile.active() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type] && !tile.leftSlope() && !tile.halfBrick() && !tile.inActive() && !Main.tileNoAttach[tile.type])
60872 {
60873 return true;
60874 }
60875 }
60876 catch
60877 {
60878 }
60879 return false;
60880 }
60881
60882 public static bool BottomEdgeCanBeAttachedTo(int i, int j)
60883 {
60884 try
60885 {
60886 Tile tile = Main.tile[i, j];
60887 if (tile == null)
60888 {
60889 return true;
60890 }
60891 if (tile.active() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type] && !tile.bottomSlope() && !tile.inActive() && !Main.tileNoAttach[tile.type])
60892 {
60893 return true;
60894 }
60895 }
60896 catch
60897 {
60898 }
60899 return false;
60900 }
60901
60902 public static bool SolidTile3(int i, int j)
60903 {
60904 if (!InWorld(i, j, 1))
60905 {
60906 return false;
60907 }
60908 return SolidTile3(Main.tile[i, j]);
60909 }
60910
60911 public static bool SolidTile3(Tile t)
60912 {
60913 if (t == null)
60914 {
60915 return false;
60916 }
60917 if (t.active() && !t.inActive() && Main.tileSolid[t.type])
60918 {
60919 return !Main.tileSolidTop[t.type];
60920 }
60921 return false;
60922 }
60923
60924 public static bool SolidTile2(int i, int j)
60925 {
60926 try
60927 {
60928 if (Main.tile[i, j] == null)
60929 {
60930 return true;
60931 }
60932 if (Main.tile[i, j].active() && Main.tileSolid[Main.tile[i, j].type] && ((TileID.Sets.Platforms[Main.tile[i, j].type] && (Main.tile[i, j].halfBrick() || Main.tile[i, j].topSlope())) || Main.tile[i, j].slope() == 0) && !Main.tile[i, j].halfBrick() && !Main.tile[i, j].inActive())
60933 {
60934 return true;
60935 }
60936 }
60937 catch
60938 {
60939 }
60940 return false;
60941 }
60942
60943 public static bool SolidTileNoAttach(int i, int j)
60944 {
60945 try
60946 {
60947 if (Main.tile[i, j] == null)
60948 {
60949 return true;
60950 }
60951 if (Main.tile[i, j].active() && Main.tileSolid[Main.tile[i, j].type] && !Main.tileNoAttach[Main.tile[i, j].type] && Main.tile[i, j].slope() == 0 && !Main.tile[i, j].halfBrick() && !Main.tile[i, j].inActive())
60952 {
60953 return true;
60954 }
60955 }
60956 catch
60957 {
60958 }
60959 return false;
60960 }
60961
60962 public static void MineHouse(int i, int j)
60963 {
60965 {
60966 return;
60967 }
60968 int num = genRand.Next(6, 12);
60969 int num2 = genRand.Next(3, 6);
60970 int num3 = genRand.Next(15, 30);
60971 int num4 = genRand.Next(15, 30);
60972 if (SolidTile(i, j) || Main.tile[i, j].wall > 0)
60973 {
60974 return;
60975 }
60976 int num5 = j - num;
60977 int num6 = j + num2;
60978 for (int k = 0; k < 2; k++)
60979 {
60980 bool flag = true;
60981 int num7 = i;
60982 int num8 = j;
60983 int num9 = -1;
60984 int num10 = num3;
60985 if (k == 1)
60986 {
60987 num9 = 1;
60988 num10 = num4;
60989 num7++;
60990 }
60991 while (flag)
60992 {
60993 if (num8 - num < num5)
60994 {
60995 num5 = num8 - num;
60996 }
60997 if (num8 + num2 > num6)
60998 {
60999 num6 = num8 + num2;
61000 }
61001 for (int l = 0; l < 2; l++)
61002 {
61003 int num11 = num8;
61004 bool flag2 = true;
61005 int num12 = num;
61006 int num13 = -1;
61007 if (l == 1)
61008 {
61009 num11++;
61010 num12 = num2;
61011 num13 = 1;
61012 }
61013 while (flag2)
61014 {
61015 if (num7 != i && Main.tile[num7 - num9, num11].wall != 27 && (SolidTile(num7 - num9, num11) || !Main.tile[num7 - num9, num11].active() || Main.tile[num7 - num9, num11].halfBrick() || Main.tile[num7 - num9, num11].slope() != 0))
61016 {
61017 Main.tile[num7 - num9, num11].active(active: true);
61018 Main.tile[num7 - num9, num11].type = 30;
61019 }
61020 if (SolidTile(num7 - 1, num11) || Main.tile[num7 - 1, num11].halfBrick() || Main.tile[num7 - 1, num11].slope() != 0)
61021 {
61022 Main.tile[num7 - 1, num11].type = 30;
61023 }
61024 if (SolidTile(num7 + 1, num11) || Main.tile[num7 + 1, num11].halfBrick() || Main.tile[num7 + 1, num11].slope() != 0)
61025 {
61026 Main.tile[num7 + 1, num11].type = 30;
61027 }
61028 if (SolidTile(num7, num11) || Main.tile[num7, num11].halfBrick() || Main.tile[num7, num11].slope() != 0)
61029 {
61030 int num14 = 0;
61031 if (SolidTile(num7 - 1, num11))
61032 {
61033 num14++;
61034 }
61035 if (SolidTile(num7 + 1, num11))
61036 {
61037 num14++;
61038 }
61039 if (SolidTile(num7, num11 - 1))
61040 {
61041 num14++;
61042 }
61043 if (SolidTile(num7, num11 + 1))
61044 {
61045 num14++;
61046 }
61047 if (num14 < 2)
61048 {
61049 Main.tile[num7, num11].active(active: false);
61050 }
61051 else
61052 {
61053 flag2 = false;
61054 Main.tile[num7, num11].type = 30;
61055 }
61056 }
61057 else
61058 {
61059 Main.tile[num7, num11].wall = 27;
61060 Main.tile[num7, num11].liquid = 0;
61061 Main.tile[num7, num11].lava(lava: false);
61062 }
61063 num11 += num13;
61064 num12--;
61065 if (num12 <= 0)
61066 {
61067 if (!Main.tile[num7, num11].active())
61068 {
61069 Main.tile[num7, num11].active(active: true);
61070 Main.tile[num7, num11].type = 30;
61071 }
61072 flag2 = false;
61073 }
61074 }
61075 }
61076 num10--;
61077 num7 += num9;
61078 if (SolidTile(num7, num8))
61079 {
61080 int num15 = 0;
61081 int num16 = 0;
61082 int num17 = num8;
61083 bool flag3 = true;
61084 while (flag3)
61085 {
61086 num17--;
61087 num15++;
61088 if (SolidTile(num7 - num9, num17))
61089 {
61090 num15 = 999;
61091 flag3 = false;
61092 }
61093 else if (!SolidTile(num7, num17))
61094 {
61095 flag3 = false;
61096 }
61097 }
61098 num17 = num8;
61099 flag3 = true;
61100 while (flag3)
61101 {
61102 num17++;
61103 num16++;
61104 if (SolidTile(num7 - num9, num17))
61105 {
61106 num16 = 999;
61107 flag3 = false;
61108 }
61109 else if (!SolidTile(num7, num17))
61110 {
61111 flag3 = false;
61112 }
61113 }
61114 if (num16 <= num15)
61115 {
61116 if (num16 > num2)
61117 {
61118 num10 = 0;
61119 }
61120 else
61121 {
61122 num8 += num16 + 1;
61123 }
61124 }
61125 else if (num15 > num)
61126 {
61127 num10 = 0;
61128 }
61129 else
61130 {
61131 num8 -= num15 + 1;
61132 }
61133 }
61134 if (num10 <= 0)
61135 {
61136 flag = false;
61137 }
61138 }
61139 }
61140 int num18 = i - num3 - 1;
61141 int num19 = i + num4 + 2;
61142 int num20 = num5 - 1;
61143 int num21 = num6 + 2;
61144 for (int m = num18; m < num19; m++)
61145 {
61146 for (int n = num20; n < num21; n++)
61147 {
61148 if (Main.tile[m, n].wall == 27 && !Main.tile[m, n].active())
61149 {
61150 if (Main.tile[m - 1, n].wall != 27 && m < i && !SolidTile(m - 1, n))
61151 {
61152 PlaceTile(m, n, 30, mute: true);
61153 Main.tile[m, n].wall = 0;
61154 }
61155 if (Main.tile[m + 1, n].wall != 27 && m > i && !SolidTile(m + 1, n))
61156 {
61157 PlaceTile(m, n, 30, mute: true);
61158 Main.tile[m, n].wall = 0;
61159 }
61160 for (int num22 = m - 1; num22 <= m + 1; num22++)
61161 {
61162 for (int num23 = n - 1; num23 <= n + 1; num23++)
61163 {
61164 if (SolidTile(num22, num23))
61165 {
61166 Main.tile[num22, num23].type = 30;
61167 }
61168 }
61169 }
61170 }
61171 if (Main.tile[m, n].type == 30 && Main.tile[m - 1, n].wall == 27 && Main.tile[m + 1, n].wall == 27 && (Main.tile[m, n - 1].wall == 27 || Main.tile[m, n - 1].active()) && (Main.tile[m, n + 1].wall == 27 || Main.tile[m, n + 1].active()))
61172 {
61173 Main.tile[m, n].active(active: false);
61174 Main.tile[m, n].wall = 27;
61175 }
61176 }
61177 }
61178 for (int num24 = num18; num24 < num19; num24++)
61179 {
61180 for (int num25 = num20; num25 < num21; num25++)
61181 {
61182 if (Main.tile[num24, num25].type == 30)
61183 {
61184 if (Main.tile[num24 - 1, num25].wall == 27 && Main.tile[num24 + 1, num25].wall == 27 && !Main.tile[num24 - 1, num25].active() && !Main.tile[num24 + 1, num25].active())
61185 {
61186 Main.tile[num24, num25].active(active: false);
61187 Main.tile[num24, num25].wall = 27;
61188 }
61189 if (!TileID.Sets.BasicChest[Main.tile[num24, num25 - 1].type] && Main.tile[num24 - 1, num25].wall == 27 && Main.tile[num24 + 1, num25].type == 30 && Main.tile[num24 + 2, num25].wall == 27 && !Main.tile[num24 - 1, num25].active() && !Main.tile[num24 + 2, num25].active())
61190 {
61191 Main.tile[num24, num25].active(active: false);
61192 Main.tile[num24, num25].wall = 27;
61193 Main.tile[num24 + 1, num25].active(active: false);
61194 Main.tile[num24 + 1, num25].wall = 27;
61195 }
61196 if (Main.tile[num24, num25 - 1].wall == 27 && Main.tile[num24, num25 + 1].wall == 27 && !Main.tile[num24, num25 - 1].active() && !Main.tile[num24, num25 + 1].active())
61197 {
61198 Main.tile[num24, num25].active(active: false);
61199 Main.tile[num24, num25].wall = 27;
61200 }
61201 }
61202 }
61203 }
61204 for (int num26 = num18; num26 < num19; num26++)
61205 {
61206 for (int num27 = num21; num27 > num20; num27--)
61207 {
61208 bool flag4 = false;
61209 if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 30)
61210 {
61211 int num28 = -1;
61212 for (int num29 = 0; num29 < 2; num29++)
61213 {
61214 if (!SolidTile(num26 + num28, num27) && Main.tile[num26 + num28, num27].wall == 0)
61215 {
61216 int num30 = 0;
61217 int num31 = num27;
61218 int num32 = num27;
61219 while (Main.tile[num26, num31].active() && Main.tile[num26, num31].type == 30 && !SolidTile(num26 + num28, num31) && Main.tile[num26 + num28, num31].wall == 0)
61220 {
61221 num31--;
61222 num30++;
61223 }
61224 num31++;
61225 int num33 = num31 + 1;
61226 if (num30 > 4)
61227 {
61228 if (genRand.Next(2) == 0)
61229 {
61230 num31 = num32 - 1;
61231 bool flag5 = true;
61232 for (int num34 = num26 - 2; num34 <= num26 + 2; num34++)
61233 {
61234 for (int num35 = num31 - 2; num35 <= num31; num35++)
61235 {
61236 if (num34 != num26 && Main.tile[num34, num35].active())
61237 {
61238 flag5 = false;
61239 }
61240 }
61241 }
61242 if (flag5)
61243 {
61244 Main.tile[num26, num31].active(active: false);
61245 Main.tile[num26, num31 - 1].active(active: false);
61246 Main.tile[num26, num31 - 2].active(active: false);
61247 PlaceTile(num26, num31, 10, mute: true);
61248 flag4 = true;
61249 }
61250 }
61251 if (!flag4)
61252 {
61253 for (int num36 = num33; num36 < num32; num36++)
61254 {
61255 Main.tile[num26, num36].type = 124;
61256 }
61257 }
61258 }
61259 }
61260 num28 = 1;
61261 }
61262 }
61263 if (flag4)
61264 {
61265 break;
61266 }
61267 }
61268 }
61269 int num37 = genRand.Next(1, 2);
61270 if (genRand.Next(4) == 0)
61271 {
61272 num37 = 0;
61273 }
61274 if (genRand.Next(6) == 0)
61275 {
61276 num37++;
61277 }
61278 if (genRand.Next(10) == 0)
61279 {
61280 num37++;
61281 }
61282 for (int num38 = 0; num38 < num37; num38++)
61283 {
61284 int num39 = 0;
61285 int num40 = genRand.Next(num18, num19);
61286 int num41 = genRand.Next(num20, num21);
61287 while (!Main.wallHouse[Main.tile[num40, num41].wall] || Main.tile[num40, num41].active())
61288 {
61289 num39++;
61290 if (num39 > 1000)
61291 {
61292 break;
61293 }
61294 num40 = genRand.Next(num18, num19);
61295 num41 = genRand.Next(num20, num21);
61296 }
61297 if (num39 > 1000)
61298 {
61299 break;
61300 }
61301 int num42 = num40;
61302 int num43 = num40;
61303 int num44 = num41;
61304 int num45 = num41;
61305 int num46 = 0;
61306 for (int num47 = 0; num47 < 2; num47++)
61307 {
61308 num42 = num40;
61309 num43 = num40;
61310 while (!Main.tile[num42, num41].active() && Main.wallHouse[Main.tile[num42, num41].wall])
61311 {
61312 num42--;
61313 }
61314 num42++;
61315 for (; !Main.tile[num43, num41].active() && Main.wallHouse[Main.tile[num43, num41].wall]; num43++)
61316 {
61317 }
61318 num43--;
61319 i = (num42 + num43) / 2;
61320 num44 = num41;
61321 num45 = num41;
61322 while (!Main.tile[num40, num44].active() && Main.wallHouse[Main.tile[num40, num44].wall])
61323 {
61324 num44--;
61325 }
61326 num44++;
61327 for (; !Main.tile[num40, num45].active() && Main.wallHouse[Main.tile[num40, num45].wall]; num45++)
61328 {
61329 }
61330 num45--;
61331 num41 = (num44 + num45) / 2;
61332 }
61333 num42 = num40;
61334 num43 = num40;
61335 while (!Main.tile[num42, num41].active() && !Main.tile[num42, num41 - 1].active() && !Main.tile[num42, num41 + 1].active())
61336 {
61337 num42--;
61338 }
61339 num42++;
61340 for (; !Main.tile[num43, num41].active() && !Main.tile[num43, num41 - 1].active() && !Main.tile[num43, num41 + 1].active(); num43++)
61341 {
61342 }
61343 num43--;
61344 num44 = num41;
61345 num45 = num41;
61346 while (!Main.tile[num40, num44].active() && !Main.tile[num40 - 1, num44].active() && !Main.tile[num40 + 1, num44].active())
61347 {
61348 num44--;
61349 }
61350 num44++;
61351 for (; !Main.tile[num40, num45].active() && !Main.tile[num40 - 1, num45].active() && !Main.tile[num40 + 1, num45].active(); num45++)
61352 {
61353 }
61354 num45--;
61355 num40 = (num42 + num43) / 2;
61356 num41 = (num44 + num45) / 2;
61357 int num48 = num43 - num42;
61358 num46 = num45 - num44;
61359 if (num48 <= 7 || num46 <= 5)
61360 {
61361 continue;
61362 }
61363 int num49 = 0;
61364 if (nearPicture2(i, num41))
61365 {
61366 num49 = -1;
61367 }
61368 if (num49 == 0)
61369 {
61370 PaintingEntry paintingEntry = RandHousePicture();
61371 if (!nearPicture(num40, num41))
61372 {
61373 PlaceTile(num40, num41, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style);
61374 }
61375 }
61376 }
61377 int num50;
61378 for (num50 = num18; num50 < num19; num50++)
61379 {
61380 bool flag6 = true;
61381 for (int num51 = num20; num51 < num21; num51++)
61382 {
61383 for (int num52 = num50 - 3; num52 <= num50 + 3; num52++)
61384 {
61385 if (Main.tile[num52, num51].active() && (!SolidTile(num52, num51) || Main.tile[num52, num51].type == 10))
61386 {
61387 flag6 = false;
61388 }
61389 }
61390 }
61391 if (flag6)
61392 {
61393 for (int num53 = num20; num53 < num21; num53++)
61394 {
61395 if (Main.tile[num50, num53].wall == 27 && !Main.tile[num50, num53].active())
61396 {
61397 PlaceTile(num50, num53, 124, mute: true);
61398 }
61399 }
61400 }
61401 num50 += genRand.Next(4);
61402 }
61403 for (int num54 = 0; num54 < 4; num54++)
61404 {
61405 int num55 = genRand.Next(num18 + 2, num19 - 1);
61406 int num56 = genRand.Next(num20 + 2, num21 - 1);
61407 while (Main.tile[num55, num56].wall != 27)
61408 {
61409 num55 = genRand.Next(num18 + 2, num19 - 1);
61410 num56 = genRand.Next(num20 + 2, num21 - 1);
61411 }
61412 while (Main.tile[num55, num56].active())
61413 {
61414 num56--;
61415 }
61416 for (; !Main.tile[num55, num56].active(); num56++)
61417 {
61418 }
61419 num56--;
61420 if (Main.tile[num55, num56].wall != 27)
61421 {
61422 continue;
61423 }
61424 if (genRand.Next(3) == 0)
61425 {
61426 int num57 = genRand.Next(9);
61427 if (num57 == 0)
61428 {
61429 num57 = 14;
61430 }
61431 if (num57 == 1)
61432 {
61433 num57 = 16;
61434 }
61435 if (num57 == 2)
61436 {
61437 num57 = 18;
61438 }
61439 if (num57 == 3)
61440 {
61441 num57 = 86;
61442 }
61443 if (num57 == 4)
61444 {
61445 num57 = 87;
61446 }
61447 if (num57 == 5)
61448 {
61449 num57 = 94;
61450 }
61451 if (num57 == 6)
61452 {
61453 num57 = 101;
61454 }
61455 if (num57 == 7)
61456 {
61457 num57 = 104;
61458 }
61459 if (num57 == 8)
61460 {
61461 num57 = 106;
61462 }
61463 PlaceTile(num55, num56, num57, mute: true);
61464 }
61465 else if (GenVars.statueList != null)
61466 {
61467 int num58 = genRand.Next(2, GenVars.statueList.Length);
61468 PlaceTile(num55, num56, GenVars.statueList[num58].X, mute: true, forced: true, -1, GenVars.statueList[num58].Y);
61469 }
61470 }
61471 for (int num59 = 0; num59 < 40; num59++)
61472 {
61473 int num60 = genRand.Next(num18 + 2, num19 - 1);
61474 int num61 = genRand.Next(num20 + 2, num21 - 1);
61475 while (Main.tile[num60, num61].wall != 27)
61476 {
61477 num60 = genRand.Next(num18 + 2, num19 - 1);
61478 num61 = genRand.Next(num20 + 2, num21 - 1);
61479 }
61480 while (Main.tile[num60, num61].active())
61481 {
61482 num61--;
61483 }
61484 for (; !Main.tile[num60, num61].active(); num61++)
61485 {
61486 }
61487 num61--;
61488 if (Main.tile[num60, num61].wall == 27 && genRand.Next(2) == 0)
61489 {
61490 int style = genRand.Next(22, 26);
61491 PlaceTile(num60, num61, 186, mute: true, forced: false, -1, style);
61492 }
61493 }
61494 for (int num62 = 0; num62 < 20; num62++)
61495 {
61496 int num63 = genRand.Next(num18 + 2, num19 - 1);
61497 int num64 = genRand.Next(num20 + 2, num21 - 1);
61498 while (Main.tile[num63, num64].wall != 27)
61499 {
61500 num63 = genRand.Next(num18 + 2, num19 - 1);
61501 num64 = genRand.Next(num20 + 2, num21 - 1);
61502 }
61503 while (Main.tile[num63, num64].active())
61504 {
61505 num64--;
61506 }
61507 for (; !Main.tile[num63, num64].active(); num64++)
61508 {
61509 }
61510 num64--;
61511 if (Main.tile[num63, num64].wall == 27 && genRand.Next(2) == 0)
61512 {
61513 int x = genRand.Next(31, 34);
61514 PlaceSmallPile(num63, num64, x, 1, 185);
61515 }
61516 }
61517 for (int num65 = 0; num65 < 15; num65++)
61518 {
61519 int num66 = genRand.Next(num18 + 2, num19 - 1);
61520 int num67 = genRand.Next(num20 + 2, num21 - 1);
61521 while (Main.tile[num66, num67].wall != 27)
61522 {
61523 num66 = genRand.Next(num18 + 2, num19 - 1);
61524 num67 = genRand.Next(num20 + 2, num21 - 1);
61525 }
61526 while (Main.tile[num66, num67].active())
61527 {
61528 num67--;
61529 }
61530 while (num67 > 0 && !Main.tile[num66, num67 - 1].active())
61531 {
61532 num67--;
61533 }
61534 if (Main.tile[num66, num67].wall != 27)
61535 {
61536 continue;
61537 }
61538 int num68 = 4;
61539 int style2 = 0;
61540 if (genRand.Next(10) < 9)
61541 {
61542 num68 = -1;
61543 }
61544 else
61545 {
61546 num68 = 34;
61547 style2 = genRand.Next(6);
61548 }
61549 if (num68 <= 0)
61550 {
61551 continue;
61552 }
61553 PlaceTile(num66, num67, num68, mute: true, forced: false, -1, style2);
61554 if (Main.tile[num66, num67].type != num68)
61555 {
61556 continue;
61557 }
61558 if (num68 == 4)
61559 {
61560 Main.tile[num66, num67].frameX += 54;
61561 continue;
61562 }
61563 int num69 = num66;
61564 int num70 = num67;
61565 num67 = num70 - Main.tile[num69, num70].frameY % 54 / 18;
61566 num66 = Main.tile[num69, num70].frameX / 18;
61567 if (num66 > 2)
61568 {
61569 num66 -= 3;
61570 }
61571 num66 = num69 - num66;
61572 short num71 = 54;
61573 if (Main.tile[num66, num67].frameX > 0)
61574 {
61575 num71 = -54;
61576 }
61577 for (int num72 = num66; num72 < num66 + 3; num72++)
61578 {
61579 for (int num73 = num67; num73 < num67 + 3; num73++)
61580 {
61581 Main.tile[num72, num73].frameX += num71;
61582 }
61583 }
61584 }
61585 }
61586
61587 public static void CountTiles(int X)
61588 {
61589 if (X == 0)
61590 {
61591 totalEvil = totalEvil2;
61592 totalBlood = totalBlood2;
61593 totalSolid = totalSolid2;
61594 totalGood = totalGood2;
61595 tGood = (byte)Math.Round((double)totalGood / (double)totalSolid * 100.0);
61596 tEvil = (byte)Math.Round((double)totalEvil / (double)totalSolid * 100.0);
61597 tBlood = (byte)Math.Round((double)totalBlood / (double)totalSolid * 100.0);
61598 if (tGood == 0 && totalGood > 0)
61599 {
61600 tGood = 1;
61601 }
61602 if (tEvil == 0 && totalEvil > 0)
61603 {
61604 tEvil = 1;
61605 }
61606 if (tBlood == 0 && totalBlood > 0)
61607 {
61608 tBlood = 1;
61609 }
61610 if (Main.netMode == 2)
61611 {
61612 NetMessage.SendData(57);
61613 }
61614 totalEvil2 = 0;
61615 totalSolid2 = 0;
61616 totalGood2 = 0;
61617 totalBlood2 = 0;
61618 }
61619 ushort num = 0;
61620 ushort num2 = 0;
61621 int num3 = 0;
61622 int num4 = 0;
61623 int num5 = 0;
61624 do
61625 {
61626 int num6;
61627 int num7;
61628 if (num4 == 0)
61629 {
61630 num6 = 0;
61631 num5 = (int)(Main.worldSurface + 1.0);
61632 num7 = 5;
61633 }
61634 else
61635 {
61636 num6 = num5;
61638 num7 = 1;
61639 }
61640 for (int i = num6; i < num5; i++)
61641 {
61642 Tile tile = Main.tile[X, i];
61643 if (tile == null)
61644 {
61645 tile = (Main.tile[X, i] = new Tile());
61646 }
61647 num = tile.type;
61648 if (num != 0 || tile.active())
61649 {
61650 if (num == num2)
61651 {
61652 num3 += num7;
61653 continue;
61654 }
61655 tileCounts[num2] += num3;
61656 num2 = num;
61657 num3 = num7;
61658 }
61659 }
61660 tileCounts[num2] += num3;
61661 num3 = 0;
61662 num4++;
61663 }
61664 while (num4 < 2);
61665 AddUpAlignmentCounts();
61666 }
61667
61668 public static void AddUpAlignmentCounts(bool clearCounts = false)
61669 {
61670 if (clearCounts)
61671 {
61672 totalEvil2 = 0;
61673 totalSolid2 = 0;
61674 totalGood2 = 0;
61675 totalBlood2 = 0;
61676 }
61677 for (int i = 0; i < TileID.Sets.HallowCountCollection.Count; i++)
61678 {
61679 totalGood2 += tileCounts[TileID.Sets.HallowCountCollection[i]];
61680 }
61681 for (int j = 0; j < TileID.Sets.CorruptCountCollection.Count; j++)
61682 {
61683 totalEvil2 += tileCounts[TileID.Sets.CorruptCountCollection[j]];
61684 }
61685 for (int k = 0; k < TileID.Sets.CrimsonCountCollection.Count; k++)
61686 {
61687 totalBlood2 += tileCounts[TileID.Sets.CrimsonCountCollection[k]];
61688 }
61689 totalSolid2 += tileCounts[2] + tileCounts[477] + tileCounts[1] + tileCounts[60] + tileCounts[53] + tileCounts[161];
61690 totalSolid2 += tileCounts[164] + tileCounts[109] + tileCounts[492] + tileCounts[117] + tileCounts[116];
61691 totalSolid2 += tileCounts[23] + tileCounts[661] + tileCounts[163] + tileCounts[112] + tileCounts[25];
61692 totalSolid2 += tileCounts[199] + tileCounts[662] + tileCounts[234] + tileCounts[203] + tileCounts[200];
61693 Array.Clear(tileCounts, 0, tileCounts.Length);
61694 }
61695
61696 public static void plantDye(int i, int j, bool exoticPlant = false)
61697 {
61698 UnifiedRandom unifiedRandom = (gen ? genRand : Main.rand);
61699 if (!Main.tile[i, j].active() || i < 95 || i > Main.maxTilesX - 95 || j < 95 || j > Main.maxTilesY - 95)
61700 {
61701 return;
61702 }
61703 int num = 90;
61704 if (exoticPlant)
61705 {
61706 num = 240;
61707 }
61708 if (((double)j < Main.worldSurface || remixWorldGen) && (!Main.tile[i, j - 1].active() || Main.tile[i, j - 1].type == 3 || Main.tile[i, j - 1].type == 51 || Main.tile[i, j - 1].type == 61 || Main.tile[i, j - 1].type == 73 || Main.tile[i, j - 1].type == 74 || Main.tile[i, j - 1].type == 184))
61709 {
61710 int num2 = Utils.Clamp(i - num, 1, Main.maxTilesX - 1 - 1);
61711 int num3 = Utils.Clamp(i + num, 1, Main.maxTilesX - 1 - 1);
61712 int num4 = Utils.Clamp(j - num, 1, Main.maxTilesY - 1 - 1);
61713 int num5 = Utils.Clamp(j + num, 1, Main.maxTilesY - 1 - 1);
61714 for (int k = num2; k < num3; k++)
61715 {
61716 for (int l = num4; l < num5; l++)
61717 {
61718 if (Main.tile[k, l].active() && Main.tile[k, l].type == 227 && (!exoticPlant || Main.tile[k, l].frameX >= 272) && (exoticPlant || Main.tile[k, l].frameX < 272))
61719 {
61720 return;
61721 }
61722 }
61723 }
61724 if (exoticPlant)
61725 {
61726 int type = Main.tile[i, j].type;
61727 bool flag = TileID.Sets.Conversion.Grass[type] || TileID.Sets.Conversion.Moss[type] || type == 0;
61728 if (Main.tile[i, j - 1].liquid > 0 && (Main.tile[i, j - 1].lava() || Main.tile[i, j - 1].honey()))
61729 {
61730 flag = false;
61731 }
61732 if (flag)
61733 {
61734 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, genRand.Next(8, 12));
61735 }
61736 }
61737 else if (Main.tile[i, j].type == 2 || Main.tile[i, j].type == 109)
61738 {
61739 if (unifiedRandom.Next(4) == 0)
61740 {
61741 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 4);
61742 }
61743 else
61744 {
61745 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 3);
61746 }
61747 }
61748 else if (Main.tile[i, j].type == 60)
61749 {
61750 if (unifiedRandom.Next(2) == 0)
61751 {
61752 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 2);
61753 }
61754 else
61755 {
61756 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 4);
61757 }
61758 }
61759 else if (Main.tile[i, j].type == 53 && Main.tile[i, j - 1].liquid == byte.MaxValue && Main.tile[i, j - 2].liquid == byte.MaxValue)
61760 {
61761 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 2);
61762 }
61763 else if (Main.tile[i, j].type == 80 && !Main.tile[i - 1, j - 1].active() && !Main.tile[i + 1, j - 1].active())
61764 {
61765 try
61766 {
61767 bool flag2 = true;
61768 for (int m = i - 5; m <= i + 5; m++)
61769 {
61770 for (int n = j - 5; n <= j + 15; n++)
61771 {
61772 if (Main.tile[m, n].active() && (Main.tile[m, n].type == 112 || Main.tile[m, n].type == 234))
61773 {
61774 flag2 = false;
61775 }
61776 }
61777 }
61778 if (flag2)
61779 {
61780 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 6);
61781 }
61782 }
61783 catch
61784 {
61785 }
61786 }
61787 }
61788 if ((!((double)j >= Main.worldSurface) && !remixWorldGen) || j >= Main.UnderworldLayer)
61789 {
61790 return;
61791 }
61792 if (!Main.tile[i, j - 1].active() || Main.tile[i, j - 1].type == 3 || Main.tile[i, j - 1].type == 51 || Main.tile[i, j - 1].type == 61 || Main.tile[i, j - 1].type == 73 || Main.tile[i, j - 1].type == 74 || Main.tile[i, j - 1].type == 184)
61793 {
61794 int num6 = Utils.Clamp(i - num, 1, Main.maxTilesX - 1 - 1);
61795 int num7 = Utils.Clamp(i + num, 1, Main.maxTilesX - 1 - 1);
61796 int num8 = Utils.Clamp(j - num, 1, Main.maxTilesY - 1 - 1);
61797 int num9 = Utils.Clamp(j + num, 1, Main.maxTilesY - 1 - 1);
61798 for (int num10 = num6; num10 < num7; num10++)
61799 {
61800 for (int num11 = num8; num11 < num9; num11++)
61801 {
61802 if (Main.tile[num10, num11].active() && Main.tile[num10, num11].type == 227 && (!exoticPlant || Main.tile[num10, num11].frameX >= 272) && (exoticPlant || Main.tile[num10, num11].frameX < 272))
61803 {
61804 return;
61805 }
61806 }
61807 }
61808 if (exoticPlant)
61809 {
61810 int type2 = Main.tile[i, j].type;
61812 {
61813 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, genRand.Next(8, 12));
61814 }
61815 }
61816 else if (Main.tile[i, j].type == 60)
61817 {
61818 if (unifiedRandom.Next(2) == 0)
61819 {
61820 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 2);
61821 }
61822 else if (unifiedRandom.Next(2) == 0)
61823 {
61824 PlaceTile(i, j - 1, 227, mute: true);
61825 }
61826 else
61827 {
61828 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 1);
61829 }
61830 }
61831 else if (Main.tile[i, j].type == 0 || Main.tile[i, j].type == 1 || Main.tile[i, j].type == 59)
61832 {
61833 if (unifiedRandom.Next(2) == 0)
61834 {
61835 PlaceTile(i, j - 1, 227, mute: true);
61836 }
61837 else
61838 {
61839 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 1);
61840 }
61841 }
61842 else if (Main.tile[i, j - 1].liquid == byte.MaxValue && Main.tile[i, j - 2].liquid == byte.MaxValue)
61843 {
61844 PlaceTile(i, j - 1, 227, mute: true, forced: false, -1, 5);
61845 }
61846 }
61847 if (Main.tile[i, j + 1].active() || exoticPlant)
61848 {
61849 return;
61850 }
61851 for (int num12 = i - num; num12 < i + num; num12++)
61852 {
61853 for (int num13 = j - num; num13 < j + num; num13++)
61854 {
61855 if (Main.tile[num12, num13].active() && Main.tile[num12, num13].type == 227)
61856 {
61857 return;
61858 }
61859 }
61860 }
61861 if (Main.tile[i, j].type == 0)
61862 {
61863 PlaceTile(i, j + 1, 227, mute: true, forced: false, -1, 7);
61864 }
61865 }
61866
61867 private static int MossConversion(int thisType, int otherType)
61868 {
61870 {
61871 return thisType;
61872 }
61873 if (Main.tileMoss[thisType] && otherType == 1)
61874 {
61875 return thisType;
61876 }
61877 return thisType switch
61878 {
61879 182 => 515,
61880 515 => 182,
61881 180 => 513,
61882 513 => 180,
61883 179 => 512,
61884 512 => 179,
61885 381 => 517,
61886 517 => 381,
61887 534 => 535,
61888 535 => 534,
61889 536 => 537,
61890 537 => 536,
61891 539 => 540,
61892 540 => 539,
61893 625 => 626,
61894 626 => 625,
61895 627 => 628,
61896 628 => 627,
61897 183 => 516,
61898 516 => 183,
61899 181 => 514,
61900 514 => 181,
61901 _ => 0,
61902 };
61903 }
61904
61905 public static void UpdateWorld()
61906 {
61907 if (gen)
61908 {
61909 return;
61910 }
61911 AllowedToSpreadInfections = true;
61913 if (power != null && power.GetIsUnlocked())
61914 {
61915 AllowedToSpreadInfections = !power.Enabled;
61916 }
61917 int wallDist = 3;
61920 foreach (TileEntity value in TileEntity.ByID.Values)
61921 {
61922 value.Update();
61923 }
61925 UpdateLunarApocalypse();
61926 if (Main.netMode != 1)
61927 {
61928 totalD++;
61929 if (totalD >= 30)
61930 {
61931 totalD = 0;
61932 CountTiles(totalX);
61933 totalX++;
61934 if (totalX >= Main.maxTilesX)
61935 {
61936 totalX = 0;
61937 }
61938 }
61939 }
61940 Liquid.skipCount++;
61941 if (Liquid.skipCount > 1)
61942 {
61944 Liquid.skipCount = 0;
61945 }
61946 int worldUpdateRate = GetWorldUpdateRate();
61947 if (worldUpdateRate == 0)
61948 {
61949 return;
61950 }
61951 double num = 3E-05f * (float)worldUpdateRate;
61952 double num2 = 1.5E-05f * (float)worldUpdateRate;
61953 double num3 = 2.5E-05f * (float)worldUpdateRate;
61954 bool checkNPCSpawns = false;
61955 spawnDelay++;
61956 if (Main.invasionType > 0 || Main.eclipse)
61957 {
61958 spawnDelay = 0;
61959 }
61960 if (spawnDelay >= 20)
61961 {
61962 checkNPCSpawns = true;
61963 spawnDelay = 0;
61964 if (prioritizedTownNPCType != 37)
61965 {
61966 for (int i = 0; i < 200; i++)
61967 {
61968 if (Main.npc[i].active && Main.npc[i].homeless && Main.npc[i].townNPC && Main.npc[i].type != 368)
61969 {
61970 prioritizedTownNPCType = Main.npc[i].type;
61971 break;
61972 }
61973 }
61974 }
61975 }
61976 double num4 = (double)(Main.maxTilesX * Main.maxTilesY) * num;
61977 int num5 = 151;
61978 int num6 = (int)Utils.Lerp(num5, (double)num5 * 2.8, Utils.Clamp((double)Main.maxTilesX / 4200.0 - 1.0, 0.0, 1.0));
61979 for (int j = 0; (double)j < num4; j++)
61980 {
61981 if (Main.rand.Next(num6 * 100) == 0)
61982 {
61983 PlantAlch();
61984 }
61985 int i2 = genRand.Next(10, Main.maxTilesX - 10);
61986 int j2 = genRand.Next(10, (int)Main.worldSurface - 1);
61987 UpdateWorld_OvergroundTile(i2, j2, checkNPCSpawns, wallDist);
61988 }
61989 if (Main.remixWorld)
61990 {
61991 for (int k = 0; (double)k < (double)(Main.maxTilesX * Main.maxTilesY) * num3; k++)
61992 {
61993 int i3 = genRand.Next(10, Main.maxTilesX - 10);
61994 int j3 = genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20);
61995 growGrassUnderground = true;
61996 UpdateWorld_UndergroundTile(i3, j3, checkNPCSpawns, wallDist);
61997 UpdateWorld_OvergroundTile(i3, j3, checkNPCSpawns, wallDist);
61998 growGrassUnderground = false;
61999 }
62000 }
62001 else
62002 {
62003 for (int l = 0; (double)l < (double)(Main.maxTilesX * Main.maxTilesY) * num2; l++)
62004 {
62005 int i4 = genRand.Next(10, Main.maxTilesX - 10);
62006 int j4 = genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20);
62007 UpdateWorld_UndergroundTile(i4, j4, checkNPCSpawns, wallDist);
62008 }
62009 }
62010 if (Main.dayTime && !Main.remixWorld)
62011 {
62012 return;
62013 }
62014 for (int m = 0; m < Main.dayRate; m++)
62015 {
62016 double num7 = (double)Main.maxTilesX / 4200.0;
62017 num7 *= (double)Star.starfallBoost;
62018 if (!((double)Main.rand.Next(8000) < 10.0 * num7))
62019 {
62020 continue;
62021 }
62022 int num8 = 12;
62023 int num9 = Main.rand.Next(Main.maxTilesX - 50) + 100;
62024 num9 *= 16;
62025 int num10 = Main.rand.Next((int)((double)Main.maxTilesY * 0.05));
62026 num10 *= 16;
62027 Vector2 position = new Vector2(num9, num10);
62028 int num11 = -1;
62029 if (Main.expertMode && Main.rand.Next(15) == 0)
62030 {
62031 int num12 = Player.FindClosest(position, 1, 1);
62032 if ((double)Main.player[num12].position.Y < Main.worldSurface * 16.0 && Main.player[num12].afkCounter < 3600)
62033 {
62034 int num13 = Main.rand.Next(1, 640);
62035 position.X = Main.player[num12].position.X + (float)Main.rand.Next(-num13, num13 + 1);
62036 num11 = num12;
62037 }
62038 }
62039 if (!Collision.SolidCollision(position, 16, 16))
62040 {
62041 float num14 = Main.rand.Next(-100, 101);
62042 float num15 = Main.rand.Next(200) + 100;
62043 float num16 = (float)Math.Sqrt(num14 * num14 + num15 * num15);
62044 num16 = (float)num8 / num16;
62045 num14 *= num16;
62046 num15 *= num16;
62047 Projectile.NewProjectile(new EntitySource_ByProjectileSourceId(11), position.X, position.Y, num14, num15, 720, 0, 0f, Main.myPlayer, 0f, num11);
62048 }
62049 }
62050 }
62051
62052 public static int GetWorldUpdateRate()
62053 {
62054 int result = Math.Min(Main.desiredWorldTilesUpdateRate, 24);
62056 {
62057 result = 0;
62058 }
62059 return result;
62060 }
62061
62062 private static void UpdateWorld_OvergroundTile(int i, int j, bool checkNPCSpawns, int wallDist)
62063 {
62064 int num = i - 1;
62065 int num2 = i + 2;
62066 int num3 = j - 1;
62067 int num4 = j + 2;
62068 if (num < 10)
62069 {
62070 num = 10;
62071 }
62072 if (num2 > Main.maxTilesX - 10)
62073 {
62074 num2 = Main.maxTilesX - 10;
62075 }
62076 if (num3 < 10)
62077 {
62078 num3 = 10;
62079 }
62080 if (num4 > Main.maxTilesY - 10)
62081 {
62082 num4 = Main.maxTilesY - 10;
62083 }
62084 if (Main.tile[i, j] == null)
62085 {
62086 return;
62087 }
62088 if (Main.tile[i, j].type == 655 && !NPC.AnyNPCs(262))
62089 {
62090 KillTile(i, j);
62091 if (Main.netMode == 2)
62092 {
62093 NetMessage.SendData(17, -1, -1, null, 0, i, j);
62094 }
62095 }
62096 if (Main.tile[i, j].type == 85)
62097 {
62098 TryGrowingAbigailsFlower(i, j);
62099 }
62100 else if (Main.tileAlch[Main.tile[i, j].type])
62101 {
62102 GrowAlch(i, j);
62103 }
62104 else if ((double)j < Main.worldSurface + 10.0 && (i < beachDistance || i > Main.maxTilesX - beachDistance) && !Main.tile[i, j].active())
62105 {
62106 int num5 = 3000;
62107 num5 -= (int)(Math.Abs(Main.windSpeedCurrent) * 1250f);
62108 if (Main.raining)
62109 {
62110 num5 -= (int)(1250f * Main.maxRaining);
62111 }
62112 if (num5 < 300)
62113 {
62114 num5 = 300;
62115 }
62116 if (genRand.Next(num5) == 0)
62117 {
62118 int k;
62119 for (k = j; (double)k < Main.worldSurface + 10.0 && !Main.tile[i, k].active() && k - j < 15; k++)
62120 {
62121 }
62122 if (Main.tile[i, k].active() && Main.tile[i, k].type == 53 && SolidTileAllowBottomSlope(i, k))
62123 {
62124 k--;
62125 int num6 = genRand.Next(2, 5);
62126 int num7 = genRand.Next(8, 11);
62127 int num8 = 0;
62128 for (int l = i - num7; l <= i + num7; l++)
62129 {
62130 for (int m = k - num7; m <= k + num7; m++)
62131 {
62132 if (Main.tile[l, m].active() && (Main.tile[l, m].type == 324 || Main.tile[l, m].type == 81))
62133 {
62134 num8++;
62135 }
62136 }
62137 }
62138 if (num8 < num6)
62139 {
62140 if (genRand.Next(2) == 0 && Main.tile[i, k].liquid >= 230)
62141 {
62142 PlaceTile(i, k, 81, mute: true);
62143 if (Main.netMode == 2 && Main.tile[i, k].active())
62144 {
62145 NetMessage.SendTileSquare(-1, i, k);
62146 }
62147 }
62148 else
62149 {
62150 PlaceTile(i, k, 324, mute: true, forced: false, -1, RollRandomSeaShellStyle());
62151 if (Main.netMode == 2 && Main.tile[i, k].active())
62152 {
62153 NetMessage.SendTileSquare(-1, i, k);
62154 }
62155 }
62156 }
62157 }
62158 }
62159 }
62160 if ((Main.tile[i, j].type == 596 || Main.tile[i, j].type == 616 || Main.tile[i, j].type == 595 || Main.tile[i, j].type == 615) && (Main.tile[i, j + 1].type == 199 || Main.tile[i, j + 1].type == 23))
62161 {
62162 KillTile(i, j);
62163 if (Main.netMode == 2)
62164 {
62165 NetMessage.SendTileSquare(-1, i, j);
62166 }
62167 }
62168 if ((Main.tile[i, j].type == 571 || (Main.tile[i, j].type == 60 && Main.tile[i, j - 1].liquid > 0)) && genRand.Next(5) == 0 && (!Main.tile[i, j - 1].active() || Main.tile[i, j - 1].type == 61 || Main.tile[i, j - 1].type == 74 || Main.tile[i, j - 1].type == 518) && (Main.tile[i, j].type != 60 || genRand.Next(30) == 0) && PlaceBamboo(i, j - 1))
62169 {
62170 NetMessage.SendTileSquare(-1, i, j - 1, 1, 2);
62171 }
62172 if (Main.tile[i, j].type == 518)
62173 {
62174 if (Main.tile[i, j].liquid == 0 || (Main.tile[i, j].liquid / 16 >= 9 && SolidTile(i, j - 1)) || (Main.tile[i, j - 1].liquid > 0 && Main.tile[i, j - 1].active()))
62175 {
62176 KillTile(i, j);
62177 if (Main.netMode == 2)
62178 {
62179 NetMessage.SendData(17, -1, -1, null, 0, i, j);
62180 }
62181 }
62182 else
62183 {
62184 CheckLilyPad(i, j);
62185 }
62186 }
62187 else if (Main.tile[i, j].type == 519)
62188 {
62189 CheckCatTail(i, j);
62190 if (Main.tile[i, j].active() && genRand.Next(8) == 0)
62191 {
62192 GrowCatTail(i, j);
62193 CheckCatTail(i, j);
62194 }
62195 }
62196 else if (Main.tile[i, j].liquid > 32)
62197 {
62198 if (Main.tile[i, j].active())
62199 {
62200 if (TileID.Sets.SlowlyDiesInWater[Main.tile[i, j].type])
62201 {
62202 KillTile(i, j);
62203 if (Main.netMode == 2)
62204 {
62205 NetMessage.SendData(17, -1, -1, null, 0, i, j);
62206 }
62207 }
62208 else if (Main.tile[i, j].type == 60)
62209 {
62210 UpdateWorld_GrassGrowth(i, j, num, num2, num3, num4, underground: false);
62211 }
62212 }
62213 else if (genRand.Next(600) == 0)
62214 {
62215 PlaceTile(i, j, 518, mute: true);
62216 if (Main.netMode == 2)
62217 {
62218 NetMessage.SendTileSquare(-1, i, j);
62219 }
62220 }
62221 else if (genRand.Next(600) == 0)
62222 {
62223 PlaceTile(i, j, 519, mute: true);
62224 if (Main.netMode == 2)
62225 {
62226 NetMessage.SendTileSquare(-1, i, j);
62227 }
62228 }
62229 }
62230 else if (Main.tile[i, j].nactive())
62231 {
62232 hardUpdateWorld(i, j);
62233 if (Main.rand.Next(3000) == 0)
62234 {
62235 plantDye(i, j);
62236 }
62237 else if (Main.hardMode && ((double)i < (double)Main.maxTilesX * 0.4 || (double)i > (double)Main.maxTilesX * 0.6) && Main.rand.Next(15000) == 0)
62238 {
62239 plantDye(i, j, exoticPlant: true);
62240 }
62241 if (Main.tile[i, j].type == 80)
62242 {
62243 if (genRand.Next(15) == 0)
62244 {
62245 GrowCactus(i, j);
62246 }
62247 }
62248 else if (Main.tile[i, j].type == 529)
62249 {
62250 if (CheckSeaOat(i, j) && genRand.Next(20) == 0)
62251 {
62252 GrowSeaOat(i, j);
62253 }
62254 }
62255 else if (TileID.Sets.Conversion.Sand[Main.tile[i, j].type])
62256 {
62257 if (!Main.tile[i, num3].active())
62258 {
62259 if (genRand.Next(25) == 0)
62260 {
62261 PlaceOasisPlant(i, num3, 530);
62262 if (Main.tile[i, num3].type == 530 && Main.netMode == 2)
62263 {
62264 NetMessage.SendTileSquare(-1, i - 1, num3 - 1, 3, 2);
62265 }
62266 }
62267 if (genRand.Next(20) != 0 || !PlantSeaOat(i, num3))
62268 {
62269 if (i < oceanDistance || i > Main.maxTilesX - oceanDistance)
62270 {
62271 if (genRand.Next(500) == 0)
62272 {
62273 int num9 = 7;
62274 int num10 = 6;
62275 int num11 = 0;
62276 for (int n = i - num9; n <= i + num9; n++)
62277 {
62278 for (int num12 = num3 - num9; num12 <= num3 + num9; num12++)
62279 {
62280 if (Main.tile[n, num12].active() && Main.tile[n, num12].type == 81)
62281 {
62282 num11++;
62283 }
62284 }
62285 }
62286 if (num11 < num10 && Main.tile[i, num3].liquid == byte.MaxValue && Main.tile[i, num3 - 1].liquid == byte.MaxValue && Main.tile[i, num3 - 2].liquid == byte.MaxValue && Main.tile[i, num3 - 3].liquid == byte.MaxValue && Main.tile[i, num3 - 4].liquid == byte.MaxValue)
62287 {
62288 PlaceTile(i, num3, 81, mute: true);
62289 if (Main.netMode == 2 && Main.tile[i, num3].active())
62290 {
62292 }
62293 }
62294 }
62295 }
62296 else if (i > beachDistance + 20 && i < Main.maxTilesX - beachDistance - 20 && genRand.Next(300) == 0)
62297 {
62298 GrowCactus(i, j);
62299 }
62300 }
62301 }
62302 }
62303 else if (Main.tile[i, j].type == 530)
62304 {
62305 if (!OasisPlantWaterCheck(i, j, boost: true))
62306 {
62307 KillTile(i, j);
62308 if (Main.netMode == 2)
62309 {
62310 NetMessage.SendData(17, -1, -1, null, 0, i, j);
62311 }
62312 }
62313 }
62314 else if (Main.tile[i, j].type == 147 || Main.tile[i, j].type == 161 || Main.tile[i, j].type == 163 || Main.tile[i, j].type == 164 || Main.tile[i, j].type == 200)
62315 {
62316 if (Main.rand.Next(10) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 2].active())
62317 {
62318 int num13 = i - 3;
62319 int num14 = i + 4;
62320 int num15 = 0;
62321 for (int num16 = num13; num16 < num14; num16++)
62322 {
62323 if (Main.tile[num16, j].type == 165 && Main.tile[num16, j].active())
62324 {
62325 num15++;
62326 }
62327 if (Main.tile[num16, j + 1].type == 165 && Main.tile[num16, j + 1].active())
62328 {
62329 num15++;
62330 }
62331 if (Main.tile[num16, j + 2].type == 165 && Main.tile[num16, j + 2].active())
62332 {
62333 num15++;
62334 }
62335 if (Main.tile[num16, j + 3].type == 165 && Main.tile[num16, j + 3].active())
62336 {
62337 num15++;
62338 }
62339 }
62340 if (num15 < 2)
62341 {
62342 PlaceTight(i, j + 1);
62343 SquareTileFrame(i, j + 1);
62344 if (Main.netMode == 2 && Main.tile[i, j + 1].active())
62345 {
62346 NetMessage.SendTileSquare(-1, i, j + 1, 1, 2);
62347 }
62348 }
62349 }
62350 }
62351 else if (Main.tile[i, j].type == 254)
62352 {
62353 if (Main.rand.Next((Main.tile[i, j].frameX + 10) / 10) == 0)
62354 {
62355 GrowPumpkin(i, j, 254);
62356 }
62357 }
62358 else if (Main.tile[i, j].type == 78 || Main.tile[i, j].type == 380 || Main.tile[i, j].type == 579)
62359 {
62360 if (!Main.tile[i, num3].active() && genRand.Next(2) == 0)
62361 {
62362 PlaceTile(i, num3, 3, mute: true);
62363 if (Main.netMode == 2 && Main.tile[i, num3].active())
62364 {
62366 }
62367 }
62368 }
62369 else if (TileID.Sets.SpreadOverground[Main.tile[i, j].type])
62370 {
62371 UpdateWorld_GrassGrowth(i, j, num, num2, num3, num4, underground: false);
62372 int type = Main.tile[i, j].type;
62373 if ((type == 32 || type == 352) && genRand.Next(3) == 0)
62374 {
62375 if (type == 32)
62376 {
62377 GrowSpike(i, j, 32, 23);
62378 }
62379 else
62380 {
62381 GrowSpike(i, j, 352, 199);
62382 }
62383 }
62384 }
62385 else if (Main.tileMoss[Main.tile[i, j].type] || TileID.Sets.tileMossBrick[Main.tile[i, j].type])
62386 {
62387 if (genRand.NextDouble() < 0.5)
62388 {
62389 int type2 = Main.tile[i, j].type;
62390 bool flag = false;
62391 TileColorCache color = Main.tile[i, j].BlockColorAndCoating();
62392 for (int num17 = num; num17 < num2; num17++)
62393 {
62394 for (int num18 = num3; num18 < num4; num18++)
62395 {
62396 if ((i != num17 || j != num18) && Main.tile[num17, num18].active() && (Main.tile[num17, num18].type == 1 || Main.tile[num17, num18].type == 38))
62397 {
62398 int type3 = Main.tile[num17, num18].type;
62399 int num19 = MossConversion(type2, type3);
62400 SpreadGrass(num17, num18, Main.tile[num17, num18].type, num19, repeat: false, color);
62401 if (Main.tile[num17, num18].type == num19)
62402 {
62403 SquareTileFrame(num17, num18);
62404 flag = true;
62405 }
62406 }
62407 }
62408 }
62409 if (Main.netMode == 2 && flag)
62410 {
62411 NetMessage.SendTileSquare(-1, i, j, 3);
62412 }
62413 if (genRand.Next(6) == 0)
62414 {
62415 int num20 = i;
62416 int num21 = j;
62417 switch (genRand.Next(4))
62418 {
62419 case 0:
62420 num20--;
62421 break;
62422 case 1:
62423 num20++;
62424 break;
62425 case 2:
62426 num21--;
62427 break;
62428 default:
62429 num21++;
62430 break;
62431 }
62432 if (!Main.tile[num20, num21].active())
62433 {
62434 if (PlaceTile(num20, num21, 184, mute: true))
62435 {
62436 Main.tile[num20, num21].CopyPaintAndCoating(Main.tile[i, j]);
62437 }
62438 if (Main.netMode == 2 && Main.tile[num20, num21].active())
62439 {
62441 }
62442 }
62443 }
62444 }
62445 }
62446 else if (Main.tile[i, j].type == 20)
62447 {
62448 if (genRand.Next(20) == 0)
62449 {
62450 AttemptToGrowTreeFromSapling(i, j, underground: false);
62451 }
62452 }
62453 else if (Main.tile[i, j].type == 595)
62454 {
62455 if (genRand.Next(5) == 0)
62456 {
62457 AttemptToGrowTreeFromSapling(i, j, underground: false);
62458 }
62459 }
62460 else if (Main.tile[i, j].type == 615)
62461 {
62462 if (genRand.Next(5) == 0)
62463 {
62464 AttemptToGrowTreeFromSapling(i, j, underground: false);
62465 }
62466 }
62467 else if (Main.tile[i, j].type == 3 && genRand.Next(20) == 0)
62468 {
62469 if (Main.tile[i, j].frameX != 144)
62470 {
62471 Main.tile[i, j].type = 73;
62472 if (Main.netMode == 2)
62473 {
62474 NetMessage.SendTileSquare(-1, i, j);
62475 }
62476 }
62477 }
62478 else if (Main.tile[i, j].type == 110 && genRand.Next(20) == 0 && Main.tile[i, j].frameX < 144)
62479 {
62480 Main.tile[i, j].type = 113;
62481 if (Main.netMode == 2)
62482 {
62483 NetMessage.SendTileSquare(-1, i, j);
62484 }
62485 }
62486 }
62487 else
62488 {
62489 if (Main.tile[i, j].wall == 62 && Main.tile[i, j].liquid == 0)
62490 {
62491 GrowWeb(i, j);
62492 }
62493 if (checkNPCSpawns)
62494 {
62495 TrySpawningTownNPC(i, j);
62496 }
62497 }
62498 if (AllowedToSpreadInfections)
62499 {
62500 if (Main.tile[i, j].wall == 81 || Main.tile[i, j].wall == 83 || (Main.tile[i, j].type == 199 && Main.tile[i, j].active()))
62501 {
62502 int num22 = i + genRand.Next(-2, 3);
62503 int num23 = j + genRand.Next(-2, 3);
62504 if (InWorld(num22, num23, 10) && Main.tile[num22, num23].wall >= 63 && Main.tile[num22, num23].wall <= 68)
62505 {
62506 bool flag2 = false;
62507 for (int num24 = i - wallDist; num24 < i + wallDist; num24++)
62508 {
62509 for (int num25 = j - wallDist; num25 < j + wallDist; num25++)
62510 {
62511 if (Main.tile[num24, num25].active())
62512 {
62513 int type4 = Main.tile[num24, num25].type;
62514 if (type4 == 199 || type4 == 200 || type4 == 201 || type4 == 203 || type4 == 205 || type4 == 234 || type4 == 352 || type4 == 662)
62515 {
62516 flag2 = true;
62517 break;
62518 }
62519 }
62520 }
62521 }
62522 if (flag2)
62523 {
62524 Main.tile[num22, num23].wall = 81;
62525 if (Main.netMode == 2)
62526 {
62528 }
62529 }
62530 }
62531 }
62532 else if (Main.tile[i, j].wall == 69 || Main.tile[i, j].wall == 3 || (Main.tile[i, j].type == 23 && Main.tile[i, j].active()))
62533 {
62534 int num26 = i + genRand.Next(-2, 3);
62535 int num27 = j + genRand.Next(-2, 3);
62536 if (InWorld(num26, num27, 10) && Main.tile[num26, num27].wall >= 63 && Main.tile[num26, num27].wall <= 68)
62537 {
62538 bool flag3 = false;
62539 for (int num28 = i - wallDist; num28 < i + wallDist; num28++)
62540 {
62541 for (int num29 = j - wallDist; num29 < j + wallDist; num29++)
62542 {
62543 if (Main.tile[num28, num29].active())
62544 {
62545 int type5 = Main.tile[num28, num29].type;
62546 if (type5 == 22 || type5 == 23 || type5 == 24 || type5 == 25 || type5 == 32 || type5 == 112 || type5 == 163 || type5 == 636 || type5 == 661)
62547 {
62548 flag3 = true;
62549 break;
62550 }
62551 }
62552 }
62553 }
62554 if (flag3)
62555 {
62556 Main.tile[num26, num27].wall = 69;
62557 if (Main.netMode == 2)
62558 {
62560 }
62561 }
62562 }
62563 }
62564 else if (Main.tile[i, j].wall == 70 || (Main.tile[i, j].type == 109 && Main.tile[i, j].active()))
62565 {
62566 int num30 = i + genRand.Next(-2, 3);
62567 int num31 = j + genRand.Next(-2, 3);
62568 if ((InWorld(num30, num31, 10) && Main.tile[num30, num31].wall == 63) || Main.tile[num30, num31].wall == 65 || Main.tile[num30, num31].wall == 66 || Main.tile[num30, num31].wall == 68)
62569 {
62570 bool flag4 = false;
62571 for (int num32 = i - wallDist; num32 < i + wallDist; num32++)
62572 {
62573 for (int num33 = j - wallDist; num33 < j + wallDist; num33++)
62574 {
62575 if (Main.tile[num32, num33].active())
62576 {
62577 int type6 = Main.tile[num32, num33].type;
62578 if (type6 == 109 || type6 == 110 || type6 == 113 || type6 == 115 || type6 == 116 || type6 == 117 || type6 == 164)
62579 {
62580 flag4 = true;
62581 break;
62582 }
62583 }
62584 }
62585 }
62586 if (flag4)
62587 {
62588 Main.tile[num30, num31].wall = 70;
62589 if (Main.netMode == 2)
62590 {
62592 }
62593 }
62594 }
62595 }
62596 SpreadDesertWalls(wallDist, i, j);
62597 }
62598 if (Main.tile[i, j].nactive())
62599 {
62600 if (Main.tile[i, j].type == 2 || Main.tile[i, j].type == 52 || Main.tile[i, j].type == 382 || (Main.tile[i, j].type == 192 && genRand.Next(10) == 0))
62601 {
62602 int num34 = 60;
62603 if (Main.tile[i, j].type == 52 || Main.tile[i, j].type == 382)
62604 {
62605 num34 = 20;
62606 }
62607 num34 = 1;
62608 if (genRand.Next(num34) == 0 && GrowMoreVines(i, j) && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62609 {
62610 bool flag5 = false;
62611 ushort type7 = 52;
62612 if (Main.tile[i, j].type == 382)
62613 {
62614 type7 = 382;
62615 }
62616 else if (Main.tile[i, j].type != 52)
62617 {
62618 if (Main.tile[i, j].wall == 68 || Main.tile[i, j].wall == 65 || Main.tile[i, j].wall == 66 || Main.tile[i, j].wall == 63)
62619 {
62620 type7 = 382;
62621 }
62622 else if (Main.tile[i, j + 1].wall == 68 || Main.tile[i, j + 1].wall == 65 || Main.tile[i, j + 1].wall == 66 || Main.tile[i, j + 1].wall == 63)
62623 {
62624 type7 = 382;
62625 }
62626 if (Main.remixWorld && genRand.Next(5) == 0)
62627 {
62628 type7 = 382;
62629 }
62630 }
62631 for (int num35 = j; num35 > j - 10; num35--)
62632 {
62633 if (Main.tile[i, num35].bottomSlope())
62634 {
62635 flag5 = false;
62636 break;
62637 }
62638 if (Main.tile[i, num35].active() && Main.tile[i, num35].type == 2 && !Main.tile[i, num35].bottomSlope())
62639 {
62640 flag5 = true;
62641 break;
62642 }
62643 }
62644 if (flag5)
62645 {
62646 int num36 = j + 1;
62647 Main.tile[i, num36].type = type7;
62648 Main.tile[i, num36].active(active: true);
62649 Main.tile[i, num36].CopyPaintAndCoating(Main.tile[i, j]);
62650 SquareTileFrame(i, num36);
62651 if (Main.netMode == 2)
62652 {
62654 }
62655 }
62656 }
62657 }
62658 else if (Main.tile[i, j].type == 61 && genRand.Next(3) == 0 && Main.tile[i, j].frameX < 144)
62659 {
62660 if (Main.rand.Next(4) == 0)
62661 {
62662 Main.tile[i, j].frameX = (short)(162 + genRand.Next(8) * 18);
62663 }
62664 Main.tile[i, j].type = 74;
62665 if (Main.netMode == 2)
62666 {
62667 NetMessage.SendTileSquare(-1, i, j);
62668 }
62669 }
62670 if ((Main.tile[i, j].type == 60 || Main.tile[i, j].type == 62) && GrowMoreVines(i, j))
62671 {
62672 int maxValue = 30;
62673 if (Main.tile[i, j].type == 62)
62674 {
62675 maxValue = 10;
62676 }
62677 if (genRand.Next(maxValue) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62678 {
62679 bool flag6 = false;
62680 for (int num37 = j; num37 > j - 10; num37--)
62681 {
62682 if (Main.tile[i, num37].bottomSlope())
62683 {
62684 flag6 = false;
62685 break;
62686 }
62687 if (Main.tile[i, num37].active() && Main.tile[i, num37].type == 60 && !Main.tile[i, num37].bottomSlope())
62688 {
62689 flag6 = true;
62690 break;
62691 }
62692 }
62693 if (flag6)
62694 {
62695 int num38 = j + 1;
62696 Main.tile[i, num38].type = 62;
62697 Main.tile[i, num38].active(active: true);
62698 Main.tile[i, num38].CopyPaintAndCoating(Main.tile[i, j]);
62699 SquareTileFrame(i, num38);
62700 if (Main.netMode == 2)
62701 {
62703 }
62704 }
62705 }
62706 }
62707 else if ((Main.tile[i, j].type == 70 || Main.tile[i, j].type == 528) && GrowMoreVines(i, j))
62708 {
62709 int maxValue2 = 70;
62710 if (Main.tile[i, j].type == 528)
62711 {
62712 maxValue2 = 7;
62713 }
62714 if (genRand.Next(maxValue2) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62715 {
62716 bool flag7 = false;
62717 for (int num39 = j; num39 > j - 10; num39--)
62718 {
62719 if (Main.tile[i, num39].bottomSlope())
62720 {
62721 flag7 = false;
62722 break;
62723 }
62724 if (Main.tile[i, num39].active() && Main.tile[i, num39].type == 70 && !Main.tile[i, num39].bottomSlope())
62725 {
62726 flag7 = true;
62727 break;
62728 }
62729 }
62730 if (flag7)
62731 {
62732 int num40 = j + 1;
62733 Main.tile[i, num40].type = 528;
62734 Main.tile[i, num40].active(active: true);
62735 Main.tile[i, num40].CopyPaintAndCoating(Main.tile[i, j]);
62736 SquareTileFrame(i, num40);
62737 if (Main.netMode == 2)
62738 {
62740 }
62741 }
62742 }
62743 }
62744 else if ((Main.tile[i, j].type == 109 || Main.tile[i, j].type == 115) && GrowMoreVines(i, j))
62745 {
62746 int maxValue3 = 60;
62747 if (Main.tile[i, j].type == 115)
62748 {
62749 maxValue3 = 20;
62750 }
62751 if (genRand.Next(maxValue3) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62752 {
62753 bool flag8 = false;
62754 for (int num41 = j; num41 > j - 10; num41--)
62755 {
62756 if (Main.tile[i, num41].bottomSlope())
62757 {
62758 flag8 = false;
62759 break;
62760 }
62761 if (Main.tile[i, num41].active() && Main.tile[i, num41].type == 109 && !Main.tile[i, num41].bottomSlope())
62762 {
62763 flag8 = true;
62764 break;
62765 }
62766 }
62767 if (flag8)
62768 {
62769 int num42 = j + 1;
62770 Main.tile[i, num42].type = 115;
62771 Main.tile[i, num42].active(active: true);
62772 Main.tile[i, num42].CopyPaintAndCoating(Main.tile[i, j]);
62773 SquareTileFrame(i, num42);
62774 if (Main.netMode == 2)
62775 {
62777 }
62778 }
62779 }
62780 }
62781 else if ((Main.tile[i, j].type == 23 || Main.tile[i, j].type == 661 || Main.tile[i, j].type == 636) && GrowMoreVines(i, j))
62782 {
62783 int maxValue4 = 60;
62784 if (Main.tile[i, j].type == 636)
62785 {
62786 maxValue4 = 20;
62787 }
62788 if (genRand.Next(maxValue4) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62789 {
62790 bool flag9 = false;
62791 for (int num43 = j; num43 > j - 10; num43--)
62792 {
62793 if (Main.tile[i, num43].bottomSlope())
62794 {
62795 flag9 = false;
62796 break;
62797 }
62798 if (Main.tile[i, num43].active() && (Main.tile[i, num43].type == 23 || Main.tile[i, num43].type == 661) && !Main.tile[i, num43].bottomSlope())
62799 {
62800 flag9 = true;
62801 break;
62802 }
62803 }
62804 if (flag9)
62805 {
62806 int num44 = j + 1;
62807 Main.tile[i, num44].type = 636;
62808 Main.tile[i, num44].active(active: true);
62809 Main.tile[i, num44].CopyPaintAndCoating(Main.tile[i, j]);
62810 SquareTileFrame(i, num44);
62811 if (Main.netMode == 2)
62812 {
62814 }
62815 }
62816 }
62817 }
62818 else if ((Main.tile[i, j].type == 199 || Main.tile[i, j].type == 662 || Main.tile[i, j].type == 205) && GrowMoreVines(i, j))
62819 {
62820 int maxValue5 = 60;
62821 if (Main.tile[i, j].type == 205)
62822 {
62823 maxValue5 = 20;
62824 }
62825 if (genRand.Next(maxValue5) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62826 {
62827 bool flag10 = false;
62828 for (int num45 = j; num45 > j - 10; num45--)
62829 {
62830 if (Main.tile[i, num45].bottomSlope())
62831 {
62832 flag10 = false;
62833 break;
62834 }
62835 if (Main.tile[i, num45].active() && (Main.tile[i, num45].type == 199 || Main.tile[i, num45].type == 662) && !Main.tile[i, num45].bottomSlope())
62836 {
62837 flag10 = true;
62838 break;
62839 }
62840 }
62841 if (flag10)
62842 {
62843 int num46 = j + 1;
62844 Main.tile[i, num46].type = 205;
62845 Main.tile[i, num46].active(active: true);
62846 Main.tile[i, num46].CopyPaintAndCoating(Main.tile[i, j]);
62847 SquareTileFrame(i, num46);
62848 if (Main.netMode == 2)
62849 {
62851 }
62852 }
62853 }
62854 }
62855 else if ((Main.tile[i, j].type == 633 || Main.tile[i, j].type == 638) && GrowMoreVines(i, j))
62856 {
62857 int maxValue6 = 70;
62858 if (Main.tile[i, j].type == 638)
62859 {
62860 maxValue6 = 7;
62861 }
62862 if (genRand.Next(maxValue6) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
62863 {
62864 bool flag11 = false;
62865 for (int num47 = j; num47 > j - 10; num47--)
62866 {
62867 if (Main.tile[i, num47].bottomSlope())
62868 {
62869 flag11 = false;
62870 break;
62871 }
62872 if (Main.tile[i, num47].active() && Main.tile[i, num47].type == 633 && !Main.tile[i, num47].bottomSlope())
62873 {
62874 flag11 = true;
62875 break;
62876 }
62877 }
62878 if (flag11)
62879 {
62880 int num48 = j + 1;
62881 Main.tile[i, num48].type = 638;
62882 Main.tile[i, num48].active(active: true);
62883 Main.tile[i, num48].CopyPaintAndCoating(Main.tile[i, j]);
62884 SquareTileFrame(i, num48);
62885 if (Main.netMode == 2)
62886 {
62888 }
62889 }
62890 }
62891 }
62892 }
62893 if (!Main.remixWorld && Main.dontStarveWorld && (float)Main.rand.Next(200) < 100f * Main.maxRaining && Main.maxRaining >= 0.2f)
62894 {
62895 DontStarveTryWateringTile(i, j);
62896 }
62897 }
62898
62899 public static bool AttemptToGrowTreeFromSapling(int x, int y, bool underground)
62900 {
62901 if (Main.netMode == 1)
62902 {
62903 return false;
62904 }
62905 if (!InWorld(x, y, 2))
62906 {
62907 return false;
62908 }
62909 Tile tile = Main.tile[x, y];
62910 if (tile == null || !tile.active())
62911 {
62912 return false;
62913 }
62914 bool flag = false;
62915 int num = 0;
62916 int num2 = -1;
62917 switch (tile.type)
62918 {
62919 case 20:
62920 switch (tile.frameX / 54)
62921 {
62922 case 10:
62923 flag = TryGrowingTreeByType(634, x, y);
62924 break;
62925 case 6:
62926 case 7:
62927 case 8:
62928 case 9:
62929 if (underground)
62930 {
62931 return false;
62932 }
62933 flag = GrowPalmTree(x, y);
62934 break;
62935 default:
62936 if (underground)
62937 {
62938 return false;
62939 }
62940 flag = GrowTree(x, y);
62941 break;
62942 }
62943 if (flag && PlayerLOS(x, y))
62944 {
62945 TreeGrowFXCheck(x, y);
62946 }
62947 return flag;
62948 case 595:
62949 num = tile.frameX / 54;
62950 num2 = 596;
62951 if (num == 0)
62952 {
62953 num2 = 596;
62954 }
62955 flag = TryGrowingTreeByType(num2, x, y);
62956 if (flag && PlayerLOS(x, y))
62957 {
62958 TreeGrowFXCheck(x, y);
62959 }
62960 return flag;
62961 case 615:
62962 num = tile.frameX / 54;
62963 num2 = 616;
62964 if (num == 0)
62965 {
62966 num2 = 616;
62967 }
62968 flag = TryGrowingTreeByType(num2, x, y);
62969 if (flag && PlayerLOS(x, y))
62970 {
62971 TreeGrowFXCheck(x, y);
62972 }
62973 return flag;
62974 case 590:
62975 if (!underground)
62976 {
62977 return false;
62978 }
62979 num = tile.frameX / 54;
62980 num2 = 587;
62981 switch (num)
62982 {
62983 case 0:
62984 num2 = 583;
62985 break;
62986 case 1:
62987 num2 = 584;
62988 break;
62989 case 2:
62990 num2 = 585;
62991 break;
62992 case 3:
62993 num2 = 586;
62994 break;
62995 case 4:
62996 num2 = 587;
62997 break;
62998 case 5:
62999 num2 = 588;
63000 break;
63001 case 6:
63002 num2 = 589;
63003 break;
63004 }
63005 flag = TryGrowingTreeByType(num2, x, y);
63006 if (flag && PlayerLOS(x, y))
63007 {
63008 TreeGrowFXCheck(x, y);
63009 }
63010 return flag;
63011 default:
63012 return false;
63013 }
63014 }
63015
63016 public static void DontStarveTryWateringTile(int x, int y)
63017 {
63018 Tile tile = Main.tile[x, y];
63019 if (tile.active() && TileObjectData.CheckWaterDeath(tile) && !IsSafeFromRain(x, y) && !HasAnyWireNearby(x, y, 0) && !TryToggleLight(x, y, false, skipWires: false))
63020 {
63021 KillTile(x, y);
63022 if (Main.netMode == 2)
63023 {
63024 NetMessage.SendData(17, -1, -1, null, 0, x, y);
63025 }
63026 }
63027 }
63028
63029 public static bool HasAnyWireNearby(int sourceX, int sourceY, int boxSpread)
63030 {
63031 int num = Utils.Clamp(sourceX - boxSpread, 0, Main.maxTilesX - 1);
63032 int num2 = Utils.Clamp(sourceX + boxSpread, 0, Main.maxTilesX - 1);
63033 int num3 = Utils.Clamp(sourceY - boxSpread, 0, Main.maxTilesY - 1);
63034 int num4 = Utils.Clamp(sourceY + boxSpread, 0, Main.maxTilesY - 1);
63035 for (int i = num; i <= num2; i++)
63036 {
63037 for (int j = num3; j <= num4; j++)
63038 {
63039 Tile tile = Main.tile[i, j];
63040 if (tile != null && (tile.wire() || tile.wire2() || tile.wire3() || tile.wire4()))
63041 {
63042 return true;
63043 }
63044 }
63045 }
63046 return false;
63047 }
63048
63049 public static bool IsSafeFromRain(int startX, int startY)
63050 {
63051 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
63052 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
63053 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
63054 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
63055 //IL_0036: Unknown result type (might be due to invalid IL or missing references)
63056 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
63057 //IL_0049: Unknown result type (might be due to invalid IL or missing references)
63058 //IL_004e: Unknown result type (might be due to invalid IL or missing references)
63059 //IL_0063: Unknown result type (might be due to invalid IL or missing references)
63060 //IL_0064: Unknown result type (might be due to invalid IL or missing references)
63061 //IL_006e: Unknown result type (might be due to invalid IL or missing references)
63062 //IL_0074: Unknown result type (might be due to invalid IL or missing references)
63063 //IL_0079: Unknown result type (might be due to invalid IL or missing references)
63064 Vector2D val = -Rain.GetRainFallVelocity().SafeNormalize(new Vector2(0f, 1f)).ToVector2D();
63065 Vector2D val2 = new Vector2D((double)startX, (double)startY) * 16.0 + Vector2D.One * 8.0;
63066 double num = 85.0;
63067 DelegateMethods.CheckResultOut = false;
63068 Utils.PlotTileLine(val2, val2 + val * 16.0 * num, 4.0, DelegateMethods.CheckStopForSolids);
63070 }
63071
63072 public static bool TryToggleLight(int x, int y, bool? forcedState, bool skipWires)
63073 {
63074 Tile tile = Main.tile[x, y];
63075 if (!tile.active())
63076 {
63077 return false;
63078 }
63079 switch (tile.type)
63080 {
63081 default:
63082 return false;
63083 case 4:
63084 Wiring.ToggleTorch(x, y, tile, forcedState);
63085 return true;
63086 case 33:
63087 case 49:
63088 case 174:
63089 case 372:
63090 case 646:
63091 Wiring.ToggleCandle(x, y, tile, forcedState);
63092 return true;
63093 case 405:
63095 return true;
63096 case 95:
63097 case 100:
63098 case 126:
63099 case 173:
63100 case 564:
63102 return true;
63103 case 92:
63105 return true;
63106 case 215:
63108 return true;
63109 case 34:
63111 return true;
63112 case 93:
63113 Wiring.ToggleLamp(x, y, tile, forcedState, skipWires);
63114 return true;
63115 case 42:
63117 return true;
63118 case 149:
63120 return true;
63121 }
63122 }
63123
63124 private static bool HasValidGroundForAbigailsFlowerBelowSpot(int x, int y)
63125 {
63126 if (!InWorld(x, y, 2))
63127 {
63128 return false;
63129 }
63130 Tile tile = Main.tile[x, y + 1];
63131 if (tile == null || !tile.active())
63132 {
63133 return false;
63134 }
63135 ushort type = tile.type;
63137 {
63138 return false;
63139 }
63140 if (type != 70 && type != 633 && !TileID.Sets.Conversion.Grass[type])
63141 {
63142 return false;
63143 }
63144 return SolidTileAllowBottomSlope(x, y + 1);
63145 }
63146
63147 private static bool TryGrowingAbigailsFlower(int i, int j)
63148 {
63149 if (Main.rand.Next(30) != 0)
63150 {
63151 return false;
63152 }
63153 int num = 1;
63155 {
63156 num = 2;
63157 }
63158 for (int k = 0; k < num; k++)
63159 {
63160 int num2 = genRand.Next(Math.Max(10, i - 10), Math.Min(Main.maxTilesX - 10, i + 10));
63161 int num3 = genRand.Next(Math.Max(10, j - 10), Math.Min(Main.maxTilesY - 10, j + 10));
63162 if (HasValidGroundForAbigailsFlowerBelowSpot(num2, num3) && NoNearbyAbigailsFlower(num2, num3) && PlaceTile(num2, num3, 624, mute: true))
63163 {
63164 if (Main.netMode == 2 && Main.tile[num2, num3] != null && Main.tile[num2, num3].active())
63165 {
63167 }
63168 return true;
63169 }
63170 }
63171 return false;
63172 }
63173
63174 private static bool NoNearbyAbigailsFlower(int i, int j)
63175 {
63176 int num = Utils.Clamp(i - 120, 10, Main.maxTilesX - 1 - 10);
63177 int num2 = Utils.Clamp(i + 120, 10, Main.maxTilesX - 1 - 10);
63178 int num3 = Utils.Clamp(j - 120, 10, Main.maxTilesY - 1 - 10);
63179 int num4 = Utils.Clamp(j + 120, 10, Main.maxTilesY - 1 - 10);
63180 for (int k = num; k <= num2; k++)
63181 {
63182 for (int l = num3; l <= num4; l++)
63183 {
63184 Tile tile = Main.tile[k, l];
63185 if (tile.active() && tile.type == 624)
63186 {
63187 return false;
63188 }
63189 }
63190 }
63191 return true;
63192 }
63193
63194 private static bool HasValidGroundForGlowTulipBelowSpot(int x, int y)
63195 {
63196 if (!InWorld(x, y, 2))
63197 {
63198 return false;
63199 }
63200 Tile tile = Main.tile[x, y + 1];
63201 if (tile == null || !tile.active())
63202 {
63203 return false;
63204 }
63205 ushort type = tile.type;
63207 {
63208 return false;
63209 }
63210 if (type != 0 && type != 70 && type != 633 && type != 59 && type != 225 && !TileID.Sets.Conversion.Grass[type] && !TileID.Sets.Conversion.Stone[type] && !Main.tileMoss[type])
63211 {
63212 return false;
63213 }
63214 return SolidTileAllowBottomSlope(x, y + 1);
63215 }
63216
63217 private static bool TryGrowingGlowTulip(int i, int j)
63218 {
63219 int num = 5;
63220 for (int k = 0; k < num; k++)
63221 {
63222 int num2 = genRand.Next(Math.Max(10, i - 10), Math.Min(Main.maxTilesX - 10, i + 10));
63223 int num3 = genRand.Next(Math.Max(10, j - 10), Math.Min(Main.maxTilesY - 10, j + 10));
63224 if (!HasValidGroundForGlowTulipBelowSpot(num2, num3) || !NoNearbyGlowTulips(num2, num3))
63225 {
63226 continue;
63227 }
63228 PlaceTile(num2, num3, 656, mute: true);
63229 Tile tile = Main.tile[num2, num3];
63230 if (tile.active() && tile.type == 656)
63231 {
63232 if (!generatingWorld && Main.netMode == 2 && Main.tile[num2, num3] != null && Main.tile[num2, num3].active())
63233 {
63235 }
63236 return true;
63237 }
63238 }
63239 return false;
63240 }
63241
63242 private static bool NoNearbyGlowTulips(int i, int j)
63243 {
63244 int num = Utils.Clamp(i - 120, 10, Main.maxTilesX - 1 - 10);
63245 int num2 = Utils.Clamp(i + 120, 10, Main.maxTilesX - 1 - 10);
63246 int num3 = Utils.Clamp(j - 120, 10, Main.maxTilesY - 1 - 10);
63247 int num4 = Utils.Clamp(j + 120, 10, Main.maxTilesY - 1 - 10);
63248 for (int k = num; k <= num2; k++)
63249 {
63250 for (int l = num3; l <= num4; l++)
63251 {
63252 Tile tile = Main.tile[k, l];
63253 if (tile.active() && tile.type == 656)
63254 {
63255 return false;
63256 }
63257 }
63258 }
63259 return true;
63260 }
63261
63262 private static void UpdateWorld_UndergroundTile(int i, int j, bool checkNPCSpawns, int wallDist)
63263 {
63264 int num = i - 1;
63265 int num2 = i + 2;
63266 int num3 = j - 1;
63267 int num4 = j + 2;
63268 if (num < 10)
63269 {
63270 num = 10;
63271 }
63272 if (num2 > Main.maxTilesX - 10)
63273 {
63274 num2 = Main.maxTilesX - 10;
63275 }
63276 if (num3 < 10)
63277 {
63278 num3 = 10;
63279 }
63280 if (num4 > Main.maxTilesY - 10)
63281 {
63282 num4 = Main.maxTilesY - 10;
63283 }
63284 if (Main.tile[i, j] == null)
63285 {
63286 return;
63287 }
63288 if (Main.tile[i, j].type == 655 && !NPC.AnyNPCs(262))
63289 {
63290 KillTile(i, j);
63291 if (Main.netMode == 2)
63292 {
63293 NetMessage.SendData(17, -1, -1, null, 0, i, j);
63294 }
63295 }
63296 if (Main.tileAlch[Main.tile[i, j].type])
63297 {
63298 GrowAlch(i, j);
63299 }
63300 else if (Main.tile[i, j].nactive())
63301 {
63302 hardUpdateWorld(i, j);
63303 if (Main.rand.Next(2500) == 0)
63304 {
63305 plantDye(i, j);
63306 }
63307 else if (Main.hardMode && Main.rand.Next(10000) == 0)
63308 {
63309 plantDye(i, j, exoticPlant: true);
63310 }
63311 if (Main.tile[i, j].type == 519)
63312 {
63313 CheckCatTail(i, j);
63314 if (Main.tile[i, j].active() && genRand.Next(2) == 0)
63315 {
63316 GrowCatTail(i, j);
63317 CheckCatTail(i, j);
63318 }
63319 }
63320 if (Main.tile[i, j].type == 549)
63321 {
63322 GrowCheckSeaweed(i, j);
63323 }
63324 else if (Main.tile[i, j].type == 53 && !Main.tile[i, j].topSlope() && !Main.tile[i, j].halfBrick() && !Main.tile[i, j - 1].active() && genRand.Next(20) == 0)
63325 {
63326 GrowCheckSeaweed(i, j);
63327 }
63328 else if (TileID.Sets.SpreadUnderground[Main.tile[i, j].type])
63329 {
63330 UpdateWorld_GrassGrowth(i, j, num, num2, num3, num4, underground: true);
63331 int type = Main.tile[i, j].type;
63332 if ((type == 32 || type == 352) && genRand.Next(3) == 0)
63333 {
63334 if (type == 32)
63335 {
63336 GrowSpike(i, j, 32, 23);
63337 }
63338 else
63339 {
63340 GrowSpike(i, j, 352, 199);
63341 }
63342 }
63343 }
63344 else if (Main.tile[i, j].type == 61 && genRand.Next(3) == 0)
63345 {
63346 if (Main.tile[i, j].frameX < 144)
63347 {
63348 if (Main.rand.Next(4) == 0)
63349 {
63350 Main.tile[i, j].frameX = (short)(162 + genRand.Next(8) * 18);
63351 }
63352 Main.tile[i, j].type = 74;
63353 if (Main.netMode == 2)
63354 {
63355 NetMessage.SendTileSquare(-1, i, j);
63356 }
63357 }
63358 }
63359 else if ((Main.tile[i, j].type == 60 || Main.tile[i, j].type == 62) && genRand.Next(5) == 0 && GrowMoreVines(i, j))
63360 {
63361 if (!Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
63362 {
63363 bool flag = false;
63364 for (int num5 = j; num5 > j - 10; num5--)
63365 {
63366 if (Main.tile[i, num5].bottomSlope())
63367 {
63368 flag = false;
63369 break;
63370 }
63371 if (Main.tile[i, num5].active() && Main.tile[i, num5].type == 60 && !Main.tile[i, num5].bottomSlope())
63372 {
63373 flag = true;
63374 break;
63375 }
63376 }
63377 if (flag)
63378 {
63379 int num6 = j + 1;
63380 Main.tile[i, num6].type = 62;
63381 Main.tile[i, num6].active(active: true);
63382 SquareTileFrame(i, num6);
63383 Main.tile[i, num6].CopyPaintAndCoating(Main.tile[i, num6 - 1]);
63384 if (Main.netMode == 2)
63385 {
63387 }
63388 }
63389 }
63390 }
63391 else if ((Main.tile[i, j].type == 633 || Main.tile[i, j].type == 638) && GrowMoreVines(i, j))
63392 {
63393 if (!Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
63394 {
63395 int maxValue = 70;
63396 if (Main.tile[i, j].type == 638)
63397 {
63398 maxValue = 7;
63399 }
63400 if (genRand.Next(maxValue) == 0)
63401 {
63402 bool flag2 = false;
63403 for (int num7 = j; num7 > j - 10; num7--)
63404 {
63405 if (Main.tile[i, num7].bottomSlope())
63406 {
63407 flag2 = false;
63408 break;
63409 }
63410 if (Main.tile[i, num7].active() && Main.tile[i, num7].type == 633 && !Main.tile[i, num7].bottomSlope())
63411 {
63412 flag2 = true;
63413 break;
63414 }
63415 }
63416 if (flag2)
63417 {
63418 int num8 = j + 1;
63419 Main.tile[i, num8].type = 638;
63420 Main.tile[i, num8].active(active: true);
63421 Main.tile[i, num8].CopyPaintAndCoating(Main.tile[i, num8 - 1]);
63422 SquareTileFrame(i, num8);
63423 if (Main.netMode == 2)
63424 {
63426 }
63427 }
63428 }
63429 }
63430 }
63431 else if ((Main.tile[i, j].type == 70 || Main.tile[i, j].type == 528) && GrowMoreVines(i, j))
63432 {
63433 if (!Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
63434 {
63435 int maxValue2 = 70;
63436 if (Main.tile[i, j].type == 528)
63437 {
63438 maxValue2 = 7;
63439 }
63440 if (genRand.Next(maxValue2) == 0)
63441 {
63442 bool flag3 = false;
63443 for (int num9 = j; num9 > j - 10; num9--)
63444 {
63445 if (Main.tile[i, num9].bottomSlope())
63446 {
63447 flag3 = false;
63448 break;
63449 }
63450 if (Main.tile[i, num9].active() && Main.tile[i, num9].type == 70 && !Main.tile[i, num9].bottomSlope())
63451 {
63452 flag3 = true;
63453 break;
63454 }
63455 }
63456 if (flag3)
63457 {
63458 int num10 = j + 1;
63459 Main.tile[i, num10].type = 528;
63460 Main.tile[i, num10].active(active: true);
63461 Main.tile[i, num10].CopyPaintAndCoating(Main.tile[i, num10 - 1]);
63462 SquareTileFrame(i, num10);
63463 if (Main.netMode == 2)
63464 {
63466 }
63467 }
63468 }
63469 }
63470 }
63471 else if ((Main.tile[i, j].type == 661 || Main.tile[i, j].type == 636) && GrowMoreVines(i, j))
63472 {
63473 if (!Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
63474 {
63475 int maxValue3 = 70;
63476 if (Main.tile[i, j].type == 636)
63477 {
63478 maxValue3 = 7;
63479 }
63480 if (genRand.Next(maxValue3) == 0)
63481 {
63482 bool flag4 = false;
63483 for (int num11 = j; num11 > j - 10; num11--)
63484 {
63485 if (Main.tile[i, num11].bottomSlope())
63486 {
63487 flag4 = false;
63488 break;
63489 }
63490 if (Main.tile[i, num11].active() && Main.tile[i, num11].type == 661 && !Main.tile[i, num11].bottomSlope())
63491 {
63492 flag4 = true;
63493 break;
63494 }
63495 }
63496 if (flag4)
63497 {
63498 int num12 = j + 1;
63499 Main.tile[i, num12].type = 636;
63500 Main.tile[i, num12].active(active: true);
63501 Main.tile[i, num12].CopyPaintAndCoating(Main.tile[i, num12 - 1]);
63502 SquareTileFrame(i, num12);
63503 if (Main.netMode == 2)
63504 {
63506 }
63507 }
63508 }
63509 }
63510 }
63511 else if ((Main.tile[i, j].type == 662 || Main.tile[i, j].type == 205) && GrowMoreVines(i, j))
63512 {
63513 if (!Main.tile[i, j + 1].active() && !Main.tile[i, j + 1].lava())
63514 {
63515 int maxValue4 = 70;
63516 if (Main.tile[i, j].type == 205)
63517 {
63518 maxValue4 = 7;
63519 }
63520 if (genRand.Next(maxValue4) == 0)
63521 {
63522 bool flag5 = false;
63523 for (int num13 = j; num13 > j - 10; num13--)
63524 {
63525 if (Main.tile[i, num13].bottomSlope())
63526 {
63527 flag5 = false;
63528 break;
63529 }
63530 if (Main.tile[i, num13].active() && Main.tile[i, num13].type == 662 && !Main.tile[i, num13].bottomSlope())
63531 {
63532 flag5 = true;
63533 break;
63534 }
63535 }
63536 if (flag5)
63537 {
63538 int num14 = j + 1;
63539 Main.tile[i, num14].type = 205;
63540 Main.tile[i, num14].active(active: true);
63541 Main.tile[i, num14].CopyPaintAndCoating(Main.tile[i, num14 - 1]);
63542 SquareTileFrame(i, num14);
63543 if (Main.netMode == 2)
63544 {
63546 }
63547 }
63548 }
63549 }
63550 }
63551 else if ((Main.tile[i, j].type == 60 || Main.tile[i, j].type == 62) && genRand.Next(80) == 0 && !PlayerLOS(i, j))
63552 {
63553 bool flag6 = true;
63554 int num15 = j;
63555 if (Main.tile[i, j].type == 60)
63556 {
63557 num15++;
63558 }
63559 for (int k = i; k < i + 2; k++)
63560 {
63561 int num16 = num15 - 1;
63562 if (!AnchorValid(Framing.GetTileSafely(k, num16), AnchorType.SolidTile) || Main.tile[k, num16].bottomSlope())
63563 {
63564 flag6 = false;
63565 }
63566 if (Main.tile[k, num16].liquid > 0 || Main.wallHouse[Main.tile[k, num16].wall])
63567 {
63568 flag6 = false;
63569 }
63570 if (!flag6)
63571 {
63572 break;
63573 }
63574 for (int l = num15; l < num15 + 2; l++)
63575 {
63576 if ((Main.tile[k, l].active() && (!Main.tileCut[Main.tile[k, l].type] || Main.tile[k, l].type == 444)) || Main.tile[k, l].lava())
63577 {
63578 flag6 = false;
63579 }
63580 if (!flag6)
63581 {
63582 break;
63583 }
63584 }
63585 if (!flag6)
63586 {
63587 break;
63588 }
63589 }
63590 if (flag6 && CountNearBlocksTypes(i, j, 20, 1, 444) > 0)
63591 {
63592 flag6 = false;
63593 }
63594 if (flag6)
63595 {
63596 for (int m = i; m < i + 2; m++)
63597 {
63598 Main.tile[m, num15 - 1].slope(0);
63599 Main.tile[m, num15 - 1].halfBrick(halfBrick: false);
63600 for (int n = num15; n < num15 + 2; n++)
63601 {
63602 if (Main.tile[m, n].active())
63603 {
63604 KillTile(m, n);
63605 }
63606 }
63607 }
63608 for (int num17 = i; num17 < i + 2; num17++)
63609 {
63610 for (int num18 = num15; num18 < num15 + 2; num18++)
63611 {
63612 Main.tile[num17, num18].active(active: true);
63613 Main.tile[num17, num18].type = 444;
63614 Main.tile[num17, num18].frameX = (short)((num17 - i) * 18);
63615 Main.tile[num17, num18].frameY = (short)((num18 - num15) * 18);
63616 }
63617 }
63618 if (Main.netMode == 2)
63619 {
63620 NetMessage.SendTileSquare(-1, i, num15 - 1, 2, 3);
63621 }
63622 }
63623 }
63624 else if (Main.tile[i, j].type == 396 && genRand.Next(80) == 0 && !PlayerLOS(i, j))
63625 {
63626 bool flag7 = true;
63627 int num19 = j - 1;
63628 for (int num20 = i; num20 < i + 2; num20++)
63629 {
63630 int num21 = num19 + 1;
63631 if (!AnchorValid(Framing.GetTileSafely(num20, num21), AnchorType.SolidTile) || Main.tile[num20, num21].topSlope())
63632 {
63633 flag7 = false;
63634 }
63635 if (Main.tile[num20, num21].liquid > 0 || Main.wallHouse[Main.tile[num20, num21].wall])
63636 {
63637 flag7 = false;
63638 }
63639 if (!flag7)
63640 {
63641 break;
63642 }
63643 for (int num22 = num19 - 2; num22 < num19; num22++)
63644 {
63645 if ((Main.tile[num20, num22].active() && (!Main.tileCut[Main.tile[num20, num22].type] || Main.tile[num20, num22].type == 485)) || Main.tile[num20, num22].lava())
63646 {
63647 flag7 = false;
63648 }
63649 if (!flag7)
63650 {
63651 break;
63652 }
63653 }
63654 if (!flag7)
63655 {
63656 break;
63657 }
63658 }
63659 if (flag7 && CountNearBlocksTypes(i, j, 20, 1, 485) > 0)
63660 {
63661 flag7 = false;
63662 }
63663 if (flag7)
63664 {
63665 bool flag8 = true;
63666 for (int num23 = -1; num23 >= -3; num23--)
63667 {
63668 if (Main.tile[i, j + num23].active())
63669 {
63670 flag8 = false;
63671 break;
63672 }
63673 }
63674 if (flag8)
63675 {
63676 PlaceTile(i, j - 1, 485, mute: true, forced: false, -1, genRand.Next(4));
63677 if (Main.netMode == 2)
63678 {
63679 NetMessage.SendTileSquare(-1, i, j - 2, 2, 2);
63680 }
63681 }
63682 }
63683 }
63684 else if (Main.tile[i, j].type == 69)
63685 {
63686 GrowSpike(i, j, 69, 60);
63687 }
63688 else if (Main.tile[i, j].type == 147 || Main.tile[i, j].type == 161 || Main.tile[i, j].type == 163 || Main.tile[i, j].type == 164 || Main.tile[i, j].type == 200)
63689 {
63690 if (Main.rand.Next(10) == 0 && !Main.tile[i, j + 1].active() && !Main.tile[i, j + 2].active())
63691 {
63692 int num24 = i - 3;
63693 int num25 = i + 4;
63694 int num26 = 0;
63695 for (int num27 = num24; num27 < num25; num27++)
63696 {
63697 if (Main.tile[num27, j].type == 165 && Main.tile[num27, j].active())
63698 {
63699 num26++;
63700 }
63701 if (Main.tile[num27, j + 1].type == 165 && Main.tile[num27, j + 1].active())
63702 {
63703 num26++;
63704 }
63705 if (Main.tile[num27, j + 2].type == 165 && Main.tile[num27, j + 2].active())
63706 {
63707 num26++;
63708 }
63709 if (Main.tile[num27, j + 3].type == 165 && Main.tile[num27, j + 3].active())
63710 {
63711 num26++;
63712 }
63713 }
63714 if (num26 < 2)
63715 {
63716 PlaceTight(i, j + 1);
63717 SquareTileFrame(i, j + 1);
63718 if (Main.netMode == 2 && Main.tile[i, j + 1].active())
63719 {
63720 NetMessage.SendTileSquare(-1, i, j + 1, 1, 2);
63721 }
63722 }
63723 }
63724 }
63725 else if (Main.tileMoss[Main.tile[i, j].type] || TileID.Sets.tileMossBrick[Main.tile[i, j].type])
63726 {
63727 int type2 = Main.tile[i, j].type;
63728 bool flag9 = false;
63729 TileColorCache color = Main.tile[i, j].BlockColorAndCoating();
63730 for (int num28 = num; num28 < num2; num28++)
63731 {
63732 for (int num29 = num3; num29 < num4; num29++)
63733 {
63734 if ((i != num28 || j != num29) && Main.tile[num28, num29].active() && (Main.tile[num28, num29].type == 1 || Main.tile[num28, num29].type == 38))
63735 {
63736 int type3 = Main.tile[num28, num29].type;
63737 int num30 = MossConversion(type2, type3);
63738 SpreadGrass(num28, num29, Main.tile[num28, num29].type, num30, repeat: false, color);
63739 if (Main.tile[num28, num29].type == num30)
63740 {
63741 SquareTileFrame(num28, num29);
63742 flag9 = true;
63743 }
63744 }
63745 }
63746 }
63747 if (Main.netMode == 2 && flag9)
63748 {
63749 NetMessage.SendTileSquare(-1, i, j, 3);
63750 }
63751 if (genRand.Next(6) == 0)
63752 {
63753 int num31 = i;
63754 int num32 = j;
63755 switch (genRand.Next(4))
63756 {
63757 case 0:
63758 num31--;
63759 break;
63760 case 1:
63761 num31++;
63762 break;
63763 case 2:
63764 num32--;
63765 break;
63766 default:
63767 num32++;
63768 break;
63769 }
63770 if (!Main.tile[num31, num32].active())
63771 {
63772 if (PlaceTile(num31, num32, 184, mute: true))
63773 {
63774 Main.tile[num31, num32].CopyPaintAndCoating(Main.tile[i, j]);
63775 }
63776 if (Main.netMode == 2 && Main.tile[num31, num32].active())
63777 {
63779 }
63780 }
63781 }
63782 }
63783 else if (Main.tile[i, j].type == 20)
63784 {
63785 if (genRand.Next(5) == 0)
63786 {
63787 AttemptToGrowTreeFromSapling(i, j, underground: true);
63788 }
63789 }
63790 else if (Main.tile[i, j].type == 590)
63791 {
63792 if (genRand.Next(5) == 0)
63793 {
63794 AttemptToGrowTreeFromSapling(i, j, underground: true);
63795 }
63796 }
63797 else if (Main.tile[i, j].type == 595)
63798 {
63799 if (genRand.Next(5) == 0)
63800 {
63801 AttemptToGrowTreeFromSapling(i, j, underground: true);
63802 }
63803 }
63804 else if (Main.tile[i, j].type == 615 && genRand.Next(5) == 0)
63805 {
63806 AttemptToGrowTreeFromSapling(i, j, underground: true);
63807 }
63808 }
63809 else
63810 {
63811 if (Main.tile[i, j].wall == 62 && Main.tile[i, j].liquid == 0)
63812 {
63813 GrowWeb(i, j);
63814 }
63815 if (checkNPCSpawns)
63816 {
63817 TrySpawningTownNPC(i, j);
63818 }
63819 }
63820 if (AllowedToSpreadInfections)
63821 {
63822 if (Main.tile[i, j].wall == 81 || Main.tile[i, j].wall == 83 || (Main.tile[i, j].type == 199 && Main.tile[i, j].active()))
63823 {
63824 int num33 = i + genRand.Next(-2, 3);
63825 int num34 = j + genRand.Next(-2, 3);
63826 if (InWorld(num33, num34, 10) && Main.tile[num33, num34].wall >= 63 && Main.tile[num33, num34].wall <= 68)
63827 {
63828 bool flag10 = false;
63829 for (int num35 = i - wallDist; num35 < i + wallDist; num35++)
63830 {
63831 for (int num36 = j - wallDist; num36 < j + wallDist; num36++)
63832 {
63833 if (Main.tile[num35, num36].active())
63834 {
63835 int type4 = Main.tile[num35, num36].type;
63836 if (type4 == 199 || type4 == 200 || type4 == 201 || type4 == 203 || type4 == 205 || type4 == 234 || type4 == 352 || type4 == 662)
63837 {
63838 flag10 = true;
63839 break;
63840 }
63841 }
63842 }
63843 }
63844 if (flag10)
63845 {
63846 Main.tile[num33, num34].wall = 81;
63847 if (Main.netMode == 2)
63848 {
63850 }
63851 }
63852 }
63853 }
63854 else if (Main.tile[i, j].wall == 69 || Main.tile[i, j].wall == 3 || (Main.tile[i, j].type == 23 && Main.tile[i, j].active()))
63855 {
63856 int num37 = i + genRand.Next(-2, 3);
63857 int num38 = j + genRand.Next(-2, 3);
63858 if (InWorld(num37, num38, 10) && Main.tile[num37, num38].wall >= 63 && Main.tile[num37, num38].wall <= 68)
63859 {
63860 bool flag11 = false;
63861 for (int num39 = i - wallDist; num39 < i + wallDist; num39++)
63862 {
63863 for (int num40 = j - wallDist; num40 < j + wallDist; num40++)
63864 {
63865 if (Main.tile[num39, num40].active())
63866 {
63867 int type5 = Main.tile[num39, num40].type;
63868 if (type5 == 22 || type5 == 23 || type5 == 24 || type5 == 25 || type5 == 32 || type5 == 112 || type5 == 163 || type5 == 636 || type5 == 661)
63869 {
63870 flag11 = true;
63871 break;
63872 }
63873 }
63874 }
63875 }
63876 if (flag11)
63877 {
63878 Main.tile[num37, num38].wall = 69;
63879 if (Main.netMode == 2)
63880 {
63882 }
63883 }
63884 }
63885 }
63886 else if (Main.tile[i, j].wall == 70 || (Main.tile[i, j].type == 109 && Main.tile[i, j].active()))
63887 {
63888 int num41 = i + genRand.Next(-2, 3);
63889 int num42 = j + genRand.Next(-2, 3);
63890 if ((InWorld(num41, num42, 10) && Main.tile[num41, num42].wall == 63) || Main.tile[num41, num42].wall == 65 || Main.tile[num41, num42].wall == 66 || Main.tile[num41, num42].wall == 68)
63891 {
63892 bool flag12 = false;
63893 for (int num43 = i - wallDist; num43 < i + wallDist; num43++)
63894 {
63895 for (int num44 = j - wallDist; num44 < j + wallDist; num44++)
63896 {
63897 if (Main.tile[num43, num44].active())
63898 {
63899 int type6 = Main.tile[num43, num44].type;
63900 if (type6 == 109 || type6 == 110 || type6 == 113 || type6 == 115 || type6 == 116 || type6 == 117 || type6 == 164)
63901 {
63902 flag12 = true;
63903 break;
63904 }
63905 }
63906 }
63907 }
63908 if (flag12)
63909 {
63910 Main.tile[num41, num42].wall = 70;
63911 if (Main.netMode == 2)
63912 {
63914 }
63915 }
63916 }
63917 }
63918 SpreadDesertWalls(wallDist, i, j);
63919 }
63920 if (!Main.tile[i, j].nactive())
63921 {
63922 return;
63923 }
63924 if (Main.tile[i, j].type == 61 && genRand.Next(3) == 0 && Main.tile[i, j].frameX < 144)
63925 {
63926 if (Main.rand.Next(4) == 0)
63927 {
63928 Main.tile[i, j].frameX = (short)(162 + genRand.Next(8) * 18);
63929 }
63930 Main.tile[i, j].type = 74;
63931 if (Main.netMode == 2)
63932 {
63933 NetMessage.SendTileSquare(-1, i, j);
63934 }
63935 }
63936 if ((Main.tile[i, j].type == 60 || Main.tile[i, j].type == 62) && GrowMoreVines(i, j))
63937 {
63938 int maxValue5 = 30;
63939 if (Main.tile[i, j].type == 62)
63940 {
63941 maxValue5 = 10;
63942 }
63943 if (genRand.Next(maxValue5) != 0 || Main.tile[i, j + 1].active() || Main.tile[i, j + 1].lava())
63944 {
63945 return;
63946 }
63947 bool flag13 = false;
63948 for (int num45 = j; num45 > j - 10; num45--)
63949 {
63950 if (Main.tile[i, num45].bottomSlope())
63951 {
63952 flag13 = false;
63953 break;
63954 }
63955 if (Main.tile[i, num45].active() && Main.tile[i, num45].type == 60 && !Main.tile[i, num45].bottomSlope())
63956 {
63957 flag13 = true;
63958 break;
63959 }
63960 }
63961 if (flag13)
63962 {
63963 int num46 = j + 1;
63964 Main.tile[i, num46].type = 62;
63965 Main.tile[i, num46].active(active: true);
63966 Main.tile[i, num46].CopyPaintAndCoating(Main.tile[i, num46 - 1]);
63967 SquareTileFrame(i, num46);
63968 if (Main.netMode == 2)
63969 {
63971 }
63972 }
63973 }
63974 else if ((Main.tile[i, j].type == 633 || Main.tile[i, j].type == 638) && GrowMoreVines(i, j))
63975 {
63976 int maxValue6 = 70;
63977 if (Main.tile[i, j].type == 638)
63978 {
63979 maxValue6 = 7;
63980 }
63981 if (genRand.Next(maxValue6) != 0 || Main.tile[i, j + 1].active() || Main.tile[i, j + 1].lava())
63982 {
63983 return;
63984 }
63985 bool flag14 = false;
63986 for (int num47 = j; num47 > j - 10; num47--)
63987 {
63988 if (Main.tile[i, num47].bottomSlope())
63989 {
63990 flag14 = false;
63991 break;
63992 }
63993 if (Main.tile[i, num47].active() && Main.tile[i, num47].type == 633 && !Main.tile[i, num47].bottomSlope())
63994 {
63995 flag14 = true;
63996 break;
63997 }
63998 }
63999 if (flag14)
64000 {
64001 int num48 = j + 1;
64002 Main.tile[i, num48].type = 638;
64003 Main.tile[i, num48].active(active: true);
64004 Main.tile[i, num48].CopyPaintAndCoating(Main.tile[i, num48 - 1]);
64005 SquareTileFrame(i, num48);
64006 if (Main.netMode == 2)
64007 {
64009 }
64010 }
64011 }
64012 else
64013 {
64014 if ((Main.tile[i, j].type != 70 && Main.tile[i, j].type != 528) || !GrowMoreVines(i, j))
64015 {
64016 return;
64017 }
64018 int maxValue7 = 70;
64019 if (Main.tile[i, j].type == 528)
64020 {
64021 maxValue7 = 7;
64022 }
64023 if (genRand.Next(maxValue7) != 0 || Main.tile[i, j + 1].active() || Main.tile[i, j + 1].lava())
64024 {
64025 return;
64026 }
64027 bool flag15 = false;
64028 for (int num49 = j; num49 > j - 10; num49--)
64029 {
64030 if (Main.tile[i, num49].bottomSlope())
64031 {
64032 flag15 = false;
64033 break;
64034 }
64035 if (Main.tile[i, num49].active() && Main.tile[i, num49].type == 70 && !Main.tile[i, num49].bottomSlope())
64036 {
64037 flag15 = true;
64038 break;
64039 }
64040 }
64041 if (flag15)
64042 {
64043 int num50 = j + 1;
64044 Main.tile[i, num50].type = 528;
64045 Main.tile[i, num50].active(active: true);
64046 Main.tile[i, num50].CopyPaintAndCoating(Main.tile[i, num50 - 1]);
64047 SquareTileFrame(i, num50);
64048 if (Main.netMode == 2)
64049 {
64051 }
64052 }
64053 }
64054 }
64055
64056 private static void GrowWeb(int i, int j)
64057 {
64058 if (genRand.Next(10) != 0)
64059 {
64060 return;
64061 }
64062 int num = genRand.Next(2, 4);
64063 int num2 = i - num;
64064 int num3 = i + num;
64065 int num4 = j - num;
64066 int num5 = j + num;
64067 bool flag = false;
64068 for (int k = num2; k <= num3; k++)
64069 {
64070 for (int l = num4; l <= num5; l++)
64071 {
64072 if (SolidTile(k, l))
64073 {
64074 flag = true;
64075 break;
64076 }
64077 }
64078 }
64079 if (flag && !Main.tile[i, j].active())
64080 {
64081 PlaceTile(i, j, 51, mute: true);
64082 TileFrame(i, j, resetFrame: true);
64083 if (Main.netMode == 2)
64084 {
64085 NetMessage.SendTileSquare(-1, i, j, 1);
64086 }
64087 }
64088 }
64089
64091 {
64092 bool num = (double)Main.dungeonX > (double)Main.maxTilesX * 0.5;
64093 int num2 = (int)(num ? ((double)Main.maxTilesX * 0.15) : ((double)Main.maxTilesX * 0.65));
64094 int num3 = (int)(num ? ((double)Main.maxTilesX * 0.35) : ((double)Main.maxTilesX * 0.85));
64095 int num4 = (int)Main.worldSurface;
64097 int width = num3 - num2;
64098 int height = underworldLayer - num4;
64099 Rectangle rectangle = new Rectangle(num2, num4, width, height);
64100 int num5 = 2500;
64101 while (num5 > 0)
64102 {
64103 bool flag = num5 < 500;
64104 bool flag2 = num5 < 200;
64105 num5--;
64106 Point point = new Point(rectangle.X + genRand.Next(rectangle.Width), rectangle.Y + genRand.Next(rectangle.Height));
64107 Tile tile = Main.tile[point.X, point.Y];
64108 int num6 = 500;
64109 bool flag3 = false;
64110 while (!flag3)
64111 {
64112 num6--;
64113 if (num6 <= 0)
64114 {
64115 flag3 = true;
64116 }
64117 point.Y--;
64118 if (point.Y < rectangle.Y)
64119 {
64120 break;
64121 }
64122 tile = Main.tile[point.X, point.Y];
64123 if (tile != null && (flag2 || tile.active()))
64124 {
64125 if (tile.type == 60)
64126 {
64127 flag3 = true;
64128 }
64129 else if (flag && tile.type == 59)
64130 {
64131 flag3 = true;
64132 }
64133 }
64134 }
64135 if (tile == null)
64136 {
64137 continue;
64138 }
64139 bool num7 = tile.active() || flag2;
64140 bool flag4 = tile.type == 60 || (flag && tile.type == 59);
64141 if (num7 && flag4)
64142 {
64143 if (AttemptToGeneratePlanteraBulbAt(point.X, point.Y - 1, flag))
64144 {
64145 return true;
64146 }
64147 if (AttemptToGeneratePlanteraBulbAt(point.X - 1, point.Y - 1, flag))
64148 {
64149 return true;
64150 }
64151 if (AttemptToGeneratePlanteraBulbAt(point.X + 1, point.Y - 1, flag))
64152 {
64153 return true;
64154 }
64155 }
64156 }
64157 return false;
64158 }
64159
64160 private static bool AttemptToGeneratePlanteraBulbAt(int i, int j, bool forceBulb)
64161 {
64162 if (forceBulb)
64163 {
64164 int num = 0;
64165 for (int k = -2; k < 2; k++)
64166 {
64167 for (int l = -2; l < 2; l++)
64168 {
64169 int num2 = i + k;
64170 int num3 = j + l;
64171 Tile tile = Main.tile[num2, num3];
64172 if (tile.type == 59 || tile.type == 60)
64173 {
64174 num++;
64175 }
64176 else if (tile.active())
64177 {
64178 num--;
64179 }
64180 if (IsAContainer(tile) || tile.type == 226 || tile.type == 237 || tile.type == 10 || tile.type == 11 || tile.type == 26 || tile.type == 16 || tile.type == 15 || tile.type == 14 || tile.type == 104 || TileID.Sets.Paintings[tile.type] || tile.type == 158 || tile.type == 105 || tile.type == 531 || tile.type == 349 || tile.type == 138 || tile.type == 664 || tile.type == 665 || tile.type == 137 || tile.type == 443 || tile.type == 12 || tile.type == 665 || tile.type == 314)
64181 {
64182 num = -1;
64183 break;
64184 }
64185 }
64186 if (num <= -1)
64187 {
64188 break;
64189 }
64190 }
64191 if (num < 12)
64192 {
64193 return false;
64194 }
64195 for (int m = -2; m < 2; m++)
64196 {
64197 for (int n = -2; n < 2; n++)
64198 {
64199 int num4 = i + m;
64200 int num5 = j + n;
64201 bool num6 = m == -2 || m == 1 || n == -2 || n == 1;
64203 tile2.ClearTile();
64204 if (num6)
64205 {
64206 tile2.type = 60;
64207 tile2.active(active: true);
64208 }
64209 SquareTileFrame(num4, num5);
64210 }
64211 }
64212 PlaceJunglePlant(i, j, 238, 0, 0);
64213 if (Main.tile[i, j].type == 238)
64214 {
64215 SquareTileFrame(i, j);
64216 SquareTileFrame(i + 2, j);
64217 SquareTileFrame(i - 1, j);
64218 if (Main.netMode == 2)
64219 {
64220 NetMessage.SendTileSquare(-1, i, j, 8);
64221 }
64222 return true;
64223 }
64224 }
64225 else
64226 {
64227 PlaceJunglePlant(i, j, 238, 0, 0);
64228 if (Main.tile[i, j].type == 238)
64229 {
64230 SquareTileFrame(i, j);
64231 SquareTileFrame(i + 2, j);
64232 SquareTileFrame(i - 1, j);
64233 if (Main.netMode == 2)
64234 {
64235 NetMessage.SendTileSquare(-1, i, j, 5);
64236 }
64237 return true;
64238 }
64239 }
64240 return false;
64241 }
64242
64243 private static void UpdateWorld_GrassGrowth(int i, int j, int minI, int maxI, int minJ, int maxJ, bool underground)
64244 {
64245 if (!InWorld(i, j, 10))
64246 {
64247 return;
64248 }
64249 if (underground)
64250 {
64251 int type = Main.tile[i, j].type;
64252 int num = -1;
64253 int num2 = -1;
64254 int num3 = -1;
64255 int maxValue = 1;
64256 int num4 = type;
64257 int num5 = -1;
64258 switch (type)
64259 {
64260 case 23:
64261 num = 0;
64262 num2 = 59;
64263 num4 = 23;
64264 num5 = 661;
64265 num3 = 24;
64266 maxValue = 2;
64267 if (!AllowedToSpreadInfections)
64268 {
64269 return;
64270 }
64271 break;
64272 case 199:
64273 num = 0;
64274 num2 = 59;
64275 num4 = 199;
64276 num5 = 662;
64277 num3 = 201;
64278 maxValue = 2;
64279 if (!AllowedToSpreadInfections)
64280 {
64281 return;
64282 }
64283 break;
64284 case 661:
64285 num = 59;
64286 num2 = 0;
64287 num4 = 661;
64288 num5 = 23;
64289 num3 = 24;
64290 maxValue = 2;
64291 if (!AllowedToSpreadInfections)
64292 {
64293 return;
64294 }
64295 break;
64296 case 662:
64297 num = 59;
64298 num2 = 0;
64299 num4 = 662;
64300 num5 = 199;
64301 num3 = 201;
64302 maxValue = 2;
64303 if (!AllowedToSpreadInfections)
64304 {
64305 return;
64306 }
64307 break;
64308 case 60:
64309 num = 59;
64310 num3 = 61;
64311 maxValue = 10;
64312 break;
64313 case 70:
64314 num = 59;
64315 num3 = 71;
64316 maxValue = 10;
64317 break;
64318 case 633:
64319 num = 57;
64320 num3 = 637;
64321 maxValue = 2;
64322 break;
64323 }
64324 bool flag = false;
64325 if (num3 != -1 && !Main.tile[i, minJ].active() && genRand.Next(maxValue) == 0)
64326 {
64327 flag = true;
64328 if (PlaceTile(i, minJ, num3, mute: true))
64329 {
64330 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64331 }
64332 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64333 {
64335 }
64336 }
64337 if (num != -1)
64338 {
64339 bool flag2 = false;
64340 TileColorCache color = Main.tile[i, j].BlockColorAndCoating();
64341 for (int k = minI; k < maxI; k++)
64342 {
64343 for (int l = minJ; l < maxJ; l++)
64344 {
64345 if (!InWorld(k, l, 10) || (i == k && j == l) || !Main.tile[k, l].active())
64346 {
64347 continue;
64348 }
64349 if (Main.tile[k, l].type == num)
64350 {
64351 SpreadGrass(k, l, num, num4, repeat: false, color);
64352 if (Main.tile[k, l].type == num4)
64353 {
64354 SquareTileFrame(k, l);
64355 flag2 = true;
64356 }
64357 }
64358 else if (num2 > -1 && num5 > -1 && Main.tile[k, l].type == num2)
64359 {
64360 SpreadGrass(k, l, num2, num5, repeat: false, color);
64361 if (Main.tile[k, l].type == num5)
64362 {
64363 SquareTileFrame(k, l);
64364 flag2 = true;
64365 }
64366 }
64367 }
64368 }
64369 if (Main.netMode == 2 && flag2)
64370 {
64371 NetMessage.SendTileSquare(-1, i, j, 3);
64372 }
64373 }
64374 switch (type)
64375 {
64376 case 60:
64377 {
64378 if (flag || genRand.Next(25) != 0 || Main.tile[i, minJ].liquid != 0)
64379 {
64380 break;
64381 }
64382 if (Main.hardMode && NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3 && genRand.Next(60) == 0)
64383 {
64384 bool flag3 = true;
64385 int num6 = 150;
64386 for (int m = i - num6; m < i + num6; m += 2)
64387 {
64388 for (int n = j - num6; n < j + num6; n += 2)
64389 {
64390 if (m > 1 && m < Main.maxTilesX - 2 && n > 1 && n < Main.maxTilesY - 2 && Main.tile[m, n].active() && Main.tile[m, n].type == 238)
64391 {
64392 flag3 = false;
64393 break;
64394 }
64395 }
64396 }
64397 if (flag3)
64398 {
64399 PlaceJunglePlant(i, minJ, 238, 0, 0);
64400 SquareTileFrame(i, minJ);
64401 SquareTileFrame(i + 2, minJ);
64402 SquareTileFrame(i - 1, minJ);
64403 if (Main.tile[i, minJ].type == 238 && Main.netMode == 2)
64404 {
64405 NetMessage.SendTileSquare(-1, i, minJ, 5);
64406 }
64407 }
64408 }
64409 int maxValue2 = (Main.expertMode ? 30 : 40);
64410 if (Main.hardMode && NPC.downedMechBossAny && genRand.Next(maxValue2) == 0)
64411 {
64412 bool flag4 = true;
64413 int num7 = 60;
64414 if (Main.expertMode)
64415 {
64416 num7 -= 10;
64417 }
64418 for (int num8 = i - num7; num8 < i + num7; num8 += 2)
64419 {
64420 for (int num9 = j - num7; num9 < j + num7; num9 += 2)
64421 {
64422 if (num8 > 1 && num8 < Main.maxTilesX - 2 && num9 > 1 && num9 < Main.maxTilesY - 2 && Main.tile[num8, num9].active() && Main.tile[num8, num9].type == 236)
64423 {
64424 flag4 = false;
64425 break;
64426 }
64427 }
64428 }
64429 if (flag4)
64430 {
64431 PlaceJunglePlant(i, minJ, 236, genRand.Next(3), 0);
64432 SquareTileFrame(i, minJ);
64433 SquareTileFrame(i + 1, minJ + 1);
64434 if (Main.tile[i, minJ].type == 236 && Main.netMode == 2)
64435 {
64436 NetMessage.SendTileSquare(-1, i, minJ, 4);
64437 }
64438 }
64439 break;
64440 }
64441 PlaceJunglePlant(i, minJ, 233, genRand.Next(8), 0);
64442 if (Main.tile[i, minJ].type != 233)
64443 {
64444 break;
64445 }
64446 if (Main.netMode == 2)
64447 {
64448 NetMessage.SendTileSquare(-1, i, minJ, 4);
64449 break;
64450 }
64451 PlaceJunglePlant(i, minJ, 233, genRand.Next(12), 1);
64452 if (Main.tile[i, minJ].type == 233 && Main.netMode == 2)
64453 {
64454 NetMessage.SendTileSquare(-1, i, minJ, 3);
64455 }
64456 break;
64457 }
64458 case 70:
64459 if (Main.tile[i, j - 1].liquid > 0)
64460 {
64461 PlaceCatTail(i, j - 1);
64462 }
64463 if (genRand.Next(250) == 0 && GrowTree(i, j) && PlayerLOS(i, j))
64464 {
64465 TreeGrowFXCheck(i, j - 1);
64466 }
64467 break;
64468 }
64469 return;
64470 }
64471 int num10 = Main.tile[i, j].type;
64472 switch (num10)
64473 {
64474 case 2:
64475 case 23:
64476 case 32:
64477 case 109:
64478 case 199:
64479 case 352:
64480 case 477:
64481 case 492:
64482 case 661:
64483 case 662:
64484 {
64485 if (Main.halloween && genRand.Next(75) == 0 && (num10 == 2 || num10 == 109))
64486 {
64487 int num13 = 100;
64488 int num14 = 0;
64489 for (int num15 = i - num13; num15 < i + num13; num15 += 2)
64490 {
64491 for (int num16 = j - num13; num16 < j + num13; num16 += 2)
64492 {
64493 if (num15 > 1 && num15 < Main.maxTilesX - 2 && num16 > 1 && num16 < Main.maxTilesY - 2 && Main.tile[num15, num16].active() && Main.tile[num15, num16].type == 254)
64494 {
64495 num14++;
64496 }
64497 }
64498 }
64499 if (num14 < 6)
64500 {
64501 PlacePumpkin(i, minJ);
64502 if (Main.netMode == 2 && Main.tile[i, minJ].type == 254)
64503 {
64504 NetMessage.SendTileSquare(-1, i - 1, minJ - 1, 2, 2);
64505 }
64506 }
64507 }
64508 if (!Main.tile[i, minJ].active() && Main.tile[i, minJ].liquid == 0)
64509 {
64510 int num17 = -1;
64511 if (num10 == 2 && genRand.Next(12) == 0)
64512 {
64513 num17 = 3;
64514 }
64515 else if (num10 == 23 && genRand.Next(10) == 0)
64516 {
64517 num17 = 24;
64518 }
64519 else if (num10 == 199 && genRand.Next(10) == 0)
64520 {
64521 num17 = 201;
64522 }
64523 else if (num10 == 661 && genRand.Next(10) == 0)
64524 {
64525 num17 = 24;
64526 }
64527 else if (num10 == 662 && genRand.Next(10) == 0)
64528 {
64529 num17 = 201;
64530 }
64531 else if (num10 == 109 && genRand.Next(10) == 0)
64532 {
64533 num17 = 110;
64534 }
64535 else if (num10 == 633 && genRand.Next(10) == 0)
64536 {
64537 num17 = 637;
64538 }
64539 if (num17 != -1 && PlaceTile(i, minJ, num17, mute: true))
64540 {
64541 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64542 if (Main.netMode == 2)
64543 {
64545 }
64546 }
64547 }
64548 bool flag6 = false;
64549 switch (num10)
64550 {
64551 case 32:
64552 num10 = 23;
64553 if (!AllowedToSpreadInfections)
64554 {
64555 return;
64556 }
64557 break;
64558 case 352:
64559 num10 = 199;
64560 if (!AllowedToSpreadInfections)
64561 {
64562 return;
64563 }
64564 break;
64565 case 477:
64566 num10 = 2;
64567 break;
64568 case 492:
64569 num10 = 109;
64570 break;
64571 }
64572 int grass = num10;
64573 int num18 = -1;
64574 if (num10 == 23 || num10 == 661)
64575 {
64576 grass = 23;
64577 num18 = 661;
64578 }
64579 if (num10 == 199 || num10 == 662)
64580 {
64581 grass = 199;
64582 num18 = 662;
64583 }
64584 bool flag7 = AllowedToSpreadInfections && (num10 == 23 || num10 == 199 || num10 == 109 || num10 == 492 || num10 == 661 || num10 == 662) && InWorld(i, j, 10);
64585 for (int num19 = minI; num19 < maxI; num19++)
64586 {
64587 for (int num20 = minJ; num20 < maxJ; num20++)
64588 {
64589 if (!InWorld(num19, num20, 10) || (i == num19 && j == num20) || !Main.tile[num19, num20].active())
64590 {
64591 continue;
64592 }
64593 int type2 = Main.tile[num19, num20].type;
64594 if (!flag7 && type2 != 0 && (num18 == -1 || type2 != 59))
64595 {
64596 continue;
64597 }
64598 TileColorCache color3 = Main.tile[i, j].BlockColorAndCoating();
64599 if (type2 == 0 || (num18 > -1 && type2 == 59) || ((num10 == 23 || num10 == 661 || num10 == 199 || num10 == 662) && (type2 == 2 || type2 == 109 || type2 == 477 || type2 == 492)))
64600 {
64601 SpreadGrass(num19, num20, 0, grass, repeat: false, color3);
64602 if (num18 > -1)
64603 {
64604 SpreadGrass(num19, num20, 59, num18, repeat: false, color3);
64605 }
64606 if (AllowedToSpreadInfections && (num10 == 23 || num10 == 199 || num10 == 661 || num10 == 662))
64607 {
64608 SpreadGrass(num19, num20, 2, grass, repeat: false, color3);
64609 SpreadGrass(num19, num20, 109, grass, repeat: false, color3);
64610 SpreadGrass(num19, num20, 477, grass, repeat: false, color3);
64611 SpreadGrass(num19, num20, 492, grass, repeat: false, color3);
64612 if (num18 > -1)
64613 {
64614 SpreadGrass(num19, num20, 60, num18, repeat: false, color3);
64615 }
64616 }
64617 if (Main.tile[num19, num20].type == num10 || (num18 > -1 && Main.tile[num19, num20].type == num18))
64618 {
64619 SquareTileFrame(num19, num20);
64620 flag6 = true;
64621 }
64622 }
64623 if (type2 == 0 || ((num10 == 109 || num10 == 492) && (type2 == 2 || type2 == 477 || type2 == 23 || type2 == 199)))
64624 {
64625 SpreadGrass(num19, num20, 0, grass, repeat: false, color3);
64626 if (num10 == 109)
64627 {
64628 SpreadGrass(num19, num20, 2, grass, repeat: false, color3);
64629 }
64630 switch (num10)
64631 {
64632 case 492:
64633 SpreadGrass(num19, num20, 477, grass, repeat: false, color3);
64634 break;
64635 case 109:
64636 SpreadGrass(num19, num20, 477, 492, repeat: false, color3);
64637 break;
64638 }
64639 if ((num10 == 492 || num10 == 109) && AllowedToSpreadInfections)
64640 {
64641 SpreadGrass(num19, num20, 23, 109, repeat: false, color3);
64642 }
64643 if ((num10 == 492 || num10 == 109) && AllowedToSpreadInfections)
64644 {
64645 SpreadGrass(num19, num20, 199, 109, repeat: false, color3);
64646 }
64647 if (Main.tile[num19, num20].type == num10)
64648 {
64649 SquareTileFrame(num19, num20);
64650 flag6 = true;
64651 }
64652 }
64653 }
64654 }
64655 if (Main.netMode == 2 && flag6)
64656 {
64657 NetMessage.SendTileSquare(-1, i, j, 3);
64658 }
64659 break;
64660 }
64661 case 70:
64662 {
64663 if (!Main.tile[i, j].inActive())
64664 {
64665 if (!Main.tile[i, minJ].active() && genRand.Next(10) == 0)
64666 {
64667 PlaceTile(i, minJ, 71, mute: true);
64668 if (Main.tile[i, minJ].active())
64669 {
64670 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64671 }
64672 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64673 {
64675 }
64676 }
64677 if (genRand.Next(300) == 0)
64678 {
64679 bool flag8 = PlayerLOS(i, j);
64680 if (GrowTree(i, j) && flag8)
64681 {
64682 TreeGrowFXCheck(i, j - 1);
64683 }
64684 }
64685 }
64686 bool flag9 = false;
64687 TileColorCache color4 = Main.tile[i, j].BlockColorAndCoating();
64688 for (int num21 = minI; num21 < maxI; num21++)
64689 {
64690 for (int num22 = minJ; num22 < maxJ; num22++)
64691 {
64692 if ((i != num21 || j != num22) && Main.tile[num21, num22].active() && Main.tile[num21, num22].type == 59)
64693 {
64694 SpreadGrass(num21, num22, 59, num10, repeat: false, color4);
64695 if (Main.tile[num21, num22].type == num10)
64696 {
64697 SquareTileFrame(num21, num22);
64698 flag9 = true;
64699 }
64700 }
64701 }
64702 }
64703 if (Main.netMode == 2 && flag9)
64704 {
64705 NetMessage.SendTileSquare(-1, i, j, 3);
64706 }
64707 break;
64708 }
64709 case 60:
64710 {
64711 if (!Main.tile[i, minJ].active() && genRand.Next(7) == 0)
64712 {
64713 PlaceTile(i, minJ, 61, mute: true);
64714 if (Main.tile[i, minJ].active())
64715 {
64716 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64717 }
64718 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64719 {
64721 }
64722 }
64723 else if (genRand.Next(500) == 0 && (!Main.tile[i, minJ].active() || Main.tile[i, minJ].type == 61 || Main.tile[i, minJ].type == 74 || Main.tile[i, minJ].type == 69))
64724 {
64725 if (GrowTree(i, j) && PlayerLOS(i, j))
64726 {
64727 TreeGrowFXCheck(i, j - 1);
64728 }
64729 }
64730 else if (genRand.Next(25) == 0 && Main.tile[i, minJ].liquid == 0)
64731 {
64732 PlaceJunglePlant(i, minJ, 233, genRand.Next(8), 0);
64733 if (Main.tile[i, minJ].type == 233)
64734 {
64735 if (Main.netMode == 2)
64736 {
64737 NetMessage.SendTileSquare(-1, i, minJ, 4);
64738 }
64739 else
64740 {
64741 PlaceJunglePlant(i, minJ, 233, genRand.Next(12), 1);
64742 if (Main.tile[i, minJ].type == 233 && Main.netMode == 2)
64743 {
64744 NetMessage.SendTileSquare(-1, i, minJ, 3);
64745 }
64746 }
64747 }
64748 }
64749 bool flag10 = false;
64750 TileColorCache color5 = Main.tile[i, j].BlockColorAndCoating();
64751 for (int num23 = minI; num23 < maxI; num23++)
64752 {
64753 for (int num24 = minJ; num24 < maxJ; num24++)
64754 {
64755 if ((i != num23 || j != num24) && Main.tile[num23, num24].active() && Main.tile[num23, num24].type == 59)
64756 {
64757 SpreadGrass(num23, num24, 59, num10, repeat: false, color5);
64758 if (Main.tile[num23, num24].type == num10)
64759 {
64760 SquareTileFrame(num23, num24);
64761 flag10 = true;
64762 }
64763 }
64764 }
64765 }
64766 if (Main.netMode == 2 && flag10)
64767 {
64768 NetMessage.SendTileSquare(-1, i, j, 3);
64769 }
64770 break;
64771 }
64772 case 633:
64773 {
64774 if (!Main.tile[i, minJ].active() && genRand.Next(10) == 0)
64775 {
64776 PlaceTile(i, minJ, 637, mute: true);
64777 if (Main.tile[i, minJ].active())
64778 {
64779 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64780 }
64781 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64782 {
64784 }
64785 }
64786 TileColorCache color2 = Main.tile[i, j].BlockColorAndCoating();
64787 bool flag5 = false;
64788 for (int num11 = minI; num11 < maxI; num11++)
64789 {
64790 for (int num12 = minJ; num12 < maxJ; num12++)
64791 {
64792 if ((i != num11 || j != num12) && Main.tile[num11, num12].active() && Main.tile[num11, num12].type == 57)
64793 {
64794 SpreadGrass(num11, num12, 57, num10, repeat: false, color2);
64795 if (Main.tile[num11, num12].type == num10)
64796 {
64797 SquareTileFrame(num11, num12);
64798 flag5 = true;
64799 }
64800 }
64801 }
64802 }
64803 if (Main.netMode == 2 && flag5)
64804 {
64805 NetMessage.SendTileSquare(-1, i, j, 3);
64806 }
64807 break;
64808 }
64809 }
64810 }
64811
64812 private static void TrySpawningTownNPC(int x, int y)
64813 {
64814 bool flag = Main.tileSolid[379];
64815 Main.tileSolid[379] = true;
64816 if (prioritizedTownNPCType > 0)
64817 {
64818 if (Main.tile[x, y].wall == 34)
64819 {
64820 if (Main.rand.Next(4) == 0)
64821 {
64822 SpawnTownNPC(x, y);
64823 }
64824 }
64825 else
64826 {
64827 SpawnTownNPC(x, y);
64828 }
64829 }
64830 Main.tileSolid[379] = flag;
64831 }
64832
64833 public static void SpreadDesertWalls(int wallDist, int i, int j)
64834 {
64835 if (!InWorld(i, j, 10) || (!WallID.Sets.Conversion.Sandstone[Main.tile[i, j].wall] && (!Main.tile[i, j].active() || !TileID.Sets.Conversion.Sandstone[Main.tile[i, j].type]) && !WallID.Sets.Conversion.HardenedSand[Main.tile[i, j].wall]))
64836 {
64837 return;
64838 }
64839 int num = 0;
64840 int wall = Main.tile[i, j].wall;
64841 int type = Main.tile[i, j].type;
64842 if (WallID.Sets.Corrupt[wall] || TileID.Sets.Corrupt[type])
64843 {
64844 num = 1;
64845 }
64846 if (WallID.Sets.Hallow[wall] || TileID.Sets.Hallow[type])
64847 {
64848 num = 2;
64849 }
64850 if (WallID.Sets.Crimson[wall] || TileID.Sets.Crimson[type])
64851 {
64852 num = 3;
64853 }
64854 if (num == 0)
64855 {
64856 return;
64857 }
64858 int num2 = i + genRand.Next(-2, 3);
64859 int num3 = j + genRand.Next(-2, 3);
64860 bool flag = false;
64862 {
64863 switch (num)
64864 {
64865 case 3:
64866 {
64867 for (int m = i - wallDist; m < i + wallDist; m++)
64868 {
64869 for (int n = j - wallDist; n < j + wallDist; n++)
64870 {
64871 if (Main.tile[m, n].active() && TileID.Sets.Crimson[Main.tile[m, n].type])
64872 {
64873 flag = true;
64874 break;
64875 }
64876 }
64877 if (flag)
64878 {
64879 break;
64880 }
64881 }
64882 break;
64883 }
64884 case 2:
64885 {
64886 for (int num4 = i - wallDist; num4 < i + wallDist; num4++)
64887 {
64888 for (int num5 = j - wallDist; num5 < j + wallDist; num5++)
64889 {
64890 if (Main.tile[num4, num5].active() && TileID.Sets.Hallow[Main.tile[num4, num5].type])
64891 {
64892 flag = true;
64893 break;
64894 }
64895 }
64896 if (flag)
64897 {
64898 break;
64899 }
64900 }
64901 break;
64902 }
64903 case 1:
64904 {
64905 for (int k = i - wallDist; k < i + wallDist; k++)
64906 {
64907 for (int l = j - wallDist; l < j + wallDist; l++)
64908 {
64909 if (Main.tile[k, l].active() && TileID.Sets.Corrupt[Main.tile[k, l].type])
64910 {
64911 flag = true;
64912 break;
64913 }
64914 }
64915 if (flag)
64916 {
64917 break;
64918 }
64919 }
64920 break;
64921 }
64922 }
64923 }
64924 if (!flag)
64925 {
64926 return;
64927 }
64928 ushort? num6 = null;
64930 {
64931 switch (num)
64932 {
64933 case 3:
64934 num6 = 221;
64935 break;
64936 case 2:
64937 num6 = 222;
64938 break;
64939 case 1:
64940 num6 = 220;
64941 break;
64942 }
64943 }
64945 {
64946 switch (num)
64947 {
64948 case 3:
64949 num6 = 218;
64950 break;
64951 case 2:
64952 num6 = 219;
64953 break;
64954 case 1:
64955 num6 = 217;
64956 break;
64957 }
64958 }
64959 if (num6.HasValue && Main.tile[num2, num3].wall != num6.Value)
64960 {
64961 Main.tile[num2, num3].wall = num6.Value;
64962 if (Main.netMode == 2)
64963 {
64965 }
64966 }
64967 }
64968
64969 public static void PlaceWall(int i, int j, int type, bool mute = false)
64970 {
64971 if (i <= 1 || j <= 1 || i >= Main.maxTilesX - 2 || j >= Main.maxTilesY - 2)
64972 {
64973 return;
64974 }
64975 if (Main.tile[i, j] == null)
64976 {
64977 Main.tile[i, j] = new Tile();
64978 }
64979 if (Main.tile[i, j].wall == 0)
64980 {
64981 Main.tile[i, j].wall = (ushort)type;
64982 SquareWallFrame(i, j);
64983 if (!mute)
64984 {
64985 SoundEngine.PlaySound(0, i * 16, j * 16);
64986 }
64987 }
64988 }
64989
64990 public static void SpreadGrass(int i, int j, int dirt = 0, int grass = 2, bool repeat = true, TileColorCache color = default(TileColorCache))
64991 {
64992 try
64993 {
64994 if (!InWorld(i, j, 10) || !Main.tile[i, j].active() || Main.tile[i, j].type != dirt)
64995 {
64996 return;
64997 }
64998 if (gen && (grass == 199 || grass == 23))
64999 {
65000 int num = beachDistance;
65001 if ((!tenthAnniversaryWorldGen && (double)i > (double)Main.maxTilesX * 0.45 && (double)i <= (double)Main.maxTilesX * 0.55) || i < num || i >= Main.maxTilesX - num)
65002 {
65003 return;
65004 }
65005 }
65006 else if ((gen || (grass != 199 && grass != 23 && grass != 661 && grass != 662)) && (Main.tile[i, j].type != dirt || !Main.tile[i, j].active() || ((double)j >= Main.worldSurface && dirt == 0)) && !growGrassUnderground)
65007 {
65008 return;
65009 }
65010 int num2 = i - 1;
65011 int num3 = i + 2;
65012 int num4 = j - 1;
65013 int num5 = j + 2;
65014 if (num2 < 0)
65015 {
65016 num2 = 0;
65017 }
65018 if (num3 > Main.maxTilesX)
65019 {
65021 }
65022 if (num4 < 0)
65023 {
65024 num4 = 0;
65025 }
65026 if (num5 > Main.maxTilesY)
65027 {
65029 }
65030 bool flag = true;
65031 for (int k = num2; k < num3; k++)
65032 {
65033 for (int l = num4; l < num5; l++)
65034 {
65035 if (!Main.tile[k, l].active() || !Main.tileSolid[Main.tile[k, l].type])
65036 {
65037 flag = false;
65038 }
65039 if (Main.tile[k, l].lava() && Main.tile[k, l].liquid > 0)
65040 {
65041 flag = true;
65042 break;
65043 }
65044 }
65045 }
65046 if (flag || !TileID.Sets.CanBeClearedDuringGeneration[Main.tile[i, j].type] || ((grass == 23 || grass == 661) && Main.tile[i, j - 1].type == 27) || ((grass == 199 || grass == 662) && Main.tile[i, j - 1].type == 27) || (grass == 109 && Main.tile[i, j - 1].type == 27))
65047 {
65048 return;
65049 }
65050 Main.tile[i, j].type = (ushort)grass;
65051 Main.tile[i, j].UseBlockColors(color);
65052 for (int m = num2; m < num3; m++)
65053 {
65054 for (int n = num4; n < num5; n++)
65055 {
65056 if (!Main.tile[m, n].active() || Main.tile[m, n].type != dirt)
65057 {
65058 continue;
65059 }
65060 try
65061 {
65062 if (repeat && grassSpread < 1000)
65063 {
65064 grassSpread++;
65065 SpreadGrass(m, n, dirt, grass);
65066 grassSpread--;
65067 }
65068 }
65069 catch
65070 {
65071 }
65072 }
65073 }
65074 }
65075 catch
65076 {
65077 }
65078 }
65079
65080 public static void ChasmRunnerSideways(int i, int j, int direction, int steps)
65081 {
65082 //IL_06f1: Unknown result type (might be due to invalid IL or missing references)
65083 //IL_06fa: Unknown result type (might be due to invalid IL or missing references)
65084 //IL_0105: Unknown result type (might be due to invalid IL or missing references)
65085 //IL_0138: Unknown result type (might be due to invalid IL or missing references)
65086 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
65087 //IL_0163: Unknown result type (might be due to invalid IL or missing references)
65088 //IL_0178: Unknown result type (might be due to invalid IL or missing references)
65089 //IL_027f: Unknown result type (might be due to invalid IL or missing references)
65090 //IL_0280: Unknown result type (might be due to invalid IL or missing references)
65091 //IL_0281: Unknown result type (might be due to invalid IL or missing references)
65092 //IL_0286: Unknown result type (might be due to invalid IL or missing references)
65093 //IL_02ab: Unknown result type (might be due to invalid IL or missing references)
65094 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
65095 //IL_01d1: Unknown result type (might be due to invalid IL or missing references)
65096 //IL_01e0: Unknown result type (might be due to invalid IL or missing references)
65097 //IL_0309: Unknown result type (might be due to invalid IL or missing references)
65098 //IL_032a: Unknown result type (might be due to invalid IL or missing references)
65099 //IL_0373: Unknown result type (might be due to invalid IL or missing references)
65100 //IL_03fd: Unknown result type (might be due to invalid IL or missing references)
65101 //IL_0412: Unknown result type (might be due to invalid IL or missing references)
65102 //IL_0428: Unknown result type (might be due to invalid IL or missing references)
65103 //IL_043d: Unknown result type (might be due to invalid IL or missing references)
65104 //IL_03bb: Unknown result type (might be due to invalid IL or missing references)
65105 //IL_0394: Unknown result type (might be due to invalid IL or missing references)
65106 //IL_03dc: Unknown result type (might be due to invalid IL or missing references)
65107 //IL_0496: Unknown result type (might be due to invalid IL or missing references)
65108 //IL_04a5: Unknown result type (might be due to invalid IL or missing references)
65109 //IL_05f0: Unknown result type (might be due to invalid IL or missing references)
65110 //IL_05ff: Unknown result type (might be due to invalid IL or missing references)
65111 double num = steps;
65112 Vector2D val = default(Vector2D);
65113 val.X = i;
65114 val.Y = j;
65115 Vector2D val2 = default(Vector2D);
65116 val2.X = (double)genRand.Next(10, 21) * 0.1 * (double)direction;
65117 val2.Y = (double)genRand.Next(-10, 10) * 0.01;
65118 double num2 = genRand.Next(5) + 7;
65119 while (num2 > 0.0)
65120 {
65121 if (num > 0.0)
65122 {
65123 num2 += (double)genRand.Next(3);
65124 num2 -= (double)genRand.Next(3);
65125 if (num2 < 7.0)
65126 {
65127 num2 = 7.0;
65128 }
65129 if (num2 > 20.0)
65130 {
65131 num2 = 20.0;
65132 }
65133 if (num == 1.0 && num2 < 10.0)
65134 {
65135 num2 = 10.0;
65136 }
65137 }
65138 else
65139 {
65140 num2 -= (double)genRand.Next(4);
65141 }
65142 if (val.Y > Main.rockLayer && num > 0.0)
65143 {
65144 num = 0.0;
65145 }
65146 num -= 1.0;
65147 int num3 = (int)(val.X - num2 * 0.5);
65148 int num4 = (int)(val.X + num2 * 0.5);
65149 int num5 = (int)(val.Y - num2 * 0.5);
65150 int num6 = (int)(val.Y + num2 * 0.5);
65151 if (num3 < 0)
65152 {
65153 num3 = 0;
65154 }
65155 if (num4 > Main.maxTilesX - 1)
65156 {
65157 num4 = Main.maxTilesX - 1;
65158 }
65159 if (num5 < 0)
65160 {
65161 num5 = 0;
65162 }
65163 if (num6 > Main.maxTilesY)
65164 {
65166 }
65167 for (int k = num3; k < num4; k++)
65168 {
65169 for (int l = num5; l < num6; l++)
65170 {
65171 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num2 * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[k, l].type != 31 && Main.tile[k, l].type != 22)
65172 {
65173 Main.tile[k, l].active(active: false);
65174 }
65175 }
65176 }
65177 val += val2;
65178 val2.Y += (double)genRand.Next(-10, 10) * 0.1;
65179 if (val.Y < (double)(j - 20))
65180 {
65181 val2.Y += (double)genRand.Next(20) * 0.01;
65182 }
65183 if (val.Y > (double)(j + 20))
65184 {
65185 val2.Y -= (double)genRand.Next(20) * 0.01;
65186 }
65187 if (val2.Y < -0.5)
65188 {
65189 val2.Y = -0.5;
65190 }
65191 if (val2.Y > 0.5)
65192 {
65193 val2.Y = 0.5;
65194 }
65195 val2.X += (double)genRand.Next(-10, 11) * 0.01;
65196 switch (direction)
65197 {
65198 case -1:
65199 if (val2.X > -0.5)
65200 {
65201 val2.X = -0.5;
65202 }
65203 if (val2.X < -2.0)
65204 {
65205 val2.X = -2.0;
65206 }
65207 break;
65208 case 1:
65209 if (val2.X < 0.5)
65210 {
65211 val2.X = 0.5;
65212 }
65213 if (val2.X > 2.0)
65214 {
65215 val2.X = 2.0;
65216 }
65217 break;
65218 }
65219 num3 = (int)(val.X - num2 * 1.1);
65220 num4 = (int)(val.X + num2 * 1.1);
65221 num5 = (int)(val.Y - num2 * 1.1);
65222 num6 = (int)(val.Y + num2 * 1.1);
65223 if (num3 < 1)
65224 {
65225 num3 = 1;
65226 }
65227 if (num4 > Main.maxTilesX - 1)
65228 {
65229 num4 = Main.maxTilesX - 1;
65230 }
65231 if (num5 < 0)
65232 {
65233 num5 = 0;
65234 }
65235 if (num6 > Main.maxTilesY)
65236 {
65238 }
65239 for (int m = num3; m < num4; m++)
65240 {
65241 for (int n = num5; n < num6; n++)
65242 {
65243 if (Math.Abs((double)m - val.X) + Math.Abs((double)n - val.Y) < num2 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[m, n].wall != 3)
65244 {
65245 if (Main.tile[m, n].type != 25 && n > j + genRand.Next(3, 20))
65246 {
65247 Main.tile[m, n].active(active: true);
65248 }
65249 Main.tile[m, n].active(active: true);
65250 if (Main.tile[m, n].type != 31 && Main.tile[m, n].type != 22)
65251 {
65252 Main.tile[m, n].type = 25;
65253 }
65254 if (Main.tile[m, n].wall == 2)
65255 {
65256 Main.tile[m, n].wall = 0;
65257 }
65258 }
65259 }
65260 }
65261 for (int num7 = num3; num7 < num4; num7++)
65262 {
65263 for (int num8 = num5; num8 < num6; num8++)
65264 {
65265 if (Math.Abs((double)num7 - val.X) + Math.Abs((double)num8 - val.Y) < num2 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[num7, num8].wall != 3)
65266 {
65267 if (Main.tile[num7, num8].type != 31 && Main.tile[num7, num8].type != 22)
65268 {
65269 Main.tile[num7, num8].type = 25;
65270 }
65271 Main.tile[num7, num8].active(active: true);
65272 PlaceWall(num7, num8, 3, mute: true);
65273 }
65274 }
65275 }
65276 }
65277 if (genRand.Next(3) == 0)
65278 {
65279 int num9 = (int)val.X;
65280 int num10;
65281 for (num10 = (int)val.Y; !Main.tile[num9, num10].active(); num10++)
65282 {
65283 }
65284 TileRunner(num9, num10, genRand.Next(2, 6), genRand.Next(3, 7), 22);
65285 }
65286 }
65287
65288 public static void CrimStart(int i, int j)
65289 {
65290 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
65291 //IL_00f0: Unknown result type (might be due to invalid IL or missing references)
65292 //IL_0490: Unknown result type (might be due to invalid IL or missing references)
65293 //IL_04a9: Unknown result type (might be due to invalid IL or missing references)
65294 //IL_02e7: Unknown result type (might be due to invalid IL or missing references)
65295 //IL_010c: Unknown result type (might be due to invalid IL or missing references)
65296 //IL_0300: Unknown result type (might be due to invalid IL or missing references)
65297 //IL_068b: Unknown result type (might be due to invalid IL or missing references)
65298 //IL_0695: Unknown result type (might be due to invalid IL or missing references)
65299 //IL_02c5: Unknown result type (might be due to invalid IL or missing references)
65300 //IL_0312: Unknown result type (might be due to invalid IL or missing references)
65301 //IL_0835: Unknown result type (might be due to invalid IL or missing references)
65302 //IL_0837: Unknown result type (might be due to invalid IL or missing references)
65303 //IL_0842: Unknown result type (might be due to invalid IL or missing references)
65304 //IL_0847: Unknown result type (might be due to invalid IL or missing references)
65305 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
65306 //IL_0262: Unknown result type (might be due to invalid IL or missing references)
65307 //IL_0134: Unknown result type (might be due to invalid IL or missing references)
65308 //IL_0144: Unknown result type (might be due to invalid IL or missing references)
65309 //IL_0754: Unknown result type (might be due to invalid IL or missing references)
65310 //IL_0760: Unknown result type (might be due to invalid IL or missing references)
65311 //IL_08de: Unknown result type (might be due to invalid IL or missing references)
65312 //IL_08f6: Unknown result type (might be due to invalid IL or missing references)
65313 //IL_0191: Unknown result type (might be due to invalid IL or missing references)
65314 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
65315 //IL_03c2: Unknown result type (might be due to invalid IL or missing references)
65316 //IL_0bcd: Unknown result type (might be due to invalid IL or missing references)
65317 //IL_03e4: Unknown result type (might be due to invalid IL or missing references)
65318 //IL_0209: Unknown result type (might be due to invalid IL or missing references)
65319 //IL_0219: Unknown result type (might be due to invalid IL or missing references)
65320 //IL_0406: Unknown result type (might be due to invalid IL or missing references)
65321 //IL_0783: Unknown result type (might be due to invalid IL or missing references)
65322 //IL_0428: Unknown result type (might be due to invalid IL or missing references)
65323 //IL_07a4: Unknown result type (might be due to invalid IL or missing references)
65324 //IL_044a: Unknown result type (might be due to invalid IL or missing references)
65325 //IL_044c: Unknown result type (might be due to invalid IL or missing references)
65326 //IL_044e: Unknown result type (might be due to invalid IL or missing references)
65327 //IL_0453: Unknown result type (might be due to invalid IL or missing references)
65328 //IL_0455: Unknown result type (might be due to invalid IL or missing references)
65329 //IL_07c5: Unknown result type (might be due to invalid IL or missing references)
65330 //IL_07e6: Unknown result type (might be due to invalid IL or missing references)
65331 int crimDir = 1;
65332 int k = j;
65333 if ((double)k > Main.worldSurface)
65334 {
65335 k = (int)Main.worldSurface;
65336 }
65337 for (; !SolidTile(i, k); k++)
65338 {
65339 }
65340 int num = k;
65341 Vector2D val = default(Vector2D);
65342 ((Vector2D)(ref val))._002Ector((double)i, (double)k);
65343 Vector2D val2 = default(Vector2D);
65344 ((Vector2D)(ref val2))._002Ector((double)genRand.Next(-20, 21) * 0.1, (double)genRand.Next(20, 201) * 0.01);
65345 if (val2.X < 0.0)
65346 {
65347 crimDir = -1;
65348 }
65349 double num2 = genRand.Next(15, 26);
65350 bool flag = true;
65351 int num3 = 0;
65352 while (flag)
65353 {
65354 num2 += (double)genRand.Next(-50, 51) * 0.01;
65355 if (num2 < 15.0)
65356 {
65357 num2 = 15.0;
65358 }
65359 if (num2 > 25.0)
65360 {
65361 num2 = 25.0;
65362 }
65363 for (int l = (int)(val.X - num2 / 2.0); (double)l < val.X + num2 / 2.0; l++)
65364 {
65365 for (int m = (int)(val.Y - num2 / 2.0); (double)m < val.Y + num2 / 2.0; m++)
65366 {
65367 if (m > num)
65368 {
65369 if (Math.Abs((double)l - val.X) + Math.Abs((double)m - val.Y) < num2 * 0.3)
65370 {
65371 Main.tile[l, m].active(active: false);
65372 Main.tile[l, m].wall = 83;
65373 }
65374 else if (Math.Abs((double)l - val.X) + Math.Abs((double)m - val.Y) < num2 * 0.8 && Main.tile[l, m].wall != 83)
65375 {
65376 Main.tile[l, m].active(active: true);
65377 Main.tile[l, m].type = 203;
65378 if (Math.Abs((double)l - val.X) + Math.Abs((double)m - val.Y) < num2 * 0.6)
65379 {
65380 Main.tile[l, m].wall = 83;
65381 }
65382 }
65383 }
65384 else if (Math.Abs((double)l - val.X) + Math.Abs((double)m - val.Y) < num2 * 0.3 && Main.tile[l, m].active())
65385 {
65386 Main.tile[l, m].active(active: false);
65387 Main.tile[l, m].wall = 83;
65388 }
65389 }
65390 }
65391 if (val.X > (double)(i + 50))
65392 {
65393 num3 = -100;
65394 }
65395 if (val.X < (double)(i - 50))
65396 {
65397 num3 = 100;
65398 }
65399 if (num3 < 0)
65400 {
65401 val2.X -= (double)genRand.Next(20, 51) * 0.01;
65402 }
65403 else if (num3 > 0)
65404 {
65405 val2.X += (double)genRand.Next(20, 51) * 0.01;
65406 }
65407 else
65408 {
65409 val2.X += (double)genRand.Next(-50, 51) * 0.01;
65410 }
65411 val2.Y += (double)genRand.Next(-50, 51) * 0.01;
65412 if (val2.Y < 0.25)
65413 {
65414 val2.Y = 0.25;
65415 }
65416 if (val2.Y > 2.0)
65417 {
65418 val2.Y = 2.0;
65419 }
65420 if (val2.X < -2.0)
65421 {
65422 val2.X = -2.0;
65423 }
65424 if (val2.X > 2.0)
65425 {
65426 val2.X = 2.0;
65427 }
65428 val += val2;
65429 if (val.Y > Main.worldSurface + 100.0)
65430 {
65431 flag = false;
65432 }
65433 }
65434 num2 = genRand.Next(40, 55);
65435 for (int n = 0; n < 50; n++)
65436 {
65437 int num4 = (int)val.X + genRand.Next(-20, 21);
65438 int num5 = (int)val.Y + genRand.Next(-20, 21);
65439 for (int num6 = (int)((double)num4 - num2 / 2.0); (double)num6 < (double)num4 + num2 / 2.0; num6++)
65440 {
65441 for (int num7 = (int)((double)num5 - num2 / 2.0); (double)num7 < (double)num5 + num2 / 2.0; num7++)
65442 {
65443 double num8 = Math.Abs(num6 - num4);
65444 double num9 = Math.Abs(num7 - num5);
65445 double num10 = 1.0 + (double)genRand.Next(-20, 21) * 0.01;
65446 double num11 = 1.0 + (double)genRand.Next(-20, 21) * 0.01;
65447 double num12 = num8 * num10;
65448 num9 *= num11;
65449 double num13 = Math.Sqrt(num12 * num12 + num9 * num9);
65450 if (num13 < num2 * 0.25)
65451 {
65452 Main.tile[num6, num7].active(active: false);
65453 Main.tile[num6, num7].wall = 83;
65454 }
65455 else if (num13 < num2 * 0.4 && Main.tile[num6, num7].wall != 83)
65456 {
65457 Main.tile[num6, num7].active(active: true);
65458 Main.tile[num6, num7].type = 203;
65459 if (num13 < num2 * 0.35)
65460 {
65461 Main.tile[num6, num7].wall = 83;
65462 }
65463 }
65464 }
65465 }
65466 }
65467 int num14 = genRand.Next(5, 9);
65468 Vector2D[] array = (Vector2D[])(object)new Vector2D[num14];
65469 Vector2D val3 = default(Vector2D);
65470 for (int num15 = 0; num15 < num14; num15++)
65471 {
65472 int num16 = (int)val.X;
65473 int num17 = (int)val.Y;
65474 int num18 = 0;
65475 bool flag2 = true;
65476 ((Vector2D)(ref val3))._002Ector((double)genRand.Next(-20, 21) * 0.15, (double)genRand.Next(0, 21) * 0.15);
65477 while (flag2)
65478 {
65479 ((Vector2D)(ref val3))._002Ector((double)genRand.Next(-20, 21) * 0.15, (double)genRand.Next(0, 21) * 0.15);
65480 while (Math.Abs(val3.X) + Math.Abs(val3.Y) < 1.5)
65481 {
65482 ((Vector2D)(ref val3))._002Ector((double)genRand.Next(-20, 21) * 0.15, (double)genRand.Next(0, 21) * 0.15);
65483 }
65484 flag2 = false;
65485 for (int num19 = 0; num19 < num15; num19++)
65486 {
65487 if (val2.X > array[num19].X - 0.75 && val2.X < array[num19].X + 0.75 && val2.Y > array[num19].Y - 0.75 && val2.Y < array[num19].Y + 0.75)
65488 {
65489 flag2 = true;
65490 num18++;
65491 break;
65492 }
65493 }
65494 if (num18 > 10000)
65495 {
65496 break;
65497 }
65498 }
65499 array[num15] = val3;
65500 CrimVein(new Vector2D((double)num16, (double)num17), val3);
65501 }
65502 int num20 = Main.maxTilesX;
65503 int num21 = 0;
65504 val.X = i;
65505 val.Y = num;
65506 num2 = genRand.Next(25, 35);
65507 double num22 = genRand.Next(0, 6);
65508 for (int num23 = 0; num23 < 50; num23++)
65509 {
65510 if (num22 > 0.0)
65511 {
65512 double num24 = (double)genRand.Next(10, 30) * 0.01;
65513 num22 -= num24;
65514 val.Y -= num24;
65515 }
65516 int num25 = (int)val.X + genRand.Next(-2, 3);
65517 int num26 = (int)val.Y + genRand.Next(-2, 3);
65518 for (int num27 = (int)((double)num25 - num2 / 2.0); (double)num27 < (double)num25 + num2 / 2.0; num27++)
65519 {
65520 for (int num28 = (int)((double)num26 - num2 / 2.0); (double)num28 < (double)num26 + num2 / 2.0; num28++)
65521 {
65522 double num29 = Math.Abs(num27 - num25);
65523 double num30 = Math.Abs(num28 - num26);
65524 double num31 = 1.0 + (double)genRand.Next(-20, 21) * 0.005;
65525 double num32 = 1.0 + (double)genRand.Next(-20, 21) * 0.005;
65526 double num33 = num29 * num31;
65527 num30 *= num32;
65528 double num34 = Math.Sqrt(num33 * num33 + num30 * num30);
65529 if (num34 < num2 * 0.2 * ((double)genRand.Next(90, 111) * 0.01))
65530 {
65531 Main.tile[num27, num28].active(active: false);
65532 Main.tile[num27, num28].wall = 83;
65533 }
65534 else
65535 {
65536 if (!(num34 < num2 * 0.45))
65537 {
65538 continue;
65539 }
65540 if (num27 < num20)
65541 {
65542 num20 = num27;
65543 }
65544 if (num27 > num21)
65545 {
65546 num21 = num27;
65547 }
65548 if (Main.tile[num27, num28].wall != 83)
65549 {
65550 Main.tile[num27, num28].active(active: true);
65551 Main.tile[num27, num28].type = 203;
65552 if (num34 < num2 * 0.35)
65553 {
65554 Main.tile[num27, num28].wall = 83;
65555 }
65556 }
65557 }
65558 }
65559 }
65560 }
65561 for (int num35 = num20; num35 <= num21; num35++)
65562 {
65563 int num36;
65564 for (num36 = num; (Main.tile[num35, num36].type == 203 && Main.tile[num35, num36].active()) || Main.tile[num35, num36].wall == 83; num36++)
65565 {
65566 }
65567 int num37 = genRand.Next(15, 20);
65568 for (; !Main.tile[num35, num36].active(); num36++)
65569 {
65570 if (num37 <= 0)
65571 {
65572 break;
65573 }
65574 if (Main.tile[num35, num36].wall == 83)
65575 {
65576 break;
65577 }
65578 num37--;
65579 Main.tile[num35, num36].type = 203;
65580 Main.tile[num35, num36].active(active: true);
65581 }
65582 }
65583 CrimEnt(val, crimDir);
65584 }
65585
65586 public static void CrimPlaceHearts()
65587 {
65588 int num = 16;
65589 for (int i = 0; i < heartCount; i++)
65590 {
65591 num = genRand.Next(16, 21);
65592 int x = heartPos[i].X;
65593 int y = heartPos[i].Y;
65594 for (int j = x - num / 2; j < x + num / 2; j++)
65595 {
65596 for (int k = y - num / 2; k < y + num / 2; k++)
65597 {
65598 double num2 = Math.Abs(j - x);
65599 double num3 = Math.Abs(k - y);
65600 if (Math.Sqrt(num2 * num2 + num3 * num3) < (double)num * 0.4)
65601 {
65602 Main.tile[j, k].active(active: true);
65603 Main.tile[j, k].type = 203;
65604 Main.tile[j, k].wall = 83;
65605 }
65606 }
65607 }
65608 }
65609 for (int l = 0; l < heartCount; l++)
65610 {
65611 num = genRand.Next(10, 14);
65612 int x2 = heartPos[l].X;
65613 int y2 = heartPos[l].Y;
65614 for (int m = x2 - num / 2; m < x2 + num / 2; m++)
65615 {
65616 for (int n = y2 - num / 2; n < y2 + num / 2; n++)
65617 {
65618 double num4 = Math.Abs(m - x2);
65619 double num5 = Math.Abs(n - y2);
65620 if (Math.Sqrt(num4 * num4 + num5 * num5) < (double)num * 0.3)
65621 {
65622 Main.tile[m, n].active(active: false);
65623 Main.tile[m, n].wall = 83;
65624 }
65625 }
65626 }
65627 }
65628 for (int num6 = 0; num6 < heartCount; num6++)
65629 {
65630 AddShadowOrb(heartPos[num6].X, heartPos[num6].Y);
65631 }
65632 }
65633
65634 public static void CrimEnt(Vector2D position, int crimDir)
65635 {
65636 //IL_00b8: Unknown result type (might be due to invalid IL or missing references)
65637 //IL_019e: Unknown result type (might be due to invalid IL or missing references)
65638 //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
65639 //IL_01b5: Unknown result type (might be due to invalid IL or missing references)
65640 //IL_01b6: Unknown result type (might be due to invalid IL or missing references)
65641 //IL_01b7: Unknown result type (might be due to invalid IL or missing references)
65642 //IL_01bc: Unknown result type (might be due to invalid IL or missing references)
65643 //IL_017e: Unknown result type (might be due to invalid IL or missing references)
65644 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
65645 //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
65646 double num = 0.0;
65647 double num2 = genRand.Next(6, 11);
65648 bool flag = true;
65649 Vector2D val = default(Vector2D);
65650 ((Vector2D)(ref val))._002Ector(2.0, (double)genRand.Next(-20, 0) * 0.01);
65651 val.X *= -crimDir;
65652 while (flag)
65653 {
65654 num += 1.0;
65655 if (num >= 20.0)
65656 {
65657 flag = false;
65658 }
65659 num2 += (double)genRand.Next(-10, 11) * 0.02;
65660 if (num2 < 6.0)
65661 {
65662 num2 = 6.0;
65663 }
65664 if (num2 > 10.0)
65665 {
65666 num2 = 10.0;
65667 }
65668 for (int i = (int)(position.X - num2 / 2.0); (double)i < position.X + num2 / 2.0; i++)
65669 {
65670 for (int j = (int)(position.Y - num2 / 2.0); (double)j < position.Y + num2 / 2.0; j++)
65671 {
65672 double num3 = Math.Abs((double)i - position.X);
65673 double num4 = Math.Abs((double)j - position.Y);
65674 if (Math.Sqrt(num3 * num3 + num4 * num4) < num2 * 0.5 && Main.tile[i, j].active() && Main.tile[i, j].type == 203)
65675 {
65676 Main.tile[i, j].active(active: false);
65677 flag = true;
65678 num = 0.0;
65679 }
65680 }
65681 }
65682 position += val;
65683 }
65684 }
65685
65686 public static void CrimVein(Vector2D position, Vector2D velocity)
65687 {
65688 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
65689 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
65690 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
65691 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
65692 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
65693 //IL_032d: Unknown result type (might be due to invalid IL or missing references)
65694 //IL_0091: Unknown result type (might be due to invalid IL or missing references)
65695 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
65696 //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
65697 //IL_022c: Unknown result type (might be due to invalid IL or missing references)
65698 //IL_0232: Unknown result type (might be due to invalid IL or missing references)
65699 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
65700 //IL_025b: Unknown result type (might be due to invalid IL or missing references)
65701 //IL_0261: Unknown result type (might be due to invalid IL or missing references)
65702 //IL_0246: Unknown result type (might be due to invalid IL or missing references)
65703 //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
65704 //IL_00d7: Unknown result type (might be due to invalid IL or missing references)
65705 //IL_028a: Unknown result type (might be due to invalid IL or missing references)
65706 //IL_0290: Unknown result type (might be due to invalid IL or missing references)
65707 //IL_0275: Unknown result type (might be due to invalid IL or missing references)
65708 //IL_02b9: Unknown result type (might be due to invalid IL or missing references)
65709 //IL_02bf: Unknown result type (might be due to invalid IL or missing references)
65710 //IL_02a4: Unknown result type (might be due to invalid IL or missing references)
65711 //IL_02e8: Unknown result type (might be due to invalid IL or missing references)
65712 //IL_02e9: Unknown result type (might be due to invalid IL or missing references)
65713 //IL_02ea: Unknown result type (might be due to invalid IL or missing references)
65714 //IL_02ef: Unknown result type (might be due to invalid IL or missing references)
65715 //IL_02f1: Unknown result type (might be due to invalid IL or missing references)
65716 //IL_02f7: Unknown result type (might be due to invalid IL or missing references)
65717 //IL_0303: Unknown result type (might be due to invalid IL or missing references)
65718 //IL_0309: Unknown result type (might be due to invalid IL or missing references)
65719 //IL_02d3: Unknown result type (might be due to invalid IL or missing references)
65720 double num = genRand.Next(15, 26);
65721 bool flag = true;
65722 Vector2D val = velocity;
65723 Vector2D val2 = position;
65724 int num2 = genRand.Next(100, 150);
65725 if (velocity.Y < 0.0)
65726 {
65727 num2 -= 25;
65728 }
65729 while (flag)
65730 {
65731 num += (double)genRand.Next(-50, 51) * 0.02;
65732 if (num < 15.0)
65733 {
65734 num = 15.0;
65735 }
65736 if (num > 25.0)
65737 {
65738 num = 25.0;
65739 }
65740 for (int i = (int)(position.X - num / 2.0); (double)i < position.X + num / 2.0; i++)
65741 {
65742 for (int j = (int)(position.Y - num / 2.0); (double)j < position.Y + num / 2.0; j++)
65743 {
65744 double num3 = Math.Abs((double)i - position.X);
65745 double num4 = Math.Abs((double)j - position.Y);
65746 double num5 = Math.Sqrt(num3 * num3 + num4 * num4);
65747 if (num5 < num * 0.2)
65748 {
65749 Main.tile[i, j].active(active: false);
65750 Main.tile[i, j].wall = 83;
65751 }
65752 else if (num5 < num * 0.5 && Main.tile[i, j].wall != 83)
65753 {
65754 Main.tile[i, j].active(active: true);
65755 Main.tile[i, j].type = 203;
65756 if (num5 < num * 0.4)
65757 {
65758 Main.tile[i, j].wall = 83;
65759 }
65760 }
65761 }
65762 }
65763 velocity.X += (double)genRand.Next(-50, 51) * 0.05;
65764 velocity.Y += (double)genRand.Next(-50, 51) * 0.05;
65765 if (velocity.Y < val.Y - 0.75)
65766 {
65767 velocity.Y = val.Y - 0.75;
65768 }
65769 if (velocity.Y > val.Y + 0.75)
65770 {
65771 velocity.Y = val.Y + 0.75;
65772 }
65773 if (velocity.X < val.X - 0.75)
65774 {
65775 velocity.X = val.X - 0.75;
65776 }
65777 if (velocity.X > val.X + 0.75)
65778 {
65779 velocity.X = val.X + 0.75;
65780 }
65781 position += velocity;
65782 if (Math.Abs(position.X - val2.X) + Math.Abs(position.Y - val2.Y) > (double)num2)
65783 {
65784 flag = false;
65785 }
65786 }
65787 heartPos[heartCount] = position.ToPoint();
65788 heartCount++;
65789 }
65790
65791 public static void ChasmRunner(int i, int j, int steps, bool makeOrb = false)
65792 {
65793 //IL_0107: Unknown result type (might be due to invalid IL or missing references)
65794 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
65795 //IL_0165: Unknown result type (might be due to invalid IL or missing references)
65796 //IL_01cc: Unknown result type (might be due to invalid IL or missing references)
65797 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
65798 //IL_01f8: Unknown result type (might be due to invalid IL or missing references)
65799 //IL_020e: Unknown result type (might be due to invalid IL or missing references)
65800 //IL_017e: Unknown result type (might be due to invalid IL or missing references)
65801 //IL_0185: Unknown result type (might be due to invalid IL or missing references)
65802 //IL_01a0: Unknown result type (might be due to invalid IL or missing references)
65803 //IL_01a7: Unknown result type (might be due to invalid IL or missing references)
65804 //IL_0328: Unknown result type (might be due to invalid IL or missing references)
65805 //IL_045d: Unknown result type (might be due to invalid IL or missing references)
65806 //IL_045e: Unknown result type (might be due to invalid IL or missing references)
65807 //IL_0460: Unknown result type (might be due to invalid IL or missing references)
65808 //IL_0465: Unknown result type (might be due to invalid IL or missing references)
65809 //IL_048a: Unknown result type (might be due to invalid IL or missing references)
65810 //IL_04ac: Unknown result type (might be due to invalid IL or missing references)
65811 //IL_035f: Unknown result type (might be due to invalid IL or missing references)
65812 //IL_0366: Unknown result type (might be due to invalid IL or missing references)
65813 //IL_04ce: Unknown result type (might be due to invalid IL or missing references)
65814 //IL_04e4: Unknown result type (might be due to invalid IL or missing references)
65815 //IL_04fa: Unknown result type (might be due to invalid IL or missing references)
65816 //IL_0510: Unknown result type (might be due to invalid IL or missing references)
65817 //IL_038f: Unknown result type (might be due to invalid IL or missing references)
65818 //IL_0399: Unknown result type (might be due to invalid IL or missing references)
65819 //IL_03af: Unknown result type (might be due to invalid IL or missing references)
65820 //IL_03b9: Unknown result type (might be due to invalid IL or missing references)
65821 //IL_026d: Unknown result type (might be due to invalid IL or missing references)
65822 //IL_027c: Unknown result type (might be due to invalid IL or missing references)
65823 //IL_056f: Unknown result type (might be due to invalid IL or missing references)
65824 //IL_057e: Unknown result type (might be due to invalid IL or missing references)
65825 //IL_0676: Unknown result type (might be due to invalid IL or missing references)
65826 //IL_0685: Unknown result type (might be due to invalid IL or missing references)
65827 bool flag = false;
65828 bool flag2 = false;
65829 bool flag3 = false;
65830 if (!makeOrb)
65831 {
65832 flag2 = true;
65833 }
65834 double num = steps;
65835 Vector2D val = default(Vector2D);
65836 val.X = i;
65837 val.Y = j;
65838 Vector2D val2 = default(Vector2D);
65839 val2.X = (double)genRand.Next(-10, 11) * 0.1;
65840 val2.Y = (double)genRand.Next(11) * 0.2 + 0.5;
65841 int num2 = 5;
65842 double num3 = genRand.Next(5) + 7;
65843 while (num3 > 0.0)
65844 {
65845 if (num > 0.0)
65846 {
65847 num3 += (double)genRand.Next(3);
65848 num3 -= (double)genRand.Next(3);
65849 if (num3 < 7.0)
65850 {
65851 num3 = 7.0;
65852 }
65853 if (num3 > 20.0)
65854 {
65855 num3 = 20.0;
65856 }
65857 if (num == 1.0 && num3 < 10.0)
65858 {
65859 num3 = 10.0;
65860 }
65861 }
65862 else if (val.Y > Main.worldSurface + 45.0)
65863 {
65864 num3 -= (double)genRand.Next(4);
65865 }
65866 if (val.Y > Main.rockLayer && num > 0.0)
65867 {
65868 num = 0.0;
65869 }
65870 num -= 1.0;
65871 if (!flag && val.Y > Main.worldSurface + 20.0)
65872 {
65873 flag = true;
65874 ChasmRunnerSideways((int)val.X, (int)val.Y, -1, genRand.Next(20, 40));
65875 ChasmRunnerSideways((int)val.X, (int)val.Y, 1, genRand.Next(20, 40));
65876 }
65877 int num4;
65878 int num5;
65879 int num6;
65880 int num7;
65881 if (num > (double)num2)
65882 {
65883 num4 = (int)(val.X - num3 * 0.5);
65884 num5 = (int)(val.X + num3 * 0.5);
65885 num6 = (int)(val.Y - num3 * 0.5);
65886 num7 = (int)(val.Y + num3 * 0.5);
65887 if (num4 < 0)
65888 {
65889 num4 = 0;
65890 }
65891 if (num5 > Main.maxTilesX - 1)
65892 {
65893 num5 = Main.maxTilesX - 1;
65894 }
65895 if (num6 < 0)
65896 {
65897 num6 = 0;
65898 }
65899 if (num7 > Main.maxTilesY)
65900 {
65902 }
65903 for (int k = num4; k < num5; k++)
65904 {
65905 for (int l = num6; l < num7; l++)
65906 {
65907 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num3 * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[k, l].type != 31 && Main.tile[k, l].type != 22)
65908 {
65909 Main.tile[k, l].active(active: false);
65910 }
65911 }
65912 }
65913 }
65914 if (num <= 2.0 && val.Y < Main.worldSurface + 45.0)
65915 {
65916 num = 2.0;
65917 }
65918 if (num <= 0.0)
65919 {
65920 if (!flag2)
65921 {
65922 flag2 = true;
65923 AddShadowOrb((int)val.X, (int)val.Y);
65924 }
65925 else if (!flag3)
65926 {
65927 flag3 = false;
65928 bool flag4 = false;
65929 int num8 = 0;
65930 while (!flag4)
65931 {
65932 int num9 = genRand.Next((int)val.X - 25, (int)val.X + 25);
65933 int num10 = genRand.Next((int)val.Y - 50, (int)val.Y);
65934 if (num9 < 5)
65935 {
65936 num9 = 5;
65937 }
65938 if (num9 > Main.maxTilesX - 5)
65939 {
65940 num9 = Main.maxTilesX - 5;
65941 }
65942 if (num10 < 5)
65943 {
65944 num10 = 5;
65945 }
65946 if (num10 > Main.maxTilesY - 5)
65947 {
65948 num10 = Main.maxTilesY - 5;
65949 }
65950 if ((double)num10 > Main.worldSurface)
65951 {
65952 if (!IsTileNearby(num9, num10, 26, 3))
65953 {
65954 Place3x2(num9, num10, 26);
65955 }
65956 if (Main.tile[num9, num10].type == 26)
65957 {
65958 flag4 = true;
65959 continue;
65960 }
65961 num8++;
65962 if (num8 >= 10000)
65963 {
65964 flag4 = true;
65965 }
65966 }
65967 else
65968 {
65969 flag4 = true;
65970 }
65971 }
65972 }
65973 }
65974 val += val2;
65975 val2.X += (double)genRand.Next(-10, 11) * 0.01;
65976 if (val2.X > 0.3)
65977 {
65978 val2.X = 0.3;
65979 }
65980 if (val2.X < -0.3)
65981 {
65982 val2.X = -0.3;
65983 }
65984 num4 = (int)(val.X - num3 * 1.1);
65985 num5 = (int)(val.X + num3 * 1.1);
65986 num6 = (int)(val.Y - num3 * 1.1);
65987 num7 = (int)(val.Y + num3 * 1.1);
65988 if (num4 < 1)
65989 {
65990 num4 = 1;
65991 }
65992 if (num5 > Main.maxTilesX - 1)
65993 {
65994 num5 = Main.maxTilesX - 1;
65995 }
65996 if (num6 < 0)
65997 {
65998 num6 = 0;
65999 }
66000 if (num7 > Main.maxTilesY)
66001 {
66003 }
66004 for (int m = num4; m < num5; m++)
66005 {
66006 for (int n = num6; n < num7; n++)
66007 {
66008 if (Math.Abs((double)m - val.X) + Math.Abs((double)n - val.Y) < num3 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015))
66009 {
66010 if (Main.tile[m, n].type != 25 && n > j + genRand.Next(3, 20))
66011 {
66012 Main.tile[m, n].active(active: true);
66013 }
66014 if (steps <= num2)
66015 {
66016 Main.tile[m, n].active(active: true);
66017 }
66018 if (Main.tile[m, n].type != 31)
66019 {
66020 Main.tile[m, n].type = 25;
66021 }
66022 }
66023 }
66024 }
66025 for (int num11 = num4; num11 < num5; num11++)
66026 {
66027 for (int num12 = num6; num12 < num7; num12++)
66028 {
66029 if (Math.Abs((double)num11 - val.X) + Math.Abs((double)num12 - val.Y) < num3 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015))
66030 {
66031 if (Main.tile[num11, num12].type != 31)
66032 {
66033 Main.tile[num11, num12].type = 25;
66034 }
66035 if (steps <= num2)
66036 {
66037 Main.tile[num11, num12].active(active: true);
66038 }
66039 if (num12 > j + genRand.Next(3, 20))
66040 {
66041 Main.tile[num11, num12].wall = 3;
66042 }
66043 }
66044 }
66045 }
66046 }
66047 }
66048
66049 public static void SpawnPlanteraThorns(Vector2 position)
66050 {
66051 if (Main.netMode == 1)
66052 {
66053 return;
66054 }
66055 int num = Main.rand.Next(3, 6);
66056 for (int i = 0; i < num; i++)
66057 {
66058 int num2 = Main.rand.Next(15, 31);
66059 int num3 = (int)(position.X / 16f);
66060 int num4 = (int)(position.Y / 16f);
66061 int num5 = 0;
66062 int num6 = 0;
66063 if (Main.rand.Next(2) != 0)
66064 {
66065 num6 = ((Main.rand.Next(2) == 0) ? 1 : (-1));
66066 }
66067 else
66068 {
66069 num5 = ((Main.rand.Next(2) == 0) ? 1 : (-1));
66070 }
66071 while (num2 > 0)
66072 {
66073 num2--;
66074 if (!Main.tile[num3, num4].active())
66075 {
66076 PlaceTile(num3, num4, 655);
66077 if (Main.tile[num3, num4].active() && Main.netMode == 2)
66078 {
66080 }
66081 }
66082 num3 += num5;
66083 num4 += num6;
66084 if (!InWorld(num3, num4))
66085 {
66086 return;
66087 }
66088 if (Main.rand.Next(5) == 0)
66089 {
66090 if (num6 == 0)
66091 {
66092 num5 = 0;
66093 num6 = ((Main.rand.Next(2) == 0) ? 1 : (-1));
66094 }
66095 else
66096 {
66097 num6 = 0;
66098 num5 = ((Main.rand.Next(2) == 0) ? 1 : (-1));
66099 }
66100 }
66101 }
66102 }
66103 }
66104
66105 public static void GERunner(int i, int j, double speedX = 0.0, double speedY = 0.0, bool good = true)
66106 {
66107 //IL_0129: Unknown result type (might be due to invalid IL or missing references)
66108 //IL_013f: Unknown result type (might be due to invalid IL or missing references)
66109 //IL_0155: Unknown result type (might be due to invalid IL or missing references)
66110 //IL_016b: Unknown result type (might be due to invalid IL or missing references)
66111 //IL_0e2d: Unknown result type (might be due to invalid IL or missing references)
66112 //IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
66113 //IL_0e2f: Unknown result type (might be due to invalid IL or missing references)
66114 //IL_0e34: Unknown result type (might be due to invalid IL or missing references)
66115 //IL_0e59: Unknown result type (might be due to invalid IL or missing references)
66116 //IL_0e7e: Unknown result type (might be due to invalid IL or missing references)
66117 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
66118 //IL_01d9: Unknown result type (might be due to invalid IL or missing references)
66119 //IL_0ea3: Unknown result type (might be due to invalid IL or missing references)
66120 //IL_0eaf: Unknown result type (might be due to invalid IL or missing references)
66121 //IL_0ebb: Unknown result type (might be due to invalid IL or missing references)
66122 //IL_0ecc: Unknown result type (might be due to invalid IL or missing references)
66123 int num = 0;
66124 for (int k = 20; k < Main.maxTilesX - 20; k++)
66125 {
66126 for (int l = 20; l < Main.maxTilesY - 20; l++)
66127 {
66128 if (Main.tile[k, l].active() && Main.tile[k, l].type == 225)
66129 {
66130 num++;
66131 }
66132 }
66133 }
66134 bool flag = false;
66135 if (num > 200000)
66136 {
66137 flag = true;
66138 }
66139 int num2 = genRand.Next(200, 250);
66140 double num3 = (double)Main.maxTilesX / 4200.0;
66141 num2 = (int)((double)num2 * num3);
66142 double num4 = num2;
66143 Vector2D val = default(Vector2D);
66144 val.X = i;
66145 val.Y = j;
66146 Vector2D val2 = default(Vector2D);
66147 val2.X = (double)genRand.Next(-10, 11) * 0.1;
66148 val2.Y = (double)genRand.Next(-10, 11) * 0.1;
66149 if (speedX != 0.0 || speedY != 0.0)
66150 {
66151 val2.X = speedX;
66152 val2.Y = speedY;
66153 }
66154 bool flag2 = true;
66155 while (flag2)
66156 {
66157 int num5 = (int)(val.X - num4 * 0.5);
66158 int num6 = (int)(val.X + num4 * 0.5);
66159 int num7 = (int)(val.Y - num4 * 0.5);
66160 int num8 = (int)(val.Y + num4 * 0.5);
66161 if (num5 < 0)
66162 {
66163 num5 = 0;
66164 }
66165 if (num6 > Main.maxTilesX)
66166 {
66168 }
66169 if (num7 < 0)
66170 {
66171 num7 = 0;
66172 }
66173 if (num8 > Main.maxTilesY - 5)
66174 {
66175 num8 = Main.maxTilesY - 5;
66176 }
66177 for (int m = num5; m < num6; m++)
66178 {
66179 for (int n = num7; n < num8; n++)
66180 {
66181 if (!(Math.Abs((double)m - val.X) + Math.Abs((double)n - val.Y) < (double)num2 * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015)))
66182 {
66183 continue;
66184 }
66185 if (good)
66186 {
66187 if (Main.tile[m, n].wall == 63 || Main.tile[m, n].wall == 65 || Main.tile[m, n].wall == 66 || Main.tile[m, n].wall == 68 || Main.tile[m, n].wall == 69 || Main.tile[m, n].wall == 81)
66188 {
66189 Main.tile[m, n].wall = 70;
66190 }
66191 else if (Main.tile[m, n].wall == 216)
66192 {
66193 Main.tile[m, n].wall = 219;
66194 }
66195 else if (Main.tile[m, n].wall == 187)
66196 {
66197 Main.tile[m, n].wall = 222;
66198 }
66199 else if (Main.tile[m, n].wall == 3 || Main.tile[m, n].wall == 83)
66200 {
66201 Main.tile[m, n].wall = 28;
66202 }
66203 if (flag && Main.tile[m, n].type == 225)
66204 {
66205 Main.tile[m, n].type = 117;
66206 SquareTileFrame(m, n);
66207 }
66208 else if (flag && Main.tile[m, n].type == 230)
66209 {
66210 Main.tile[m, n].type = 402;
66211 SquareTileFrame(m, n);
66212 }
66213 else if (Main.tile[m, n].type == 2)
66214 {
66215 Main.tile[m, n].type = 109;
66216 SquareTileFrame(m, n);
66217 }
66218 else if (Main.tile[m, n].type == 1 || Main.tile[m, n].type == 25 || Main.tile[m, n].type == 203)
66219 {
66220 Main.tile[m, n].type = 117;
66221 SquareTileFrame(m, n);
66222 }
66223 else if (Main.tile[m, n].type == 53 || Main.tile[m, n].type == 123 || Main.tile[m, n].type == 112 || Main.tile[m, n].type == 234)
66224 {
66225 Main.tile[m, n].type = 116;
66226 SquareTileFrame(m, n);
66227 }
66228 else if (Main.tile[m, n].type == 661 || Main.tile[m, n].type == 662)
66229 {
66230 Main.tile[m, n].type = 60;
66231 SquareTileFrame(m, n);
66232 }
66233 else if (Main.tile[m, n].type == 23 || Main.tile[m, n].type == 199)
66234 {
66235 Main.tile[m, n].type = 109;
66236 SquareTileFrame(m, n);
66237 }
66238 else if (Main.tile[m, n].type == 161 || Main.tile[m, n].type == 163 || Main.tile[m, n].type == 200)
66239 {
66240 Main.tile[m, n].type = 164;
66241 SquareTileFrame(m, n);
66242 }
66243 else if (Main.tile[m, n].type == 396)
66244 {
66245 Main.tile[m, n].type = 403;
66246 SquareTileFrame(m, n);
66247 }
66248 else if (Main.tile[m, n].type == 397)
66249 {
66250 Main.tile[m, n].type = 402;
66251 SquareTileFrame(m, n);
66252 }
66253 }
66254 else if (crimson)
66255 {
66256 if (Main.tile[m, n].wall == 63 || Main.tile[m, n].wall == 65 || Main.tile[m, n].wall == 66 || Main.tile[m, n].wall == 68)
66257 {
66258 Main.tile[m, n].wall = 81;
66259 }
66260 else if (Main.tile[m, n].wall == 216)
66261 {
66262 Main.tile[m, n].wall = 218;
66263 }
66264 else if (Main.tile[m, n].wall == 187)
66265 {
66266 Main.tile[m, n].wall = 221;
66267 }
66268 if (flag && Main.tile[m, n].type == 225)
66269 {
66270 Main.tile[m, n].type = 203;
66271 SquareTileFrame(m, n);
66272 }
66273 else if (flag && Main.tile[m, n].type == 230)
66274 {
66275 Main.tile[m, n].type = 399;
66276 SquareTileFrame(m, n);
66277 }
66278 else if (Main.tile[m, n].type == 60 || Main.tile[m, n].type == 661)
66279 {
66280 Main.tile[m, n].type = 662;
66281 SquareTileFrame(m, n);
66282 }
66283 else if (Main.tile[m, n].type == 2 || Main.tile[m, n].type == 109)
66284 {
66285 Main.tile[m, n].type = 199;
66286 SquareTileFrame(m, n);
66287 }
66288 else if (Main.tile[m, n].type == 1 || Main.tile[m, n].type == 117)
66289 {
66290 Main.tile[m, n].type = 203;
66291 SquareTileFrame(m, n);
66292 }
66293 else if (Main.tile[m, n].type == 53 || Main.tile[m, n].type == 123 || Main.tile[m, n].type == 116)
66294 {
66295 Main.tile[m, n].type = 234;
66296 SquareTileFrame(m, n);
66297 }
66298 else if (Main.tile[m, n].type == 161 || Main.tile[m, n].type == 164)
66299 {
66300 Main.tile[m, n].type = 200;
66301 SquareTileFrame(m, n);
66302 }
66303 else if (Main.tile[m, n].type == 396)
66304 {
66305 Main.tile[m, n].type = 401;
66306 SquareTileFrame(m, n);
66307 }
66308 else if (Main.tile[m, n].type == 397)
66309 {
66310 Main.tile[m, n].type = 399;
66311 SquareTileFrame(m, n);
66312 }
66313 }
66314 else
66315 {
66316 if (Main.tile[m, n].wall == 63 || Main.tile[m, n].wall == 65 || Main.tile[m, n].wall == 66 || Main.tile[m, n].wall == 68)
66317 {
66318 Main.tile[m, n].wall = 69;
66319 }
66320 else if (Main.tile[m, n].wall == 216)
66321 {
66322 Main.tile[m, n].wall = 217;
66323 }
66324 else if (Main.tile[m, n].wall == 187)
66325 {
66326 Main.tile[m, n].wall = 220;
66327 }
66328 if (flag && Main.tile[m, n].type == 225)
66329 {
66330 Main.tile[m, n].type = 25;
66331 SquareTileFrame(m, n);
66332 }
66333 else if (flag && Main.tile[m, n].type == 230)
66334 {
66335 Main.tile[m, n].type = 398;
66336 SquareTileFrame(m, n);
66337 }
66338 else if (Main.tile[m, n].type == 60 || Main.tile[m, n].type == 662)
66339 {
66340 Main.tile[m, n].type = 661;
66341 SquareTileFrame(m, n);
66342 }
66343 else if (Main.tile[m, n].type == 2 || Main.tile[m, n].type == 109)
66344 {
66345 Main.tile[m, n].type = 23;
66346 SquareTileFrame(m, n);
66347 }
66348 else if (Main.tile[m, n].type == 1 || Main.tile[m, n].type == 117)
66349 {
66350 Main.tile[m, n].type = 25;
66351 SquareTileFrame(m, n);
66352 }
66353 else if (Main.tile[m, n].type == 53 || Main.tile[m, n].type == 123 || Main.tile[m, n].type == 116)
66354 {
66355 Main.tile[m, n].type = 112;
66356 SquareTileFrame(m, n);
66357 }
66358 else if (Main.tile[m, n].type == 161 || Main.tile[m, n].type == 164)
66359 {
66360 Main.tile[m, n].type = 163;
66361 SquareTileFrame(m, n);
66362 }
66363 else if (Main.tile[m, n].type == 396)
66364 {
66365 Main.tile[m, n].type = 400;
66366 SquareTileFrame(m, n);
66367 }
66368 else if (Main.tile[m, n].type == 397)
66369 {
66370 Main.tile[m, n].type = 398;
66371 SquareTileFrame(m, n);
66372 }
66373 }
66374 }
66375 }
66376 val += val2;
66377 val2.X += (double)genRand.Next(-10, 11) * 0.05;
66378 if (val2.X > speedX + 1.0)
66379 {
66380 val2.X = speedX + 1.0;
66381 }
66382 if (val2.X < speedX - 1.0)
66383 {
66384 val2.X = speedX - 1.0;
66385 }
66386 if (val.X < (double)(-num2) || val.Y < (double)(-num2) || val.X > (double)(Main.maxTilesX + num2) || val.Y > (double)(Main.maxTilesY + num2))
66387 {
66388 flag2 = false;
66389 }
66390 }
66391 }
66392
66393 private static bool badOceanCaveTiles(int x, int y)
66394 {
66395 if (Main.tile[x, y].wall == 83 || Main.tile[x, y].wall == 3 || Main.wallDungeon[Main.tile[x, y].wall] || Main.tile[x, y].type == 203 || Main.tile[x, y].type == 25 || Main.tileDungeon[Main.tile[x, y].type] || Main.tile[x, y].type == 26 || Main.tile[x, y].type == 31)
66396 {
66397 return true;
66398 }
66399 return false;
66400 }
66401
66402 public static void oceanCave(int i, int j)
66403 {
66404 //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
66405 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
66406 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
66407 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
66408 //IL_0225: Unknown result type (might be due to invalid IL or missing references)
66409 //IL_023b: Unknown result type (might be due to invalid IL or missing references)
66410 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
66411 //IL_01ed: Unknown result type (might be due to invalid IL or missing references)
66412 //IL_079f: Unknown result type (might be due to invalid IL or missing references)
66413 //IL_07a0: Unknown result type (might be due to invalid IL or missing references)
66414 //IL_07a1: Unknown result type (might be due to invalid IL or missing references)
66415 //IL_07a6: Unknown result type (might be due to invalid IL or missing references)
66416 //IL_085d: Unknown result type (might be due to invalid IL or missing references)
66417 //IL_07fd: Unknown result type (might be due to invalid IL or missing references)
66418 //IL_0894: Unknown result type (might be due to invalid IL or missing references)
66419 //IL_086d: Unknown result type (might be due to invalid IL or missing references)
66420 //IL_0836: Unknown result type (might be due to invalid IL or missing references)
66421 //IL_0824: Unknown result type (might be due to invalid IL or missing references)
66422 //IL_02ac: Unknown result type (might be due to invalid IL or missing references)
66423 //IL_02bb: Unknown result type (might be due to invalid IL or missing references)
66424 //IL_02c7: Unknown result type (might be due to invalid IL or missing references)
66425 //IL_02cc: Unknown result type (might be due to invalid IL or missing references)
66426 //IL_09ba: Unknown result type (might be due to invalid IL or missing references)
66427 //IL_08fb: Unknown result type (might be due to invalid IL or missing references)
66428 //IL_08bd: Unknown result type (might be due to invalid IL or missing references)
66429 //IL_09f2: Unknown result type (might be due to invalid IL or missing references)
66430 //IL_09cc: Unknown result type (might be due to invalid IL or missing references)
66431 //IL_095d: Unknown result type (might be due to invalid IL or missing references)
66432 //IL_0922: Unknown result type (might be due to invalid IL or missing references)
66433 //IL_035b: Unknown result type (might be due to invalid IL or missing references)
66434 //IL_0998: Unknown result type (might be due to invalid IL or missing references)
66435 //IL_0713: Unknown result type (might be due to invalid IL or missing references)
66436 //IL_043c: Unknown result type (might be due to invalid IL or missing references)
66437 //IL_0366: Unknown result type (might be due to invalid IL or missing references)
66438 //IL_071f: Unknown result type (might be due to invalid IL or missing references)
66439 //IL_0452: Unknown result type (might be due to invalid IL or missing references)
66440 //IL_0382: Unknown result type (might be due to invalid IL or missing references)
66441 //IL_037a: Unknown result type (might be due to invalid IL or missing references)
66442 //IL_0399: Unknown result type (might be due to invalid IL or missing references)
66443 //IL_04c6: Unknown result type (might be due to invalid IL or missing references)
66444 //IL_0515: Unknown result type (might be due to invalid IL or missing references)
66446 {
66447 GenVars.numOceanCaveTreasure = 0;
66448 }
66449 Vector2D val = default(Vector2D);
66450 val.X = i;
66451 val.Y = j;
66452 Vector2D val2 = default(Vector2D);
66453 if (i < Main.maxTilesX / 2)
66454 {
66455 val2.X = 0.25 + genRand.NextDouble() * 0.25;
66456 }
66457 else
66458 {
66459 val2.X = -0.35 - genRand.NextDouble() * 0.5;
66460 }
66461 val2.Y = 0.4 + genRand.NextDouble() * 0.25;
66462 ushort num = 264;
66463 ushort num2 = 53;
66464 ushort num3 = 397;
66465 double num4 = genRand.Next(17, 25);
66466 double num5 = genRand.Next(600, 800);
66467 double num6 = 4.0;
66468 bool flag = true;
66469 while (num4 > num6 && num5 > 0.0)
66470 {
66471 bool flag2 = true;
66472 bool flag3 = true;
66473 bool flag4 = true;
66474 if (val.X > (double)(beachDistance - 50) && val.X < (double)(Main.maxTilesX - beachDistance + 50))
66475 {
66476 num4 *= 0.96;
66477 num5 *= 0.96;
66478 }
66479 if (num4 < num6 + 2.0 || num5 < 20.0)
66480 {
66481 flag4 = false;
66482 }
66483 if (flag)
66484 {
66485 num4 -= 0.01 + genRand.NextDouble() * 0.01;
66486 num5 -= 0.5;
66487 }
66488 else
66489 {
66490 num4 -= 0.02 + genRand.NextDouble() * 0.02;
66491 num5 -= 1.0;
66492 }
66493 if (flag4)
66494 {
66497 }
66498 int num7 = (int)(val.X - num4 * 3.0);
66499 int num8 = (int)(val.X + num4 * 3.0);
66500 int num9 = (int)(val.Y - num4 * 3.0);
66501 int num10 = (int)(val.Y + num4 * 3.0);
66502 if (num7 < 1)
66503 {
66504 num7 = 1;
66505 }
66506 if (num8 > Main.maxTilesX - 1)
66507 {
66508 num8 = Main.maxTilesX - 1;
66509 }
66510 if (num9 < 1)
66511 {
66512 num9 = 1;
66513 }
66514 if (num10 > Main.maxTilesY - 1)
66515 {
66516 num10 = Main.maxTilesY - 1;
66517 }
66518 for (int k = num7; k < num8; k++)
66519 {
66520 for (int l = num9; l < num10; l++)
66521 {
66522 if (badOceanCaveTiles(k, l))
66523 {
66524 continue;
66525 }
66526 Vector2D val3 = new Vector2D(Math.Abs((double)k - val.X), Math.Abs((double)l - val.Y));
66527 double num11 = ((Vector2D)(ref val3)).Length();
66528 if (flag4 && num11 < num4 * 0.5 + 1.0)
66529 {
66530 Main.tile[k, l].type = num;
66531 Main.tile[k, l].active(active: false);
66532 }
66533 else if (num11 < num4 * 1.5 + 1.0 && Main.tile[k, l].type != num)
66534 {
66535 if ((double)l < val.Y)
66536 {
66537 if ((val2.X < 0.0 && (double)k < val.X) || (val2.X > 0.0 && (double)k > val.X))
66538 {
66539 if (num11 < num4 * 1.1 + 1.0)
66540 {
66541 Main.tile[k, l].type = num3;
66542 if (Main.tile[k, l].liquid == byte.MaxValue)
66543 {
66544 Main.tile[k, l].wall = 0;
66545 }
66546 }
66547 else if (Main.tile[k, l].type != num3)
66548 {
66549 Main.tile[k, l].type = num2;
66550 }
66551 }
66552 }
66553 else if ((val2.X < 0.0 && k < i) || (val2.X > 0.0 && k > i))
66554 {
66555 if (Main.tile[k, l].liquid == byte.MaxValue)
66556 {
66557 Main.tile[k, l].wall = 0;
66558 }
66559 Main.tile[k, l].type = num2;
66560 Main.tile[k, l].active(active: true);
66561 if (k == (int)val.X && flag2)
66562 {
66563 flag2 = false;
66564 int num12 = 50 + genRand.Next(3);
66565 int num13 = 43 + genRand.Next(3);
66566 int num14 = 20 + genRand.Next(3);
66567 int num15 = k;
66568 int num16 = k + num14;
66569 if (val2.X < 0.0)
66570 {
66571 num15 = k - num14;
66572 num16 = k;
66573 }
66574 if (num5 < 100.0)
66575 {
66576 num12 = (int)((double)num12 * (num5 / 100.0));
66577 num13 = (int)((double)num13 * (num5 / 100.0));
66578 num14 = (int)((double)num14 * (num5 / 100.0));
66579 }
66580 if (num4 < num6 + 5.0)
66581 {
66582 double num17 = (num4 - num6) / 5.0;
66583 num12 = (int)((double)num12 * num17);
66584 num13 = (int)((double)num13 * num17);
66585 num14 = (int)((double)num14 * num17);
66586 }
66587 for (int m = num15; m <= num16; m++)
66588 {
66589 for (int n = l; n < l + num12 && !badOceanCaveTiles(m, n); n++)
66590 {
66591 if (n > l + num13)
66592 {
66593 if (SolidTile(m, n) && Main.tile[m, n].type != num2)
66594 {
66595 break;
66596 }
66597 Main.tile[m, n].type = num3;
66598 }
66599 else
66600 {
66601 Main.tile[m, n].type = num2;
66602 }
66603 Main.tile[m, n].active(active: true);
66604 if (genRand.Next(3) == 0)
66605 {
66606 Main.tile[m - 1, n].type = num2;
66607 Main.tile[m - 1, n].active(active: true);
66608 }
66609 if (genRand.Next(3) == 0)
66610 {
66611 Main.tile[m + 1, n].type = num2;
66612 Main.tile[m + 1, n].active(active: true);
66613 }
66614 }
66615 }
66616 }
66617 }
66618 }
66620 {
66621 Main.tile[k, l].liquid = byte.MaxValue;
66622 }
66623 if (!flag3 || k != (int)val.X || !((double)l > val.Y))
66624 {
66625 continue;
66626 }
66627 flag3 = false;
66628 int num18 = 100;
66629 int num19 = 2;
66630 for (int num20 = k - num19; num20 <= k + num19; num20++)
66631 {
66632 for (int num21 = l; num21 < l + num18; num21++)
66633 {
66634 if (!badOceanCaveTiles(num20, num21))
66635 {
66636 Main.tile[num20, num21].liquid = byte.MaxValue;
66637 }
66638 }
66639 }
66640 }
66641 }
66642 val += val2;
66643 val2.X += genRand.NextDouble() * 0.1 - 0.05;
66644 val2.Y += genRand.NextDouble() * 0.1 - 0.05;
66645 if (flag)
66646 {
66647 if (val.Y > (Main.worldSurface * 2.0 + Main.rockLayer) / 3.0 && val.Y > (double)(j + 30))
66648 {
66649 flag = false;
66650 }
66651 val2.Y = Utils.Clamp(val2.Y, 0.35, 1.0);
66652 }
66653 else
66654 {
66655 if (val.X < (double)(Main.maxTilesX / 2))
66656 {
66657 if (val2.X < 0.5)
66658 {
66659 val2.X += 0.02;
66660 }
66661 }
66662 else if (val2.X > -0.5)
66663 {
66664 val2.X -= 0.02;
66665 }
66666 if (!flag4)
66667 {
66668 if (val2.Y < 0.0)
66669 {
66670 val2.Y *= 0.95;
66671 }
66672 val2.Y += 0.04;
66673 }
66674 else if (val.Y < (Main.worldSurface * 4.0 + Main.rockLayer) / 5.0)
66675 {
66676 if (val2.Y < 0.0)
66677 {
66678 val2.Y *= 0.97;
66679 }
66680 val2.Y += 0.02;
66681 }
66682 else if (val2.Y > -0.1)
66683 {
66684 val2.Y *= 0.99;
66685 val2.Y -= 0.01;
66686 }
66687 val2.Y = Utils.Clamp(val2.Y, -1.0, 1.0);
66688 }
66689 if (val.X < (double)(Main.maxTilesX / 2))
66690 {
66691 val2.X = Utils.Clamp(val2.X, 0.1, 1.0);
66692 }
66693 else
66694 {
66695 val2.X = Utils.Clamp(val2.X, -1.0, -0.1);
66696 }
66697 }
66699 }
66700
66701 public static void WavyCaverer(int startX, int startY, double waveStrengthScalar, double wavePercentScalar, int steps, int type)
66702 {
66703 //IL_01c7: Unknown result type (might be due to invalid IL or missing references)
66704 //IL_01d0: Unknown result type (might be due to invalid IL or missing references)
66705 Vector2D val = default(Vector2D);
66706 ((Vector2D)(ref val))._002Ector((double)startX, (double)startY);
66707 bool flag = ((startX > Main.maxTilesX / 2) ? true : false);
66708 int num = 2 + genRand.Next(2);
66709 int num2 = 15 + genRand.Next(11);
66710 int num3 = 1 + genRand.Next(2);
66711 int num4 = (int)Math.Ceiling((double)num2 / (double)num3);
66712 double num5 = 1.0;
66713 double num6 = 1.0;
66714 int num7 = (int)(-1.0 + genRand.NextDouble() * 3.0);
66715 int num8 = num;
66716 int num9 = 0;
66717 for (int i = 0; i < steps; i++)
66718 {
66719 bool flag2 = i < num4;
66720 bool flag3 = i >= steps - num4;
66721 val.X += ((!flag) ? 1 : (-1));
66722 if (!flag2 && !flag3)
66723 {
66724 num9++;
66725 num5 = Math.Min(2.0, Math.Max(0.5, num5 + (-0.5 + genRand.NextDouble()) * 0.25));
66726 num6 = Math.Min(1.1, Math.Max(0.9, num6 + (-0.5 + genRand.NextDouble()) * 0.02));
66727 }
66728 double num10 = Math.Sin((double)num9 * 0.1 * num6 * wavePercentScalar) * num5 * waveStrengthScalar;
66729 val.Y = (double)startY + num10 + (double)(num9 * num7);
66730 int num11 = num8;
66731 if (flag2)
66732 {
66733 num8 = Math.Min(num2, num8 + num3);
66734 }
66735 else if (flag3)
66736 {
66737 num8 = Math.Max(num, num8 - num3);
66738 }
66739 val.Y -= (num11 + num8) / 4;
66740 for (int j = 0; j < num8; j++)
66741 {
66742 int num12 = (int)val.X;
66743 int num13 = (int)val.Y + j;
66744 if (InWorld(num12, num13, 20))
66745 {
66746 if (type >= 0)
66747 {
66748 PlaceTile(num12, num13, type, mute: true, forced: true);
66749 }
66750 else
66751 {
66752 KillTile(num12, num13);
66753 }
66754 }
66755 }
66756 }
66757 }
66758
66759 public 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)
66760 {
66761 //IL_01f3: Unknown result type (might be due to invalid IL or missing references)
66762 //IL_0239: Unknown result type (might be due to invalid IL or missing references)
66763 //IL_024e: Unknown result type (might be due to invalid IL or missing references)
66764 //IL_0264: Unknown result type (might be due to invalid IL or missing references)
66765 //IL_0279: Unknown result type (might be due to invalid IL or missing references)
66766 //IL_0958: Unknown result type (might be due to invalid IL or missing references)
66767 //IL_0959: Unknown result type (might be due to invalid IL or missing references)
66768 //IL_095a: Unknown result type (might be due to invalid IL or missing references)
66769 //IL_095f: Unknown result type (might be due to invalid IL or missing references)
66770 //IL_0987: Unknown result type (might be due to invalid IL or missing references)
66771 //IL_0988: Unknown result type (might be due to invalid IL or missing references)
66772 //IL_0989: Unknown result type (might be due to invalid IL or missing references)
66773 //IL_098e: Unknown result type (might be due to invalid IL or missing references)
66774 //IL_0eeb: Unknown result type (might be due to invalid IL or missing references)
66775 //IL_09f5: Unknown result type (might be due to invalid IL or missing references)
66776 //IL_09f6: Unknown result type (might be due to invalid IL or missing references)
66777 //IL_09f7: Unknown result type (might be due to invalid IL or missing references)
66778 //IL_09fc: Unknown result type (might be due to invalid IL or missing references)
66779 //IL_0f0c: Unknown result type (might be due to invalid IL or missing references)
66780 //IL_0a63: Unknown result type (might be due to invalid IL or missing references)
66781 //IL_0a64: Unknown result type (might be due to invalid IL or missing references)
66782 //IL_0a65: Unknown result type (might be due to invalid IL or missing references)
66783 //IL_0a6a: Unknown result type (might be due to invalid IL or missing references)
66784 //IL_0ad1: Unknown result type (might be due to invalid IL or missing references)
66785 //IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
66786 //IL_0ad3: Unknown result type (might be due to invalid IL or missing references)
66787 //IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
66788 //IL_034a: Unknown result type (might be due to invalid IL or missing references)
66789 //IL_0359: Unknown result type (might be due to invalid IL or missing references)
66790 //IL_0f55: Unknown result type (might be due to invalid IL or missing references)
66791 //IL_0b3f: Unknown result type (might be due to invalid IL or missing references)
66792 //IL_0b40: Unknown result type (might be due to invalid IL or missing references)
66793 //IL_0b41: Unknown result type (might be due to invalid IL or missing references)
66794 //IL_0b46: Unknown result type (might be due to invalid IL or missing references)
66795 //IL_0f76: Unknown result type (might be due to invalid IL or missing references)
66796 //IL_0bad: Unknown result type (might be due to invalid IL or missing references)
66797 //IL_0bae: Unknown result type (might be due to invalid IL or missing references)
66798 //IL_0baf: Unknown result type (might be due to invalid IL or missing references)
66799 //IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
66800 //IL_0fac: Unknown result type (might be due to invalid IL or missing references)
66801 //IL_0c1b: Unknown result type (might be due to invalid IL or missing references)
66802 //IL_0c1c: Unknown result type (might be due to invalid IL or missing references)
66803 //IL_0c1d: Unknown result type (might be due to invalid IL or missing references)
66804 //IL_0c22: Unknown result type (might be due to invalid IL or missing references)
66805 //IL_0ffe: Unknown result type (might be due to invalid IL or missing references)
66806 //IL_0fcd: Unknown result type (might be due to invalid IL or missing references)
66807 //IL_0c89: Unknown result type (might be due to invalid IL or missing references)
66808 //IL_0c8a: Unknown result type (might be due to invalid IL or missing references)
66809 //IL_0c8b: Unknown result type (might be due to invalid IL or missing references)
66810 //IL_0c90: Unknown result type (might be due to invalid IL or missing references)
66811 //IL_0657: Unknown result type (might be due to invalid IL or missing references)
66812 //IL_0666: Unknown result type (might be due to invalid IL or missing references)
66813 //IL_101f: Unknown result type (might be due to invalid IL or missing references)
66814 //IL_0cf7: Unknown result type (might be due to invalid IL or missing references)
66815 //IL_0cf8: Unknown result type (might be due to invalid IL or missing references)
66816 //IL_0cf9: Unknown result type (might be due to invalid IL or missing references)
66817 //IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
66818 //IL_06ba: Unknown result type (might be due to invalid IL or missing references)
66819 //IL_06c9: Unknown result type (might be due to invalid IL or missing references)
66820 //IL_03ed: Unknown result type (might be due to invalid IL or missing references)
66821 //IL_03fc: Unknown result type (might be due to invalid IL or missing references)
66822 //IL_1040: Unknown result type (might be due to invalid IL or missing references)
66823 //IL_0d65: Unknown result type (might be due to invalid IL or missing references)
66824 //IL_0d66: Unknown result type (might be due to invalid IL or missing references)
66825 //IL_0d67: Unknown result type (might be due to invalid IL or missing references)
66826 //IL_0d6c: Unknown result type (might be due to invalid IL or missing references)
66827 //IL_1067: Unknown result type (might be due to invalid IL or missing references)
66828 //IL_0dd3: Unknown result type (might be due to invalid IL or missing references)
66829 //IL_0dd4: Unknown result type (might be due to invalid IL or missing references)
66830 //IL_0dd5: Unknown result type (might be due to invalid IL or missing references)
66831 //IL_0dda: Unknown result type (might be due to invalid IL or missing references)
66832 //IL_0e3e: Unknown result type (might be due to invalid IL or missing references)
66833 //IL_0e3f: Unknown result type (might be due to invalid IL or missing references)
66834 //IL_0e40: Unknown result type (might be due to invalid IL or missing references)
66835 //IL_0e45: Unknown result type (might be due to invalid IL or missing references)
66836 if (!GenVars.mudWall)
66837 {
66838 if (drunkWorldGen)
66839 {
66840 strength *= 1.0 + (double)genRand.Next(-80, 81) * 0.01;
66841 steps = (int)((double)steps * (1.0 + (double)genRand.Next(-80, 81) * 0.01));
66842 }
66843 else if (remixWorldGen)
66844 {
66845 strength *= 1.0 + (double)genRand.Next(-50, 51) * 0.01;
66846 }
66847 else if (getGoodWorldGen && type != 57)
66848 {
66849 strength *= 1.0 + (double)genRand.Next(-80, 81) * 0.015;
66850 steps += genRand.Next(3);
66851 }
66852 }
66853 double num = strength;
66854 double num2 = steps;
66855 Vector2D val = default(Vector2D);
66856 val.X = i;
66857 val.Y = j;
66858 Vector2D val2 = default(Vector2D);
66859 val2.X = (double)genRand.Next(-10, 11) * 0.1;
66860 val2.Y = (double)genRand.Next(-10, 11) * 0.1;
66861 if (speedX != 0.0 || speedY != 0.0)
66862 {
66863 val2.X = speedX;
66864 val2.Y = speedY;
66865 }
66866 bool flag = type == 368;
66867 bool flag2 = type == 367;
66868 bool lava = false;
66869 if (getGoodWorldGen && genRand.Next(4) == 0)
66870 {
66871 lava = true;
66872 }
66873 while (num > 0.0 && num2 > 0.0)
66874 {
66875 if (drunkWorldGen && genRand.Next(30) == 0)
66876 {
66877 val.X += (double)genRand.Next(-100, 101) * 0.05;
66878 val.Y += (double)genRand.Next(-100, 101) * 0.05;
66879 }
66880 if (val.Y < 0.0 && num2 > 0.0 && type == 59)
66881 {
66882 num2 = 0.0;
66883 }
66884 num = strength * (num2 / (double)steps);
66885 num2 -= 1.0;
66886 int num3 = (int)(val.X - num * 0.5);
66887 int num4 = (int)(val.X + num * 0.5);
66888 int num5 = (int)(val.Y - num * 0.5);
66889 int num6 = (int)(val.Y + num * 0.5);
66890 if (num3 < 1)
66891 {
66892 num3 = 1;
66893 }
66894 if (num4 > Main.maxTilesX - 1)
66895 {
66896 num4 = Main.maxTilesX - 1;
66897 }
66898 if (num5 < 1)
66899 {
66900 num5 = 1;
66901 }
66902 if (num6 > Main.maxTilesY - 1)
66903 {
66904 num6 = Main.maxTilesY - 1;
66905 }
66906 for (int k = num3; k < num4; k++)
66907 {
66908 if (k < beachDistance + 50 || k >= Main.maxTilesX - beachDistance - 50)
66909 {
66910 lava = false;
66911 }
66912 for (int l = num5; l < num6; l++)
66913 {
66914 if ((drunkWorldGen && l < Main.maxTilesY - 300 && type == 57) || (ignoreTileType >= 0 && Main.tile[k, l].active() && Main.tile[k, l].type == ignoreTileType) || !(Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < strength * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015)))
66915 {
66916 continue;
66917 }
66918 if (GenVars.mudWall && (double)l > Main.worldSurface && Main.tile[k, l - 1].wall != 2 && l < Main.maxTilesY - 210 - genRand.Next(3) && Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < strength * 0.45 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
66919 {
66920 if (l > GenVars.lavaLine - genRand.Next(0, 4) - 50)
66921 {
66922 if (Main.tile[k, l - 1].wall != 64 && Main.tile[k, l + 1].wall != 64 && Main.tile[k - 1, l].wall != 64 && Main.tile[k + 1, l].wall != 64)
66923 {
66924 PlaceWall(k, l, 15, mute: true);
66925 }
66926 }
66927 else if (Main.tile[k, l - 1].wall != 15 && Main.tile[k, l + 1].wall != 15 && Main.tile[k - 1, l].wall != 15 && Main.tile[k + 1, l].wall != 15)
66928 {
66929 PlaceWall(k, l, 64, mute: true);
66930 }
66931 }
66932 if (type < 0)
66933 {
66934 if (Main.tile[k, l].type == 53)
66935 {
66936 continue;
66937 }
66938 if (type == -2 && Main.tile[k, l].active() && (l < GenVars.waterLine || l > GenVars.lavaLine))
66939 {
66940 Main.tile[k, l].liquid = byte.MaxValue;
66941 Main.tile[k, l].lava(lava);
66942 if (remixWorldGen)
66943 {
66944 if (l > GenVars.lavaLine && ((double)l < Main.rockLayer - 80.0 || l > Main.maxTilesY - 350) && !oceanDepths(k, l))
66945 {
66946 Main.tile[k, l].lava(lava: true);
66947 }
66948 }
66949 else if (l > GenVars.lavaLine)
66950 {
66951 Main.tile[k, l].lava(lava: true);
66952 }
66953 }
66954 Main.tile[k, l].active(active: false);
66955 continue;
66956 }
66957 if (flag && Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < strength * 0.3 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
66958 {
66959 PlaceWall(k, l, 180, mute: true);
66960 }
66961 if (flag2 && Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < strength * 0.3 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
66962 {
66963 PlaceWall(k, l, 178, mute: true);
66964 }
66965 if (overRide || !Main.tile[k, l].active())
66966 {
66967 Tile tile = Main.tile[k, l];
66968 bool flag3 = false;
66969 flag3 = Main.tileStone[type] && tile.type != 1;
66971 {
66972 flag3 = true;
66973 }
66974 switch (tile.type)
66975 {
66976 case 53:
66977 if (type == 59 && GenVars.UndergroundDesertLocation.Contains(k, l))
66978 {
66979 flag3 = true;
66980 }
66981 if (type == 40)
66982 {
66983 flag3 = true;
66984 }
66985 if ((double)l < Main.worldSurface && type != 59)
66986 {
66987 flag3 = true;
66988 }
66989 break;
66990 case 45:
66991 case 147:
66992 case 189:
66993 case 190:
66994 case 196:
66995 case 460:
66996 flag3 = true;
66997 break;
66998 case 396:
66999 case 397:
67000 flag3 = !TileID.Sets.Ore[type];
67001 break;
67002 case 1:
67003 if (type == 59 && (double)l < Main.worldSurface + (double)genRand.Next(-50, 50))
67004 {
67005 flag3 = true;
67006 }
67007 break;
67008 case 367:
67009 case 368:
67010 if (type == 59)
67011 {
67012 flag3 = true;
67013 }
67014 break;
67015 }
67016 if (!flag3)
67017 {
67018 tile.type = (ushort)type;
67019 }
67020 }
67021 if (addTile)
67022 {
67023 Main.tile[k, l].active(active: true);
67024 Main.tile[k, l].liquid = 0;
67025 Main.tile[k, l].lava(lava: false);
67026 }
67027 if (noYChange && (double)l < Main.worldSurface && type != 59)
67028 {
67029 Main.tile[k, l].wall = 2;
67030 }
67031 if (type == 59 && l > GenVars.waterLine && Main.tile[k, l].liquid > 0)
67032 {
67033 Main.tile[k, l].lava(lava: false);
67034 Main.tile[k, l].liquid = 0;
67035 }
67036 }
67037 }
67038 val += val2;
67039 if ((!drunkWorldGen || genRand.Next(3) != 0) && num > 50.0)
67040 {
67041 val += val2;
67042 num2 -= 1.0;
67043 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67044 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67045 if (num > 100.0)
67046 {
67047 val += val2;
67048 num2 -= 1.0;
67049 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67050 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67051 if (num > 150.0)
67052 {
67053 val += val2;
67054 num2 -= 1.0;
67055 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67056 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67057 if (num > 200.0)
67058 {
67059 val += val2;
67060 num2 -= 1.0;
67061 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67062 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67063 if (num > 250.0)
67064 {
67065 val += val2;
67066 num2 -= 1.0;
67067 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67068 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67069 if (num > 300.0)
67070 {
67071 val += val2;
67072 num2 -= 1.0;
67073 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67074 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67075 if (num > 400.0)
67076 {
67077 val += val2;
67078 num2 -= 1.0;
67079 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67080 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67081 if (num > 500.0)
67082 {
67083 val += val2;
67084 num2 -= 1.0;
67085 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67086 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67087 if (num > 600.0)
67088 {
67089 val += val2;
67090 num2 -= 1.0;
67091 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67092 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67093 if (num > 700.0)
67094 {
67095 val += val2;
67096 num2 -= 1.0;
67097 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67098 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67099 if (num > 800.0)
67100 {
67101 val += val2;
67102 num2 -= 1.0;
67103 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67104 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67105 if (num > 900.0)
67106 {
67107 val += val2;
67108 num2 -= 1.0;
67109 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67110 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67111 }
67112 }
67113 }
67114 }
67115 }
67116 }
67117 }
67118 }
67119 }
67120 }
67121 }
67122 }
67123 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67124 if (drunkWorldGen)
67125 {
67126 val2.X += (double)genRand.Next(-10, 11) * 0.25;
67127 }
67128 if (val2.X > 1.0)
67129 {
67130 val2.X = 1.0;
67131 }
67132 if (val2.X < -1.0)
67133 {
67134 val2.X = -1.0;
67135 }
67136 if (!noYChange)
67137 {
67138 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67139 if (val2.Y > 1.0)
67140 {
67141 val2.Y = 1.0;
67142 }
67143 if (val2.Y < -1.0)
67144 {
67145 val2.Y = -1.0;
67146 }
67147 }
67148 else if (type != 59 && num < 3.0)
67149 {
67150 if (val2.Y > 1.0)
67151 {
67152 val2.Y = 1.0;
67153 }
67154 if (val2.Y < -1.0)
67155 {
67156 val2.Y = -1.0;
67157 }
67158 }
67159 if (type == 59 && !noYChange)
67160 {
67161 if (val2.Y > 0.5)
67162 {
67163 val2.Y = 0.5;
67164 }
67165 if (val2.Y < -0.5)
67166 {
67167 val2.Y = -0.5;
67168 }
67169 if (val.Y < Main.rockLayer + 100.0)
67170 {
67171 val2.Y = 1.0;
67172 }
67173 if (val.Y > (double)(Main.maxTilesY - 300))
67174 {
67175 val2.Y = -1.0;
67176 }
67177 }
67178 }
67179 }
67180
67181 public static void DirtyRockRunner(int i, int j)
67182 {
67183 //IL_0092: Unknown result type (might be due to invalid IL or missing references)
67184 //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
67185 //IL_00bd: Unknown result type (might be due to invalid IL or missing references)
67186 //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
67187 //IL_01be: Unknown result type (might be due to invalid IL or missing references)
67188 //IL_01bf: Unknown result type (might be due to invalid IL or missing references)
67189 //IL_01c0: Unknown result type (might be due to invalid IL or missing references)
67190 //IL_01c5: Unknown result type (might be due to invalid IL or missing references)
67191 //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
67192 //IL_020b: Unknown result type (might be due to invalid IL or missing references)
67193 //IL_0127: Unknown result type (might be due to invalid IL or missing references)
67194 //IL_0136: Unknown result type (might be due to invalid IL or missing references)
67195 //IL_0250: Unknown result type (might be due to invalid IL or missing references)
67196 //IL_0271: Unknown result type (might be due to invalid IL or missing references)
67197 double num = genRand.Next(2, 6);
67198 double num2 = genRand.Next(5, 50);
67199 double num3 = num2;
67200 Vector2D val = default(Vector2D);
67201 val.X = i;
67202 val.Y = j;
67203 Vector2D val2 = default(Vector2D);
67204 val2.X = (double)genRand.Next(-10, 11) * 0.1;
67205 val2.Y = (double)genRand.Next(-10, 11) * 0.1;
67206 while (num > 0.0 && num3 > 0.0)
67207 {
67208 double num4 = num * (num3 / num2);
67209 num3 -= 1.0;
67210 int num5 = (int)(val.X - num4 * 0.5);
67211 int num6 = (int)(val.X + num4 * 0.5);
67212 int num7 = (int)(val.Y - num4 * 0.5);
67213 int num8 = (int)(val.Y + num4 * 0.5);
67214 if (num5 < 0)
67215 {
67216 num5 = 0;
67217 }
67218 if (num6 > Main.maxTilesX)
67219 {
67221 }
67222 if (num7 < 0)
67223 {
67224 num7 = 0;
67225 }
67226 if (num8 > Main.maxTilesY)
67227 {
67229 }
67230 for (int k = num5; k < num6; k++)
67231 {
67232 for (int l = num7; l < num8; l++)
67233 {
67234 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[k, l].wall == 2)
67235 {
67236 Main.tile[k, l].wall = 59;
67237 }
67238 }
67239 }
67240 val += val2;
67241 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67242 if (val2.X > 1.0)
67243 {
67244 val2.X = 1.0;
67245 }
67246 if (val2.X < -1.0)
67247 {
67248 val2.X = -1.0;
67249 }
67250 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67251 if (val2.Y > 1.0)
67252 {
67253 val2.Y = 1.0;
67254 }
67255 if (val2.Y < -1.0)
67256 {
67257 val2.Y = -1.0;
67258 }
67259 }
67260 }
67261
67262 public static void MudWallRunner(int i, int j)
67263 {
67264 //IL_0093: Unknown result type (might be due to invalid IL or missing references)
67265 //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
67266 //IL_00be: Unknown result type (might be due to invalid IL or missing references)
67267 //IL_00d3: Unknown result type (might be due to invalid IL or missing references)
67268 //IL_01ac: Unknown result type (might be due to invalid IL or missing references)
67269 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
67270 //IL_01ae: Unknown result type (might be due to invalid IL or missing references)
67271 //IL_01b3: Unknown result type (might be due to invalid IL or missing references)
67272 //IL_01d8: Unknown result type (might be due to invalid IL or missing references)
67273 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
67274 //IL_0125: Unknown result type (might be due to invalid IL or missing references)
67275 //IL_0134: Unknown result type (might be due to invalid IL or missing references)
67276 //IL_023e: Unknown result type (might be due to invalid IL or missing references)
67277 //IL_025f: Unknown result type (might be due to invalid IL or missing references)
67278 double num = genRand.Next(8, 21);
67279 double num2 = genRand.Next(8, 33);
67280 double num3 = num2;
67281 Vector2D val = default(Vector2D);
67282 val.X = i;
67283 val.Y = j;
67284 Vector2D val2 = default(Vector2D);
67285 val2.X = (double)genRand.Next(-10, 11) * 0.1;
67286 val2.Y = (double)genRand.Next(-10, 11) * 0.1;
67287 while (num > 0.0 && num3 > 0.0)
67288 {
67289 double num4 = num * (num3 / num2);
67290 num3 -= 1.0;
67291 int num5 = (int)(val.X - num4 * 0.5);
67292 int num6 = (int)(val.X + num4 * 0.5);
67293 int num7 = (int)(val.Y - num4 * 0.5);
67294 int num8 = (int)(val.Y + num4 * 0.5);
67295 if (num5 < 0)
67296 {
67297 num5 = 0;
67298 }
67299 if (num6 > Main.maxTilesX)
67300 {
67302 }
67303 if (num7 < 0)
67304 {
67305 num7 = 0;
67306 }
67307 if (num8 > Main.maxTilesY)
67308 {
67310 }
67311 for (int k = num5; k < num6; k++)
67312 {
67313 for (int l = num7; l < num8; l++)
67314 {
67315 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && (double)l > Main.worldSurface)
67316 {
67317 Main.tile[k, l].wall = 0;
67318 }
67319 }
67320 }
67321 val += val2;
67322 val2.X += (double)genRand.Next(-10, 11) * 0.05;
67323 if (val2.X > 1.0)
67324 {
67325 val2.X = 1.0;
67326 }
67327 if (val2.X < -1.0)
67328 {
67329 val2.X = -1.0;
67330 }
67331 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
67332 if (val2.Y > 1.0)
67333 {
67334 val2.Y = 1.0;
67335 }
67336 if (val2.Y < -1.0)
67337 {
67338 val2.Y = -1.0;
67339 }
67340 }
67341 }
67342
67343 public static void SnowCloudIsland(int i, int j)
67344 {
67345 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
67346 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
67347 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
67348 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
67349 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
67350 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
67351 //IL_0563: Unknown result type (might be due to invalid IL or missing references)
67352 //IL_0574: Unknown result type (might be due to invalid IL or missing references)
67353 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
67354 //IL_05c9: Unknown result type (might be due to invalid IL or missing references)
67355 //IL_05de: Unknown result type (might be due to invalid IL or missing references)
67356 //IL_05f9: Unknown result type (might be due to invalid IL or missing references)
67357 //IL_02d3: Unknown result type (might be due to invalid IL or missing references)
67358 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
67359 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
67360 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
67361 //IL_02ff: Unknown result type (might be due to invalid IL or missing references)
67362 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
67363 //IL_0320: Unknown result type (might be due to invalid IL or missing references)
67364 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
67365 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
67366 //IL_0341: Unknown result type (might be due to invalid IL or missing references)
67367 //IL_01ee: Unknown result type (might be due to invalid IL or missing references)
67368 //IL_0362: Unknown result type (might be due to invalid IL or missing references)
67369 //IL_0659: Unknown result type (might be due to invalid IL or missing references)
67370 //IL_077b: Unknown result type (might be due to invalid IL or missing references)
67371 //IL_077c: Unknown result type (might be due to invalid IL or missing references)
67372 //IL_077d: Unknown result type (might be due to invalid IL or missing references)
67373 //IL_0782: Unknown result type (might be due to invalid IL or missing references)
67374 //IL_07a7: Unknown result type (might be due to invalid IL or missing references)
67375 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
67376 //IL_0224: Unknown result type (might be due to invalid IL or missing references)
67377 //IL_0694: Unknown result type (might be due to invalid IL or missing references)
67378 //IL_07c8: Unknown result type (might be due to invalid IL or missing references)
67379 //IL_06a6: Unknown result type (might be due to invalid IL or missing references)
67380 //IL_069c: Unknown result type (might be due to invalid IL or missing references)
67381 //IL_07e9: Unknown result type (might be due to invalid IL or missing references)
67382 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
67383 //IL_080a: Unknown result type (might be due to invalid IL or missing references)
67384 //IL_06df: Unknown result type (might be due to invalid IL or missing references)
67385 //IL_06ee: Unknown result type (might be due to invalid IL or missing references)
67386 double num = genRand.Next(100, 150);
67387 double num2 = num;
67388 double num3 = genRand.Next(20, 30);
67389 int num4 = i;
67390 int num5 = i;
67391 int num6 = i;
67392 int num7 = j;
67393 Vector2D val = default(Vector2D);
67394 val.X = i;
67395 val.Y = j;
67396 Vector2D val2 = default(Vector2D);
67397 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67398 while (val2.X > -2.0 && val2.X < 2.0)
67399 {
67400 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67401 }
67402 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
67403 while (num > 0.0 && num3 > 0.0)
67404 {
67405 num -= (double)genRand.Next(4);
67406 num3 -= 1.0;
67407 int num8 = (int)(val.X - num * 0.5);
67408 int num9 = (int)(val.X + num * 0.5);
67409 int num10 = (int)(val.Y - num * 0.5);
67410 int num11 = (int)(val.Y + num * 0.5);
67411 if (num8 < 0)
67412 {
67413 num8 = 0;
67414 }
67415 if (num9 > Main.maxTilesX)
67416 {
67418 }
67419 if (num10 < 0)
67420 {
67421 num10 = 0;
67422 }
67423 if (num11 > Main.maxTilesY)
67424 {
67426 }
67427 num2 = num * (double)genRand.Next(80, 120) * 0.01;
67428 double num12 = val.Y + 1.0;
67429 for (int k = num8; k < num9; k++)
67430 {
67431 if (genRand.Next(2) == 0)
67432 {
67433 num12 += (double)genRand.Next(-1, 2);
67434 }
67435 if (num12 < val.Y)
67436 {
67437 num12 = val.Y;
67438 }
67439 if (num12 > val.Y + 2.0)
67440 {
67441 num12 = val.Y + 2.0;
67442 }
67443 for (int l = num10; l < num11; l++)
67444 {
67445 if (!((double)l > num12))
67446 {
67447 continue;
67448 }
67449 double num13 = Math.Abs((double)k - val.X);
67450 double num14 = Math.Abs((double)l - val.Y) * 3.0;
67451 if (Math.Sqrt(num13 * num13 + num14 * num14) < num2 * 0.4)
67452 {
67453 if (k < num4)
67454 {
67455 num4 = k;
67456 }
67457 if (k > num5)
67458 {
67459 num5 = k;
67460 }
67461 if (l < num6)
67462 {
67463 num6 = l;
67464 }
67465 if (l > num7)
67466 {
67467 num7 = l;
67468 }
67469 Main.tile[k, l].active(active: true);
67470 Main.tile[k, l].type = 189;
67471 SquareTileFrame(k, l);
67472 }
67473 }
67474 }
67475 val += val2;
67476 val2.X += (double)genRand.Next(-20, 21) * 0.05;
67477 if (val2.X > 1.0)
67478 {
67479 val2.X = 1.0;
67480 }
67481 if (val2.X < -1.0)
67482 {
67483 val2.X = -1.0;
67484 }
67485 if (val2.Y > 0.2)
67486 {
67487 val2.Y = -0.2;
67488 }
67489 if (val2.Y < -0.2)
67490 {
67491 val2.Y = -0.2;
67492 }
67493 }
67494 int num15 = num4;
67495 int num17;
67496 for (num15 += genRand.Next(5); num15 < num5; num15 += genRand.Next(num17, (int)((double)num17 * 1.5)))
67497 {
67498 int num16 = num7;
67499 while (!Main.tile[num15, num16].active())
67500 {
67501 num16--;
67502 }
67503 num16 += genRand.Next(-3, 4);
67504 num17 = genRand.Next(4, 8);
67505 int num18 = 189;
67506 if (genRand.Next(4) == 0)
67507 {
67508 num18 = 460;
67509 }
67510 for (int m = num15 - num17; m <= num15 + num17; m++)
67511 {
67512 for (int n = num16 - num17; n <= num16 + num17; n++)
67513 {
67514 if (n > num6)
67515 {
67516 double num19 = Math.Abs(m - num15);
67517 double num20 = Math.Abs(n - num16) * 2;
67518 if (Math.Sqrt(num19 * num19 + num20 * num20) < (double)(num17 + genRand.Next(2)))
67519 {
67520 Main.tile[m, n].active(active: true);
67521 Main.tile[m, n].type = (ushort)num18;
67522 SquareTileFrame(m, n);
67523 }
67524 }
67525 }
67526 }
67527 }
67528 num = genRand.Next(80, 95);
67529 num2 = num;
67530 num3 = genRand.Next(10, 15);
67531 val.X = i;
67532 val.Y = num6;
67533 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67534 while (val2.X > -2.0 && val2.X < 2.0)
67535 {
67536 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67537 }
67538 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
67539 while (num > 0.0 && num3 > 0.0)
67540 {
67541 num -= (double)genRand.Next(4);
67542 num3 -= 1.0;
67543 int num8 = (int)(val.X - num * 0.5);
67544 int num9 = (int)(val.X + num * 0.5);
67545 int num10 = num6 - 1;
67546 int num11 = (int)(val.Y + num * 0.5);
67547 if (num8 < 0)
67548 {
67549 num8 = 0;
67550 }
67551 if (num9 > Main.maxTilesX)
67552 {
67554 }
67555 if (num10 < 0)
67556 {
67557 num10 = 0;
67558 }
67559 if (num11 > Main.maxTilesY)
67560 {
67562 }
67563 num2 = num * (double)genRand.Next(80, 120) * 0.01;
67564 double num21 = val.Y + 1.0;
67565 for (int num22 = num8; num22 < num9; num22++)
67566 {
67567 if (genRand.Next(2) == 0)
67568 {
67569 num21 += (double)genRand.Next(-1, 2);
67570 }
67571 if (num21 < val.Y)
67572 {
67573 num21 = val.Y;
67574 }
67575 if (num21 > val.Y + 2.0)
67576 {
67577 num21 = val.Y + 2.0;
67578 }
67579 for (int num23 = num10; num23 < num11; num23++)
67580 {
67581 if ((double)num23 > num21)
67582 {
67583 double num24 = Math.Abs((double)num22 - val.X);
67584 double num25 = Math.Abs((double)num23 - val.Y) * 3.0;
67585 if (Math.Sqrt(num24 * num24 + num25 * num25) < num2 * 0.4 && Main.tile[num22, num23].type == 189)
67586 {
67587 Main.tile[num22, num23].type = 147;
67588 SquareTileFrame(num22, num23);
67589 }
67590 }
67591 }
67592 }
67593 val += val2;
67594 val2.X += (double)genRand.Next(-20, 21) * 0.05;
67595 if (val2.X > 1.0)
67596 {
67597 val2.X = 1.0;
67598 }
67599 if (val2.X < -1.0)
67600 {
67601 val2.X = -1.0;
67602 }
67603 if (val2.Y > 0.2)
67604 {
67605 val2.Y = -0.2;
67606 }
67607 if (val2.Y < -0.2)
67608 {
67609 val2.Y = -0.2;
67610 }
67611 }
67612 int num26 = num4;
67613 num26 += genRand.Next(5);
67614 while (num26 < num5)
67615 {
67616 int num27 = num7;
67617 while ((!Main.tile[num26, num27].active() || Main.tile[num26, num27].type != 0) && num26 < num5)
67618 {
67619 num27--;
67620 if (num27 < num6)
67621 {
67622 num27 = num7;
67623 num26 += genRand.Next(1, 4);
67624 }
67625 }
67626 if (num26 >= num5)
67627 {
67628 continue;
67629 }
67630 num27 += genRand.Next(0, 4);
67631 int num28 = genRand.Next(2, 5);
67632 int num29 = 189;
67633 for (int num30 = num26 - num28; num30 <= num26 + num28; num30++)
67634 {
67635 for (int num31 = num27 - num28; num31 <= num27 + num28; num31++)
67636 {
67637 if (num31 > num6)
67638 {
67639 double num32 = Math.Abs(num30 - num26);
67640 double num33 = Math.Abs(num31 - num27) * 2;
67641 if (Math.Sqrt(num32 * num32 + num33 * num33) < (double)num28)
67642 {
67643 Main.tile[num30, num31].type = (ushort)num29;
67644 SquareTileFrame(num30, num31);
67645 }
67646 }
67647 }
67648 }
67649 num26 += genRand.Next(num28, (int)((double)num28 * 1.5));
67650 }
67651 for (int num34 = num4 - 20; num34 <= num5 + 20; num34++)
67652 {
67653 for (int num35 = num6 - 20; num35 <= num7 + 20; num35++)
67654 {
67655 bool flag = true;
67656 for (int num36 = num34 - 1; num36 <= num34 + 1; num36++)
67657 {
67658 for (int num37 = num35 - 1; num37 <= num35 + 1; num37++)
67659 {
67660 if (!Main.tile[num36, num37].active())
67661 {
67662 flag = false;
67663 }
67664 }
67665 }
67666 if (flag)
67667 {
67668 Main.tile[num34, num35].wall = 73;
67669 SquareWallFrame(num34, num35);
67670 }
67671 }
67672 }
67673 for (int num38 = num4; num38 <= num5; num38++)
67674 {
67675 int num39;
67676 for (num39 = num6 - 10; !Main.tile[num38, num39 + 1].active(); num39++)
67677 {
67678 }
67679 if (num39 >= num7 || Main.tile[num38, num39 + 1].type != 189)
67680 {
67681 continue;
67682 }
67683 if (genRand.Next(10) == 0)
67684 {
67685 int num40 = genRand.Next(1, 3);
67686 for (int num41 = num38 - num40; num41 <= num38 + num40; num41++)
67687 {
67688 if (Main.tile[num41, num39].type == 189 && WillWaterPlacedHereStayPut(num41, num39))
67689 {
67690 Main.tile[num41, num39].active(active: false);
67691 Main.tile[num41, num39].liquid = byte.MaxValue;
67692 Main.tile[num41, num39].lava(lava: false);
67693 SquareTileFrame(num38, num39);
67694 }
67695 if (Main.tile[num41, num39 + 1].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 1))
67696 {
67697 Main.tile[num41, num39 + 1].active(active: false);
67698 Main.tile[num41, num39 + 1].liquid = byte.MaxValue;
67699 Main.tile[num41, num39 + 1].lava(lava: false);
67700 SquareTileFrame(num38, num39 + 1);
67701 }
67702 if (num41 > num38 - num40 && num41 < num38 + 2 && Main.tile[num41, num39 + 2].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 2))
67703 {
67704 Main.tile[num41, num39 + 2].active(active: false);
67705 Main.tile[num41, num39 + 2].liquid = byte.MaxValue;
67706 Main.tile[num41, num39 + 2].lava(lava: false);
67707 SquareTileFrame(num38, num39 + 2);
67708 }
67709 }
67710 }
67711 if (genRand.Next(5) == 0 && WillWaterPlacedHereStayPut(num38, num39))
67712 {
67713 Main.tile[num38, num39].liquid = byte.MaxValue;
67714 }
67715 Main.tile[num38, num39].lava(lava: false);
67716 SquareTileFrame(num38, num39);
67717 }
67718 int num42 = genRand.Next(4);
67719 for (int num43 = 0; num43 <= num42; num43++)
67720 {
67721 int num44 = genRand.Next(num4 - 5, num5 + 5);
67722 int num45 = num6 - genRand.Next(20, 40);
67723 int num46 = genRand.Next(4, 8);
67724 int num47 = 189;
67725 if (genRand.Next(2) == 0)
67726 {
67727 num47 = 460;
67728 }
67729 for (int num48 = num44 - num46; num48 <= num44 + num46; num48++)
67730 {
67731 for (int num49 = num45 - num46; num49 <= num45 + num46; num49++)
67732 {
67733 double num50 = Math.Abs(num48 - num44);
67734 double num51 = Math.Abs(num49 - num45) * 2;
67735 if (Math.Sqrt(num50 * num50 + num51 * num51) < (double)(num46 + genRand.Next(-1, 2)))
67736 {
67737 Main.tile[num48, num49].active(active: true);
67738 Main.tile[num48, num49].type = (ushort)num47;
67739 SquareTileFrame(num48, num49);
67740 }
67741 }
67742 }
67743 for (int num52 = num44 - num46 + 2; num52 <= num44 + num46 - 2; num52++)
67744 {
67745 int num53;
67746 for (num53 = num45 - num46; !Main.tile[num52, num53].active(); num53++)
67747 {
67748 }
67749 if (WillWaterPlacedHereStayPut(num52, num53))
67750 {
67751 Main.tile[num52, num53].active(active: false);
67752 Main.tile[num52, num53].liquid = byte.MaxValue;
67753 SquareTileFrame(num52, num53);
67754 }
67755 }
67756 }
67757 }
67758
67759 public static void DesertCloudIsland(int i, int j)
67760 {
67761 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
67762 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
67763 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
67764 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
67765 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
67766 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
67767 //IL_0563: Unknown result type (might be due to invalid IL or missing references)
67768 //IL_0574: Unknown result type (might be due to invalid IL or missing references)
67769 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
67770 //IL_05c9: Unknown result type (might be due to invalid IL or missing references)
67771 //IL_05de: Unknown result type (might be due to invalid IL or missing references)
67772 //IL_05f9: Unknown result type (might be due to invalid IL or missing references)
67773 //IL_02d3: Unknown result type (might be due to invalid IL or missing references)
67774 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
67775 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
67776 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
67777 //IL_02ff: Unknown result type (might be due to invalid IL or missing references)
67778 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
67779 //IL_0320: Unknown result type (might be due to invalid IL or missing references)
67780 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
67781 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
67782 //IL_0341: Unknown result type (might be due to invalid IL or missing references)
67783 //IL_01ee: Unknown result type (might be due to invalid IL or missing references)
67784 //IL_0362: Unknown result type (might be due to invalid IL or missing references)
67785 //IL_0659: Unknown result type (might be due to invalid IL or missing references)
67786 //IL_0775: Unknown result type (might be due to invalid IL or missing references)
67787 //IL_0776: Unknown result type (might be due to invalid IL or missing references)
67788 //IL_0777: Unknown result type (might be due to invalid IL or missing references)
67789 //IL_077c: Unknown result type (might be due to invalid IL or missing references)
67790 //IL_07a1: Unknown result type (might be due to invalid IL or missing references)
67791 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
67792 //IL_0224: Unknown result type (might be due to invalid IL or missing references)
67793 //IL_0694: Unknown result type (might be due to invalid IL or missing references)
67794 //IL_07c2: Unknown result type (might be due to invalid IL or missing references)
67795 //IL_06a6: Unknown result type (might be due to invalid IL or missing references)
67796 //IL_069c: Unknown result type (might be due to invalid IL or missing references)
67797 //IL_07e3: Unknown result type (might be due to invalid IL or missing references)
67798 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
67799 //IL_0804: Unknown result type (might be due to invalid IL or missing references)
67800 //IL_06dc: Unknown result type (might be due to invalid IL or missing references)
67801 //IL_06eb: Unknown result type (might be due to invalid IL or missing references)
67802 double num = genRand.Next(100, 150);
67803 double num2 = num;
67804 double num3 = genRand.Next(20, 30);
67805 int num4 = i;
67806 int num5 = i;
67807 int num6 = i;
67808 int num7 = j;
67809 Vector2D val = default(Vector2D);
67810 val.X = i;
67811 val.Y = j;
67812 Vector2D val2 = default(Vector2D);
67813 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67814 while (val2.X > -2.0 && val2.X < 2.0)
67815 {
67816 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67817 }
67818 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
67819 while (num > 0.0 && num3 > 0.0)
67820 {
67821 num -= (double)genRand.Next(4);
67822 num3 -= 1.0;
67823 int num8 = (int)(val.X - num * 0.5);
67824 int num9 = (int)(val.X + num * 0.5);
67825 int num10 = (int)(val.Y - num * 0.5);
67826 int num11 = (int)(val.Y + num * 0.5);
67827 if (num8 < 0)
67828 {
67829 num8 = 0;
67830 }
67831 if (num9 > Main.maxTilesX)
67832 {
67834 }
67835 if (num10 < 0)
67836 {
67837 num10 = 0;
67838 }
67839 if (num11 > Main.maxTilesY)
67840 {
67842 }
67843 num2 = num * (double)genRand.Next(80, 120) * 0.01;
67844 double num12 = val.Y + 1.0;
67845 for (int k = num8; k < num9; k++)
67846 {
67847 if (genRand.Next(2) == 0)
67848 {
67849 num12 += (double)genRand.Next(-1, 2);
67850 }
67851 if (num12 < val.Y)
67852 {
67853 num12 = val.Y;
67854 }
67855 if (num12 > val.Y + 2.0)
67856 {
67857 num12 = val.Y + 2.0;
67858 }
67859 for (int l = num10; l < num11; l++)
67860 {
67861 if (!((double)l > num12))
67862 {
67863 continue;
67864 }
67865 double num13 = Math.Abs((double)k - val.X);
67866 double num14 = Math.Abs((double)l - val.Y) * 3.0;
67867 if (Math.Sqrt(num13 * num13 + num14 * num14) < num2 * 0.4)
67868 {
67869 if (k < num4)
67870 {
67871 num4 = k;
67872 }
67873 if (k > num5)
67874 {
67875 num5 = k;
67876 }
67877 if (l < num6)
67878 {
67879 num6 = l;
67880 }
67881 if (l > num7)
67882 {
67883 num7 = l;
67884 }
67885 Main.tile[k, l].active(active: true);
67886 Main.tile[k, l].type = 189;
67887 SquareTileFrame(k, l);
67888 }
67889 }
67890 }
67891 val += val2;
67892 val2.X += (double)genRand.Next(-20, 21) * 0.05;
67893 if (val2.X > 1.0)
67894 {
67895 val2.X = 1.0;
67896 }
67897 if (val2.X < -1.0)
67898 {
67899 val2.X = -1.0;
67900 }
67901 if (val2.Y > 0.2)
67902 {
67903 val2.Y = -0.2;
67904 }
67905 if (val2.Y < -0.2)
67906 {
67907 val2.Y = -0.2;
67908 }
67909 }
67910 int num15 = num4;
67911 int num17;
67912 for (num15 += genRand.Next(5); num15 < num5; num15 += genRand.Next(num17, (int)((double)num17 * 1.5)))
67913 {
67914 int num16 = num7;
67915 while (!Main.tile[num15, num16].active())
67916 {
67917 num16--;
67918 }
67919 num16 += genRand.Next(-3, 4);
67920 num17 = genRand.Next(4, 8);
67921 int num18 = 189;
67922 if (genRand.Next(4) == 0)
67923 {
67924 num18 = 196;
67925 }
67926 for (int m = num15 - num17; m <= num15 + num17; m++)
67927 {
67928 for (int n = num16 - num17; n <= num16 + num17; n++)
67929 {
67930 if (n > num6)
67931 {
67932 double num19 = Math.Abs(m - num15);
67933 double num20 = Math.Abs(n - num16) * 2;
67934 if (Math.Sqrt(num19 * num19 + num20 * num20) < (double)(num17 + genRand.Next(2)))
67935 {
67936 Main.tile[m, n].active(active: true);
67937 Main.tile[m, n].type = (ushort)num18;
67938 SquareTileFrame(m, n);
67939 }
67940 }
67941 }
67942 }
67943 }
67944 num = genRand.Next(80, 95);
67945 num2 = num;
67946 num3 = genRand.Next(10, 15);
67947 val.X = i;
67948 val.Y = num6;
67949 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67950 while (val2.X > -2.0 && val2.X < 2.0)
67951 {
67952 val2.X = (double)genRand.Next(-20, 21) * 0.2;
67953 }
67954 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
67955 while (num > 0.0 && num3 > 0.0)
67956 {
67957 num -= (double)genRand.Next(4);
67958 num3 -= 1.0;
67959 int num8 = (int)(val.X - num * 0.5);
67960 int num9 = (int)(val.X + num * 0.5);
67961 int num10 = num6 - 1;
67962 int num11 = (int)(val.Y + num * 0.5);
67963 if (num8 < 0)
67964 {
67965 num8 = 0;
67966 }
67967 if (num9 > Main.maxTilesX)
67968 {
67970 }
67971 if (num10 < 0)
67972 {
67973 num10 = 0;
67974 }
67975 if (num11 > Main.maxTilesY)
67976 {
67978 }
67979 num2 = num * (double)genRand.Next(80, 120) * 0.01;
67980 double num21 = val.Y + 1.0;
67981 for (int num22 = num8; num22 < num9; num22++)
67982 {
67983 if (genRand.Next(2) == 0)
67984 {
67985 num21 += (double)genRand.Next(-1, 2);
67986 }
67987 if (num21 < val.Y)
67988 {
67989 num21 = val.Y;
67990 }
67991 if (num21 > val.Y + 2.0)
67992 {
67993 num21 = val.Y + 2.0;
67994 }
67995 for (int num23 = num10; num23 < num11; num23++)
67996 {
67997 if ((double)num23 > num21)
67998 {
67999 double num24 = Math.Abs((double)num22 - val.X);
68000 double num25 = Math.Abs((double)num23 - val.Y) * 3.0;
68001 if (Math.Sqrt(num24 * num24 + num25 * num25) < num2 * 0.4 && Main.tile[num22, num23].type == 189)
68002 {
68003 Main.tile[num22, num23].type = 53;
68004 SquareTileFrame(num22, num23);
68005 }
68006 }
68007 }
68008 }
68009 val += val2;
68010 val2.X += (double)genRand.Next(-20, 21) * 0.05;
68011 if (val2.X > 1.0)
68012 {
68013 val2.X = 1.0;
68014 }
68015 if (val2.X < -1.0)
68016 {
68017 val2.X = -1.0;
68018 }
68019 if (val2.Y > 0.2)
68020 {
68021 val2.Y = -0.2;
68022 }
68023 if (val2.Y < -0.2)
68024 {
68025 val2.Y = -0.2;
68026 }
68027 }
68028 int num26 = num4;
68029 num26 += genRand.Next(5);
68030 while (num26 < num5)
68031 {
68032 int num27 = num7;
68033 while ((!Main.tile[num26, num27].active() || Main.tile[num26, num27].type != 0) && num26 < num5)
68034 {
68035 num27--;
68036 if (num27 < num6)
68037 {
68038 num27 = num7;
68039 num26 += genRand.Next(1, 4);
68040 }
68041 }
68042 if (num26 >= num5)
68043 {
68044 continue;
68045 }
68046 num27 += genRand.Next(0, 4);
68047 int num28 = genRand.Next(2, 5);
68048 int num29 = 189;
68049 for (int num30 = num26 - num28; num30 <= num26 + num28; num30++)
68050 {
68051 for (int num31 = num27 - num28; num31 <= num27 + num28; num31++)
68052 {
68053 if (num31 > num6)
68054 {
68055 double num32 = Math.Abs(num30 - num26);
68056 double num33 = Math.Abs(num31 - num27) * 2;
68057 if (Math.Sqrt(num32 * num32 + num33 * num33) < (double)num28)
68058 {
68059 Main.tile[num30, num31].type = (ushort)num29;
68060 SquareTileFrame(num30, num31);
68061 }
68062 }
68063 }
68064 }
68065 num26 += genRand.Next(num28, (int)((double)num28 * 1.5));
68066 }
68067 for (int num34 = num4 - 20; num34 <= num5 + 20; num34++)
68068 {
68069 for (int num35 = num6 - 20; num35 <= num7 + 20; num35++)
68070 {
68071 bool flag = true;
68072 for (int num36 = num34 - 1; num36 <= num34 + 1; num36++)
68073 {
68074 for (int num37 = num35 - 1; num37 <= num35 + 1; num37++)
68075 {
68076 if (!Main.tile[num36, num37].active())
68077 {
68078 flag = false;
68079 }
68080 }
68081 }
68082 if (flag)
68083 {
68084 Main.tile[num34, num35].wall = 73;
68085 SquareWallFrame(num34, num35);
68086 }
68087 }
68088 }
68089 for (int num38 = num4; num38 <= num5; num38++)
68090 {
68091 int num39;
68092 for (num39 = num6 - 10; !Main.tile[num38, num39 + 1].active(); num39++)
68093 {
68094 }
68095 if (num39 >= num7 || Main.tile[num38, num39 + 1].type != 189)
68096 {
68097 continue;
68098 }
68099 if (genRand.Next(10) == 0)
68100 {
68101 int num40 = genRand.Next(1, 3);
68102 for (int num41 = num38 - num40; num41 <= num38 + num40; num41++)
68103 {
68104 if (Main.tile[num41, num39].type == 189 && WillWaterPlacedHereStayPut(num41, num39))
68105 {
68106 Main.tile[num41, num39].active(active: false);
68107 Main.tile[num41, num39].liquid = byte.MaxValue;
68108 Main.tile[num41, num39].lava(lava: false);
68109 SquareTileFrame(num38, num39);
68110 }
68111 if (Main.tile[num41, num39 + 1].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 1))
68112 {
68113 Main.tile[num41, num39 + 1].active(active: false);
68114 Main.tile[num41, num39 + 1].liquid = byte.MaxValue;
68115 Main.tile[num41, num39 + 1].lava(lava: false);
68116 SquareTileFrame(num38, num39 + 1);
68117 }
68118 if (num41 > num38 - num40 && num41 < num38 + 2 && Main.tile[num41, num39 + 2].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 2))
68119 {
68120 Main.tile[num41, num39 + 2].active(active: false);
68121 Main.tile[num41, num39 + 2].liquid = byte.MaxValue;
68122 Main.tile[num41, num39 + 2].lava(lava: false);
68123 SquareTileFrame(num38, num39 + 2);
68124 }
68125 }
68126 }
68127 if (genRand.Next(5) == 0 && WillWaterPlacedHereStayPut(num38, num39))
68128 {
68129 Main.tile[num38, num39].liquid = byte.MaxValue;
68130 }
68131 Main.tile[num38, num39].lava(lava: false);
68132 SquareTileFrame(num38, num39);
68133 }
68134 int num42 = genRand.Next(4);
68135 for (int num43 = 0; num43 <= num42; num43++)
68136 {
68137 int num44 = genRand.Next(num4 - 5, num5 + 5);
68138 int num45 = num6 - genRand.Next(20, 40);
68139 int num46 = genRand.Next(4, 8);
68140 int num47 = 189;
68141 if (genRand.Next(2) == 0)
68142 {
68143 num47 = 196;
68144 }
68145 for (int num48 = num44 - num46; num48 <= num44 + num46; num48++)
68146 {
68147 for (int num49 = num45 - num46; num49 <= num45 + num46; num49++)
68148 {
68149 double num50 = Math.Abs(num48 - num44);
68150 double num51 = Math.Abs(num49 - num45) * 2;
68151 if (Math.Sqrt(num50 * num50 + num51 * num51) < (double)(num46 + genRand.Next(-1, 2)))
68152 {
68153 Main.tile[num48, num49].active(active: true);
68154 Main.tile[num48, num49].type = (ushort)num47;
68155 SquareTileFrame(num48, num49);
68156 }
68157 }
68158 }
68159 for (int num52 = num44 - num46 + 2; num52 <= num44 + num46 - 2; num52++)
68160 {
68161 int num53;
68162 for (num53 = num45 - num46; !Main.tile[num52, num53].active(); num53++)
68163 {
68164 }
68165 if (WillWaterPlacedHereStayPut(num52, num53))
68166 {
68167 Main.tile[num52, num53].active(active: false);
68168 Main.tile[num52, num53].liquid = byte.MaxValue;
68169 SquareTileFrame(num52, num53);
68170 }
68171 }
68172 }
68173 }
68174
68175 public static void CloudIsland(int i, int j)
68176 {
68177 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
68178 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
68179 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
68180 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
68181 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
68182 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
68183 //IL_0563: Unknown result type (might be due to invalid IL or missing references)
68184 //IL_0574: Unknown result type (might be due to invalid IL or missing references)
68185 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
68186 //IL_05c9: Unknown result type (might be due to invalid IL or missing references)
68187 //IL_05de: Unknown result type (might be due to invalid IL or missing references)
68188 //IL_05f9: Unknown result type (might be due to invalid IL or missing references)
68189 //IL_02d3: Unknown result type (might be due to invalid IL or missing references)
68190 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
68191 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
68192 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
68193 //IL_02ff: Unknown result type (might be due to invalid IL or missing references)
68194 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
68195 //IL_0320: Unknown result type (might be due to invalid IL or missing references)
68196 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
68197 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
68198 //IL_0341: Unknown result type (might be due to invalid IL or missing references)
68199 //IL_01ee: Unknown result type (might be due to invalid IL or missing references)
68200 //IL_0362: Unknown result type (might be due to invalid IL or missing references)
68201 //IL_0659: Unknown result type (might be due to invalid IL or missing references)
68202 //IL_0774: Unknown result type (might be due to invalid IL or missing references)
68203 //IL_0775: Unknown result type (might be due to invalid IL or missing references)
68204 //IL_0776: Unknown result type (might be due to invalid IL or missing references)
68205 //IL_077b: Unknown result type (might be due to invalid IL or missing references)
68206 //IL_07a0: Unknown result type (might be due to invalid IL or missing references)
68207 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
68208 //IL_0224: Unknown result type (might be due to invalid IL or missing references)
68209 //IL_0694: Unknown result type (might be due to invalid IL or missing references)
68210 //IL_07c1: Unknown result type (might be due to invalid IL or missing references)
68211 //IL_06a6: Unknown result type (might be due to invalid IL or missing references)
68212 //IL_069c: Unknown result type (might be due to invalid IL or missing references)
68213 //IL_07e2: Unknown result type (might be due to invalid IL or missing references)
68214 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
68215 //IL_0803: Unknown result type (might be due to invalid IL or missing references)
68216 //IL_06dc: Unknown result type (might be due to invalid IL or missing references)
68217 //IL_06eb: Unknown result type (might be due to invalid IL or missing references)
68218 double num = genRand.Next(100, 150);
68219 double num2 = num;
68220 double num3 = genRand.Next(20, 30);
68221 int num4 = i;
68222 int num5 = i;
68223 int num6 = i;
68224 int num7 = j;
68225 Vector2D val = default(Vector2D);
68226 val.X = i;
68227 val.Y = j;
68228 Vector2D val2 = default(Vector2D);
68229 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68230 while (val2.X > -2.0 && val2.X < 2.0)
68231 {
68232 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68233 }
68234 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
68235 while (num > 0.0 && num3 > 0.0)
68236 {
68237 num -= (double)genRand.Next(4);
68238 num3 -= 1.0;
68239 int num8 = (int)(val.X - num * 0.5);
68240 int num9 = (int)(val.X + num * 0.5);
68241 int num10 = (int)(val.Y - num * 0.5);
68242 int num11 = (int)(val.Y + num * 0.5);
68243 if (num8 < 0)
68244 {
68245 num8 = 0;
68246 }
68247 if (num9 > Main.maxTilesX)
68248 {
68250 }
68251 if (num10 < 0)
68252 {
68253 num10 = 0;
68254 }
68255 if (num11 > Main.maxTilesY)
68256 {
68258 }
68259 num2 = num * (double)genRand.Next(80, 120) * 0.01;
68260 double num12 = val.Y + 1.0;
68261 for (int k = num8; k < num9; k++)
68262 {
68263 if (genRand.Next(2) == 0)
68264 {
68265 num12 += (double)genRand.Next(-1, 2);
68266 }
68267 if (num12 < val.Y)
68268 {
68269 num12 = val.Y;
68270 }
68271 if (num12 > val.Y + 2.0)
68272 {
68273 num12 = val.Y + 2.0;
68274 }
68275 for (int l = num10; l < num11; l++)
68276 {
68277 if (!((double)l > num12))
68278 {
68279 continue;
68280 }
68281 double num13 = Math.Abs((double)k - val.X);
68282 double num14 = Math.Abs((double)l - val.Y) * 3.0;
68283 if (Math.Sqrt(num13 * num13 + num14 * num14) < num2 * 0.4)
68284 {
68285 if (k < num4)
68286 {
68287 num4 = k;
68288 }
68289 if (k > num5)
68290 {
68291 num5 = k;
68292 }
68293 if (l < num6)
68294 {
68295 num6 = l;
68296 }
68297 if (l > num7)
68298 {
68299 num7 = l;
68300 }
68301 Main.tile[k, l].active(active: true);
68302 Main.tile[k, l].type = 189;
68303 SquareTileFrame(k, l);
68304 }
68305 }
68306 }
68307 val += val2;
68308 val2.X += (double)genRand.Next(-20, 21) * 0.05;
68309 if (val2.X > 1.0)
68310 {
68311 val2.X = 1.0;
68312 }
68313 if (val2.X < -1.0)
68314 {
68315 val2.X = -1.0;
68316 }
68317 if (val2.Y > 0.2)
68318 {
68319 val2.Y = -0.2;
68320 }
68321 if (val2.Y < -0.2)
68322 {
68323 val2.Y = -0.2;
68324 }
68325 }
68326 int num15 = num4;
68327 int num17;
68328 for (num15 += genRand.Next(5); num15 < num5; num15 += genRand.Next(num17, (int)((double)num17 * 1.5)))
68329 {
68330 int num16 = num7;
68331 while (!Main.tile[num15, num16].active())
68332 {
68333 num16--;
68334 }
68335 num16 += genRand.Next(-3, 4);
68336 num17 = genRand.Next(4, 8);
68337 int num18 = 189;
68338 if (genRand.Next(4) == 0)
68339 {
68340 num18 = 196;
68341 }
68342 for (int m = num15 - num17; m <= num15 + num17; m++)
68343 {
68344 for (int n = num16 - num17; n <= num16 + num17; n++)
68345 {
68346 if (n > num6)
68347 {
68348 double num19 = Math.Abs(m - num15);
68349 double num20 = Math.Abs(n - num16) * 2;
68350 if (Math.Sqrt(num19 * num19 + num20 * num20) < (double)(num17 + genRand.Next(2)))
68351 {
68352 Main.tile[m, n].active(active: true);
68353 Main.tile[m, n].type = (ushort)num18;
68354 SquareTileFrame(m, n);
68355 }
68356 }
68357 }
68358 }
68359 }
68360 num = genRand.Next(80, 95);
68361 num2 = num;
68362 num3 = genRand.Next(10, 15);
68363 val.X = i;
68364 val.Y = num6;
68365 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68366 while (val2.X > -2.0 && val2.X < 2.0)
68367 {
68368 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68369 }
68370 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
68371 while (num > 0.0 && num3 > 0.0)
68372 {
68373 num -= (double)genRand.Next(4);
68374 num3 -= 1.0;
68375 int num8 = (int)(val.X - num * 0.5);
68376 int num9 = (int)(val.X + num * 0.5);
68377 int num10 = num6 - 1;
68378 int num11 = (int)(val.Y + num * 0.5);
68379 if (num8 < 0)
68380 {
68381 num8 = 0;
68382 }
68383 if (num9 > Main.maxTilesX)
68384 {
68386 }
68387 if (num10 < 0)
68388 {
68389 num10 = 0;
68390 }
68391 if (num11 > Main.maxTilesY)
68392 {
68394 }
68395 num2 = num * (double)genRand.Next(80, 120) * 0.01;
68396 double num21 = val.Y + 1.0;
68397 for (int num22 = num8; num22 < num9; num22++)
68398 {
68399 if (genRand.Next(2) == 0)
68400 {
68401 num21 += (double)genRand.Next(-1, 2);
68402 }
68403 if (num21 < val.Y)
68404 {
68405 num21 = val.Y;
68406 }
68407 if (num21 > val.Y + 2.0)
68408 {
68409 num21 = val.Y + 2.0;
68410 }
68411 for (int num23 = num10; num23 < num11; num23++)
68412 {
68413 if ((double)num23 > num21)
68414 {
68415 double num24 = Math.Abs((double)num22 - val.X);
68416 double num25 = Math.Abs((double)num23 - val.Y) * 3.0;
68417 if (Math.Sqrt(num24 * num24 + num25 * num25) < num2 * 0.4 && Main.tile[num22, num23].type == 189)
68418 {
68419 Main.tile[num22, num23].type = 0;
68420 SquareTileFrame(num22, num23);
68421 }
68422 }
68423 }
68424 }
68425 val += val2;
68426 val2.X += (double)genRand.Next(-20, 21) * 0.05;
68427 if (val2.X > 1.0)
68428 {
68429 val2.X = 1.0;
68430 }
68431 if (val2.X < -1.0)
68432 {
68433 val2.X = -1.0;
68434 }
68435 if (val2.Y > 0.2)
68436 {
68437 val2.Y = -0.2;
68438 }
68439 if (val2.Y < -0.2)
68440 {
68441 val2.Y = -0.2;
68442 }
68443 }
68444 int num26 = num4;
68445 num26 += genRand.Next(5);
68446 while (num26 < num5)
68447 {
68448 int num27 = num7;
68449 while ((!Main.tile[num26, num27].active() || Main.tile[num26, num27].type != 0) && num26 < num5)
68450 {
68451 num27--;
68452 if (num27 < num6)
68453 {
68454 num27 = num7;
68455 num26 += genRand.Next(1, 4);
68456 }
68457 }
68458 if (num26 >= num5)
68459 {
68460 continue;
68461 }
68462 num27 += genRand.Next(0, 4);
68463 int num28 = genRand.Next(2, 5);
68464 int num29 = 189;
68465 for (int num30 = num26 - num28; num30 <= num26 + num28; num30++)
68466 {
68467 for (int num31 = num27 - num28; num31 <= num27 + num28; num31++)
68468 {
68469 if (num31 > num6)
68470 {
68471 double num32 = Math.Abs(num30 - num26);
68472 double num33 = Math.Abs(num31 - num27) * 2;
68473 if (Math.Sqrt(num32 * num32 + num33 * num33) < (double)num28)
68474 {
68475 Main.tile[num30, num31].type = (ushort)num29;
68476 SquareTileFrame(num30, num31);
68477 }
68478 }
68479 }
68480 }
68481 num26 += genRand.Next(num28, (int)((double)num28 * 1.5));
68482 }
68483 for (int num34 = num4 - 20; num34 <= num5 + 20; num34++)
68484 {
68485 for (int num35 = num6 - 20; num35 <= num7 + 20; num35++)
68486 {
68487 bool flag = true;
68488 for (int num36 = num34 - 1; num36 <= num34 + 1; num36++)
68489 {
68490 for (int num37 = num35 - 1; num37 <= num35 + 1; num37++)
68491 {
68492 if (!Main.tile[num36, num37].active())
68493 {
68494 flag = false;
68495 }
68496 }
68497 }
68498 if (flag)
68499 {
68500 Main.tile[num34, num35].wall = 73;
68501 SquareWallFrame(num34, num35);
68502 }
68503 }
68504 }
68505 for (int num38 = num4; num38 <= num5; num38++)
68506 {
68507 int num39;
68508 for (num39 = num6 - 10; !Main.tile[num38, num39 + 1].active(); num39++)
68509 {
68510 }
68511 if (num39 >= num7 || Main.tile[num38, num39 + 1].type != 189)
68512 {
68513 continue;
68514 }
68515 if (genRand.Next(10) == 0)
68516 {
68517 int num40 = genRand.Next(1, 3);
68518 for (int num41 = num38 - num40; num41 <= num38 + num40; num41++)
68519 {
68520 if (Main.tile[num41, num39].type == 189 && WillWaterPlacedHereStayPut(num41, num39))
68521 {
68522 Main.tile[num41, num39].active(active: false);
68523 Main.tile[num41, num39].liquid = byte.MaxValue;
68524 Main.tile[num41, num39].lava(lava: false);
68525 SquareTileFrame(num38, num39);
68526 }
68527 if (Main.tile[num41, num39 + 1].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 1))
68528 {
68529 Main.tile[num41, num39 + 1].active(active: false);
68530 Main.tile[num41, num39 + 1].liquid = byte.MaxValue;
68531 Main.tile[num41, num39 + 1].lava(lava: false);
68532 SquareTileFrame(num38, num39 + 1);
68533 }
68534 if (num41 > num38 - num40 && num41 < num38 + 2 && Main.tile[num41, num39 + 2].type == 189 && WillWaterPlacedHereStayPut(num41, num39 + 2))
68535 {
68536 Main.tile[num41, num39 + 2].active(active: false);
68537 Main.tile[num41, num39 + 2].liquid = byte.MaxValue;
68538 Main.tile[num41, num39 + 2].lava(lava: false);
68539 SquareTileFrame(num38, num39 + 2);
68540 }
68541 }
68542 }
68543 if (genRand.Next(5) == 0 && WillWaterPlacedHereStayPut(num38, num39))
68544 {
68545 Main.tile[num38, num39].liquid = byte.MaxValue;
68546 }
68547 Main.tile[num38, num39].lava(lava: false);
68548 SquareTileFrame(num38, num39);
68549 }
68550 int num42 = genRand.Next(4);
68551 for (int num43 = 0; num43 <= num42; num43++)
68552 {
68553 int num44 = genRand.Next(num4 - 5, num5 + 5);
68554 int num45 = num6 - genRand.Next(20, 40);
68555 int num46 = genRand.Next(4, 8);
68556 int num47 = 189;
68557 if (genRand.Next(2) == 0)
68558 {
68559 num47 = 196;
68560 }
68561 for (int num48 = num44 - num46; num48 <= num44 + num46; num48++)
68562 {
68563 for (int num49 = num45 - num46; num49 <= num45 + num46; num49++)
68564 {
68565 double num50 = Math.Abs(num48 - num44);
68566 double num51 = Math.Abs(num49 - num45) * 2;
68567 if (Math.Sqrt(num50 * num50 + num51 * num51) < (double)(num46 + genRand.Next(-1, 2)))
68568 {
68569 Main.tile[num48, num49].active(active: true);
68570 Main.tile[num48, num49].type = (ushort)num47;
68571 SquareTileFrame(num48, num49);
68572 }
68573 }
68574 }
68575 for (int num52 = num44 - num46 + 2; num52 <= num44 + num46 - 2; num52++)
68576 {
68577 int num53;
68578 for (num53 = num45 - num46; !Main.tile[num52, num53].active(); num53++)
68579 {
68580 }
68581 if (WillWaterPlacedHereStayPut(num52, num53))
68582 {
68583 Main.tile[num52, num53].active(active: false);
68584 Main.tile[num52, num53].liquid = byte.MaxValue;
68585 SquareTileFrame(num52, num53);
68586 }
68587 }
68588 }
68589 }
68590
68591 public static bool WillWaterPlacedHereStayPut(int x, int y)
68592 {
68593 if (((Main.tile[x, y + 1].active() && Main.tileSolid[Main.tile[x, y + 1].type] && !Main.tileSolidTop[Main.tile[x, y + 1].type]) || Main.tile[x, y + 1].liquid == byte.MaxValue) && ((Main.tile[x - 1, y].active() && Main.tileSolid[Main.tile[x - 1, y].type] && !Main.tileSolidTop[Main.tile[x - 1, y].type]) || Main.tile[x - 1, y].liquid == byte.MaxValue) && ((Main.tile[x + 1, y].active() && Main.tileSolid[Main.tile[x + 1, y].type] && !Main.tileSolidTop[Main.tile[x + 1, y].type]) || Main.tile[x + 1, y].liquid == byte.MaxValue))
68594 {
68595 return true;
68596 }
68597 return false;
68598 }
68599
68600 public static void CloudLake(int i, int j)
68601 {
68602 //IL_0089: Unknown result type (might be due to invalid IL or missing references)
68603 //IL_009a: Unknown result type (might be due to invalid IL or missing references)
68604 //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
68605 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
68606 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
68607 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
68608 //IL_0563: Unknown result type (might be due to invalid IL or missing references)
68609 //IL_0574: Unknown result type (might be due to invalid IL or missing references)
68610 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
68611 //IL_05c9: Unknown result type (might be due to invalid IL or missing references)
68612 //IL_05de: Unknown result type (might be due to invalid IL or missing references)
68613 //IL_05f9: Unknown result type (might be due to invalid IL or missing references)
68614 //IL_02d3: Unknown result type (might be due to invalid IL or missing references)
68615 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
68616 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
68617 //IL_02da: Unknown result type (might be due to invalid IL or missing references)
68618 //IL_02ff: Unknown result type (might be due to invalid IL or missing references)
68619 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
68620 //IL_0320: Unknown result type (might be due to invalid IL or missing references)
68621 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
68622 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
68623 //IL_0341: Unknown result type (might be due to invalid IL or missing references)
68624 //IL_01ee: Unknown result type (might be due to invalid IL or missing references)
68625 //IL_0362: Unknown result type (might be due to invalid IL or missing references)
68626 //IL_0659: Unknown result type (might be due to invalid IL or missing references)
68627 //IL_07d6: Unknown result type (might be due to invalid IL or missing references)
68628 //IL_07d7: Unknown result type (might be due to invalid IL or missing references)
68629 //IL_07d8: Unknown result type (might be due to invalid IL or missing references)
68630 //IL_07dd: Unknown result type (might be due to invalid IL or missing references)
68631 //IL_0802: Unknown result type (might be due to invalid IL or missing references)
68632 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
68633 //IL_0224: Unknown result type (might be due to invalid IL or missing references)
68634 //IL_0694: Unknown result type (might be due to invalid IL or missing references)
68635 //IL_0823: Unknown result type (might be due to invalid IL or missing references)
68636 //IL_06a6: Unknown result type (might be due to invalid IL or missing references)
68637 //IL_069c: Unknown result type (might be due to invalid IL or missing references)
68638 //IL_0844: Unknown result type (might be due to invalid IL or missing references)
68639 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
68640 //IL_0865: Unknown result type (might be due to invalid IL or missing references)
68641 //IL_06e9: Unknown result type (might be due to invalid IL or missing references)
68642 //IL_06f8: Unknown result type (might be due to invalid IL or missing references)
68643 double num = genRand.Next(100, 150);
68644 double num2 = num;
68645 double num3 = genRand.Next(20, 30);
68646 int num4 = i;
68647 int num5 = i;
68648 int num6 = i;
68649 int num7 = j;
68650 Vector2D val = default(Vector2D);
68651 val.X = i;
68652 val.Y = j;
68653 Vector2D val2 = default(Vector2D);
68654 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68655 while (val2.X > -2.0 && val2.X < 2.0)
68656 {
68657 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68658 }
68659 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
68660 while (num > 0.0 && num3 > 0.0)
68661 {
68662 num -= (double)genRand.Next(4);
68663 num3 -= 1.0;
68664 int num8 = (int)(val.X - num * 0.5);
68665 int num9 = (int)(val.X + num * 0.5);
68666 int num10 = (int)(val.Y - num * 0.5);
68667 int num11 = (int)(val.Y + num * 0.5);
68668 if (num8 < 0)
68669 {
68670 num8 = 0;
68671 }
68672 if (num9 > Main.maxTilesX)
68673 {
68675 }
68676 if (num10 < 0)
68677 {
68678 num10 = 0;
68679 }
68680 if (num11 > Main.maxTilesY)
68681 {
68683 }
68684 num2 = num * (double)genRand.Next(80, 120) * 0.01;
68685 double num12 = val.Y + 1.0;
68686 for (int k = num8; k < num9; k++)
68687 {
68688 if (genRand.Next(2) == 0)
68689 {
68690 num12 += (double)genRand.Next(-1, 2);
68691 }
68692 if (num12 < val.Y)
68693 {
68694 num12 = val.Y;
68695 }
68696 if (num12 > val.Y + 2.0)
68697 {
68698 num12 = val.Y + 2.0;
68699 }
68700 for (int l = num10; l < num11; l++)
68701 {
68702 if (!((double)l > num12))
68703 {
68704 continue;
68705 }
68706 double num13 = Math.Abs((double)k - val.X);
68707 double num14 = Math.Abs((double)l - val.Y) * 3.0;
68708 if (Math.Sqrt(num13 * num13 + num14 * num14) < num2 * 0.4)
68709 {
68710 if (k < num4)
68711 {
68712 num4 = k;
68713 }
68714 if (k > num5)
68715 {
68716 num5 = k;
68717 }
68718 if (l < num6)
68719 {
68720 num6 = l;
68721 }
68722 if (l > num7)
68723 {
68724 num7 = l;
68725 }
68726 Main.tile[k, l].active(active: true);
68727 Main.tile[k, l].type = 189;
68728 SquareTileFrame(k, l);
68729 }
68730 }
68731 }
68732 val += val2;
68733 val2.X += (double)genRand.Next(-20, 21) * 0.05;
68734 if (val2.X > 1.0)
68735 {
68736 val2.X = 1.0;
68737 }
68738 if (val2.X < -1.0)
68739 {
68740 val2.X = -1.0;
68741 }
68742 if (val2.Y > 0.2)
68743 {
68744 val2.Y = -0.2;
68745 }
68746 if (val2.Y < -0.2)
68747 {
68748 val2.Y = -0.2;
68749 }
68750 }
68751 int num15 = num4;
68752 int num17;
68753 for (num15 += genRand.Next(5); num15 < num5; num15 += genRand.Next(num17, (int)((double)num17 * 1.5)))
68754 {
68755 int num16 = num7;
68756 while (!Main.tile[num15, num16].active())
68757 {
68758 num16--;
68759 }
68760 num16 += genRand.Next(-3, 4);
68761 num17 = genRand.Next(4, 8);
68762 int num18 = 189;
68763 if (genRand.Next(4) == 0)
68764 {
68765 num18 = 196;
68766 }
68767 for (int m = num15 - num17; m <= num15 + num17; m++)
68768 {
68769 for (int n = num16 - num17; n <= num16 + num17; n++)
68770 {
68771 if (n > num6)
68772 {
68773 double num19 = Math.Abs(m - num15);
68774 double num20 = Math.Abs(n - num16) * 2;
68775 if (Math.Sqrt(num19 * num19 + num20 * num20) < (double)(num17 + genRand.Next(2)))
68776 {
68777 Main.tile[m, n].active(active: true);
68778 Main.tile[m, n].type = (ushort)num18;
68779 SquareTileFrame(m, n);
68780 }
68781 }
68782 }
68783 }
68784 }
68785 num = genRand.Next(80, 95);
68786 num2 = num;
68787 num3 = genRand.Next(10, 15);
68788 val.X = i;
68789 val.Y = num6;
68790 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68791 while (val2.X > -2.0 && val2.X < 2.0)
68792 {
68793 val2.X = (double)genRand.Next(-20, 21) * 0.2;
68794 }
68795 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
68796 while (num > 0.0 && num3 > 0.0)
68797 {
68798 num -= (double)genRand.Next(4);
68799 num3 -= 1.0;
68800 int num8 = (int)(val.X - num * 0.5);
68801 int num9 = (int)(val.X + num * 0.5);
68802 int num10 = num6 - 1;
68803 int num11 = (int)(val.Y + num * 0.5);
68804 if (num8 < 0)
68805 {
68806 num8 = 0;
68807 }
68808 if (num9 > Main.maxTilesX)
68809 {
68811 }
68812 if (num10 < 0)
68813 {
68814 num10 = 0;
68815 }
68816 if (num11 > Main.maxTilesY)
68817 {
68819 }
68820 num2 = num * (double)genRand.Next(80, 120) * 0.01;
68821 double num21 = val.Y + 1.0;
68822 for (int num22 = num8; num22 < num9; num22++)
68823 {
68824 if (genRand.Next(2) == 0)
68825 {
68826 num21 += (double)genRand.Next(-1, 2);
68827 }
68828 if (num21 < val.Y)
68829 {
68830 num21 = val.Y;
68831 }
68832 if (num21 > val.Y + 2.0)
68833 {
68834 num21 = val.Y + 2.0;
68835 }
68836 for (int num23 = num10; num23 < num11; num23++)
68837 {
68838 if (!((double)num23 > num21 - 2.0))
68839 {
68840 continue;
68841 }
68842 double num24 = Math.Abs((double)num22 - val.X);
68843 double num25 = Math.Abs((double)num23 - val.Y) * 3.0;
68844 if (!(Math.Sqrt(num24 * num24 + num25 * num25) < num2 * 0.4) || Main.tile[num22, num23].type != 189)
68845 {
68846 continue;
68847 }
68848 Main.tile[num22, num23].active(active: false);
68849 if ((double)num23 > num21 + 1.0)
68850 {
68851 if (WillWaterPlacedHereStayPut(num22, num23))
68852 {
68853 Main.tile[num22, num23].liquid = byte.MaxValue;
68854 }
68855 Main.tile[num22, num23].honey(honey: false);
68856 Main.tile[num22, num23].lava(lava: false);
68857 }
68858 }
68859 }
68860 val += val2;
68861 val2.X += (double)genRand.Next(-20, 21) * 0.05;
68862 if (val2.X > 1.0)
68863 {
68864 val2.X = 1.0;
68865 }
68866 if (val2.X < -1.0)
68867 {
68868 val2.X = -1.0;
68869 }
68870 if (val2.Y > 0.2)
68871 {
68872 val2.Y = -0.2;
68873 }
68874 if (val2.Y < 0.0)
68875 {
68876 val2.Y = 0.0;
68877 }
68878 }
68879 for (int num26 = num4 - 20; num26 <= num5 + 20; num26++)
68880 {
68881 for (int num27 = num6 - 20; num27 <= num7 + 20; num27++)
68882 {
68883 bool flag = true;
68884 for (int num28 = num26 - 1; num28 <= num26 + 1; num28++)
68885 {
68886 for (int num29 = num27 - 1; num29 <= num27 + 1; num29++)
68887 {
68888 if (!Main.tile[num28, num29].active())
68889 {
68890 flag = false;
68891 }
68892 }
68893 }
68894 if (flag)
68895 {
68896 Main.tile[num26, num27].wall = 73;
68897 }
68898 }
68899 }
68900 for (int num30 = num4; num30 <= num5; num30++)
68901 {
68902 int num31;
68903 for (num31 = num6 - 10; !Main.tile[num30, num31 + 1].active(); num31++)
68904 {
68905 }
68906 if (num31 >= num7 || Main.tile[num30, num31 + 1].type != 189)
68907 {
68908 continue;
68909 }
68910 if (genRand.Next(10) == 0)
68911 {
68912 int num32 = genRand.Next(1, 3);
68913 for (int num33 = num30 - num32; num33 <= num30 + num32; num33++)
68914 {
68915 if (Main.tile[num33, num31].type == 189 && WillWaterPlacedHereStayPut(num33, num31))
68916 {
68917 Main.tile[num33, num31].active(active: false);
68918 Main.tile[num33, num31].liquid = byte.MaxValue;
68919 Main.tile[num33, num31].lava(lava: false);
68920 SquareTileFrame(num30, num31);
68921 }
68922 if (Main.tile[num33, num31 + 1].type == 189 && WillWaterPlacedHereStayPut(num33, num31 + 1))
68923 {
68924 Main.tile[num33, num31 + 1].active(active: false);
68925 Main.tile[num33, num31 + 1].liquid = byte.MaxValue;
68926 Main.tile[num33, num31 + 1].lava(lava: false);
68927 SquareTileFrame(num30, num31 + 1);
68928 }
68929 if (num33 > num30 - num32 && num33 < num30 + 2 && Main.tile[num33, num31 + 2].type == 189 && WillWaterPlacedHereStayPut(num33, num31 + 2))
68930 {
68931 Main.tile[num33, num31 + 2].active(active: false);
68932 Main.tile[num33, num31 + 2].liquid = byte.MaxValue;
68933 Main.tile[num33, num31 + 2].lava(lava: false);
68934 SquareTileFrame(num30, num31 + 2);
68935 }
68936 }
68937 }
68938 if (genRand.Next(5) == 0 && WillWaterPlacedHereStayPut(num30, num31))
68939 {
68940 Main.tile[num30, num31].liquid = byte.MaxValue;
68941 }
68942 Main.tile[num30, num31].lava(lava: false);
68943 SquareTileFrame(num30, num31);
68944 }
68945 int num34 = genRand.Next(1, 4);
68946 for (int num35 = 0; num35 <= num34; num35++)
68947 {
68948 int num36 = genRand.Next(num4 - 5, num5 + 5);
68949 int num37 = num6 - genRand.Next(20, 40);
68950 int num38 = genRand.Next(4, 8);
68951 int num39 = 189;
68952 if (genRand.Next(4) != 0)
68953 {
68954 num39 = 196;
68955 }
68956 for (int num40 = num36 - num38; num40 <= num36 + num38; num40++)
68957 {
68958 for (int num41 = num37 - num38; num41 <= num37 + num38; num41++)
68959 {
68960 double num42 = Math.Abs(num40 - num36);
68961 double num43 = Math.Abs(num41 - num37) * 2;
68962 if (Math.Sqrt(num42 * num42 + num43 * num43) < (double)(num38 + genRand.Next(-1, 2)))
68963 {
68964 Main.tile[num40, num41].active(active: true);
68965 Main.tile[num40, num41].type = (ushort)num39;
68966 SquareTileFrame(num40, num41);
68967 }
68968 }
68969 }
68970 for (int num44 = num36 - num38 + 2; num44 <= num36 + num38 - 2; num44++)
68971 {
68972 int num45;
68973 for (num45 = num37 - num38; !Main.tile[num44, num45].active(); num45++)
68974 {
68975 }
68976 if (WillWaterPlacedHereStayPut(num44, num45))
68977 {
68978 Main.tile[num44, num45].active(active: false);
68979 Main.tile[num44, num45].liquid = byte.MaxValue;
68980 SquareTileFrame(num44, num45);
68981 }
68982 }
68983 }
68984 }
68985
68986 public static void FloatingIsland(int i, int j)
68987 {
68988 //IL_007a: Unknown result type (might be due to invalid IL or missing references)
68989 //IL_008b: Unknown result type (might be due to invalid IL or missing references)
68990 //IL_00e0: Unknown result type (might be due to invalid IL or missing references)
68991 //IL_00f5: Unknown result type (might be due to invalid IL or missing references)
68992 //IL_010b: Unknown result type (might be due to invalid IL or missing references)
68993 //IL_0120: Unknown result type (might be due to invalid IL or missing references)
68994 //IL_0180: Unknown result type (might be due to invalid IL or missing references)
68995 //IL_02a5: Unknown result type (might be due to invalid IL or missing references)
68996 //IL_02ba: Unknown result type (might be due to invalid IL or missing references)
68997 //IL_02d0: Unknown result type (might be due to invalid IL or missing references)
68998 //IL_02e5: Unknown result type (might be due to invalid IL or missing references)
68999 //IL_01bb: Unknown result type (might be due to invalid IL or missing references)
69000 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
69001 //IL_01c3: Unknown result type (might be due to invalid IL or missing references)
69002 //IL_01df: Unknown result type (might be due to invalid IL or missing references)
69003 //IL_0206: Unknown result type (might be due to invalid IL or missing references)
69004 //IL_0215: Unknown result type (might be due to invalid IL or missing references)
69005 //IL_03db: Unknown result type (might be due to invalid IL or missing references)
69006 //IL_03dc: Unknown result type (might be due to invalid IL or missing references)
69007 //IL_03dd: Unknown result type (might be due to invalid IL or missing references)
69008 //IL_03e2: Unknown result type (might be due to invalid IL or missing references)
69009 //IL_0407: Unknown result type (might be due to invalid IL or missing references)
69010 //IL_0428: Unknown result type (might be due to invalid IL or missing references)
69011 //IL_0355: Unknown result type (might be due to invalid IL or missing references)
69012 //IL_0449: Unknown result type (might be due to invalid IL or missing references)
69013 //IL_036a: Unknown result type (might be due to invalid IL or missing references)
69014 //IL_0379: Unknown result type (might be due to invalid IL or missing references)
69015 //IL_046a: Unknown result type (might be due to invalid IL or missing references)
69016 double num = genRand.Next(80, 120);
69017 double num2 = num;
69018 double num3 = genRand.Next(20, 25);
69019 Vector2D val = default(Vector2D);
69020 val.X = i;
69021 val.Y = j;
69022 Vector2D val2 = default(Vector2D);
69023 val2.X = (double)genRand.Next(-20, 21) * 0.2;
69024 while (val2.X > -2.0 && val2.X < 2.0)
69025 {
69026 val2.X = (double)genRand.Next(-20, 21) * 0.2;
69027 }
69028 val2.Y = (double)genRand.Next(-20, -10) * 0.02;
69029 while (num > 0.0 && num3 > 0.0)
69030 {
69031 num -= (double)genRand.Next(4);
69032 num3 -= 1.0;
69033 int num4 = (int)(val.X - num * 0.5);
69034 int num5 = (int)(val.X + num * 0.5);
69035 int num6 = (int)(val.Y - num * 0.5);
69036 int num7 = (int)(val.Y + num * 0.5);
69037 if (num4 < 0)
69038 {
69039 num4 = 0;
69040 }
69041 if (num5 > Main.maxTilesX)
69042 {
69044 }
69045 if (num6 < 0)
69046 {
69047 num6 = 0;
69048 }
69049 if (num7 > Main.maxTilesY)
69050 {
69052 }
69053 num2 = num * (double)genRand.Next(80, 120) * 0.01;
69054 double num8 = val.Y + 1.0;
69055 for (int k = num4; k < num5; k++)
69056 {
69057 if (genRand.Next(2) == 0)
69058 {
69059 num8 += (double)genRand.Next(-1, 2);
69060 }
69061 if (num8 < val.Y)
69062 {
69063 num8 = val.Y;
69064 }
69065 if (num8 > val.Y + 2.0)
69066 {
69067 num8 = val.Y + 2.0;
69068 }
69069 for (int l = num6; l < num7; l++)
69070 {
69071 if (!((double)l > num8))
69072 {
69073 continue;
69074 }
69075 double num9 = Math.Abs((double)k - val.X);
69076 double num10 = Math.Abs((double)l - val.Y) * 2.0;
69077 if (Math.Sqrt(num9 * num9 + num10 * num10) < num2 * 0.4)
69078 {
69079 Main.tile[k, l].active(active: true);
69080 if (Main.tile[k, l].type == 59)
69081 {
69082 Main.tile[k, l].type = 0;
69083 }
69084 }
69085 }
69086 }
69087 num4 = (int)(val.X - num * 0.4);
69088 num5 = (int)(val.X + num * 0.4);
69089 num6 = (int)(val.Y - num * 0.4);
69090 num7 = (int)(val.Y + num * 0.4);
69091 if (num4 < 0)
69092 {
69093 num4 = 0;
69094 }
69095 if (num5 > Main.maxTilesX)
69096 {
69098 }
69099 if (num6 < 0)
69100 {
69101 num6 = 0;
69102 }
69103 if (num7 > Main.maxTilesY)
69104 {
69106 }
69107 num2 = num * (double)genRand.Next(80, 120) * 0.01;
69108 for (int m = num4; m < num5; m++)
69109 {
69110 for (int n = num6; n < num7; n++)
69111 {
69112 if ((double)n > val.Y + 2.0)
69113 {
69114 double num11 = Math.Abs((double)m - val.X);
69115 double num12 = Math.Abs((double)n - val.Y) * 2.0;
69116 if (Math.Sqrt(num11 * num11 + num12 * num12) < num2 * 0.4)
69117 {
69118 Main.tile[m, n].wall = 2;
69119 }
69120 }
69121 }
69122 }
69123 val += val2;
69124 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
69125 if (val2.X > 1.0)
69126 {
69127 val2.X = 1.0;
69128 }
69129 if (val2.X < -1.0)
69130 {
69131 val2.X = -1.0;
69132 }
69133 if (val2.Y > 0.2)
69134 {
69135 val2.Y = -0.2;
69136 }
69137 if (val2.Y < -0.2)
69138 {
69139 val2.Y = -0.2;
69140 }
69141 }
69142 }
69143
69144 public static void Caverer(int X, int Y)
69145 {
69146 //IL_0077: Unknown result type (might be due to invalid IL or missing references)
69147 //IL_007e: Unknown result type (might be due to invalid IL or missing references)
69148 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
69149 //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
69150 //IL_0284: Unknown result type (might be due to invalid IL or missing references)
69151 //IL_028b: Unknown result type (might be due to invalid IL or missing references)
69152 //IL_02b0: Unknown result type (might be due to invalid IL or missing references)
69153 //IL_02b5: Unknown result type (might be due to invalid IL or missing references)
69154 //IL_0184: Unknown result type (might be due to invalid IL or missing references)
69155 //IL_018b: Unknown result type (might be due to invalid IL or missing references)
69156 //IL_01b1: Unknown result type (might be due to invalid IL or missing references)
69157 //IL_01b6: Unknown result type (might be due to invalid IL or missing references)
69158 //IL_01b8: Unknown result type (might be due to invalid IL or missing references)
69159 //IL_01c0: Unknown result type (might be due to invalid IL or missing references)
69160 switch (genRand.Next(2))
69161 {
69162 case 0:
69163 {
69164 int num4 = genRand.Next(7, 9);
69165 double num5 = (double)genRand.Next(100) * 0.01;
69166 double num6 = 1.0 - num5;
69167 if (genRand.Next(2) == 0)
69168 {
69169 num5 = 0.0 - num5;
69170 }
69171 if (genRand.Next(2) == 0)
69172 {
69173 num6 = 0.0 - num6;
69174 }
69175 Vector2D val2 = default(Vector2D);
69176 ((Vector2D)(ref val2))._002Ector((double)X, (double)Y);
69177 for (int j = 0; j < num4; j++)
69178 {
69179 val2 = digTunnel(val2.X, val2.Y, num5, num6, genRand.Next(6, 20), genRand.Next(4, 9));
69180 num5 += (double)genRand.Next(-20, 21) * 0.1;
69181 num6 += (double)genRand.Next(-20, 21) * 0.1;
69182 if (num5 < -1.5)
69183 {
69184 num5 = -1.5;
69185 }
69186 if (num5 > 1.5)
69187 {
69188 num5 = 1.5;
69189 }
69190 if (num6 < -1.5)
69191 {
69192 num6 = -1.5;
69193 }
69194 if (num6 > 1.5)
69195 {
69196 num6 = 1.5;
69197 }
69198 double num7 = (double)genRand.Next(100) * 0.01;
69199 double num8 = 1.0 - num7;
69200 if (genRand.Next(2) == 0)
69201 {
69202 num7 = 0.0 - num7;
69203 }
69204 if (genRand.Next(2) == 0)
69205 {
69206 num8 = 0.0 - num8;
69207 }
69208 Vector2D val3 = digTunnel(val2.X, val2.Y, num7, num8, genRand.Next(30, 50), genRand.Next(3, 6));
69209 TileRunner((int)val3.X, (int)val3.Y, genRand.Next(10, 20), genRand.Next(5, 10), -1);
69210 }
69211 break;
69212 }
69213 case 1:
69214 {
69215 int num = genRand.Next(15, 30);
69216 double num2 = (double)genRand.Next(100) * 0.01;
69217 double num3 = 1.0 - num2;
69218 if (genRand.Next(2) == 0)
69219 {
69220 num2 = 0.0 - num2;
69221 }
69222 if (genRand.Next(2) == 0)
69223 {
69224 num3 = 0.0 - num3;
69225 }
69226 Vector2D val = default(Vector2D);
69227 ((Vector2D)(ref val))._002Ector((double)X, (double)Y);
69228 for (int i = 0; i < num; i++)
69229 {
69230 val = digTunnel(val.X, val.Y, num2, num3, genRand.Next(5, 15), genRand.Next(2, 6), Wet: true);
69231 num2 += (double)genRand.Next(-20, 21) * 0.1;
69232 num3 += (double)genRand.Next(-20, 21) * 0.1;
69233 if (num2 < -1.5)
69234 {
69235 num2 = -1.5;
69236 }
69237 if (num2 > 1.5)
69238 {
69239 num2 = 1.5;
69240 }
69241 if (num3 < -1.5)
69242 {
69243 num3 = -1.5;
69244 }
69245 if (num3 > 1.5)
69246 {
69247 num3 = 1.5;
69248 }
69249 }
69250 break;
69251 }
69252 }
69253 }
69254
69255 public static Vector2D digTunnel(double X, double Y, double xDir, double yDir, int Steps, int Size, bool Wet = false)
69256 {
69257 //IL_024e: Unknown result type (might be due to invalid IL or missing references)
69258 double num = X;
69259 double num2 = Y;
69260 try
69261 {
69262 double num3 = 0.0;
69263 double num4 = 0.0;
69264 double num5 = Size;
69265 num = Utils.Clamp(num, num5 + 1.0, (double)Main.maxTilesX - num5 - 1.0);
69266 num2 = Utils.Clamp(num2, num5 + 1.0, (double)Main.maxTilesY - num5 - 1.0);
69267 for (int i = 0; i < Steps; i++)
69268 {
69269 for (int j = (int)(num - num5); (double)j <= num + num5; j++)
69270 {
69271 for (int k = (int)(num2 - num5); (double)k <= num2 + num5; k++)
69272 {
69273 if (Math.Abs((double)j - num) + Math.Abs((double)k - num2) < num5 * (1.0 + (double)genRand.Next(-10, 11) * 0.005) && j >= 0 && j < Main.maxTilesX && k >= 0 && k < Main.maxTilesY)
69274 {
69275 Main.tile[j, k].active(active: false);
69276 if (Wet)
69277 {
69278 Main.tile[j, k].liquid = byte.MaxValue;
69279 }
69280 }
69281 }
69282 }
69283 num5 += (double)genRand.Next(-50, 51) * 0.03;
69284 if (num5 < (double)Size * 0.6)
69285 {
69286 num5 = (double)Size * 0.6;
69287 }
69288 if (num5 > (double)(Size * 2))
69289 {
69290 num5 = Size * 2;
69291 }
69292 num3 += (double)genRand.Next(-20, 21) * 0.01;
69293 num4 += (double)genRand.Next(-20, 21) * 0.01;
69294 if (num3 < -1.0)
69295 {
69296 num3 = -1.0;
69297 }
69298 if (num3 > 1.0)
69299 {
69300 num3 = 1.0;
69301 }
69302 if (num4 < -1.0)
69303 {
69304 num4 = -1.0;
69305 }
69306 if (num4 > 1.0)
69307 {
69308 num4 = 1.0;
69309 }
69310 num += (xDir + num3) * 0.6;
69311 num2 += (yDir + num4) * 0.6;
69312 }
69313 }
69314 catch
69315 {
69316 }
69317 return new Vector2D(num, num2);
69318 }
69319
69320 public static void IslandHouse(int i, int j, int islandStyle)
69321 {
69322 //IL_009b: Unknown result type (might be due to invalid IL or missing references)
69323 //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
69324 //IL_00ec: Unknown result type (might be due to invalid IL or missing references)
69325 //IL_0103: Unknown result type (might be due to invalid IL or missing references)
69326 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
69327 //IL_021d: Unknown result type (might be due to invalid IL or missing references)
69328 //IL_022a: Unknown result type (might be due to invalid IL or missing references)
69329 //IL_0237: Unknown result type (might be due to invalid IL or missing references)
69330 //IL_0244: Unknown result type (might be due to invalid IL or missing references)
69331 //IL_0305: Unknown result type (might be due to invalid IL or missing references)
69332 bool flag = crimson;
69333 if (drunkWorldGen)
69334 {
69335 flag = (GenVars.crimsonLeft && i < Main.maxTilesX / 2) || ((!GenVars.crimsonLeft && i > Main.maxTilesX / 2) ? true : false);
69336 }
69337 byte type = 202;
69338 byte wall = 82;
69339 Vector2D val = default(Vector2D);
69340 ((Vector2D)(ref val))._002Ector((double)i, (double)j);
69341 int num = 1;
69342 if (genRand.Next(2) == 0)
69343 {
69344 num = -1;
69345 }
69346 int num2 = genRand.Next(7, 12);
69347 int num3 = genRand.Next(5, 7);
69348 val.X = i + (num2 + 2) * num;
69349 for (int k = j - 15; k < j + 30; k++)
69350 {
69351 if (Main.tile[(int)val.X, k].active())
69352 {
69353 val.Y = k - 1;
69354 break;
69355 }
69356 }
69357 val.X = i;
69358 int num4 = (int)(val.X - (double)num2 - 1.0);
69359 int num5 = (int)(val.X + (double)num2 + 1.0);
69360 int num6 = (int)(val.Y - (double)num3 - 1.0);
69361 int num7 = (int)(val.Y + 2.0);
69362 if (num4 < 0)
69363 {
69364 num4 = 0;
69365 }
69366 if (num5 > Main.maxTilesX)
69367 {
69369 }
69370 if (num6 < 0)
69371 {
69372 num6 = 0;
69373 }
69374 if (num7 > Main.maxTilesY)
69375 {
69377 }
69378 for (int l = num4; l <= num5; l++)
69379 {
69380 for (int m = num6 - 1; m < num7 + 1; m++)
69381 {
69382 if (m != num6 - 1 || (l != num4 && l != num5))
69383 {
69384 Main.tile[l, m].active(active: true);
69385 Main.tile[l, m].liquid = 0;
69386 Main.tile[l, m].type = type;
69387 Main.tile[l, m].wall = 0;
69388 Main.tile[l, m].halfBrick(halfBrick: false);
69389 Main.tile[l, m].slope(0);
69390 }
69391 }
69392 }
69393 num4 = (int)(val.X - (double)num2);
69394 num5 = (int)(val.X + (double)num2);
69395 num6 = (int)(val.Y - (double)num3);
69396 num7 = (int)(val.Y + 1.0);
69397 if (num4 < 0)
69398 {
69399 num4 = 0;
69400 }
69401 if (num5 > Main.maxTilesX)
69402 {
69404 }
69405 if (num6 < 0)
69406 {
69407 num6 = 0;
69408 }
69409 if (num7 > Main.maxTilesY)
69410 {
69412 }
69413 for (int n = num4; n <= num5; n++)
69414 {
69415 for (int num8 = num6; num8 < num7; num8++)
69416 {
69417 if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == 0)
69418 {
69419 Main.tile[n, num8].active(active: false);
69420 Main.tile[n, num8].wall = wall;
69421 }
69422 }
69423 }
69424 int num9 = i + (num2 + 1) * num;
69425 int num10 = (int)val.Y;
69426 for (int num11 = num9 - 2; num11 <= num9 + 2; num11++)
69427 {
69428 Main.tile[num11, num10].active(active: false);
69429 Main.tile[num11, num10 - 1].active(active: false);
69430 Main.tile[num11, num10 - 2].active(active: false);
69431 }
69432 if (remixWorldGen)
69433 {
69434 if (flag)
69435 {
69436 PlaceTile(num9, num10, 10, mute: true, forced: false, -1, 5);
69437 }
69438 else
69439 {
69440 PlaceTile(num9, num10, 10, mute: true, forced: false, -1, 38);
69441 }
69442 }
69443 else
69444 {
69445 PlaceTile(num9, num10, 10, mute: true, forced: false, -1, 9);
69446 }
69447 num9 = i + (num2 + 1) * -num - num;
69448 for (int num12 = num6; num12 <= num7 + 1; num12++)
69449 {
69450 Main.tile[num9, num12].active(active: true);
69451 Main.tile[num9, num12].liquid = 0;
69452 Main.tile[num9, num12].type = type;
69453 Main.tile[num9, num12].wall = 0;
69454 Main.tile[num9, num12].halfBrick(halfBrick: false);
69455 Main.tile[num9, num12].slope(0);
69456 }
69457 int contain = 0;
69459 if (num13 > 3)
69460 {
69461 num13 = genRand.Next(4);
69462 }
69463 switch (num13)
69464 {
69465 case 0:
69466 contain = 159;
69467 break;
69468 case 1:
69469 contain = 65;
69470 break;
69471 case 2:
69472 contain = 158;
69473 break;
69474 case 3:
69475 contain = 2219;
69476 break;
69477 }
69478 if (getGoodWorldGen)
69479 {
69480 AddBuriedChest(i, num10 - 3, contain, notNearOtherChests: false, 2, trySlope: false, 0);
69481 }
69482 else
69483 {
69484 AddBuriedChest(i, num10 - 3, contain, notNearOtherChests: false, 13, trySlope: false, 0);
69485 }
69486 if (islandStyle > 0)
69487 {
69488 for (int num14 = 0; num14 < 100000; num14++)
69489 {
69490 int num15 = i + genRand.Next(-50, 51);
69491 int num16 = num10 + genRand.Next(21);
69492 if ((num14 >= 50000 || Main.tile[num15, num16].type != 202) && !Main.tile[num15, num16].active())
69493 {
69494 Place2xX(num15, num16, 207, islandStyle);
69495 if (Main.tile[num15, num16].active())
69496 {
69497 SwitchFountain(num15, num16);
69498 break;
69499 }
69500 }
69501 }
69502 }
69504 if (!remixWorldGen)
69505 {
69506 int num17 = i - num2 / 2 + 1;
69507 int num18 = i + num2 / 2 - 1;
69508 int num19 = 1;
69509 if (num2 > 10)
69510 {
69511 num19 = 2;
69512 }
69513 int num20 = (num6 + num7) / 2 - 1;
69514 for (int num21 = num17 - num19; num21 <= num17 + num19; num21++)
69515 {
69516 for (int num22 = num20 - 1; num22 <= num20 + 1; num22++)
69517 {
69518 Main.tile[num21, num22].wall = 21;
69519 }
69520 }
69521 for (int num23 = num18 - num19; num23 <= num18 + num19; num23++)
69522 {
69523 for (int num24 = num20 - 1; num24 <= num20 + 1; num24++)
69524 {
69525 Main.tile[num23, num24].wall = 21;
69526 }
69527 }
69528 }
69529 int num25 = i + (num2 / 2 + 1) * -num;
69530 if (remixWorldGen)
69531 {
69532 if (flag)
69533 {
69534 PlaceTile(num25, num7 - 1, 14, mute: true, forced: false, -1, 5);
69535 PlaceTile(num25 - 2, num7 - 1, 15, mute: true, forced: false, 0, 8);
69536 PlaceTile(num25 + 2, num7 - 1, 15, mute: true, forced: false, 0, 8);
69537 }
69538 else
69539 {
69540 PlaceTile(num25, num7 - 1, 469, mute: true, forced: false, -1, 2);
69541 PlaceTile(num25 - 2, num7 - 1, 15, mute: true, forced: false, 0, 38);
69542 PlaceTile(num25 + 2, num7 - 1, 15, mute: true, forced: false, 0, 38);
69543 }
69544 }
69545 else
69546 {
69547 PlaceTile(num25, num7 - 1, 14, mute: true, forced: false, -1, 7);
69548 PlaceTile(num25 - 2, num7 - 1, 15, mute: true, forced: false, 0, 10);
69549 PlaceTile(num25 + 2, num7 - 1, 15, mute: true, forced: false, 0, 10);
69550 }
69551 Main.tile[num25 - 2, num7 - 1].frameX += 18;
69552 Main.tile[num25 - 2, num7 - 2].frameX += 18;
69553 if (!remixWorldGen)
69554 {
69555 int i2 = num4 + 1;
69556 int j2 = num6;
69557 PlaceTile(i2, j2, 91, mute: true, forced: false, -1, genRand.Next(7, 10));
69558 i2 = num5 - 1;
69559 j2 = num6;
69560 PlaceTile(i2, j2, 91, mute: true, forced: false, -1, genRand.Next(7, 10));
69561 if (num > 0)
69562 {
69563 i2 = num4;
69564 j2 = num6 + 1;
69565 }
69566 else
69567 {
69568 i2 = num5;
69569 j2 = num6 + 1;
69570 }
69571 PlaceTile(i2, j2, 91, mute: true, forced: false, -1, genRand.Next(7, 10));
69572 }
69573 if (islandStyle != 1)
69574 {
69575 return;
69576 }
69577 int num26 = genRand.Next(3, 6);
69578 for (int num27 = 0; num27 < 100000; num27++)
69579 {
69580 int num28 = i + genRand.Next(-50, 51);
69581 int num29 = num10 + genRand.Next(-10, 21);
69582 if (!Main.tile[num28, num29].active())
69583 {
69584 GrowPalmTree(num28, num29 + 1);
69585 if (Main.tile[num28, num29].active())
69586 {
69587 num26--;
69588 }
69589 }
69590 if (num26 <= 0)
69591 {
69592 break;
69593 }
69594 }
69595 }
69596
69597 public static void Mountinater(int i, int j)
69598 {
69599 //IL_00cc: Unknown result type (might be due to invalid IL or missing references)
69600 //IL_00e1: Unknown result type (might be due to invalid IL or missing references)
69601 //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
69602 //IL_010c: Unknown result type (might be due to invalid IL or missing references)
69603 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
69604 //IL_0210: Unknown result type (might be due to invalid IL or missing references)
69605 //IL_0211: Unknown result type (might be due to invalid IL or missing references)
69606 //IL_0216: Unknown result type (might be due to invalid IL or missing references)
69607 //IL_025f: Unknown result type (might be due to invalid IL or missing references)
69608 //IL_0280: Unknown result type (might be due to invalid IL or missing references)
69609 //IL_017c: Unknown result type (might be due to invalid IL or missing references)
69610 //IL_018b: Unknown result type (might be due to invalid IL or missing references)
69611 //IL_02a1: Unknown result type (might be due to invalid IL or missing references)
69612 //IL_02c2: Unknown result type (might be due to invalid IL or missing references)
69613 double num = genRand.Next(80, 120);
69614 double num2 = num;
69615 double num3 = genRand.Next(40, 55);
69616 if (remixWorldGen)
69617 {
69618 num2 *= 1.5;
69619 num3 *= 1.5;
69620 }
69621 Vector2D val = default(Vector2D);
69622 val.X = i;
69623 val.Y = (double)j + num3 / 2.0;
69624 Vector2D val2 = default(Vector2D);
69625 val2.X = (double)genRand.Next(-10, 11) * 0.1;
69626 val2.Y = (double)genRand.Next(-20, -10) * 0.1;
69627 while (num > 0.0 && num3 > 0.0)
69628 {
69629 num -= (double)genRand.Next(4);
69630 num3 -= 1.0;
69631 int num4 = (int)(val.X - num * 0.5);
69632 int num5 = (int)(val.X + num * 0.5);
69633 int num6 = (int)(val.Y - num * 0.5);
69634 int num7 = (int)(val.Y + num * 0.5);
69635 if (num4 < 0)
69636 {
69637 num4 = 0;
69638 }
69639 if (num5 > Main.maxTilesX)
69640 {
69642 }
69643 if (num6 < 0)
69644 {
69645 num6 = 0;
69646 }
69647 if (num7 > Main.maxTilesY)
69648 {
69650 }
69651 num2 = num * (double)genRand.Next(80, 120) * 0.01;
69652 for (int k = num4; k < num5; k++)
69653 {
69654 for (int l = num6; l < num7; l++)
69655 {
69656 double num8 = Math.Abs((double)k - val.X);
69657 double num9 = Math.Abs((double)l - val.Y);
69658 if (Math.Sqrt(num8 * num8 + num9 * num9) < num2 * 0.4 && !Main.tile[k, l].active())
69659 {
69660 Main.tile[k, l].active(active: true);
69661 Main.tile[k, l].type = 0;
69662 }
69663 }
69664 }
69665 val += val2;
69666 val2.X += (double)genRand.Next(-10, 11) * 0.05;
69667 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
69668 if (val2.X > 0.5)
69669 {
69670 val2.X = 0.5;
69671 }
69672 if (val2.X < -0.5)
69673 {
69674 val2.X = -0.5;
69675 }
69676 if (val2.Y > -0.5)
69677 {
69678 val2.Y = -0.5;
69679 }
69680 if (val2.Y < -1.5)
69681 {
69682 val2.Y = -1.5;
69683 }
69684 }
69685 }
69686
69687 public static void MakeWateryIceThing(int i, int j)
69688 {
69689 if (Main.tile[i, j].liquid <= 0 || Main.tile[i, j].active() || (Main.tile[i, j].lava() && !Main.remixWorld))
69690 {
69691 return;
69692 }
69693 int num = j;
69694 while (!Main.tile[i, num].active() && Main.tile[i, num].liquid > 0)
69695 {
69696 num++;
69697 if (num > Main.maxTilesY - 50)
69698 {
69699 return;
69700 }
69701 }
69702 if (Main.tile[i, num].type != 147 && Main.tile[i, num].type != 161)
69703 {
69704 return;
69705 }
69706 num--;
69707 while (Main.tile[i, num].liquid > 0)
69708 {
69709 num--;
69710 if (num < 10)
69711 {
69712 return;
69713 }
69714 }
69715 if (Main.tile[i, num].active())
69716 {
69717 return;
69718 }
69719 num++;
69720 if (!Main.tile[i, num].active())
69721 {
69722 int num2 = i;
69723 while (!Main.tile[num2, num].active() && Main.tile[num2, num].liquid > 0 && Main.tile[num2, num - 1].liquid == 0 && !Main.tile[num2, num - 1].active() && !Main.tile[num2 - 1, num].halfBrick())
69724 {
69725 PlaceTile(num2, num, 162, mute: true);
69726 num2--;
69727 }
69728 for (num2 = i + 1; !Main.tile[num2, num].active() && Main.tile[num2, num].liquid > 0 && Main.tile[num2, num - 1].liquid == 0 && !Main.tile[num2, num - 1].active() && !Main.tile[num2 + 1, num].halfBrick(); num2++)
69729 {
69730 PlaceTile(num2, num, 162, mute: true);
69731 }
69732 }
69733 }
69734
69735 public static void Lakinater(int i, int j, double strengthMultiplier = 1.0)
69736 {
69737 //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
69738 //IL_0107: Unknown result type (might be due to invalid IL or missing references)
69739 //IL_011c: Unknown result type (might be due to invalid IL or missing references)
69740 //IL_0132: Unknown result type (might be due to invalid IL or missing references)
69741 //IL_0147: Unknown result type (might be due to invalid IL or missing references)
69742 //IL_0251: Unknown result type (might be due to invalid IL or missing references)
69743 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
69744 //IL_0253: Unknown result type (might be due to invalid IL or missing references)
69745 //IL_0258: Unknown result type (might be due to invalid IL or missing references)
69746 //IL_02a1: Unknown result type (might be due to invalid IL or missing references)
69747 //IL_02c2: Unknown result type (might be due to invalid IL or missing references)
69748 //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
69749 //IL_01c9: Unknown result type (might be due to invalid IL or missing references)
69750 //IL_02e3: Unknown result type (might be due to invalid IL or missing references)
69751 //IL_0304: Unknown result type (might be due to invalid IL or missing references)
69752 double num = (double)genRand.Next(25, 50) * strengthMultiplier;
69753 double num2 = num;
69754 double num3 = genRand.Next(30, 80);
69755 if (genRand.Next(5) == 0)
69756 {
69757 num *= 1.5;
69758 num2 *= 1.5;
69759 num3 *= 1.2;
69760 }
69761 Vector2D val = default(Vector2D);
69762 val.X = i;
69763 val.Y = (double)j - num3 * 0.3;
69764 Vector2D val2 = default(Vector2D);
69765 val2.X = (double)genRand.Next(-10, 11) * 0.1;
69766 val2.Y = (double)genRand.Next(-20, -10) * 0.1;
69767 while (num > 0.0 && num3 > 0.0)
69768 {
69769 if (val.Y + num2 * 0.5 > Main.worldSurface)
69770 {
69771 num3 = 0.0;
69772 }
69773 num -= (double)genRand.Next(3);
69774 num3 -= 1.0;
69775 int num4 = (int)(val.X - num * 0.5);
69776 int num5 = (int)(val.X + num * 0.5);
69777 int num6 = (int)(val.Y - num * 0.5);
69778 int num7 = (int)(val.Y + num * 0.5);
69779 if (num4 < 0)
69780 {
69781 num4 = 0;
69782 }
69783 if (num5 > Main.maxTilesX)
69784 {
69786 }
69787 if (num6 < 0)
69788 {
69789 num6 = 0;
69790 }
69791 if (num7 > Main.maxTilesY)
69792 {
69794 }
69795 num2 = num * (double)genRand.Next(80, 120) * 0.01;
69796 for (int k = num4; k < num5; k++)
69797 {
69798 for (int l = num6; l < num7; l++)
69799 {
69800 double num8 = Math.Abs((double)k - val.X);
69801 double num9 = Math.Abs((double)l - val.Y);
69802 if (Math.Sqrt(num8 * num8 + num9 * num9) < num2 * 0.4)
69803 {
69804 if (Main.tile[k, l].active())
69805 {
69806 Main.tile[k, l].liquid = byte.MaxValue;
69807 }
69808 Main.tile[k, l].active(active: false);
69809 }
69810 }
69811 }
69812 val += val2;
69813 val2.X += (double)genRand.Next(-10, 11) * 0.05;
69814 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
69815 if (val2.X > 0.5)
69816 {
69817 val2.X = 0.5;
69818 }
69819 if (val2.X < -0.5)
69820 {
69821 val2.X = -0.5;
69822 }
69823 if (val2.Y > 1.5)
69824 {
69825 val2.Y = 1.5;
69826 }
69827 if (val2.Y < 0.5)
69828 {
69829 val2.Y = 0.5;
69830 }
69831 }
69832 }
69833
69834 public static void SonOfLakinater(int i, int j, double strengthMultiplier = 1.0)
69835 {
69836 //IL_0176: Unknown result type (might be due to invalid IL or missing references)
69837 //IL_018b: Unknown result type (might be due to invalid IL or missing references)
69838 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
69839 //IL_01b6: Unknown result type (might be due to invalid IL or missing references)
69840 //IL_0661: Unknown result type (might be due to invalid IL or missing references)
69841 //IL_0662: Unknown result type (might be due to invalid IL or missing references)
69842 //IL_0663: Unknown result type (might be due to invalid IL or missing references)
69843 //IL_0668: Unknown result type (might be due to invalid IL or missing references)
69844 //IL_06aa: Unknown result type (might be due to invalid IL or missing references)
69845 //IL_06cb: Unknown result type (might be due to invalid IL or missing references)
69846 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
69847 //IL_022a: Unknown result type (might be due to invalid IL or missing references)
69848 //IL_0245: Unknown result type (might be due to invalid IL or missing references)
69849 //IL_0260: Unknown result type (might be due to invalid IL or missing references)
69850 //IL_06ec: Unknown result type (might be due to invalid IL or missing references)
69851 //IL_0728: Unknown result type (might be due to invalid IL or missing references)
69852 //IL_040e: Unknown result type (might be due to invalid IL or missing references)
69853 bool lava = false;
69854 if (getGoodWorldGen && genRand.Next(3) == 0)
69855 {
69856 lava = true;
69857 }
69858 double num = (double)genRand.Next(15, 31) * strengthMultiplier;
69859 double num2 = genRand.Next(30, 61);
69860 if (genRand.Next(5) == 0)
69861 {
69862 num *= 1.3;
69863 num2 *= 1.3;
69864 }
69865 if (drunkWorldGen)
69866 {
69867 num *= 1.3;
69868 num2 *= 1.3;
69869 }
69870 Vector2D val = default(Vector2D);
69871 val.X = i;
69872 val.Y = j;
69873 double num3 = genRand.NextDouble() * 0.002;
69874 Vector2D val2 = default(Vector2D);
69875 if (genRand.Next(4) != 0)
69876 {
69877 val2.X = (double)genRand.Next(-15, 16) * 0.01;
69878 }
69879 else
69880 {
69881 val2.X = (double)genRand.Next(-50, 51) * 0.01;
69882 num3 = genRand.NextDouble() * 0.004 + 0.001;
69883 }
69884 val2.Y = (double)genRand.Next(101) * 0.01;
69885 double num4 = num;
69886 double num5 = num2;
69887 while (num > 3.0 && num2 > 0.0)
69888 {
69889 num -= (double)genRand.Next(11) * 0.1;
69890 num2 -= 1.0;
69891 int num6 = (int)(val.X - num * 4.0);
69892 int num7 = (int)(val.X + num * 4.0);
69893 int num8 = (int)(val.Y - num * 3.0);
69894 int num9 = (int)(val.Y + num * 2.0);
69895 if (num6 < 0)
69896 {
69897 num6 = 0;
69898 }
69899 if (num7 > Main.maxTilesX)
69900 {
69902 }
69903 if (num8 < 0)
69904 {
69905 num8 = 0;
69906 }
69907 if (num9 > Main.maxTilesY)
69908 {
69910 }
69911 num4 = num;
69912 for (int k = num6; k < num7; k++)
69913 {
69914 for (int l = num8; l < num9; l++)
69915 {
69916 double value = Math.Abs((double)k - val.X) * 0.6;
69917 double value2 = Math.Abs((double)l - val.Y) * 1.4;
69918 double value3 = Math.Abs((double)k - val.X) * 0.3;
69919 double value4 = Math.Abs((double)l - val.Y) * 5.0;
69922 double num10 = Math.Sqrt(value * value + value2 * value2);
69923 int num11 = j + 5;
69924 if (num10 < num4 * 0.4)
69925 {
69926 if (l >= j)
69927 {
69928 if (l <= j + 1)
69929 {
69930 if (WillWaterPlacedHereStayPut(k, l))
69931 {
69932 Main.tile[k, l].liquid = byte.MaxValue;
69933 Main.tile[k, l].lava(lava);
69934 }
69935 }
69936 else
69937 {
69938 Main.tile[k, l].liquid = byte.MaxValue;
69939 Main.tile[k, l].lava(lava);
69940 }
69941 }
69942 Main.tile[k, l].active(active: false);
69943 if (!gen)
69944 {
69945 SquareTileFrame(k, l);
69946 }
69947 if (Main.tile[k, l].type == 59 || Main.tile[k, l].type == 60)
69948 {
69949 SpreadGrass(k - 1, l, 59, 60);
69950 SpreadGrass(k + 1, l, 59, 60);
69951 SpreadGrass(k, l + 1, 59, 60);
69952 }
69953 }
69954 else if (l > j + 1 && num10 < num4 && Main.tile[k, l].liquid == 0)
69955 {
69956 if (Math.Abs((double)k - val.X) * 0.8 < num4 && Main.tile[k, l].wall > 0 && Main.tile[k - 1, l].wall > 0 && Main.tile[k + 1, l].wall > 0 && Main.tile[k, l + 1].wall > 0)
69957 {
69958 Main.tile[k, l].active(active: true);
69959 }
69960 }
69961 else
69962 {
69963 if (l >= j || num2 != num5 - 1.0 || !((double)l > GenVars.worldSurfaceLow - 20.0) || TileID.Sets.Clouds[Main.tile[k, l].type])
69964 {
69965 continue;
69966 }
69967 value = (double)Math.Abs(k - i) * 0.7;
69968 value2 = (double)Math.Abs(l - num11) * 1.35;
69970 double num12 = num4 * 0.4;
69971 double num13 = (double)Math.Abs(k - i) / (double)(num7 - i);
69972 num13 = 1.0 - num13;
69973 num13 *= 2.3;
69974 num13 *= num13;
69975 num13 *= num13;
69976 if (l < num11 && value < num12 + (double)Math.Abs(l - num11) * 0.5 * num13)
69977 {
69978 Main.tile[k, l].active(active: false);
69979 if (Main.tile[k, l].type == 59 || Main.tile[k, l].type == 60)
69980 {
69981 SpreadGrass(k - 1, l, 59, 60);
69982 SpreadGrass(k + 1, l, 59, 60);
69983 SpreadGrass(k, l + 1, 59, 60);
69984 }
69985 }
69986 }
69987 }
69988 }
69989 val += val2;
69990 val2.X += (double)genRand.Next(-100, 101) * num3;
69991 val2.Y += (double)genRand.Next(-100, 101) * 0.01;
69992 if (val2.X > 1.0)
69993 {
69994 val2.X = 1.0;
69995 }
69996 if (val2.X < -1.0)
69997 {
69998 val2.X = -1.0;
69999 }
70000 if (val2.Y > 1.0)
70001 {
70002 val2.Y = 1.0;
70003 }
70004 double num14 = 0.5 * (1.0 - num2 / num5);
70005 if (val2.Y < num14)
70006 {
70007 val2.Y = num14;
70008 }
70009 }
70010 }
70011
70012 public static void ShroomPatch(int i, int j)
70013 {
70014 //IL_00f6: Unknown result type (might be due to invalid IL or missing references)
70015 //IL_010b: Unknown result type (might be due to invalid IL or missing references)
70016 //IL_0121: Unknown result type (might be due to invalid IL or missing references)
70017 //IL_0136: Unknown result type (might be due to invalid IL or missing references)
70018 //IL_032c: Unknown result type (might be due to invalid IL or missing references)
70019 //IL_032d: Unknown result type (might be due to invalid IL or missing references)
70020 //IL_032e: Unknown result type (might be due to invalid IL or missing references)
70021 //IL_0333: Unknown result type (might be due to invalid IL or missing references)
70022 //IL_033d: Unknown result type (might be due to invalid IL or missing references)
70023 //IL_038b: Unknown result type (might be due to invalid IL or missing references)
70024 //IL_03e0: Unknown result type (might be due to invalid IL or missing references)
70025 //IL_039c: Unknown result type (might be due to invalid IL or missing references)
70026 //IL_01a9: Unknown result type (might be due to invalid IL or missing references)
70027 //IL_01b8: Unknown result type (might be due to invalid IL or missing references)
70028 //IL_0401: Unknown result type (might be due to invalid IL or missing references)
70029 //IL_03ad: Unknown result type (might be due to invalid IL or missing references)
70030 //IL_0422: Unknown result type (might be due to invalid IL or missing references)
70031 //IL_022b: Unknown result type (might be due to invalid IL or missing references)
70032 //IL_0443: Unknown result type (might be due to invalid IL or missing references)
70033 //IL_02c7: Unknown result type (might be due to invalid IL or missing references)
70034 //IL_046c: Unknown result type (might be due to invalid IL or missing references)
70035 //IL_0484: Unknown result type (might be due to invalid IL or missing references)
70036 //IL_049d: Unknown result type (might be due to invalid IL or missing references)
70037 //IL_04b5: Unknown result type (might be due to invalid IL or missing references)
70038 double num = genRand.Next(80, 100);
70039 double num2 = genRand.Next(20, 26);
70040 double num3 = (double)Main.maxTilesX / 4200.0;
70041 if (getGoodWorldGen && !Main.remixWorld)
70042 {
70043 num3 *= 1.5;
70044 }
70045 num *= num3;
70046 num2 *= num3;
70047 double num4 = num2 - 1.0;
70048 double num5 = num;
70049 Vector2D val = default(Vector2D);
70050 val.X = i;
70051 val.Y = (double)j - num2 * 0.3;
70052 Vector2D val2 = default(Vector2D);
70053 val2.X = (double)genRand.Next(-100, 101) * 0.005;
70054 val2.Y = (double)genRand.Next(-200, -100) * 0.005;
70055 while (num > 0.0 && num2 > 0.0)
70056 {
70057 num -= (double)genRand.Next(3);
70058 num2 -= 1.0;
70059 int num6 = (int)(val.X - num * 0.5);
70060 int num7 = (int)(val.X + num * 0.5);
70061 int num8 = (int)(val.Y - num * 0.5);
70062 int num9 = (int)(val.Y + num * 0.5);
70063 if (num6 < 0)
70064 {
70065 num6 = 0;
70066 }
70067 if (num7 > Main.maxTilesX)
70068 {
70070 }
70071 if (num8 < 0)
70072 {
70073 num8 = 0;
70074 }
70075 if (num9 > Main.maxTilesY)
70076 {
70078 }
70079 num5 = num * (double)genRand.Next(80, 120) * 0.01;
70080 for (int k = num6; k < num7; k++)
70081 {
70082 for (int l = num8; l < num9; l++)
70083 {
70084 double num10 = Math.Abs((double)k - val.X);
70085 double num11 = Math.Abs(((double)l - val.Y) * 2.3);
70086 double num12 = Math.Sqrt(num10 * num10 + num11 * num11);
70087 if (num12 < num5 * 0.8 && Main.tile[k, l].lava())
70088 {
70089 Main.tile[k, l].liquid = 0;
70090 }
70091 if (num12 < num5 * 0.2 && (double)l < val.Y)
70092 {
70093 Main.tile[k, l].active(active: false);
70094 if (Main.tile[k, l].wall > 0)
70095 {
70096 Main.tile[k, l].wall = 80;
70097 }
70098 }
70099 else if (num12 < num5 * 0.4 * (0.95 + genRand.NextDouble() * 0.1))
70100 {
70101 Main.tile[k, l].type = 59;
70102 if (num2 == num4 && (double)l > val.Y)
70103 {
70104 Main.tile[k, l].active(active: true);
70105 }
70106 if (Main.tile[k, l].wall > 0)
70107 {
70108 Main.tile[k, l].wall = 80;
70109 }
70110 }
70111 }
70112 }
70113 val += val2;
70114 val.X += val2.X;
70115 val2.X += (double)genRand.Next(-100, 110) * 0.005;
70116 val2.Y -= (double)genRand.Next(110) * 0.005;
70117 if (val2.X > -0.5 && val2.X < 0.5)
70118 {
70119 if (val2.X < 0.0)
70120 {
70121 val2.X = -0.5;
70122 }
70123 else
70124 {
70125 val2.X = 0.5;
70126 }
70127 }
70128 if (val2.X > 0.5)
70129 {
70130 val2.X = 0.5;
70131 }
70132 if (val2.X < -0.5)
70133 {
70134 val2.X = -0.5;
70135 }
70136 if (val2.Y > 0.5)
70137 {
70138 val2.Y = 0.5;
70139 }
70140 if (val2.Y < -0.5)
70141 {
70142 val2.Y = -0.5;
70143 }
70144 for (int m = 0; m < 2; m++)
70145 {
70146 int num13 = (int)val.X + genRand.Next(-20, 20);
70147 int num14 = (int)val.Y + genRand.Next(0, 20);
70148 while (!Main.tile[num13, num14].active() && Main.tile[num13, num14].type != 59)
70149 {
70150 num13 = (int)val.X + genRand.Next(-20, 20);
70151 num14 = (int)val.Y + genRand.Next(0, 20);
70152 }
70153 int num15 = genRand.Next(10, 20);
70154 int steps = genRand.Next(10, 20);
70155 TileRunner(num13, num14, num15, steps, 59, addTile: false, 0.0, 2.0, noYChange: true);
70156 }
70157 }
70158 }
70159
70160 public static void Cavinator(int i, int j, int steps)
70161 {
70162 //IL_007e: Unknown result type (might be due to invalid IL or missing references)
70163 //IL_0093: Unknown result type (might be due to invalid IL or missing references)
70164 //IL_00a9: Unknown result type (might be due to invalid IL or missing references)
70165 //IL_00be: Unknown result type (might be due to invalid IL or missing references)
70166 //IL_02bd: Unknown result type (might be due to invalid IL or missing references)
70167 //IL_02d6: Unknown result type (might be due to invalid IL or missing references)
70168 //IL_02dd: Unknown result type (might be due to invalid IL or missing references)
70169 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
70170 //IL_01ce: Unknown result type (might be due to invalid IL or missing references)
70171 //IL_01cf: Unknown result type (might be due to invalid IL or missing references)
70172 //IL_01d4: Unknown result type (might be due to invalid IL or missing references)
70173 //IL_021d: Unknown result type (might be due to invalid IL or missing references)
70174 //IL_0246: Unknown result type (might be due to invalid IL or missing references)
70175 //IL_0131: Unknown result type (might be due to invalid IL or missing references)
70176 //IL_0140: Unknown result type (might be due to invalid IL or missing references)
70177 //IL_026f: Unknown result type (might be due to invalid IL or missing references)
70178 //IL_0290: Unknown result type (might be due to invalid IL or missing references)
70179 double num = genRand.Next(7, 15);
70180 double num2 = num;
70181 int num3 = 1;
70182 if (genRand.Next(2) == 0)
70183 {
70184 num3 = -1;
70185 }
70186 Vector2D val = default(Vector2D);
70187 val.X = i;
70188 val.Y = j;
70189 int num4 = genRand.Next(20, 40);
70190 Vector2D val2 = default(Vector2D);
70191 val2.Y = (double)genRand.Next(10, 20) * 0.01;
70192 val2.X = num3;
70193 while (num4 > 0)
70194 {
70195 num4--;
70196 int num5 = (int)(val.X - num * 0.5);
70197 int num6 = (int)(val.X + num * 0.5);
70198 int num7 = (int)(val.Y - num * 0.5);
70199 int num8 = (int)(val.Y + num * 0.5);
70200 if (num5 < 0)
70201 {
70202 num5 = 0;
70203 }
70204 if (num6 > Main.maxTilesX)
70205 {
70207 }
70208 if (num7 < 0)
70209 {
70210 num7 = 0;
70211 }
70212 if (num8 > Main.maxTilesY)
70213 {
70215 }
70216 num2 = num * (double)genRand.Next(80, 120) * 0.01;
70217 for (int k = num5; k < num6; k++)
70218 {
70219 for (int l = num7; l < num8; l++)
70220 {
70221 double num9 = Math.Abs((double)k - val.X);
70222 double num10 = Math.Abs((double)l - val.Y);
70223 if (Math.Sqrt(num9 * num9 + num10 * num10) < num2 * 0.4 && TileID.Sets.CanBeClearedDuringGeneration[Main.tile[k, l].type] && Main.tile[k, l].type != 53)
70224 {
70225 Main.tile[k, l].active(active: false);
70226 }
70227 }
70228 }
70229 val += val2;
70230 val2.X += (double)genRand.Next(-10, 11) * 0.05;
70231 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
70232 if (val2.X > (double)num3 + 0.5)
70233 {
70234 val2.X = (double)num3 + 0.5;
70235 }
70236 if (val2.X < (double)num3 - 0.5)
70237 {
70238 val2.X = (double)num3 - 0.5;
70239 }
70240 if (val2.Y > 2.0)
70241 {
70242 val2.Y = 2.0;
70243 }
70244 if (val2.Y < 0.0)
70245 {
70246 val2.Y = 0.0;
70247 }
70248 }
70249 if (steps > 0 && (double)(int)val.Y < Main.rockLayer + 50.0)
70250 {
70251 Cavinator((int)val.X, (int)val.Y, steps - 1);
70252 }
70253 }
70254
70255 public static void CaveOpenater(int i, int j)
70256 {
70257 //IL_0081: Unknown result type (might be due to invalid IL or missing references)
70258 //IL_0088: Unknown result type (might be due to invalid IL or missing references)
70259 //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
70260 //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
70261 //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
70262 //IL_0100: Unknown result type (might be due to invalid IL or missing references)
70263 //IL_01f2: Unknown result type (might be due to invalid IL or missing references)
70264 //IL_01f3: Unknown result type (might be due to invalid IL or missing references)
70265 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)
70266 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
70267 //IL_0242: Unknown result type (might be due to invalid IL or missing references)
70268 //IL_026b: Unknown result type (might be due to invalid IL or missing references)
70269 //IL_0170: Unknown result type (might be due to invalid IL or missing references)
70270 //IL_017f: Unknown result type (might be due to invalid IL or missing references)
70271 //IL_0294: Unknown result type (might be due to invalid IL or missing references)
70272 //IL_02b5: Unknown result type (might be due to invalid IL or missing references)
70273 double num = genRand.Next(7, 12);
70274 double num2 = num;
70275 int num3 = 1;
70276 if (genRand.Next(2) == 0)
70277 {
70278 num3 = -1;
70279 }
70280 if (genRand.Next(10) != 0)
70281 {
70282 num3 = ((i < Main.maxTilesX / 2) ? 1 : (-1));
70283 }
70284 Vector2D val = default(Vector2D);
70285 val.X = i;
70286 val.Y = j;
70287 int num4 = 100;
70288 Vector2D val2 = default(Vector2D);
70289 val2.Y = 0.0;
70290 val2.X = num3;
70291 while (num4 > 0)
70292 {
70293 Tile tile = Main.tile[(int)val.X, (int)val.Y];
70294 if (tile.wall == 0 || (tile.active() && !TileID.Sets.CanBeClearedDuringGeneration[tile.type]))
70295 {
70296 num4 = 0;
70297 }
70298 num4--;
70299 int num5 = (int)(val.X - num * 0.5);
70300 int num6 = (int)(val.X + num * 0.5);
70301 int num7 = (int)(val.Y - num * 0.5);
70302 int num8 = (int)(val.Y + num * 0.5);
70303 if (num5 < 0)
70304 {
70305 num5 = 0;
70306 }
70307 if (num6 > Main.maxTilesX)
70308 {
70310 }
70311 if (num7 < 0)
70312 {
70313 num7 = 0;
70314 }
70315 if (num8 > Main.maxTilesY)
70316 {
70318 }
70319 num2 = num * (double)genRand.Next(80, 120) * 0.01;
70320 for (int k = num5; k < num6; k++)
70321 {
70322 for (int l = num7; l < num8; l++)
70323 {
70324 double num9 = Math.Abs((double)k - val.X);
70325 double num10 = Math.Abs((double)l - val.Y);
70327 {
70328 Main.tile[k, l].active(active: false);
70329 }
70330 }
70331 }
70332 val += val2;
70333 val2.X += (double)genRand.Next(-10, 11) * 0.05;
70334 val2.Y += (double)genRand.Next(-10, 11) * 0.05;
70335 if (val2.X > (double)num3 + 0.5)
70336 {
70337 val2.X = (double)num3 + 0.5;
70338 }
70339 if (val2.X < (double)num3 - 0.5)
70340 {
70341 val2.X = (double)num3 - 0.5;
70342 }
70343 if (val2.Y > 0.0)
70344 {
70345 val2.Y = 0.0;
70346 }
70347 if (val2.Y < -0.5)
70348 {
70349 val2.Y = -0.5;
70350 }
70351 }
70352 }
70353
70354 public static void DiamondTileFrame(int i, int j)
70355 {
70356 TileFrame(i - 1, j);
70357 TileFrame(i, j - 1);
70358 TileFrame(i, j + 1);
70359 TileFrame(i + 1, j);
70360 }
70361
70362 public static void SquareTileFrame(int i, int j, bool resetFrame = true)
70363 {
70364 TileFrame(i - 1, j - 1);
70365 TileFrame(i - 1, j);
70366 TileFrame(i - 1, j + 1);
70367 TileFrame(i, j - 1);
70368 TileFrame(i, j, resetFrame);
70369 TileFrame(i, j + 1);
70370 TileFrame(i + 1, j - 1);
70371 TileFrame(i + 1, j);
70372 TileFrame(i + 1, j + 1);
70373 }
70374
70375 public static void SquareWallFrame(int i, int j, bool resetFrame = true)
70376 {
70377 Framing.WallFrame(i - 1, j - 1);
70378 Framing.WallFrame(i - 1, j);
70379 Framing.WallFrame(i - 1, j + 1);
70380 Framing.WallFrame(i, j - 1);
70382 Framing.WallFrame(i, j + 1);
70383 Framing.WallFrame(i + 1, j - 1);
70384 Framing.WallFrame(i + 1, j);
70385 Framing.WallFrame(i + 1, j + 1);
70386 }
70387
70388 public static void SectionTileFrameWithCheck(int startX, int startY, int endX, int endY)
70389 {
70394 for (int i = sectionX; i <= sectionX2; i++)
70395 {
70396 for (int j = sectionY; j <= sectionY2; j++)
70397 {
70398 if (Main.sectionManager.SectionLoaded(i, j) && !Main.sectionManager.SectionFramed(i, j))
70399 {
70400 SectionTileFrame(i, j, i, j);
70401 if (!Main.sectionManager.AnyUnfinishedSections)
70402 {
70403 return;
70404 }
70405 }
70406 }
70407 }
70408 }
70409
70410 public static void RefreshSections(int startX, int startY, int endX, int endY)
70411 {
70416 for (int i = sectionX; i <= sectionX2; i++)
70417 {
70418 for (int j = sectionY; j <= sectionY2; j++)
70419 {
70420 if (Main.sectionManager.SectionNeedsRefresh(i, j))
70421 {
70422 RefreshSection(i, j);
70423 }
70424 }
70425 }
70426 }
70427
70428 public static void RefreshSection(int sectionX, int sectionY)
70429 {
70431 noMapUpdate = true;
70432 int totalEcho = 0;
70433 int totalFramed = 0;
70434 for (int i = tileStartY; i < tileEndY; i += 50)
70435 {
70436 for (int j = tileStartX; j < tileEndX; j += 200)
70437 {
70438 RefreshStrip(j, i, Math.Min(j + 200, tileEndX), Math.Min(i + 50, tileEndY), ref totalEcho, ref totalFramed);
70439 }
70440 }
70441 noMapUpdate = false;
70442 Main.sectionManager.SetSectionAsRefreshed(sectionX, sectionY);
70443 }
70444
70445 public static void RefreshStrip(int xStart, int yStart, int xEnd, int yEnd, ref int totalEcho, ref int totalFramed)
70446 {
70447 int num = xStart - 1;
70448 int num2 = yStart - 1;
70449 int num3 = xEnd - xStart;
70450 int num4 = yEnd - yStart;
70451 if (num4 > 50 || num3 > 200)
70452 {
70453 throw new IndexOutOfRangeException();
70454 }
70455 int num5 = 0;
70457 for (int i = 1; i <= num3; i++)
70458 {
70459 Bits64 value = default(Bits64);
70460 for (int j = 1; j <= num4; j++)
70461 {
70462 Tile tile = Main.tile[num + i, num2 + j];
70463 if (tile != null && (tile.invisibleBlock() || tile.invisibleWall()))
70464 {
70465 num5++;
70466 value[j] = true;
70467 }
70468 }
70470 }
70471 if (num5 == 0)
70472 {
70473 return;
70474 }
70475 vertical64BitStrips.Expand3x3();
70476 for (int k = 0; k < num3 + 2; k++)
70477 {
70479 if (bits.IsEmpty)
70480 {
70481 continue;
70482 }
70483 for (int l = 0; l < num4 + 2; l++)
70484 {
70485 if (bits[l])
70486 {
70487 totalFramed++;
70488 Reframe(num + k, num2 + l);
70489 }
70490 }
70491 }
70493 totalEcho += num5;
70494 }
70495
70496 public static void Reframe(int x, int y, bool resetFrame = false)
70497 {
70498 TileFrame(x, y, resetFrame, noBreak: true);
70500 }
70501
70503 {
70504 Main.mapTime = Main.mapTimeMax + 10;
70505 noMapUpdate = true;
70507 for (int i = tileStartX - 1; i < tileEndX + 1; i++)
70508 {
70509 for (int j = tileStartY - 1; j < tileEndY + 1; j++)
70510 {
70511 if (Main.tile[i, j] == null)
70512 {
70513 Main.tile[i, j] = new Tile();
70514 }
70515 Reframe(i, j, resetFrame: true);
70516 }
70517 }
70518 for (int k = sectionStartX; k <= sectionEndXInclusive; k++)
70519 {
70520 for (int l = sectionStartY; l <= sectionEndYInclusive; l++)
70521 {
70522 Main.sectionManager.SetSectionFramed(k, l);
70523 }
70524 }
70525 noMapUpdate = false;
70526 }
70527
70529 {
70530 tileStartX = sectionStartX * 200;
70531 tileEndX = (sectionEndXInclusive + 1) * 200;
70532 tileStartY = sectionStartY * 150;
70533 tileEndY = (sectionEndYInclusive + 1) * 150;
70534 if (tileStartX < 1)
70535 {
70536 tileStartX = 1;
70537 }
70538 if (tileStartY < 1)
70539 {
70540 tileStartY = 1;
70541 }
70542 if (tileStartX > Main.maxTilesX - 2)
70543 {
70544 tileStartX = Main.maxTilesX - 2;
70545 }
70546 if (tileStartY > Main.maxTilesY - 2)
70547 {
70548 tileStartY = Main.maxTilesY - 2;
70549 }
70550 if (tileEndX > Main.maxTilesX - 2)
70551 {
70552 tileEndX = Main.maxTilesX - 2;
70553 }
70554 if (tileEndY > Main.maxTilesY - 2)
70555 {
70556 tileEndY = Main.maxTilesY - 2;
70557 }
70558 }
70559
70560 public static void RangeFrame(int startX, int startY, int endX, int endY)
70561 {
70562 int num = endX + 1;
70563 int num2 = endY + 1;
70564 for (int i = startX - 1; i < num + 1; i++)
70565 {
70566 for (int j = startY - 1; j < num2 + 1; j++)
70567 {
70568 TileFrame(i, j);
70569 Framing.WallFrame(i, j);
70570 }
70571 }
70572 }
70573
70574 public static void WaterCheck()
70575 {
70577 Liquid.numLiquid = 0;
70578 LiquidBuffer.numLiquidBuffer = 0;
70579 for (int i = 1; i < Main.maxTilesX - 1; i++)
70580 {
70581 for (int num = Main.maxTilesY - 2; num > 0; num--)
70582 {
70583 Tile tile = Main.tile[i, num];
70584 tile.checkingLiquid(checkingLiquid: false);
70585 if (tile.liquid > 0 && tile.nactive() && Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type])
70586 {
70587 tile.liquid = 0;
70588 }
70589 else if (tile.liquid > 0)
70590 {
70591 if (tile.active())
70592 {
70593 if (tile.lava())
70594 {
70596 {
70597 KillTile(i, num);
70598 }
70599 }
70600 else if (TileObjectData.CheckWaterDeath(tile))
70601 {
70602 KillTile(i, num);
70603 }
70604 }
70605 Tile tile2 = Main.tile[i, num + 1];
70606 if ((!tile2.nactive() || !Main.tileSolid[tile2.type] || Main.tileSolidTop[tile2.type]) && tile2.liquid < byte.MaxValue)
70607 {
70608 if (tile2.liquid > 250)
70609 {
70610 tile2.liquid = byte.MaxValue;
70611 }
70612 else
70613 {
70614 Liquid.AddWater(i, num);
70615 }
70616 }
70617 Tile tile3 = Main.tile[i - 1, num];
70618 Tile tile4 = Main.tile[i + 1, num];
70619 if ((!tile3.nactive() || !Main.tileSolid[tile3.type] || Main.tileSolidTop[tile3.type]) && tile3.liquid != tile.liquid)
70620 {
70621 Liquid.AddWater(i, num);
70622 }
70623 else if ((!tile4.nactive() || !Main.tileSolid[tile4.type] || Main.tileSolidTop[tile4.type]) && tile4.liquid != tile.liquid)
70624 {
70625 Liquid.AddWater(i, num);
70626 }
70627 if (tile.lava())
70628 {
70629 if (tile3.liquid > 0 && !tile3.lava())
70630 {
70631 Liquid.AddWater(i, num);
70632 }
70633 else if (tile4.liquid > 0 && !tile4.lava())
70634 {
70635 Liquid.AddWater(i, num);
70636 }
70637 else if (Main.tile[i, num - 1].liquid > 0 && !Main.tile[i, num - 1].lava())
70638 {
70639 Liquid.AddWater(i, num);
70640 }
70641 else if (tile2.liquid > 0 && !tile2.lava())
70642 {
70643 Liquid.AddWater(i, num);
70644 }
70645 }
70646 }
70647 }
70648 }
70650 }
70651
70652 public static void EveryTileFrame()
70653 {
70655 stopwatch.Start();
70656 noLiquidCheck = true;
70657 noTileActions = true;
70658 for (int i = 0; i < Main.maxTilesX; i++)
70659 {
70660 float num = (float)i / (float)Main.maxTilesX;
70661 Main.statusText = Lang.gen[55].Value + " " + (int)(num * 100f + 1f) + "%";
70662 for (int j = 0; j < Main.maxTilesY; j++)
70663 {
70664 if (Main.tile[i, j].active())
70665 {
70666 TileFrame(i, j, resetFrame: true);
70667 }
70668 if (Main.tile[i, j].wall > 0)
70669 {
70670 Framing.WallFrame(i, j, resetFrame: true);
70671 }
70672 }
70673 }
70674 noLiquidCheck = false;
70675 noTileActions = false;
70676 _ = stopwatch.ElapsedMilliseconds;
70677 }
70678
70679 public static void PlantCheck(int x, int y)
70680 {
70681 x = Utils.Clamp(x, 1, Main.maxTilesX - 2);
70682 y = Utils.Clamp(y, 1, Main.maxTilesY - 2);
70683 for (int i = x - 1; i <= x + 1; i++)
70684 {
70685 for (int j = y - 1; j <= y + 1; j++)
70686 {
70687 if (Main.tile[i, j] == null)
70688 {
70689 return;
70690 }
70691 }
70692 }
70693 int num = -1;
70694 int num2 = Main.tile[x, y].type;
70695 _ = x - 1;
70696 _ = 0;
70697 _ = x + 1;
70698 _ = Main.maxTilesX;
70699 _ = y - 1;
70700 _ = 0;
70701 if (y + 1 >= Main.maxTilesY)
70702 {
70703 num = num2;
70704 }
70705 if (x - 1 >= 0 && Main.tile[x - 1, y] != null && Main.tile[x - 1, y].nactive())
70706 {
70707 _ = Main.tile[x - 1, y].type;
70708 }
70709 if (x + 1 < Main.maxTilesX && Main.tile[x + 1, y] != null && Main.tile[x + 1, y].nactive())
70710 {
70711 _ = Main.tile[x + 1, y].type;
70712 }
70713 if (y - 1 >= 0 && Main.tile[x, y - 1] != null && Main.tile[x, y - 1].nactive())
70714 {
70715 _ = Main.tile[x, y - 1].type;
70716 }
70717 if (y + 1 < Main.maxTilesY && Main.tile[x, y + 1] != null && Main.tile[x, y + 1].nactive() && !Main.tile[x, y + 1].halfBrick() && Main.tile[x, y + 1].slope() == 0)
70718 {
70719 num = Main.tile[x, y + 1].type;
70720 }
70721 if (x - 1 >= 0 && y - 1 >= 0 && Main.tile[x - 1, y - 1] != null && Main.tile[x - 1, y - 1].nactive())
70722 {
70723 _ = Main.tile[x - 1, y - 1].type;
70724 }
70725 if (x + 1 < Main.maxTilesX && y - 1 >= 0 && Main.tile[x + 1, y - 1] != null && Main.tile[x + 1, y - 1].nactive())
70726 {
70727 _ = Main.tile[x + 1, y - 1].type;
70728 }
70729 if (x - 1 >= 0 && y + 1 < Main.maxTilesY && Main.tile[x - 1, y + 1] != null && Main.tile[x - 1, y + 1].nactive())
70730 {
70731 _ = Main.tile[x - 1, y + 1].type;
70732 }
70733 if (x + 1 < Main.maxTilesX && y + 1 < Main.maxTilesY && Main.tile[x + 1, y + 1] != null && Main.tile[x + 1, y + 1].nactive())
70734 {
70735 _ = Main.tile[x + 1, y + 1].type;
70736 }
70737 if ((num2 != 3 || num == 2 || num == 477 || num == 78 || num == 380 || num == 579) && (num2 != 73 || num == 2 || num == 477 || num == 78 || num == 380 || num == 579) && (num2 != 24 || num == 23 || num == 661) && (num2 != 61 || num == 60) && (num2 != 74 || num == 60) && (num2 != 71 || num == 70) && (num2 != 110 || num == 109 || num == 492) && (num2 != 113 || num == 109 || num == 492) && (num2 != 201 || num == 199 || num == 662) && (num2 != 637 || num == 633))
70738 {
70739 return;
70740 }
70741 bool flag = false;
70742 if (num2 == 3 || num2 == 110 || num2 == 24)
70743 {
70744 flag = Main.tile[x, y].frameX == 144;
70745 }
70746 if (num2 == 201)
70747 {
70748 flag = Main.tile[x, y].frameX == 270;
70749 }
70750 if ((num2 == 3 || num2 == 73) && num != 2 && num != 477 && Main.tile[x, y].frameX >= 162)
70751 {
70752 Main.tile[x, y].frameX = 126;
70753 }
70754 if (num2 == 74 && num != 60 && Main.tile[x, y].frameX >= 162)
70755 {
70756 Main.tile[x, y].frameX = 126;
70757 }
70758 switch (num)
70759 {
70760 case 23:
70761 case 661:
70762 num2 = 24;
70763 if (Main.tile[x, y].frameX >= 162)
70764 {
70765 Main.tile[x, y].frameX = 126;
70766 }
70767 break;
70768 case 2:
70769 case 477:
70770 num2 = ((num2 != 113) ? 3 : 73);
70771 break;
70772 case 109:
70773 case 492:
70774 num2 = ((num2 != 73) ? 110 : 113);
70775 break;
70776 case 199:
70777 case 662:
70778 num2 = 201;
70779 break;
70780 case 60:
70781 num2 = 61;
70782 while (Main.tile[x, y].frameX > 126)
70783 {
70784 Main.tile[x, y].frameX -= 126;
70785 }
70786 break;
70787 case 70:
70788 num2 = 71;
70789 while (Main.tile[x, y].frameX > 72)
70790 {
70791 Main.tile[x, y].frameX -= 72;
70792 }
70793 break;
70794 }
70795 if (num2 != Main.tile[x, y].type)
70796 {
70797 Main.tile[x, y].type = (ushort)num2;
70798 if (flag)
70799 {
70800 Main.tile[x, y].frameX = 144;
70801 if (num2 == 201)
70802 {
70803 Main.tile[x, y].frameX = 270;
70804 }
70805 }
70806 }
70807 else
70808 {
70809 KillTile(x, y);
70810 }
70811 }
70812
70813 public static bool CanPoundTile(int x, int y)
70814 {
70815 if (Main.tile[x, y] == null)
70816 {
70817 Main.tile[x, y] = new Tile();
70818 }
70819 if (Main.tile[x, y - 1] == null)
70820 {
70821 Main.tile[x, y - 1] = new Tile();
70822 }
70823 if (Main.tile[x, y + 1] == null)
70824 {
70825 Main.tile[x, y + 1] = new Tile();
70826 }
70827 switch (Main.tile[x, y].type)
70828 {
70829 case 10:
70830 case 48:
70831 case 137:
70832 case 138:
70833 case 232:
70834 case 380:
70835 case 387:
70836 case 388:
70837 case 476:
70838 case 484:
70839 case 664:
70840 case 665:
70841 return false;
70842 default:
70843 if (gen)
70844 {
70845 if (Main.tile[x, y].type == 190)
70846 {
70847 return false;
70848 }
70849 if (Main.tile[x, y].type == 30)
70850 {
70851 return false;
70852 }
70853 }
70854 if (Main.tile[x, y - 1].active())
70855 {
70856 switch (Main.tile[x, y - 1].type)
70857 {
70858 case 21:
70859 case 26:
70860 case 77:
70861 case 88:
70862 case 235:
70863 case 237:
70864 case 441:
70865 case 467:
70866 case 468:
70867 case 470:
70868 case 475:
70869 case 488:
70870 case 597:
70871 return false;
70872 }
70873 }
70874 return CanKillTile(x, y);
70875 }
70876 }
70877
70878 public static bool SlopeTile(int i, int j, int slope = 0, bool noEffects = false)
70879 {
70880 if (!CanPoundTile(i, j))
70881 {
70882 return false;
70883 }
70884 Main.tile[i, j].halfBrick(halfBrick: false);
70885 Main.tile[i, j].slope((byte)slope);
70886 if (!gen)
70887 {
70888 if (!noEffects)
70889 {
70890 KillTile(i, j, fail: true, effectOnly: true);
70891 }
70892 SoundEngine.PlaySound(0, i * 16, j * 16);
70893 SquareTileFrame(i, j);
70894 if (Main.tile[i, j].slope() == 0)
70895 {
70896 Rectangle rectangle = new Rectangle(i * 16, j * 16, 16, 16);
70897 for (int k = 0; k < 255; k++)
70898 {
70899 if (Main.player[k].active && !Main.player[k].dead && rectangle.Intersects(new Rectangle((int)Main.player[k].position.X, (int)Main.player[k].position.Y, Main.player[k].width, Main.player[k].height)))
70900 {
70901 Main.player[k].gfxOffY += Main.player[k].position.Y + (float)Main.player[k].height - (float)rectangle.Y;
70902 Main.player[k].position.Y = rectangle.Y - Main.player[k].height;
70903 }
70904 }
70905 }
70906 }
70907 return true;
70908 }
70909
70910 public static bool PoundTile(int i, int j)
70911 {
70912 if (!CanPoundTile(i, j))
70913 {
70914 return false;
70915 }
70916 if (!Main.tile[i, j].halfBrick())
70917 {
70918 Main.tile[i, j].halfBrick(halfBrick: true);
70919 }
70920 else
70921 {
70922 Main.tile[i, j].halfBrick(halfBrick: false);
70923 }
70924 if (!gen)
70925 {
70926 KillTile(i, j, fail: true, effectOnly: true);
70927 SoundEngine.PlaySound(0, i * 16, j * 16);
70928 SquareTileFrame(i, j);
70929 if (!Main.tile[i, j].halfBrick())
70930 {
70931 Rectangle rectangle = new Rectangle(i * 16, j * 16, 16, 16);
70932 for (int k = 0; k < 255; k++)
70933 {
70934 if (Main.player[k].active && !Main.player[k].dead && rectangle.Intersects(new Rectangle((int)Main.player[k].position.X, (int)Main.player[k].position.Y, Main.player[k].width, Main.player[k].height)))
70935 {
70936 Main.player[k].gfxOffY += Main.player[k].position.Y + (float)Main.player[k].height - (float)rectangle.Y;
70937 Main.player[k].position.Y = rectangle.Y - Main.player[k].height;
70938 }
70939 }
70940 }
70941 }
70942 return true;
70943 }
70944
70945 public static void PoundPlatform(int x, int y)
70946 {
70947 if (Main.tile[x, y].halfBrick())
70948 {
70949 PoundTile(x, y);
70950 if (Main.netMode == 1)
70951 {
70952 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
70953 }
70954 return;
70955 }
70956 int num = 1;
70957 int slope = 2;
70958 if (TileID.Sets.Platforms[Main.tile[x + 1, y - 1].type] || TileID.Sets.Platforms[Main.tile[x - 1, y + 1].type] || (SolidTile(x + 1, y) && !SolidTile(x - 1, y)))
70959 {
70960 num = 2;
70961 slope = 1;
70962 }
70963 if (Main.tile[x, y].slope() == 0)
70964 {
70965 SlopeTile(x, y, num);
70966 int num2 = Main.tile[x, y].slope();
70967 if (Main.netMode == 1)
70968 {
70969 NetMessage.SendData(17, -1, -1, null, 14, x, y, num2);
70970 }
70971 return;
70972 }
70973 if (Main.tile[x, y].slope() == num)
70974 {
70975 SlopeTile(x, y, slope);
70976 int num3 = Main.tile[x, y].slope();
70977 if (Main.netMode == 1)
70978 {
70979 NetMessage.SendData(17, -1, -1, null, 14, x, y, num3);
70980 }
70981 return;
70982 }
70983 SlopeTile(x, y);
70984 int num4 = Main.tile[x, y].slope();
70985 if (Main.netMode == 1)
70986 {
70987 NetMessage.SendData(17, -1, -1, null, 14, x, y, num4);
70988 }
70989 PoundTile(x, y);
70990 if (Main.netMode == 1)
70991 {
70992 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
70993 }
70994 }
70995
70996 public static int PlatformProperSides(int x, int y, bool acceptNonOpposing = false)
70997 {
70998 Tile tile = Main.tile[x, y];
70999 if (!tile.active() || !TileID.Sets.Platforms[tile.type])
71000 {
71001 return 0;
71002 }
71003 int num = tile.slope();
71004 int num2 = -1;
71005 if (num == 1)
71006 {
71007 num2 = 2;
71008 }
71009 if (num == 2)
71010 {
71011 num2 = 1;
71012 }
71013 int num3 = 0;
71014 int num4 = 1;
71015 int num5 = 0;
71016 if (num == 1)
71017 {
71018 num5 = 1;
71019 }
71020 if (num == 2)
71021 {
71022 num5 = -1;
71023 }
71025 {
71026 if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[Main.tile[x + num4, y + num5].type] && Main.tile[x + num4, y + num5].slope() != num2)
71027 {
71028 num3++;
71029 }
71030 }
71031 else if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[Main.tile[x + num4, y + num5].type] && Main.tile[x + num4, y + num5].slope() == num)
71032 {
71033 num3++;
71034 }
71035 num4 *= -1;
71036 num5 *= -1;
71038 {
71039 if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[Main.tile[x + num4, y + num5].type] && Main.tile[x + num4, y + num5].slope() != num2)
71040 {
71041 num3++;
71042 }
71043 }
71044 else if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[Main.tile[x + num4, y + num5].type] && Main.tile[x + num4, y + num5].slope() == num)
71045 {
71046 num3++;
71047 }
71048 return num3;
71049 }
71050
71051 public static bool UpdateMapTile(int i, int j, bool addToList = true)
71052 {
71053 bool result = false;
71054 if (!Main.dedServ && Main.mapEnabled && !noMapUpdate && !gen && !Main.refreshMap && Main.Map[i, j].Light > 0 && Main.Map.UpdateType(i, j) && addToList)
71055 {
71056 result = true;
71058 {
71062 }
71063 else
71064 {
71065 Main.refreshMap = true;
71066 }
71067 }
71068 return result;
71069 }
71070
71071 public static void TileMergeAttemptFrametest(int i, int j, int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71072 {
71073 if (up == lookfor)
71074 {
71075 TileFrame(i, j - 1);
71076 if (mergeDown)
71077 {
71078 up = myType;
71079 }
71080 }
71081 if (down == lookfor)
71082 {
71083 TileFrame(i, j + 1);
71084 if (mergeUp)
71085 {
71086 down = myType;
71087 }
71088 }
71089 if (left == lookfor)
71090 {
71091 TileFrame(i - 1, j);
71092 if (mergeRight)
71093 {
71094 left = myType;
71095 }
71096 }
71097 if (right == lookfor)
71098 {
71099 TileFrame(i + 1, j);
71100 if (mergeLeft)
71101 {
71102 right = myType;
71103 }
71104 }
71105 if (upLeft == lookfor)
71106 {
71107 upLeft = myType;
71108 }
71109 if (upRight == lookfor)
71110 {
71111 upRight = myType;
71112 }
71113 if (downLeft == lookfor)
71114 {
71115 downLeft = myType;
71116 }
71117 if (downRight == lookfor)
71118 {
71119 downRight = myType;
71120 }
71121 }
71122
71123 public static void TileMergeAttemptFrametest(int i, int j, int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71124 {
71125 if (up > -1 && lookfor[up])
71126 {
71127 TileFrame(i, j - 1);
71128 if (mergeDown)
71129 {
71130 up = myType;
71131 }
71132 }
71133 if (down > -1 && lookfor[down])
71134 {
71135 TileFrame(i, j + 1);
71136 if (mergeUp)
71137 {
71138 down = myType;
71139 }
71140 }
71141 if (left > -1 && lookfor[left])
71142 {
71143 TileFrame(i - 1, j);
71144 if (mergeRight)
71145 {
71146 left = myType;
71147 }
71148 }
71149 if (right > -1 && lookfor[right])
71150 {
71151 TileFrame(i + 1, j);
71152 if (mergeLeft)
71153 {
71154 right = myType;
71155 }
71156 }
71157 if (upLeft > -1 && lookfor[upLeft])
71158 {
71159 upLeft = myType;
71160 }
71161 if (upRight > -1 && lookfor[upRight])
71162 {
71163 upRight = myType;
71164 }
71165 if (downLeft > -1 && lookfor[downLeft])
71166 {
71167 downLeft = myType;
71168 }
71169 if (downRight > -1 && lookfor[downRight])
71170 {
71171 downRight = myType;
71172 }
71173 }
71174
71175 public static void TileMergeAttempt(int myType, int lookfor, ref int up, ref int down, ref int left, ref int right)
71176 {
71177 if (lookfor == up)
71178 {
71179 up = myType;
71180 }
71181 if (lookfor == down)
71182 {
71183 down = myType;
71184 }
71185 if (lookfor == left)
71186 {
71187 left = myType;
71188 }
71189 if (lookfor == right)
71190 {
71191 right = myType;
71192 }
71193 }
71194
71195 public static void TileMergeAttempt(int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right)
71196 {
71197 if (up > -1 && lookfor[up])
71198 {
71199 up = myType;
71200 }
71201 if (down > -1 && lookfor[down])
71202 {
71203 down = myType;
71204 }
71205 if (left > -1 && lookfor[left])
71206 {
71207 left = myType;
71208 }
71209 if (right > -1 && lookfor[right])
71210 {
71211 right = myType;
71212 }
71213 }
71214
71215 public static void TileMergeAttempt(int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71216 {
71217 if (lookfor == up)
71218 {
71219 up = myType;
71220 }
71221 if (lookfor == down)
71222 {
71223 down = myType;
71224 }
71225 if (lookfor == left)
71226 {
71227 left = myType;
71228 }
71229 if (lookfor == right)
71230 {
71231 right = myType;
71232 }
71233 if (lookfor == upLeft)
71234 {
71235 upLeft = myType;
71236 }
71237 if (lookfor == upRight)
71238 {
71239 upRight = myType;
71240 }
71241 if (lookfor == downLeft)
71242 {
71243 downLeft = myType;
71244 }
71245 if (lookfor == downRight)
71246 {
71247 downRight = myType;
71248 }
71249 }
71250
71251 public static void TileMergeAttempt(int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71252 {
71253 if (up > -1 && lookfor[up])
71254 {
71255 up = myType;
71256 }
71257 if (down > -1 && lookfor[down])
71258 {
71259 down = myType;
71260 }
71261 if (left > -1 && lookfor[left])
71262 {
71263 left = myType;
71264 }
71265 if (right > -1 && lookfor[right])
71266 {
71267 right = myType;
71268 }
71269 if (upLeft > -1 && lookfor[upLeft])
71270 {
71271 upLeft = myType;
71272 }
71273 if (upRight > -1 && lookfor[upRight])
71274 {
71275 upRight = myType;
71276 }
71277 if (downLeft > -1 && lookfor[downLeft])
71278 {
71279 downLeft = myType;
71280 }
71281 if (downRight > -1 && lookfor[downRight])
71282 {
71283 downRight = myType;
71284 }
71285 }
71286
71287 public static void TileMergeAttempt(int myType, bool[] lookfor, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71288 {
71289 if (up > -1 && !exclude[up] && lookfor[up])
71290 {
71291 up = myType;
71292 }
71293 if (down > -1 && !exclude[down] && lookfor[down])
71294 {
71295 down = myType;
71296 }
71297 if (left > -1 && !exclude[left] && lookfor[left])
71298 {
71299 left = myType;
71300 }
71301 if (right > -1 && !exclude[right] && lookfor[right])
71302 {
71303 right = myType;
71304 }
71305 if (upLeft > -1 && !exclude[upLeft] && lookfor[upLeft])
71306 {
71307 upLeft = myType;
71308 }
71309 if (upRight > -1 && !exclude[upRight] && lookfor[upRight])
71310 {
71311 upRight = myType;
71312 }
71313 if (downLeft > -1 && !exclude[downLeft] && lookfor[downLeft])
71314 {
71315 downLeft = myType;
71316 }
71317 if (downRight > -1 && !exclude[downRight] && lookfor[downRight])
71318 {
71319 downRight = myType;
71320 }
71321 }
71322
71323 public static void TileMergeAttemptWeird(int myType, int changeTo, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
71324 {
71325 if (up > -1 && !exclude[up] && up != myType)
71326 {
71327 up = changeTo;
71328 }
71329 if (down > -1 && !exclude[down] && down != myType)
71330 {
71331 down = changeTo;
71332 }
71333 if (left > -1 && !exclude[left] && left != myType)
71334 {
71335 left = changeTo;
71336 }
71337 if (right > -1 && !exclude[right] && right != myType)
71338 {
71339 right = changeTo;
71340 }
71341 if (upLeft > -1 && !exclude[upLeft] && upLeft != myType)
71342 {
71343 upLeft = changeTo;
71344 }
71345 if (upRight > -1 && !exclude[upRight] && upRight != myType)
71346 {
71347 upRight = changeTo;
71348 }
71349 if (downLeft > -1 && !exclude[downLeft] && downLeft != myType)
71350 {
71352 }
71353 if (downRight > -1 && !exclude[downRight] && downRight != myType)
71354 {
71356 }
71357 }
71358
71359 public static int GetTileMossColor(int tileType)
71360 {
71361 switch (tileType)
71362 {
71363 default:
71364 return -1;
71365 case 179:
71366 case 512:
71367 return 0;
71368 case 180:
71369 case 513:
71370 return 1;
71371 case 181:
71372 case 514:
71373 return 2;
71374 case 182:
71375 case 515:
71376 return 3;
71377 case 183:
71378 case 516:
71379 return 4;
71380 case 381:
71381 case 517:
71382 return 5;
71383 case 534:
71384 case 535:
71385 return 6;
71386 case 536:
71387 case 537:
71388 return 7;
71389 case 539:
71390 case 540:
71391 return 8;
71392 case 625:
71393 case 626:
71394 return 9;
71395 case 627:
71396 case 628:
71397 return 10;
71398 }
71399 }
71400
71401 public static void CheckFoodPlatter(int x, int y, int type)
71402 {
71403 if (Main.tile[x, y] == null || destroyObject || SolidTileAllowBottomSlope(x, y + 1))
71404 {
71405 return;
71406 }
71407 if (type == 520)
71408 {
71409 int num = TEFoodPlatter.Find(x, y);
71410 if (num != -1 && ((TEFoodPlatter)TileEntity.ByID[num]).item.stack > 0)
71411 {
71412 ((TEFoodPlatter)TileEntity.ByID[num]).DropItem();
71413 if (Main.netMode != 2)
71414 {
71415 Main.LocalPlayer.InterruptItemUsageIfOverTile(520);
71416 }
71417 }
71418 }
71419 destroyObject = true;
71420 if (Main.tile[x, y].type == type)
71421 {
71422 KillTile(x, y);
71423 }
71424 if (type == 520)
71425 {
71426 TEFoodPlatter.Kill(x, y);
71427 }
71428 destroyObject = false;
71429 }
71430
71431 public static void TileFrame(int i, int j, bool resetFrame = false, bool noBreak = false)
71432 {
71433 bool addToList = false;
71434 try
71435 {
71436 if (i > 5 && j > 5 && i < Main.maxTilesX - 5 && j < Main.maxTilesY - 5 && Main.tile[i, j] != null)
71437 {
71438 if (SkipFramingBecauseOfGen && !Main.tileFrameImportant[Main.tile[i, j].type])
71439 {
71440 return;
71441 }
71442 addToList = UpdateMapTile(i, j);
71443 Tile tile = Main.tile[i, j];
71444 if (!tile.active())
71445 {
71446 tile.halfBrick(halfBrick: false);
71448 tile.slope(0);
71449 }
71450 if (tile.liquid > 0 && Main.netMode != 1 && !noLiquidCheck)
71451 {
71452 Liquid.AddWater(i, j);
71453 }
71454 if (tile.active())
71455 {
71456 if (noBreak && Main.tileFrameImportant[tile.type] && tile.type != 4)
71457 {
71458 return;
71459 }
71460 int num = tile.type;
71461 if (Main.tileStone[num])
71462 {
71463 num = 1;
71464 }
71465 int frameX = tile.frameX;
71466 int frameY = tile.frameY;
71467 Rectangle rectangle = new Rectangle(-1, -1, 0, 0);
71468 if (Main.tileFrameImportant[tile.type])
71469 {
71470 switch (num)
71471 {
71472 case 518:
71473 CheckLilyPad(i, j);
71474 break;
71475 case 519:
71476 CheckCatTail(i, j);
71477 break;
71478 case 549:
71479 CheckUnderwaterPlant(549, i, j);
71480 break;
71481 case 571:
71482 CheckBamboo(i, j);
71483 break;
71484 case 4:
71485 CheckTorch(i, j);
71486 break;
71487 case 442:
71488 CheckProjectilePressurePad(i, j);
71489 break;
71490 case 136:
71491 {
71492 Tile tile2 = Main.tile[i, j - 1];
71493 Tile tile3 = Main.tile[i, j + 1];
71494 Tile tile4 = Main.tile[i - 1, j];
71495 Tile tile5 = Main.tile[i + 1, j];
71496 Tile tile6 = Main.tile[i - 1, j + 1];
71497 Tile tile7 = Main.tile[i + 1, j + 1];
71498 Tile tile8 = Main.tile[i - 1, j - 1];
71499 Tile tile9 = Main.tile[i + 1, j - 1];
71500 int num20 = -1;
71501 int num21 = -1;
71502 int num22 = -1;
71503 int tree = -1;
71504 int tree2 = -1;
71505 int tree3 = -1;
71506 int tree4 = -1;
71507 if (tile2 != null && tile2.nactive())
71508 {
71509 _ = tile2.type;
71510 }
71511 if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope())
71512 {
71513 num20 = tile3.type;
71514 }
71515 if (tile4 != null && tile4.nactive())
71516 {
71517 num21 = tile4.type;
71518 }
71519 if (tile5 != null && tile5.nactive())
71520 {
71521 num22 = tile5.type;
71522 }
71523 if (tile6 != null && tile6.nactive())
71524 {
71525 tree = tile6.type;
71526 }
71527 if (tile7 != null && tile7.nactive())
71528 {
71529 tree2 = tile7.type;
71530 }
71531 if (tile8 != null && tile8.nactive())
71532 {
71533 tree3 = tile8.type;
71534 }
71535 if (tile9 != null && tile9.nactive())
71536 {
71537 tree4 = tile9.type;
71538 }
71539 if (num20 >= 0 && Main.tileSolid[num20] && !Main.tileNoAttach[num20] && tile3 != null && !tile3.halfBrick() && (tile3.slope() == 0 || tile3.bottomSlope()))
71540 {
71541 tile.frameX = 0;
71542 }
71543 else if ((num21 >= 0 && Main.tileSolid[num21] && !Main.tileNoAttach[num21] && tile4 != null && (tile4.leftSlope() || tile4.slope() == 0) && !tile4.halfBrick()) || (num21 >= 0 && TileID.Sets.IsBeam[num21]) || (IsTreeType(num21) && IsTreeType(tree3) && IsTreeType(tree)))
71544 {
71545 tile.frameX = 18;
71546 }
71547 else if ((num22 >= 0 && Main.tileSolid[num22] && !Main.tileNoAttach[num22] && tile5 != null && (tile5.rightSlope() || tile5.slope() == 0) && !tile5.halfBrick()) || (num22 >= 0 && TileID.Sets.IsBeam[num22]) || (IsTreeType(num22) && IsTreeType(tree4) && IsTreeType(tree2)))
71548 {
71549 tile.frameX = 36;
71550 }
71551 else if (tile.wall > 0)
71552 {
71553 tile.frameX = 54;
71554 }
71555 else
71556 {
71557 KillTile(i, j);
71558 }
71559 break;
71560 }
71561 case 129:
71562 case 149:
71563 {
71564 Tile tile2 = Main.tile[i, j - 1];
71565 Tile tile3 = Main.tile[i, j + 1];
71566 Tile tile4 = Main.tile[i - 1, j];
71567 Tile tile5 = Main.tile[i + 1, j];
71568 int num23 = -1;
71569 int num24 = -1;
71570 int num25 = -1;
71571 int num26 = -1;
71572 if (tile2 != null && tile2.nactive() && !tile2.bottomSlope())
71573 {
71574 num24 = tile2.type;
71575 }
71576 if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope())
71577 {
71578 num23 = tile3.type;
71579 }
71580 if (tile4 != null && tile4.nactive() && !tile5.rightSlope())
71581 {
71582 num25 = tile4.type;
71583 }
71584 if (tile5 != null && tile5.nactive() && !tile5.leftSlope())
71585 {
71586 num26 = tile5.type;
71587 }
71588 if (num23 >= 0 && Main.tileSolid[num23] && !Main.tileSolidTop[num23])
71589 {
71590 tile.frameY = 0;
71591 }
71592 else if (num25 >= 0 && Main.tileSolid[num25] && !Main.tileSolidTop[num25])
71593 {
71594 tile.frameY = 54;
71595 }
71596 else if (num26 >= 0 && Main.tileSolid[num26] && !Main.tileSolidTop[num26])
71597 {
71598 tile.frameY = 36;
71599 }
71600 else if (num24 >= 0 && Main.tileSolid[num24] && !Main.tileSolidTop[num24])
71601 {
71602 tile.frameY = 18;
71603 }
71604 else
71605 {
71606 KillTile(i, j);
71607 }
71608 break;
71609 }
71610 default:
71611 if (num != 461)
71612 {
71613 switch (num)
71614 {
71615 case 178:
71616 {
71617 Tile tile2 = Main.tile[i, j - 1];
71618 Tile tile3 = Main.tile[i, j + 1];
71619 Tile tile4 = Main.tile[i - 1, j];
71620 Tile tile5 = Main.tile[i + 1, j];
71621 int num15 = -1;
71622 int num16 = -1;
71623 int num17 = -1;
71624 int num18 = -1;
71625 if (tile2 != null && tile2.nactive() && !tile2.bottomSlope())
71626 {
71627 num16 = tile2.type;
71628 }
71629 if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope())
71630 {
71631 num15 = tile3.type;
71632 }
71633 if (tile4 != null && tile4.nactive() && !tile4.halfBrick() && !tile4.rightSlope())
71634 {
71635 num17 = tile4.type;
71636 }
71637 if (tile5 != null && tile5.nactive() && !tile5.halfBrick() && !tile5.leftSlope())
71638 {
71639 num18 = tile5.type;
71640 }
71641 if (num17 == 10)
71642 {
71643 num17 = -1;
71644 }
71645 if (num18 == 10)
71646 {
71647 num18 = -1;
71648 }
71649 short num19 = (short)(genRand.Next(3) * 18);
71650 if (num15 >= 0 && Main.tileSolid[num15] && !Main.tileSolidTop[num15])
71651 {
71652 if (tile.frameY < 0 || tile.frameY > 36)
71653 {
71654 tile.frameY = num19;
71655 }
71656 }
71657 else if (num17 >= 0 && Main.tileSolid[num17] && !Main.tileSolidTop[num17])
71658 {
71659 if (tile.frameY < 108 || tile.frameY > 54)
71660 {
71661 tile.frameY = (short)(108 + num19);
71662 }
71663 }
71664 else if (num18 >= 0 && Main.tileSolid[num18] && !Main.tileSolidTop[num18])
71665 {
71666 if (tile.frameY < 162 || tile.frameY > 198)
71667 {
71668 tile.frameY = (short)(162 + num19);
71669 }
71670 }
71671 else if (num16 >= 0 && Main.tileSolid[num16] && !Main.tileSolidTop[num16])
71672 {
71673 if (tile.frameY < 54 || tile.frameY > 90)
71674 {
71675 tile.frameY = (short)(54 + num19);
71676 }
71677 }
71678 else
71679 {
71680 KillTile(i, j);
71681 }
71682 break;
71683 }
71684 case 184:
71685 {
71686 Tile tile2 = Main.tile[i, j - 1];
71687 Tile tile3 = Main.tile[i, j + 1];
71688 Tile tile4 = Main.tile[i - 1, j];
71689 Tile tile5 = Main.tile[i + 1, j];
71690 int num10 = -1;
71691 int num11 = -1;
71692 int num12 = -1;
71693 int num13 = -1;
71694 if (tile2 != null && tile2.active() && !tile2.bottomSlope())
71695 {
71696 num11 = tile2.type;
71697 }
71698 if (tile3 != null && tile3.active() && !tile3.halfBrick() && !tile3.topSlope())
71699 {
71700 num10 = tile3.type;
71701 }
71702 if (tile4 != null && tile4.active())
71703 {
71704 num12 = tile4.type;
71705 }
71706 if (tile5 != null && tile5.active())
71707 {
71708 num13 = tile5.type;
71709 }
71710 short num14 = (short)(genRand.Next(3) * 18);
71711 if (num10 >= 0 && GetTileMossColor(num10) != -1)
71712 {
71713 tile.frameX = (short)(22 * GetTileMossColor(num10));
71714 if (tile.frameY < 0 || tile.frameY > 36)
71715 {
71716 tile.frameY = num14;
71717 }
71718 }
71719 else if (num11 >= 0 && GetTileMossColor(num11) != -1)
71720 {
71721 tile.frameX = (short)(22 * GetTileMossColor(num11));
71722 if (tile.frameY < 54 || tile.frameY > 90)
71723 {
71724 tile.frameY = (short)(54 + num14);
71725 }
71726 }
71727 else if (num12 >= 0 && GetTileMossColor(num12) != -1)
71728 {
71729 tile.frameX = (short)(22 * GetTileMossColor(num12));
71730 if (tile.frameY < 108 || tile.frameY > 144)
71731 {
71732 tile.frameY = (short)(108 + num14);
71733 }
71734 }
71735 else if (num13 >= 0 && GetTileMossColor(num13) != -1)
71736 {
71737 tile.frameX = (short)(22 * GetTileMossColor(num13));
71738 if (tile.frameY < 162 || tile.frameY > 198)
71739 {
71740 tile.frameY = (short)(162 + num14);
71741 }
71742 }
71743 else
71744 {
71745 KillTile(i, j);
71746 }
71747 break;
71748 }
71749 case 529:
71750 {
71751 if (!SolidTileAllowBottomSlope(i, j + 1))
71752 {
71753 KillTile(i, j);
71754 break;
71755 }
71756 Tile tile3 = Main.tile[i, j + 1];
71757 _ = Main.tile[i, j].frameY / 34;
71758 if (tile3 == null || !tile3.active() || (tile3.type >= 0 && tile3.type < TileID.Count && !TileID.Sets.Conversion.Sand[tile3.type]))
71759 {
71760 KillTile(i, j);
71761 }
71762 break;
71763 }
71764 case 3:
71765 case 24:
71766 case 61:
71767 case 71:
71768 case 73:
71769 case 74:
71770 case 110:
71771 case 113:
71772 case 201:
71773 case 637:
71774 PlantCheck(i, j);
71775 break;
71776 case 227:
71777 CheckDye(i, j);
71778 break;
71779 case 579:
71780 CheckRockGolemHead(i, j);
71781 break;
71782 case 12:
71783 case 31:
71784 case 639:
71785 CheckOrb(i, j, num);
71786 break;
71787 case 165:
71788 CheckTight(i, j);
71789 break;
71790 case 324:
71791 if (!SolidTileAllowBottomSlope(i, j + 1))
71792 {
71793 KillTile(i, j);
71794 }
71795 break;
71796 case 235:
71797 Check3x1(i, j, num);
71798 break;
71799 case 185:
71800 CheckPile(i, j);
71801 break;
71802 default:
71803 if (num != 296 && num != 297 && num != 309 && num != 358 && num != 359 && num != 413 && num != 414 && num != 542 && num != 550 && num != 551 && num != 553 && num != 554 && num != 558 && num != 559 && num != 599 && num != 600 && num != 601 && num != 602 && num != 603 && num != 604 && num != 605 && num != 606 && num != 607 && num != 608 && num != 609 && num != 610 && num != 611 && num != 612 && num != 632 && num != 640 && num != 643 && num != 644 && num != 645)
71804 {
71805 if (num == 10)
71806 {
71807 CheckDoorClosed(i, j, tile, num);
71808 break;
71809 }
71810 if (num == 11)
71811 {
71812 CheckDoorOpen(i, j, tile);
71813 break;
71814 }
71815 if (num == 314)
71816 {
71817 Minecart.FrameTrack(i, j, pound: false);
71818 Tile tile2 = Main.tile[i, j - 1];
71819 Tile tile3 = Main.tile[i, j + 1];
71820 if (tile2 != null && tile2.type >= 0 && tile2.type < TileID.Count && Main.tileRope[tile2.type])
71821 {
71822 TileFrame(i, j - 1);
71823 }
71824 if (tile3 != null && tile3.type >= 0 && tile3.type < TileID.Count && Main.tileRope[tile3.type])
71825 {
71826 TileFrame(i, j + 1);
71827 }
71828 break;
71829 }
71830 if (num == 380)
71831 {
71832 Tile tile4 = Main.tile[i - 1, j];
71833 if (tile4 == null)
71834 {
71835 break;
71836 }
71837 Tile tile5 = Main.tile[i + 1, j];
71838 if (tile5 == null)
71839 {
71840 break;
71841 }
71842 Tile tile6 = Main.tile[i - 1, j + 1];
71843 if (tile6 == null)
71844 {
71845 break;
71846 }
71847 Tile tile7 = Main.tile[i + 1, j + 1];
71848 if (tile7 == null)
71849 {
71850 break;
71851 }
71852 Tile tile8 = Main.tile[i - 1, j - 1];
71853 if (tile8 == null)
71854 {
71855 break;
71856 }
71857 Tile tile9 = Main.tile[i + 1, j - 1];
71858 if (tile9 != null)
71859 {
71860 int num2 = -1;
71861 int num3 = -1;
71862 if (tile4 != null && tile4.active())
71863 {
71864 num3 = (Main.tileStone[tile4.type] ? 1 : tile4.type);
71865 }
71866 if (tile5 != null && tile5.active())
71867 {
71868 num2 = (Main.tileStone[tile5.type] ? 1 : tile5.type);
71869 }
71870 if (num2 >= 0 && !Main.tileSolid[num2])
71871 {
71872 num2 = -1;
71873 }
71874 if (num3 >= 0 && !Main.tileSolid[num3])
71875 {
71876 num3 = -1;
71877 }
71878 if (num3 == num && num2 == num)
71879 {
71880 rectangle.X = 18;
71881 }
71882 else if (num3 == num && num2 != num)
71883 {
71884 rectangle.X = 36;
71885 }
71886 else if (num3 != num && num2 == num)
71887 {
71888 rectangle.X = 0;
71889 }
71890 else
71891 {
71892 rectangle.X = 54;
71893 }
71894 tile.frameX = (short)rectangle.X;
71895 }
71896 break;
71897 }
71898 if (num >= 0 && TileID.Sets.Platforms[num])
71899 {
71900 Tile tile4 = Main.tile[i - 1, j];
71901 if (tile4 == null)
71902 {
71903 break;
71904 }
71905 Tile tile5 = Main.tile[i + 1, j];
71906 if (tile5 == null)
71907 {
71908 break;
71909 }
71910 Tile tile6 = Main.tile[i - 1, j + 1];
71911 if (tile6 == null)
71912 {
71913 break;
71914 }
71915 Tile tile7 = Main.tile[i + 1, j + 1];
71916 if (tile7 == null)
71917 {
71918 break;
71919 }
71920 Tile tile8 = Main.tile[i - 1, j - 1];
71921 if (tile8 == null)
71922 {
71923 break;
71924 }
71925 Tile tile9 = Main.tile[i + 1, j - 1];
71926 if (tile9 == null)
71927 {
71928 break;
71929 }
71930 int num4 = -1;
71931 int num5 = -1;
71932 if (tile4 != null && tile4.active())
71933 {
71934 num5 = (Main.tileStone[tile4.type] ? 1 : ((!TileID.Sets.Platforms[tile4.type]) ? tile4.type : num));
71935 }
71936 if (tile5 != null && tile5.active())
71937 {
71938 num4 = (Main.tileStone[tile5.type] ? 1 : ((!TileID.Sets.Platforms[tile5.type]) ? tile5.type : num));
71939 }
71940 if (num4 >= 0 && !Main.tileSolid[num4])
71941 {
71942 num4 = -1;
71943 }
71944 if (num5 >= 0 && !Main.tileSolid[num5])
71945 {
71946 num5 = -1;
71947 }
71948 if (num5 == num && tile4.halfBrick() != tile.halfBrick())
71949 {
71950 num5 = -1;
71951 }
71952 if (num4 == num && tile5.halfBrick() != tile.halfBrick())
71953 {
71954 num4 = -1;
71955 }
71956 if (num5 != -1 && num5 != num && tile.halfBrick())
71957 {
71958 num5 = -1;
71959 }
71960 if (num4 != -1 && num4 != num && tile.halfBrick())
71961 {
71962 num4 = -1;
71963 }
71964 if (num5 == -1 && tile8.active() && tile8.type == num && tile8.slope() == 1)
71965 {
71966 num5 = num;
71967 }
71968 if (num4 == -1 && tile9.active() && tile9.type == num && tile9.slope() == 2)
71969 {
71970 num4 = num;
71971 }
71972 if (num5 == num && tile4.slope() == 2 && num4 != num)
71973 {
71974 num4 = -1;
71975 }
71976 if (num4 == num && tile5.slope() == 1 && num5 != num)
71977 {
71978 num5 = -1;
71979 }
71980 if (tile.slope() == 1)
71981 {
71982 if (TileID.Sets.Platforms[tile5.type] && tile5.slope() == 0 && !tile5.halfBrick())
71983 {
71984 rectangle.X = 468;
71985 }
71986 else if (!tile7.active() && (!TileID.Sets.Platforms[tile7.type] || tile7.slope() == 2))
71987 {
71988 if (!tile4.active() && (!TileID.Sets.Platforms[tile8.type] || tile8.slope() != 1))
71989 {
71990 rectangle.X = 432;
71991 }
71992 else
71993 {
71994 rectangle.X = 360;
71995 }
71996 }
71997 else if (!tile4.active() && (!TileID.Sets.Platforms[tile8.type] || tile8.slope() != 1))
71998 {
71999 rectangle.X = 396;
72000 }
72001 else
72002 {
72003 rectangle.X = 180;
72004 }
72005 }
72006 else if (tile.slope() == 2)
72007 {
72008 if (TileID.Sets.Platforms[tile4.type] && tile4.slope() == 0 && !tile4.halfBrick())
72009 {
72010 rectangle.X = 450;
72011 }
72012 else if (!tile6.active() && (!TileID.Sets.Platforms[tile6.type] || tile6.slope() == 1))
72013 {
72014 if (!tile5.active() && (!TileID.Sets.Platforms[tile9.type] || tile9.slope() != 2))
72015 {
72016 rectangle.X = 414;
72017 }
72018 else
72019 {
72020 rectangle.X = 342;
72021 }
72022 }
72023 else if (!tile5.active() && (!TileID.Sets.Platforms[tile9.type] || tile9.slope() != 2))
72024 {
72025 rectangle.X = 378;
72026 }
72027 else
72028 {
72029 rectangle.X = 144;
72030 }
72031 }
72032 else if (num5 == num && num4 == num)
72033 {
72034 if (tile4.slope() == 2 && tile5.slope() == 1)
72035 {
72036 rectangle.X = 252;
72037 }
72038 else if (tile4.slope() == 2)
72039 {
72040 rectangle.X = 216;
72041 }
72042 else if (tile5.slope() == 1)
72043 {
72044 rectangle.X = 234;
72045 }
72046 else
72047 {
72048 rectangle.X = 0;
72049 }
72050 }
72051 else if (num5 == num && num4 == -1)
72052 {
72053 if (tile4.slope() == 2)
72054 {
72055 rectangle.X = 270;
72056 }
72057 else
72058 {
72059 rectangle.X = 18;
72060 }
72061 }
72062 else if (num5 == -1 && num4 == num)
72063 {
72064 if (tile5.slope() == 1)
72065 {
72066 rectangle.X = 288;
72067 }
72068 else
72069 {
72070 rectangle.X = 36;
72071 }
72072 }
72073 else if (num5 != num && num4 == num)
72074 {
72075 rectangle.X = 54;
72076 }
72077 else if (num5 == num && num4 != num)
72078 {
72079 rectangle.X = 72;
72080 }
72081 else if (num5 != num && num5 != -1 && num4 == -1)
72082 {
72083 rectangle.X = 108;
72084 }
72085 else if (num5 == -1 && num4 != num && num4 != -1)
72086 {
72087 rectangle.X = 126;
72088 }
72089 else
72090 {
72091 rectangle.X = 90;
72092 }
72093 tile.frameX = (short)rectangle.X;
72094 if (Main.tile[i, j - 1] != null && Main.tileRope[Main.tile[i, j - 1].type])
72095 {
72096 TileFrame(i, j - 1);
72097 }
72098 if (Main.tile[i, j + 1] != null && Main.tileRope[Main.tile[i, j + 1].type])
72099 {
72100 TileFrame(i, j + 1);
72101 }
72102 break;
72103 }
72104 switch (num)
72105 {
72106 case 233:
72107 case 236:
72108 case 238:
72109 CheckJunglePlant(i, j, num);
72110 break;
72111 case 530:
72112 CheckOasisPlant(i, j);
72113 break;
72114 case 240:
72115 case 440:
72116 Check3x3Wall(i, j);
72117 break;
72118 case 245:
72119 Check2x3Wall(i, j);
72120 break;
72121 case 246:
72122 Check3x2Wall(i, j);
72123 break;
72124 case 241:
72125 Check4x3Wall(i, j);
72126 break;
72127 case 242:
72128 Check6x4Wall(i, j);
72129 break;
72130 case 464:
72131 case 466:
72132 Check5x4(i, j, num);
72133 break;
72134 case 334:
72135 CheckWeaponsRack(i, j);
72136 break;
72137 case 471:
72139 break;
72140 case 34:
72141 case 454:
72142 CheckChand(i, j, num);
72143 break;
72144 case 547:
72145 case 623:
72146 Check2x5(i, j, num);
72147 break;
72148 case 548:
72149 case 614:
72150 Check3x6(i, j, num);
72151 break;
72152 case 613:
72153 Check3x5(i, j, num);
72154 break;
72155 default:
72156 if (num != 354 && num != 406 && num != 412 && num != 355 && num != 452 && num != 455 && num != 491 && num != 499 && num != 642)
72157 {
72158 switch (num)
72159 {
72160 case 15:
72161 case 20:
72162 case 216:
72163 case 338:
72164 case 390:
72165 case 493:
72166 case 497:
72167 case 590:
72168 case 595:
72169 case 615:
72170 Check1x2(i, j, (ushort)num);
72171 break;
72172 default:
72173 if (num < 391 || num > 394)
72174 {
72175 switch (num)
72176 {
72177 case 405:
72178 case 486:
72179 case 488:
72180 case 532:
72181 case 533:
72182 case 544:
72183 case 552:
72184 case 555:
72185 case 556:
72186 case 582:
72187 case 619:
72188 case 629:
72189 case 647:
72190 case 648:
72191 case 651:
72192 break;
72193 case 36:
72194 case 135:
72195 case 141:
72196 case 144:
72197 case 210:
72198 case 239:
72199 case 428:
72200 case 593:
72201 case 624:
72202 case 650:
72203 case 656:
72204 Check1x1(i, j, num);
72205 return;
72206 case 476:
72207 CheckGolf1x1(i, j, num);
72208 return;
72209 case 494:
72210 CheckGolf1x1(i, j, num);
72211 return;
72212 case 419:
72213 case 420:
72214 case 423:
72215 case 424:
72216 case 429:
72217 case 445:
72218 CheckLogicTiles(i, j, num);
72219 return;
72220 case 16:
72221 case 18:
72222 case 29:
72223 case 103:
72224 case 134:
72225 case 462:
72226 case 649:
72227 Check2x1(i, j, (ushort)num);
72228 return;
72229 case 13:
72230 case 33:
72231 case 49:
72232 case 50:
72233 case 78:
72234 case 174:
72235 case 372:
72236 case 646:
72237 CheckOnTable1x1(i, j, num);
72238 return;
72239 default:
72240 if (TileID.Sets.BasicChest[num])
72241 {
72242 CheckChest(i, j, num);
72243 return;
72244 }
72245 switch (num)
72246 {
72247 case 128:
72248 CheckMan(i, j);
72249 break;
72250 case 269:
72251 CheckWoman(i, j);
72252 break;
72253 case 470:
72255 break;
72256 case 475:
72258 break;
72259 case 597:
72261 break;
72262 case 27:
72263 CheckSunflower(i, j);
72264 break;
72265 case 28:
72266 case 653:
72267 CheckPot(i, j, num);
72268 break;
72269 case 171:
72270 CheckXmasTree(i, j);
72271 break;
72272 default:
72273 if (!TileID.Sets.BasicChestFake[num] && num != 457)
72274 {
72275 switch (num)
72276 {
72277 case 335:
72278 case 411:
72279 case 490:
72280 case 564:
72281 case 565:
72282 case 594:
72283 Check2x2(i, j, num);
72284 break;
72285 default:
72286 if (num < 316 || num > 318)
72287 {
72288 switch (num)
72289 {
72290 case 172:
72291 case 360:
72292 case 505:
72293 case 521:
72294 case 522:
72295 case 523:
72296 case 524:
72297 case 525:
72298 case 526:
72299 case 527:
72300 case 543:
72301 case 568:
72302 case 569:
72303 case 570:
72304 case 580:
72305 case 598:
72306 case 620:
72307 case 652:
72308 case 654:
72309 break;
72310 case 376:
72311 case 443:
72312 case 444:
72313 case 485:
72314 CheckSuper(i, j, num);
72315 return;
72316 case 91:
72317 CheckBanner(i, j, (byte)num);
72318 return;
72319 case 35:
72320 case 139:
72321 CheckMB(i, j, (byte)num);
72322 return;
72323 case 386:
72324 case 387:
72325 CheckTrapDoor(i, j, num);
72326 return;
72327 case 388:
72328 case 389:
72329 CheckTallGate(i, j, num);
72330 return;
72331 case 92:
72332 case 93:
72333 case 453:
72334 Check1xX(i, j, (short)num);
72335 return;
72336 case 104:
72337 case 105:
72338 case 207:
72339 case 320:
72340 case 337:
72341 case 349:
72342 case 356:
72343 case 378:
72344 case 410:
72345 case 456:
72346 case 465:
72347 case 480:
72348 case 489:
72349 case 506:
72350 case 509:
72351 case 531:
72352 case 545:
72353 case 560:
72354 case 591:
72355 case 592:
72356 case 657:
72357 case 658:
72358 case 663:
72359 Check2xX(i, j, (ushort)num);
72360 return;
72361 case 101:
72362 case 102:
72363 case 463:
72364 case 617:
72365 Check3x4(i, j, num);
72366 return;
72367 case 42:
72368 case 270:
72369 case 271:
72370 case 572:
72371 case 581:
72372 case 660:
72373 Check1x2Top(i, j, (ushort)num);
72374 return;
72375 case 55:
72376 case 85:
72377 case 395:
72378 case 425:
72379 case 510:
72380 case 511:
72381 case 573:
72382 CheckSign(i, j, (ushort)num);
72383 return;
72384 case 520:
72385 CheckFoodPlatter(i, j, (ushort)num);
72386 return;
72387 case 209:
72388 CheckCannon(i, j, num);
72389 return;
72390 case 79:
72391 case 90:
72392 case 487:
72393 Check4x2(i, j, num);
72394 return;
72395 case 94:
72396 case 95:
72397 case 97:
72398 case 98:
72399 case 99:
72400 case 100:
72401 case 125:
72402 case 126:
72403 case 173:
72404 case 282:
72405 case 287:
72406 case 319:
72407 case 621:
72408 case 622:
72409 Check2x2(i, j, num);
72410 return;
72411 case 96:
72412 Check2x2Style(i, j, num);
72413 return;
72414 case 81:
72415 {
72416 Tile tile2 = Main.tile[i, j - 1];
72417 Tile tile3 = Main.tile[i, j + 1];
72418 Tile tile4 = Main.tile[i - 1, j];
72419 Tile tile5 = Main.tile[i + 1, j];
72420 int num8 = -1;
72421 int num9 = -1;
72422 if (tile2 != null && tile2.active())
72423 {
72424 num9 = tile2.type;
72425 }
72426 if (tile3 != null && tile3.active())
72427 {
72428 num8 = tile3.type;
72429 }
72430 if (num9 != -1)
72431 {
72432 KillTile(i, j);
72433 }
72434 else if (num8 < 0 || !Main.tileSolid[num8] || (tile3 != null && (tile3.halfBrick() || tile3.topSlope())))
72435 {
72436 KillTile(i, j);
72437 }
72438 return;
72439 }
72440 default:
72441 if (Main.tileAlch[num])
72442 {
72443 CheckAlch(i, j);
72444 return;
72445 }
72446 switch (num)
72447 {
72448 case 72:
72449 {
72450 Tile tile2 = Main.tile[i, j - 1];
72451 Tile tile3 = Main.tile[i, j + 1];
72452 int num6 = -1;
72453 int num7 = -1;
72454 if (tile2 != null && tile2.active())
72455 {
72456 num7 = tile2.type;
72457 }
72458 if (tile3 != null && tile3.active())
72459 {
72460 num6 = tile3.type;
72461 }
72462 if (num6 != num && num6 != 70)
72463 {
72464 KillTile(i, j);
72465 }
72466 else if (num7 != num && tile.frameX == 0)
72467 {
72468 tile.frameNumber((byte)genRand.Next(3));
72469 if (tile.frameNumber() == 0)
72470 {
72471 tile.frameX = 18;
72472 tile.frameY = 0;
72473 }
72474 if (tile.frameNumber() == 1)
72475 {
72476 tile.frameX = 18;
72477 tile.frameY = 18;
72478 }
72479 if (tile.frameNumber() == 2)
72480 {
72481 tile.frameX = 18;
72482 tile.frameY = 36;
72483 }
72484 }
72485 break;
72486 }
72487 case 5:
72488 CheckTree(i, j);
72489 break;
72490 case 583:
72491 case 584:
72492 case 585:
72493 case 586:
72494 case 587:
72495 case 588:
72496 case 589:
72497 CheckTreeWithSettings(i, j, new CheckTreeSettings
72498 {
72499 IsGroundValid = GemTreeGroundTest
72500 });
72501 break;
72502 case 596:
72503 CheckTreeWithSettings(i, j, new CheckTreeSettings
72504 {
72505 IsGroundValid = VanityTreeGroundTest
72506 });
72507 break;
72508 case 616:
72509 CheckTreeWithSettings(i, j, new CheckTreeSettings
72510 {
72511 IsGroundValid = VanityTreeGroundTest
72512 });
72513 break;
72514 case 634:
72515 CheckTreeWithSettings(i, j, new CheckTreeSettings
72516 {
72517 IsGroundValid = AshTreeGroundTest
72518 });
72519 break;
72520 case 323:
72521 CheckPalmTree(i, j);
72522 break;
72523 case 567:
72524 CheckGnome(i, j);
72525 break;
72526 case 630:
72527 case 631:
72528 CheckStinkbugBlocker(i, j);
72529 break;
72530 }
72531 return;
72532 }
72533 }
72534 goto case 132;
72535 case 132:
72536 case 138:
72537 case 142:
72538 case 143:
72539 case 288:
72540 case 289:
72541 case 290:
72542 case 291:
72543 case 292:
72544 case 293:
72545 case 294:
72546 case 295:
72547 case 484:
72548 case 664:
72549 case 665:
72550 Check2x2(i, j, num);
72551 break;
72552 }
72553 break;
72554 }
72555 goto case 254;
72556 case 254:
72557 Check2x2Style(i, j, num);
72558 break;
72559 }
72560 return;
72561 }
72562 }
72563 goto case 14;
72564 case 14:
72565 case 17:
72566 case 26:
72567 case 77:
72568 case 86:
72569 case 87:
72570 case 88:
72571 case 89:
72572 case 114:
72573 case 133:
72574 case 186:
72575 case 187:
72576 case 215:
72577 case 217:
72578 case 218:
72579 case 237:
72580 case 244:
72581 case 285:
72582 case 286:
72583 case 298:
72584 case 299:
72585 case 310:
72586 case 339:
72587 case 361:
72588 case 362:
72589 case 363:
72590 case 364:
72591 case 377:
72592 case 469:
72593 case 538:
72594 Check3x2(i, j, (ushort)num);
72595 break;
72596 }
72597 break;
72598 }
72599 goto case 106;
72600 case 106:
72601 case 212:
72602 case 219:
72603 case 220:
72604 case 228:
72605 case 231:
72606 case 243:
72607 case 247:
72608 case 283:
72609 case 300:
72610 case 301:
72611 case 302:
72612 case 303:
72613 case 304:
72614 case 305:
72615 case 306:
72616 case 307:
72617 case 308:
72618 Check3x3(i, j, (ushort)num);
72619 break;
72620 }
72621 break;
72622 }
72623 goto case 275;
72624 case 275:
72625 case 276:
72626 case 277:
72627 case 278:
72628 case 279:
72629 case 280:
72630 case 281:
72631 Check6x3(i, j, num);
72632 break;
72633 }
72634 break;
72635 }
72636 goto case 373;
72637 case 373:
72638 case 374:
72639 case 375:
72640 {
72641 Tile tile2 = Main.tile[i, j - 1];
72642 if (tile2 == null || !tile2.active() || tile2.bottomSlope() || !Main.tileSolid[tile2.type] || Main.tileSolidTop[tile2.type])
72643 {
72644 KillTile(i, j);
72645 }
72646 break;
72647 }
72648 }
72649 return;
72650 }
72651 if (num < 255 || num > 268)
72652 {
72653 switch (num)
72654 {
72655 case 385:
72656 case 446:
72657 case 447:
72658 case 448:
72659 break;
72660 default:
72661 {
72662 Tile tile2 = Main.tile[i, j - 1];
72663 Tile tile3 = Main.tile[i, j + 1];
72664 Tile tile4 = Main.tile[i - 1, j];
72665 Tile tile5 = Main.tile[i + 1, j];
72666 Tile tile6 = Main.tile[i - 1, j + 1];
72667 Tile tile7 = Main.tile[i + 1, j + 1];
72668 Tile tile8 = Main.tile[i - 1, j - 1];
72669 Tile tile9 = Main.tile[i + 1, j - 1];
72670 int upLeft = -1;
72671 int up = -1;
72672 int upRight = -1;
72673 int left = -1;
72674 int right = -1;
72675 int downLeft = -1;
72676 int down = -1;
72677 int downRight = -1;
72678 if (tile4 != null && tile4.active())
72679 {
72680 left = (Main.tileStone[tile4.type] ? 1 : tile4.type);
72681 if (tile4.slope() == 1 || tile4.slope() == 3)
72682 {
72683 left = -1;
72684 }
72685 }
72686 if (tile5 != null && tile5.active())
72687 {
72688 right = (Main.tileStone[tile5.type] ? 1 : tile5.type);
72689 if (tile5.slope() == 2 || tile5.slope() == 4)
72690 {
72691 right = -1;
72692 }
72693 }
72694 if (tile2 != null && tile2.active())
72695 {
72696 up = (Main.tileStone[tile2.type] ? 1 : tile2.type);
72697 if (tile2.slope() == 3 || tile2.slope() == 4)
72698 {
72699 up = -1;
72700 }
72701 }
72702 if (tile3 != null && tile3.active())
72703 {
72704 down = (Main.tileStone[tile3.type] ? 1 : tile3.type);
72705 if (tile3.slope() == 1 || tile3.slope() == 2)
72706 {
72707 down = -1;
72708 }
72709 }
72710 if (tile8 != null && tile8.active())
72711 {
72712 upLeft = (Main.tileStone[tile8.type] ? 1 : tile8.type);
72713 }
72714 if (tile9 != null && tile9.active())
72715 {
72716 upRight = (Main.tileStone[tile9.type] ? 1 : tile9.type);
72717 }
72718 if (tile6 != null && tile6.active())
72719 {
72720 downLeft = (Main.tileStone[tile6.type] ? 1 : tile6.type);
72721 }
72722 if (tile7 != null && tile7.active())
72723 {
72724 downRight = (Main.tileStone[tile7.type] ? 1 : tile7.type);
72725 }
72726 if (tile.slope() == 2)
72727 {
72728 up = -1;
72729 left = -1;
72730 }
72731 if (tile.slope() == 1)
72732 {
72733 up = -1;
72734 right = -1;
72735 }
72736 if (tile.slope() == 4)
72737 {
72738 down = -1;
72739 left = -1;
72740 }
72741 if (tile.slope() == 3)
72742 {
72743 down = -1;
72744 right = -1;
72745 }
72746 if (num == 668)
72747 {
72748 num = 0;
72749 }
72750 TileMergeAttempt(0, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72751 switch (num)
72752 {
72753 case 147:
72754 TileMergeAttempt(num, Main.tileBrick, TileID.Sets.Ices, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72755 break;
72756 case 161:
72757 case 163:
72758 case 164:
72759 case 200:
72760 TileMergeAttempt(num, Main.tileBrick, TileID.Sets.Snow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72761 break;
72762 case 162:
72763 TileMergeAttempt(num, Main.tileBrick, TileID.Sets.IcesSnow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72764 break;
72765 default:
72766 if (Main.tileBrick[num])
72767 {
72768 switch (num)
72769 {
72770 case 60:
72771 case 70:
72772 case 661:
72773 case 662:
72774 TileMergeAttempt(num, Main.tileBrick, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72775 break;
72776 case 633:
72777 TileMergeAttempt(num, Main.tileBrick, TileID.Sets.Ash, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72778 break;
72779 default:
72780 TileMergeAttempt(num, Main.tileBrick, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72781 break;
72782 }
72783 }
72784 else if (Main.tilePile[num])
72785 {
72786 TileMergeAttempt(num, Main.tilePile, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72787 }
72788 break;
72789 }
72790 if ((num == 1 || Main.tileMoss[num] || num == 117 || num == 25 || num == 203) && down == 165)
72791 {
72792 if (tile3 != null && tile3.frameY == 72)
72793 {
72794 down = num;
72795 }
72796 else if (tile3 != null && tile3.frameY == 0)
72797 {
72798 down = num;
72799 }
72800 }
72801 if ((num == 1 || Main.tileMoss[num] || num == 117 || num == 25 || num == 203) && up == 165)
72802 {
72803 if (tile2 != null && tile2.frameY == 90)
72804 {
72805 up = num;
72806 }
72807 else if (tile2 != null && tile2.frameY == 54)
72808 {
72809 up = num;
72810 }
72811 }
72812 if (num == 225)
72813 {
72814 if (down == 165)
72815 {
72816 down = num;
72817 }
72818 if (up == 165)
72819 {
72820 up = num;
72821 }
72822 }
72823 if ((num == 200 || num == 161 || num == 147 || num == 163 || num == 164) && down == 165)
72824 {
72825 down = num;
72826 }
72827 if ((tile.slope() == 1 || tile.slope() == 2) && down > -1 && !TileID.Sets.Platforms[down])
72828 {
72829 down = num;
72830 }
72831 if (up > -1 && tile2 != null && (tile2.slope() == 1 || tile2.slope() == 2) && !TileID.Sets.Platforms[up])
72832 {
72833 up = num;
72834 }
72835 if ((tile.slope() == 3 || tile.slope() == 4) && up > -1 && !TileID.Sets.Platforms[up])
72836 {
72837 up = num;
72838 }
72839 if (down > -1 && tile3 != null && (tile3.slope() == 3 || tile3.slope() == 4) && !TileID.Sets.Platforms[down])
72840 {
72841 down = num;
72842 }
72843 if (num == 124)
72844 {
72845 if (up > -1 && Main.tileSolid[up] && !TileID.Sets.Platforms[up])
72846 {
72847 up = num;
72848 }
72849 if (down > -1 && Main.tileSolid[down] && !TileID.Sets.Platforms[down])
72850 {
72851 down = num;
72852 }
72853 }
72854 if (up > -1 && tile2 != null && tile2.halfBrick() && !TileID.Sets.Platforms[up])
72855 {
72856 up = num;
72857 }
72858 if (left > -1 && tile4 != null && tile4.halfBrick())
72859 {
72860 if (tile.halfBrick())
72861 {
72862 left = num;
72863 }
72864 else if (tile4.type != num)
72865 {
72866 left = -1;
72867 }
72868 }
72869 if (right > -1 && tile5 != null && tile5.halfBrick())
72870 {
72871 if (tile.halfBrick())
72872 {
72873 right = num;
72874 }
72875 else if (tile5.type != num)
72876 {
72877 right = -1;
72878 }
72879 }
72880 if (tile.halfBrick())
72881 {
72882 if (left != num)
72883 {
72884 left = -1;
72885 }
72886 if (right != num)
72887 {
72888 right = -1;
72889 }
72890 up = -1;
72891 }
72892 if (tile3 != null && tile3.halfBrick())
72893 {
72894 down = -1;
72895 }
72896 if (!Main.tileSolid[num])
72897 {
72898 switch (num)
72899 {
72900 case 49:
72901 CheckOnTable1x1(i, j, (byte)num);
72902 return;
72903 case 80:
72904 CactusFrame(i, j);
72905 return;
72906 }
72907 }
72908 mergeUp = false;
72909 mergeDown = false;
72910 mergeLeft = false;
72911 mergeRight = false;
72912 int num27 = 0;
72913 if (resetFrame)
72914 {
72915 num27 = genRand.Next(0, 3);
72916 tile.frameNumber((byte)num27);
72917 }
72918 else
72919 {
72920 num27 = tile.frameNumber();
72921 }
72922 if (Main.tileLargeFrames[num] == 1)
72923 {
72924 int num28 = j % 4;
72925 int num29 = i % 3;
72926 num27 = (new int[4, 3]
72927 {
72928 { 2, 4, 2 },
72929 { 1, 3, 1 },
72930 { 2, 2, 4 },
72931 { 1, 1, 3 }
72932 })[num28, num29] - 1;
72933 }
72934 if (Main.tileLargeFrames[num] == 2)
72935 {
72936 int num30 = i % 2;
72937 int num31 = j % 2;
72938 num27 = num30 + num31 * 2;
72939 }
72941 {
72942 TileMergeAttempt(num, Main.tileBlendAll, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72943 }
72944 if (Main.tileBlendAll[num])
72945 {
72946 TileMergeAttempt(num, TileID.Sets.BlockMergesWithMergeAllBlock, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72947 }
72948 if (TileID.Sets.ForcedDirtMerging[num])
72949 {
72950 TileMergeAttempt(num, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
72951 }
72952 if (TileID.Sets.Dirt[num])
72953 {
72954 if (up > -1 && Main.tileMergeDirt[up])
72955 {
72956 TileFrame(i, j - 1);
72957 if (mergeDown)
72958 {
72959 up = num;
72960 }
72961 }
72962 else if (up == 147)
72963 {
72964 TileFrame(i, j - 1);
72965 if (mergeDown)
72966 {
72967 up = num;
72968 }
72969 }
72970 if (down > -1 && Main.tileMergeDirt[down])
72971 {
72972 TileFrame(i, j + 1);
72973 if (mergeUp)
72974 {
72975 down = num;
72976 }
72977 }
72978 else if (down == 147)
72979 {
72980 TileFrame(i, j + 1);
72981 if (mergeUp)
72982 {
72983 down = num;
72984 }
72985 }
72986 if (left > -1 && Main.tileMergeDirt[left])
72987 {
72988 TileFrame(i - 1, j);
72989 if (mergeRight)
72990 {
72991 left = num;
72992 }
72993 }
72994 else if (left == 147)
72995 {
72996 TileFrame(i - 1, j);
72997 if (mergeRight)
72998 {
72999 left = num;
73000 }
73001 }
73002 if (right > -1 && Main.tileMergeDirt[right])
73003 {
73004 TileFrame(i + 1, j);
73005 if (mergeLeft)
73006 {
73007 right = num;
73008 }
73009 }
73010 else if (right == 147)
73011 {
73012 TileFrame(i + 1, j);
73013 if (mergeLeft)
73014 {
73015 right = num;
73016 }
73017 }
73019 if (up > -1 && mergesWithDirtInASpecialWay[up])
73020 {
73021 up = num;
73022 }
73023 if (down > -1 && mergesWithDirtInASpecialWay[down])
73024 {
73025 down = num;
73026 }
73027 if (left > -1 && mergesWithDirtInASpecialWay[left])
73028 {
73029 left = num;
73030 }
73031 if (right > -1 && mergesWithDirtInASpecialWay[right])
73032 {
73033 right = num;
73034 }
73035 if (upLeft > -1 && Main.tileMergeDirt[upLeft])
73036 {
73037 upLeft = num;
73038 }
73039 else if (upLeft > -1 && mergesWithDirtInASpecialWay[upLeft])
73040 {
73041 upLeft = num;
73042 }
73043 if (upRight > -1 && Main.tileMergeDirt[upRight])
73044 {
73045 upRight = num;
73046 }
73048 {
73049 upRight = num;
73050 }
73051 if (downLeft > -1 && Main.tileMergeDirt[downLeft])
73052 {
73053 downLeft = num;
73054 }
73056 {
73057 downLeft = num;
73058 }
73060 {
73061 downRight = num;
73062 }
73064 {
73065 downRight = num;
73066 }
73067 TileMergeAttempt(0, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73068 TileMergeAttempt(-2, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73069 TileMergeAttempt(0, 191, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73070 if (up > -1 && TileID.Sets.ForcedDirtMerging[up])
73071 {
73072 up = num;
73073 }
73074 if (down > -1 && TileID.Sets.ForcedDirtMerging[down])
73075 {
73076 down = num;
73077 }
73078 if (left > -1 && TileID.Sets.ForcedDirtMerging[left])
73079 {
73080 left = num;
73081 }
73082 if (right > -1 && TileID.Sets.ForcedDirtMerging[right])
73083 {
73084 right = num;
73085 }
73087 {
73088 upLeft = num;
73089 }
73091 {
73092 upRight = num;
73093 }
73095 {
73096 downLeft = num;
73097 }
73099 {
73100 downRight = num;
73101 }
73102 }
73103 else if (Main.tileRope[num])
73104 {
73105 if (num != 504 && up != num && IsRope(i, j - 1))
73106 {
73107 up = num;
73108 }
73109 if (down != num && IsRope(i, j + 1))
73110 {
73111 down = num;
73112 }
73113 if (num != 504 && up > -1 && Main.tileSolid[up] && !Main.tileSolidTop[up])
73114 {
73115 up = num;
73116 }
73117 if (down > -1 && Main.tileSolid[down])
73118 {
73119 down = num;
73120 }
73121 if (num != 504 && up != num)
73122 {
73123 if (left > -1 && Main.tileSolid[left])
73124 {
73125 left = num;
73126 }
73127 if (right > -1 && Main.tileSolid[right])
73128 {
73129 right = num;
73130 }
73131 }
73132 }
73133 else
73134 {
73135 switch (num)
73136 {
73137 case 53:
73138 TileMergeAttemptFrametest(i, j, num, 397, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73139 TileMergeAttemptFrametest(i, j, num, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73140 break;
73141 case 234:
73142 TileMergeAttemptFrametest(i, j, num, 399, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73143 TileMergeAttemptFrametest(i, j, num, 401, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73144 break;
73145 case 112:
73146 TileMergeAttemptFrametest(i, j, num, 398, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73147 TileMergeAttemptFrametest(i, j, num, 400, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73148 break;
73149 case 116:
73150 TileMergeAttemptFrametest(i, j, num, 402, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73151 TileMergeAttemptFrametest(i, j, num, 403, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73152 break;
73153 }
73154 }
73155 if (Main.tileMergeDirt[num])
73156 {
73157 TileMergeAttempt(-2, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73158 if (num == 1)
73159 {
73160 if ((double)j > Main.rockLayer)
73161 {
73162 TileMergeAttemptFrametest(i, j, num, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73163 }
73164 TileMergeAttemptFrametest(i, j, num, TileID.Sets.Ash, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73165 }
73166 }
73167 else
73168 {
73169 switch (num)
73170 {
73171 case 58:
73172 case 75:
73173 case 76:
73174 TileMergeAttempt(-2, TileID.Sets.Ash, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73175 break;
73176 case 57:
73177 TileMergeAttempt(-2, 1, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73178 TileMergeAttempt(num, 633, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73179 TileMergeAttemptFrametest(i, j, num, TileID.Sets.HellSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73180 break;
73181 case 59:
73182 if ((double)j > Main.rockLayer)
73183 {
73184 TileMergeAttempt(-2, 1, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73185 }
73186 TileMergeAttempt(num, TileID.Sets.GrassSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73187 TileMergeAttemptFrametest(i, j, num, TileID.Sets.JungleSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73188 if ((double)j < Main.rockLayer)
73189 {
73190 TileMergeAttemptFrametest(i, j, num, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73191 }
73192 else
73193 {
73194 TileMergeAttempt(num, TileID.Sets.Dirt, ref up, ref down, ref left, ref right);
73195 }
73196 break;
73197 case 211:
73198 TileMergeAttempt(59, 60, ref up, ref down, ref left, ref right);
73199 TileMergeAttempt(-2, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73200 break;
73201 case 225:
73202 case 226:
73203 TileMergeAttempt(-2, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73204 break;
73205 case 60:
73206 TileMergeAttempt(59, 211, ref up, ref down, ref left, ref right);
73207 break;
73208 case 189:
73209 TileMergeAttemptFrametest(i, j, num, TileID.Sets.MergesWithClouds, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73210 break;
73211 case 196:
73212 TileMergeAttempt(-2, 189, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73213 TileMergeAttempt(num, 460, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73214 break;
73215 case 460:
73216 TileMergeAttempt(-2, 189, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73217 TileMergeAttempt(num, 196, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73218 break;
73219 case 147:
73220 TileMergeAttemptFrametest(i, j, num, TileID.Sets.IcesSlush, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73221 break;
73222 case 161:
73223 case 163:
73224 case 164:
73225 case 200:
73226 case 224:
73227 TileMergeAttempt(-2, 147, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73228 break;
73229 case 162:
73230 TileMergeAttempt(-2, TileID.Sets.IcesSnow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73231 break;
73232 case 32:
73233 if (down == 23)
73234 {
73235 down = num;
73236 }
73237 break;
73238 case 352:
73239 if (down == 199)
73240 {
73241 down = num;
73242 }
73243 break;
73244 case 69:
73245 if (down == 60)
73246 {
73247 down = num;
73248 }
73249 break;
73250 case 655:
73251 if (down == 60)
73252 {
73253 down = num;
73254 }
73255 break;
73256 case 51:
73257 TileMergeAttempt(num, TileID.Sets.AllTiles, Main.tileNoAttach, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73258 break;
73259 case 192:
73260 TileMergeAttemptFrametest(i, j, num, 191, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73261 break;
73262 case 191:
73263 TileMergeAttempt(-2, 192, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73264 TileMergeAttempt(num, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73265 break;
73266 case 384:
73267 TileMergeAttemptFrametest(i, j, num, 383, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73268 break;
73269 case 383:
73270 TileMergeAttempt(-2, 384, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73271 TileMergeAttempt(num, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73272 break;
73273 case 407:
73274 TileMergeAttempt(-2, 404, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73275 break;
73276 case 404:
73277 TileMergeAttempt(-2, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73278 TileMergeAttemptFrametest(i, j, num, 407, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73279 break;
73280 case 397:
73281 TileMergeAttempt(-2, 53, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73282 TileMergeAttemptFrametest(i, j, num, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73283 break;
73284 case 396:
73285 TileMergeAttempt(-2, 397, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73286 TileMergeAttempt(-2, 53, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73287 TileMergeAttemptFrametest(i, j, num, 404, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73288 break;
73289 case 398:
73290 TileMergeAttempt(-2, 112, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73291 TileMergeAttemptFrametest(i, j, num, 400, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73292 break;
73293 case 400:
73294 TileMergeAttempt(-2, 398, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73295 TileMergeAttempt(-2, 112, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73296 break;
73297 case 399:
73298 TileMergeAttempt(-2, 234, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73299 TileMergeAttemptFrametest(i, j, num, 401, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73300 break;
73301 case 401:
73302 TileMergeAttempt(-2, 399, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73303 TileMergeAttempt(-2, 234, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73304 break;
73305 case 402:
73306 TileMergeAttempt(-2, 116, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73307 TileMergeAttemptFrametest(i, j, num, 403, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73308 break;
73309 case 403:
73310 TileMergeAttempt(-2, 402, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73311 TileMergeAttempt(-2, 116, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73312 break;
73313 }
73314 }
73315 if (num == 0)
73316 {
73317 TileMergeAttempt(num, Main.tileMoss, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73318 TileMergeAttempt(num, TileID.Sets.tileMossBrick, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73319 }
73320 else if (Main.tileMoss[num] || TileID.Sets.tileMossBrick[num])
73321 {
73322 TileMergeAttempt(num, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73323 }
73324 else if (Main.tileStone[num] || num == 1)
73325 {
73326 TileMergeAttempt(num, Main.tileMoss, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73327 }
73328 else if (num == 38)
73329 {
73330 TileMergeAttempt(num, TileID.Sets.tileMossBrick, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73331 }
73332 if (TileID.Sets.Conversion.Grass[num])
73333 {
73334 TileMergeAttempt(num, TileID.Sets.Ore, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73335 }
73336 else if (TileID.Sets.Ore[num])
73337 {
73338 TileMergeAttempt(num, TileID.Sets.Conversion.Grass, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73339 }
73340 if (num >= 0 && num < TileID.Count && TileID.Sets.Mud[num])
73341 {
73342 TileMergeAttempt(num, TileID.Sets.OreMergesWithMud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73343 }
73344 else if (TileID.Sets.OreMergesWithMud[num])
73345 {
73346 TileMergeAttempt(num, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73347 }
73348 bool flag = false;
73351 {
73352 bool flag2 = tile.invisibleBlock();
73353 tileMergeCullCache.CullTop |= tile2 != null && tile2.invisibleBlock() != flag2;
73354 tileMergeCullCache.CullBottom |= tile3 != null && tile3.invisibleBlock() != flag2;
73355 tileMergeCullCache.CullLeft |= tile4 != null && tile4.invisibleBlock() != flag2;
73356 tileMergeCullCache.CullRight |= tile5 != null && tile5.invisibleBlock() != flag2;
73357 tileMergeCullCache.CullTopLeft |= tile8 != null && tile8.invisibleBlock() != flag2;
73358 tileMergeCullCache.CullTopRight |= tile9 != null && tile9.invisibleBlock() != flag2;
73359 tileMergeCullCache.CullBottomLeft |= tile6 != null && tile6.invisibleBlock() != flag2;
73360 tileMergeCullCache.CullBottomRight |= tile7 != null && tile7.invisibleBlock() != flag2;
73361 }
73362 if (num == 2 || num == 23 || num == 661 || num == 662 || num == 60 || num == 477 || num == 492 || num == 70 || num == 109 || num == 199 || Main.tileMoss[num] || TileID.Sets.NeedsGrassFraming[num] || TileID.Sets.tileMossBrick[num])
73363 {
73364 flag = true;
73365 TileMergeAttemptWeird(num, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73367 if (num == 60 || num == 70 || num == 661 || num == 662)
73368 {
73369 num32 = 59;
73370 }
73371 else if (Main.tileMoss[num])
73372 {
73373 num32 = 1;
73374 }
73375 else if (TileID.Sets.tileMossBrick[num])
73376 {
73377 num32 = 38;
73378 }
73379 else
73380 {
73381 switch (num)
73382 {
73383 case 2:
73384 case 477:
73385 TileMergeAttempt(num32, 23, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73386 break;
73387 case 23:
73388 TileMergeAttempt(num32, 2, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73389 break;
73390 }
73391 }
73392 tileMergeCullCache.Cull(ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
73393 if (up != num && up != num32 && (down == num || down == num32))
73394 {
73395 if (left == num32 && right == num)
73396 {
73397 switch (num27)
73398 {
73399 case 0:
73400 rectangle.X = 0;
73401 rectangle.Y = 198;
73402 break;
73403 case 1:
73404 rectangle.X = 18;
73405 rectangle.Y = 198;
73406 break;
73407 default:
73408 rectangle.X = 36;
73409 rectangle.Y = 198;
73410 break;
73411 }
73412 }
73413 else if (left == num && right == num32)
73414 {
73415 switch (num27)
73416 {
73417 case 0:
73418 rectangle.X = 54;
73419 rectangle.Y = 198;
73420 break;
73421 case 1:
73422 rectangle.X = 72;
73423 rectangle.Y = 198;
73424 break;
73425 default:
73426 rectangle.X = 90;
73427 rectangle.Y = 198;
73428 break;
73429 }
73430 }
73431 }
73432 else if (down != num && down != num32 && (up == num || up == num32))
73433 {
73434 if (left == num32 && right == num)
73435 {
73436 switch (num27)
73437 {
73438 case 0:
73439 rectangle.X = 0;
73440 rectangle.Y = 216;
73441 break;
73442 case 1:
73443 rectangle.X = 18;
73444 rectangle.Y = 216;
73445 break;
73446 default:
73447 rectangle.X = 36;
73448 rectangle.Y = 216;
73449 break;
73450 }
73451 }
73452 else if (left == num && right == num32)
73453 {
73454 switch (num27)
73455 {
73456 case 0:
73457 rectangle.X = 54;
73458 rectangle.Y = 216;
73459 break;
73460 case 1:
73461 rectangle.X = 72;
73462 rectangle.Y = 216;
73463 break;
73464 default:
73465 rectangle.X = 90;
73466 rectangle.Y = 216;
73467 break;
73468 }
73469 }
73470 }
73471 else if (left != num && left != num32 && (right == num || right == num32))
73472 {
73473 if (up == num32 && down == num)
73474 {
73475 switch (num27)
73476 {
73477 case 0:
73478 rectangle.X = 72;
73479 rectangle.Y = 144;
73480 break;
73481 case 1:
73482 rectangle.X = 72;
73483 rectangle.Y = 162;
73484 break;
73485 default:
73486 rectangle.X = 72;
73487 rectangle.Y = 180;
73488 break;
73489 }
73490 }
73491 else if (down == num && up == num32)
73492 {
73493 switch (num27)
73494 {
73495 case 0:
73496 rectangle.X = 72;
73497 rectangle.Y = 90;
73498 break;
73499 case 1:
73500 rectangle.X = 72;
73501 rectangle.Y = 108;
73502 break;
73503 default:
73504 rectangle.X = 72;
73505 rectangle.Y = 126;
73506 break;
73507 }
73508 }
73509 }
73510 else if (right != num && right != num32 && (left == num || left == num32))
73511 {
73512 if (up == num32 && down == num)
73513 {
73514 switch (num27)
73515 {
73516 case 0:
73517 rectangle.X = 90;
73518 rectangle.Y = 144;
73519 break;
73520 case 1:
73521 rectangle.X = 90;
73522 rectangle.Y = 162;
73523 break;
73524 default:
73525 rectangle.X = 90;
73526 rectangle.Y = 180;
73527 break;
73528 }
73529 }
73530 else if (down == num && right == up)
73531 {
73532 switch (num27)
73533 {
73534 case 0:
73535 rectangle.X = 90;
73536 rectangle.Y = 90;
73537 break;
73538 case 1:
73539 rectangle.X = 90;
73540 rectangle.Y = 108;
73541 break;
73542 default:
73543 rectangle.X = 90;
73544 rectangle.Y = 126;
73545 break;
73546 }
73547 }
73548 }
73549 else if (up == num && down == num && left == num && right == num)
73550 {
73551 if (upLeft != num && upRight != num && downLeft != num && downRight != num)
73552 {
73553 if (downRight == num32)
73554 {
73555 switch (num27)
73556 {
73557 case 0:
73558 rectangle.X = 108;
73559 rectangle.Y = 324;
73560 break;
73561 case 1:
73562 rectangle.X = 126;
73563 rectangle.Y = 324;
73564 break;
73565 default:
73566 rectangle.X = 144;
73567 rectangle.Y = 324;
73568 break;
73569 }
73570 }
73571 else if (upRight == num32)
73572 {
73573 switch (num27)
73574 {
73575 case 0:
73576 rectangle.X = 108;
73577 rectangle.Y = 342;
73578 break;
73579 case 1:
73580 rectangle.X = 126;
73581 rectangle.Y = 342;
73582 break;
73583 default:
73584 rectangle.X = 144;
73585 rectangle.Y = 342;
73586 break;
73587 }
73588 }
73589 else if (downLeft == num32)
73590 {
73591 switch (num27)
73592 {
73593 case 0:
73594 rectangle.X = 108;
73595 rectangle.Y = 360;
73596 break;
73597 case 1:
73598 rectangle.X = 126;
73599 rectangle.Y = 360;
73600 break;
73601 default:
73602 rectangle.X = 144;
73603 rectangle.Y = 360;
73604 break;
73605 }
73606 }
73607 else if (upLeft == num32)
73608 {
73609 switch (num27)
73610 {
73611 case 0:
73612 rectangle.X = 108;
73613 rectangle.Y = 378;
73614 break;
73615 case 1:
73616 rectangle.X = 126;
73617 rectangle.Y = 378;
73618 break;
73619 default:
73620 rectangle.X = 144;
73621 rectangle.Y = 378;
73622 break;
73623 }
73624 }
73625 else
73626 {
73627 switch (num27)
73628 {
73629 case 0:
73630 rectangle.X = 144;
73631 rectangle.Y = 234;
73632 break;
73633 case 1:
73634 rectangle.X = 198;
73635 rectangle.Y = 234;
73636 break;
73637 default:
73638 rectangle.X = 252;
73639 rectangle.Y = 234;
73640 break;
73641 }
73642 }
73643 }
73644 else if (upLeft != num && downRight != num)
73645 {
73646 switch (num27)
73647 {
73648 case 0:
73649 rectangle.X = 36;
73650 rectangle.Y = 306;
73651 break;
73652 case 1:
73653 rectangle.X = 54;
73654 rectangle.Y = 306;
73655 break;
73656 default:
73657 rectangle.X = 72;
73658 rectangle.Y = 306;
73659 break;
73660 }
73661 }
73662 else if (upRight != num && downLeft != num)
73663 {
73664 switch (num27)
73665 {
73666 case 0:
73667 rectangle.X = 90;
73668 rectangle.Y = 306;
73669 break;
73670 case 1:
73671 rectangle.X = 108;
73672 rectangle.Y = 306;
73673 break;
73674 default:
73675 rectangle.X = 126;
73676 rectangle.Y = 306;
73677 break;
73678 }
73679 }
73680 else if (upLeft != num && upRight == num && downLeft == num && downRight == num)
73681 {
73682 switch (num27)
73683 {
73684 case 0:
73685 rectangle.X = 54;
73686 rectangle.Y = 108;
73687 break;
73688 case 1:
73689 rectangle.X = 54;
73690 rectangle.Y = 144;
73691 break;
73692 default:
73693 rectangle.X = 54;
73694 rectangle.Y = 180;
73695 break;
73696 }
73697 }
73698 else if (upLeft == num && upRight != num && downLeft == num && downRight == num)
73699 {
73700 switch (num27)
73701 {
73702 case 0:
73703 rectangle.X = 36;
73704 rectangle.Y = 108;
73705 break;
73706 case 1:
73707 rectangle.X = 36;
73708 rectangle.Y = 144;
73709 break;
73710 default:
73711 rectangle.X = 36;
73712 rectangle.Y = 180;
73713 break;
73714 }
73715 }
73716 else if (upLeft == num && upRight == num && downLeft != num && downRight == num)
73717 {
73718 switch (num27)
73719 {
73720 case 0:
73721 rectangle.X = 54;
73722 rectangle.Y = 90;
73723 break;
73724 case 1:
73725 rectangle.X = 54;
73726 rectangle.Y = 126;
73727 break;
73728 default:
73729 rectangle.X = 54;
73730 rectangle.Y = 162;
73731 break;
73732 }
73733 }
73734 else if (upLeft == num && upRight == num && downLeft == num && downRight != num)
73735 {
73736 switch (num27)
73737 {
73738 case 0:
73739 rectangle.X = 36;
73740 rectangle.Y = 90;
73741 break;
73742 case 1:
73743 rectangle.X = 36;
73744 rectangle.Y = 126;
73745 break;
73746 default:
73747 rectangle.X = 36;
73748 rectangle.Y = 162;
73749 break;
73750 }
73751 }
73752 }
73753 else if (up == num && down == num32 && left == num && right == num && upLeft == -1 && upRight == -1)
73754 {
73755 switch (num27)
73756 {
73757 case 0:
73758 rectangle.X = 108;
73759 rectangle.Y = 18;
73760 break;
73761 case 1:
73762 rectangle.X = 126;
73763 rectangle.Y = 18;
73764 break;
73765 default:
73766 rectangle.X = 144;
73767 rectangle.Y = 18;
73768 break;
73769 }
73770 }
73771 else if (up == num32 && down == num && left == num && right == num && downLeft == -1 && downRight == -1)
73772 {
73773 switch (num27)
73774 {
73775 case 0:
73776 rectangle.X = 108;
73777 rectangle.Y = 36;
73778 break;
73779 case 1:
73780 rectangle.X = 126;
73781 rectangle.Y = 36;
73782 break;
73783 default:
73784 rectangle.X = 144;
73785 rectangle.Y = 36;
73786 break;
73787 }
73788 }
73789 else if (up == num && down == num && left == num32 && right == num && upRight == -1 && downRight == -1)
73790 {
73791 switch (num27)
73792 {
73793 case 0:
73794 rectangle.X = 198;
73795 rectangle.Y = 0;
73796 break;
73797 case 1:
73798 rectangle.X = 198;
73799 rectangle.Y = 18;
73800 break;
73801 default:
73802 rectangle.X = 198;
73803 rectangle.Y = 36;
73804 break;
73805 }
73806 }
73807 else if (up == num && down == num && left == num && right == num32 && upLeft == -1 && downLeft == -1)
73808 {
73809 switch (num27)
73810 {
73811 case 0:
73812 rectangle.X = 180;
73813 rectangle.Y = 0;
73814 break;
73815 case 1:
73816 rectangle.X = 180;
73817 rectangle.Y = 18;
73818 break;
73819 default:
73820 rectangle.X = 180;
73821 rectangle.Y = 36;
73822 break;
73823 }
73824 }
73825 else if (up == num && down == num32 && left == num && right == num)
73826 {
73827 if (upRight != -1)
73828 {
73829 switch (num27)
73830 {
73831 case 0:
73832 rectangle.X = 54;
73833 rectangle.Y = 108;
73834 break;
73835 case 1:
73836 rectangle.X = 54;
73837 rectangle.Y = 144;
73838 break;
73839 default:
73840 rectangle.X = 54;
73841 rectangle.Y = 180;
73842 break;
73843 }
73844 }
73845 else if (upLeft != -1)
73846 {
73847 switch (num27)
73848 {
73849 case 0:
73850 rectangle.X = 36;
73851 rectangle.Y = 108;
73852 break;
73853 case 1:
73854 rectangle.X = 36;
73855 rectangle.Y = 144;
73856 break;
73857 default:
73858 rectangle.X = 36;
73859 rectangle.Y = 180;
73860 break;
73861 }
73862 }
73863 }
73864 else if (up == num32 && down == num && left == num && right == num)
73865 {
73866 if (downRight != -1)
73867 {
73868 switch (num27)
73869 {
73870 case 0:
73871 rectangle.X = 54;
73872 rectangle.Y = 90;
73873 break;
73874 case 1:
73875 rectangle.X = 54;
73876 rectangle.Y = 126;
73877 break;
73878 default:
73879 rectangle.X = 54;
73880 rectangle.Y = 162;
73881 break;
73882 }
73883 }
73884 else if (downLeft != -1)
73885 {
73886 switch (num27)
73887 {
73888 case 0:
73889 rectangle.X = 36;
73890 rectangle.Y = 90;
73891 break;
73892 case 1:
73893 rectangle.X = 36;
73894 rectangle.Y = 126;
73895 break;
73896 default:
73897 rectangle.X = 36;
73898 rectangle.Y = 162;
73899 break;
73900 }
73901 }
73902 }
73903 else if (up == num && down == num && left == num && right == num32)
73904 {
73905 if (upLeft != -1)
73906 {
73907 switch (num27)
73908 {
73909 case 0:
73910 rectangle.X = 54;
73911 rectangle.Y = 90;
73912 break;
73913 case 1:
73914 rectangle.X = 54;
73915 rectangle.Y = 126;
73916 break;
73917 default:
73918 rectangle.X = 54;
73919 rectangle.Y = 162;
73920 break;
73921 }
73922 }
73923 else if (downLeft != -1)
73924 {
73925 switch (num27)
73926 {
73927 case 0:
73928 rectangle.X = 54;
73929 rectangle.Y = 108;
73930 break;
73931 case 1:
73932 rectangle.X = 54;
73933 rectangle.Y = 144;
73934 break;
73935 default:
73936 rectangle.X = 54;
73937 rectangle.Y = 180;
73938 break;
73939 }
73940 }
73941 }
73942 else if (up == num && down == num && left == num32 && right == num)
73943 {
73944 if (upRight != -1)
73945 {
73946 switch (num27)
73947 {
73948 case 0:
73949 rectangle.X = 36;
73950 rectangle.Y = 90;
73951 break;
73952 case 1:
73953 rectangle.X = 36;
73954 rectangle.Y = 126;
73955 break;
73956 default:
73957 rectangle.X = 36;
73958 rectangle.Y = 162;
73959 break;
73960 }
73961 }
73962 else if (downRight != -1)
73963 {
73964 switch (num27)
73965 {
73966 case 0:
73967 rectangle.X = 36;
73968 rectangle.Y = 108;
73969 break;
73970 case 1:
73971 rectangle.X = 36;
73972 rectangle.Y = 144;
73973 break;
73974 default:
73975 rectangle.X = 36;
73976 rectangle.Y = 180;
73977 break;
73978 }
73979 }
73980 }
73981 else if ((up == num32 && down == num && left == num && right == num) || (up == num && down == num32 && left == num && right == num) || (up == num && down == num && left == num32 && right == num) || (up == num && down == num && left == num && right == num32))
73982 {
73983 switch (num27)
73984 {
73985 case 0:
73986 rectangle.X = 18;
73987 rectangle.Y = 18;
73988 break;
73989 case 1:
73990 rectangle.X = 36;
73991 rectangle.Y = 18;
73992 break;
73993 default:
73994 rectangle.X = 54;
73995 rectangle.Y = 18;
73996 break;
73997 }
73998 }
73999 if ((up == num || up == num32) && (down == num || down == num32) && (left == num || left == num32) && (right == num || right == num32))
74000 {
74001 if (upLeft != num && upLeft != num32 && (upRight == num || upRight == num32) && (downLeft == num || downLeft == num32) && (downRight == num || downRight == num32))
74002 {
74003 switch (num27)
74004 {
74005 case 0:
74006 rectangle.X = 54;
74007 rectangle.Y = 108;
74008 break;
74009 case 1:
74010 rectangle.X = 54;
74011 rectangle.Y = 144;
74012 break;
74013 default:
74014 rectangle.X = 54;
74015 rectangle.Y = 180;
74016 break;
74017 }
74018 }
74019 else if (upRight != num && upRight != num32 && (upLeft == num || upLeft == num32) && (downLeft == num || downLeft == num32) && (downRight == num || downRight == num32))
74020 {
74021 switch (num27)
74022 {
74023 case 0:
74024 rectangle.X = 36;
74025 rectangle.Y = 108;
74026 break;
74027 case 1:
74028 rectangle.X = 36;
74029 rectangle.Y = 144;
74030 break;
74031 default:
74032 rectangle.X = 36;
74033 rectangle.Y = 180;
74034 break;
74035 }
74036 }
74037 else if (downLeft != num && downLeft != num32 && (upLeft == num || upLeft == num32) && (upRight == num || upRight == num32) && (downRight == num || downRight == num32))
74038 {
74039 switch (num27)
74040 {
74041 case 0:
74042 rectangle.X = 54;
74043 rectangle.Y = 90;
74044 break;
74045 case 1:
74046 rectangle.X = 54;
74047 rectangle.Y = 126;
74048 break;
74049 default:
74050 rectangle.X = 54;
74051 rectangle.Y = 162;
74052 break;
74053 }
74054 }
74055 else if (downRight != num && downRight != num32 && (upLeft == num || upLeft == num32) && (downLeft == num || downLeft == num32) && (upRight == num || upRight == num32))
74056 {
74057 switch (num27)
74058 {
74059 case 0:
74060 rectangle.X = 36;
74061 rectangle.Y = 90;
74062 break;
74063 case 1:
74064 rectangle.X = 36;
74065 rectangle.Y = 126;
74066 break;
74067 default:
74068 rectangle.X = 36;
74069 rectangle.Y = 162;
74070 break;
74071 }
74072 }
74073 }
74074 if (up != num32 && up != num && down == num && left != num32 && left != num && right == num && downRight != num32 && downRight != num)
74075 {
74076 switch (num27)
74077 {
74078 case 0:
74079 rectangle.X = 90;
74080 rectangle.Y = 270;
74081 break;
74082 case 1:
74083 rectangle.X = 108;
74084 rectangle.Y = 270;
74085 break;
74086 default:
74087 rectangle.X = 126;
74088 rectangle.Y = 270;
74089 break;
74090 }
74091 }
74092 else if (up != num32 && up != num && down == num && left == num && right != num32 && right != num && downLeft != num32 && downLeft != num)
74093 {
74094 switch (num27)
74095 {
74096 case 0:
74097 rectangle.X = 144;
74098 rectangle.Y = 270;
74099 break;
74100 case 1:
74101 rectangle.X = 162;
74102 rectangle.Y = 270;
74103 break;
74104 default:
74105 rectangle.X = 180;
74106 rectangle.Y = 270;
74107 break;
74108 }
74109 }
74110 else if (down != num32 && down != num && up == num && left != num32 && left != num && right == num && upRight != num32 && upRight != num)
74111 {
74112 switch (num27)
74113 {
74114 case 0:
74115 rectangle.X = 90;
74116 rectangle.Y = 288;
74117 break;
74118 case 1:
74119 rectangle.X = 108;
74120 rectangle.Y = 288;
74121 break;
74122 default:
74123 rectangle.X = 126;
74124 rectangle.Y = 288;
74125 break;
74126 }
74127 }
74128 else if (down != num32 && down != num && up == num && left == num && right != num32 && right != num && upLeft != num32 && upLeft != num)
74129 {
74130 switch (num27)
74131 {
74132 case 0:
74133 rectangle.X = 144;
74134 rectangle.Y = 288;
74135 break;
74136 case 1:
74137 rectangle.X = 162;
74138 rectangle.Y = 288;
74139 break;
74140 default:
74141 rectangle.X = 180;
74142 rectangle.Y = 288;
74143 break;
74144 }
74145 }
74146 else if (up != num && up != num32 && down == num && left == num && right == num && downLeft != num && downLeft != num32 && downRight != num && downRight != num32)
74147 {
74148 switch (num27)
74149 {
74150 case 0:
74151 rectangle.X = 144;
74152 rectangle.Y = 216;
74153 break;
74154 case 1:
74155 rectangle.X = 198;
74156 rectangle.Y = 216;
74157 break;
74158 default:
74159 rectangle.X = 252;
74160 rectangle.Y = 216;
74161 break;
74162 }
74163 }
74164 else if (down != num && down != num32 && up == num && left == num && right == num && upLeft != num && upLeft != num32 && upRight != num && upRight != num32)
74165 {
74166 switch (num27)
74167 {
74168 case 0:
74169 rectangle.X = 144;
74170 rectangle.Y = 252;
74171 break;
74172 case 1:
74173 rectangle.X = 198;
74174 rectangle.Y = 252;
74175 break;
74176 default:
74177 rectangle.X = 252;
74178 rectangle.Y = 252;
74179 break;
74180 }
74181 }
74182 else if (left != num && left != num32 && down == num && up == num && right == num && upRight != num && upRight != num32 && downRight != num && downRight != num32)
74183 {
74184 switch (num27)
74185 {
74186 case 0:
74187 rectangle.X = 126;
74188 rectangle.Y = 234;
74189 break;
74190 case 1:
74191 rectangle.X = 180;
74192 rectangle.Y = 234;
74193 break;
74194 default:
74195 rectangle.X = 234;
74196 rectangle.Y = 234;
74197 break;
74198 }
74199 }
74200 else if (right != num && right != num32 && down == num && up == num && left == num && upLeft != num && upLeft != num32 && downLeft != num && downLeft != num32)
74201 {
74202 switch (num27)
74203 {
74204 case 0:
74205 rectangle.X = 162;
74206 rectangle.Y = 234;
74207 break;
74208 case 1:
74209 rectangle.X = 216;
74210 rectangle.Y = 234;
74211 break;
74212 default:
74213 rectangle.X = 270;
74214 rectangle.Y = 234;
74215 break;
74216 }
74217 }
74218 else if (up != num32 && up != num && (down == num32 || down == num) && left == num32 && right == num32)
74219 {
74220 switch (num27)
74221 {
74222 case 0:
74223 rectangle.X = 36;
74224 rectangle.Y = 270;
74225 break;
74226 case 1:
74227 rectangle.X = 54;
74228 rectangle.Y = 270;
74229 break;
74230 default:
74231 rectangle.X = 72;
74232 rectangle.Y = 270;
74233 break;
74234 }
74235 }
74236 else if (down != num32 && down != num && (up == num32 || up == num) && left == num32 && right == num32)
74237 {
74238 switch (num27)
74239 {
74240 case 0:
74241 rectangle.X = 36;
74242 rectangle.Y = 288;
74243 break;
74244 case 1:
74245 rectangle.X = 54;
74246 rectangle.Y = 288;
74247 break;
74248 default:
74249 rectangle.X = 72;
74250 rectangle.Y = 288;
74251 break;
74252 }
74253 }
74254 else if (left != num32 && left != num && (right == num32 || right == num) && up == num32 && down == num32)
74255 {
74256 switch (num27)
74257 {
74258 case 0:
74259 rectangle.X = 0;
74260 rectangle.Y = 270;
74261 break;
74262 case 1:
74263 rectangle.X = 0;
74264 rectangle.Y = 288;
74265 break;
74266 default:
74267 rectangle.X = 0;
74268 rectangle.Y = 306;
74269 break;
74270 }
74271 }
74272 else if (right != num32 && right != num && (left == num32 || left == num) && up == num32 && down == num32)
74273 {
74274 switch (num27)
74275 {
74276 case 0:
74277 rectangle.X = 18;
74278 rectangle.Y = 270;
74279 break;
74280 case 1:
74281 rectangle.X = 18;
74282 rectangle.Y = 288;
74283 break;
74284 default:
74285 rectangle.X = 18;
74286 rectangle.Y = 306;
74287 break;
74288 }
74289 }
74290 else if (up == num && down == num32 && left == num32 && right == num32)
74291 {
74292 switch (num27)
74293 {
74294 case 0:
74295 rectangle.X = 198;
74296 rectangle.Y = 288;
74297 break;
74298 case 1:
74299 rectangle.X = 216;
74300 rectangle.Y = 288;
74301 break;
74302 default:
74303 rectangle.X = 234;
74304 rectangle.Y = 288;
74305 break;
74306 }
74307 }
74308 else if (up == num32 && down == num && left == num32 && right == num32)
74309 {
74310 switch (num27)
74311 {
74312 case 0:
74313 rectangle.X = 198;
74314 rectangle.Y = 270;
74315 break;
74316 case 1:
74317 rectangle.X = 216;
74318 rectangle.Y = 270;
74319 break;
74320 default:
74321 rectangle.X = 234;
74322 rectangle.Y = 270;
74323 break;
74324 }
74325 }
74326 else if (up == num32 && down == num32 && left == num && right == num32)
74327 {
74328 switch (num27)
74329 {
74330 case 0:
74331 rectangle.X = 198;
74332 rectangle.Y = 306;
74333 break;
74334 case 1:
74335 rectangle.X = 216;
74336 rectangle.Y = 306;
74337 break;
74338 default:
74339 rectangle.X = 234;
74340 rectangle.Y = 306;
74341 break;
74342 }
74343 }
74344 else if (up == num32 && down == num32 && left == num32 && right == num)
74345 {
74346 switch (num27)
74347 {
74348 case 0:
74349 rectangle.X = 144;
74350 rectangle.Y = 306;
74351 break;
74352 case 1:
74353 rectangle.X = 162;
74354 rectangle.Y = 306;
74355 break;
74356 default:
74357 rectangle.X = 180;
74358 rectangle.Y = 306;
74359 break;
74360 }
74361 }
74362 if (up != num && up != num32 && down == num && left == num && right == num)
74363 {
74364 if ((downLeft == num32 || downLeft == num) && downRight != num32 && downRight != num)
74365 {
74366 switch (num27)
74367 {
74368 case 0:
74369 rectangle.X = 0;
74370 rectangle.Y = 324;
74371 break;
74372 case 1:
74373 rectangle.X = 18;
74374 rectangle.Y = 324;
74375 break;
74376 default:
74377 rectangle.X = 36;
74378 rectangle.Y = 324;
74379 break;
74380 }
74381 }
74382 else if ((downRight == num32 || downRight == num) && downLeft != num32 && downLeft != num)
74383 {
74384 switch (num27)
74385 {
74386 case 0:
74387 rectangle.X = 54;
74388 rectangle.Y = 324;
74389 break;
74390 case 1:
74391 rectangle.X = 72;
74392 rectangle.Y = 324;
74393 break;
74394 default:
74395 rectangle.X = 90;
74396 rectangle.Y = 324;
74397 break;
74398 }
74399 }
74400 }
74401 else if (down != num && down != num32 && up == num && left == num && right == num)
74402 {
74403 if ((upLeft == num32 || upLeft == num) && upRight != num32 && upRight != num)
74404 {
74405 switch (num27)
74406 {
74407 case 0:
74408 rectangle.X = 0;
74409 rectangle.Y = 342;
74410 break;
74411 case 1:
74412 rectangle.X = 18;
74413 rectangle.Y = 342;
74414 break;
74415 default:
74416 rectangle.X = 36;
74417 rectangle.Y = 342;
74418 break;
74419 }
74420 }
74421 else if ((upRight == num32 || upRight == num) && upLeft != num32 && upLeft != num)
74422 {
74423 switch (num27)
74424 {
74425 case 0:
74426 rectangle.X = 54;
74427 rectangle.Y = 342;
74428 break;
74429 case 1:
74430 rectangle.X = 72;
74431 rectangle.Y = 342;
74432 break;
74433 default:
74434 rectangle.X = 90;
74435 rectangle.Y = 342;
74436 break;
74437 }
74438 }
74439 }
74440 else if (left != num && left != num32 && up == num && down == num && right == num)
74441 {
74442 if ((upRight == num32 || upRight == num) && downRight != num32 && downRight != num)
74443 {
74444 switch (num27)
74445 {
74446 case 0:
74447 rectangle.X = 54;
74448 rectangle.Y = 360;
74449 break;
74450 case 1:
74451 rectangle.X = 72;
74452 rectangle.Y = 360;
74453 break;
74454 default:
74455 rectangle.X = 90;
74456 rectangle.Y = 360;
74457 break;
74458 }
74459 }
74460 else if ((downRight == num32 || downRight == num) && upRight != num32 && upRight != num)
74461 {
74462 switch (num27)
74463 {
74464 case 0:
74465 rectangle.X = 0;
74466 rectangle.Y = 360;
74467 break;
74468 case 1:
74469 rectangle.X = 18;
74470 rectangle.Y = 360;
74471 break;
74472 default:
74473 rectangle.X = 36;
74474 rectangle.Y = 360;
74475 break;
74476 }
74477 }
74478 }
74479 else if (right != num && right != num32 && up == num && down == num && left == num)
74480 {
74481 if ((upLeft == num32 || upLeft == num) && downLeft != num32 && downLeft != num)
74482 {
74483 switch (num27)
74484 {
74485 case 0:
74486 rectangle.X = 0;
74487 rectangle.Y = 378;
74488 break;
74489 case 1:
74490 rectangle.X = 18;
74491 rectangle.Y = 378;
74492 break;
74493 default:
74494 rectangle.X = 36;
74495 rectangle.Y = 378;
74496 break;
74497 }
74498 }
74499 else if ((downLeft == num32 || downLeft == num) && upLeft != num32 && upLeft != num)
74500 {
74501 switch (num27)
74502 {
74503 case 0:
74504 rectangle.X = 54;
74505 rectangle.Y = 378;
74506 break;
74507 case 1:
74508 rectangle.X = 72;
74509 rectangle.Y = 378;
74510 break;
74511 default:
74512 rectangle.X = 90;
74513 rectangle.Y = 378;
74514 break;
74515 }
74516 }
74517 }
74518 if ((up == num || up == num32) && (down == num || down == num32) && (left == num || left == num32) && (right == num || right == num32) && upLeft != -1 && upRight != -1 && downLeft != -1 && downRight != -1)
74519 {
74520 if ((i + j) % 2 == 1)
74521 {
74522 switch (num27)
74523 {
74524 case 0:
74525 rectangle.X = 108;
74526 rectangle.Y = 198;
74527 break;
74528 case 1:
74529 rectangle.X = 126;
74530 rectangle.Y = 198;
74531 break;
74532 default:
74533 rectangle.X = 144;
74534 rectangle.Y = 198;
74535 break;
74536 }
74537 }
74538 else
74539 {
74540 switch (num27)
74541 {
74542 case 0:
74543 rectangle.X = 18;
74544 rectangle.Y = 18;
74545 break;
74546 case 1:
74547 rectangle.X = 36;
74548 rectangle.Y = 18;
74549 break;
74550 default:
74551 rectangle.X = 54;
74552 rectangle.Y = 18;
74553 break;
74554 }
74555 }
74556 }
74557 if (num32 >= 0 && num32 < TileID.Count && TileID.Sets.Dirt[num32])
74558 {
74559 TileMergeAttempt(-2, TileID.Sets.Dirt, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74560 }
74561 else if (num32 >= 0 && num32 < TileID.Count && TileID.Sets.Mud[num32])
74562 {
74563 TileMergeAttempt(-2, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74564 }
74565 else
74566 {
74567 TileMergeAttempt(-2, num32, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74568 }
74569 tileMergeCullCache.Cull(ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74570 }
74571 TileMergeAttempt(num, Main.tileMerge[num], ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74572 if (rectangle.X == -1 && rectangle.Y == -1 && (Main.tileMergeDirt[num] || (num > -1 && TileID.Sets.ChecksForMerge[num])))
74573 {
74574 if (!flag)
74575 {
74576 flag = true;
74577 TileMergeAttemptWeird(num, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74578 }
74579 if (up > -1 && up != num)
74580 {
74581 up = -1;
74582 }
74583 if (down > -1 && down != num)
74584 {
74585 down = -1;
74586 }
74587 if (left > -1 && left != num)
74588 {
74589 left = -1;
74590 }
74591 if (right > -1 && right != num)
74592 {
74593 right = -1;
74594 }
74595 tileMergeCullCache.Cull(ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
74596 if (up != -1 && down != -1 && left != -1 && right != -1)
74597 {
74598 if (up == -2 && down == num && left == num && right == num)
74599 {
74600 switch (num27)
74601 {
74602 case 0:
74603 rectangle.X = 144;
74604 rectangle.Y = 108;
74605 break;
74606 case 1:
74607 rectangle.X = 162;
74608 rectangle.Y = 108;
74609 break;
74610 default:
74611 rectangle.X = 180;
74612 rectangle.Y = 108;
74613 break;
74614 }
74615 mergeUp = true;
74616 }
74617 else if (up == num && down == -2 && left == num && right == num)
74618 {
74619 switch (num27)
74620 {
74621 case 0:
74622 rectangle.X = 144;
74623 rectangle.Y = 90;
74624 break;
74625 case 1:
74626 rectangle.X = 162;
74627 rectangle.Y = 90;
74628 break;
74629 default:
74630 rectangle.X = 180;
74631 rectangle.Y = 90;
74632 break;
74633 }
74634 mergeDown = true;
74635 }
74636 else if (up == num && down == num && left == -2 && right == num)
74637 {
74638 switch (num27)
74639 {
74640 case 0:
74641 rectangle.X = 162;
74642 rectangle.Y = 126;
74643 break;
74644 case 1:
74645 rectangle.X = 162;
74646 rectangle.Y = 144;
74647 break;
74648 default:
74649 rectangle.X = 162;
74650 rectangle.Y = 162;
74651 break;
74652 }
74653 mergeLeft = true;
74654 }
74655 else if (up == num && down == num && left == num && right == -2)
74656 {
74657 switch (num27)
74658 {
74659 case 0:
74660 rectangle.X = 144;
74661 rectangle.Y = 126;
74662 break;
74663 case 1:
74664 rectangle.X = 144;
74665 rectangle.Y = 144;
74666 break;
74667 default:
74668 rectangle.X = 144;
74669 rectangle.Y = 162;
74670 break;
74671 }
74672 mergeRight = true;
74673 }
74674 else if (up == -2 && down == num && left == -2 && right == num)
74675 {
74676 switch (num27)
74677 {
74678 case 0:
74679 rectangle.X = 36;
74680 rectangle.Y = 90;
74681 break;
74682 case 1:
74683 rectangle.X = 36;
74684 rectangle.Y = 126;
74685 break;
74686 default:
74687 rectangle.X = 36;
74688 rectangle.Y = 162;
74689 break;
74690 }
74691 mergeUp = true;
74692 mergeLeft = true;
74693 }
74694 else if (up == -2 && down == num && left == num && right == -2)
74695 {
74696 switch (num27)
74697 {
74698 case 0:
74699 rectangle.X = 54;
74700 rectangle.Y = 90;
74701 break;
74702 case 1:
74703 rectangle.X = 54;
74704 rectangle.Y = 126;
74705 break;
74706 default:
74707 rectangle.X = 54;
74708 rectangle.Y = 162;
74709 break;
74710 }
74711 mergeUp = true;
74712 mergeRight = true;
74713 }
74714 else if (up == num && down == -2 && left == -2 && right == num)
74715 {
74716 switch (num27)
74717 {
74718 case 0:
74719 rectangle.X = 36;
74720 rectangle.Y = 108;
74721 break;
74722 case 1:
74723 rectangle.X = 36;
74724 rectangle.Y = 144;
74725 break;
74726 default:
74727 rectangle.X = 36;
74728 rectangle.Y = 180;
74729 break;
74730 }
74731 mergeDown = true;
74732 mergeLeft = true;
74733 }
74734 else if (up == num && down == -2 && left == num && right == -2)
74735 {
74736 switch (num27)
74737 {
74738 case 0:
74739 rectangle.X = 54;
74740 rectangle.Y = 108;
74741 break;
74742 case 1:
74743 rectangle.X = 54;
74744 rectangle.Y = 144;
74745 break;
74746 default:
74747 rectangle.X = 54;
74748 rectangle.Y = 180;
74749 break;
74750 }
74751 mergeDown = true;
74752 mergeRight = true;
74753 }
74754 else if (up == num && down == num && left == -2 && right == -2)
74755 {
74756 switch (num27)
74757 {
74758 case 0:
74759 rectangle.X = 180;
74760 rectangle.Y = 126;
74761 break;
74762 case 1:
74763 rectangle.X = 180;
74764 rectangle.Y = 144;
74765 break;
74766 default:
74767 rectangle.X = 180;
74768 rectangle.Y = 162;
74769 break;
74770 }
74771 mergeLeft = true;
74772 mergeRight = true;
74773 }
74774 else if (up == -2 && down == -2 && left == num && right == num)
74775 {
74776 switch (num27)
74777 {
74778 case 0:
74779 rectangle.X = 144;
74780 rectangle.Y = 180;
74781 break;
74782 case 1:
74783 rectangle.X = 162;
74784 rectangle.Y = 180;
74785 break;
74786 default:
74787 rectangle.X = 180;
74788 rectangle.Y = 180;
74789 break;
74790 }
74791 mergeUp = true;
74792 mergeDown = true;
74793 }
74794 else if (up == -2 && down == num && left == -2 && right == -2)
74795 {
74796 switch (num27)
74797 {
74798 case 0:
74799 rectangle.X = 198;
74800 rectangle.Y = 90;
74801 break;
74802 case 1:
74803 rectangle.X = 198;
74804 rectangle.Y = 108;
74805 break;
74806 default:
74807 rectangle.X = 198;
74808 rectangle.Y = 126;
74809 break;
74810 }
74811 mergeUp = true;
74812 mergeLeft = true;
74813 mergeRight = true;
74814 }
74815 else if (up == num && down == -2 && left == -2 && right == -2)
74816 {
74817 switch (num27)
74818 {
74819 case 0:
74820 rectangle.X = 198;
74821 rectangle.Y = 144;
74822 break;
74823 case 1:
74824 rectangle.X = 198;
74825 rectangle.Y = 162;
74826 break;
74827 default:
74828 rectangle.X = 198;
74829 rectangle.Y = 180;
74830 break;
74831 }
74832 mergeDown = true;
74833 mergeLeft = true;
74834 mergeRight = true;
74835 }
74836 else if (up == -2 && down == -2 && left == num && right == -2)
74837 {
74838 switch (num27)
74839 {
74840 case 0:
74841 rectangle.X = 216;
74842 rectangle.Y = 144;
74843 break;
74844 case 1:
74845 rectangle.X = 216;
74846 rectangle.Y = 162;
74847 break;
74848 default:
74849 rectangle.X = 216;
74850 rectangle.Y = 180;
74851 break;
74852 }
74853 mergeUp = true;
74854 mergeDown = true;
74855 mergeRight = true;
74856 }
74857 else if (up == -2 && down == -2 && left == -2 && right == num)
74858 {
74859 switch (num27)
74860 {
74861 case 0:
74862 rectangle.X = 216;
74863 rectangle.Y = 90;
74864 break;
74865 case 1:
74866 rectangle.X = 216;
74867 rectangle.Y = 108;
74868 break;
74869 default:
74870 rectangle.X = 216;
74871 rectangle.Y = 126;
74872 break;
74873 }
74874 mergeUp = true;
74875 mergeDown = true;
74876 mergeLeft = true;
74877 }
74878 else if (up == -2 && down == -2 && left == -2 && right == -2)
74879 {
74880 switch (num27)
74881 {
74882 case 0:
74883 rectangle.X = 108;
74884 rectangle.Y = 198;
74885 break;
74886 case 1:
74887 rectangle.X = 126;
74888 rectangle.Y = 198;
74889 break;
74890 default:
74891 rectangle.X = 144;
74892 rectangle.Y = 198;
74893 break;
74894 }
74895 mergeUp = true;
74896 mergeDown = true;
74897 mergeLeft = true;
74898 mergeRight = true;
74899 }
74900 else if (up == num && down == num && left == num && right == num)
74901 {
74902 if (upLeft == -2)
74903 {
74904 switch (num27)
74905 {
74906 case 0:
74907 rectangle.X = 18;
74908 rectangle.Y = 108;
74909 break;
74910 case 1:
74911 rectangle.X = 18;
74912 rectangle.Y = 144;
74913 break;
74914 default:
74915 rectangle.X = 18;
74916 rectangle.Y = 180;
74917 break;
74918 }
74919 }
74920 if (upRight == -2)
74921 {
74922 switch (num27)
74923 {
74924 case 0:
74925 rectangle.X = 0;
74926 rectangle.Y = 108;
74927 break;
74928 case 1:
74929 rectangle.X = 0;
74930 rectangle.Y = 144;
74931 break;
74932 default:
74933 rectangle.X = 0;
74934 rectangle.Y = 180;
74935 break;
74936 }
74937 }
74938 if (downLeft == -2)
74939 {
74940 switch (num27)
74941 {
74942 case 0:
74943 rectangle.X = 18;
74944 rectangle.Y = 90;
74945 break;
74946 case 1:
74947 rectangle.X = 18;
74948 rectangle.Y = 126;
74949 break;
74950 default:
74951 rectangle.X = 18;
74952 rectangle.Y = 162;
74953 break;
74954 }
74955 }
74956 if (downRight == -2)
74957 {
74958 switch (num27)
74959 {
74960 case 0:
74961 rectangle.X = 0;
74962 rectangle.Y = 90;
74963 break;
74964 case 1:
74965 rectangle.X = 0;
74966 rectangle.Y = 126;
74967 break;
74968 default:
74969 rectangle.X = 0;
74970 rectangle.Y = 162;
74971 break;
74972 }
74973 }
74974 }
74975 }
74976 else
74977 {
74978 if (num != 2 && num != 23 && num != 60 && num != 70 && num != 109 && num != 199 && num != 477 && num != 492 && num != 633 && num != 661 && num != 662)
74979 {
74980 if (up == -1 && down == -2 && left == num && right == num)
74981 {
74982 switch (num27)
74983 {
74984 case 0:
74985 rectangle.X = 234;
74986 rectangle.Y = 0;
74987 break;
74988 case 1:
74989 rectangle.X = 252;
74990 rectangle.Y = 0;
74991 break;
74992 default:
74993 rectangle.X = 270;
74994 rectangle.Y = 0;
74995 break;
74996 }
74997 mergeDown = true;
74998 }
74999 else if (up == -2 && down == -1 && left == num && right == num)
75000 {
75001 switch (num27)
75002 {
75003 case 0:
75004 rectangle.X = 234;
75005 rectangle.Y = 18;
75006 break;
75007 case 1:
75008 rectangle.X = 252;
75009 rectangle.Y = 18;
75010 break;
75011 default:
75012 rectangle.X = 270;
75013 rectangle.Y = 18;
75014 break;
75015 }
75016 mergeUp = true;
75017 }
75018 else if (up == num && down == num && left == -1 && right == -2)
75019 {
75020 switch (num27)
75021 {
75022 case 0:
75023 rectangle.X = 234;
75024 rectangle.Y = 36;
75025 break;
75026 case 1:
75027 rectangle.X = 252;
75028 rectangle.Y = 36;
75029 break;
75030 default:
75031 rectangle.X = 270;
75032 rectangle.Y = 36;
75033 break;
75034 }
75035 mergeRight = true;
75036 }
75037 else if (up == num && down == num && left == -2 && right == -1)
75038 {
75039 switch (num27)
75040 {
75041 case 0:
75042 rectangle.X = 234;
75043 rectangle.Y = 54;
75044 break;
75045 case 1:
75046 rectangle.X = 252;
75047 rectangle.Y = 54;
75048 break;
75049 default:
75050 rectangle.X = 270;
75051 rectangle.Y = 54;
75052 break;
75053 }
75054 mergeLeft = true;
75055 }
75056 }
75057 if (up != -1 && down != -1 && left == -1 && right == num)
75058 {
75059 if (up == -2 && down == num)
75060 {
75061 switch (num27)
75062 {
75063 case 0:
75064 rectangle.X = 72;
75065 rectangle.Y = 144;
75066 break;
75067 case 1:
75068 rectangle.X = 72;
75069 rectangle.Y = 162;
75070 break;
75071 default:
75072 rectangle.X = 72;
75073 rectangle.Y = 180;
75074 break;
75075 }
75076 mergeUp = true;
75077 }
75078 else if (down == -2 && up == num)
75079 {
75080 switch (num27)
75081 {
75082 case 0:
75083 rectangle.X = 72;
75084 rectangle.Y = 90;
75085 break;
75086 case 1:
75087 rectangle.X = 72;
75088 rectangle.Y = 108;
75089 break;
75090 default:
75091 rectangle.X = 72;
75092 rectangle.Y = 126;
75093 break;
75094 }
75095 mergeDown = true;
75096 }
75097 }
75098 else if (up != -1 && down != -1 && left == num && right == -1)
75099 {
75100 if (up == -2 && down == num)
75101 {
75102 switch (num27)
75103 {
75104 case 0:
75105 rectangle.X = 90;
75106 rectangle.Y = 144;
75107 break;
75108 case 1:
75109 rectangle.X = 90;
75110 rectangle.Y = 162;
75111 break;
75112 default:
75113 rectangle.X = 90;
75114 rectangle.Y = 180;
75115 break;
75116 }
75117 mergeUp = true;
75118 }
75119 else if (down == -2 && up == num)
75120 {
75121 switch (num27)
75122 {
75123 case 0:
75124 rectangle.X = 90;
75125 rectangle.Y = 90;
75126 break;
75127 case 1:
75128 rectangle.X = 90;
75129 rectangle.Y = 108;
75130 break;
75131 default:
75132 rectangle.X = 90;
75133 rectangle.Y = 126;
75134 break;
75135 }
75136 mergeDown = true;
75137 }
75138 }
75139 else if (up == -1 && down == num && left != -1 && right != -1)
75140 {
75141 if (left == -2 && right == num)
75142 {
75143 switch (num27)
75144 {
75145 case 0:
75146 rectangle.X = 0;
75147 rectangle.Y = 198;
75148 break;
75149 case 1:
75150 rectangle.X = 18;
75151 rectangle.Y = 198;
75152 break;
75153 default:
75154 rectangle.X = 36;
75155 rectangle.Y = 198;
75156 break;
75157 }
75158 mergeLeft = true;
75159 }
75160 else if (right == -2 && left == num)
75161 {
75162 switch (num27)
75163 {
75164 case 0:
75165 rectangle.X = 54;
75166 rectangle.Y = 198;
75167 break;
75168 case 1:
75169 rectangle.X = 72;
75170 rectangle.Y = 198;
75171 break;
75172 default:
75173 rectangle.X = 90;
75174 rectangle.Y = 198;
75175 break;
75176 }
75177 mergeRight = true;
75178 }
75179 }
75180 else if (up == num && down == -1 && left != -1 && right != -1)
75181 {
75182 if (left == -2 && right == num)
75183 {
75184 switch (num27)
75185 {
75186 case 0:
75187 rectangle.X = 0;
75188 rectangle.Y = 216;
75189 break;
75190 case 1:
75191 rectangle.X = 18;
75192 rectangle.Y = 216;
75193 break;
75194 default:
75195 rectangle.X = 36;
75196 rectangle.Y = 216;
75197 break;
75198 }
75199 mergeLeft = true;
75200 }
75201 else if (right == -2 && left == num)
75202 {
75203 switch (num27)
75204 {
75205 case 0:
75206 rectangle.X = 54;
75207 rectangle.Y = 216;
75208 break;
75209 case 1:
75210 rectangle.X = 72;
75211 rectangle.Y = 216;
75212 break;
75213 default:
75214 rectangle.X = 90;
75215 rectangle.Y = 216;
75216 break;
75217 }
75218 mergeRight = true;
75219 }
75220 }
75221 else if (up != -1 && down != -1 && left == -1 && right == -1)
75222 {
75223 if (up == -2 && down == -2)
75224 {
75225 switch (num27)
75226 {
75227 case 0:
75228 rectangle.X = 108;
75229 rectangle.Y = 216;
75230 break;
75231 case 1:
75232 rectangle.X = 108;
75233 rectangle.Y = 234;
75234 break;
75235 default:
75236 rectangle.X = 108;
75237 rectangle.Y = 252;
75238 break;
75239 }
75240 mergeUp = true;
75241 mergeDown = true;
75242 }
75243 else if (up == -2)
75244 {
75245 switch (num27)
75246 {
75247 case 0:
75248 rectangle.X = 126;
75249 rectangle.Y = 144;
75250 break;
75251 case 1:
75252 rectangle.X = 126;
75253 rectangle.Y = 162;
75254 break;
75255 default:
75256 rectangle.X = 126;
75257 rectangle.Y = 180;
75258 break;
75259 }
75260 mergeUp = true;
75261 }
75262 else if (down == -2)
75263 {
75264 switch (num27)
75265 {
75266 case 0:
75267 rectangle.X = 126;
75268 rectangle.Y = 90;
75269 break;
75270 case 1:
75271 rectangle.X = 126;
75272 rectangle.Y = 108;
75273 break;
75274 default:
75275 rectangle.X = 126;
75276 rectangle.Y = 126;
75277 break;
75278 }
75279 mergeDown = true;
75280 }
75281 }
75282 else if (up == -1 && down == -1 && left != -1 && right != -1)
75283 {
75284 if (left == -2 && right == -2)
75285 {
75286 switch (num27)
75287 {
75288 case 0:
75289 rectangle.X = 162;
75290 rectangle.Y = 198;
75291 break;
75292 case 1:
75293 rectangle.X = 180;
75294 rectangle.Y = 198;
75295 break;
75296 default:
75297 rectangle.X = 198;
75298 rectangle.Y = 198;
75299 break;
75300 }
75301 mergeLeft = true;
75302 mergeRight = true;
75303 }
75304 else if (left == -2)
75305 {
75306 switch (num27)
75307 {
75308 case 0:
75309 rectangle.X = 0;
75310 rectangle.Y = 252;
75311 break;
75312 case 1:
75313 rectangle.X = 18;
75314 rectangle.Y = 252;
75315 break;
75316 default:
75317 rectangle.X = 36;
75318 rectangle.Y = 252;
75319 break;
75320 }
75321 mergeLeft = true;
75322 }
75323 else if (right == -2)
75324 {
75325 switch (num27)
75326 {
75327 case 0:
75328 rectangle.X = 54;
75329 rectangle.Y = 252;
75330 break;
75331 case 1:
75332 rectangle.X = 72;
75333 rectangle.Y = 252;
75334 break;
75335 default:
75336 rectangle.X = 90;
75337 rectangle.Y = 252;
75338 break;
75339 }
75340 mergeRight = true;
75341 }
75342 }
75343 else if (up == -2 && down == -1 && left == -1 && right == -1)
75344 {
75345 switch (num27)
75346 {
75347 case 0:
75348 rectangle.X = 108;
75349 rectangle.Y = 144;
75350 break;
75351 case 1:
75352 rectangle.X = 108;
75353 rectangle.Y = 162;
75354 break;
75355 default:
75356 rectangle.X = 108;
75357 rectangle.Y = 180;
75358 break;
75359 }
75360 mergeUp = true;
75361 }
75362 else if (up == -1 && down == -2 && left == -1 && right == -1)
75363 {
75364 switch (num27)
75365 {
75366 case 0:
75367 rectangle.X = 108;
75368 rectangle.Y = 90;
75369 break;
75370 case 1:
75371 rectangle.X = 108;
75372 rectangle.Y = 108;
75373 break;
75374 default:
75375 rectangle.X = 108;
75376 rectangle.Y = 126;
75377 break;
75378 }
75379 mergeDown = true;
75380 }
75381 else if (up == -1 && down == -1 && left == -2 && right == -1)
75382 {
75383 switch (num27)
75384 {
75385 case 0:
75386 rectangle.X = 0;
75387 rectangle.Y = 234;
75388 break;
75389 case 1:
75390 rectangle.X = 18;
75391 rectangle.Y = 234;
75392 break;
75393 default:
75394 rectangle.X = 36;
75395 rectangle.Y = 234;
75396 break;
75397 }
75398 mergeLeft = true;
75399 }
75400 else if (up == -1 && down == -1 && left == -1 && right == -2)
75401 {
75402 switch (num27)
75403 {
75404 case 0:
75405 rectangle.X = 54;
75406 rectangle.Y = 234;
75407 break;
75408 case 1:
75409 rectangle.X = 72;
75410 rectangle.Y = 234;
75411 break;
75412 default:
75413 rectangle.X = 90;
75414 rectangle.Y = 234;
75415 break;
75416 }
75417 mergeRight = true;
75418 }
75419 }
75420 }
75421 int num33 = tile.blockType();
75422 if (TileID.Sets.HasSlopeFrames[num])
75423 {
75424 if (num33 == 0)
75425 {
75426 bool flag3 = num == up && tile2 != null && tile2.topSlope();
75427 bool flag4 = num == left && tile4 != null && tile4.leftSlope();
75428 bool flag5 = num == right && tile5 != null && tile5.rightSlope();
75429 bool flag6 = num == down && tile3 != null && tile3.bottomSlope();
75430 int num34 = 0;
75431 int num35 = 0;
75432 if (flag3.ToInt() + flag4.ToInt() + flag5.ToInt() + flag6.ToInt() > 2)
75433 {
75434 int num36 = (tile2 != null && tile2.slope() == 1).ToInt() + (tile5 != null && tile5.slope() == 1).ToInt() + (tile3 != null && tile3.slope() == 4).ToInt() + (tile4 != null && tile4.slope() == 4).ToInt();
75435 int num37 = (tile2 != null && tile2.slope() == 2).ToInt() + (tile5 != null && tile5.slope() == 3).ToInt() + (tile3 != null && tile3.slope() == 3).ToInt() + (tile4 != null && tile4.slope() == 2).ToInt();
75436 if (num36 == num37)
75437 {
75438 num34 = 2;
75439 num35 = 4;
75440 }
75441 else if (num36 > num37)
75442 {
75443 bool num38 = num == upLeft && tile8 != null && tile8.slope() == 0;
75444 bool flag7 = num == downRight && tile7 != null && tile7.slope() == 0;
75445 if (num38 && flag7)
75446 {
75447 num35 = 4;
75448 }
75449 else if (flag7)
75450 {
75451 num34 = 6;
75452 }
75453 else
75454 {
75455 num34 = 7;
75456 num35 = 1;
75457 }
75458 }
75459 else
75460 {
75461 bool num39 = num == upRight && tile9 != null && tile9.slope() == 0;
75462 bool flag8 = num == downLeft && tile6 != null && tile6.slope() == 0;
75463 if (num39 && flag8)
75464 {
75465 num35 = 4;
75466 num34 = 1;
75467 }
75468 else if (flag8)
75469 {
75470 num34 = 7;
75471 }
75472 else
75473 {
75474 num34 = 6;
75475 num35 = 1;
75476 }
75477 }
75478 rectangle.X = (18 + num34) * 18;
75479 rectangle.Y = num35 * 18;
75480 }
75481 else
75482 {
75483 if (flag3 && flag4 && num == down && num == right)
75484 {
75485 num35 = 2;
75486 }
75487 else if (flag3 && flag5 && num == down && num == left)
75488 {
75489 num34 = 1;
75490 num35 = 2;
75491 }
75492 else if (flag5 && flag6 && num == up && num == left)
75493 {
75494 num34 = 1;
75495 num35 = 3;
75496 }
75497 else if (flag6 && flag4 && num == up && num == right)
75498 {
75499 num35 = 3;
75500 }
75501 if (num34 != 0 || num35 != 0)
75502 {
75503 rectangle.X = (18 + num34) * 18;
75504 rectangle.Y = num35 * 18;
75505 }
75506 }
75507 }
75508 if (num33 >= 2 && (rectangle.X < 0 || rectangle.Y < 0))
75509 {
75510 int num40 = -1;
75511 int num41 = -1;
75512 int num42 = -1;
75513 int num43 = 0;
75514 int num44 = 0;
75515 switch (num33)
75516 {
75517 case 2:
75518 num40 = left;
75519 num41 = down;
75520 num42 = downLeft;
75521 num43++;
75522 break;
75523 case 3:
75524 num40 = right;
75525 num41 = down;
75526 num42 = downRight;
75527 break;
75528 case 4:
75529 num40 = left;
75530 num41 = up;
75531 num42 = upLeft;
75532 num43++;
75533 num44++;
75534 break;
75535 case 5:
75536 num40 = right;
75537 num41 = up;
75538 num42 = upRight;
75539 num44++;
75540 break;
75541 }
75542 if (num != num40 || num != num41 || num != num42)
75543 {
75544 if (num == num40 && num == num41)
75545 {
75546 num43 += 2;
75547 }
75548 else if (num == num40)
75549 {
75550 num43 += 4;
75551 }
75552 else if (num == num41)
75553 {
75554 num43 += 4;
75555 num44 += 2;
75556 }
75557 else
75558 {
75559 num43 += 2;
75560 num44 += 2;
75561 }
75562 }
75563 rectangle.X = (18 + num43) * 18;
75564 rectangle.Y = num44 * 18;
75565 }
75566 }
75567 if (rectangle.X < 0 || rectangle.Y < 0)
75568 {
75569 if (!flag)
75570 {
75571 flag = true;
75572 TileMergeAttemptWeird(num, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
75573 tileMergeCullCache.Cull(ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
75574 }
75575 if (num == 2 || num == 23 || num == 60 || num == 70 || num == 109 || num == 199 || num == 477 || num == 492 || num == 633 || num == 661 || num == 662 || Main.tileMoss[num] || TileID.Sets.tileMossBrick[num])
75576 {
75577 TileMergeAttempt(num, -2, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
75578 tileMergeCullCache.Cull(ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
75579 }
75580 if (up == num && down == num && left == num && right == num)
75581 {
75582 if (upLeft != num && upRight != num)
75583 {
75584 switch (num27)
75585 {
75586 case 0:
75587 rectangle.X = 108;
75588 rectangle.Y = 18;
75589 break;
75590 case 1:
75591 rectangle.X = 126;
75592 rectangle.Y = 18;
75593 break;
75594 default:
75595 rectangle.X = 144;
75596 rectangle.Y = 18;
75597 break;
75598 }
75599 }
75600 else if (downLeft != num && downRight != num)
75601 {
75602 switch (num27)
75603 {
75604 case 0:
75605 rectangle.X = 108;
75606 rectangle.Y = 36;
75607 break;
75608 case 1:
75609 rectangle.X = 126;
75610 rectangle.Y = 36;
75611 break;
75612 default:
75613 rectangle.X = 144;
75614 rectangle.Y = 36;
75615 break;
75616 }
75617 }
75618 else if (upLeft != num && downLeft != num)
75619 {
75620 switch (num27)
75621 {
75622 case 0:
75623 rectangle.X = 180;
75624 rectangle.Y = 0;
75625 break;
75626 case 1:
75627 rectangle.X = 180;
75628 rectangle.Y = 18;
75629 break;
75630 default:
75631 rectangle.X = 180;
75632 rectangle.Y = 36;
75633 break;
75634 }
75635 }
75636 else if (upRight != num && downRight != num)
75637 {
75638 switch (num27)
75639 {
75640 case 0:
75641 rectangle.X = 198;
75642 rectangle.Y = 0;
75643 break;
75644 case 1:
75645 rectangle.X = 198;
75646 rectangle.Y = 18;
75647 break;
75648 default:
75649 rectangle.X = 198;
75650 rectangle.Y = 36;
75651 break;
75652 }
75653 }
75654 else
75655 {
75656 switch (num27)
75657 {
75658 case 0:
75659 rectangle.X = 18;
75660 rectangle.Y = 18;
75661 break;
75662 case 1:
75663 rectangle.X = 36;
75664 rectangle.Y = 18;
75665 break;
75666 default:
75667 rectangle.X = 54;
75668 rectangle.Y = 18;
75669 break;
75670 }
75671 }
75672 }
75673 else if (up != num && down == num && left == num && right == num)
75674 {
75675 switch (num27)
75676 {
75677 case 0:
75678 rectangle.X = 18;
75679 rectangle.Y = 0;
75680 break;
75681 case 1:
75682 rectangle.X = 36;
75683 rectangle.Y = 0;
75684 break;
75685 default:
75686 rectangle.X = 54;
75687 rectangle.Y = 0;
75688 break;
75689 }
75690 }
75691 else if (up == num && down != num && left == num && right == num)
75692 {
75693 switch (num27)
75694 {
75695 case 0:
75696 rectangle.X = 18;
75697 rectangle.Y = 36;
75698 break;
75699 case 1:
75700 rectangle.X = 36;
75701 rectangle.Y = 36;
75702 break;
75703 default:
75704 rectangle.X = 54;
75705 rectangle.Y = 36;
75706 break;
75707 }
75708 }
75709 else if (up == num && down == num && left != num && right == num)
75710 {
75711 switch (num27)
75712 {
75713 case 0:
75714 rectangle.X = 0;
75715 rectangle.Y = 0;
75716 break;
75717 case 1:
75718 rectangle.X = 0;
75719 rectangle.Y = 18;
75720 break;
75721 default:
75722 rectangle.X = 0;
75723 rectangle.Y = 36;
75724 break;
75725 }
75726 }
75727 else if (up == num && down == num && left == num && right != num)
75728 {
75729 switch (num27)
75730 {
75731 case 0:
75732 rectangle.X = 72;
75733 rectangle.Y = 0;
75734 break;
75735 case 1:
75736 rectangle.X = 72;
75737 rectangle.Y = 18;
75738 break;
75739 default:
75740 rectangle.X = 72;
75741 rectangle.Y = 36;
75742 break;
75743 }
75744 }
75745 else if (up != num && down == num && left != num && right == num)
75746 {
75747 switch (num27)
75748 {
75749 case 0:
75750 rectangle.X = 0;
75751 rectangle.Y = 54;
75752 break;
75753 case 1:
75754 rectangle.X = 36;
75755 rectangle.Y = 54;
75756 break;
75757 default:
75758 rectangle.X = 72;
75759 rectangle.Y = 54;
75760 break;
75761 }
75762 }
75763 else if (up != num && down == num && left == num && right != num)
75764 {
75765 switch (num27)
75766 {
75767 case 0:
75768 rectangle.X = 18;
75769 rectangle.Y = 54;
75770 break;
75771 case 1:
75772 rectangle.X = 54;
75773 rectangle.Y = 54;
75774 break;
75775 default:
75776 rectangle.X = 90;
75777 rectangle.Y = 54;
75778 break;
75779 }
75780 }
75781 else if (up == num && down != num && left != num && right == num)
75782 {
75783 switch (num27)
75784 {
75785 case 0:
75786 rectangle.X = 0;
75787 rectangle.Y = 72;
75788 break;
75789 case 1:
75790 rectangle.X = 36;
75791 rectangle.Y = 72;
75792 break;
75793 default:
75794 rectangle.X = 72;
75795 rectangle.Y = 72;
75796 break;
75797 }
75798 }
75799 else if (up == num && down != num && left == num && right != num)
75800 {
75801 switch (num27)
75802 {
75803 case 0:
75804 rectangle.X = 18;
75805 rectangle.Y = 72;
75806 break;
75807 case 1:
75808 rectangle.X = 54;
75809 rectangle.Y = 72;
75810 break;
75811 default:
75812 rectangle.X = 90;
75813 rectangle.Y = 72;
75814 break;
75815 }
75816 }
75817 else if (up == num && down == num && left != num && right != num)
75818 {
75819 switch (num27)
75820 {
75821 case 0:
75822 rectangle.X = 90;
75823 rectangle.Y = 0;
75824 break;
75825 case 1:
75826 rectangle.X = 90;
75827 rectangle.Y = 18;
75828 break;
75829 default:
75830 rectangle.X = 90;
75831 rectangle.Y = 36;
75832 break;
75833 }
75834 }
75835 else if (up != num && down != num && left == num && right == num)
75836 {
75837 switch (num27)
75838 {
75839 case 0:
75840 rectangle.X = 108;
75841 rectangle.Y = 72;
75842 break;
75843 case 1:
75844 rectangle.X = 126;
75845 rectangle.Y = 72;
75846 break;
75847 default:
75848 rectangle.X = 144;
75849 rectangle.Y = 72;
75850 break;
75851 }
75852 }
75853 else if (up != num && down == num && left != num && right != num)
75854 {
75855 switch (num27)
75856 {
75857 case 0:
75858 rectangle.X = 108;
75859 rectangle.Y = 0;
75860 break;
75861 case 1:
75862 rectangle.X = 126;
75863 rectangle.Y = 0;
75864 break;
75865 default:
75866 rectangle.X = 144;
75867 rectangle.Y = 0;
75868 break;
75869 }
75870 }
75871 else if (up == num && down != num && left != num && right != num)
75872 {
75873 switch (num27)
75874 {
75875 case 0:
75876 rectangle.X = 108;
75877 rectangle.Y = 54;
75878 break;
75879 case 1:
75880 rectangle.X = 126;
75881 rectangle.Y = 54;
75882 break;
75883 default:
75884 rectangle.X = 144;
75885 rectangle.Y = 54;
75886 break;
75887 }
75888 }
75889 else if (up != num && down != num && left != num && right == num)
75890 {
75891 switch (num27)
75892 {
75893 case 0:
75894 rectangle.X = 162;
75895 rectangle.Y = 0;
75896 break;
75897 case 1:
75898 rectangle.X = 162;
75899 rectangle.Y = 18;
75900 break;
75901 default:
75902 rectangle.X = 162;
75903 rectangle.Y = 36;
75904 break;
75905 }
75906 }
75907 else if (up != num && down != num && left == num && right != num)
75908 {
75909 switch (num27)
75910 {
75911 case 0:
75912 rectangle.X = 216;
75913 rectangle.Y = 0;
75914 break;
75915 case 1:
75916 rectangle.X = 216;
75917 rectangle.Y = 18;
75918 break;
75919 default:
75920 rectangle.X = 216;
75921 rectangle.Y = 36;
75922 break;
75923 }
75924 }
75925 else if (up != num && down != num && left != num && right != num)
75926 {
75927 switch (num27)
75928 {
75929 case 0:
75930 rectangle.X = 162;
75931 rectangle.Y = 54;
75932 break;
75933 case 1:
75934 rectangle.X = 180;
75935 rectangle.Y = 54;
75936 break;
75937 default:
75938 rectangle.X = 198;
75939 rectangle.Y = 54;
75940 break;
75941 }
75942 }
75943 }
75944 if (rectangle.X <= -1 || rectangle.Y <= -1)
75945 {
75946 if (num27 <= 0)
75947 {
75948 rectangle.X = 18;
75949 rectangle.Y = 18;
75950 }
75951 else if (num27 == 1)
75952 {
75953 rectangle.X = 36;
75954 rectangle.Y = 18;
75955 }
75956 if (num27 >= 2)
75957 {
75958 rectangle.X = 54;
75959 rectangle.Y = 18;
75960 }
75961 }
75962 if (Main.tileLargeFrames[num] == 1 && num27 == 3)
75963 {
75964 rectangle.Y += 90;
75965 }
75966 if (Main.tileLargeFrames[num] == 2 && num27 == 3)
75967 {
75968 rectangle.Y += 90;
75969 }
75970 tile.frameX = (short)rectangle.X;
75971 tile.frameY = (short)rectangle.Y;
75972 if (TileID.Sets.IsVine[num])
75973 {
75974 up = ((tile2 == null) ? num : ((!tile2.nactive()) ? (-1) : ((!tile2.bottomSlope()) ? tile2.type : (-1))));
75975 if (num != up)
75976 {
75977 bool num45 = up == 60 || up == 62;
75978 bool num46 = up == 109 || up == 115;
75979 bool flag9 = up == 23 || up == 636 || up == 661;
75980 bool flag10 = up == 199 || up == 205 || up == 662;
75981 bool flag11 = up == 2 || up == 52;
75982 bool flag12 = up == 382;
75983 bool num47 = up == 70 || up == 528;
75984 bool num48 = up == 633 || up == 638;
75985 ushort num49 = 0;
75986 if (num48)
75987 {
75988 num49 = 638;
75989 }
75990 if (num47)
75991 {
75992 num49 = 528;
75993 }
75994 if (num46)
75995 {
75996 num49 = 115;
75997 }
75998 if (num45)
75999 {
76000 num49 = 62;
76001 }
76002 if (flag9)
76003 {
76004 num49 = 636;
76005 }
76006 if (flag10)
76007 {
76008 num49 = 205;
76009 }
76010 if (flag11 && num != 382)
76011 {
76012 num49 = 52;
76013 }
76014 if (flag12)
76015 {
76016 num49 = 382;
76017 }
76018 if (num49 != 0 && num49 != num)
76019 {
76020 tile.type = num49;
76021 SquareTileFrame(i, j);
76022 return;
76023 }
76024 }
76025 if (up != num)
76026 {
76027 bool flag13 = false;
76028 if (up == -1)
76029 {
76030 flag13 = true;
76031 }
76032 if (num == 52 && up != 2 && up != 192)
76033 {
76034 flag13 = true;
76035 }
76036 if (num == 382 && up != 2 && up != 192)
76037 {
76038 flag13 = true;
76039 }
76040 if (num == 62 && up != 60)
76041 {
76042 flag13 = true;
76043 }
76044 if (num == 115 && up != 109)
76045 {
76046 flag13 = true;
76047 }
76048 if (num == 528 && up != 70)
76049 {
76050 flag13 = true;
76051 }
76052 if (num == 636 && up != 23 && up != 661)
76053 {
76054 flag13 = true;
76055 }
76056 if (num == 205 && up != 199 && up != 662)
76057 {
76058 flag13 = true;
76059 }
76060 if (num == 638 && up != 633)
76061 {
76062 flag13 = true;
76063 }
76064 if (flag13)
76065 {
76066 KillTile(i, j);
76067 }
76068 }
76069 }
76070 bool flag14 = false;
76071 if (!noTileActions && tile.active() && TileID.Sets.Falling[num])
76072 {
76073 SpawnFallingBlockProjectile(i, j, tile, tile2, tile3, num);
76074 }
76075 if ((rectangle.X != frameX && rectangle.Y != frameY && frameX >= 0 && frameY >= 0) || flag14)
76076 {
76077 tileReframeCount++;
76078 if (tileReframeCount < 25)
76079 {
76080 bool num50 = mergeUp;
76081 bool flag15 = mergeDown;
76082 bool flag16 = mergeLeft;
76083 bool flag17 = mergeRight;
76084 TileFrame(i - 1, j);
76085 TileFrame(i + 1, j);
76086 TileFrame(i, j - 1);
76087 TileFrame(i, j + 1);
76088 mergeUp = num50;
76089 mergeDown = flag15;
76090 mergeLeft = flag16;
76091 mergeRight = flag17;
76092 }
76093 tileReframeCount--;
76094 }
76095 goto end_IL_0002;
76096 }
76097 }
76098 }
76099 Framing.SelfFrame8Way(i, j, tile, resetFrame);
76100 return;
76101 }
76102 }
76103 end_IL_0002:;
76104 }
76105 catch
76106 {
76107 }
76108 if (i > 0 && j > 0)
76109 {
76110 UpdateMapTile(i, j, addToList);
76111 }
76112 }
76113
76115 {
76116 if (currentMerge > -1 && block.invisibleBlock() != wantedInvisibilityState)
76117 {
76118 currentMerge = -1;
76119 }
76120 }
76121
76122 private static bool SpawnFallingBlockProjectile(int i, int j, Tile tileCache, Tile tileTopCache, Tile tileBottomCache, int type)
76123 {
76124 if (Main.netMode == 1)
76125 {
76126 return false;
76127 }
76128 if (tileCache == null || tileTopCache == null || tileBottomCache == null)
76129 {
76130 return false;
76131 }
76132 if (!BlockBelowMakesSandFall(i, j))
76133 {
76134 return false;
76135 }
76136 if (!AllowsSandfall(tileTopCache))
76137 {
76138 return false;
76139 }
76140 GetSandfallProjData(type, out var projType, out var dmg);
76141 tileCache.ClearTile();
76142 if (Main.netMode == 0)
76143 {
76144 int num = Projectile.NewProjectile(GetProjectileSource_TileBreak(i, j), i * 16 + 8, j * 16 + 8, 0f, 0.41f, projType, dmg, 0f, Main.myPlayer);
76145 Main.projectile[num].ai[0] = 1f;
76146 SquareTileFrame(i, j);
76147 }
76148 if (Main.netMode == 2)
76149 {
76150 bool flag = false;
76151 for (int k = 0; k < 1000; k++)
76152 {
76153 if (Main.projectile[k].active && Main.projectile[k].owner == Main.myPlayer && Main.projectile[k].type == projType && Math.Abs(Main.projectile[k].timeLeft - 3600) < 60 && Main.projectile[k].Distance(new Vector2(i * 16 + 8, j * 16 + 10)) < 4f)
76154 {
76155 flag = true;
76156 break;
76157 }
76158 }
76159 if (!flag)
76160 {
76161 int num2 = Projectile.NewProjectile(GetProjectileSource_TileBreak(i, j), i * 16 + 8, j * 16 + 8, 0f, 2.5f, projType, dmg, 0f, Main.myPlayer);
76162 Main.projectile[num2].velocity.Y = 0.5f;
76163 Main.projectile[num2].position.Y += 2f;
76164 Main.projectile[num2].netUpdate = true;
76165 }
76166 SquareTileFrame(i, j);
76167 NetMessage.SendTileSquare(-1, i, j);
76168 ExploitDestroyQueue.Enqueue(new Point(i, j));
76169 ExploitDestroyQueue.Enqueue(new Point(i, j - 1));
76170 }
76171 return true;
76172 }
76173
76174 public static void CheckTorch(int x, int y)
76175 {
76176 for (int i = x - 1; i <= x + 1; i++)
76177 {
76178 for (int j = y - 1; j <= y + 1; j++)
76179 {
76180 if (Main.tile[i, j] == null)
76181 {
76182 return;
76183 }
76184 }
76185 }
76186 Tile tile = Main.tile[x, y];
76187 Tile tile2 = Main.tile[x, y - 1];
76188 Tile tile3 = Main.tile[x, y + 1];
76189 Tile tile4 = Main.tile[x - 1, y];
76190 Tile tile5 = Main.tile[x + 1, y];
76191 Tile tile6 = Main.tile[x - 1, y + 1];
76192 Tile tile7 = Main.tile[x + 1, y + 1];
76193 Tile tile8 = Main.tile[x - 1, y - 1];
76194 Tile tile9 = Main.tile[x + 1, y - 1];
76195 short num = 0;
76196 if (tile.frameX >= 66)
76197 {
76198 num = 66;
76199 }
76200 int num2 = -1;
76201 int num3 = -1;
76202 int num4 = -1;
76203 int tree = -1;
76204 int tree2 = -1;
76205 int tree3 = -1;
76206 int tree4 = -1;
76207 if (tile2 != null && tile2.active() && !tile2.bottomSlope())
76208 {
76209 _ = tile2.type;
76210 }
76211 if (tile3 != null && tile3.active() && ((TileID.Sets.Platforms[tile3.type] && TopEdgeCanBeAttachedTo(x, y + 1)) || (!tile3.halfBrick() && !tile3.topSlope())))
76212 {
76213 num2 = tile3.type;
76214 }
76215 if (tile4 != null && tile4.active() && (tile4.slope() == 0 || tile4.slope() % 2 != 1))
76216 {
76217 num3 = tile4.type;
76218 }
76219 if (tile5 != null && tile5.active() && (tile5.slope() == 0 || tile5.slope() % 2 != 0))
76220 {
76221 num4 = tile5.type;
76222 }
76223 if (tile6 != null && tile6.active())
76224 {
76225 tree = tile6.type;
76226 }
76227 if (tile7 != null && tile7.active())
76228 {
76229 tree2 = tile7.type;
76230 }
76231 if (tile8 != null && tile8.active())
76232 {
76233 tree3 = tile8.type;
76234 }
76235 if (tile9 != null && tile9.active())
76236 {
76237 tree4 = tile9.type;
76238 }
76240 {
76241 tile.frameX = num;
76242 }
76243 else if ((num3 >= 0 && Main.tileSolid[num3] && !Main.tileNoAttach[num3]) || (num3 >= 0 && TileID.Sets.IsBeam[num3]) || (IsTreeType(num3) && IsTreeType(tree3) && IsTreeType(tree)))
76244 {
76245 tile.frameX = (short)(22 + num);
76246 }
76247 else if ((num4 >= 0 && Main.tileSolid[num4] && !Main.tileNoAttach[num4]) || (num4 >= 0 && TileID.Sets.IsBeam[num4]) || (IsTreeType(num4) && IsTreeType(tree4) && IsTreeType(tree2)))
76248 {
76249 tile.frameX = (short)(44 + num);
76250 }
76251 else if (tile.wall > 0)
76252 {
76253 tile.frameX = num;
76254 }
76255 else
76256 {
76257 KillTile(x, y);
76258 }
76259 }
76260
76261 public static void CheckProjectilePressurePad(int i, int j)
76262 {
76263 CheckProjectilePressurePad_GetPossiblePlacementDirections(i, j, out var canUp, out var canLeft, out var canRight, out var canDown);
76264 Tile tile = Main.tile[i, j];
76265 int num = tile.frameX / 22;
76266 bool flag = false;
76267 if (num switch
76268 {
76269 0 => !canDown,
76270 1 => !canUp,
76271 2 => !canLeft,
76272 3 => !canRight,
76273 _ => true,
76274 })
76275 {
76276 if (canDown)
76277 {
76278 tile.frameX = 0;
76279 }
76280 else if (canUp)
76281 {
76282 tile.frameX = 22;
76283 }
76284 else if (canLeft)
76285 {
76286 tile.frameX = 44;
76287 }
76288 else if (canRight)
76289 {
76290 tile.frameX = 66;
76291 }
76292 else
76293 {
76294 KillTile(i, j);
76295 }
76296 }
76297 }
76298
76300 {
76301 canUp = false;
76302 canLeft = false;
76303 canRight = false;
76304 canDown = false;
76305 _ = Main.tile[i, j];
76306 Tile tile = Main.tile[i, j - 1];
76307 Tile tile2 = Main.tile[i, j + 1];
76308 Tile tile3 = Main.tile[i - 1, j];
76309 Tile tile4 = Main.tile[i + 1, j];
76310 Tile tile5 = Main.tile[i - 1, j + 1];
76311 Tile tile6 = Main.tile[i + 1, j + 1];
76312 Tile tile7 = Main.tile[i - 1, j - 1];
76313 Tile tile8 = Main.tile[i + 1, j - 1];
76314 int num = -1;
76315 int num2 = -1;
76316 int num3 = -1;
76317 int num4 = -1;
76318 int tree = -1;
76319 int tree2 = -1;
76320 int tree3 = -1;
76321 int tree4 = -1;
76322 if (tile != null && tile.nactive() && !tile.bottomSlope())
76323 {
76324 num2 = tile.type;
76325 }
76326 if (tile2 != null && tile2.nactive() && !tile2.halfBrick() && !tile2.topSlope())
76327 {
76328 num = tile2.type;
76329 }
76330 if (tile3 != null && tile3.nactive() && (tile3.slope() == 0 || tile3.slope() % 2 != 1))
76331 {
76332 num3 = tile3.type;
76333 }
76334 if (tile4 != null && tile4.nactive() && (tile4.slope() == 0 || tile4.slope() % 2 != 0))
76335 {
76336 num4 = tile4.type;
76337 }
76338 if (tile5 != null && tile5.nactive())
76339 {
76340 tree = tile5.type;
76341 }
76342 if (tile6 != null && tile6.nactive())
76343 {
76344 tree2 = tile6.type;
76345 }
76346 if (tile7 != null && tile7.nactive())
76347 {
76348 tree3 = tile7.type;
76349 }
76350 if (tile8 != null && tile8.nactive())
76351 {
76352 tree4 = tile8.type;
76353 }
76354 if (num >= 0 && Main.tileSolid[num] && (!Main.tileNoAttach[num] || TileID.Sets.Platforms[num]) && (tile2.bottomSlope() || tile2.slope() == 0) && !tile2.halfBrick())
76355 {
76356 canDown = true;
76357 }
76358 if (num2 >= 0 && Main.tileSolid[num2] && (!Main.tileNoAttach[num2] || (TileID.Sets.Platforms[num2] && tile.halfBrick())) && (tile.topSlope() || tile.slope() == 0 || tile.halfBrick()))
76359 {
76360 canUp = true;
76361 }
76362 if ((num3 >= 0 && Main.tileSolid[num3] && !Main.tileNoAttach[num3] && (tile3.leftSlope() || tile3.slope() == 0) && !tile3.halfBrick()) || (num3 >= 0 && TileID.Sets.IsBeam[num3]) || (IsTreeType(num3) && IsTreeType(tree3) && IsTreeType(tree)))
76363 {
76364 canLeft = true;
76365 }
76366 if ((num4 >= 0 && Main.tileSolid[num4] && !Main.tileNoAttach[num4] && (tile4.rightSlope() || tile4.slope() == 0) && !tile4.halfBrick()) || (num4 >= 0 && TileID.Sets.IsBeam[num4]) || (IsTreeType(num4) && IsTreeType(tree4) && IsTreeType(tree2)))
76367 {
76368 canRight = true;
76369 }
76370 }
76371
76372 public static bool IsTreeType(int tree)
76373 {
76374 if (tree >= 0)
76375 {
76376 return TileID.Sets.IsATreeTrunk[tree];
76377 }
76378 return false;
76379 }
76380
76381 public static int CanPlaceProjectilePressurePad(int x, int y, int type = 442, int style = 0, int direction = 0, int alternate = 0)
76382 {
76383 CheckProjectilePressurePad_GetPossiblePlacementDirections(x, y, out var canUp, out var canLeft, out var canRight, out var canDown);
76384 if (!canUp && !canDown && !canLeft && !canRight)
76385 {
76386 return -1;
76387 }
76388 switch (alternate)
76389 {
76390 case 0:
76391 if (!canDown)
76392 {
76393 return -1;
76394 }
76395 break;
76396 case 1:
76397 if (!canUp)
76398 {
76399 return -1;
76400 }
76401 break;
76402 case 2:
76403 if (!canLeft)
76404 {
76405 return -1;
76406 }
76407 break;
76408 case 3:
76409 if (!canRight)
76410 {
76411 return -1;
76412 }
76413 break;
76414 }
76415 return style;
76416 }
76417
76418 private static void CheckDoorOpen(int i, int j, Tile tileCache)
76419 {
76420 if (destroyObject)
76421 {
76422 return;
76423 }
76424 int num = 0;
76425 int num2 = i;
76426 int num3 = j;
76427 short frameX = tileCache.frameX;
76428 int frameY = tileCache.frameY;
76429 int num4 = frameY / 54;
76430 num4 += tileCache.frameX / 72 * 36;
76431 num3 = j - frameY % 54 / 18;
76432 bool flag = false;
76433 switch (frameX % 72)
76434 {
76435 case 0:
76436 num2 = i;
76437 num = 1;
76438 break;
76439 case 18:
76440 num2 = i - 1;
76441 num = 1;
76442 break;
76443 case 36:
76444 num2 = i + 1;
76445 num = -1;
76446 break;
76447 case 54:
76448 num2 = i;
76449 num = -1;
76450 break;
76451 }
76452 Tile tile = Main.tile[num2, num3 - 1];
76453 Tile tile2 = Main.tile[num2, num3 + 3];
76454 if (tile == null)
76455 {
76456 tile = new Tile();
76457 Main.tile[num2, num3 - 1] = tile;
76458 }
76459 if (tile2 == null)
76460 {
76461 tile2 = new Tile();
76462 Main.tile[num2, num3 + 3] = tile2;
76463 }
76464 if (!SolidTile(tile) || !SolidTile(tile2))
76465 {
76466 flag = true;
76467 destroyObject = true;
76468 DropDoorItem(i, j, num4);
76469 }
76470 int num5 = num2;
76471 if (num == -1)
76472 {
76473 num5 = num2 - 1;
76474 }
76475 for (int k = num5; k < num5 + 2; k++)
76476 {
76477 for (int l = num3; l < num3 + 3; l++)
76478 {
76479 if (!flag)
76480 {
76481 Tile tile3 = Main.tile[k, l];
76482 if (!tile3.active() || tile3.type != 11)
76483 {
76484 destroyObject = true;
76485 DropDoorItem(i, j, num4);
76486 flag = true;
76487 k = num5;
76488 l = num3;
76489 }
76490 }
76491 if (flag)
76492 {
76493 KillTile(k, l);
76494 }
76495 }
76496 }
76497 destroyObject = false;
76498 }
76499
76500 private static void CheckDoorClosed(int i, int j, Tile tileCache, int type)
76501 {
76502 if (!destroyObject)
76503 {
76504 int num = j;
76505 bool flag = false;
76506 int frameY = tileCache.frameY;
76507 int num2 = frameY / 54;
76508 num2 += tileCache.frameX / 54 * 36;
76509 num = j - frameY % 54 / 18;
76510 Tile tile = Main.tile[i, num - 1];
76511 Tile tile2 = Main.tile[i, num];
76512 Tile tile3 = Main.tile[i, num + 1];
76513 Tile tile4 = Main.tile[i, num + 2];
76514 Tile tile5 = Main.tile[i, num + 3];
76515 if (tile == null)
76516 {
76517 tile = new Tile();
76518 Main.tile[i, num - 1] = tile;
76519 }
76520 if (tile2 == null)
76521 {
76522 tile2 = new Tile();
76523 Main.tile[i, num] = tile2;
76524 }
76525 if (tile3 == null)
76526 {
76527 tile3 = new Tile();
76528 Main.tile[i, num + 1] = tile3;
76529 }
76530 if (tile4 == null)
76531 {
76532 tile4 = new Tile();
76533 Main.tile[i, num + 2] = tile4;
76534 }
76535 if (tile5 == null)
76536 {
76537 tile5 = new Tile();
76538 Main.tile[i, num + 3] = tile5;
76539 }
76540 if (!SolidTile(tile))
76541 {
76542 flag = true;
76543 }
76544 if (!SolidTile(tile5))
76545 {
76546 flag = true;
76547 }
76548 if (!tile2.active() || tile2.type != type)
76549 {
76550 flag = true;
76551 }
76552 if (!tile3.active() || tile3.type != type)
76553 {
76554 flag = true;
76555 }
76556 if (!tile4.active() || tile4.type != type)
76557 {
76558 flag = true;
76559 }
76560 if (flag)
76561 {
76562 destroyObject = true;
76563 KillTile(i, num);
76564 KillTile(i, num + 1);
76565 KillTile(i, num + 2);
76566 DropDoorItem(i, j, num2);
76567 }
76568 destroyObject = false;
76569 }
76570 }
76571
76572 private static void GetSandfallProjData(int type, out int projType, out int dmg)
76573 {
76574 dmg = 10;
76575 switch (type)
76576 {
76577 case 112:
76578 projType = 56;
76579 break;
76580 case 59:
76581 projType = 39;
76582 break;
76583 case 116:
76584 projType = 67;
76585 break;
76586 case 123:
76587 projType = 71;
76588 break;
76589 case 224:
76590 projType = 179;
76591 break;
76592 case 234:
76593 projType = 241;
76594 break;
76595 case 330:
76596 projType = 411;
76597 dmg = 0;
76598 break;
76599 case 331:
76600 projType = 412;
76601 dmg = 0;
76602 break;
76603 case 332:
76604 projType = 413;
76605 dmg = 0;
76606 break;
76607 case 333:
76608 projType = 414;
76609 dmg = 0;
76610 break;
76611 case 495:
76612 projType = 812;
76613 break;
76614 default:
76615 projType = 31;
76616 break;
76617 }
76618 }
76619
76620 public static bool BlockBelowMakesSandConvertIntoHardenedSand(int i, int j)
76621 {
76622 bool result = false;
76623 if (j >= Main.maxTilesY - 1)
76624 {
76625 return false;
76626 }
76627 Tile tile = Main.tile[i, j + 1];
76628 if (tile == null)
76629 {
76630 return false;
76631 }
76632 if (!tile.nactive())
76633 {
76634 result = true;
76635 }
76636 else if (tile.type >= 0 && tile.type < TileID.Count && !Main.tileSolid[tile.type])
76637 {
76638 result = true;
76639 }
76640 return result;
76641 }
76642
76643 public static bool BlockBelowMakesSandFall(int i, int j)
76644 {
76645 bool result = false;
76646 if (j >= Main.maxTilesY - 1)
76647 {
76648 return false;
76649 }
76650 Tile tile = Main.tile[i, j + 1];
76651 if (tile == null)
76652 {
76653 return false;
76654 }
76655 if (!tile.nactive())
76656 {
76657 result = true;
76658 }
76659 else if (!Main.tile[i, j + 2].nactive() && (!tile.active() || !Main.tileSolid[tile.type]))
76660 {
76661 result = true;
76662 }
76663 else if (tile.active() && tile.type == 165)
76664 {
76665 result = true;
76666 }
76667 return result;
76668 }
76669
76671 {
76672 if (tileTopCache == null)
76673 {
76674 return false;
76675 }
76676 bool result = true;
76677 if (tileTopCache.active() && (TileID.Sets.BasicChest[tileTopCache.type] || TileID.Sets.BasicChestFake[tileTopCache.type] || tileTopCache.type == 323 || tileTopCache.type == 88 || tileTopCache.type == 80 || tileTopCache.type == 77 || tileTopCache.type == 26 || tileTopCache.type == 475 || tileTopCache.type == 470 || tileTopCache.type == 597))
76678 {
76679 result = false;
76680 }
76681 return result;
76682 }
76683
76684 public static void TriggerLunarApocalypse()
76685 {
76686 List<int> list = new List<int> { 517, 422, 507, 493 };
76687 int[] array = new int[4];
76688 for (int i = 0; i < 4; i++)
76689 {
76690 array[i] = list[Main.rand.Next(list.Count)];
76691 list.Remove(array[i]);
76692 }
76693 int num = Main.maxTilesX / 5;
76694 int num2 = (int)Main.worldSurface;
76695 for (int j = 0; j < 4; j++)
76696 {
76697 int num3 = num * (1 + j);
76698 bool flag = false;
76699 for (int k = 0; k < 30; k++)
76700 {
76701 int num4 = Main.rand.Next(-100, 101);
76703 {
76704 int num5 = Main.rand.Next((int)Main.worldSurface, Main.maxTilesY - 350);
76705 if (!PlayerLOS(num3 + num4 - 10, num5) && !PlayerLOS(num3 + num4 + 10, num5) && !PlayerLOS(num3 + num4 - 10, num5 - 20) && !PlayerLOS(num3 + num4 + 10, num5 - 20))
76706 {
76707 int num6 = NPC.NewNPC(new EntitySource_WorldEvent(), (num3 + num4) * 16, num5 * 16, array[j]);
76708 if (Main.netMode == 2 && num6 < 200)
76709 {
76710 NetMessage.SendData(23, -1, -1, null, num6);
76711 }
76712 flag = true;
76713 break;
76714 }
76715 continue;
76716 }
76717 for (int num7 = num2; num7 > 100; num7--)
76718 {
76719 if (!Collision.SolidTiles(num3 + num4 - 10, num3 + num4 + 10, num7 - 20, num7 + 15) && !PlayerLOS(num3 + num4 - 10, num7) && !PlayerLOS(num3 + num4 + 10, num7) && !PlayerLOS(num3 + num4 - 10, num7 - 20) && !PlayerLOS(num3 + num4 + 10, num7 - 20))
76720 {
76721 int num8 = NPC.NewNPC(new EntitySource_WorldEvent(), (num3 + num4) * 16, num7 * 16, array[j]);
76722 if (Main.netMode == 2 && num8 < 200)
76723 {
76724 NetMessage.SendData(23, -1, -1, null, num8);
76725 }
76726 flag = true;
76727 break;
76728 }
76729 }
76730 if (flag)
76731 {
76732 break;
76733 }
76734 }
76735 if (!flag)
76736 {
76737 NPC.NewNPC(new EntitySource_WorldEvent(), num3 * 16, (num2 - 40) * 16, array[j]);
76738 }
76739 }
76740 NPC.TowerActiveVortex = (NPC.TowerActiveNebula = (NPC.TowerActiveSolar = (NPC.TowerActiveStardust = true)));
76741 NPC.LunarApocalypseIsUp = true;
76742 NPC.ShieldStrengthTowerSolar = (NPC.ShieldStrengthTowerVortex = (NPC.ShieldStrengthTowerNebula = (NPC.ShieldStrengthTowerStardust = NPC.ShieldStrengthTowerMax)));
76743 NetMessage.SendData(101);
76744 MessageLunarApocalypse();
76745 }
76746
76747 public static void UpdateLunarApocalypse()
76748 {
76750 {
76751 return;
76752 }
76753 bool flag = false;
76754 bool flag2 = false;
76755 bool flag3 = false;
76756 bool flag4 = false;
76757 bool flag5 = false;
76758 for (int i = 0; i < 200; i++)
76759 {
76760 if (Main.npc[i].active)
76761 {
76762 switch (Main.npc[i].type)
76763 {
76764 case 398:
76765 flag = true;
76766 break;
76767 case 517:
76768 flag2 = true;
76769 break;
76770 case 422:
76771 flag3 = true;
76772 break;
76773 case 507:
76774 flag4 = true;
76775 break;
76776 case 493:
76777 flag5 = true;
76778 break;
76779 }
76780 }
76781 }
76782 if (!flag2)
76783 {
76784 NPC.TowerActiveSolar = false;
76785 }
76786 if (!flag3)
76787 {
76788 NPC.TowerActiveVortex = false;
76789 }
76790 if (!flag4)
76791 {
76792 NPC.TowerActiveNebula = false;
76793 }
76794 if (!flag5)
76795 {
76796 NPC.TowerActiveStardust = false;
76797 }
76799 {
76800 StartImpendingDoom(3600);
76801 }
76802 }
76803
76804 public static void StartImpendingDoom(int countdownTime)
76805 {
76806 NPC.LunarApocalypseIsUp = false;
76807 NPC.MaxMoonLordCountdown = countdownTime;
76808 NPC.MoonLordCountdown = NPC.MaxMoonLordCountdown;
76809 NetMessage.SendData(103);
76810 BroadcastText(NetworkText.FromKey(Lang.misc[52].Key), 50, 255, 130);
76811 if (Main.netMode != 1)
76812 {
76813 GetRidOfCultists();
76814 }
76815 }
76816
76817 public static void GetRidOfCultists()
76818 {
76819 for (int i = 0; i < 200; i++)
76820 {
76821 if (Main.npc[i].active && (Main.npc[i].type == 437 || Main.npc[i].type == 438 || Main.npc[i].type == 379))
76822 {
76823 Main.npc[i].active = false;
76824 if (Main.netMode != 1)
76825 {
76826 NetMessage.SendData(23, -1, -1, null, i);
76827 }
76828 }
76829 }
76830 }
76831
76832 public static void MessageLunarApocalypse()
76833 {
76835 {
76836 int num = 0;
76837 if (!NPC.TowerActiveSolar)
76838 {
76839 num++;
76840 }
76842 {
76843 num++;
76844 }
76846 {
76847 num++;
76848 }
76850 {
76851 num++;
76852 }
76853 BroadcastText(NetworkText.FromKey(Lang.misc[43 + num].Key), 175, 75, 255);
76854 }
76855 }
76856
76857 public static void BroadcastText(NetworkText text, Vector4 color)
76858 {
76859 BroadcastText(text, new Color(color));
76860 }
76861
76862 public static void BroadcastText(NetworkText text, Vector3 color)
76863 {
76864 BroadcastText(text, new Color(color));
76865 }
76866
76867 public static void BroadcastText(NetworkText text, int r, int g, int b)
76868 {
76869 BroadcastText(text, new Color(r, g, b));
76870 }
76871
76872 public static void BroadcastText(NetworkText text, byte r, byte g, byte b)
76873 {
76874 BroadcastText(text, new Color(r, g, b));
76875 }
76876
76877 public static void BroadcastText(NetworkText text, Color color)
76878 {
76879 if (Main.netMode == 0)
76880 {
76881 Main.NewText(text.ToString(), color.R, color.G, color.B);
76882 }
76883 else if (Main.netMode == 2)
76884 {
76886 }
76887 }
76888
76889 public static bool CanCutTile(int x, int y, TileCuttingContext context)
76890 {
76891 if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380 && Main.tile[x, y + 1].type != 579)
76892 {
76893 if (Main.tile[x, y].type == 254)
76894 {
76895 return Main.tile[x, y].frameX >= 144;
76896 }
76897 return true;
76898 }
76899 return false;
76900 }
76901
76902 public static bool InAPlaceWithWind(Vector2 position, int width, int height)
76903 {
76904 Point point = position.ToTileCoordinates();
76905 Point point2 = (position + new Vector2(width, height)).ToTileCoordinates();
76906 return InAPlaceWithWind(point.X, point.Y, 1 + point2.X - point.X, 1 + point2.Y - point.Y);
76907 }
76908
76909 public static bool DoesWindBlowAtThisHeight(int tileY)
76910 {
76911 bool flag = (double)tileY < Main.worldSurface;
76912 if (Main.remixWorld)
76913 {
76914 flag = !flag;
76915 }
76916 return flag;
76917 }
76918
76919 public static bool InAPlaceWithWind(int x, int y, int width, int height)
76920 {
76921 if (!DoesWindBlowAtThisHeight(y))
76922 {
76923 return false;
76924 }
76925 for (int i = 0; i < width; i++)
76926 {
76927 for (int j = 0; j < height; j++)
76928 {
76929 Tile tile = Main.tile[x + i, y + j];
76930 if (tile == null)
76931 {
76932 return false;
76933 }
76934 if (tile.liquid > 0 || (tile.wall > 0 && !WallID.Sets.AllowsWind[tile.wall]))
76935 {
76936 return false;
76937 }
76938 }
76939 }
76940 return true;
76941 }
76942
76943 public static int[] CountTileTypesInWorld(params int[] oreTypes)
76944 {
76945 int[] array = new int[oreTypes.Length];
76946 for (int i = 0; i < Main.maxTilesX; i++)
76947 {
76948 for (int j = 0; j < Main.maxTilesY; j++)
76949 {
76950 Tile tile = Main.tile[i, j];
76951 if (!tile.active())
76952 {
76953 continue;
76954 }
76955 for (int k = 0; k < oreTypes.Length; k++)
76956 {
76957 if (oreTypes[k] == tile.type)
76958 {
76959 array[k]++;
76960 break;
76961 }
76962 }
76963 }
76964 }
76965 return array;
76966 }
76967}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static unsafe void Clear(Array array)
Definition Array.cs:755
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
static void WriteLine()
Definition Console.cs:733
static double Cos(double d)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sqrt(double d)
static double Pow(double x, double y)
static decimal Round(decimal d)
Definition Math.cs:1096
static double Ceiling(double a)
static double Abs(double value)
static double Sin(double a)
static int Sign(decimal value)
Definition Math.cs:1202
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static new TaskFactory< TResult > Factory
Definition Task.cs:56
static bool QueueUserWorkItem(WaitCallback callBack)
static void Sleep(int millisecondsTimeout)
Definition Thread.cs:658
static void PlaySound(int type, Vector2 position, int style=1)
static void StopTrackedSounds()
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
static bool DestroyChest(int X, int Y)
Definition Chest.cs:691
static bool IsLocked(int x, int y)
Definition Chest.cs:235
static int[] chestItemSpawn
Definition Chest.cs:23
static int CreateChest(int X, int Y, int id=-1)
Definition Chest.cs:645
Item[] item
Definition Chest.cs:41
static int[] chestItemSpawn2
Definition Chest.cs:29
static bool NearOtherChests(int x, int y)
Definition Chest.cs:591
static void SetupTravelShop()
Definition Chest.cs:1303
static int FindChest(int X, int Y)
Definition Chest.cs:546
static bool CanDestroyChest(int X, int Y)
Definition Chest.cs:670
static void resetClouds()
Definition Cloud.cs:36
static bool CanHit(Entity source, Entity target)
Definition Collision.cs:344
static bool CanHitLine(Vector2 Position1, int Width1, int Height1, Vector2 Position2, int Width2, int Height2)
Definition Collision.cs:551
static bool EmptyTile(int i, int j, bool ignoreTiles=false)
static bool SolidCollision(Vector2 Position, int Width, int Height)
static bool SolidTiles(Vector2 position, int width, int height)
static void clearAll()
static Dictionary< int, TileEntity > ByID
Definition TileEntity.cs:18
static bool CheckStopForSolids(int x, int y)
static int NewDust(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:73
static Dust NewDustDirect(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:63
Vector2 Center
Definition Entity.cs:43
static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame)
Definition Framing.cs:201
static void WallFrame(int i, int j, bool resetFrame=false)
Definition Framing.cs:334
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:419
static void NotifyTileDestroyed(Player player, ushort tile)
static bool CanPlace(Point origin, StructureMap structures)
static void Framing_CheckTile(int callX, int callY)
static bool IsBreakable(int clickX, int clickY)
static bool IsBreakable(int clickX, int clickY)
Definition TEHatRack.cs:506
static void Framing_CheckTile(int callX, int callY)
Definition TEHatRack.cs:171
static void Framing_CheckTile(int callX, int callY)
static Gore NewGoreDirect(Vector2 Position, Vector2 Velocity, int Type, float Scale=1f)
Definition Gore.cs:1283
static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale=1f)
Definition Gore.cs:1288
static int[] OverflowProtectionTimeOffset
Definition ItemID.cs:71
static bool[] IsTownPet
Definition NPCID.cs:4099
static readonly short Count
Definition NPCID.cs:11744
static readonly LegacySoundStyle LiquidsHoneyWater
Definition SoundID.cs:782
static readonly LegacySoundStyle Item50
Definition SoundID.cs:514
static readonly LegacySoundStyle Item127
Definition SoundID.cs:668
static readonly LegacySoundStyle LiquidsWaterLava
Definition SoundID.cs:786
static readonly LegacySoundStyle LiquidsHoneyLava
Definition SoundID.cs:784
static readonly LegacySoundStyle Item173
Definition SoundID.cs:760
static readonly LegacySoundStyle Item27
Definition SoundID.cs:468
static readonly LegacySoundStyle Item49
Definition SoundID.cs:512
static readonly LegacySoundStyle Item30
Definition SoundID.cs:474
static readonly LegacySoundStyle Item48
Definition SoundID.cs:510
static readonly LegacySoundStyle Item177
Definition SoundID.cs:768
static readonly LegacySoundStyle Item52
Definition SoundID.cs:518
static bool[] MergesWithDirtInASpecialWay
Definition TileID.cs:12
static bool[] GrassSpecial
Definition TileID.cs:211
static bool[] Crimson
Definition TileID.cs:249
static bool[] ResetsHalfBrickPlacementAttempt
Definition TileID.cs:111
static bool[] PreventsTileRemovalIfOnTopOfIt
Definition TileID.cs:99
static bool[] ForcedDirtMerging
Definition TileID.cs:115
static bool[] SpreadOverground
Definition TileID.cs:307
static bool[] Mud
Definition TileID.cs:199
static bool[] IsVine
Definition TileID.cs:159
static bool[] Boulders
Definition TileID.cs:123
static List< int > HallowCountCollection
Definition TileID.cs:237
static bool[] GetsCheckedForLeaves
Definition TileID.cs:97
static bool[] HasSlopeFrames
Definition TileID.cs:183
static bool[] Ash
Definition TileID.cs:201
static bool[] AllTiles
Definition TileID.cs:195
static bool[] IsATrigger
Definition TileID.cs:301
static int[] NeedsGrassFramingDirt
Definition TileID.cs:265
static bool[] BreakableWhenPlacing
Definition TileID.cs:277
static bool[] GetsDestroyedForMeteors
Definition TileID.cs:95
static bool[] PreventsTileReplaceIfOnTopOfIt
Definition TileID.cs:101
static List< int > CrimsonCountCollection
Definition TileID.cs:245
static bool[] SpreadUnderground
Definition TileID.cs:309
static bool[] IsBeam
Definition TileID.cs:161
static bool[] NeedsGrassFraming
Definition TileID.cs:263
static bool[] Paintings
Definition TileID.cs:117
static bool[] ChecksForMerge
Definition TileID.cs:267
static bool[] tileMossBrick
Definition TileID.cs:219
static bool[] CrackedBricks
Definition TileID.cs:113
static bool[] Falling
Definition TileID.cs:289
static bool[] IsAMechanism
Definition TileID.cs:299
static bool[] JungleSpecial
Definition TileID.cs:213
static bool[] BasicDresser
Definition TileID.cs:227
static bool[] IgnoredInHouseScore
Definition TileID.cs:305
static bool[] FramesOnKillWall
Definition TileID.cs:269
static bool[] BlocksWaterDrawingBehindSelf
Definition TileID.cs:259
static bool[] IcesSnow
Definition TileID.cs:209
static bool[] CommonSapling
Definition TileID.cs:103
static bool[] Dirt
Definition TileID.cs:197
static bool[] OreMergesWithMud
Definition TileID.cs:293
static bool[] IsShakeable
Definition TileID.cs:93
static bool[] Ices
Definition TileID.cs:205
static bool[] SlowlyDiesInWater
Definition TileID.cs:169
static bool[] BlockMergesWithMergeAllBlock
Definition TileID.cs:291
static bool[] NotReallySolid
Definition TileID.cs:257
static bool[] Snow
Definition TileID.cs:203
static bool[] BasicChest
Definition TileID.cs:223
static bool[] BasicChestFake
Definition TileID.cs:225
static bool[] Clouds
Definition TileID.cs:125
static bool[] Ore
Definition TileID.cs:295
static bool[] CanBeClearedDuringGeneration
Definition TileID.cs:229
static bool[] Platforms
Definition TileID.cs:163
static bool[] IcesSlush
Definition TileID.cs:207
static bool[] ReplaceTileBreakUp
Definition TileID.cs:165
static List< int > CorruptCountCollection
Definition TileID.cs:231
static bool[] Corrupt
Definition TileID.cs:235
static bool[] ReplaceTileBreakDown
Definition TileID.cs:167
static bool[] IsATreeTrunk
Definition TileID.cs:91
static bool[] MergesWithClouds
Definition TileID.cs:121
static bool[] CanGrowCrystalShards
Definition TileID.cs:243
static bool[] Hallow
Definition TileID.cs:241
static bool[] HellSpecial
Definition TileID.cs:215
static bool[] HousingWalls
Definition TileID.cs:275
static readonly ushort Count
Definition TileID.cs:1698
static readonly short Count
Definition TorchID.cs:132
static int[] Dust
Definition TorchID.cs:75
static bool[] Corrupt
Definition WallID.cs:42
static bool[] CannotBeReplacedByWallSpread
Definition WallID.cs:52
static bool[] Crimson
Definition WallID.cs:44
static bool[] AllowsPlantsToGrow
Definition WallID.cs:50
static bool[] AllowsWind
Definition WallID.cs:48
static bool[] WallSpreadStopsAtAir
Definition WallID.cs:54
static bool[] CanBeConvertedToGlowingMushroom
Definition WallID.cs:36
static bool[] Hallow
Definition WallID.cs:46
static readonly ushort Count
Definition WallID.cs:753
static FileMetadata FromCurrentSettings(FileType type)
override void SetAsActive()
static void LoadWorld(bool loadFromCloud)
Definition WorldFile.cs:576
static void ResetTemps()
Definition WorldFile.cs:549
static void CacheSaveTime()
Definition WorldFile.cs:187
static void SaveWorld()
Definition WorldFile.cs:780
static void SetOngoingToTemps()
Definition WorldFile.cs:211
int stack
Definition Item.cs:149
bool Prefix(int prefixWeWant)
Definition Item.cs:487
static int[] legType
Definition Item.cs:73
static int[] headType
Definition Item.cs:69
static int[] bodyType
Definition Item.cs:71
void SetDefaults(int Type=0)
Definition Item.cs:47332
static int NewItem(IEntitySource source, Vector2 pos, Vector2 randomBox, int Type, int Stack=1, bool noBroadcast=false, int prefixGiven=0, bool noGrabDelay=false, bool reverseLookup=false)
Definition Item.cs:49697
static LocalizedText[] inter
Definition Lang.cs:28
static LocalizedText[] gen
Definition Lang.cs:22
static LocalizedText[] misc
Definition Lang.cs:25
static int numLiquidBuffer
static void GetLiquidMergeTypes(int thisLiquidType, out int liquidMergeTileType, out int liquidMergeType, bool waterNearby, bool lavaNearby, bool honeyNearby, bool shimmerNearby)
Definition Liquid.cs:1377
static void tilesIgnoreWater(bool ignoreSolids)
Definition Liquid.cs:67
static int maxLiquid
Definition Liquid.cs:15
static void UpdateLiquid()
Definition Liquid.cs:983
static void ReInit()
Definition Liquid.cs:82
static void AddWater(int x, int y)
Definition Liquid.cs:1160
static int skipCount
Definition Liquid.cs:17
static void QuickWater(int verbose=0, int minY=-1, int maxY=-1)
Definition Liquid.cs:103
static string GetTextValue(string key)
Definition Language.cs:15
static NetworkText FromKey(string key, params object[] substitutions)
static void AnglerQuestSwap()
Definition Main.cs:3518
static bool halloween
Definition Main.cs:688
static bool[] tileCracked
Definition Main.cs:1491
static bool[] tileDungeon
Definition Main.cs:1465
static float windSpeedCurrent
Definition Main.cs:1360
static bool raining
Definition Main.cs:1310
static double time
Definition Main.cs:1284
static bool[] tileMergeDirt
Definition Main.cs:1431
static int maxTilesY
Definition Main.cs:1116
static int[] treeBGSet1
Definition Main.cs:640
static double starGameMath(double value=1.0)
Definition Main.cs:59630
static int[] treeBGSet3
Definition Main.cs:644
static GolfState LocalGolfState
Definition Main.cs:1876
static float cloudAlpha
Definition Main.cs:1302
static bool[] townNPCCanSpawn
Definition Main.cs:570
static int spawnTileY
Definition Main.cs:1811
static void NotifyOfEvent(GameNotificationType type)
Definition Main.cs:15651
static int[] underworldBG
Definition Main.cs:666
static bool[] tileSolidTop
Definition Main.cs:1469
static int desiredWorldTilesUpdateRate
Definition Main.cs:748
static Chest[] chest
Definition Main.cs:1699
static WorldFileData ActiveWorldFileData
Definition Main.cs:1946
static int loadMapLastX
Definition Main.cs:860
static bool[] tileCut
Definition Main.cs:1433
static bool ShouldShowInvisibleWalls()
Definition Main.cs:54895
static Item[] item
Definition Main.cs:1681
static bool[] tileTable
Definition Main.cs:1459
static bool[] countsAsHostForGameplay
Definition Main.cs:1807
static void LoadWorlds()
Definition Main.cs:3642
static UserInterface MenuUI
Definition Main.cs:381
static double worldSurface
Definition Main.cs:1272
static int myPlayer
Definition Main.cs:1801
static int[] treeX
Definition Main.cs:668
static bool[] tilePile
Definition Main.cs:1497
static int DiscoR
Definition Main.cs:1062
static int netMode
Definition Main.cs:2095
static void ResetWindCounter(bool resetExtreme=false)
Definition Main.cs:55675
static bool starGame
Definition Main.cs:2597
static double rockLayer
Definition Main.cs:1274
static bool[] wallDungeon
Definition Main.cs:1443
static bool[] tileLighted
Definition Main.cs:1429
static Gore[] gore
Definition Main.cs:1687
static bool[] wallHouse
Definition Main.cs:1441
static bool expertMode
Definition Main.cs:2737
static CreativeUI CreativeMenu
Definition Main.cs:369
static bool dayTime
Definition Main.cs:1282
static bool dedServ
Definition Main.cs:1226
static bool[] tileMoss
Definition Main.cs:1485
static bool refreshMap
Definition Main.cs:858
static int[] caveBackStyle
Definition Main.cs:674
static bool bloodMoon
Definition Main.cs:1296
static void checkHalloween()
Definition Main.cs:12188
static Main instance
Definition Main.cs:283
static int[] crimsonBG
Definition Main.cs:658
static bool[] tileBrick
Definition Main.cs:1483
static void FixUIScale()
Definition Main.cs:63169
static string worldPathName
Definition Main.cs:2837
static WorldSections sectionManager
Definition Main.cs:395
static bool loadMapLock
Definition Main.cs:862
static TeleportPylonsSystem PylonSystem
Definition Main.cs:1872
static bool[] tileStone
Definition Main.cs:1449
static int[] corruptBG
Definition Main.cs:648
static int moonPhase
Definition Main.cs:1288
static int[] treeMntBGSet3
Definition Main.cs:636
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
Definition Main.cs:61429
static int maxTilesX
Definition Main.cs:1114
static int[] treeMntBGSet2
Definition Main.cs:634
static int dungeonX
Definition Main.cs:1218
static bool[] tileSand
Definition Main.cs:1651
static int[] hallowBG
Definition Main.cs:656
static int DiscoG
Definition Main.cs:1066
static bool[] tileRope
Definition Main.cs:1481
static void GoToWorldSelect()
Definition Main.cs:45201
static int LogicCheckScreenWidth
Definition Main.cs:1896
static bool[] tileAlch
Definition Main.cs:1435
static bool getGoodWorld
Definition Main.cs:341
static int[] treeMntBGSet1
Definition Main.cs:632
static bool[] tileSolid
Definition Main.cs:1471
static List< string > anglerWhoFinishedToday
Definition Main.cs:1845
static Tile[,] tile
Definition Main.cs:1675
static BestiaryUnlocksTracker BestiaryTracker
Definition Main.cs:1868
static int spawnTileX
Definition Main.cs:1809
static void ToggleGameplayUpdates(bool state)
Definition Main.cs:2959
static bool[] tileLavaDeath
Definition Main.cs:1457
static WorldMap Map
Definition Main.cs:1673
static int dungeonY
Definition Main.cs:1220
static PlayerFileData ActivePlayerFileData
Definition Main.cs:1940
static DroneCameraTracker DroneCameraTracker
Definition Main.cs:1878
static bool eclipse
Definition Main.cs:1312
static Projectile[] projectile
Definition Main.cs:1691
static int[] treeBGSet2
Definition Main.cs:642
static bool[] tileBlendAll
Definition Main.cs:1499
static LiquidBuffer[] liquidBuffer
Definition Main.cs:1224
static int invasionType
Definition Main.cs:1970
static int moonType
Definition Main.cs:1397
static int invasionDelay
Definition Main.cs:1976
static int DiscoB
Definition Main.cs:1064
static readonly int offLimitBorderTiles
Definition Main.cs:445
static int[] snowMntBG
Definition Main.cs:652
static int LogicCheckScreenHeight
Definition Main.cs:1898
static ParticleRenderer ParticleSystem_World_OverPlayers
Definition Main.cs:2249
static UnifiedRandom rand
Definition Main.cs:1387
static NPC[] npc
Definition Main.cs:1685
static void UpdateTimeRate()
Definition Main.cs:5760
static bool dontStarveWorld
Definition Main.cs:345
static float maxRaining
Definition Main.cs:1304
static byte[] tileLargeFrames
Definition Main.cs:1477
static bool mapEnabled
Definition Main.cs:906
static int[] timeItemSlotCannotBeReusedFor
Definition Main.cs:1683
static int[] mushroomBG
Definition Main.cs:662
static bool tenthAnniversaryWorld
Definition Main.cs:343
static int[] treeStyle
Definition Main.cs:670
static int[] desertBG
Definition Main.cs:660
static int dayRate
Definition Main.cs:746
static ParticleRenderer ParticleSystem_World_BehindPlayers
Definition Main.cs:2251
static Liquid[] liquid
Definition Main.cs:1222
static int[] snowBG
Definition Main.cs:654
static bool drunkWorld
Definition Main.cs:339
static int UnderworldLayer
Definition Main.cs:2825
static bool[] tileFrameImportant
Definition Main.cs:1495
static bool[][] tileMerge
Definition Main.cs:1507
static int[] caveBackX
Definition Main.cs:672
static int menuMode
Definition Main.cs:2379
static bool mapReady
Definition Main.cs:866
static bool gameMenu
Definition Main.cs:1926
static Player LocalPlayer
Definition Main.cs:2829
static bool[] tileNoAttach
Definition Main.cs:1487
static int[] jungleBG
Definition Main.cs:650
static bool hardMode
Definition Main.cs:1022
static void checkXMas()
Definition Main.cs:12169
static Sign[] sign
Definition Main.cs:1701
static Player[] player
Definition Main.cs:1803
static int[] treeMntBGSet4
Definition Main.cs:638
static int[] treeBGSet4
Definition Main.cs:646
static int invasionSize
Definition Main.cs:1974
static bool remixWorld
Definition Main.cs:349
static Dust[] dust
Definition Main.cs:1677
static short[] updateTileY
Definition MapHelper.cs:172
static int numUpdateTile
Definition MapHelper.cs:168
static int maxUpdateTile
Definition MapHelper.cs:166
static void ResetMapData()
static short[] updateTileX
Definition MapHelper.cs:170
static bool FrameTrack(int i, int j, bool pound, bool mute=false)
Definition Minecart.cs:934
static void PlaceTrack(Tile trackCache, int style)
Definition Minecart.cs:1478
static bool IsPressurePlate(Tile tile)
Definition Minecart.cs:537
static int GetTrackItem(Tile trackCache)
Definition Minecart.cs:1500
static CoinLossRevengeSystem RevengeManager
Definition NPC.cs:439
static bool downedFrost
Definition NPC.cs:357
static int CountNPCS(int Type)
Definition NPC.cs:86664
static bool downedMechBoss2
Definition NPC.cs:425
static int goldCritterChance
Definition NPC.cs:69
static bool downedBoss2
Definition NPC.cs:347
static int ShieldStrengthTowerMax
Definition NPC.cs:785
static bool TowerActiveStardust
Definition NPC.cs:417
static int safeRangeY
Definition NPC.cs:187
static bool downedMechBossAny
Definition NPC.cs:421
static void ResetBadgerHatTime()
Definition NPC.cs:71189
static int MaxMoonLordCountdown
Definition NPC.cs:53
static void ResetKillCount()
Definition NPC.cs:71033
static bool downedBoss1
Definition NPC.cs:345
static bool TowerActiveVortex
Definition NPC.cs:413
static int sWidth
Definition NPC.cs:177
static bool unlockedTruffleSpawn
Definition NPC.cs:331
static bool[] ShimmeredTownNPCs
Definition NPC.cs:97
static bool downedMechBoss3
Definition NPC.cs:427
static bool downedPirates
Definition NPC.cs:359
static bool TowerActiveSolar
Definition NPC.cs:411
static bool AnyNPCs(int Type)
Definition NPC.cs:86689
static int safeRangeX
Definition NPC.cs:185
static bool downedQueenBee
Definition NPC.cs:351
static bool downedGoblins
Definition NPC.cs:355
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static void SpawnOnPlayer(int plr, int Type)
Definition NPC.cs:77311
static void ClearFoundActiveNPCs()
Definition NPC.cs:1257
static bool downedGolemBoss
Definition NPC.cs:365
static bool LunarApocalypseIsUp
Definition NPC.cs:419
static bool downedBoss3
Definition NPC.cs:349
static IEntitySource GetSpawnSourceForTownSpawn()
Definition NPC.cs:87541
static bool downedPlantBoss
Definition NPC.cs:363
static bool TooWindyForButterflies
Definition NPC.cs:850
static IEntitySource GetSpawnSourceForNaturalSpawn()
Definition NPC.cs:87536
static bool TowerActiveNebula
Definition NPC.cs:415
static bool downedMechBoss1
Definition NPC.cs:423
static int GetAvailableAmountOfNPCsToSpawnUpToSlot(int amountWeWant, int highestNPCSlotIndexWeWillPick=100)
Definition NPC.cs:77558
static int sHeight
Definition NPC.cs:179
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)
Definition NetMessage.cs:88
static bool TrySendData(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)
Definition NetMessage.cs:75
static void SendTileSquare(int whoAmi, int tileX, int tileY, int xSize, int ySize, TileChangeType changeType=TileChangeType.None)
static void SendTravelShop(int remoteClient)
static void sendWater(int x, int y)
static void ResetSections()
Definition Netplay.cs:104
static int GetSectionX(int x)
Definition Netplay.cs:774
static int GetSectionY(int y)
Definition Netplay.cs:779
static bool CheckWaterDeath(int type, int style)
static bool CheckLavaDeath(int type, int style)
static TileObjectData GetTileData(int type, int style, int alternate=0)
static float GetClosestRollLuck(Vector2 position, int range)
Definition Player.cs:17876
bool ZoneUnderworldHeight
Definition Player.cs:3145
static void ClearPlayerTempInfo()
Definition Player.cs:51485
bool ZoneGlowshroom
Definition Player.cs:3073
static byte FindClosest(Vector2 Position, int Width, int Height)
Definition Player.cs:4011
static void SavePlayer(PlayerFileData playerFile, bool skipMapSave=false)
Definition Player.cs:51176
static void ClearAll()
Definition PopupText.cs:690
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
static void ClearRain()
Definition Rain.cs:23
static Vector2 GetRainFallVelocity()
Definition Rain.cs:105
static int MushroomTileThreshold
static void KillSign(int x, int y)
Definition Sign.cs:13
static float starfallBoost
Definition Star.cs:33
static void SpawnStars(int s=-1)
Definition Star.cs:84
bool leftSlope()
Definition Tile.cs:327
byte color()
Definition Tile.cs:555
bool wire4()
Definition Tile.cs:413
static void SmoothSlope(int x, int y, bool applyToNeighbors=true, bool sync=false)
Definition Tile.cs:759
bool wire3()
Definition Tile.cs:633
bool bottomSlope()
Definition Tile.cs:317
bool rightSlope()
Definition Tile.cs:337
void liquidType(int liquidType)
Definition Tile.cs:233
bool nactive()
Definition Tile.cs:257
bool fullbrightWall()
Definition Tile.cs:694
bool topSlope()
Definition Tile.cs:307
bool checkingLiquid()
Definition Tile.cs:470
bool invisibleWall()
Definition Tile.cs:521
void ClearBlockPaintAndCoating()
Definition Tile.cs:869
byte liquid
Definition Tile.cs:12
bool inActive()
Definition Tile.cs:582
void ClearWallPaintAndCoating()
Definition Tile.cs:876
bool fullbrightBlock()
Definition Tile.cs:538
short frameY
Definition Tile.cs:24
ushort type
Definition Tile.cs:8
byte frameNumber()
Definition Tile.cs:440
short frameX
Definition Tile.cs:22
bool invisibleBlock()
Definition Tile.cs:504
bool active()
Definition Tile.cs:565
void Clear(TileDataType types)
Definition Tile.cs:711
int blockType()
Definition Tile.cs:219
byte slope()
Definition Tile.cs:684
bool honey()
Definition Tile.cs:379
bool lava()
Definition Tile.cs:362
ushort wall
Definition Tile.cs:10
bool wire2()
Definition Tile.cs:616
byte wallColor()
Definition Tile.cs:352
void ClearTile()
Definition Tile.cs:151
bool actuator()
Definition Tile.cs:667
bool wire()
Definition Tile.cs:599
bool halfBrick()
Definition Tile.cs:650
static bool Exists(string path, bool cloud)
static void Copy(string source, string destination, bool cloud, bool overwrite=true)
static void Delete(string path, bool cloud, bool forceDeleteFile=false)
static double Lerp(double value1, double value2, double amount)
Definition Utils.cs:64
static Vector2 RandomVector2(UnifiedRandom random, float min, float max)
Definition Utils.cs:1823
static bool PlotTileLine(Vector2 start, Vector2 end, float width, TileActionAttempt plot)
Definition Utils.cs:1670
static void ToggleCampFire(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2684
static void Toggle2x2Light(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2527
static void ToggleLampPost(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2563
static void ToggleLamp(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2619
static void ToggleTorch(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2587
static void ToggleFirePlace(int i, int j, Tile theBlock, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2714
static bool running
Definition Wiring.cs:17
static void ClearAll()
Definition Wiring.cs:115
static void ToggleCandle(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2604
static void PokeLogicGate(int lampX, int lampY)
Definition Wiring.cs:354
static void ToggleHolidayLight(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn)
Definition Wiring.cs:2484
static void ToggleHangingLantern(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2501
static void ToggleChandelier(int i, int j, Tile tileCache, bool? forcedStateWhereTrueIsOn, bool doSkipWires)
Definition Wiring.cs:2647
static void SkipWire(int x, int y)
Definition Wiring.cs:105
static void UpdateMech()
Definition Wiring.cs:135
static void HitSwitch(int i, int j)
Definition Wiring.cs:237
static GenAction Chain(params GenAction[] actions)
Definition Actions.cs:470
GenAction Output(ShapeData data)
Definition GenAction.cs:39
static int beachSandRandomWidthRange
Definition GenVars.cs:70
static readonly int oasisHeight
Definition GenVars.cs:298
static int[] floatingIslandHouseY
Definition GenVars.cs:252
static Rectangle UndergroundDesertHiveLocation
Definition GenVars.cs:112
static int[] floatingIslandStyle
Definition GenVars.cs:254
static int beachSandJungleExtraWidth
Definition GenVars.cs:74
static readonly int maxOceanCaveTreasure
Definition GenVars.cs:102
static Point[] oasisPosition
Definition GenVars.cs:294
static readonly int maxTunnels
Definition GenVars.cs:262
static int oceanWaterStartRandomMin
Definition GenVars.cs:84
static Vector2D lastDungeonHall
Definition GenVars.cs:184
static double worldSurfaceHigh
Definition GenVars.cs:42
static int[] floatingIslandHouseX
Definition GenVars.cs:250
static WorldGenConfiguration configuration
Definition GenVars.cs:10
static Point[] oceanCaveTreasure
Definition GenVars.cs:106
static readonly int maxLakes
Definition GenVars.cs:284
static int evilBiomeBeachAvoidance
Definition GenVars.cs:90
static int smallHolesBeachAvoidance
Definition GenVars.cs:96
static Vector2D shimmerPosition
Definition GenVars.cs:310
static double worldSurfaceLow
Definition GenVars.cs:38
static int oceanWaterForcedJungleLength
Definition GenVars.cs:88
static Point[] mushroomBiomesPosition
Definition GenVars.cs:278
static int surfaceCavesBeachAvoidance2
Definition GenVars.cs:100
static readonly int maxMushroomBiomes
Definition GenVars.cs:274
static List< int > StatuesWithTraps
Definition GenVars.cs:306
static int oceanWaterStartRandomMax
Definition GenVars.cs:86
static int beachSandDungeonExtraWidth
Definition GenVars.cs:72
static readonly int maxOasis
Definition GenVars.cs:290
static StructureMap structures
Definition GenVars.cs:12
static Point16[] statueList
Definition GenVars.cs:304
static int evilBiomeAvoidanceMidFixer
Definition GenVars.cs:92
static readonly int maxOrePatch
Definition GenVars.cs:268
static Rectangle UndergroundDesertLocation
Definition GenVars.cs:110
static double rockLayerHigh
Definition GenVars.cs:48
static WorldGenConfiguration FromEmbeddedPath(string path)
static void WireLine(Point start, Point end)
Definition WorldUtils.cs:81
static bool Gen(Point origin, GenShape shape, GenAction action)
Definition WorldUtils.cs:17
static GrowTreeSettings GemTree_Emerald
Definition WorldGen.cs:674
static GrowTreeSettings GemTree_Sappphire
Definition WorldGen.cs:663
static GrowTreeSettings VanityTree_Willow
Definition WorldGen.cs:707
static GrowTreeSettings GemTree_Diamond
Definition WorldGen.cs:630
static GrowTreeSettings GemTree_Topaz
Definition WorldGen.cs:641
static bool TryGetFromItemId(int itemType, out GrowTreeSettings profile)
Definition WorldGen.cs:729
static GrowTreeSettings VanityTree_Sakura
Definition WorldGen.cs:696
static GrowTreeSettings GemTree_Amethyst
Definition WorldGen.cs:652
static GrowTreeSettings GemTree_Amber
Definition WorldGen.cs:685
static bool TryGetFromTreeId(int tileType, out GrowTreeSettings profile)
Definition WorldGen.cs:766
static void Initialize()
Definition WorldGen.cs:67
static Action OnWorldLoad
Definition WorldGen.cs:65
delegate void WorldGenConfigProcessEvent(ref WorldGenConfiguration config)
static WorldGenConfigProcessEvent OnWorldGenConfigProcess
Definition WorldGen.cs:63
static void ProcessWorldGenConfig(ref WorldGenConfiguration config)
Definition WorldGen.cs:93
static void WorldLoaded()
Definition WorldGen.cs:85
static void Spider(int x, int y)
Definition WorldGen.cs:430
static void Wall(int x, int y, int wallType)
Definition WorldGen.cs:104
static void Moss(int x, int y)
Definition WorldGen.cs:274
static void Wall2(int x, int y, int wallType)
Definition WorldGen.cs:164
static void Gem(int x, int y)
Definition WorldGen.cs:342
static bool Gemmable(int type)
Definition WorldGen.cs:588
static void WallDungeon(int x, int y, int wallType)
Definition WorldGen.cs:529
static int[] treeShakeX
Definition WorldGen.cs:1186
static int[] roomX
Definition WorldGen.cs:1048
static void OreRunner(int i, int j, double strength, int steps, ushort type)
static void GrowAlch(int x, int y)
static int hallowBG
Definition WorldGen.cs:914
static int[,] trapDiag
Definition WorldGen.cs:1124
static bool GeneratePlanteraBulbOnAllMechsDefeated()
static bool tempRemixWorldGen
Definition WorldGen.cs:1146
static void KillTile_GetTreeDrops(int i, int j, Tile tileCache, ref bool bonusWood, ref int dropItem, ref int secondaryItem)
static void UpdateWorld()
static void serverLoadWorldCallBack()
Definition WorldGen.cs:3313
static int _lastSeed
Definition WorldGen.cs:1016
static bool loadFailed
Definition WorldGen.cs:982
static void PlaceChand(int x, int y, ushort type, int style=0)
static void Place6x3(int x, int y, ushort type, int direction=-1, int style=0)
static void StartImpendingDoom(int countdownTime)
static bool IsTileTypeFitForTree(ushort type)
static bool TileEmpty(int i, int j)
static void CheckRockGolemHead(int x, int y)
static Point RandomRectanglePoint(int x, int y, int width, int height)
static void AddGenerationPass(string name, WorldGenLegacyMethod method)
Definition WorldGen.cs:6236
static readonly int cactusWaterHeight
Definition WorldGen.cs:1096
static bool destroyObject
Definition WorldGen.cs:1020
static void UpdateWorld_GrassGrowth(int i, int j, int minI, int maxI, int minJ, int maxJ, bool underground)
static void PaintTheDungeon(byte tilePaintColor, byte wallPaintColor)
static int tileReframeCount
Definition WorldGen.cs:896
static void GetCactusType(int tileX, int tileY, int frameX, int frameY, out bool evil, out bool good, out bool crimson)
static void FixChand(int i, int j)
static void HellRoom(int i, int j, int width, int height, byte type=76, byte wall=13)
static void Check1xX(int x, int j, short type)
static bool AttemptToGrowTreeFromSapling(int x, int y, bool underground)
static EntitySource_ShakeTree GetProjectileSource_ShakeTree(int x, int y)
Definition WorldGen.cs:1323
static bool mergeRight
Definition WorldGen.cs:1002
static bool NoNearbyGlowTulips(int i, int j)
static int SmallConsecutivesEliminated
Definition WorldGen.cs:1144
static void randMoss(bool justNeon=false)
Definition WorldGen.cs:5870
static void KillTile_GetItemDrops(int x, int y, Tile tileCache, out int dropItem, out int dropItemStack, out int secondaryItem, out int secondaryItemStack, bool includeLargeObjectDrops=false)
static bool growGrassUnderground
Definition WorldGen.cs:1194
static void StopMergingByInvsibility(ref int currentMerge, Tile block, bool wantedInvisibilityState)
static int WorldGenParam_Evil
Definition WorldGen.cs:1092
static bool ActiveAndWalkableTile(int i, int j)
static void CloudIsland(int i, int j)
static void setWorldSize()
Definition WorldGen.cs:3013
static void templeCleaner(int x, int y)
static void oceanCave(int i, int j)
static bool IsTreeType(int tree)
static void Check3x2(int i, int j, int type)
static bool BiomeTileCheck(int x, int y)
Definition WorldGen.cs:7113
static ? Rectangle GetTileVisualHitbox(int x, int y)
static int totalEvil2
Definition WorldGen.cs:944
static int mushroomBG
Definition WorldGen.cs:922
static void FixHeart(int i, int j)
static void CrimEnt(Vector2D position, int crimDir)
static void Place2x3Wall(int x, int y, ushort type, int style)
static double MakeDungeon_GroundFurniture(int wallType)
static void ChlorophyteDefense(int x, int y)
const int InfectionAndGrassSpreadOuterWorldBuffer
Definition WorldGen.cs:1120
static void PlaceOasisPlant(int X, int Y, ushort type=530)
static void Check2x2(int i, int j, int type)
static bool IsChestRigged(int x, int y)
static bool IsAContainer(Tile t)
static bool nearPicture(int x, int y)
static void SmashAltar(int i, int j)
static void CheckTree(int i, int j)
static bool AllowedToSpreadInfections
Definition WorldGen.cs:1008
static bool PlaceLiquid(int x, int y, byte liquidType, byte amount)
Definition WorldGen.cs:1371
static bool TryToggleLight(int x, int y, bool? forcedState, bool skipWires)
static PaintingEntry RandHousePictureDesert()
static int maxTreeShakes
Definition WorldGen.cs:1182
static Color coatingColor(int coating)
static bool SolidTileNoAttach(int i, int j)
static bool BottomEdgeCanBeAttachedTo(int i, int j)
static Player GetPlayerForTile(int x, int y)
static void FinishTenthAnniversaryWorld()
static void Check2xX(int i, int j, ushort type)
static int jungleBG
Definition WorldGen.cs:910
static void PaintTheMushrooms()
static int totalSolid
Definition WorldGen.cs:942
static bool placeTNTBarrel(int x, int y)
Definition WorldGen.cs:5132
static void TileMergeAttempt(int myType, bool[] lookfor, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static bool remixWorldGen
Definition WorldGen.cs:1148
static void FixHearts()
static volatile bool gen
Definition WorldGen.cs:972
static void PlantAlch()
static void PlaceLogicTiles(int x, int y, int type, int style=0)
static void GenerateWorld(int seed, GenerationProgress customProgressObject=null)
Definition WorldGen.cs:7175
static bool BlockBelowMakesSandConvertIntoHardenedSand(int i, int j)
static int treeBG2
Definition WorldGen.cs:902
static int totalEvil
Definition WorldGen.cs:936
static void AddShadowOrb(int x, int y)
static void ClearAllBrokenTraps()
static bool TryGrowingGlowTulip(int i, int j)
static void TileMergeAttemptFrametest(int i, int j, int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static int totalSolid2
Definition WorldGen.cs:950
static void MakeDungeon(int x, int y)
static void SwitchMonolith(int i, int j)
static void CheckTallGate(int x, int y, int type)
static int CountNearBlocksTypes(int i, int j, int radius, int cap=0, params int[] tiletypes)
static bool SolidTile(Tile testTile)
static void JustQuit()
Definition WorldGen.cs:3064
static void ReplaceTile_DoActualReplacement_Area(ushort targetType, int targetStyle, int topLeftX, int topLeftY, int areaSizeX, int areaSizeY)
static bool GrowTreeWithSettings(int checkedX, int checkedY, GrowTreeSettings settings)
static void paintEffect(int x, int y, byte color, byte oldColor)
static bool IsLockedDoor(Tile t)
static bool TopEdgeCanBeAttachedTo(int i, int j)
static void Check1x2Top(int x, int j, ushort type)
static void CheckAchievement_RealEstateAndTownSlimes()
Definition WorldGen.cs:2158
static void CheckRoom(int x, int y)
Definition WorldGen.cs:2621
static bool ReplaceTile_IsValidSolid(int type)
const bool BUBBLES_SOLID_STATE_FOR_HOUSING
Definition WorldGen.cs:1196
static Point RandomRectanglePoint(Rectangle rectangle)
static void Place3x2(int x, int y, ushort type, int style=0)
static PaintingEntry RandBonePicture()
static double MakeDungeon_Banners(int[] roomWall, double count)
static ushort randGemTile()
Definition WorldGen.cs:5853
static void SectionTileFrameWithCheck(int startX, int startY, int endX, int endY)
static bool HasValidGroundForGlowTulipBelowSpot(int x, int y)
static int treeBG3
Definition WorldGen.cs:904
static bool PlaceSmallPile(int i, int j, int X, int Y, ushort type=185)
static int shadowOrbCount
Definition WorldGen.cs:976
static bool IsThereASpawnablePrioritizedTownNPC_Old(int x, int y)
Definition WorldGen.cs:1658
static bool SolidTileAllowRightSlope(int i, int j)
static void TryProtectingSpawnedItems()
static int[] roomY
Definition WorldGen.cs:1050
static bool placeLavaTrap(int x, int y)
Definition WorldGen.cs:5016
static bool PlaceWire2(int i, int j)
static TownRoomManager TownManager
Definition WorldGen.cs:892
static void NotTheBees()
static void PlaceUnderwaterPlant(ushort type, int x, int y)
static bool CanPoundTile(int x, int y)
static void CheckLilyPad(int x, int y)
static Vector2D templePather(Vector2D templePath, int destX, int destY)
static void SpawnTravelNPC()
Definition WorldGen.cs:1782
static int treeBG4
Definition WorldGen.cs:906
static bool OpenDoor(int i, int j, int direction)
static bool Place2x2Horizontal(int x, int y, ushort type, int Style=0)
static bool GrowShroom(int i, int y)
static void PaintTheSand(byte tilePaintColor, byte wallPaintColor)
static Dictionary< Point, bool > CountedTiles
Definition WorldGen.cs:1032
static bool Housing_CheckIfIsCeiling(int i, int j)
Definition WorldGen.cs:2550
static bool ScoreRoom_IsThisRoomOccupiedBySomeone(int ignoreNPC=-1, int npcTypeAsking=-1)
Definition WorldGen.cs:2304
static int numTileCount
Definition WorldGen.cs:1026
static bool KillTile_ShouldDropSeeds(int x, int y)
static EntitySource_TileBreak GetNPCSource_TileBreak(int x, int y)
Definition WorldGen.cs:1313
const int WorldSizeMediumX
Definition WorldGen.cs:1112
static void Check6x3(int i, int j, int type)
static void FinishNotTheBees()
static void CheckDoorOpen(int i, int j, Tile tileCache)
static void OreHelper(int X, int Y)
Definition WorldGen.cs:6360
static bool TileIsExposedToAir(int x, int y)
static bool CheckSpecialTownNPCSpawningConditions(int type)
Definition WorldGen.cs:1707
static void UpdateWorld_OvergroundTile(int i, int j, bool checkNPCSpawns, int wallDist)
static bool IsTileReplacable(int x, int y)
static void BroadcastText(NetworkText text, Vector4 color)
static int TileType(int x, int y)
static byte tBlood
Definition WorldGen.cs:954
static bool loadBackup
Definition WorldGen.cs:990
static void SwitchMB(int i, int j)
const int WorldSizeLargeX
Definition WorldGen.cs:1116
static void SetForestBGSet(int style, int[] mountainSet, int[] treeSet)
Definition WorldGen.cs:4027
static bool IsItATrap(Tile tile)
static bool noLiquidCheck
Definition WorldGen.cs:1006
static bool GetCommonTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
static void TileMergeAttempt(int myType, int lookfor, ref int up, ref int down, ref int left, ref int right)
static int roomCeilingsCount
Definition WorldGen.cs:1052
static bool GrowLivingTree_HorizontalTunnel(int i, int j)
static bool InAPlaceWithWind(int x, int y, int width, int height)
static void tileCounterKill()
Definition WorldGen.cs:6226
static void TreeGrowFX(int x, int y, int height, int treeGore, bool hitTree=false)
static void LaunchRocketSmall(int x, int y, bool fromWiring)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static void Check3x3(int i, int j, int type)
const bool USE_FRAMING_SKIP_FOR_UNIMPORTANT_TILES_IN_WORLDGEN
Definition WorldGen.cs:1170
static bool meteor(int i, int j, bool ignorePlayers=false)
Definition WorldGen.cs:2829
static void moveRoom(int x, int y, int n)
Definition WorldGen.cs:1575
static void SwitchCannon(int i, int j)
static void PlantCactus(int i, int j)
static void UndoSpawnedItemProtection()
static bool everythingWorldGen
Definition WorldGen.cs:1150
static void DropDoorItem(int x, int y, int doorStyle)
static void PoundPlatform(int x, int y)
static void CheckAlch(int x, int y)
static bool AttemptToGeneratePlanteraBulbAt(int i, int j, bool forceBulb)
static void FinishDrunkGen()
static void GrowCheckSeaweed(int x, int y)
static void saveAndPlay()
Definition WorldGen.cs:3298
static void QueuePostGenAction(Action< StructureMap > action)
static bool GrowPalmTree(int i, int y)
static void MakeWateryIceThing(int i, int j)
static int GetWorldUpdateRate()
static bool IsBackgroundConsideredTheSame(int oldBG, int newBG)
Definition WorldGen.cs:4404
static readonly int cactusWaterWidth
Definition WorldGen.cs:1094
static void CheckBamboo(int x, int y)
static void KillTile_DropItems(int x, int y, Tile tileCache, bool includeLargeObjectDrops=false)
static void GrowCactus(int i, int j)
static int GetItemDrop_Chair(int style)
static void Check3x2Wall(int x, int y)
static bool TryGrowingTreeByType(int treeTileType, int checkedX, int checkedY)
static int shroomCount
Definition WorldGen.cs:1042
static bool KillWire3(int i, int j)
static bool noTrapsWorldGen
Definition WorldGen.cs:1152
static int roomY2
Definition WorldGen.cs:1064
static bool NoNearbyAbigailsFlower(int i, int j)
static PaintingEntry RandPictureTile()
static bool GrowLivingTree(int i, int j, bool patch=false)
static bool roomTorch
Definition WorldGen.cs:1076
static void Check1x1(int x, int y, int type)
static readonly int shimmerSafetyDistance
Definition WorldGen.cs:930
static bool IsThereASpawnablePrioritizedTownNPC(int x, int y, ref bool canSpawnNewTownNPC)
Definition WorldGen.cs:1612
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static int prioritizedTownNPCType
Definition WorldGen.cs:1024
static void BroadcastText(NetworkText text, int r, int g, int b)
static Task serverLoadWorld()
Definition WorldGen.cs:3368
static bool worldBackup
Definition WorldGen.cs:988
static bool noMapUpdate
Definition WorldGen.cs:898
static bool tenthAnniversaryWorldGen
Definition WorldGen.cs:1160
static void setBG(int bg, int style)
Definition WorldGen.cs:3660
static bool PoundTile(int i, int j)
static int[] tileCounterX
Definition WorldGen.cs:1136
static void GetDesiredStalagtiteStyle(int x, int j, out bool fail, out int desiredStyle, out int height, out int y)
static void MessageLunarApocalypse()
static void TileMergeAttemptWeird(int myType, int changeTo, bool[] exclude, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static void CheckOrb(int i, int j, int type)
static bool IsLockedDoor(int x, int y)
static void Check3x4(int i, int j, int type)
static void CheckCannon(int i, int j, int type)
static int FillWallHolesInColumn(int x, int startY, int endY)
Definition WorldGen.cs:6028
static void SonOfLakinater(int i, int j, double strengthMultiplier=1.0)
static void CountTileTypesInArea(int[] tileTypeCounts, int startX, int endX, int startY, int endY)
Definition WorldGen.cs:2340
static int SmallConsecutivesFound
Definition WorldGen.cs:1142
static int underworldBG
Definition WorldGen.cs:924
static bool OasisPlantWaterCheck(int x, int y, bool boost=false)
static void CheckOnTable1x1(int x, int y, int type)
static bool placingTraps
Definition WorldGen.cs:1168
static bool SolidTile3(int i, int j)
static void SaveAndQuit(Action callback=null)
Definition WorldGen.cs:3146
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static ushort neonMossType
Definition WorldGen.cs:1130
static void CheckSign(int x, int y, ushort type)
static void Check2x3Wall(int x, int y)
static void DiamondTileFrame(int i, int j)
static void PlaceSunflower(int x, int y, ushort type=27)
static bool CanUnderwaterPlantGrowHere(ushort type, int x, int y, bool ignoreSelf)
static void MakeDungeon_Lights(ushort tileType, ref int failCount, int failMax, ref int numAdd, int[] roomWall)
static int totalBlood2
Definition WorldGen.cs:946
static bool roomEvil
Definition WorldGen.cs:1086
static void RandomizeBackgrounds(UnifiedRandom random)
Definition WorldGen.cs:4313
static int sharedRoomX
Definition WorldGen.cs:1104
static TreeTopsInfo TreeTops
Definition WorldGen.cs:1178
static int corruptBG
Definition WorldGen.cs:908
static bool CloseDoor(int i, int j, bool forced=false)
static bool ReplaceTile_IsValidChest(int type)
static void Check1x2(int x, int j, ushort type)
static void FloatingIsland(int i, int j)
static void Place1x2(int x, int y, ushort type, int style)
static int roomX2
Definition WorldGen.cs:1060
static bool nearPicture2(int x, int y)
static int[] treeShakeY
Definition WorldGen.cs:1188
static bool PlaceLilyPad(int x, int j)
static void Caverer(int X, int Y)
static readonly int oceanDistance
Definition WorldGen.cs:926
static Vector2D digTunnel(double X, double Y, double xDir, double yDir, int Steps, int Size, bool Wet=false)
static void DungeonEnt(int i, int j, ushort tileType, int wallType)
static bool loadSuccess
Definition WorldGen.cs:984
static bool EmptyTileCheck(int startX, int endX, int startY, int endY, int ignoreID=-1)
static int numTreeShakes
Definition WorldGen.cs:1184
static bool SeaOatWaterCheck(int x, int y)
static void CheckPot(int i, int j, int type=28)
static void CheckOasisPlant(int i, int j, int type=530)
static void Place4x2(int x, int y, ushort type, int direction=-1, int style=0)
static void RefreshSection(int sectionX, int sectionY)
static bool GetAshTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
static void CheckStinkbugBlocker(int x, int y)
static bool ShiftTallGate(int x, int y, bool closing, bool forced=false)
static void SpreadDesertWalls(int wallDist, int i, int j)
static bool CanKillTile(int i, int j, SpecialKillTileContext context)
static void GiveItemGoodPrefixes(Item item)
static bool roomHasEchoStinkbug
Definition WorldGen.cs:1090
static bool fossilBreak
Definition WorldGen.cs:1190
static void CheckWoman(int i, int j)
static int GetItemDrop_Benches(int style)
static void RandomizeWeather()
Definition WorldGen.cs:4140
static bool KillWire4(int i, int j)
static int GetWaterDepth(int x, int y)
static void CheckLogicTiles(int x, int y, int type)
static bool AttemptReorientingStinkbugBlocker(int x, int y, int wall, ref int style)
static void RangeFrame(int startX, int startY, int endX, int endY)
static bool IsRoomConsideredAlreadyOccupied(int spawnTileX, int spawnTileY, int npcTypeToSpawn)
Definition WorldGen.cs:2143
static void PaintTheClouds(byte tilePaintColor, byte wallPaintColor)
static bool WouldTileReplacementWork(ushort attemptingToReplaceWith, int x, int y)
static void CheckDye(int x, int y)
static void BroadcastText(NetworkText text, Color color)
static bool PlaceWire3(int i, int j)
static bool CanKillTile(int i, int j)
static void ChasmRunner(int i, int j, int steps, bool makeOrb=false)
static bool roomChair
Definition WorldGen.cs:1080
static void Check3x1(int i, int j, int type)
static void saveToonWhilePlayingCallBack(object threadContext)
Definition WorldGen.cs:3303
static bool SolidTile2(Tile testTile)
static bool crimson
Definition WorldGen.cs:932
static bool paintWall(int x, int y, byte color, bool broadCast=false)
static void smCallBack(object threadContext)
static bool PlaceOasis(int X, int Y)
Definition WorldGen.cs:6880
static int totalGood2
Definition WorldGen.cs:948
static int RollRandomForestBGStyle(UnifiedRandom random)
Definition WorldGen.cs:4378
static void PlaceMB(int X, int y, ushort type, int style)
static void MudWallRunner(int i, int j)
static void SectionTileFrame(int sectionStartX, int sectionStartY, int sectionEndXInclusive, int sectionEndYInclusive)
static bool badOceanCaveTiles(int x, int y)
static void DungeonStairs(int i, int j, ushort tileType, int wallType)
static void BroadcastText(NetworkText text, byte r, byte g, byte b)
static void PlaceDresserDirect(int x, int y, ushort type, int style, int id)
static int CheckTileBreakability(int x, int y)
static void PlaceXmasTree(int x, int y, ushort type=171)
static void GetSectionBounds(int sectionStartX, int sectionStartY, int sectionEndXInclusive, int sectionEndYInclusive, out int tileStartX, out int tileEndX, out int tileStartY, out int tileEndY)
static void SquareWallFrame(int i, int j, bool resetFrame=true)
static void GERunner(int i, int j, double speedX=0.0, double speedY=0.0, bool good=true)
static bool UpdateStalagtiteStyle(int x, int j)
static int[] tileCounterY
Definition WorldGen.cs:1138
static Point PlaceCatTail(int x, int j)
static void AddGenerationPass(string name, double weight, WorldGenLegacyMethod method)
Definition WorldGen.cs:6246
static void Check5x4(int i, int j, int type)
static void DesertCloudIsland(int i, int j)
static bool ShiftTrapdoor(int x, int y, bool playerAbove, int onlyCloseOrOpen=-1)
static int GetWorldSize()
Definition WorldGen.cs:3021
static int lavaCount
Definition WorldGen.cs:1034
static int maxWallOut2
Definition WorldGen.cs:1030
static void GrowSpike(int i, int j, ushort spikeType, ushort landType)
static void FinishRemixWorld()
static void ScoreRoom(int ignoreNPC=-1, int npcTypeAskingToScoreRoom=-1)
Definition WorldGen.cs:2380
static bool tempTenthAnniversaryWorldGen
Definition WorldGen.cs:1158
static bool MoveTownNPC(int x, int y, int n)
Definition WorldGen.cs:1478
static void RenameWorldCallBack(object threadContext)
Definition WorldGen.cs:3158
static void TreeGrowFXCheck(int x, int y)
const int WorldSizeSmallY
Definition WorldGen.cs:1110
static int GetTileTypeCountByCategory(int[] tileTypeCounts, TileScanGroup group)
Definition WorldGen.cs:2354
static void AddHellHouses()
static bool checkUnderground(int x, int y)
Definition WorldGen.cs:6251
static MysticLogFairiesEvent mysticLogsEvent
Definition WorldGen.cs:1100
static bool dontStarveWorldGen
Definition WorldGen.cs:1162
static int lastMaxTilesX
Definition WorldGen.cs:992
static void StartHardmode()
static bool InAPlaceWithWind(Vector2 position, int width, int height)
static bool spawnEye
Definition WorldGen.cs:968
static void ShimmerCleanUp()
static int countWires(int x, int y, int size)
Definition WorldGen.cs:5648
static void IslandHouse(int i, int j, int islandStyle)
static bool drunkWorldGenText
Definition WorldGen.cs:1166
static void CheckProjectilePressurePad_GetPossiblePlacementDirections(int i, int j, out bool canUp, out bool canLeft, out bool canRight, out bool canDown)
static bool KillWire(int i, int j)
static Queue< Point > ExploitDestroyQueue
Definition WorldGen.cs:1192
static void Mountinater(int i, int j)
static void TileMergeAttemptFrametest(int i, int j, int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static void Place3x2Wall(int x, int y, ushort type, int style)
static void tileCountAndDestroy()
Definition WorldGen.cs:6183
static void SetVanityTreeDrops(int dropType, Tile tileCache, ref int dropItem)
static int PlaceXmasTree_Direct(int x, int y, int type, int style, int dir, int alternate)
static void CheckWeaponsRack(int i, int j)
static int RollRandomSeaShellStyle()
static void RandomizeTreeStyle()
Definition WorldGen.cs:4440
static void HellFort(int i, int j, ushort tileType=75, byte wallType=14)
static int sandCount
Definition WorldGen.cs:1038
static int hiScore
Definition WorldGen.cs:1074
static bool UpdateMapTile(int i, int j, bool addToList=true)
static bool oceanDepths(int x, int y)
Definition WorldGen.cs:7142
static void FixSunflowers()
static bool roomHasStinkbug
Definition WorldGen.cs:1088
static void GetTreeBottom(int i, int j, out int x, out int y)
static bool TryKillingReplaceableTile(int x, int y, int tileType)
static int FindAHomelessNPC()
Definition WorldGen.cs:2129
static void GrowPumpkin(int i, int j, int type)
static Point[] heartPos
Definition WorldGen.cs:1200
static bool StartRoomCheck(int x, int y)
Definition WorldGen.cs:2581
static void Place1x1(int x, int y, int type, int style=0)
static void GetBiomeInfluence(int startX, int endX, int startY, int endY, out int corruptCount, out int crimsonCount, out int hallowedCount)
const int WorldSizeSmallX
Definition WorldGen.cs:1108
static bool PlayerLOS(int x, int y)
static void ConsumePostGenActions(StructureMap structures)
static void nextDirtCount(int x, int y)
Definition WorldGen.cs:5778
static readonly Vertical64BitStrips bitStrip
Definition WorldGen.cs:1208
delegate bool GetTreeFoliageDataMethod(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
static void TreeGrowFX_AshShake(int x, int y, int height, bool hitTree=false)
static readonly int beachDistance
Definition WorldGen.cs:928
static Task CreateNewWorld(GenerationProgress progress=null)
Definition WorldGen.cs:3048
const int strip_w
Definition WorldGen.cs:1204
static bool KillWall_CheckFailure(bool fail, Tile tileCache)
static void plantDye(int i, int j, bool exoticPlant=false)
static void UpdateDesertHiveBounds(int x, int y)
Definition WorldGen.cs:7155
static bool GetGemTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
static bool IsThisAMushroomTree(int i, int j)
static int[] CountTileTypesInWorld(params int[] oreTypes)
static void PaintTheTemple(byte tilePaintColor, byte wallPaintColor)
static bool RoomNeeds(int npcType)
Definition WorldGen.cs:2178
static bool AddBuriedChest(Point point, int contain=0, bool notNearOtherChests=false, int Style=-1)
static bool canSpawn
Definition WorldGen.cs:1066
static void FinishNoTraps()
static void CheckDoorClosed(int i, int j, Tile tileCache, int type)
static void PlaceCannon(int x, int y, ushort type, int style=0)
static void PaintThePyramids(byte tilePaintColor, byte wallPaintColor)
static bool GrowDungeonTree(int i, int j, bool patch=false)
static void CheckChand(int i, int j, int type)
static void KillWall_PlaySounds(int i, int j, Tile tileCache)
static bool PlaceWire4(int i, int j)
static void SetupStatueList()
Definition WorldGen.cs:1246
static bool TryKillingTreesAboveIfTheyWouldBecomeInvalid(int i, int j, int newFloorType)
static void setXmasTree(int x, int y, int obj, int style)
static void Reframe(int x, int y, bool resetFrame=false)
static void PlaceJunglePlant(int X2, int Y2, ushort type, int styleX, int styleY)
static void Place2x1(int x, int y, ushort type, int style=0)
static void CaveOpenater(int i, int j)
static string statusText
Definition WorldGen.cs:1018
static void templePart2()
static void SaveAndQuitCallBack(object threadContext)
Definition WorldGen.cs:3099
static bool SolidTileAllowTopSlope(int i, int j)
static void clearWorld()
Definition WorldGen.cs:3373
static void PlaceDye(int x, int y, int style)
static void CheckChest(int i, int j, int type)
static void Check3x3Wall(int x, int y)
static void Check2x5(int i, int j, int type)
static bool TryGrowingAbigailsFlower(int i, int j)
static int GetDresserItemDrop(int style)
static void PlaceGnome(int x, int y, int style)
static bool roomDoor
Definition WorldGen.cs:1078
static int[] mossType
Definition WorldGen.cs:1128
static void EveryTileFrame()
static List< Color > _coatingColors
Definition WorldGen.cs:1174
static void Check2x2Style(int i, int j, int type)
static void SwitchFountain(int i, int j)
static bool GrowMoreVines(int x, int y)
static void QuickFindHome(int npc)
Definition WorldGen.cs:2227
static void Convert(int i, int j, int conversionType, int size=4)
static int KillTile_MakeTileDust(int i, int j, Tile tileCache)
static void RandomizeBackgroundBasedOnPlayer(UnifiedRandom random, Player player)
Definition WorldGen.cs:4162
static void TileFrame(int i, int j, bool resetFrame=false, bool noBreak=false)
static void AttemptFossilShattering(int i, int j, Tile tileCache, bool fail)
static void ImproveAllChestContents()
static bool generatingWorld
Definition WorldGen.cs:1122
static int tileCounterNum
Definition WorldGen.cs:1132
static int grassSpread
Definition WorldGen.cs:1198
static int CanPlaceProjectilePressurePad(int x, int y, int type=442, int style=0, int direction=0, int alternate=0)
static bool noTileActions
Definition WorldGen.cs:966
static void MineHouse(int i, int j)
static void GetTreeLeaf(int x, Tile topTile, Tile t, ref int treeHeight, out int treeFrame, out int passStyle)
static bool roomTable
Definition WorldGen.cs:1082
static void Check4x3Wall(int x, int y)
static void Check4x2(int i, int j, int type)
static bool GrowEpicTree(int i, int y)
static void playWorld()
Definition WorldGen.cs:3288
static void CheckTreeWithSettings(int x, int y, CheckTreeSettings settings)
static int altarCount
Definition WorldGen.cs:978
static bool DungeonPitTrap(int i, int j, ushort tileType, int wallType)
static double TuneOceanDepth(int count, double depth, bool floridaStyle=false)
static bool ShimmerMakeBiome(int X, int Y)
static void ReplaceTile_DoActualReplacement_Single(ushort targetType, int targetStyle, int topLeftX, int topLeftY, Tile t)
static IEntitySource GetProjectileSource_PlayerOrWires(int x, int y, bool fromWiring, Player player)
Definition WorldGen.cs:1333
static void Check2x1(int i, int y, ushort type)
static Point GetTopLeftAndStyles(ref int x, ref int y, int w, int h, int frameXinc, int frameYinc)
static void DungeonHalls(int i, int j, ushort tileType, int wallType, bool forceX=false)
static void neonMossBiome(int i, int j, int maxY=99999)
Definition WorldGen.cs:5889
static int spawnHardBoss
Definition WorldGen.cs:970
static bool SpawnFallingBlockProjectile(int i, int j, Tile tileCache, Tile tileTopCache, Tile tileBottomCache, int type)
static bool Chlorophyte(int i, int j)
static void outerTempled(int x, int y)
static void CheckPalmTree(int i, int j)
static bool noMapUpdateRefresh
Definition WorldGen.cs:1210
static bool BlockBelowMakesSandFall(int i, int j)
static bool ScoreRoom_CanBeHomeSpot(int x, int y)
Definition WorldGen.cs:2536
static bool SkipFramingBecauseOfGen
Definition WorldGen.cs:1235
static bool SolidOrSlopedTile(int x, int y)
static bool SlopeTile(int i, int j, int slope=0, bool noEffects=false)
static void CloudLake(int i, int j)
static bool GrowSeaOat(int x, int y)
static int bestX
Definition WorldGen.cs:1070
static void TrySpawningTownNPC(int x, int y)
static void CountTiles(int X)
static void TileMergeAttempt(int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right)
static bool CanKillTile(int i, int j, out bool blockDamaged)
static void SnowCloudIsland(int i, int j)
static int totalX
Definition WorldGen.cs:960
static bool PlaceBamboo(int x, int y)
static void CheckTrapDoor(int x, int y, int type)
static bool Housing_CheckIfInRoom(int i, int j)
Definition WorldGen.cs:2567
static bool paintTile(int x, int y, byte color, bool broadCast=false)
static bool MarblePileWithStatues(int X, int Y)
Definition WorldGen.cs:6585
static bool RightEdgeCanBeAttachedTo(int i, int j)
static void CactusFrame(int i, int j)
static bool KillWire2(int i, int j)
static bool FillWallHolesInSpot(int originX, int originY, int maxWallsThreshold)
Definition WorldGen.cs:6056
static void UnlockDoor(int i, int j)
static void CheckProjectilePressurePad(int i, int j)
static void CheckPile(int i, int y)
static bool Statue(int x, int y, byte paint)
Definition WorldGen.cs:6709
static Point RandomWorldPoint(int top=0, int right=0, int bottom=0, int left=0)
static bool ReplaceTile_IsValidCampfire(int type)
static void CheckTight(int x, int j)
static void GetSandfallProjData(int type, out int projType, out int dmg)
static void Scan3By3(int topLeftX, int topLeftY, out bool isEmpty, out bool hasFloor)
static void PaintTheLivingTrees(byte livingTreePaintColor, byte livingTreeWallPaintColor)
const int WorldSizeLargeY
Definition WorldGen.cs:1118
static void KillWall(int i, int j, bool fail=false)
static void paintCoatEffect(int x, int y, byte paintCoatId, List< Color > oldColors)
static bool EmptyLiquid(int x, int y)
Definition WorldGen.cs:1342
static void SpawnThingsFromPot(int i, int j, int x2, int y2, int style)
static int totalBlood
Definition WorldGen.cs:938
static void CheckSuper(int x, int y, int type)
static bool CheckTileAnchors(int sx, int sy, int w, int h, int mode, AnchorType anchor)
static void ShimmerMakeBiomeOpening(int direction, int X, int Y, int caveOpenningSize)
static int PlatformProperSides(int x, int y, bool acceptNonOpposing=false)
static int MossConversion(int thisType, int otherType)
static int tileCounter(int x, int y)
Definition WorldGen.cs:6197
static TownNPCRoomCheckFailureReason roomCheckFailureReason
Definition WorldGen.cs:1106
static void UpdateWorld_UndergroundTile(int i, int j, bool checkNPCSpawns, int wallDist)
static void Place3x3Wall(int x, int y, ushort type, int style)
static void ScanTileColumnAndRemoveClumps(int x)
Definition WorldGen.cs:6332
static void CheckSunflower(int i, int j, int type=27)
static void Shimminate()
static int GetTileMossColor(int tileType)
static bool SolidTile(int i, int j, bool noDoors=false)
static bool ShellPile(int X, int Y)
Definition WorldGen.cs:6475
static TownNPCSpawnResult SpawnTownNPC(int x, int y)
Definition WorldGen.cs:1926
static int maxRoomTiles
Definition WorldGen.cs:1044
static void PlayLiquidChangeSound(TileChangeType eventType, int x, int y, int count=1)
Definition WorldGen.cs:1424
static bool GemTreeWallTest(int wallType)
static bool IsOpenDoorAnchorFrame(int x, int y)
static int desertBG
Definition WorldGen.cs:918
static bool CheckCactus(int i, int j)
static bool CheckTileFrames(int type, int sx, int sy, int w, int h, int styleX, int frameXinc, int styleY, int frameYinc)
static void hardUpdateWorld(int i, int j)
static void Check3x6(int i, int j, int type)
static bool IsPalmOasisTree(int x)
static int tileCounterMax
Definition WorldGen.cs:1134
static bool roomOccupied
Definition WorldGen.cs:1084
static bool DefaultTreeWallTest(int wallType)
static Point GetAdjustedFloorPosition(int x, int y)
static void AddUpAlignmentCounts(bool clearCounts=false)
static void Place2x2(int x, int y, ushort type, int style)
static void Housing_GetTestedRoomBounds(out int startX, out int endX, out int startY, out int endY)
Definition WorldGen.cs:2509
static void CheckGolf1x1(int x, int y, int type)
static bool ReplaceTile_IsValidPlatform(int type)
static PaintingEntry RandHousePicture()
static int KillWall_GetItemDrops(Tile tileCache)
static bool[] houseTile
Definition WorldGen.cs:1068
static bool DoesWindBlowAtThisHeight(int tileY)
static int crimsonBG
Definition WorldGen.cs:916
static int totalGood
Definition WorldGen.cs:940
static readonly int cactusWaterLimit
Definition WorldGen.cs:1098
static string currentWorldSeed
Definition WorldGen.cs:958
static bool IsFitToPlaceFlowerIn(int x, int y, int typeAttemptedToPlace)
static void FixSunflower(int i, int j)
static UnifiedRandom _genRand
Definition WorldGen.cs:1011
static void CheckGnome(int x, int j)
static void ReplaceTile_EliminateNaturalExtras(int x, int y)
static bool SolidTile(Point p)
static int totalD
Definition WorldGen.cs:962
static void RandomizeMoonState(UnifiedRandom random, bool garenteeNewStyle=false)
Definition WorldGen.cs:4152
static void nextCount(int x, int y, bool jungle=false, bool lavaOk=false)
Definition WorldGen.cs:5692
static void KillWall_DropItems(int i, int j, Tile tileCache)
static void PaintThePurityGrass(byte tilePaintColor, byte wallPaintColor)
static int heartCount
Definition WorldGen.cs:1202
static void KillWall_MakeWallDust(int i, int j, Tile tileCache)
static bool mergeUp
Definition WorldGen.cs:996
static void PrefixItemFromOptions(Item item, int[] options)
static TileChangeType GetLiquidChangeType(int liquidType, int otherLiquidType)
Definition WorldGen.cs:1449
static bool mayanTrap(int x2, int y2)
Definition WorldGen.cs:4600
static void PlacePumpkin(int x, int superY)
static void Check3x5(int i, int j, int type)
static void saveToonWhilePlaying()
Definition WorldGen.cs:3308
static void DestroyHeart(int i, int j)
const int ItemSpawnProtectionTime
Definition WorldGen.cs:1172
static bool HasValidGroundForAbigailsFlowerBelowSpot(int x, int y)
static bool BunnyCannonCanFire()
static int treeBG1
Definition WorldGen.cs:900
static void UnspawnTravelNPC()
Definition WorldGen.cs:1737
static bool EligibleForSpawnProtection(Item item)
static byte tEvil
Definition WorldGen.cs:952
static bool PlacePot(int x, int y, ushort type=28, int style=0)
static int[] roomCeilingX
Definition WorldGen.cs:1054
static void GrowDungeonTree_MakePassage(int j, int W, ref int minl, ref int minr, bool noSecretRoom=false)
static bool IsBelowANonHammeredPlatform(int x, int y)
static void GrowLivingTreePassageRoom(int minl, int minr, int Y)
static void RandomizeCaveBackgrounds()
Definition WorldGen.cs:4515
static void LaunchRocket(int x, int y, bool fromWiring)
static void TileMergeAttempt(int myType, int lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static int GetCampfireItemDrop(int style)
static void Shimmerator(int x, int y, bool jungle=false, bool lavaOk=false)
static bool IsItATrigger(Tile tile)
static void HellHouse(int i, int j, byte type=76, byte wall=13)
static bool GrowTree(int i, int y)
static void PlaceMan(int i, int j, int dir)
static void AddGenerationPass(GenPass pass)
Definition WorldGen.cs:6241
static int snowBG
Definition WorldGen.cs:912
static void GetVineTop(int i, int j, out int x, out int y)
static bool GetVanityTreeFoliageData(int i, int j, int xoffset, ref int treeFrame, ref int treeStyle, out int floorY, out int topTextureFrameWidth, out int topTextureFrameHeight)
static void Place6x4Wall(int x, int y, ushort type, int style)
static int CountGrowingPlantTiles(int x, int y, int range, int type)
static void saveAndPlayCallBack(object threadContext)
Definition WorldGen.cs:3293
static bool currentlyTryingToUseAlternateHousingSpot
Definition WorldGen.cs:1102
static void MatureTheHerbPlants()
static void dropXmasTree(int x, int y, int obj)
static int checkXmasTreeDrop(int x, int y, int obj)
static bool PlantSeaOat(int x, int y)
static void GetRidOfCultists()
static void Place1x2Top(int x, int y, ushort type, int style)
static void ShimmerRemoveWater()
static bool SolidTileAllowLeftSlope(int i, int j)
static bool LeftEdgeCanBeAttachedTo(int i, int j)
static void dropMeteor()
Definition WorldGen.cs:2739
const int WorldSizeMediumY
Definition WorldGen.cs:1114
static bool ReplaceTile_IsValidTorch(int type)
static bool[] gem
Definition WorldGen.cs:1126
static int countDirtTiles(int x, int y)
Definition WorldGen.cs:5770
static int rockCount
Definition WorldGen.cs:1040
static void ShakeTree(int i, int j)
static WorldGenerator _generator
Definition WorldGen.cs:1140
static void UpdateLunarApocalypse()
static double oceanLevel
Definition WorldGen.cs:1232
static bool PlaceWire(int i, int j)
static bool SolidTile2(int i, int j)
static void Place4x3Wall(int x, int y, ushort type, int style)
static void Place1xX(int x, int y, ushort type, int style=0)
static int iceCount
Definition WorldGen.cs:1036
static void ResetTreeShakes()
static void PlaceWall(int i, int j, int type, bool mute=false)
static void Place3x1(int x, int y, ushort type, int style=0)
static void TriggerLunarApocalypse()
static bool worldCleared
Definition WorldGen.cs:986
static EntitySource_TileBreak GetProjectileSource_TileBreak(int x, int y)
Definition WorldGen.cs:1308
static void CheckUnderwaterPlant(ushort type, int x, int y)
static void ExplodeMine(int i, int j, bool fromWiring)
static void playWorldCallBack(object threadContext)
Definition WorldGen.cs:3189
static bool AddBuriedChest(int i, int j, int contain=0, bool notNearOtherChests=false, int Style=-1, bool trySlope=false, ushort chestTileType=0)
static void GrowGlowTulips()
static void ToggleGemLock(int i, int j, bool on)
static void PlaceStatueTrap(int x, int y)
Definition WorldGen.cs:1287
static void PlaceUncheckedStalactite(int x, int y, bool preferSmall, int variation, bool spiders)
static bool IsNPCEvictable(int n)
Definition WorldGen.cs:1588
static void PlaceOnTable1x1(int x, int y, int type, int style=0)
static void GrowWeb(int i, int j)
static bool PlatformProperTopFrame(short frameX)
static void FixChands()
static void DirtyRockRunner(int i, int j)
static int GetTreeFrame(Tile t)
static int spawnDelay
Definition WorldGen.cs:1022
static void CrimStart(int i, int j)
static bool SolidTileAllowBottomSlope(int i, int j)
static void SpreadGrass(int i, int j, int dirt=0, int grass=2, bool repeat=true, TileColorCache color=default(TileColorCache))
static void ReplaceTIle_DoActualReplacement(ushort targetType, int targetStyle, int topLeftX, int topLeftY, Tile t)
static void CheckTorch(int x, int y)
static void DontStarveTryWateringTile(int x, int y)
static int roomY1
Definition WorldGen.cs:1062
static int oceanBG
Definition WorldGen.cs:920
static void Place3x3(int x, int y, ushort type, int style=0)
static bool IsDungeon(int x, int y)
static int _genRandSeed
Definition WorldGen.cs:1014
static void ResetGenerator()
Definition WorldGen.cs:4574
static bool PlaceObject(int x, int y, int type, bool mute=false, int style=0, int alternate=0, int random=-1, int direction=-1)
static bool drunkWorldGen
Definition WorldGen.cs:1154
static EntitySource_ShakeTree GetItemSource_ShakeTree(int x, int y)
Definition WorldGen.cs:1328
static bool skipFramingDuringGen
Definition WorldGen.cs:1212
static PaintingEntry RandHellPicture()
static int GetNextJungleChestItem()
Definition WorldGen.cs:6298
static void KillTile_PlaySounds(int i, int j, bool fail, Tile tileCache)
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)
static void worldGenCallback(object threadContext)
Definition WorldGen.cs:3034
static int maxTileCount
Definition WorldGen.cs:1028
static bool PlaceDoor(int i, int j, int type, int style=0)
static int[] roomCeilingY
Definition WorldGen.cs:1056
static bool ReplaceTile_IsValidDresser(int type)
static void BroadcastText(NetworkText text, Vector3 color)
static int KillTile_GetTileDustAmount(bool fail, Tile tileCache)
static BackgroundChangeFlashInfo BackgroundsCache
Definition WorldGen.cs:1180
static bool IsUndergroundDesert(int x, int y)
static int GetItemDrop_PicnicTables(int style)
static bool paintCoatWall(int x, int y, byte paintCoatId, bool broadcast=false)
static bool PlaceAlch(int x, int y, int style)
static void GetStalagtiteStyle(int x, int y, out int style, out bool fail)
static List< Color > coatingColors(Tile tile, bool block)
static int bestY
Definition WorldGen.cs:1072
static void GrowUndergroundTree(int i, int y)
static int lastMaxTilesY
Definition WorldGen.cs:994
static bool ReplaceWall(int x, int y, ushort targetWall)
static bool VanityTreeGroundTest(int tileType)
static void ConvertSkyIslands(int convertType, bool growTrees)
static bool Pyramid(int i, int j)
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static byte tGood
Definition WorldGen.cs:956
static void ShootFromCannon(int x, int y, int angle, int ammo, int Damage, float KnockBack, int owner, bool fromWire)
static bool PlaceSign(int x, int y, ushort type, int Style=0)
static void ShroomPatch(int i, int j)
static void TileMergeAttempt(int myType, bool[] lookfor, ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
static bool IsRope(int x, int y)
static bool IsRoomConsideredOccupiedForNPCIndex(int npc)
Definition WorldGen.cs:2286
static void PlantCheck(int x, int y)
static bool PlaceActuator(int i, int j)
static int GetChestItemDrop(int x, int y, int type)
static bool WillWaterPlacedHereStayPut(int x, int y)
static void Place3x4(int x, int y, ushort type, int style)
static void CheckMB(int i, int j, int type)
static bool AnchorValid(Tile tileCache, AnchorType anchor)
static void CrimVein(Vector2D position, Vector2D velocity)
static void CheckFoodPlatter(int x, int y, int type)
static IEntitySource GetItemSource_FromTileBreak(int x, int y)
static void SquareTileFrame(int i, int j, bool resetFrame=true)
static bool CheckSeaOat(int x, int y)
static bool OrePatch(int X, int Y)
Definition WorldGen.cs:6741
static bool nearbyChlorophyte(int i, int j)
static void RefreshSections(int startX, int startY, int endX, int endY)
static bool CanCutTile(int x, int y, TileCuttingContext context)
static void gemCave(int x, int y)
Definition WorldGen.cs:5825
static void Place5x4(int x, int y, ushort type, int style)
static void SetGemTreeDrops(int gemType, int seedType, Tile tileCache, ref int dropItem, ref int secondaryItem)
static void PaintTheTrees()
static bool placeTrap(int x2, int y2, int type=-1)
Definition WorldGen.cs:5155
static bool shadowOrbSmashed
Definition WorldGen.cs:974
static void WavyCaverer(int startX, int startY, double waveStrengthScalar, double wavePercentScalar, int steps, int type)
static bool GemTreeGroundTest(int tileType)
static void PlaceBanner(int x, int y, ushort type, int style=0)
static void RenameWorld(WorldFileData data, string newName, Action< string > callback=null)
Definition WorldGen.cs:3152
static IEntitySource GetItemSource_FromTreeShake(int x, int y)
static bool stopDrops
Definition WorldGen.cs:1004
static void CheckXmasTree(int x, int y)
static int randGem()
Definition WorldGen.cs:5843
static bool StonePatch(int X, int Y)
Definition WorldGen.cs:6374
static bool AllowsSandfall(Tile tileTopCache)
static bool IsHarvestableHerbWithSeed(int type, int style)
static void MakeDungeon_Traps(ref int failCount, int failMax, ref int numAdd)
static void GrowLivingTree_MakePassage(int j, int W, ref int minl, ref int minr, bool noSecretRoom=false)
static void WaterCheck()
static void makeTemple(int x, int y)
static void CheckJunglePlant(int i, int j, int type)
static void CheckCatTail(int x, int j)
static bool NearFriendlyWall(int x, int y)
static bool notTheBees
Definition WorldGen.cs:1164
static bool spawnMeteor
Definition WorldGen.cs:980
static bool getGoodWorldGen
Definition WorldGen.cs:1156
static bool paintCoatTile(int x, int y, byte paintCoatId, bool broadcast=false)
static bool mergeDown
Definition WorldGen.cs:998
static void PlaceTight(int x, int y, bool spiders=false)
static void ChasmRunnerSideways(int i, int j, int direction, int steps)
static bool WouldTileReplacementBeBlockedByLiquid(int x, int y, int liquidType)
static void MoveReplaceTileAnchor(ref int x, ref int y, ushort targetType, Tile t)
static Queue< Action< StructureMap > > _postGenActions
Definition WorldGen.cs:894
static void AddTrees(bool undergroundOnly=false)
static void ClearBrokenTraps(Point startTileCoords, List< Point > pointsWeAlreadyWentOver)
static int roomX1
Definition WorldGen.cs:1058
static int[] tileCounts
Definition WorldGen.cs:934
static bool SolidTile3(Tile t)
static int countTiles(int x, int y, bool jungle=false, bool lavaOk=false)
Definition WorldGen.cs:5679
static void CrimPlaceHearts()
static bool CanPlaceSink(int x, int y, ushort type, int style)
static bool HasAnyWireNearby(int sourceX, int sourceY, int boxSpread)
static bool mergeLeft
Definition WorldGen.cs:1000
static void Place2x2Style(int x, int y, ushort type, int style=0)
static void ShimmeratorNext(int x, int y)
static int catTailDistance
Definition WorldGen.cs:1176
static void CheckBanner(int x, int j, byte type)
static void GrowCatTail(int x, int j)
static bool ReplaceTile(int x, int y, ushort targetType, int targetStyle)
static IEntitySource GetItemSource_FromWallBreak(int x, int y)
static void Place2xX(int x, int y, ushort type, int style=0)
static int numRoomTiles
Definition WorldGen.cs:1046
static Point RandomWorldPoint(int padding)
static void setMoss(int x, int y)
Definition WorldGen.cs:6006
static bool IsSafeFromRain(int startX, int startY)
static double MakeDungeon_Pictures(int[] roomWall, double count)
const int strip_h
Definition WorldGen.cs:1206
static bool PlaceSandTrap(int i, int j)
static void Cavinator(int i, int j, int steps)
static void SpawnPlanteraThorns(Vector2 position)
static bool CheckBoulderChest(int i, int j)
static void FinishGetGoodWorld()
static void PlaceChestDirect(int x, int y, ushort type, int style, int id)
static void DungeonRoom(int i, int j, ushort tileType, int wallType)
static bool AddLifeCrystal(int i, int j)
static bool IsTileALeafyTreeTop(int i, int j)
static int PlaceChest(int x, int y, ushort type=21, bool notNearOtherChests=false, int style=0)
static TreeTypes GetTreeType(int tileType)
static bool CheckTileBreakability2_ShouldTileSurvive(int x, int y)
static void CheckMan(int i, int j)
static bool SolidOrSlopedTile(Tile tile)
static void kickOut(int n)
Definition WorldGen.cs:1601
static void RefreshStrip(int xStart, int yStart, int xEnd, int yEnd, ref int totalEcho, ref int totalFramed)
static bool IsTileNearby(int x, int y, int type, int distance)
Definition WorldGen.cs:5117
static void Lakinater(int i, int j, double strengthMultiplier=1.0)
static void PlaceWoman(int i, int j, int dir)
static void tileCounterNext(int x, int y)
Definition WorldGen.cs:6204
static void FillWallHolesInArea(Rectangle worldCoordsArea)
Definition WorldGen.cs:6014
static bool AshTreeGroundTest(int tileType)
static Color paintColor(int color)
static void KillTile_DropBait(int i, int j, Tile tileCache)
static bool KillActuator(int i, int j)
static void Check6x4Wall(int x, int y)
static int GetHollowTreeFoliageStyle()
static EntitySource_ShakeTree GetNPCSource_ShakeTree(int x, int y)
Definition WorldGen.cs:1318
static bool IsGeneratingHardMode
Definition WorldGen.cs:964
static int GetItemDrop_Toilet(int style)
delegate void Action()
delegate void WorldGenLegacyMethod(GenerationProgress progress, GameConfiguration configuration)
static Color Transparent
Definition Color.cs:76
bool Intersects(Rectangle value)
Definition Rectangle.cs:129
static Vector2D Zero
Definition Vector2D.cs:24
static double Distance(Vector2D value1, Vector2D value2)
Definition Vector2D.cs:137
static DateTime Now
Definition DateTime.cs:103
static bool Place(TileObject toBePlaced)
Definition TileObject.cs:29
static bool CanPlace(int x, int y, int type, int style, int dir, out TileObject objectData, bool onlyCheck=false, int? forcedRandom=null)
delegate bool GroundValidTest(int groundTileType)
delegate bool IsWallTypeFitForTreeBack(int wallType)
IsTileFitForTreeGroundTest GroundTest
Definition WorldGen.cs:815
delegate bool IsTileFitForTreeGroundTest(int tileType)
IsWallTypeFitForTreeBack WallTest
Definition WorldGen.cs:817
void Cull(ref int up, ref int down, ref int left, ref int right, ref int upLeft, ref int upRight, ref int downLeft, ref int downRight)
Definition WorldGen.cs:855