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

◆ ItemCheck_UseMiningTools_TryPoundingTile()

void Terraria.Player.ItemCheck_UseMiningTools_TryPoundingTile ( Item sItem,
int tileHitId,
ref bool hitWall,
int x,
int y )
inlineprivate

Definition at line 43746 of file Player.cs.

43747 {
43748 Tile tile = Main.tile[x, y];
43749 if (sItem.hammer > 0 && tile.active() && (Main.tileSolid[tile.type] || tile.type == 314 || tile.type == 351 || tile.type == 424 || tile.type == 442) && poundRelease)
43750 {
43751 hitWall = false;
43753 int damageAmount = 100;
43754 if (WorldGen.IsLockedDoor(x, y - 1) || WorldGen.IsLockedDoor(x, y + 1))
43755 {
43756 damageAmount = 0;
43757 }
43759 {
43760 ClearMiningCacheAt(x, y, 1);
43761 if (!poundRelease)
43762 {
43763 return;
43764 }
43765 if (TileID.Sets.Platforms[Main.tile[x, y].type])
43766 {
43767 if (tile.halfBrick())
43768 {
43769 WorldGen.PoundTile(x, y);
43770 if (Main.netMode == 1)
43771 {
43772 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
43773 }
43774 }
43775 else
43776 {
43777 int num = 1;
43778 int slope = 2;
43779 if (TileID.Sets.Platforms[Main.tile[x + 1, y - 1].type] || TileID.Sets.Platforms[Main.tile[x - 1, y + 1].type] || (WorldGen.SolidTile(x + 1, y) && !WorldGen.SolidTile(x - 1, y)))
43780 {
43781 num = 2;
43782 slope = 1;
43783 }
43784 if (Main.tile[x, y].slope() == 0)
43785 {
43786 WorldGen.SlopeTile(x, y, num);
43787 int num2 = Main.tile[x, y].slope();
43788 if (Main.netMode == 1)
43789 {
43790 NetMessage.SendData(17, -1, -1, null, 14, x, y, num2);
43791 }
43792 }
43793 else if (Main.tile[x, y].slope() == num)
43794 {
43795 WorldGen.SlopeTile(x, y, slope);
43796 int num3 = Main.tile[x, y].slope();
43797 if (Main.netMode == 1)
43798 {
43799 NetMessage.SendData(17, -1, -1, null, 14, x, y, num3);
43800 }
43801 }
43802 else
43803 {
43804 WorldGen.SlopeTile(x, y);
43805 int num4 = Main.tile[x, y].slope();
43806 if (Main.netMode == 1)
43807 {
43808 NetMessage.SendData(17, -1, -1, null, 14, x, y, num4);
43809 }
43810 WorldGen.PoundTile(x, y);
43811 if (Main.netMode == 1)
43812 {
43813 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
43814 }
43815 }
43816 }
43817 }
43818 else if (Main.tile[x, y].type == 314)
43819 {
43820 if (Minecart.FrameTrack(x, y, pound: true) && Main.netMode == 1)
43821 {
43822 NetMessage.SendData(17, -1, -1, null, 15, x, y, 1f);
43823 }
43824 }
43825 else if (Main.tile[x, y].type == 137)
43826 {
43827 int num5 = 0;
43828 switch (Main.tile[x, y].frameY / 18)
43829 {
43830 case 0:
43831 case 1:
43832 case 2:
43833 case 5:
43834 switch (Main.tile[x, y].frameX / 18)
43835 {
43836 case 0:
43837 num5 = 2;
43838 break;
43839 case 1:
43840 num5 = 3;
43841 break;
43842 case 2:
43843 num5 = 4;
43844 break;
43845 case 3:
43846 num5 = 5;
43847 break;
43848 case 4:
43849 num5 = 1;
43850 break;
43851 case 5:
43852 num5 = 0;
43853 break;
43854 }
43855 break;
43856 case 3:
43857 case 4:
43858 switch (Main.tile[x, y].frameX / 18)
43859 {
43860 case 0:
43861 case 1:
43862 num5 = 3;
43863 break;
43864 case 3:
43865 num5 = 2;
43866 break;
43867 case 2:
43868 num5 = 4;
43869 break;
43870 case 4:
43871 num5 = 0;
43872 break;
43873 }
43874 break;
43875 }
43876 Main.tile[x, y].frameX = (short)(num5 * 18);
43877 if (Main.netMode == 1)
43878 {
43879 NetMessage.SendTileSquare(-1, x, y);
43880 }
43881 }
43882 else if (Main.tile[x, y].type == 424)
43883 {
43884 if (Main.tile[x, y].frameX == 0)
43885 {
43886 Main.tile[x, y].frameX = 18;
43887 }
43888 else if (Main.tile[x, y].frameX == 18)
43889 {
43890 Main.tile[x, y].frameX = 36;
43891 }
43892 else
43893 {
43894 Main.tile[x, y].frameX = 0;
43895 }
43896 if (Main.netMode == 1)
43897 {
43898 NetMessage.SendTileSquare(-1, x, y);
43899 }
43900 }
43901 else if (Main.tile[x, y].type == 442)
43902 {
43903 Tile tile2 = Main.tile[x, y - 1];
43904 Tile tile3 = Main.tile[x, y + 1];
43905 Tile tile4 = Main.tile[x - 1, y];
43906 Tile tile5 = Main.tile[x + 1, y];
43907 Tile tile6 = Main.tile[x - 1, y + 1];
43908 Tile tile7 = Main.tile[x + 1, y + 1];
43909 Tile tile8 = Main.tile[x - 1, y - 1];
43910 Tile tile9 = Main.tile[x + 1, y - 1];
43911 int num6 = -1;
43912 int num7 = -1;
43913 int num8 = -1;
43914 int num9 = -1;
43915 int tree = -1;
43916 int tree2 = -1;
43917 int tree3 = -1;
43918 int tree4 = -1;
43919 if (tile2 != null && tile2.nactive() && !tile2.bottomSlope())
43920 {
43921 num7 = tile2.type;
43922 }
43923 if (tile3 != null && tile3.nactive() && !tile3.halfBrick() && !tile3.topSlope())
43924 {
43925 num6 = tile3.type;
43926 }
43927 if (tile4 != null && tile4.nactive() && (tile4.slope() == 0 || tile4.slope() % 2 != 1))
43928 {
43929 num8 = tile4.type;
43930 }
43931 if (tile5 != null && tile5.nactive() && (tile5.slope() == 0 || tile5.slope() % 2 != 0))
43932 {
43933 num9 = tile5.type;
43934 }
43935 if (tile6 != null && tile6.nactive())
43936 {
43937 tree = tile6.type;
43938 }
43939 if (tile7 != null && tile7.nactive())
43940 {
43941 tree2 = tile7.type;
43942 }
43943 if (tile8 != null && tile8.nactive())
43944 {
43945 tree3 = tile8.type;
43946 }
43947 if (tile9 != null && tile9.nactive())
43948 {
43949 tree4 = tile9.type;
43950 }
43951 bool flag = false;
43952 bool flag2 = false;
43953 bool flag3 = false;
43954 bool flag4 = false;
43955 if (num6 >= 0 && Main.tileSolid[num6] && (!Main.tileNoAttach[num6] || TileID.Sets.Platforms[num6]) && (tile3.bottomSlope() || tile3.slope() == 0) && !tile3.halfBrick())
43956 {
43957 flag4 = true;
43958 }
43959 if (num7 >= 0 && Main.tileSolid[num7] && (!Main.tileNoAttach[num7] || (TileID.Sets.Platforms[num7] && tile2.halfBrick())) && (tile2.topSlope() || tile2.slope() == 0 || tile2.halfBrick()))
43960 {
43961 flag = true;
43962 }
43963 if ((num8 >= 0 && Main.tileSolid[num8] && !Main.tileNoAttach[num8] && (tile4.leftSlope() || tile4.slope() == 0) && !tile4.halfBrick()) || (num8 >= 0 && TileID.Sets.IsBeam[num8]) || (WorldGen.IsTreeType(num8) && WorldGen.IsTreeType(tree3) && WorldGen.IsTreeType(tree)))
43964 {
43965 flag2 = true;
43966 }
43967 if ((num9 >= 0 && Main.tileSolid[num9] && !Main.tileNoAttach[num9] && (tile5.rightSlope() || tile5.slope() == 0) && !tile5.halfBrick()) || (num9 >= 0 && TileID.Sets.IsBeam[num9]) || (WorldGen.IsTreeType(num9) && WorldGen.IsTreeType(tree4) && WorldGen.IsTreeType(tree2)))
43968 {
43969 flag3 = true;
43970 }
43971 int num10 = Main.tile[x, y].frameX / 22;
43972 short num11 = -2;
43973 switch (num10)
43974 {
43975 case 0:
43976 num11 = (short)((!flag2) ? (flag ? 1 : ((!flag3) ? (-1) : 3)) : 2);
43977 break;
43978 case 2:
43979 num11 = (short)(flag ? 1 : ((!flag3) ? ((!flag4) ? (-1) : 0) : 3));
43980 break;
43981 case 1:
43982 num11 = (short)((!flag3) ? ((!flag4) ? ((!flag2) ? (-1) : 2) : 0) : 3);
43983 break;
43984 case 3:
43985 num11 = (short)((!flag4) ? ((!flag2) ? (flag ? 1 : (-1)) : 2) : 0);
43986 break;
43987 }
43988 if (num11 != -1)
43989 {
43990 if (num11 == -2)
43991 {
43992 num11 = 0;
43993 }
43994 Main.tile[x, y].frameX = (short)(22 * num11);
43995 if (Main.netMode == 1)
43996 {
43997 NetMessage.SendTileSquare(-1, x, y);
43998 }
43999 }
44000 }
44001 else if ((Main.tile[x, y].halfBrick() || Main.tile[x, y].slope() != 0) && !Main.tileSolidTop[Main.tile[x, y].type])
44002 {
44003 int num12 = 1;
44004 int num13 = 1;
44005 int num14 = 2;
44006 if ((WorldGen.SolidTile(x + 1, y) || Main.tile[x + 1, y].slope() == 1 || Main.tile[x + 1, y].slope() == 3) && !WorldGen.SolidTile(x - 1, y))
44007 {
44008 num13 = 2;
44009 num14 = 1;
44010 }
44011 if (WorldGen.SolidTile(x, y - 1) && !WorldGen.SolidTile(x, y + 1))
44012 {
44013 num12 = -1;
44014 }
44015 if (num12 == 1)
44016 {
44017 if (Main.tile[x, y].slope() == 0)
44018 {
44019 WorldGen.SlopeTile(x, y, num13);
44020 }
44021 else if (Main.tile[x, y].slope() == num13)
44022 {
44023 WorldGen.SlopeTile(x, y, num14);
44024 }
44025 else if (Main.tile[x, y].slope() == num14)
44026 {
44027 WorldGen.SlopeTile(x, y, num13 + 2);
44028 }
44029 else if (Main.tile[x, y].slope() == num13 + 2)
44030 {
44031 WorldGen.SlopeTile(x, y, num14 + 2);
44032 }
44033 else
44034 {
44035 WorldGen.SlopeTile(x, y);
44036 }
44037 }
44038 else if (Main.tile[x, y].slope() == 0)
44039 {
44040 WorldGen.SlopeTile(x, y, num13 + 2);
44041 }
44042 else if (Main.tile[x, y].slope() == num13 + 2)
44043 {
44044 WorldGen.SlopeTile(x, y, num14 + 2);
44045 }
44046 else if (Main.tile[x, y].slope() == num14 + 2)
44047 {
44048 WorldGen.SlopeTile(x, y, num13);
44049 }
44050 else if (Main.tile[x, y].slope() == num13)
44051 {
44052 WorldGen.SlopeTile(x, y, num14);
44053 }
44054 else
44055 {
44056 WorldGen.SlopeTile(x, y);
44057 }
44058 int num15 = Main.tile[x, y].slope();
44059 if (Main.netMode == 1)
44060 {
44061 NetMessage.SendData(17, -1, -1, null, 14, x, y, num15);
44062 }
44063 }
44064 else
44065 {
44066 WorldGen.PoundTile(x, y);
44067 if (Main.netMode == 1)
44068 {
44069 NetMessage.SendData(17, -1, -1, null, 7, x, y, 1f);
44070 }
44071 }
44072 poundRelease = false;
44073 }
44074 else
44075 {
44076 WorldGen.KillTile(x, y, fail: true, effectOnly: true);
44077 SoundEngine.PlaySound(0, x * 16, y * 16);
44078 }
44079 }
44080 else
44081 {
44082 poundRelease = false;
44083 }
44084 }
static void PlaySound(int type, Vector2 position, int style=1)
int AddDamage(int tileId, int damageAmount, bool updateAmount=true)
Definition HitTile.cs:177
static bool[] IsBeam
Definition TileID.cs:161
static bool[] Platforms
Definition TileID.cs:163
bool poundRelease
Definition Player.cs:1185
void ApplyItemTime(Item sItem)
Definition Player.cs:3752
HitTile hitTile
Definition Player.cs:1323
void ClearMiningCacheAt(int x, int y, int hitTileCacheType)
Definition Player.cs:50311

References Terraria.Tile.active(), Terraria.Minecart.FrameTrack(), Terraria.Tile.halfBrick(), Terraria.ID.TileID.Sets.IsBeam, Terraria.WorldGen.IsLockedDoor(), Terraria.WorldGen.IsTreeType(), Terraria.WorldGen.KillTile(), Terraria.Main.netMode, Terraria.ID.TileID.Sets.Platforms, Terraria.Audio.SoundEngine.PlaySound(), Terraria.WorldGen.PoundTile(), Terraria.NetMessage.SendData(), Terraria.NetMessage.SendTileSquare(), Terraria.WorldGen.SlopeTile(), Terraria.WorldGen.SolidTile(), Terraria.Main.tile, Terraria.Main.tileNoAttach, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Tile.type.