/// <summary> /// Indicates if a given tile is "solid". /// </summary> /// <param name="tile"></param> /// <param name="isPlatformSolid"></param> /// <param name="isActuatedSolid"></param> /// <returns></returns> public static bool IsSolid(Tile tile, bool isPlatformSolid = false, bool isActuatedSolid = false) { if (TileLibraries.IsAir(tile)) { return(false); } if (!Main.tileSolid[tile.type] || !tile.active()) { return(false); } if (!isPlatformSolid) { bool isTopSolid = Main.tileSolidTop[tile.type]; if (isTopSolid) { return(false); } } if (!isActuatedSolid && tile.inActive()) { return(false); } return(true); }
/// <summary> /// Indicates if a given tile is "air" (including no walls). /// </summary> /// <param name="tile"></param> /// <param name="isWireAir"></param> /// <param name="isLiquidAir"></param> /// <returns></returns> public static bool IsAir(Tile tile, bool isWireAir = false, bool isLiquidAir = false) { if (tile == null) { return(true); } if (tile.active() || tile.wall > 0) /*|| tile.type == 0*/ { return(false); } if (!isWireAir && TileLibraries.IsWire(tile)) { return(false); } if (!isLiquidAir && tile.liquid != 0) { return(false); } return(true); }
//////////////// /// <summary> /// Kills a given tile. Results are synced. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <param name="effectOnly">Only a visual effect; tile is not actually killed (nothing to sync).</param> /// <param name="dropsItem"></param> /// <param name="forceSyncIfUnchanged"></param> /// <param name="suppressErrors"></param> /// <returns>`true` when no complications occurred during removal. Does not force tile to be removed, if /// complications occur.</returns> public static bool KillTileSynced( int tileX, int tileY, bool effectOnly, bool dropsItem, bool forceSyncIfUnchanged, bool suppressErrors = true) { Tile tile = Framing.GetTileSafely(tileX, tileY); if (!tile.active()) { if (forceSyncIfUnchanged && Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 4, (float)tileX, (float)tileY, 0f, 0, 0, 0); } return(false); } bool isTileKilled = false; bool isContainer = tile.type == TileID.Containers || tile.type == TileID.Containers2; try { if (isContainer) { isTileKilled = TileLibraries.KillContainerTileSynced(tileX, tileY, effectOnly, dropsItem); } else { WorldGen.KillTile(tileX, tileY, false, effectOnly, !dropsItem); isTileKilled = effectOnly || !Main.tile[tileX, tileY].active(); } } catch (Exception e) { if (!suppressErrors) { LogLibraries.WarnOnce("Could not kill type (with sync) at " + tileX + ", " + tileY + " (effectOnly:" + effectOnly + ", dropsItem:" + dropsItem + ": " + e.Message); throw e; } return(false); } if (!isContainer && !effectOnly) { if (Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData( msgType: MessageID.TileChange, remoteClient: -1, ignoreClient: -1, text: null, number: dropsItem ? 0 : 4, number2: (float)tileX, number3: (float)tileY, number4: 0f, number5: 0, number6: 0, number7: 0 ); } } return(isTileKilled); }