示例#1
0
 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)
     {
         PlayerHeadDisplayHelpers.DrawHeadLayer(player, skinVariant, ref drawOrigin, ref color4, ref color, ref color2, scale, spriteEffects);
     }
     else if (drawLayer == PlayerHeadLayer.Hair)
     {
         if (drawHair)
         {
             PlayerHeadDisplayHelpers.DrawHairLayer(player, shaderId, hairDye, ref color5, ref color3, ref drawOrigin, scale, spriteEffects);
         }
     }
     else if (drawLayer == PlayerHeadLayer.AltHair)
     {
         if (drawAltHair)
         {
             PlayerHeadDisplayHelpers.DrawAltHairLayer(player, hairDye, ref color3, ref drawOrigin, scale, spriteEffects);
         }
     }
     else if (drawLayer == PlayerHeadLayer.Armor)
     {
         PlayerHeadDisplayHelpers.DrawArmorLayer(player, shaderId, hairDye, ref color3, ref color5, ref drawOrigin, scale, spriteEffects);
     }
     else if (drawLayer == PlayerHeadLayer.FaceAcc)
     {
         if (player.face > 0)
         {
             PlayerHeadDisplayHelpers.DrawFaceLayer(player, shaderId, ref color5, ref drawOrigin, scale, spriteEffects);
         }
     }
     else
     {
         drawLayer.Draw(ref drawInfo);
     }
 }
示例#2
0
        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)
            {
                PlayerHeadDisplayHelpers.LoadAccFace((int)player.face);
            }
            if (player.dye[0] != null)
            {
                shaderId = player.dye[0].dye;
            }
            drawInfo.armorShader = shaderId;

            PlayerHeadDisplayHelpers.LoadHair(player.hair);

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

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

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

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

            drawInfo.skinColor = color4;
            Color color5 = PlayerHeadDisplayHelpers.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)
            {
                PlayerHeadDisplayHelpers.LoadArmorHead(player.head);
            }
            if (player.face > 0 && player.face < 9)
            {
                PlayerHeadDisplayHelpers.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 = Terraria.ModLoader.PlayerHooks.GetDrawHeadLayers(player);

            for (int i = 0; i < drawLayers.Count; i++)
            {
                if (drawLayers[i].ShouldDraw(drawLayers))
                {
                    PlayerHeadDisplayHelpers.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);
                }
            }
            PlayerHeadDisplayHelpers.PostDrawLayer(player, ref position, ref bodyFrame);
        }