Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DungeonHalls()

static void Terraria.WorldGen.DungeonHalls ( int i,
int j,
ushort tileType,
int wallType,
bool forceX = false )
inlinestatic

Definition at line 29472 of file WorldGen.cs.

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 {
29931 num11 = Main.maxTilesX;
29932 }
29933 if (num12 < 0)
29934 {
29935 num12 = 0;
29936 }
29937 if (num13 > Main.maxTilesY)
29938 {
29939 num13 = Main.maxTilesY;
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 {
29996 num11 = Main.maxTilesX;
29997 }
29998 if (num12 < 0)
29999 {
30000 num12 = 0;
30001 }
30002 if (num13 > Main.maxTilesY)
30003 {
30004 num13 = Main.maxTilesY;
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);
30016 Main.tile[num17, num18].type = GenVars.crackedType;
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 }
static double Abs(double value)
static Vector2D lastDungeonHall
Definition GenVars.cs:184
static bool remixWorldGen
Definition WorldGen.cs:1148
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static int lastMaxTilesX
Definition WorldGen.cs:992
static int lastMaxTilesY
Definition WorldGen.cs:994
static Vector2D Zero
Definition Vector2D.cs:24

References System.Math.Abs(), Terraria.WorldBuilding.GenVars.crackedType, Terraria.WorldBuilding.GenVars.DDoorPos, Terraria.WorldBuilding.GenVars.DDoorX, Terraria.WorldBuilding.GenVars.DDoorY, Terraria.WorldBuilding.GenVars.dMaxX, Terraria.WorldBuilding.GenVars.dMaxY, Terraria.WorldBuilding.GenVars.dMinX, Terraria.WorldBuilding.GenVars.dungeonPlatformX, Terraria.WorldBuilding.GenVars.dungeonPlatformY, Terraria.WorldBuilding.GenVars.lastDungeonHall, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.WorldBuilding.GenVars.numDDoors, Terraria.WorldBuilding.GenVars.numDungeonPlatforms, Terraria.Main.rockLayer, Terraria.Main.tile, Terraria.Main.wallDungeon, Terraria.Main.worldSurface, ReLogic.Utilities.Vector2D.X, ReLogic.Utilities.Vector2D.Y, and ReLogic.Utilities.Vector2D.Zero.