////////////////

        /// <summary>
        /// Draws a player's head.
        /// </summary>
        /// <param name="sb">SpriteBatch to draw to. Typically `Main.spriteBatch`.</param>
        /// <param name="player"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="alpha"></param>
        /// <param name="scale"></param>
        public static void DrawPlayerHead(SpriteBatch sb, Player player, float x, float y, float alpha = 1f, float scale = 1f)
        {
            PlayerHeadDrawInfo drawInfo = new PlayerHeadDrawInfo {
                spriteBatch = sb,
                drawPlayer  = player,
                alpha       = alpha,
                scale       = scale
            };

            int   shaderId    = 0;
            int   skinVariant = player.skinVariant;
            short hairDye     = player.hairDye;

            if (player.head == 0 && hairDye == 0)
            {
                hairDye = 1;
            }
            drawInfo.hairShader = hairDye;

            if (player.face > 0 && player.face < 9)
            {
                PlayerHeadDrawHelpers.LoadAccFace((int)player.face);
            }
            if (player.dye[0] != null)
            {
                shaderId = player.dye[0].dye;
            }
            drawInfo.armorShader = shaderId;

            PlayerHeadDrawHelpers.LoadHair(player.hair);

            Color color = PlayerHeadDrawHelpers.QuickAlpha(Color.White, alpha);

            drawInfo.eyeWhiteColor = color;
            Color color2 = PlayerHeadDrawHelpers.QuickAlpha(player.eyeColor, alpha);

            drawInfo.eyeColor = color2;
            Color color3 = PlayerHeadDrawHelpers.QuickAlpha(player.GetHairColor(false), alpha);

            drawInfo.hairColor = color3;
            Color color4 = PlayerHeadDrawHelpers.QuickAlpha(player.skinColor, alpha);

            drawInfo.skinColor = color4;
            Color color5 = PlayerHeadDrawHelpers.QuickAlpha(Color.White, alpha);

            drawInfo.armorColor = color5;

            SpriteEffects spriteEffects = SpriteEffects.None;

            if (player.direction < 0)
            {
                spriteEffects = SpriteEffects.FlipHorizontally;
            }
            drawInfo.spriteEffects = spriteEffects;

            Vector2 drawOrigin = new Vector2(player.legFrame.Width * 0.5f, player.legFrame.Height * 0.4f);

            drawInfo.drawOrigin = drawOrigin;

            Vector2   position  = player.position;
            Rectangle bodyFrame = player.bodyFrame;

            player.bodyFrame.Y = 0;
            player.position    = Main.screenPosition;
            player.position.X  = player.position.X + x;
            player.position.Y  = player.position.Y + y;
            player.position.X  = player.position.X - 6f;
            player.position.Y  = player.position.Y - 4f;

            float headOffset = player.mount.PlayerHeadOffset;

            player.position.Y = player.position.Y - headOffset;

            if (player.head > 0 && player.head < 214)
            {
                PlayerHeadDrawHelpers.LoadArmorHead(player.head);
            }
            if (player.face > 0 && player.face < 9)
            {
                PlayerHeadDrawHelpers.LoadAccFace(player.face);
            }

            bool drawHair = false;

            if (player.head == 10 || player.head == 12 || player.head == 28 || player.head == 62 || player.head == 97 || player.head == 106 || player.head == 113 || player.head == 116 || player.head == 119 || player.head == 133 || player.head == 138 || player.head == 139 || player.head == 163 || player.head == 178 || player.head == 181 || player.head == 191 || player.head == 198)
            {
                drawHair = true;
            }
            bool drawAltHair = false;

            if (player.head == 161 || player.head == 14 || player.head == 15 || player.head == 16 || player.head == 18 || player.head == 21 || player.head == 24 || player.head == 25 || player.head == 26 || player.head == 40 || player.head == 44 || player.head == 51 || player.head == 56 || player.head == 59 || player.head == 60 || player.head == 67 || player.head == 68 || player.head == 69 || player.head == 114 || player.head == 121 || player.head == 126 || player.head == 130 || player.head == 136 || player.head == 140 || player.head == 145 || player.head == 158 || player.head == 159 || player.head == 184 || player.head == 190 || (double)player.head == 92.0 || player.head == 195)
            {
                drawAltHair = true;
            }
            ItemLoader.DrawHair(player, ref drawHair, ref drawAltHair);
            drawInfo.drawHair    = drawHair;
            drawInfo.drawAltHair = drawAltHair;
            List <PlayerHeadLayer> drawLayers = PlayerHooks.GetDrawHeadLayers(player);

            for (int i = 0; i < drawLayers.Count; i++)
            {
                if (drawLayers[i].ShouldDraw(drawLayers))
                {
                    PlayerHeadDrawHelpers.DrawCompleteLayer(player, drawLayers[i], ref position, ref bodyFrame, ref drawOrigin, ref drawInfo,
                                                            ref color, ref color2, ref color3, ref color4, ref color5, drawHair, drawAltHair,
                                                            shaderId, skinVariant, hairDye, scale, spriteEffects);
                }
            }
            PlayerHeadDrawHelpers.PostDrawLayer(player, ref position, ref bodyFrame);
        }
Пример #2
0
        public override void DrawEffects(PlayerDrawInfo drawinfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
        {
            PlayerHeadDrawInfo drawInfo = new PlayerHeadDrawInfo();

            drawInfo.spriteBatch = Main.spriteBatch;
            drawInfo.drawPlayer  = player;

            int radius = 72;

            if (/*thrown || */ canSpin)
            {
                degrees3 += 0.06f;                 // 0.017f = 1 degree displayed in radians
            }
            else
            {
                degrees3 = 0;
            }

            //	CurrentPoint = (Time - Depreciating) / Time;

            SpriteEffects effects       = SpriteEffects.None;
            Color         color         = player.GetImmuneAlpha(Lighting.GetColor((int)((double)player.position.X + (double)player.width * 0.5) / 16, (int)(((double)player.position.Y + (double)player.height * 0.25) / 16.0), Color.White), 0f);
            Vector2       Position      = player.position;
            Vector2       origin        = new Vector2((float)player.legFrame.Width * 0.5f, (float)player.legFrame.Height * 0.5f);
            Vector2       bodyPosition  = new Vector2((float)((int)(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2))), (float)((int)(player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f)));
            Vector2       wingsPosition = new Vector2((float)((int)(Position.X - Main.screenPosition.X + (float)(player.width / 2) - (float)(9 * player.direction)) + 0 * player.direction), (float)((int)(Position.Y - Main.screenPosition.Y + (float)(player.height / 2) + 2f * player.gravDir + (float)24 * player.gravDir)));

            float MoveX = origin.X + (float)(radius * Math.Cos(degrees3));
            float MoveY = origin.Y + (float)(radius * Math.Sin(degrees3));

            Item item = player.inventory[player.selectedItem];

            for (int i = 0; i < SwordID.swordTypes.Length; i++)
            {
                if (item.type == SwordID.swordTypes[i])
                {
                    swordTexture = Main.itemTexture[item.type];
                    break;
                }
            }
            if (canSpin)
            {
                Main.spriteBatch.Draw(swordTexture,
                                      bodyPosition + player.bodyPosition + new Vector2(MoveX, MoveY),
                                      null, Color.White, (degrees3 * 3) * (-1) + 0.48f, origin, 1f, effects, 0f);
            }
            if (drawBlink)
            {
                animate++;

                if (animate == 9)
                {
                    animate = 0;
                }
                if (animate == 0)
                {
                    frameHeight = 1;
                }
                else
                {
                    frameHeight = 52;
                }
                blinkTexture = mod.GetTexture("Gores/ShineSpark");
                if (drawRight)
                {
                    Main.spriteBatch.Draw(blinkTexture,
                                          bodyPosition + player.bodyPosition - new Vector2((player.width) * (-1), (player.height / 2 + 4) * (-1)),
                                          new Rectangle(0, animate * frameHeight, 50, 52), Color.White, 1.57f, origin, 1.2f, effects, 0f);
                }
                else if (drawLeft)
                {
                    effects = SpriteEffects.FlipVertically;
                    Main.spriteBatch.Draw(blinkTexture,
                                          bodyPosition + player.bodyPosition - new Vector2(-8, (player.height / 2 + 4) * (-1)),
                                          new Rectangle(0, animate * frameHeight, 50, 52), Color.White, 1.57f, origin, 1.2f, effects, 0f);
                }
            }
            if (angel)
            {
                GemTexture = Main.gemTexture[1];
                if (GemTexture != null)
                {
                    Main.spriteBatch.Draw(GemTexture,
                                          bodyPosition + player.bodyPosition + new Vector2(player.width + 2, -16),
                                          null, color, 0f, origin, 1f, effects, 0f);
                }
                player.wings = WingID.Angel;
            }
            else if (demon)
            {
                GemTexture = Main.gemTexture[4];
                if (GemTexture != null)
                {
                    Main.spriteBatch.Draw(GemTexture,
                                          bodyPosition + player.bodyPosition + new Vector2(player.width + 4, -16),
                                          null, color, 0f, origin, 1f, effects, 0f);
                }
                player.wings = WingID.Demon;
            }
            #region debug
            if (!disabled)
            {
                try
                {
                    if (KeyPress(Keys.Up) && WingID.Selected > 0)
                    {
                        WingID.Selected--;
                    }
                    if (KeyPress(Keys.Down))
                    {
                        WingID.Selected++;
                    }
                    if (KeyPress(Keys.F1) && !disabled)
                    {
                        int[] wings = new int[] { ItemID.AngelWings, ItemID.DemonWings };
                        for (int i = 0; i < 2; i++)
                        {
                            Item.NewItem(player.Center, Vector2.Zero, wings[i]);
                        }
                    }
                    if (KeyPress(Keys.F2))
                    {
                        Main.NewText(WingID.Selected);
                    }
                    player.wings = WingID.Selected;
                }
                catch
                {
                    return;
                }
            }
            #endregion
        }
        ////////////////

        private static void DrawCompleteLayer(Player player, PlayerHeadLayer drawLayer, ref Vector2 position, ref Rectangle bodyFrame, ref Vector2 drawOrigin, ref PlayerHeadDrawInfo drawInfo, ref Color color, ref Color color2, ref Color color3, ref Color color4, ref Color color5, bool drawHair, bool drawAltHair, int shaderId, int skinVariant, short hairDye, float scale, SpriteEffects spriteEffects)
        {
            if (drawLayer == PlayerHeadLayer.Head)
            {
                PlayerHeadDrawHelpers.DrawHeadLayer(player, skinVariant, ref drawOrigin, ref color4, ref color, ref color2, scale, spriteEffects);
            }
            else if (drawLayer == PlayerHeadLayer.Hair)
            {
                if (drawHair)
                {
                    PlayerHeadDrawHelpers.DrawHairLayer(player, shaderId, hairDye, ref color5, ref color3, ref drawOrigin, scale, spriteEffects);
                }
            }
            else if (drawLayer == PlayerHeadLayer.AltHair)
            {
                if (drawAltHair)
                {
                    PlayerHeadDrawHelpers.DrawAltHairLayer(player, hairDye, ref color3, ref drawOrigin, scale, spriteEffects);
                }
            }
            else if (drawLayer == PlayerHeadLayer.Armor)
            {
                PlayerHeadDrawHelpers.DrawArmorLayer(player, shaderId, hairDye, ref color3, ref color5, ref drawOrigin, scale, spriteEffects);
            }
            else if (drawLayer == PlayerHeadLayer.FaceAcc)
            {
                if (player.face > 0)
                {
                    PlayerHeadDrawHelpers.DrawFaceLayer(player, shaderId, ref color5, ref drawOrigin, scale, spriteEffects);
                }
            }
            else
            {
                drawLayer.Draw(ref drawInfo);
            }
        }
Пример #4
0
        public override void DrawEffects(PlayerDrawInfo drawinfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
        {
            PlayerHeadDrawInfo drawInfo = new PlayerHeadDrawInfo();

            drawInfo.spriteBatch = Main.spriteBatch;
            drawInfo.drawPlayer  = player;

            int radius = 72;

            if (/*thrown || */ canSpin)
            {
                degrees3 += 0.06f;                 // 0.017f = 1 degree displayed in radians
            }
            else
            {
                degrees3 = 0;
            }

            //	CurrentPoint = (Time - Depreciating) / Time;

            SpriteEffects effects       = SpriteEffects.None;
            Color         color         = player.GetImmuneAlpha(Lighting.GetColor((int)((double)player.position.X + (double)player.width * 0.5) / 16, (int)(((double)player.position.Y + (double)player.height * 0.25) / 16.0), Color.White), 0f);
            Vector2       Position      = player.position;
            Vector2       origin        = new Vector2((float)player.legFrame.Width * 0.5f, (float)player.legFrame.Height * 0.5f);
            Vector2       bodyPosition  = new Vector2((float)((int)(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2))), (float)((int)(player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f)));
            Vector2       wingsPosition = new Vector2((float)((int)(Position.X - Main.screenPosition.X + (float)(player.width / 2) - (float)(9 * player.direction)) + 0 * player.direction), (float)((int)(Position.Y - Main.screenPosition.Y + (float)(player.height / 2) + 2f * player.gravDir + (float)24 * player.gravDir)));

            float MoveX = origin.X + (float)(radius * Math.Cos(degrees3));
            float MoveY = origin.Y + (float)(radius * Math.Sin(degrees3));

            Item item = player.inventory[player.selectedItem];

            #region sword textures
            if (item.type == 46)            // light's bane
            {
                swordTexture = Main.itemTexture[46];
            }
            if (item.type == 121)            // fiery greatsword
            {
                swordTexture = Main.itemTexture[121];
            }
            if (item.type == 155)            // muramasa
            {
                swordTexture = Main.itemTexture[155];
            }
            if (item.type == 190)            // blade of grass
            {
                swordTexture = Main.itemTexture[190];
            }
            if (item.type == 273)            // night's edge
            {
                swordTexture = Main.itemTexture[273];
            }
            if (item.type == 368)            // excalibur
            {
                swordTexture = Main.itemTexture[368];
            }
            if (item.type == 484)            // adamantite sword
            {
                swordTexture = Main.itemTexture[484];
            }
            if (item.type == 485)            // cobalt sword
            {
                swordTexture = Main.itemTexture[485];
            }
            if (item.type == 486)            // mythril sword
            {
                swordTexture = Main.itemTexture[486];
            }
            if (item.type == 675)            // true night's edge
            {
                swordTexture = Main.itemTexture[675];
            }
            if (item.type == 723)            // beam sword
            {
                swordTexture = Main.itemTexture[723];
            }
            if (item.type == 989)            // enchanted sword
            {
                swordTexture = Main.itemTexture[989];
            }
            if (item.type == 1166)            // bone sword
            {
                swordTexture = Main.itemTexture[1166];
            }
            if (item.type == 1185)            // palladium sword
            {
                swordTexture = Main.itemTexture[1185];
            }
            if (item.type == 1192)            // orichalcum sword
            {
                swordTexture = Main.itemTexture[1192];
            }
            if (item.type == 1199)            // titanium sword
            {
                swordTexture = Main.itemTexture[1199];
            }
            #endregion
            if (canSpin)
            {
                Main.spriteBatch.Draw(swordTexture,
                                      bodyPosition + player.bodyPosition + new Vector2(MoveX, MoveY),
                                      null, Color.White, (degrees3 * 3) * (-1) + 0.48f, origin, 1f, effects, 0f);
            }
            if (drawBlink)
            {
                animate++;

                if (animate == 9)
                {
                    animate = 0;
                }
                if (animate == 0)
                {
                    frameHeight = 1;
                }
                else
                {
                    frameHeight = 52;
                }
                blinkTexture = mod.GetTexture("Gores/ShineSpark");
                if (drawRight)
                {
                    Main.spriteBatch.Draw(blinkTexture,
                                          bodyPosition + player.bodyPosition - new Vector2((player.width) * (-1), (player.height / 2 + 4) * (-1)),
                                          new Rectangle(0, animate * frameHeight, 50, 52), Color.White, 1.57f, origin, 1.2f, effects, 0f);
                }
                else if (drawLeft)
                {
                    effects = SpriteEffects.FlipVertically;
                    Main.spriteBatch.Draw(blinkTexture,
                                          bodyPosition + player.bodyPosition - new Vector2(-8, (player.height / 2 + 4) * (-1)),
                                          new Rectangle(0, animate * frameHeight, 50, 52), Color.White, 1.57f, origin, 1.2f, effects, 0f);
                }
            }
            if (angel)
            {
                GemTexture = Main.gemTexture[1];
                if (GemTexture != null)
                {
                    Main.spriteBatch.Draw(GemTexture,
                                          bodyPosition + player.bodyPosition + new Vector2(player.width + 2, -16),
                                          null, color, 0f, origin, 1f, effects, 0f);
                }
            }
            else if (demon)
            {
                GemTexture = Main.gemTexture[4];
                if (GemTexture != null)
                {
                    Main.spriteBatch.Draw(GemTexture,
                                          bodyPosition + player.bodyPosition + new Vector2(player.width + 4, -16),
                                          null, color, 0f, origin, 1f, effects, 0f);
                }
            }
        }