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

◆ KillTile()

static void Terraria.WorldGen.KillTile ( int i,
int j,
bool fail = false,
bool effectOnly = false,
bool noItem = false )
inlinestatic

Definition at line 54141 of file WorldGen.cs.

54142 {
54143 if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
54144 {
54145 return;
54146 }
54147 Tile tile = Main.tile[i, j];
54148 if (tile == null)
54149 {
54150 tile = new Tile();
54151 Main.tile[i, j] = tile;
54152 }
54153 if (!tile.active())
54154 {
54155 return;
54156 }
54157 if (j >= 1 && Main.tile[i, j - 1] == null)
54158 {
54159 Main.tile[i, j - 1] = new Tile();
54160 }
54161 int num = CheckTileBreakability(i, j);
54162 if (num == 1)
54163 {
54164 fail = true;
54165 }
54166 if (num == 2)
54167 {
54168 return;
54169 }
54170 if (gen)
54171 {
54172 noItem = true;
54173 }
54174 if (!effectOnly && !stopDrops)
54175 {
54177 {
54178 return;
54179 }
54180 if (!Main.dedServ && !gen && !Main.gameMenu)
54181 {
54182 KillTile_PlaySounds(i, j, fail, tile);
54183 }
54184 }
54185 if (tile.type == 128 || tile.type == 269)
54186 {
54187 int num2 = i;
54188 int num3 = tile.frameX;
54189 int num4;
54190 for (num4 = tile.frameX; num4 >= 100; num4 -= 100)
54191 {
54192 }
54193 while (num4 >= 36)
54194 {
54195 num4 -= 36;
54196 }
54197 if (num4 == 18)
54198 {
54199 num3 = Main.tile[i - 1, j].frameX;
54200 num2--;
54201 }
54202 if (num3 >= 100)
54203 {
54204 int num5 = 0;
54205 while (num3 >= 100)
54206 {
54207 num3 -= 100;
54208 num5++;
54209 }
54210 int num6 = Main.tile[num2, j].frameY / 18;
54211 if (num6 == 0)
54212 {
54213 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.headType[num5]);
54214 }
54215 if (num6 == 1)
54216 {
54217 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.bodyType[num5]);
54218 }
54219 if (num6 == 2)
54220 {
54221 Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, Item.legType[num5]);
54222 }
54223 for (num3 = Main.tile[num2, j].frameX; num3 >= 100; num3 -= 100)
54224 {
54225 }
54226 Main.tile[num2, j].frameX = (short)num3;
54227 }
54228 }
54229 if (tile.type == 334)
54230 {
54231 int num7 = i;
54232 int frameX = tile.frameX;
54233 int num8 = tile.frameX;
54234 int num9 = 0;
54235 while (num8 >= 5000)
54236 {
54237 num8 -= 5000;
54238 num9++;
54239 }
54240 if (num9 != 0)
54241 {
54242 num8 = (num9 - 1) * 18;
54243 }
54244 num8 %= 54;
54245 if (num8 == 18)
54246 {
54247 frameX = Main.tile[i - 1, j].frameX;
54248 num7--;
54249 }
54250 if (num8 == 36)
54251 {
54252 frameX = Main.tile[i - 2, j].frameX;
54253 num7 -= 2;
54254 }
54255 if (frameX >= 5000)
54256 {
54257 int num10 = frameX % 5000;
54258 num10 -= 100;
54259 int frameX2 = Main.tile[num7 + 1, j].frameX;
54260 frameX2 = ((frameX2 < 25000) ? (frameX2 - 10000) : (frameX2 - 25000));
54261 if (Main.netMode != 1)
54262 {
54263 Item item = new Item();
54264 item.netDefaults(num10);
54265 item.Prefix(frameX2);
54266 int num11 = Item.NewItem(GetItemSource_FromTileBreak(i, j), i * 16, j * 16, 16, 16, num10, 1, noBroadcast: true);
54267 item.position = Main.item[num11].position;
54268 Main.item[num11] = item;
54269 NetMessage.SendData(21, -1, -1, null, num11);
54270 }
54271 frameX = Main.tile[num7, j].frameX;
54272 int num12 = 0;
54273 while (frameX >= 5000)
54274 {
54275 frameX -= 5000;
54276 num12++;
54277 }
54278 if (num12 != 0)
54279 {
54280 frameX = (num12 - 1) * 18;
54281 }
54282 Main.tile[num7, j].frameX = (short)frameX;
54283 Main.tile[num7 + 1, j].frameX = (short)(frameX + 18);
54284 }
54285 }
54286 if (tile.type == 395)
54287 {
54288 int num13 = TEItemFrame.Find(i - tile.frameX % 36 / 18, j - tile.frameY % 36 / 18);
54289 if (num13 != -1 && ((TEItemFrame)TileEntity.ByID[num13]).item.stack > 0)
54290 {
54291 ((TEItemFrame)TileEntity.ByID[num13]).DropItem();
54292 if (Main.netMode != 2)
54293 {
54294 Main.LocalPlayer.InterruptItemUsageIfOverTile(395);
54295 }
54296 return;
54297 }
54298 }
54299 if (tile.type == 471)
54300 {
54301 int num14 = TEWeaponsRack.Find(i - tile.frameX % 54 / 18, j - tile.frameY % 54 / 18);
54302 if (num14 != -1 && ((TEWeaponsRack)TileEntity.ByID[num14]).item.stack > 0)
54303 {
54304 ((TEWeaponsRack)TileEntity.ByID[num14]).DropItem();
54305 if (Main.netMode != 2)
54306 {
54307 Main.LocalPlayer.InterruptItemUsageIfOverTile(471);
54308 }
54309 return;
54310 }
54311 }
54312 if (tile.type == 520)
54313 {
54314 int num15 = TEFoodPlatter.Find(i, j);
54315 if (num15 != -1 && ((TEFoodPlatter)TileEntity.ByID[num15]).item.stack > 0)
54316 {
54317 ((TEFoodPlatter)TileEntity.ByID[num15]).DropItem();
54318 if (Main.netMode != 2)
54319 {
54320 Main.LocalPlayer.InterruptItemUsageIfOverTile(520);
54321 }
54322 return;
54323 }
54324 }
54325 if ((tile.type == 470 && (CheckTileBreakability2_ShouldTileSurvive(i, j) || fail)) || (tile.type == 475 && (CheckTileBreakability2_ShouldTileSurvive(i, j) || fail)))
54326 {
54327 return;
54328 }
54330 for (int k = 0; k < num16; k++)
54331 {
54332 KillTile_MakeTileDust(i, j, tile);
54333 }
54334 if (effectOnly)
54335 {
54336 return;
54337 }
54338 AttemptFossilShattering(i, j, tile, fail);
54339 if (fail)
54340 {
54341 if (Main.netMode != 1 && TileID.Sets.IsShakeable[tile.type])
54342 {
54343 ShakeTree(i, j);
54344 }
54345 if (tile.type == 2 || tile.type == 23 || tile.type == 109 || tile.type == 199 || tile.type == 477 || tile.type == 492)
54346 {
54347 tile.type = 0;
54348 }
54349 if (tile.type == 633)
54350 {
54351 tile.type = 57;
54352 }
54353 if (tile.type == 60 || tile.type == 661 || tile.type == 662 || tile.type == 70)
54354 {
54355 tile.type = 59;
54356 }
54357 if (Main.tileMoss[tile.type])
54358 {
54359 tile.type = 1;
54360 }
54361 if (TileID.Sets.tileMossBrick[tile.type])
54362 {
54363 tile.type = 38;
54364 }
54365 SquareTileFrame(i, j);
54366 return;
54367 }
54368 if (Main.getGoodWorld && Main.netMode != 1 && tile.type == 57)
54369 {
54370 for (int l = 0; l < 8; l++)
54371 {
54372 int maxValue = 2;
54373 int num17 = i;
54374 int num18 = j;
54375 switch (l)
54376 {
54377 case 0:
54378 num17--;
54379 break;
54380 case 1:
54381 num17++;
54382 break;
54383 case 2:
54384 num18--;
54385 break;
54386 case 3:
54387 num18++;
54388 break;
54389 case 4:
54390 num17--;
54391 num18--;
54392 break;
54393 case 5:
54394 num17++;
54395 num18--;
54396 break;
54397 case 6:
54398 num17--;
54399 num18++;
54400 break;
54401 case 7:
54402 num17++;
54403 num18++;
54404 break;
54405 }
54406 Tile tile2 = Main.tile[num17, num18];
54407 if (tile2.active() && genRand.Next(maxValue) == 0 && tile2.type == 57 && !SolidTile(num17, num18 + 1))
54408 {
54410 if (Main.netMode == 2)
54411 {
54412 NetMessage.TrySendData(17, -1, -1, null, 20, num17, num18);
54413 }
54414 int num19 = Projectile.NewProjectile(GetProjectileSource_TileBreak(num17, num18), num17 * 16 + 8, num18 * 16 + 8, 0f, 0.41f, 40, 15, 0f, Main.myPlayer);
54415 Main.projectile[num19].netUpdate = true;
54416 }
54417 }
54418 }
54419 if (Main.netMode != 1 && tile.type >= 481 && tile.type <= 483)
54420 {
54421 for (int m = 0; m < 8; m++)
54422 {
54423 int num20 = 6;
54424 int num21 = i;
54425 int num22 = j;
54426 switch (m)
54427 {
54428 case 0:
54429 num21--;
54430 break;
54431 case 1:
54432 num21++;
54433 break;
54434 case 2:
54435 num22--;
54436 num20 /= 2;
54437 break;
54438 case 3:
54439 num22++;
54440 break;
54441 case 4:
54442 num21--;
54443 num22--;
54444 break;
54445 case 5:
54446 num21++;
54447 num22--;
54448 break;
54449 case 6:
54450 num21--;
54451 num22++;
54452 break;
54453 case 7:
54454 num21++;
54455 num22++;
54456 break;
54457 }
54458 Tile tile3 = Main.tile[num21, num22];
54459 if (tile3.active() && genRand.Next(num20) == 0 && tile3.type >= 481 && tile3.type <= 483)
54460 {
54461 tile.active(active: false);
54463 if (Main.netMode == 2)
54464 {
54465 NetMessage.TrySendData(17, -1, -1, null, 20, num21, num22);
54466 }
54467 }
54468 }
54469 int type = tile.type - 481 + 736;
54470 int damage = 20;
54472 if (Main.netMode == 0)
54473 {
54474 Projectile.NewProjectile(projectileSource_TileBreak, i * 16 + 8, j * 16 + 8, 0f, 0.41f, type, damage, 0f, Main.myPlayer);
54475 }
54476 else if (Main.netMode == 2)
54477 {
54478 int num23 = Projectile.NewProjectile(projectileSource_TileBreak, i * 16 + 8, j * 16 + 8, 0f, 0.41f, type, damage, 0f, Main.myPlayer);
54479 Main.projectile[num23].netUpdate = true;
54480 }
54481 }
54483 {
54484 return;
54485 }
54486 if (tile.type == 51 && tile.wall == 62 && genRand.Next(4) != 0)
54487 {
54488 noItem = true;
54489 }
54490 if (!noItem && !stopDrops && Main.netMode != 1)
54491 {
54492 KillTile_DropBait(i, j, tile);
54493 KillTile_DropItems(i, j, tile);
54494 }
54495 if (tile.type == 520)
54496 {
54497 TEFoodPlatter.Kill(i, j);
54498 }
54499 if (tile.type == 423)
54500 {
54501 TELogicSensor.Kill(i, j);
54502 }
54503 if (Main.netMode != 2)
54504 {
54505 AchievementsHelper.NotifyTileDestroyed(Main.player[Main.myPlayer], tile.type);
54506 }
54507 tile.active(active: false);
54508 tile.halfBrick(halfBrick: false);
54509 tile.frameX = -1;
54510 tile.frameY = -1;
54511 tile.ClearBlockPaintAndCoating();
54512 tile.frameNumber(0);
54513 if (Main.netMode != 1)
54514 {
54515 if (tile.type == 58 && j > Main.UnderworldLayer)
54516 {
54517 tile.lava(lava: true);
54518 tile.liquid = 128;
54519 }
54520 else if (tile.type == 230 && Main.getGoodWorld && genRand.Next(2) == 0)
54521 {
54522 tile.lava(lava: true);
54523 tile.liquid = 128;
54524 }
54525 }
54526 if (tile.type == 419)
54527 {
54528 Wiring.PokeLogicGate(i, j + 1);
54529 }
54530 else if (TileID.Sets.BlocksWaterDrawingBehindSelf[tile.type])
54531 {
54532 SquareWallFrame(i, j);
54533 }
54534 tile.type = 0;
54535 tile.inActive(inActive: false);
54536 SquareTileFrame(i, j);
54537 while (!destroyObject && ExploitDestroyQueue.Count > 0)
54538 {
54539 Point point = ExploitDestroyQueue.Dequeue();
54540 if (Framing.GetTileSafely(point.X, point.Y).active())
54541 {
54542 SquareTileFrame(point.X, point.Y);
54543 NetMessage.SendTileSquare(-1, point.X, point.Y);
54544 }
54545 }
54546 }
static Dictionary< int, TileEntity > ByID
Definition TileEntity.cs:18
static void NotifyTileDestroyed(Player player, ushort tile)
static bool[] tileMossBrick
Definition TileID.cs:219
static bool[] BlocksWaterDrawingBehindSelf
Definition TileID.cs:259
static bool[] IsShakeable
Definition TileID.cs:93
static bool destroyObject
Definition WorldGen.cs:1020
static volatile bool gen
Definition WorldGen.cs:972
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static void KillTile_DropItems(int x, int y, Tile tileCache, bool includeLargeObjectDrops=false)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static int CheckTileBreakability(int x, int y)
static void SquareWallFrame(int i, int j, bool resetFrame=true)
static Queue< Point > ExploitDestroyQueue
Definition WorldGen.cs:1192
static int KillTile_MakeTileDust(int i, int j, Tile tileCache)
static void AttemptFossilShattering(int i, int j, Tile tileCache, bool fail)
static void ShakeTree(int i, int j)
static EntitySource_TileBreak GetProjectileSource_TileBreak(int x, int y)
Definition WorldGen.cs:1308
static void KillTile_PlaySounds(int i, int j, bool fail, Tile tileCache)
static int KillTile_GetTileDustAmount(bool fail, Tile tileCache)
static IEntitySource GetItemSource_FromTileBreak(int x, int y)
static void SquareTileFrame(int i, int j, bool resetFrame=true)
static bool stopDrops
Definition WorldGen.cs:1004
static bool CheckTileBreakability2_ShouldTileSurvive(int x, int y)
static void KillTile_DropBait(int i, int j, Tile tileCache)

