Terraria.Player.JumpMovement C# (CSharp) Method

JumpMovement() public method

public JumpMovement ( ) : void
return void
        public void JumpMovement()
        {
            if (this.mount.Active && this.mount.Type == 3 && ((int)this.wetSlime == 0 && (double)this.velocity.Y > 0.0))
            {
                Microsoft.Xna.Framework.Rectangle rect1 = this.getRect();
                rect1.Offset(0, this.height - 1);
                rect1.Height = 2;
                rect1.Inflate(12, 6);
                for (int number = 0; number < 200; ++number)
                {
                    NPC npc = Main.npc[number];
                    if (npc.active && !npc.dontTakeDamage && (!npc.friendly && npc.immune[this.whoAmI] == 0))
                    {
                        Microsoft.Xna.Framework.Rectangle rect2 = npc.getRect();
                        if (rect1.Intersects(rect2) && (npc.noTileCollide || Collision.CanHit(this.position, this.width, this.height, npc.position, npc.width, npc.height)))
                        {
                            float number2 = 40f * this.minionDamage;
                            float num = 5f;
                            int hitDirection = this.direction;
                            if ((double)this.velocity.X < 0.0)
                                hitDirection = -1;
                            if ((double)this.velocity.X > 0.0)
                                hitDirection = 1;
                            if (this.whoAmI == Main.myPlayer)
                            {
                                npc.StrikeNPC((int)number2, num, hitDirection, false, false, false);
                                if (Main.netMode != 0)
                                    NetMessage.SendData(28, -1, -1, "", number, number2, num, (float)hitDirection, 0, 0, 0);
                            }
                            npc.immune[this.whoAmI] = 10;
                            this.velocity.Y = -10f;
                            this.immune = true;
                            this.immuneTime = 6;
                            break;
                        }
                    }
                }
            }
            if (this.controlJump)
            {
                bool flag1 = false;
                if (this.mount.Active && this.mount.Type == 3 && (int)this.wetSlime > 0)
                    flag1 = true;
                if (this.jump > 0)
                {
                    if ((double)this.velocity.Y == 0.0)
                    {
                        this.jump = 0;
                    }
                    else
                    {
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        if (this.merman && (!this.mount.Active || !this.mount.Cart))
                        {
                            if (this.swimTime <= 10)
                                this.swimTime = 30;
                        }
                        else
                            --this.jump;
                    }
                }
                else if ((this.sliding || (double)this.velocity.Y == 0.0 || (flag1 || this.jumpAgainCloud) || (this.jumpAgainSandstorm || this.jumpAgainBlizzard || (this.jumpAgainFart || this.jumpAgainSail)) || (this.jumpAgainUnicorn || this.wet && this.accFlipper && (!this.mount.Active || !this.mount.Cart))) && (this.releaseJump || this.autoJump && ((double)this.velocity.Y == 0.0 || this.sliding)))
                {
                    if (this.sliding || (double)this.velocity.Y == 0.0)
                        this.justJumped = true;
                    bool flag2 = false;
                    if (this.wet && this.accFlipper)
                    {
                        if (this.swimTime == 0)
                            this.swimTime = 30;
                        flag2 = true;
                    }
                    bool flag3 = false;
                    bool flag4 = false;
                    bool flag5 = false;
                    bool flag6 = false;
                    bool flag7 = false;
                    if (!flag1)
                    {
                        if (this.jumpAgainUnicorn)
                        {
                            flag7 = true;
                            this.jumpAgainUnicorn = false;
                        }
                        else if (this.jumpAgainSandstorm)
                        {
                            flag3 = true;
                            this.jumpAgainSandstorm = false;
                        }
                        else if (this.jumpAgainBlizzard)
                        {
                            flag4 = true;
                            this.jumpAgainBlizzard = false;
                        }
                        else if (this.jumpAgainFart)
                        {
                            this.jumpAgainFart = false;
                            flag5 = true;
                        }
                        else if (this.jumpAgainSail)
                        {
                            this.jumpAgainSail = false;
                            flag6 = true;
                        }
                        else
                            this.jumpAgainCloud = false;
                    }
                    this.canRocket = false;
                    this.rocketRelease = false;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpCloud)
                        this.jumpAgainCloud = true;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpSandstorm)
                        this.jumpAgainSandstorm = true;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpBlizzard)
                        this.jumpAgainBlizzard = true;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpFart)
                        this.jumpAgainFart = true;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpSail)
                        this.jumpAgainSail = true;
                    if (((double)this.velocity.Y == 0.0 || this.sliding || this.autoJump && this.justJumped) && this.doubleJumpUnicorn)
                        this.jumpAgainUnicorn = true;
                    if ((double)this.velocity.Y == 0.0 || flag2 || (this.sliding || flag1))
                    {
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = Player.jumpHeight;
                        if (this.sliding)
                            this.velocity.X = (float)(3 * -this.slideDir);
                    }
                    else if (flag3)
                    {
                        this.dJumpEffectSandstorm = true;
                        int num1 = this.height;
                        double num2 = (double)this.gravDir;
                        Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = Player.jumpHeight * 3;
                    }
                    else if (flag4)
                    {
                        this.dJumpEffectBlizzard = true;
                        int num1 = this.height;
                        double num2 = (double)this.gravDir;
                        Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = (int)((double)Player.jumpHeight * 1.5);
                    }
                    else if (flag6)
                    {
                        this.dJumpEffectSail = true;
                        int num = this.height;
                        if ((double)this.gravDir == -1.0)
                            num = 0;
                        Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = (int)((double)Player.jumpHeight * 1.25);
                        for (int index1 = 0; index1 < 30; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float)num), this.width, 12, 253, this.velocity.X * 0.3f, this.velocity.Y * 0.3f, 100, new Color(), 1.5f);
                            if (index1 % 2 == 0)
                                Main.dust[index2].velocity.X += (float)Main.rand.Next(30, 71) * 0.1f;
                            else
                                Main.dust[index2].velocity.X -= (float)Main.rand.Next(30, 71) * 0.1f;
                            Main.dust[index2].velocity.Y += (float)Main.rand.Next(-10, 31) * 0.1f;
                            Main.dust[index2].noGravity = true;
                            Main.dust[index2].scale += (float)Main.rand.Next(-10, 41) * 0.01f;
                            Main.dust[index2].velocity *= Main.dust[index2].scale * 0.7f;
                            Vector2 vector2 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                            vector2.Normalize();
                            vector2 *= (float)Main.rand.Next(81) * 0.1f;
                        }
                    }
                    else if (flag5)
                    {
                        this.dJumpEffectFart = true;
                        int num = this.height;
                        if ((double)this.gravDir == -1.0)
                            num = 0;
                        Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 16);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = Player.jumpHeight * 2;
                        for (int index1 = 0; index1 < 10; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(this.position.X - 34f, (float)((double)this.position.Y + (double)num - 16.0)), 102, 32, 188, (float)(-(double)this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, new Color(), 1.5f);
                            Main.dust[index2].velocity.X = (float)((double)Main.dust[index2].velocity.X * 0.5 - (double)this.velocity.X * 0.100000001490116);
                            Main.dust[index2].velocity.Y = (float)((double)Main.dust[index2].velocity.Y * 0.5 - (double)this.velocity.Y * 0.300000011920929);
                        }
                        int index3 = Gore.NewGore(new Vector2((float)((double)this.position.X + (double)(this.width / 2) - 16.0), (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438), 1f);
                        Main.gore[index3].velocity.X = (float)((double)Main.gore[index3].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index3].velocity.Y = (float)((double)Main.gore[index3].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                        int index4 = Gore.NewGore(new Vector2(this.position.X - 36f, (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438), 1f);
                        Main.gore[index4].velocity.X = (float)((double)Main.gore[index4].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index4].velocity.Y = (float)((double)Main.gore[index4].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                        int index5 = Gore.NewGore(new Vector2((float)((double)this.position.X + (double)this.width + 4.0), (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(435, 438), 1f);
                        Main.gore[index5].velocity.X = (float)((double)Main.gore[index5].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index5].velocity.Y = (float)((double)Main.gore[index5].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                    }
                    else if (flag7)
                    {
                        this.dJumpEffectUnicorn = true;
                        int num1 = this.height;
                        double num2 = (double)this.gravDir;
                        Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = Player.jumpHeight * 2;
                        Vector2 center = this.Center;
                        Vector2 vector2_1 = new Vector2(50f, 20f);
                        float num3 = 6.283185f * Utils.NextFloat(Main.rand);
                        for (int index = 0; index < 5; ++index)
                        {
                            for (float num4 = 0.0f; (double)num4 < 14.0; ++num4)
                            {
                                Dust dust = Main.dust[Dust.NewDust(center, 0, 0, Utils.SelectRandom<int>(Main.rand, 176, 177, 179), 0.0f, 0.0f, 0, new Color(), 1f)];
                                Vector2 vector2_2 = Utils.RotatedBy(Vector2.UnitY, (double)num4 * 6.28318548202515 / 14.0 + (double)num3, new Vector2()) * (0.2f * (float)index);
                                dust.position = center + vector2_2 * vector2_1;
                                dust.velocity = vector2_2 + new Vector2(0.0f, this.gravDir * 4f);
                                dust.noGravity = true;
                                dust.scale = (float)(1.0 + (double)Utils.NextFloat(Main.rand) * 0.800000011920929);
                                dust.fadeIn = Utils.NextFloat(Main.rand) * 2f;
                                dust.shader = GameShaders.Armor.GetSecondaryShader(this.cMount, this);
                            }
                        }
                    }
                    else
                    {
                        this.dJumpEffectCloud = true;
                        int num = this.height;
                        if ((double)this.gravDir == -1.0)
                            num = 0;
                        Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
                        this.velocity.Y = -Player.jumpSpeed * this.gravDir;
                        this.jump = (int)((double)Player.jumpHeight * 0.75);
                        for (int index1 = 0; index1 < 10; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(this.position.X - 34f, (float)((double)this.position.Y + (double)num - 16.0)), 102, 32, 16, (float)(-(double)this.velocity.X * 0.5), this.velocity.Y * 0.5f, 100, new Color(), 1.5f);
                            Main.dust[index2].velocity.X = (float)((double)Main.dust[index2].velocity.X * 0.5 - (double)this.velocity.X * 0.100000001490116);
                            Main.dust[index2].velocity.Y = (float)((double)Main.dust[index2].velocity.Y * 0.5 - (double)this.velocity.Y * 0.300000011920929);
                        }
                        int index3 = Gore.NewGore(new Vector2((float)((double)this.position.X + (double)(this.width / 2) - 16.0), (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14), 1f);
                        Main.gore[index3].velocity.X = (float)((double)Main.gore[index3].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index3].velocity.Y = (float)((double)Main.gore[index3].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                        int index4 = Gore.NewGore(new Vector2(this.position.X - 36f, (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14), 1f);
                        Main.gore[index4].velocity.X = (float)((double)Main.gore[index4].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index4].velocity.Y = (float)((double)Main.gore[index4].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                        int index5 = Gore.NewGore(new Vector2((float)((double)this.position.X + (double)this.width + 4.0), (float)((double)this.position.Y + (double)num - 16.0)), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14), 1f);
                        Main.gore[index5].velocity.X = (float)((double)Main.gore[index5].velocity.X * 0.100000001490116 - (double)this.velocity.X * 0.100000001490116);
                        Main.gore[index5].velocity.Y = (float)((double)Main.gore[index5].velocity.Y * 0.100000001490116 - (double)this.velocity.Y * 0.0500000007450581);
                    }
                }
                this.releaseJump = false;
            }
            else
            {
                this.jump = 0;
                this.releaseJump = true;
                this.rocketRelease = true;
            }
        }
Player