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

◆ IsWorldPointSolid()

static bool Terraria.Collision.IsWorldPointSolid ( Vector2 pos,
bool treatPlatformsAsNonSolid = false )
inlinestatic

Definition at line 1225 of file Collision.cs.

1226 {
1227 Point point = pos.ToTileCoordinates();
1228 if (!WorldGen.InWorld(point.X, point.Y, 1))
1229 {
1230 return false;
1231 }
1232 Tile tile = Main.tile[point.X, point.Y];
1233 if (tile == null || !tile.active() || tile.inActive() || !Main.tileSolid[tile.type])
1234 {
1235 return false;
1236 }
1237 if (treatPlatformsAsNonSolid && tile.type > 0 && tile.type <= TileID.Count && (TileID.Sets.Platforms[tile.type] || tile.type == 380))
1238 {
1239 return false;
1240 }
1241 int num = tile.blockType();
1242 switch (num)
1243 {
1244 case 0:
1245 if (pos.X >= (float)(point.X * 16) && pos.X <= (float)(point.X * 16 + 16) && pos.Y >= (float)(point.Y * 16))
1246 {
1247 return pos.Y <= (float)(point.Y * 16 + 16);
1248 }
1249 return false;
1250 case 1:
1251 if (pos.X >= (float)(point.X * 16) && pos.X <= (float)(point.X * 16 + 16) && pos.Y >= (float)(point.Y * 16 + 8))
1252 {
1253 return pos.Y <= (float)(point.Y * 16 + 16);
1254 }
1255 return false;
1256 case 2:
1257 case 3:
1258 case 4:
1259 case 5:
1260 {
1261 if (pos.X < (float)(point.X * 16) && pos.X > (float)(point.X * 16 + 16) && pos.Y < (float)(point.Y * 16) && pos.Y > (float)(point.Y * 16 + 16))
1262 {
1263 return false;
1264 }
1265 float num2 = pos.X % 16f;
1266 float num3 = pos.Y % 16f;
1267 switch (num)
1268 {
1269 case 3:
1270 return num2 + num3 >= 16f;
1271 case 2:
1272 return num3 >= num2;
1273 case 5:
1274 return num3 <= num2;
1275 case 4:
1276 return num2 + num3 <= 16f;
1277 }
1278 break;
1279 }
1280 }
1281 return false;
1282 }
static bool[] Platforms
Definition TileID.cs:163
static readonly ushort Count
Definition TileID.cs:1698

References Terraria.Tile.active(), Terraria.Tile.blockType(), Terraria.ID.TileID.Count, Terraria.Tile.inActive(), Terraria.WorldGen.InWorld(), Terraria.ID.TileID.Sets.Platforms, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Tile.type, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, and Microsoft.Xna.Framework.Vector2.Y.