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

◆ templePart2()

static void Terraria.WorldGen.templePart2 ( )
inlinestatic

Definition at line 27415 of file WorldGen.cs.

27416 {
27417 int tLeft = GenVars.tLeft;
27418 int tRight = GenVars.tRight;
27419 int tTop = GenVars.tTop;
27420 int tBottom = GenVars.tBottom;
27421 int tRooms = GenVars.tRooms;
27422 double num = (double)tRooms * 1.9;
27423 num *= 1.0 + (double)genRand.Next(-15, 16) * 0.01;
27424 int num12 = 0;
27425 while (num > 0.0)
27426 {
27427 int num16 = genRand.Next(tLeft, tRight);
27428 int num17 = genRand.Next(tTop, tBottom);
27429 if (Main.tile[num16, num17].wall == 87 && !Main.tile[num16, num17].active())
27430 {
27431 if (mayanTrap(num16, num17))
27432 {
27433 num -= 1.0;
27434 num12 = 0;
27435 }
27436 else
27437 {
27438 num12++;
27439 }
27440 }
27441 else
27442 {
27443 num12++;
27444 }
27445 if (num12 > 100)
27446 {
27447 num12 = 0;
27448 num -= 1.0;
27449 }
27450 }
27451 Main.tileSolid[232] = false;
27452 double num18 = (double)tRooms * 0.35;
27453 num18 *= 1.0 + (double)genRand.Next(-15, 16) * 0.01;
27454 int contain = 1293;
27455 num12 = 0;
27456 while (num18 > 0.0)
27457 {
27458 int num19 = genRand.Next(tLeft, tRight);
27459 int num20 = genRand.Next(tTop, tBottom);
27460 if (Main.tile[num19, num20].wall == 87 && !Main.tile[num19, num20].active() && AddBuriedChest(num19, num20, contain, notNearOtherChests: true, 16, trySlope: false, 0))
27461 {
27462 num18 -= 1.0;
27463 num12 = 0;
27464 }
27465 num12++;
27466 if (num12 > 10000)
27467 {
27468 break;
27469 }
27470 }
27471 double num21 = (double)tRooms * 1.25;
27472 num21 *= 1.0 + (double)genRand.Next(-25, 36) * 0.01;
27473 num12 = 0;
27474 while (num21 > 0.0)
27475 {
27476 num12++;
27477 int num22 = genRand.Next(tLeft, tRight);
27478 int num2 = genRand.Next(tTop, tBottom);
27479 if (Main.tile[num22, num2].wall != 87 || Main.tile[num22, num2].active())
27480 {
27481 continue;
27482 }
27483 int num3 = num22;
27484 int num4 = num2;
27485 while (!Main.tile[num3, num4].active())
27486 {
27487 num4++;
27488 if (num4 > tBottom)
27489 {
27490 break;
27491 }
27492 }
27493 num4--;
27494 if (num4 <= tBottom)
27495 {
27496 PlaceTile(num3, num4, 105, mute: true, forced: false, -1, genRand.Next(43, 46));
27497 if (Main.tile[num3, num4].type == 105)
27498 {
27499 num21 -= 1.0;
27500 }
27501 }
27502 }
27503 double num5 = (double)tRooms * 1.35;
27504 num5 *= 1.0 + (double)genRand.Next(-15, 26) * 0.01;
27505 num12 = 0;
27506 while (num5 > 0.0)
27507 {
27508 num12++;
27509 int num6 = genRand.Next(tLeft, tRight);
27510 int num7 = genRand.Next(tTop, tBottom);
27511 if (Main.tile[num6, num7].wall == 87 && !Main.tile[num6, num7].active())
27512 {
27513 int num8 = num6;
27514 int num9 = num7;
27515 while (!Main.tile[num8, num9].active())
27516 {
27517 num9++;
27518 if (num9 > tBottom)
27519 {
27520 break;
27521 }
27522 }
27523 num9--;
27524 if (num9 <= tBottom)
27525 {
27526 switch (genRand.Next(3))
27527 {
27528 case 0:
27529 PlaceTile(num8, num9, 18, mute: true, forced: false, -1, 10);
27530 if (Main.tile[num8, num9].type == 18)
27531 {
27532 num5 -= 1.0;
27533 }
27534 break;
27535 case 1:
27536 PlaceTile(num8, num9, 14, mute: true, forced: false, -1, 9);
27537 if (Main.tile[num8, num9].type == 14)
27538 {
27539 num5 -= 1.0;
27540 }
27541 break;
27542 case 2:
27543 PlaceTile(num8, num9, 15, mute: true, forced: false, -1, 12);
27544 if (Main.tile[num8, num9].type == 15)
27545 {
27546 num5 -= 1.0;
27547 }
27548 break;
27549 }
27550 }
27551 }
27552 if (num12 > 10000)
27553 {
27554 break;
27555 }
27556 }
27557 int num10 = 1;
27558 if (Main.maxTilesX > 4200)
27559 {
27560 num10++;
27561 }
27562 if (Main.maxTilesX > 6400)
27563 {
27564 num10 += genRand.Next(2);
27565 }
27566 num12 = 0;
27567 while (num10 > 0)
27568 {
27569 num12++;
27570 int num11 = genRand.Next(tLeft, tRight);
27571 int num13 = genRand.Next(tTop, tBottom);
27572 if (Main.tile[num11, num13].wall == 87 && !Main.tile[num11, num13].active())
27573 {
27574 bool flag = false;
27575 for (int i = -70; i <= 70; i++)
27576 {
27577 for (int j = -70; j <= 70; j++)
27578 {
27579 int num14 = i + num11;
27580 int num15 = j + num13;
27581 if (!InWorld(num14, num15, 5))
27582 {
27583 continue;
27584 }
27585 Tile tile = Main.tile[num14, num15];
27586 if (tile.active())
27587 {
27588 if (tile.type == 240)
27589 {
27590 flag = true;
27591 break;
27592 }
27593 if (i >= -4 && i <= 4 && j >= -4 && j <= 4 && tile.type == 226)
27594 {
27595 flag = true;
27596 break;
27597 }
27598 }
27599 }
27600 if (flag)
27601 {
27602 break;
27603 }
27604 }
27605 if (flag)
27606 {
27607 continue;
27608 }
27609 if (PlaceTile(num11, num13, 240, mute: true, forced: false, -1, 88))
27610 {
27611 num10--;
27612 }
27613 }
27614 if (num12 > 10000)
27615 {
27616 break;
27617 }
27618 }
27619 Main.tileSolid[232] = true;
27620 }
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:1455
static bool AddBuriedChest(Point point, int contain=0, bool notNearOtherChests=false, int Style=-1)
static bool mayanTrap(int x2, int y2)
Definition WorldGen.cs:4967
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:6481

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.

+ Here is the call graph for this function: