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

◆ CheckChest()

static void Terraria.WorldGen.CheckChest ( int i,
int j,
int type )
inlinestatic

Definition at line 48945 of file WorldGen.cs.

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 }
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 {
49000 Chest.DestroyChest(m, n);
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 }
static bool destroyObject
Definition WorldGen.cs:1020
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static int GetChestItemDrop(int x, int y, int type)
static IEntitySource GetItemSource_FromTileBreak(int x, int y)

References Terraria.Chest.CanDestroyChest(), Terraria.Chest.DestroyChest(), Terraria.Item.NewItem(), Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, and System.type.