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

◆ CheckCrackedBrickBreak()

void Terraria.Player.CheckCrackedBrickBreak ( )
inline

Definition at line 22332 of file Player.cs.

22333 {
22334 if (shimmering)
22335 {
22336 return;
22337 }
22338 bool flag = false;
22339 if ((float)Main.rand.Next(2, 12) < Math.Abs(velocity.X))
22340 {
22341 flag = true;
22342 }
22343 if ((float)Main.rand.Next(2, 12) < velocity.Y)
22344 {
22345 flag = true;
22346 }
22347 if (flag && velocity.Y < 1f)
22348 {
22349 Point point = (base.Bottom + Vector2.UnitY).ToTileCoordinates();
22350 Point point2 = (base.BottomLeft + Vector2.UnitY).ToTileCoordinates();
22351 Point point3 = (base.BottomRight + Vector2.UnitY).ToTileCoordinates();
22352 if ((WorldGen.SolidTileAllowBottomSlope(point.X, point.Y) && !TileID.Sets.CrackedBricks[Main.tile[point.X, point.Y].type]) || (WorldGen.SolidTileAllowBottomSlope(point2.X, point2.Y) && !TileID.Sets.CrackedBricks[Main.tile[point2.X, point2.Y].type]) || (WorldGen.SolidTileAllowBottomSlope(point3.X, point3.Y) && !TileID.Sets.CrackedBricks[Main.tile[point3.X, point3.Y].type]))
22353 {
22354 flag = false;
22355 }
22356 }
22357 if (!flag)
22358 {
22359 return;
22360 }
22362 flag = false;
22363 int num = (int)(vector.X / 16f);
22364 int num2 = (int)((vector.X + (float)width) / 16f);
22365 int num3 = (int)((position.Y + (float)height + 1f) / 16f);
22367 rect.Inflate(1, 1);
22368 for (int i = num; i <= num2; i++)
22369 {
22370 for (int j = num3; j <= num3 + 1 && Main.tile[i, j] != null; j++)
22371 {
22372 if (Main.tile[i, j].nactive() && !WorldGen.SolidTile(i, j - 1) && TileID.Sets.CrackedBricks[Main.tile[i, j].type] && new Rectangle(i * 16, j * 16, 16, 16).Intersects(rect))
22373 {
22374 flag = true;
22375 if (velocity.Y > 1f)
22376 {
22377 velocity.Y = 1f;
22378 }
22379 NetMessage.SendData(13, -1, -1, null, whoAmI);
22380 }
22381 }
22382 }
22383 if (!flag)
22384 {
22385 return;
22386 }
22387 num = (int)((vector.X - 16f - 8f) / 16f);
22388 num2 = (int)((vector.X + (float)width + 16f + 8f) / 16f);
22389 for (int k = num; k <= num2; k++)
22390 {
22391 for (int l = num3; l <= num3 + 2; l++)
22392 {
22393 if (Main.tile[k, l].nactive() && !WorldGen.SolidTile(k, l - 1) && TileID.Sets.CrackedBricks[Main.tile[k, l].type])
22394 {
22395 WorldGen.KillTile(k, l);
22396 if (Main.netMode == 1)
22397 {
22398 NetMessage.SendData(17, -1, -1, null, 20, k, l);
22399 }
22400 }
22401 }
22402 }
22403 }
static double Abs(double value)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static bool[] CrackedBricks
Definition TileID.cs:113
Rectangle getRect()
Definition Player.cs:40162

References System.Math.Abs(), Terraria.ID.TileID.Sets.CrackedBricks, Microsoft.Xna.Framework.Intersects, Terraria.WorldGen.KillTile(), Terraria.Main.netMode, Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.WorldGen.SolidTile(), Terraria.WorldGen.SolidTileAllowBottomSlope(), Terraria.Main.tile, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.