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

◆ FindEmptyChest()

static int Terraria.Chest.FindEmptyChest ( int x,
int y,
int type = 21,
int style = 0,
int direction = 1,
int alternate = 0 )
inlinestatic

Determines if a new chest can exist at tile coordinates (x , y ).

Parameters
xThe x-coordinate to check, in tile coordinates.
yThe y-coordinate to check, in tile coordinates.
typeUnused, but required for use with F:Terraria.DataStructures.PlacementHook.hook.
styleUnused, but required for use with F:Terraria.DataStructures.PlacementHook.hook.
directionUnused, but required for use with F:Terraria.DataStructures.PlacementHook.hook.
alternateUnused, but required for use with F:Terraria.DataStructures.PlacementHook.hook.
Returns
-1 if there exists a chest in F:Terraria.Main.chest at the coordinates (x , y ), or if F:Terraria.Main.chest contains no null elements.
Otherwise, the index in F:Terraria.Main.chest of the first null element.

Definition at line 805 of file Chest.cs.

806 {
807 int num = -1;
808 for (int i = 0; i < 8000; i++)
809 {
810 Chest chest = Main.chest[i];
811 if (chest != null)
812 {
813 if (chest.x == x && chest.y == y)
814 {
815 return -1;
816 }
817 }
818 else if (num == -1)
819 {
820 num = i;
821 }
822 }
823 return num;
824 }
int x
The x-coordinate of this chest in the world, in tile coordinates. (Top left corner tile)
Definition Chest.cs:98
Chest(bool bank=false)
Create a new T:Terraria.Chest with no name.
Definition Chest.cs:137
int y
The y-coordinate of this chest in the world, in tile coordinates. (Top left corner tile)
Definition Chest.cs:103

References Terraria.Main.chest, Terraria.Chest.x, and Terraria.Chest.y.

Referenced by Terraria.Chest.AfterPlacement_Hook(), Terraria.Chest.CreateChest(), and Terraria.ObjectData.TileObjectData.Initialize().

+ Here is the caller graph for this function: