Terraria.Player.PlayerFrame C# (CSharp) Method

PlayerFrame() public method

public PlayerFrame ( ) : void
return void
        public void PlayerFrame()
        {
            if (this.swimTime > 0)
            {
                --this.swimTime;
                if (!this.wet)
                    this.swimTime = 0;
            }
            this.head = this.armor[0].headSlot;
            this.body = this.armor[1].bodySlot;
            this.legs = this.armor[2].legSlot;
            for (int index = 3; index < 8 + this.extraAccessorySlots; ++index)
            {
                if ((int)this.armor[index].shieldSlot == 5 && this.eocDash > 0)
                    this.shield = this.armor[index].shieldSlot;
                if (((int)this.shield <= 0 || (int)this.armor[index].frontSlot < 1 || (int)this.armor[index].frontSlot > 4) && ((int)this.front < 1 || (int)this.front > 4 || (int)this.armor[index].shieldSlot <= 0))
                {
                    if ((int)this.armor[index].wingSlot > 0)
                    {
                        if (!this.hideVisual[index] || (double)this.velocity.Y != 0.0 && !this.mount.Active)
                            this.wings = (int)this.armor[index].wingSlot;
                        else
                            continue;
                    }
                    if (!this.hideVisual[index])
                    {
                        if (this.armor[index].stringColor > 0)
                            this.stringColor = this.armor[index].stringColor;
                        if ((int)this.armor[index].handOnSlot > 0)
                            this.handon = this.armor[index].handOnSlot;
                        if ((int)this.armor[index].handOffSlot > 0)
                            this.handoff = this.armor[index].handOffSlot;
                        if ((int)this.armor[index].backSlot > 0)
                        {
                            this.back = this.armor[index].backSlot;
                            this.front = (sbyte)-1;
                        }
                        if ((int)this.armor[index].frontSlot > 0)
                            this.front = this.armor[index].frontSlot;
                        if ((int)this.armor[index].shoeSlot > 0)
                            this.shoe = this.armor[index].shoeSlot;
                        if ((int)this.armor[index].waistSlot > 0)
                            this.waist = this.armor[index].waistSlot;
                        if ((int)this.armor[index].shieldSlot > 0)
                            this.shield = this.armor[index].shieldSlot;
                        if ((int)this.armor[index].neckSlot > 0)
                            this.neck = this.armor[index].neckSlot;
                        if ((int)this.armor[index].faceSlot > 0)
                            this.face = this.armor[index].faceSlot;
                        if ((int)this.armor[index].balloonSlot > 0)
                            this.balloon = this.armor[index].balloonSlot;
                        if (this.armor[index].itemId == 3580)
                            this.yoraiz0rEye = index - 2;
                        if (this.armor[index].itemId == 3581)
                            this.yoraiz0rDarkness = true;
                    }
                }
            }
            for (int index = 13; index < 18 + this.extraAccessorySlots; ++index)
            {
                if (this.armor[index].stringColor > 0)
                    this.stringColor = this.armor[index].stringColor;
                if ((int)this.armor[index].handOnSlot > 0)
                    this.handon = this.armor[index].handOnSlot;
                if ((int)this.armor[index].handOffSlot > 0)
                    this.handoff = this.armor[index].handOffSlot;
                if ((int)this.armor[index].backSlot > 0)
                {
                    this.back = this.armor[index].backSlot;
                    this.front = (sbyte)-1;
                }
                if ((int)this.armor[index].frontSlot > 0)
                    this.front = this.armor[index].frontSlot;
                if ((int)this.armor[index].shoeSlot > 0)
                    this.shoe = this.armor[index].shoeSlot;
                if ((int)this.armor[index].waistSlot > 0)
                    this.waist = this.armor[index].waistSlot;
                if ((int)this.armor[index].shieldSlot > 0)
                    this.shield = this.armor[index].shieldSlot;
                if ((int)this.armor[index].neckSlot > 0)
                    this.neck = this.armor[index].neckSlot;
                if ((int)this.armor[index].faceSlot > 0)
                    this.face = this.armor[index].faceSlot;
                if ((int)this.armor[index].balloonSlot > 0)
                    this.balloon = this.armor[index].balloonSlot;
                if ((int)this.armor[index].wingSlot > 0)
                    this.wings = (int)this.armor[index].wingSlot;
                if (this.armor[index].itemId == 3580)
                    this.yoraiz0rEye = index - 2;
                if (this.armor[index].itemId == 3581)
                    this.yoraiz0rDarkness = true;
            }
            if (this.armor[10].headSlot >= 0)
                this.head = this.armor[10].headSlot;
            if (this.armor[11].bodySlot >= 0)
                this.body = this.armor[11].bodySlot;
            if (this.armor[12].legSlot >= 0)
                this.legs = this.armor[12].legSlot;
            this.wearsRobe = false;
            int num1 = Player.SetMatch(1, this.body, this.Male, ref this.wearsRobe);
            if (num1 != -1)
                this.legs = num1;
            bool somethingSpecial = false;
            int num2 = Player.SetMatch(2, this.legs, this.Male, ref somethingSpecial);
            if (num2 != -1)
                this.legs = num2;
            if (this.body == 93)
            {
                this.shield = (sbyte)0;
                this.handoff = (sbyte)0;
            }
            if (this.legs == 67)
                this.shoe = (sbyte)0;
            if (this.wereWolf)
            {
                this.legs = 20;
                this.body = 21;
                this.head = 38;
            }
            if (this.merman)
            {
                this.head = 39;
                this.legs = 21;
                this.body = 22;
                this.wings = 0;
            }
            this.socialShadow = false;
            this.socialGhost = false;
            if (this.head == 101 && this.body == 66 && this.legs == 55)
                this.socialGhost = true;
            if (this.head == 156 && this.body == 66 && this.legs == 55)
                this.socialGhost = true;
            if (this.head == 99 && this.body == 65 && this.legs == 54)
                this.turtleArmor = true;
            if (this.head == 162 && this.body == 170 && this.legs == 105)
                this.spiderArmor = true;
            if ((this.head == 75 || this.head == 7) && (this.body == 7 && this.legs == 7))
                this.boneArmor = true;
            if (this.wings > 0)
            {
                this.back = (sbyte)-1;
                this.front = (sbyte)-1;
            }
            if (this.head > 0 && (int)this.face != 7)
                this.face = (sbyte)-1;
            if (this.webbed || this.frozen || this.stoned || Main.gamePaused && !Main.gameMenu)
                return;
            if ((this.body == 68 && this.legs == 57 && this.head == 106 || this.body == 74 && this.legs == 63 && this.head == 106) && Main.rand.Next(10) == 0)
            {
                int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 43, 0.0f, 0.0f, 100, new Color((int)byte.MaxValue, 0, (int)byte.MaxValue), 0.3f);
                Main.dust[index].fadeIn = 0.8f;
                Main.dust[index].noGravity = true;
                Main.dust[index].velocity *= 2f;
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.wings == 27)
            {
                float R = 0.4f * this.stealth;
                Lighting.AddLight((int)this.Center.X / 16, (int)this.Center.Y / 16, R, R * 0.9f, R * 0.2f);
            }
            if (this.head == 5 && this.body == 5 && this.legs == 5)
                this.socialShadow = true;
            if (this.head == 5 && this.body == 5 && (this.legs == 5 && Main.rand.Next(10) == 0))
            {
                int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 14, 0.0f, 0.0f, 200, new Color(), 1.2f);
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.head == 76 && this.body == 49 && this.legs == 45)
                this.socialShadow = true;
            if (this.head == 74 && this.body == 48 && this.legs == 44)
                this.socialShadow = true;
            if (this.head == 74 && this.body == 48 && (this.legs == 44 && Main.rand.Next(10) == 0))
            {
                int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 14, 0.0f, 0.0f, 200, new Color(), 1.2f);
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.head == 57 && this.body == 37 && this.legs == 35)
            {
                int maxValue = 10;
                if ((double)Math.Abs(this.velocity.X) + (double)Math.Abs(this.velocity.Y) > 1.0)
                    maxValue = 2;
                if (Main.rand.Next(maxValue) == 0)
                {
                    int index = Dust.NewDust(new Vector2(this.position.X, this.position.Y), this.width, this.height, 115, 0.0f, 0.0f, 140, new Color(), 0.75f);
                    Main.dust[index].noGravity = true;
                    Main.dust[index].fadeIn = 1.5f;
                    Main.dust[index].velocity *= 0.3f;
                    Main.dust[index].velocity += this.velocity * 0.2f;
                    Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                }
            }
            if (this.head == 6 && this.body == 6 && (this.legs == 6 && (double)Math.Abs(this.velocity.X) + (double)Math.Abs(this.velocity.Y) > 1.0) && !this.rocketFrame)
            {
                for (int index1 = 0; index1 < 2; ++index1)
                {
                    int index2 = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 6, 0.0f, 0.0f, 100, new Color(), 2f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].noLight = true;
                    Main.dust[index2].velocity.X -= this.velocity.X * 0.5f;
                    Main.dust[index2].velocity.Y -= this.velocity.Y * 0.5f;
                    Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                }
            }
            if (this.head == 8 && this.body == 8 && (this.legs == 8 && (double)Math.Abs(this.velocity.X) + (double)Math.Abs(this.velocity.Y) > 1.0))
            {
                int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 40, 0.0f, 0.0f, 50, new Color(), 1.4f);
                Main.dust[index].noGravity = true;
                Main.dust[index].velocity.X = this.velocity.X * 0.25f;
                Main.dust[index].velocity.Y = this.velocity.Y * 0.25f;
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.head == 9 && this.body == 9 && (this.legs == 9 && (double)Math.Abs(this.velocity.X) + (double)Math.Abs(this.velocity.Y) > 1.0) && !this.rocketFrame)
            {
                for (int index1 = 0; index1 < 2; ++index1)
                {
                    int index2 = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 6, 0.0f, 0.0f, 100, new Color(), 2f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].noLight = true;
                    Main.dust[index2].velocity.X -= this.velocity.X * 0.5f;
                    Main.dust[index2].velocity.Y -= this.velocity.Y * 0.5f;
                    Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                }
            }
            if (this.body == 18 && this.legs == 17 && (this.head == 32 || this.head == 33 || this.head == 34) && Main.rand.Next(10) == 0)
            {
                int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 43, 0.0f, 0.0f, 100, new Color(), 0.3f);
                Main.dust[index].fadeIn = 0.8f;
                Main.dust[index].velocity *= 0.0f;
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.body == 24 && this.legs == 23 && (this.head == 42 || this.head == 43 || this.head == 41) && ((double)this.velocity.X != 0.0 && (double)this.velocity.Y != 0.0 && Main.rand.Next(10) == 0))
            {
                int index = Dust.NewDust(new Vector2(this.position.X - this.velocity.X * 2f, (float)((double)this.position.Y - 2.0 - (double)this.velocity.Y * 2.0)), this.width, this.height, 43, 0.0f, 0.0f, 100, new Color(), 0.3f);
                Main.dust[index].fadeIn = 0.8f;
                Main.dust[index].velocity *= 0.0f;
                Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
            }
            if (this.body == 36 && this.head == 56 && ((double)this.velocity.X != 0.0 && (double)this.velocity.Y == 0.0))
            {
                for (int index1 = 0; index1 < 2; ++index1)
                {
                    int index2 = Dust.NewDust(new Vector2(this.position.X, this.position.Y + ((double)this.gravDir == 1.0 ? (float)(this.height - 2) : -4f)), this.width, 6, 106, 0.0f, 0.0f, 100, new Color(), 0.1f);
                    Main.dust[index2].fadeIn = 1f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].velocity *= 0.2f;
                    Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                }
            }
            if (this.body == 27 && this.head == 46 && this.legs == 26)
            {
                this.frostArmor = true;
                if ((double)this.velocity.X != 0.0 && (double)this.velocity.Y == 0.0 && this.miscCounter % 2 == 0)
                {
                    for (int index1 = 0; index1 < 2; ++index1)
                    {
                        int index2 = index1 != 0 ? Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2), this.position.Y + (float)this.height + this.gfxOffY), this.width / 2, 6, 76, 0.0f, 0.0f, 0, new Color(), 1.35f) : Dust.NewDust(new Vector2(this.position.X, this.position.Y + (float)this.height + this.gfxOffY), this.width / 2, 6, 76, 0.0f, 0.0f, 0, new Color(), 1.35f);
                        Main.dust[index2].scale *= (float)(1.0 + (double)Main.rand.Next(20, 40) * 0.00999999977648258);
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].noLight = true;
                        Main.dust[index2].velocity *= 1.0f / 1000.0f;
                        Main.dust[index2].velocity.Y -= 3.0f / 1000.0f;
                        Main.dust[index2].shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                    }
                }
            }
            this.bodyFrame.Width = 40;
            this.bodyFrame.Height = 56;
            this.legFrame.Width = 40;
            this.legFrame.Height = 56;
            this.bodyFrame.X = 0;
            this.legFrame.X = 0;
            if (this.mount.Active)
            {
                this.legFrameCounter = 0.0;
                this.legFrame.Y = this.legFrame.Height * 6;
                if ((double)this.velocity.Y != 0.0)
                {
                    if (this.mount.FlyTime > 0 && this.jump == 0 && (this.controlJump && !this.mount.CanHover))
                    {
                        if (this.mount.Type == 0)
                        {
                            if (this.direction > 0)
                            {
                                if (Main.rand.Next(4) == 0)
                                {
                                    int index = Dust.NewDust(new Vector2(this.Center.X - 22f, (float)((double)this.position.Y + (double)this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int)byte.MaxValue, new Color(), 1f);
                                    Main.dust[index].velocity *= 0.1f;
                                    Main.dust[index].noLight = true;
                                }
                                if (Main.rand.Next(4) == 0)
                                {
                                    int index = Dust.NewDust(new Vector2(this.Center.X + 12f, (float)((double)this.position.Y + (double)this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int)byte.MaxValue, new Color(), 1f);
                                    Main.dust[index].velocity *= 0.1f;
                                    Main.dust[index].noLight = true;
                                }
                            }
                            else
                            {
                                if (Main.rand.Next(4) == 0)
                                {
                                    int index = Dust.NewDust(new Vector2(this.Center.X - 32f, (float)((double)this.position.Y + (double)this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int)byte.MaxValue, new Color(), 1f);
                                    Main.dust[index].velocity *= 0.1f;
                                    Main.dust[index].noLight = true;
                                }
                                if (Main.rand.Next(4) == 0)
                                {
                                    int index = Dust.NewDust(new Vector2(this.Center.X + 2f, (float)((double)this.position.Y + (double)this.height - 6.0)), 20, 10, 64, this.velocity.X * 0.25f, this.velocity.Y * 0.25f, (int)byte.MaxValue, new Color(), 1f);
                                    Main.dust[index].velocity *= 0.1f;
                                    Main.dust[index].noLight = true;
                                }
                            }
                        }
                        this.mount.UpdateFrame(this, 3, this.velocity);
                    }
                    else if (this.wet)
                        this.mount.UpdateFrame(this, 4, this.velocity);
                    else
                        this.mount.UpdateFrame(this, 2, this.velocity);
                }
                else if ((double)this.velocity.X == 0.0)
                    this.mount.UpdateFrame(this, 0, this.velocity);
                else
                    this.mount.UpdateFrame(this, 1, this.velocity);
            }
            else if (this.swimTime > 0)
            {
                this.legFrameCounter += 2.0;
                while (this.legFrameCounter > 8.0)
                {
                    this.legFrameCounter -= 8.0;
                    this.legFrame.Y += this.legFrame.Height;
                }
                if (this.legFrame.Y < this.legFrame.Height * 7)
                    this.legFrame.Y = this.legFrame.Height * 19;
                else if (this.legFrame.Y > this.legFrame.Height * 19)
                    this.legFrame.Y = this.legFrame.Height * 7;
            }
            else if ((double)this.velocity.Y != 0.0 || this.grappling[0] > -1)
            {
                this.legFrameCounter = 0.0;
                this.legFrame.Y = this.legFrame.Height * 5;
                if (this.wings == 22 || this.wings == 28)
                    this.legFrame.Y = 0;
            }
            else if ((double)this.velocity.X != 0.0)
            {
                if ((this.slippy || this.slippy2) && (!this.controlLeft && !this.controlRight))
                {
                    this.legFrameCounter = 0.0;
                    this.legFrame.Y = 0;
                }
                else
                {
                    this.legFrameCounter += (double)Math.Abs(this.velocity.X) * 1.3;
                    while (this.legFrameCounter > 8.0)
                    {
                        this.legFrameCounter -= 8.0;
                        this.legFrame.Y += this.legFrame.Height;
                    }
                    if (this.legFrame.Y < this.legFrame.Height * 7)
                        this.legFrame.Y = this.legFrame.Height * 19;
                    else if (this.legFrame.Y > this.legFrame.Height * 19)
                        this.legFrame.Y = this.legFrame.Height * 7;
                }
            }
            else
            {
                this.legFrameCounter = 0.0;
                this.legFrame.Y = 0;
            }
            if (this.carpetFrame >= 0)
            {
                this.legFrameCounter = 0.0;
                this.legFrame.Y = 0;
            }
            if (this.sandStorm)
            {
                if (this.miscCounter % 4 == 0 && this.itemAnimation == 0)
                {
                    this.ChangeDir(this.direction * -1);
                    if (this.inventory[this.selectedItem].holdStyle == 2)
                    {
                        if (this.inventory[this.selectedItem].itemId == 946)
                            this.itemLocation.X = this.position.X + (float)this.width * 0.5f - (float)(16 * this.direction);
                        if (this.inventory[this.selectedItem].itemId == 186)
                        {
                            this.itemLocation.X = this.position.X + (float)this.width * 0.5f + (float)(6 * this.direction);
                            this.itemRotation = 0.79f * (float)-this.direction;
                        }
                    }
                }
                this.legFrameCounter = 0.0;
                this.legFrame.Y = 0;
            }
            if (this.itemAnimation > 0 && this.inventory[this.selectedItem].useStyle != 10)
            {
                if (this.inventory[this.selectedItem].useStyle == 1 || this.inventory[this.selectedItem].itemId == 0)
                {
                    if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.333)
                        this.bodyFrame.Y = this.bodyFrame.Height * 3;
                    else if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.666)
                        this.bodyFrame.Y = this.bodyFrame.Height * 2;
                    else
                        this.bodyFrame.Y = this.bodyFrame.Height;
                }
                else if (this.inventory[this.selectedItem].useStyle == 2)
                {
                    if ((double)this.itemAnimation > (double)this.itemAnimationMax * 0.5)
                        this.bodyFrame.Y = this.bodyFrame.Height * 3;
                    else
                        this.bodyFrame.Y = this.bodyFrame.Height * 2;
                }
                else if (this.inventory[this.selectedItem].useStyle == 3)
                {
                    if ((double)this.itemAnimation > (double)this.itemAnimationMax * 0.666)
                        this.bodyFrame.Y = this.bodyFrame.Height * 3;
                    else
                        this.bodyFrame.Y = this.bodyFrame.Height * 3;
                }
                else if (this.inventory[this.selectedItem].useStyle == 4)
                {
                    this.bodyFrame.Y = this.bodyFrame.Height * 2;
                }
                else
                {
                    if (this.inventory[this.selectedItem].useStyle != 5)
                        return;
                    if (this.inventory[this.selectedItem].itemId == 281 || this.inventory[this.selectedItem].itemId == 986)
                    {
                        this.bodyFrame.Y = this.bodyFrame.Height * 2;
                    }
                    else
                    {
                        float num3 = this.itemRotation * (float)this.direction;
                        this.bodyFrame.Y = this.bodyFrame.Height * 3;
                        if ((double)num3 < -0.75)
                        {
                            this.bodyFrame.Y = this.bodyFrame.Height * 2;
                            if ((double)this.gravDir == -1.0)
                                this.bodyFrame.Y = this.bodyFrame.Height * 4;
                        }
                        if ((double)num3 <= 0.6)
                            return;
                        this.bodyFrame.Y = this.bodyFrame.Height * 4;
                        if ((double)this.gravDir != -1.0)
                            return;
                        this.bodyFrame.Y = this.bodyFrame.Height * 2;
                    }
                }
            }
            else if (this.mount.Active)
            {
                this.bodyFrameCounter = 0.0;
                this.bodyFrame.Y = this.bodyFrame.Height * this.mount.BodyFrame;
            }
            else if (this.pulley)
            {
                if ((int)this.pulleyDir == 2)
                    this.bodyFrame.Y = this.bodyFrame.Height;
                else
                    this.bodyFrame.Y = this.bodyFrame.Height * 2;
            }
            else if (this.inventory[this.selectedItem].holdStyle == 1 && (!this.wet || !this.inventory[this.selectedItem].noWet))
                this.bodyFrame.Y = this.bodyFrame.Height * 3;
            else if (this.inventory[this.selectedItem].holdStyle == 2 && (!this.wet || !this.inventory[this.selectedItem].noWet))
                this.bodyFrame.Y = this.bodyFrame.Height * 2;
            else if (this.inventory[this.selectedItem].holdStyle == 3)
                this.bodyFrame.Y = this.bodyFrame.Height * 3;
            else if (this.grappling[0] >= 0)
            {
                this.sandStorm = false;
                this.dJumpEffectCloud = false;
                this.dJumpEffectSandstorm = false;
                this.dJumpEffectBlizzard = false;
                this.dJumpEffectFart = false;
                this.dJumpEffectSail = false;
                this.dJumpEffectUnicorn = false;
                Vector2 vector2 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num3 = 0.0f;
                float num4 = 0.0f;
                for (int index = 0; index < this.grapCount; ++index)
                {
                    num3 += Main.projectile[this.grappling[index]].position.X + (float)(Main.projectile[this.grappling[index]].width / 2);
                    num4 += Main.projectile[this.grappling[index]].position.Y + (float)(Main.projectile[this.grappling[index]].height / 2);
                }
                float num5 = num3 / (float)this.grapCount;
                float num6 = num4 / (float)this.grapCount;
                float num7 = num5 - vector2.X;
                float num8 = num6 - vector2.Y;
                if ((double)num8 < 0.0 && (double)Math.Abs(num8) > (double)Math.Abs(num7))
                {
                    this.bodyFrame.Y = this.bodyFrame.Height * 2;
                    if ((double)this.gravDir != -1.0)
                        return;
                    this.bodyFrame.Y = this.bodyFrame.Height * 4;
                }
                else if ((double)num8 > 0.0 && (double)Math.Abs(num8) > (double)Math.Abs(num7))
                {
                    this.bodyFrame.Y = this.bodyFrame.Height * 4;
                    if ((double)this.gravDir != -1.0)
                        return;
                    this.bodyFrame.Y = this.bodyFrame.Height * 2;
                }
                else
                    this.bodyFrame.Y = this.bodyFrame.Height * 3;
            }
            else if (this.swimTime > 0)
            {
                if (this.swimTime > 20)
                    this.bodyFrame.Y = 0;
                else if (this.swimTime > 10)
                    this.bodyFrame.Y = this.bodyFrame.Height * 5;
                else
                    this.bodyFrame.Y = 0;
            }
            else if ((double)this.velocity.Y != 0.0)
            {
                this.bodyFrame.Y = !this.sliding ? (this.sandStorm || this.carpetFrame >= 0 ? this.bodyFrame.Height * 6 : (this.eocDash <= 0 ? (this.wings <= 0 ? this.bodyFrame.Height * 5 : (this.wings == 22 || this.wings == 28 ? 0 : ((double)this.velocity.Y <= 0.0 ? this.bodyFrame.Height * 6 : (!this.controlJump ? this.bodyFrame.Height * 5 : this.bodyFrame.Height * 6)))) : this.bodyFrame.Height * 6)) : this.bodyFrame.Height * 3;
                this.bodyFrameCounter = 0.0;
            }
            else if ((double)this.velocity.X != 0.0)
            {
                this.bodyFrameCounter += (double)Math.Abs(this.velocity.X) * 1.5;
                this.bodyFrame.Y = this.legFrame.Y;
            }
            else
            {
                this.bodyFrameCounter = 0.0;
                this.bodyFrame.Y = 0;
            }
        }

Usage Example

Example #1
0
 public static Player LoadPlayer(string playerPath)
 {
     bool flag = false;
     if (Main.rand == null)
     {
         Main.rand = new Random((int) DateTime.Now.Ticks);
     }
     Player player = new Player();
     try
     {
         string outputFile = playerPath + ".dat";
         flag = DecryptFile(playerPath, outputFile);
         if (!flag)
         {
             using (FileStream stream = new FileStream(outputFile, FileMode.Open))
             {
                 using (BinaryReader reader = new BinaryReader(stream))
                 {
                     reader.ReadInt32();
                     player.name = reader.ReadString();
                     player.hair = reader.ReadInt32();
                     player.statLife = reader.ReadInt32();
                     player.statLifeMax = reader.ReadInt32();
                     if (player.statLife > player.statLifeMax)
                     {
                         player.statLife = player.statLifeMax;
                     }
                     player.statMana = reader.ReadInt32();
                     player.statManaMax = reader.ReadInt32();
                     if (player.statMana > player.statManaMax)
                     {
                         player.statMana = player.statManaMax;
                     }
                     player.hairColor.R = reader.ReadByte();
                     player.hairColor.G = reader.ReadByte();
                     player.hairColor.B = reader.ReadByte();
                     player.skinColor.R = reader.ReadByte();
                     player.skinColor.G = reader.ReadByte();
                     player.skinColor.B = reader.ReadByte();
                     player.eyeColor.R = reader.ReadByte();
                     player.eyeColor.G = reader.ReadByte();
                     player.eyeColor.B = reader.ReadByte();
                     player.shirtColor.R = reader.ReadByte();
                     player.shirtColor.G = reader.ReadByte();
                     player.shirtColor.B = reader.ReadByte();
                     player.underShirtColor.R = reader.ReadByte();
                     player.underShirtColor.G = reader.ReadByte();
                     player.underShirtColor.B = reader.ReadByte();
                     player.pantsColor.R = reader.ReadByte();
                     player.pantsColor.G = reader.ReadByte();
                     player.pantsColor.B = reader.ReadByte();
                     player.shoeColor.R = reader.ReadByte();
                     player.shoeColor.G = reader.ReadByte();
                     player.shoeColor.B = reader.ReadByte();
                     for (int i = 0; i < 8; i++)
                     {
                         player.armor[i].SetDefaults(reader.ReadString());
                     }
                     for (int j = 0; j < 0x2c; j++)
                     {
                         player.inventory[j].SetDefaults(reader.ReadString());
                         player.inventory[j].stack = reader.ReadInt32();
                     }
                     for (int k = 0; k < Chest.maxItems; k++)
                     {
                         player.bank[k].SetDefaults(reader.ReadString());
                         player.bank[k].stack = reader.ReadInt32();
                     }
                     for (int m = 0; m < 200; m++)
                     {
                         int num5 = reader.ReadInt32();
                         if (num5 == -1)
                         {
                             break;
                         }
                         player.spX[m] = num5;
                         player.spY[m] = reader.ReadInt32();
                         player.spI[m] = reader.ReadInt32();
                         player.spN[m] = reader.ReadString();
                     }
                     reader.Close();
                 }
             }
             player.PlayerFrame();
             File.Delete(outputFile);
             return player;
         }
     }
     catch
     {
         flag = true;
     }
     if (flag)
     {
         string path = playerPath + ".bak";
         if (File.Exists(path))
         {
             File.Delete(playerPath);
             File.Move(path, playerPath);
             return LoadPlayer(playerPath);
         }
     }
     return new Player();
 }
All Usage Examples Of Terraria.Player::PlayerFrame
Player