Exemplo n.º 1
0
        /// <summary>
        /// Indicates if a given specific tile is "breakable" (typically to normal attacks).
        /// </summary>
        /// <param name="tileX"></param>
        /// <param name="tileY"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool IsBreakable(int tileX, int tileY, VanillaTileCuttingContext context = VanillaTileCuttingContext.AttackMelee)
        {
            Tile tile = Framing.GetTileSafely(tileX, tileY);

            return(Main.tileCut[tile.type] &&
                   WorldGen.CanCutTile(tileX, tileY, (TileCuttingContext)context));
        }
Exemplo n.º 2
0
        public override void CutTiles()
        {
            int num  = (int)(projectile.position.X / 16f);
            int num2 = (int)((projectile.position.X + (float)projectile.width) / 16f) + 1;
            int num3 = (int)(projectile.position.Y / 16f);
            int num4 = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 1;

            if (num < 0)
            {
                num = 0;
            }
            if (num2 > Main.maxTilesX)
            {
                num2 = Main.maxTilesX;
            }
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 > Main.maxTilesY)
            {
                num4 = Main.maxTilesY;
            }
            AchievementsHelper.CurrentlyMining = true;
            for (int i = num; i < num2; i++)
            {
                for (int j = num3; j < num4; j++)
                {
                    if (Main.tile[i, j] != null && Main.tileCut[Main.tile[i, j].type] && WorldGen.CanCutTile(i, j, TileCuttingContext.AttackProjectile))
                    {
                        WorldGen.KillTile(i, j, false, false, false);
                        if (Main.netMode != NetmodeID.SinglePlayer)
                        {
                            NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                        }
                    }
                }
            }
        }