Esempio n. 1
0
        public void MineBlock(int x, int y, int pickPower, Chest chest, HitTile hitTile)
        {
            hitTile.UpdatePosition(Main.tile[x, y].type, x, y);
            int  num    = 0;
            int  tileId = hitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[(int)tile.type])
            {
                num = 100;
            }
            if (Main.tileDungeon[(int)tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                num += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                num += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref num);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                num = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                num = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                num = 0;
            }
            else if (tile.type == 56 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 58 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                num = 0;
            }
            else if (Main.tileDungeon[(int)tile.type] && pickPower < 65)
            {
                if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                {
                    num = 0;
                }
            }
            else if (tile.type == 107 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 108 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 111 && pickPower < 150)
            {
                num = 0;
            }
            else if (tile.type == 221 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 222 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 223 && pickPower < 150)
            {
                num = 0;
            }
            else
            {
                TileLoader.PickPowerCheck(tile, pickPower, ref num);
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                num += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[(int)tile.type] || tile.type == 199 || Main.tileMoss[(int)tile.type])
            {
                num = 100;
            }
            if (hitTile.AddDamage(tileId, num, false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[(int)tile.type]))
            {
                num = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                int  i     = (int)tile.frameX;
                bool flag  = i >= 5000;
                bool flag2 = false;
                if (!flag)
                {
                    int num2 = i / 18;
                    num2 %= 3;
                    x    -= num2;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    i = (int)tile.frameX;
                    int num3 = 0;
                    while (i >= 5000)
                    {
                        i -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (!WorldGen.CanKillTile(x, y))
            {
                num = 0;
            }
            if (hitTile.AddDamage(tileId, num, true) >= 100)
            {
                hitTile.Clear(tileId);
                if (Main.netMode == 2 && Main.tileContainer[(int)Main.tile[x, y].type])
                {
                    WorldGen.KillTile(x, y, true, false, false);
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                    if (TileLoader.IsChest((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 1, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (TileLoader.IsDresser((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 3, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                }
                else
                {
                    int  num4  = y;
                    bool flag3 = Main.tile[x, num4].active();
                    WorldGen.KillTile(x, num4, false, false, false);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)num4, 0f, 0, 0, 0);
                    }
                }
            }
            else
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                }
            }
            if (num != 0)
            {
                hitTile.Prune();
            }
        }