//////////////// /// <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); }