Terraria.Chest.DestroyChest C# (CSharp) Method

DestroyChest() public static method

public static DestroyChest ( int X, int Y ) : bool
X int
Y int
return bool
        public static bool DestroyChest(int X, int Y)
        {
            for (int index1 = 0; index1 < 1000; ++index1)
            {
                Chest chest = Main.chest[index1];
                if (chest != null && chest.x == X && chest.y == Y)
                {
                    for (int index2 = 0; index2 < 40; ++index2)
                    {
                        if (chest.item[index2] != null && chest.item[index2].itemId > 0 && chest.item[index2].stack > 0)
                            return false;
                    }
                    Main.chest[index1] = null;
                    if (Main.player[Main.myPlayer].chest == index1)
                        Main.player[Main.myPlayer].chest = -1;
                    return true;
                }
            }
            return true;
        }