Terraria.Chest.FindEmptyChest C# (CSharp) Method

FindEmptyChest() public static method

public static FindEmptyChest ( int x, int y, int type = 21, int style, int direction = 1 ) : int
x int
y int
type int
style int
direction int
return int
        public static int FindEmptyChest(int x, int y, int type = 21, int style = 0, int direction = 1)
        {
            int num = -1;
            for (int index = 0; index < 1000; ++index)
            {
                Chest chest = Main.chest[index];
                if (chest != null)
                {
                    if (chest.x == x && chest.y == y)
                        return -1;
                }
                else if (num == -1)
                    num = index;
            }
            return num;
        }