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

◆ CheckRoom()

static void Terraria.WorldGen.CheckRoom ( int x,
int y )
inlinestatic

Definition at line 2621 of file WorldGen.cs.

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 }
static bool[] HousingWalls
Definition TileID.cs:275
static int[] roomX
Definition WorldGen.cs:1048
static void CheckRoom(int x, int y)
Definition WorldGen.cs:2621
static int[] roomY
Definition WorldGen.cs:1050
static int roomCeilingsCount
Definition WorldGen.cs:1052
static int roomY2
Definition WorldGen.cs:1064
static int roomX2
Definition WorldGen.cs:1060
static bool roomHasEchoStinkbug
Definition WorldGen.cs:1090
static bool roomHasStinkbug
Definition WorldGen.cs:1088
static bool canSpawn
Definition WorldGen.cs:1066
static TownNPCRoomCheckFailureReason roomCheckFailureReason
Definition WorldGen.cs:1106
static int maxRoomTiles
Definition WorldGen.cs:1044
static bool[] houseTile
Definition WorldGen.cs:1068
static int[] roomCeilingX
Definition WorldGen.cs:1054
static int roomY1
Definition WorldGen.cs:1062
static int[] roomCeilingY
Definition WorldGen.cs:1056
static int lastMaxTilesY
Definition WorldGen.cs:994
static int roomX1
Definition WorldGen.cs:1058
static int numRoomTiles
Definition WorldGen.cs:1046

References Terraria.WorldGen.canSpawn, Terraria.WorldGen.CheckRoom(), Terraria.WorldGen.houseTile, Terraria.ID.TileID.Sets.HousingWalls, Terraria.WorldGen.lastMaxTilesY, Terraria.WorldGen.maxRoomTiles, Terraria.Main.maxTilesX, Terraria.WorldGen.numRoomTiles, Terraria.WorldGen.roomCeilingsCount, Terraria.WorldGen.roomCeilingX, Terraria.WorldGen.roomCeilingY, Terraria.WorldGen.roomCheckFailureReason, Terraria.WorldGen.roomHasEchoStinkbug, Terraria.WorldGen.roomHasStinkbug, Terraria.WorldGen.roomX, Terraria.WorldGen.roomX1, Terraria.WorldGen.roomX2, Terraria.WorldGen.roomY, Terraria.WorldGen.roomY1, Terraria.WorldGen.roomY2, Terraria.Main.tile, Terraria.Main.tileSolid, and Terraria.Main.wallHouse.

Referenced by Terraria.WorldGen.CheckRoom(), and Terraria.WorldGen.StartRoomCheck().