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

◆ SolidCollision() [2/2]

static bool Terraria.Collision.SolidCollision ( Vector2 Position,
int Width,
int Height,
bool acceptTopSurfaces )
inlinestatic

Definition at line 2256 of file Collision.cs.

2257 {
2258 int value = (int)(Position.X / 16f) - 1;
2259 int value2 = (int)((Position.X + (float)Width) / 16f) + 2;
2260 int value3 = (int)(Position.Y / 16f) - 1;
2261 int value4 = (int)((Position.Y + (float)Height) / 16f) + 2;
2262 int num = Utils.Clamp(value, 0, Main.maxTilesX - 1);
2263 value2 = Utils.Clamp(value2, 0, Main.maxTilesX - 1);
2264 value3 = Utils.Clamp(value3, 0, Main.maxTilesY - 1);
2265 value4 = Utils.Clamp(value4, 0, Main.maxTilesY - 1);
2266 Vector2 vector = default(Vector2);
2267 for (int i = num; i < value2; i++)
2268 {
2269 for (int j = value3; j < value4; j++)
2270 {
2271 Tile tile = Main.tile[i, j];
2272 if (tile == null || !tile.active() || tile.inActive())
2273 {
2274 continue;
2275 }
2276 bool flag = Main.tileSolid[tile.type] && !Main.tileSolidTop[tile.type];
2278 {
2279 flag |= Main.tileSolidTop[tile.type] && tile.frameY == 0;
2280 }
2281 if (flag)
2282 {
2283 vector.X = i * 16;
2284 vector.Y = j * 16;
2285 int num2 = 16;
2286 if (tile.halfBrick())
2287 {
2288 vector.Y += 8f;
2289 num2 -= 8;
2290 }
2291 if (Position.X + (float)Width > vector.X && Position.X < vector.X + 16f && Position.Y + (float)Height > vector.Y && Position.Y < vector.Y + (float)num2)
2292 {
2293 return true;
2294 }
2295 }
2296 }
2297 }
2298 return false;
2299 }

References Terraria.Tile.active(), Terraria.Tile.halfBrick(), Terraria.Tile.inActive(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.Tile.type, and System.value.