Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ templePart2()

static void Terraria.WorldGen.templePart2 ( )
inlinestatic

Definition at line 25916 of file WorldGen.cs.

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 }
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool AddBuriedChest(Point point, int contain=0, bool notNearOtherChests=false, int Style=-1)
static bool mayanTrap(int x2, int y2)
Definition WorldGen.cs:4600
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816

References Terraria.Tile.active(), Terraria.Main.maxTilesX, Terraria.WorldBuilding.GenVars.tBottom, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.WorldBuilding.GenVars.tLeft, Terraria.WorldBuilding.GenVars.tRight, Terraria.WorldBuilding.GenVars.tRooms, Terraria.WorldBuilding.GenVars.tTop, and Terraria.Tile.type.