References Terraria.Tile.active(), Terraria.ID.TileID.Sets.BlocksWaterDrawingBehindSelf, Terraria.Item.bodyType, Terraria.DataStructures.TileEntity.ByID, Terraria.Tile.ClearBlockPaintAndCoating(), Terraria.Main.dedServ, Terraria.GameContent.Tile_Entities.TEFoodPlatter.Find(), Terraria.GameContent.Tile_Entities.TEItemFrame.Find(), Terraria.GameContent.Tile_Entities.TEWeaponsRack.Find(), Terraria.Tile.frameNumber(), Terraria.Tile.frameX, Terraria.Tile.frameY, Terraria.Main.gameMenu, Terraria.Main.getGoodWorld, Terraria.Framing.GetTileSafely(), Terraria.Tile.halfBrick(), Terraria.Item.headType, Terraria.Tile.inActive(), Terraria.ID.TileID.Sets.IsShakeable, System.item, Terraria.Main.item, Terraria.GameContent.Tile_Entities.TEFoodPlatter.Kill(), Terraria.GameContent.Tile_Entities.TELogicSensor.Kill(), Terraria.Tile.lava(), Terraria.Item.legType, Terraria.Main.LocalPlayer, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.Projectile.NewProjectile(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyTileDestroyed(), Terraria.Main.player, Terraria.Wiring.PokeLogicGate(), Terraria.Main.projectile, Terraria.NetMessage.SendData(), Terraria.NetMessage.SendTileSquare(), Terraria.Enums.SolidTile, Terraria.GameContent.FixExploitManEaters.SpotProtected(), Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileMoss, Terraria.ID.TileID.Sets.tileMossBrick, Terraria.NetMessage.TrySendData(), System.type, Terraria.Tile.type, Terraria.Main.UnderworldLayer, Terraria.Tile.wall, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.

Referenced by Terraria.Liquid.AddWater(), Terraria.NPC.AI_003_Fighters(), Terraria.NPC.AI_006_Worms(), Terraria.Projectile.AI_007_GrapplingHooks(), Terraria.Projectile.AI_010(), Terraria.NPC.AI_107_ImprovedWalkers(), Terraria.Projectile.AI_155_RemoveRope(), Terraria.Player.ApplyTouchDamage(), Terraria.Player.CheckCrackedBrickBreak(), Terraria.Player.CheckIceBreak(), Terraria.IO.WorldFile.ClearTempTiles(), Terraria.DelegateMethods.CutTiles(), Terraria.Projectile.CutTilesAt(), Terraria.Projectile.ExplodeCrackedTiles(), Terraria.Projectile.ExplodeTiles(), Terraria.Minecart.FrameTrack(), Terraria.GameContent.Tile_Entities.TEDisplayDoll.Framing_CheckTile(), Terraria.GameContent.Tile_Entities.TEHatRack.Framing_CheckTile(), Terraria.GameContent.Tile_Entities.TETeleportationPylon.Framing_CheckTile(), Terraria.GameContent.Tile_Entities.TEWeaponsRack.Framing_CheckTile(), Terraria.GameContent.Biomes.JunglePass.GenerateTunnelToSurface(), Terraria.WorldGen.GenerateWorld(), Terraria.MessageBuffer.GetData(), Terraria.Projectile.HandleMovement(), Terraria.Collision.HitTiles(), Terraria.Wiring.HitWireSingle(), Terraria.Player.ItemCheck_CheckCanUse(), Terraria.Player.ItemCheck_CutTiles(), Terraria.Player.ItemCheck_TryPlacingWearablesOnMannequins(), Terraria.Player.ItemCheck_UseMiningTools_ActuallyUseMiningTool(), Terraria.Player.ItemCheck_UseMiningTools_TryPoundingTile(), Terraria.Projectile.Kill(), Terraria.Liquid.LiquidCheck(), Terraria.WorldGen.mayanTrap(), Terraria.WorldGen.meteor(), Terraria.GameContent.MinecartDiggerHelper.MineTheTileIfNecessary(), Terraria.GameContent.Tile_Entities.TEFoodPlatter.OnPlayerInteraction(), Terraria.GameContent.Tile_Entities.TEItemFrame.OnPlayerInteraction(), Terraria.GameContent.Tile_Entities.TEWeaponsRack.OnPlayerInteraction(), Terraria.Player.PickTile(), Terraria.TileObject.Place(), Terraria.GameContent.Tile_Entities.TEFoodPlatter.PlaceItemInFrame(), Terraria.GameContent.Tile_Entities.TEItemFrame.PlaceItemInFrame(), Terraria.GameContent.Tile_Entities.TEWeaponsRack.PlaceItemInFrame(), Terraria.GameContent.Generation.TrackGenerator.PlacePath(), Terraria.Player.PlaceThing_PaintScrapper_LongMoss(), Terraria.Player.PlaceThing_Tiles_BlockPlacementForAssortedThings(), Terraria.Player.PlaceThing_Tiles_PlaceIt_KillGrassForSolids(), Terraria.WorldGen.placeTrap(), Terraria.Player.PlaceWeapon(), Terraria.GameContent.Tile_Entities.TETeleportationPylon.RejectPlacementFromNet(), Terraria.Player.Spawn_ForceClearArea(), Terraria.DelegateMethods.SpreadDirt(), Terraria.Player.StickyMovement(), Terraria.Collision.SwitchTiles(), and Terraria.Player.TileInteractionsUse().