/// <summary>
        /// Destroys the projectile
        /// </summary>
        public void Kill(Func<Int32, Int32, ITile> TileRefs, ISandbox sandbox)
        {
            if (TileRefs == null)
                TileRefs = TileCollection.ITileAt;

            if (!this.Active)
            {
                return;
            }
            this.timeLeft = 0;
            switch (this.type)
            {
                case ProjectileType.N14_BULLET:
                case ProjectileType.N20_GREEN_LASER:
                case ProjectileType.N36_METEOR_SHOT:
                case ProjectileType.N83_EYE_LASER:
                case ProjectileType.N84_PINK_LASER:
                case ProjectileType.N100_DEATH_LASER:
                    {
                        Collision.HitTiles(TileRefs, sandbox, this.Position, this.Velocity, this.Width, this.Height);
                    }
                    break;

                case ProjectileType.N28_BOMB:
                case ProjectileType.N30_GRENADE:
                case ProjectileType.N37_STICKY_BOMB:
                case ProjectileType.N75_HAPPY_BOMB:
                case ProjectileType.N102_BOMB:
                    {
                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 22;
                        this.Height = 22;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                    }
                    break;

                case ProjectileType.N29_DYNAMITE:
                    {
                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 200;
                        this.Height = 200;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                    }
                    break;

                case ProjectileType.N108_EXPLOSIVES:
                    {
                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 10;
                        this.Height = 10;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                    }
                    break;

                case ProjectileType.N41_HELLFIRE_ARROW:
                    {
                        if (this.Owner == Main.myPlayer)
                        {
                            this.penetrate = -1;
                            this.Position.X = this.Position.X + (float)(this.Width / 2);
                            this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                            this.Width = 64;
                            this.Height = 64;
                            this.Position.X = this.Position.X - (float)(this.Width / 2);
                            this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                            this.Damage(TileRefs, sandbox);
                        }
                    }
                    break;

                case ProjectileType.N80_ICE_BLOCK:
                    {
                        int num16 = (int)this.Position.X / 16;
                        int num17 = (int)this.Position.Y / 16;
                        if (!TileRefs(num16, num17).Exists)
                        {
                            Main.tile.CreateTileAt(num16, num17);
                        }
                        if (TileRefs(num16, num17).Type == 127 && TileRefs(num16, num17).Active)
                        {
                            WorldModify.KillTile(TileRefs, sandbox, num16, num17);
                        }
                    }
                    break;

                case ProjectileType.N89_CRYSTAL_BULLET:
                    {
                        if (this.Owner == Main.myPlayer)
                        {
                            for (int num12 = 0; num12 < 3; num12++)
                            {
                                float num13 = -this.Velocity.X * (float)Main.rand.Next(40, 70) * 0.01f + (float)Main.rand.Next(-20, 21) * 0.4f;
                                float num14 = -this.Velocity.Y * (float)Main.rand.Next(40, 70) * 0.01f + (float)Main.rand.Next(-20, 21) * 0.4f;
                                Projectile.NewProjectile(this.Position.X + num13, this.Position.Y + num14, num13, num14, 90, (int)((double)this.damage * 0.6), 0f, this.Owner);
                            }
                        }
                    }
                    break;

                case ProjectileType.N91_HOLY_ARROW:
                    {
                        float x = this.Position.X + (float)Main.rand.Next(-400, 400);
                        float y = this.Position.Y - (float)Main.rand.Next(600, 900);
                        Vector2 vector = new Vector2(x, y);
                        float num4 = this.Position.X + (float)(this.Width / 2) - vector.X;
                        float num5 = this.Position.Y + (float)(this.Height / 2) - vector.Y;
                        int num6 = 22;
                        float num7 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5));
                        num7 = (float)num6 / num7;
                        num4 *= num7;
                        num5 *= num7;
                        int num8 = (int)((float)this.damage * 0.5f);
                        int num9 = Projectile.NewProjectile(x, y, num4, num5, 92, num8, this.knockBack, this.Owner);
                        Main.projectile[num9].ai[1] = this.Position.Y;
                        Main.projectile[num9].ai[0] = 1f;
                    }
                    break;

                case ProjectileType.N92_HALLOW_STAR:
                    {
                        float x_2 = this.Position.X + (float)Main.rand.Next(-400, 400);
                        float y_2 = this.Position.Y - (float)Main.rand.Next(600, 900);
                        Vector2 vector_2 = new Vector2(x_2, y_2);
                        float num4_2 = this.Position.X + (float)(this.Width / 2) - vector_2.X;
                        float num5_2 = this.Position.Y + (float)(this.Height / 2) - vector_2.Y;
                        int num6_2 = 22;
                        float num7_2 = (float)Math.Sqrt((double)(num4_2 * num4_2 + num5_2 * num5_2));
                        num7_2 = (float)num6_2 / num7_2;
                        num4_2 *= num7_2;
                        num5_2 *= num7_2;
                        int num9_2 = Projectile.NewProjectile(x_2, y_2, num4_2, num5_2, 92, this.damage, this.knockBack, this.Owner);
                        Main.projectile[num9_2].ai[1] = this.Position.Y;
                    }
                    break;

                case ProjectileType.N99_BOULDER:
                    this.Velocity *= 1.9f;
                    break;

                default:
                    break;
            }
            if (this.Owner == Main.myPlayer)
            {
                bool explode = false;
                if (this.type == ProjectileType.N28_BOMB ||
                    this.type == ProjectileType.N29_DYNAMITE ||
                    this.type == ProjectileType.N37_STICKY_BOMB ||
                    this.type == ProjectileType.N75_HAPPY_BOMB ||
                    this.type == ProjectileType.N108_EXPLOSIVES)
                {
                    var ctx = new HookContext
                    {
                        Sender = this,
                    };

                    var args = new HookArgs.Explosion
                    {
                        Source = this,
                    };

                    HookPoints.Explosion.Invoke(ref ctx, ref args);

                    if (ctx.Result != HookResult.IGNORE)
                    {
                        explode = true;
                    }
                }

                if (explode)
                {
                    int num38 = 3;
                    if (this.type == ProjectileType.N29_DYNAMITE)
                    {
                        num38 = 7;
                    }
                    if (this.type == ProjectileType.N108_EXPLOSIVES)
                    {
                        num38 = 10;
                    }
                    int num39 = (int)(this.Position.X / 16f - (float)num38);
                    int num40 = (int)(this.Position.X / 16f + (float)num38);
                    int num41 = (int)(this.Position.Y / 16f - (float)num38);
                    int num42 = (int)(this.Position.Y / 16f + (float)num38);
                    if (num39 < 0)
                    {
                        num39 = 0;
                    }
                    if (num40 > Main.maxTilesX)
                    {
                        num40 = Main.maxTilesX;
                    }
                    if (num41 < 0)
                    {
                        num41 = 0;
                    }
                    if (num42 > Main.maxTilesY)
                    {
                        num42 = Main.maxTilesY;
                    }
                    bool flag = false;
                    for (int num43 = num39; num43 <= num40; num43++)
                    {
                        for (int num44 = num41; num44 <= num42; num44++)
                        {
                            float num45 = Math.Abs((float)num43 - this.Position.X / 16f);
                            float num46 = Math.Abs((float)num44 - this.Position.Y / 16f);
                            double num47 = Math.Sqrt((double)(num45 * num45 + num46 * num46));
                            if (num47 < (double)num38 && TileRefs(num43, num44).Exists && TileRefs(num43, num44).Wall == 0)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    for (int num89 = num39; num89 <= num40; num89++)
                    {
                        for (int num90 = num41; num90 <= num42; num90++)
                        {
                            float num50 = Math.Abs((float)num89 - this.Position.X / 16f);
                            float num51 = Math.Abs((float)num90 - this.Position.Y / 16f);
                            double num52 = Math.Sqrt((double)(num50 * num50 + num51 * num51));
                            int alter = -1;
                            if (num52 < (double)num38)
                            {
                                bool flag2 = true;
                                if (TileRefs(num89, num90).Active)
                                {
                                    if (Main.tileDungeon[(int)TileRefs(num89, num90).Type] || TileRefs(num89, num90).Type == 21 ||
                                    TileRefs(num89, num90).Type == 26 || TileRefs(num89, num90).Type == 107 ||
                                    TileRefs(num89, num90).Type == 108 || TileRefs(num89, num90).Type == 111)
                                    {
                                        flag2 = false;
                                    }
                                    if (!Main.hardMode && TileRefs(num89, num90).Type == 58)
                                    {
                                        flag2 = false;
                                    }
                                    if (flag2)
                                    {
                                        alter = 0;
                                    }
                                }
                                if (flag2 && TileRefs(num89, num90).Wall > 0 && flag)
                                {
                                    alter = alter == 0 ? 100 : 2;
                                }
                                if (alter >= 0)
                                {
                                    var plr = Creator as Player;
                                    if (plr == null || WorldModify.InvokeAlterationHook(this, plr, num89, num90, (byte)alter))
                                    {
                                        if (alter == 0 || alter == 100)
                                        {
                                            WorldModify.KillTile(TileRefs, sandbox, num89, num90);
                                            NetMessage.SendData(17, -1, -1, "", 0, (float)num89, (float)num90, 0f, 0);
                                        }
                                        if (alter == 2 || alter == 100)
                                        {
                                            WorldModify.KillWall(TileRefs, sandbox, num89, num90);
                                            NetMessage.SendData(17, -1, -1, "", 2, (float)num89, (float)num90, 0f, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                NetMessage.SendData(29, -1, -1, "", this.identity, (float)this.Owner);

                int num96 = -1;
                if (this.aiStyle == 10)
                {
                    int num54 = (int)(this.Position.X + (float)(this.Width / 2)) / 16;
                    int num55 = (int)(this.Position.Y + (float)(this.Width / 2)) / 16;
                    int num99 = 0;
                    int num100 = 2;
                    if (this.type == ProjectileType.N31_SAND_BALL)
                    {
                        num99 = 53;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N42_SAND_BALL)
                    {
                        num99 = 53;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N39_MUD_BALL)
                    {
                        num99 = 59;
                        num100 = 176;
                    }
                    else if (this.type == ProjectileType.N40_ASH_BALL)
                    {
                        num99 = 57;
                        num100 = 172;
                    }
                    else if (this.type == ProjectileType.N56_EBONSAND_BALL)
                    {
                        num99 = 112;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N65_EBONSAND_BALL)
                    {
                        num99 = 112;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N67_PEARL_SAND_BALL)
                    {
                        num99 = 116;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N68_PEARL_SAND_BALL)
                    {
                        num99 = 116;
                        num100 = 0;
                    }
                    else if (this.type == ProjectileType.N71_GRAVEL_BALL)
                    {
                        num99 = 123;
                        num100 = 0;
                    }
                    if (!TileRefs(num54, num55).Active)
                    {
                        WorldModify.PlaceTile(TileRefs, sandbox, num54, num55, num99, false, true, -1, 0);
                        if (TileRefs(num54, num55).Active && (int)TileRefs(num54, num55).Type == num99)
                        {
                            NetMessage.SendData(17, -1, -1, "", 1, (float)num54, (float)num55, (float)num99);
                        }
                        else
                        {
                            if (num100 > 0)
                            {
                                num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, num100, 1, false);
                            }
                        }
                    }
                    else
                    {
                        if (num100 > 0)
                        {
                            num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, num100, 1, false);
                        }
                    }
                }
                if (this.type == ProjectileType.N1_WOODEN_ARROW && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 40, 1, false);
                }
                if (this.type == ProjectileType.N103_CURSED_ARROW && Main.rand.Next(6) == 0)
                {
                    if (Main.rand.Next(3) == 0)
                    {
                        num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 545, 1, false);
                    }
                    else
                    {
                        num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 40, 1, false);
                    }
                }
                if (this.type == ProjectileType.N2_FIRE_ARROW && Main.rand.Next(2) == 0)
                {
                    if (Main.rand.Next(3) == 0)
                    {
                        num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 41, 1, false);
                    }
                    else
                    {
                        num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 40, 1, false);
                    }
                }
                if (this.type == ProjectileType.N91_HOLY_ARROW && Main.rand.Next(6) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 516, 1, false);
                }
                if (this.type == ProjectileType.N50_GLOWSTICK && Main.rand.Next(3) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 282, 1, false);
                }
                if (this.type == ProjectileType.N53_STICKY_GLOWSTICK && Main.rand.Next(3) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 286, 1, false);
                }
                if (this.type == ProjectileType.N48_THROWING_KNIFE && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 279, 1, false);
                }
                if (this.type == ProjectileType.N54_POISONED_KNIFE && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 287, 1, false);
                }
                if (this.type == ProjectileType.N3_SHURIKEN && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 42, 1, false);
                }
                if (this.type == ProjectileType.N4_UNHOLY_ARROW && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 47, 1, false);
                }
                if (this.type == ProjectileType.N12_FALLING_STAR && this.damage > 100)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 75, 1, false);
                }
                if (this.type == ProjectileType.N21_BONE && Main.rand.Next(2) == 0)
                {
                    num96 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 154, 1, false);
                }

                if (this.type == ProjectileType.N69_HOLY_WATER || this.type == ProjectileType.N70_UNHOLY_WATER)
                {
                    int num101 = (int)(this.Position.X + (float)(this.Width / 2)) / 16;
                    int num102 = (int)(this.Position.Y + (float)(this.Height / 2)) / 16;
                    for (int num103 = num101 - 4; num103 <= num101 + 4; num103++)
                    {
                        for (int num104 = num102 - 4; num104 <= num102 + 4; num104++)
                        {
                            if (Math.Abs(num103 - num101) + Math.Abs(num104 - num102) < 6)
                            {
                                if (this.type == ProjectileType.N69_HOLY_WATER)
                                {
                                    switch (TileRefs(num103, num104).Type)
                                    {
                                        case 2:
                                            {
                                                TileRefs(num103, num104).SetType(109);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        case 1:
                                            {
                                                TileRefs(num103, num104).SetType(117);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        case 53:
                                            {
                                                TileRefs(num103, num104).SetType(116);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        case 23:
                                            {
                                                TileRefs(num103, num104).SetType(109);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        case 25:
                                            {
                                                TileRefs(num103, num104).SetType(117);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        case 112:
                                            {
                                                TileRefs(num103, num104).SetType(116);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        default:
                                            break;
                                    }
                                }
                                else
                                {
                                    switch (TileRefs(num103, num104).Type)
                                    {
                                        case 2:
                                            {
                                                TileRefs(num103, num104).SetType(23);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        case 1:
                                            {
                                                TileRefs(num103, num104).SetType(25);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        case 53:
                                            {
                                                TileRefs(num103, num104).SetType(112);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        case 109:
                                            {
                                                TileRefs(num103, num104).SetType(23);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        case 117:
                                            {
                                                TileRefs(num103, num104).SetType(25);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;

                                        case 116:
                                            {
                                                TileRefs(num103, num104).SetType(112);
                                                WorldModify.SquareTileFrame(TileRefs, sandbox,num103, num104, true);
                                                NetMessage.SendTileSquare(-1, num103, num104, 1);
                                            }
                                            break;
                                        default:
                                            break;
                                    }

                                }
                            }
                        }
                    }
                }

                //if (num96 >= 0)
                // {
                //     NetMessage.SendData(21, -1, -1, "", num96, 0f, 0f, 0f, 0);
                // }
            }
            this.Active = false;
            //Reset(whoAmI);
        }
        /// <summary>
        /// Destroys the projectile
        /// </summary>
        public void Kill()
        {
            if (!this.Active)
            {
                return;
            }
            this.timeLeft = 0;
            switch(this.type)
            {
                case ProjectileType.BALL_MUSKET:
                case ProjectileType.LASER_GREEN:
                case ProjectileType.SHOT_METEOR:
                    {
                        Collision.HitTiles(this.Position, this.Velocity, this.Width, this.Height);
                    }
                    break;

                case ProjectileType.BOMB:
                case ProjectileType.GRENADE:
                case ProjectileType.BOMB_STICKY:
                    {
                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 22;
                        this.Height = 22;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                    }
                    break;

                case ProjectileType.DYNAMITE:
                    {
                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 200;
                        this.Height = 200;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);

                        this.Position.X = this.Position.X + (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                        this.Width = 10;
                        this.Height = 10;
                        this.Position.X = this.Position.X - (float)(this.Width / 2);
                        this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                    }
                    break;

                case ProjectileType.ARROW_HELLFIRE:
                    {
                        if (this.Owner == Main.myPlayer)
                        {
                            this.penetrate = -1;
                            this.Position.X = this.Position.X + (float)(this.Width / 2);
                            this.Position.Y = this.Position.Y + (float)(this.Height / 2);
                            this.Width = 64;
                            this.Height = 64;
                            this.Position.X = this.Position.X - (float)(this.Width / 2);
                            this.Position.Y = this.Position.Y - (float)(this.Height / 2);
                            this.Damage();
                        }
                    }
                    break;

                default:
                    break;
            }
            if (this.Owner == Main.myPlayer)
            {
                bool explode = false;
                if (this.type == ProjectileType.BOMB || this.type == ProjectileType.DYNAMITE || this.type == ProjectileType.BOMB_STICKY)
                {
                    var ctx = new HookContext
                    {
                        Sender = this,
                    };

                    var args = new HookArgs.Explosion
                    {
                        Source = this,
                    };

                    HookPoints.Explosion.Invoke (ref ctx, ref args);

                    if (ctx.Result != HookResult.IGNORE)
                    {
                        explode = true;
                    }
                }

                if (explode)
                {
                    int num38 = 3;
                    if (this.type == ProjectileType.DYNAMITE)
                    {
                        num38 = 7;
                    }
                    int num39 = (int)(this.Position.X / 16f - (float)num38);
                    int num40 = (int)(this.Position.X / 16f + (float)num38);
                    int num41 = (int)(this.Position.Y / 16f - (float)num38);
                    int num42 = (int)(this.Position.Y / 16f + (float)num38);
                    if (num39 < 0)
                    {
                        num39 = 0;
                    }
                    if (num40 > Main.maxTilesX)
                    {
                        num40 = Main.maxTilesX;
                    }
                    if (num41 < 0)
                    {
                        num41 = 0;
                    }
                    if (num42 > Main.maxTilesY)
                    {
                        num42 = Main.maxTilesY;
                    }
                    bool flag = false;
                    for (int num43 = num39; num43 <= num40; num43++)
                    {
                        for (int num44 = num41; num44 <= num42; num44++)
                        {
                            float num45 = Math.Abs((float)num43 - this.Position.X / 16f);
                            float num46 = Math.Abs((float)num44 - this.Position.Y / 16f);
                            double num47 = Math.Sqrt((double)(num45 * num45 + num46 * num46));
                            if (num47 < (double)num38 && Main.tile.At(num43, num44).Exists && Main.tile.At(num43, num44).Wall == 0)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    for (int num48 = num39; num48 <= num40; num48++)
                    {
                        for (int num49 = num41; num49 <= num42; num49++)
                        {
                            float num50 = Math.Abs((float)num48 - this.Position.X / 16f);
                            float num51 = Math.Abs((float)num49 - this.Position.Y / 16f);
                            double num52 = Math.Sqrt((double)(num50 * num50 + num51 * num51));
                            int alter = -1;
                            if (num52 < (double)num38)
                            {
                                bool flag2 = true;
                                if (Main.tile.At(num48, num49).Active)
                                {
                                    flag2 = false;
                                    if (this.type == ProjectileType.BOMB || this.type == ProjectileType.BOMB_STICKY)
                                    {
                                        if (!Main.tileSolid[(int)Main.tile.At(num48, num49).Type] || Main.tileSolidTop[(int)Main.tile.At(num48, num49).Type] || Main.tile.At(num48, num49).Type == 0 || Main.tile.At(num48, num49).Type == 1 || Main.tile.At(num48, num49).Type == 2 || Main.tile.At(num48, num49).Type == 23 || Main.tile.At(num48, num49).Type == 30 || Main.tile.At(num48, num49).Type == 40 || Main.tile.At(num48, num49).Type == 6 || Main.tile.At(num48, num49).Type == 7 || Main.tile.At(num48, num49).Type == 8 || Main.tile.At(num48, num49).Type == 9 || Main.tile.At(num48, num49).Type == 10 || Main.tile.At(num48, num49).Type == 53 || Main.tile.At(num48, num49).Type == 54 || Main.tile.At(num48, num49).Type == 57 || Main.tile.At(num48, num49).Type == 59 || Main.tile.At(num48, num49).Type == 60 || Main.tile.At(num48, num49).Type == 63 || Main.tile.At(num48, num49).Type == 64 || Main.tile.At(num48, num49).Type == 65 || Main.tile.At(num48, num49).Type == 66 || Main.tile.At(num48, num49).Type == 67 || Main.tile.At(num48, num49).Type == 68 || Main.tile.At(num48, num49).Type == 70 || Main.tile.At(num48, num49).Type == 37)
                                        {
                                            flag2 = true;
                                        }
                                    }
                                    else
                                    {
                                        if (this.type == ProjectileType.DYNAMITE)
                                        {
                                            flag2 = true;
                                        }
                                    }
                                    if (Main.tileDungeon[(int)Main.tile.At(num48, num49).Type] || Main.tile.At(num48, num49).Type == 26 || Main.tile.At(num48, num49).Type == 58 || Main.tile.At(num48, num49).Type == 21)
                                    {
                                        flag2 = false;
                                    }
                                    if (flag2)
                                    {
                                        alter = 0;
                                    }
                                }
                                if (flag2 && Main.tile.At(num48, num49).Exists && Main.tile.At(num48, num49).Wall > 0 && flag)
                                {
                                    alter = alter == 0 ? 100 : 2;
                                }
                                if (alter >= 0)
                                {
                                    var plr = Creator as Player;
                                    if (plr == null || WorldModify.InvokeAlterationHook (this, plr, num48, num49, (byte)alter))
                                    {
                                        if (alter == 0 || alter == 100)
                                        {
                                            WorldModify.KillTile(num48, num49, false, false, false);
                                            NetMessage.SendData(17, -1, -1, "", 0, (float)num48, (float)num49, 0f, 0);
                                        }
                                        if (alter == 2 || alter == 100)
                                        {
                                            WorldModify.KillWall(num48, num49, false);
                                            NetMessage.SendData(17, -1, -1, "", 2, (float)num48, (float)num49, 0f, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                NetMessage.SendData(29, -1, -1, "", this.identity, (float)this.Owner);

                int num53 = -1;
                if (this.aiStyle == 10)
                {
                    int num54 = (int)(this.Position.X + (float)(this.Width / 2)) / 16;
                    int num55 = (int)(this.Position.Y + (float)(this.Width / 2)) / 16;
                    int num56 = 0;
                    int num57 = 2;
                    if (this.type == ProjectileType.BALL_SAND_DROP)
                    {
                        num56 = 53;
                        num57 = 0;
                    }
                    if (this.type == ProjectileType.BALL_SAND_GUN)
                    {
                        num56 = 53;
                        num57 = 0;
                    }
                    else
                    {
                        if (this.type == ProjectileType.BALL_MUD)
                        {
                            num56 = 59;
                            num57 = 176;
                        }
                        else
                        {
                            if (this.type == ProjectileType.BALL_ASH)
                            {
                                num56 = 57;
                                num57 = 172;
                            }
                        }
                    }
                    if (!Main.tile.At(num54, num55).Active)
                    {
                        WorldModify.PlaceTile(num54, num55, num56, false, true, -1, 0);
                        if (Main.tile.At(num54, num55).Active && (int)Main.tile.At(num54, num55).Type == num56)
                        {
                            NetMessage.SendData(17, -1, -1, "", 1, (float)num54, (float)num55, (float)num56);
                        }
                        else
                        {
                            if (num57 > 0)
                            {
                                num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, num57, 1, false);
                            }
                        }
                    }
                    else
                    {
                        if (num57 > 0)
                        {
                            num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, num57, 1, false);
                        }
                    }
                }
                if (this.type == ProjectileType.ARROW_WOODEN && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 40, 1, false);
                }
                if (this.type == ProjectileType.ARROW_FIRE && Main.rand.Next(2) == 0)
                {
                    if (Main.rand.Next(3) == 0)
                    {
                        num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 41, 1, false);
                    }
                    else
                    {
                        num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 40, 1, false);
                    }
                }
                if (this.type == ProjectileType.GLOWSTICK && Main.rand.Next(3) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 282, 1, false);
                }
                if (this.type == ProjectileType.GLOWSTICK_STICKY && Main.rand.Next(3) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 286, 1, false);
                }
                if (this.type == ProjectileType.KNIFE_THROWING && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 279, 1, false);
                }
                if (this.type == ProjectileType.KNIFE_POISONED && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 287, 1, false);
                }
                if (this.type == ProjectileType.SHURIKEN && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 42, 1, false);
                }
                if (this.type == ProjectileType.ARROW_UNHOLY && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 47, 1, false);
                }
                if (this.type == ProjectileType.FALLEN_STAR && this.damage > 100)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 75, 1, false);
                }
                if (this.type == ProjectileType.BONE && Main.rand.Next(2) == 0)
                {
                    num53 = Item.NewItem((int)this.Position.X, (int)this.Position.Y, this.Width, this.Height, 154, 1, false);
                }
            }
            this.Active = false;
            Reset (whoAmI);
        }