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

◆ CanPlace() [1/2]

bool Terraria.WorldBuilding.StructureMap.CanPlace ( Rectangle area,
bool[] validTiles,
int padding = 0 )
inline

Definition at line 21 of file StructureMap.cs.

22 {
23 lock (_lock)
24 {
25 if (area.X < 0 || area.Y < 0 || area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)
26 {
27 return false;
28 }
29 Rectangle rectangle = new Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2);
30 for (int i = 0; i < _protectedStructures.Count; i++)
31 {
32 if (rectangle.Intersects(_protectedStructures[i]))
33 {
34 return false;
35 }
36 }
37 for (int j = rectangle.X; j < rectangle.X + rectangle.Width; j++)
38 {
39 for (int k = rectangle.Y; k < rectangle.Y + rectangle.Height; k++)
40 {
41 if (Main.tile[j, k].active())
42 {
43 ushort type = Main.tile[j, k].type;
44 if (!validTiles[type])
45 {
46 return false;
47 }
48 }
49 }
50 }
51 return true;
52 }
53 }
readonly List< Rectangle > _protectedStructures

References Terraria.WorldBuilding.StructureMap._lock, Terraria.WorldBuilding.StructureMap._protectedStructures, System.Collections.Generic.List< T >.Count, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, and Terraria.Main.tile.